From d962e98368b38b626292192fdfbbe2078aa35005 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Tue, 22 Dec 2020 01:00:10 -0500 Subject: [PATCH] Add the flea sound. --- ACKNOWLEDGEMENTS.md | 2 +- BuGS.xcodeproj/project.pbxproj | 2 + .../xcschemes/xcschememanagement.plist | 4 +- BuGS/game.s | 1 + BuGS/gameFlea.s | 4 + BuGS/gameSound.s | 195 +++++++++++------- BuGS/gameSpider.s | 2 +- BuGS/genData.pl | 16 ++ BuGS/main.c | 9 + BuGS/main.h | 13 +- BuGS/main.rez | 1 + BuGS/sound/flea.raw | Bin 0 -> 256 bytes 12 files changed, 165 insertions(+), 84 deletions(-) create mode 100644 BuGS/sound/flea.raw diff --git a/ACKNOWLEDGEMENTS.md b/ACKNOWLEDGEMENTS.md index 90cb0d6..e15b389 100644 --- a/ACKNOWLEDGEMENTS.md +++ b/ACKNOWLEDGEMENTS.md @@ -1,6 +1,6 @@ # Acknowledgements -This project would not have been a success without help from the Apple // community, especiall the appleiigs slack channel where I got tons of help and encouragement. I have to thank some people for their support, help, contribution of code and other materials that helped make BuGS possible. Please know that if your name is missing, that is my fault. I should have been keeping track of this early on but I find myself writing this in the later days of the project and I am almost certainly going to make a mistake. I apologize if I have left you off and I would encourage you to contact me and help me correct my mistake. +This project would not have been a success without help from the Apple // community, especially the appleiigs slack channel where I got tons of help and encouragement. I have to thank some people for their support, help, contribution of code and other materials that helped make BuGS possible. Please know that if your name is missing, that is my fault. I should have been keeping track of this early on but I find myself writing this in the later days of the project and I am almost certainly going to make a mistake. I apologize if I have left you off and I would encourage you to contact me and help me correct my mistake. * @fatdog on slack who provided multiple sound samples for the game including the spider, flea and the beat sound. * Mark Collins who pointed me to a source of sound effects and information on how to convert digital sound into a format that would work on the GS. diff --git a/BuGS.xcodeproj/project.pbxproj b/BuGS.xcodeproj/project.pbxproj index 5126615..a9b1068 100644 --- a/BuGS.xcodeproj/project.pbxproj +++ b/BuGS.xcodeproj/project.pbxproj @@ -94,6 +94,7 @@ 9D62AF3B249871A300348F45 /* colour.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = colour.s; sourceTree = ""; }; 9D62AF3F2499CD1E00348F45 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 9D6DB0AE2591A67700CDBF05 /* flea.raw */ = {isa = PBXFileReference; lastKnownFileType = file; path = flea.raw; sourceTree = ""; }; 9D8AF0B72535542400C10E3C /* level.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = level.s; sourceTree = ""; }; 9D8AF0B82535543000C10E3C /* score.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = score.s; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; 9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = ""; }; @@ -124,6 +125,7 @@ isa = PBXGroup; children = ( 9D1553EA257F3E5200657188 /* bonus.raw */, + 9D6DB0AE2591A67700CDBF05 /* flea.raw */, 9D0DC8EF258C715E00DE9E87 /* extralife.raw */, 9D1553EB257F3E5200657188 /* death.raw */, 9D1553E9257F3E5200657188 /* fire.raw */, diff --git a/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist b/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist index 2596fb4..0d0faee 100644 --- a/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/BuGS.xcodeproj/xcuserdata/jrand.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ Binary.xcscheme_^#shared#^_ orderHint - 2 + 3 BuGS.xcscheme_^#shared#^_ @@ -22,7 +22,7 @@ doNotBuild.xcscheme_^#shared#^_ orderHint - 3 + 2 diff --git a/BuGS/game.s b/BuGS/game.s index 1b0eb8d..6734e7c 100644 --- a/BuGS/game.s +++ b/BuGS/game.s @@ -73,6 +73,7 @@ gameLoop anop jsl updateFlea jsl updateSegments jsl updateLevel + jsl updateSounds jsl checkKeyboard diff --git a/BuGS/gameFlea.s b/BuGS/gameFlea.s index bd93331..7587e12 100644 --- a/BuGS/gameFlea.s +++ b/BuGS/gameFlea.s @@ -91,6 +91,7 @@ updateFlea_playerOnscreen anop rtl updateFlea_explosionDone anop + jsl stopFleaSound stz fleaState rtl @@ -182,6 +183,7 @@ updateFlea_nextTile anop bra updateFlea_nextAction updateFlea_bottom anop + jsl stopFleaSound stz fleaState rtl @@ -208,6 +210,7 @@ addFlea_fast anop lda #SPRITE_SPEED_FAST addFlea_setSpeed anop jsl setFleaSpeed + jsl startFleaSound lda #FLEA_STATE_FALLING sta fleaState @@ -314,6 +317,7 @@ explodeFlea entry lda #EXPLOSION_LAST_OFFSET sta fleaSprite + jsl stopFleaSound rtl diff --git a/BuGS/gameSound.s b/BuGS/gameSound.s index cd9043f..f946f85 100644 --- a/BuGS/gameSound.s +++ b/BuGS/gameSound.s @@ -82,6 +82,13 @@ FIRE_VOLUME equ 255 FIRE_CONTROL equ 2 FIRE_SIZE equ $1b +FLEA_SOUND_ADDR equ $3a00 +FLEA_OSC_NUM equ 12 +FLEA_VOLUME equ 255 +FLEA_CONTROL equ 6 +FLEA_SIZE equ $00 +FLEA_FRAME_COUNT equ 5 + ; X register has the address of the register to read ; Accumulator contains the result of the read @@ -104,7 +111,24 @@ writeSoundReg_jslInst anop long m rtl - +; X register has the address of the register to write +; Accumulator has the value to write +writeConsecSoundReg entry + and #$ff + short m + pha + phx +writeConsecSoundReg_jslInst1 anop + jsl writeSoundReg + plx + inx + pla +writeConsecSoundReg_jslInst2 anop + jsl writeSoundReg + long m + rtl + + soundInit entry ; jsl loadSounds @@ -139,6 +163,8 @@ soundInit_readRegHigh anop soundInit_writeRegHigh anop lda >soundInit sta writeSoundReg_jslInst+3 + sta writeConsecSoundReg_jslInst1+3 + sta writeConsecSoundReg_jslInst2+3 long m soundInit_readRegLow anop @@ -148,6 +174,8 @@ soundInit_readRegLow anop soundInit_writeRegLow anop lda >soundInit sta writeSoundReg_jslInst+1 + sta writeConsecSoundReg_jslInst1+1 + sta writeConsecSoundReg_jslInst2+1 ; Spider sound @@ -156,51 +184,27 @@ soundInit_writeRegLow anop lda #SPIDER_FREQ_LOW ldx #SOUND_REG_FREQ_LOW+SPIDER_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SPIDER_FREQ_HIGH ldx #SOUND_REG_FREQ_HIGH+SPIDER_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SPIDER_VOLUME ldx #SOUND_REG_VOLUME+SPIDER_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SPIDER_SIZE ldx #SOUND_REG_SIZE+SPIDER_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SPIDER_SOUND_ADDR/256 ldx #SOUND_REG_POINTER+SPIDER_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SPIDER_CONTROL+SOUND_HALTED ldx #SOUND_REG_CONTROL+SPIDER_OSC_NUM - jsl writeSoundReg - - lda #SPIDER_FREQ_LOW - ldx #SOUND_REG_FREQ_LOW+SPIDER_OSC_NUM+1 - jsl writeSoundReg - - lda #SPIDER_FREQ_HIGH - ldx #SOUND_REG_FREQ_HIGH+SPIDER_OSC_NUM+1 - jsl writeSoundReg - - lda #SPIDER_VOLUME - ldx #SOUND_REG_VOLUME+SPIDER_OSC_NUM+1 - jsl writeSoundReg - - lda #SPIDER_SIZE - ldx #SOUND_REG_SIZE+SPIDER_OSC_NUM+1 - jsl writeSoundReg - - lda #SPIDER_SOUND_ADDR/256 - ldx #SOUND_REG_POINTER+SPIDER_OSC_NUM+1 - jsl writeSoundReg - - lda #SPIDER_CONTROL+SOUND_HALTED - ldx #SOUND_REG_CONTROL+SPIDER_OSC_NUM+1 - jsl writeSoundReg + jsl writeConsecSoundReg ; Death sound @@ -238,51 +242,27 @@ soundInit_writeRegLow anop lda #SEGMENTS_FREQ_LOW ldx #SOUND_REG_FREQ_LOW+SEGMENTS_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SEGMENTS_FREQ_HIGH ldx #SOUND_REG_FREQ_HIGH+SEGMENTS_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SEGMENTS_VOLUME ldx #SOUND_REG_VOLUME+SEGMENTS_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SEGMENTS_SIZE ldx #SOUND_REG_SIZE+SEGMENTS_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SEGMENTS_SOUND_ADDR/256 ldx #SOUND_REG_POINTER+SEGMENTS_OSC_NUM - jsl writeSoundReg + jsl writeConsecSoundReg lda #SEGMENTS_CONTROL+SOUND_HALTED ldx #SOUND_REG_CONTROL+SEGMENTS_OSC_NUM - jsl writeSoundReg - - lda #SEGMENTS_FREQ_LOW - ldx #SOUND_REG_FREQ_LOW+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg - - lda #SEGMENTS_FREQ_HIGH - ldx #SOUND_REG_FREQ_HIGH+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg - - lda #SEGMENTS_VOLUME - ldx #SOUND_REG_VOLUME+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg - - lda #SEGMENTS_SIZE - ldx #SOUND_REG_SIZE+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg - - lda #SEGMENTS_SOUND_ADDR/256 - ldx #SOUND_REG_POINTER+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg - - lda #SEGMENTS_CONTROL+SOUND_HALTED - ldx #SOUND_REG_CONTROL+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg + jsl writeConsecSoundReg ; Bonus sound @@ -446,11 +426,57 @@ soundInit_writeRegLow anop ldx #SOUND_REG_CONTROL+EXTRA_LIFE_OSC_NUM jsl writeSoundReg +; Flea sound + pea FLEA_SOUND_ADDR + jsl loadFleaSound + + lda #FLEA_VOLUME + ldx #SOUND_REG_VOLUME+FLEA_OSC_NUM + jsl writeConsecSoundReg + + lda #FLEA_SIZE + ldx #SOUND_REG_SIZE+FLEA_OSC_NUM + jsl writeConsecSoundReg + + lda #FLEA_SOUND_ADDR/256 + ldx #SOUND_REG_POINTER+FLEA_OSC_NUM + jsl writeConsecSoundReg + + lda #FLEA_CONTROL+SOUND_HALTED + ldx #SOUND_REG_CONTROL+FLEA_OSC_NUM + jsl writeConsecSoundReg + rtl updateSounds entry -; Write this code... + lda gameRunning + bne updateSounds_done + lda fleaSoundIsPlaying + bne updateSounds_done + +updateSounds_changeFreq anop + ldy fleaSoundFreqOffset + cpy #NUM_FLEA_FREQS*2 + blt updateSounds_notDone + jmp stopFleaSound +updateSounds_notDone anop + lda #FLEA_FRAME_COUNT + sta fleaSoundFrame + iny + iny + sty fleaSoundFreqOffset + + lda fleaFreqs,y + ldx #SOUND_REG_FREQ_LOW+FLEA_OSC_NUM + jsl writeConsecSoundReg + + ldy fleaSoundFreqOffset + lda fleaFreqs+1,y + ldx #SOUND_REG_FREQ_HIGH+FLEA_OSC_NUM + jsl writeConsecSoundReg + +updateSounds_done anop rtl @@ -535,11 +561,7 @@ startSegmentSound entry stopSegmentSound entry lda #SEGMENTS_CONTROL+SOUND_HALTED ldx #SOUND_REG_CONTROL+SEGMENTS_OSC_NUM - jsl writeSoundReg - - lda #SEGMENTS_CONTROL+SOUND_HALTED - ldx #SOUND_REG_CONTROL+SEGMENTS_OSC_NUM+1 - jsl writeSoundReg + jsl writeConsecSoundReg rtl @@ -556,11 +578,7 @@ startSpiderSound entry stopSpiderSound entry lda #SPIDER_CONTROL+SOUND_HALTED ldx #SOUND_REG_CONTROL+SPIDER_OSC_NUM - jsl writeSoundReg - - lda #SPIDER_CONTROL+SOUND_HALTED - ldx #SOUND_REG_CONTROL+SPIDER_OSC_NUM+1 - jsl writeSoundReg + jsl writeConsecSoundReg rtl @@ -576,16 +594,45 @@ stopScorpionSound entry startFleaSound entry -; Write this code... + lda fleaSoundIsPlaying + bne startFleaSound_doIt + rtl + +startFleaSound_doIt anop + stz fleaSoundIsPlaying + stz fleaSoundFreqOffset + + lda #FLEA_FRAME_COUNT + sta fleaSoundFrame + + lda fleaFreqs + ldx #SOUND_REG_FREQ_LOW+FLEA_OSC_NUM + jsl writeConsecSoundReg + + lda fleaFreqs+1 + ldx #SOUND_REG_FREQ_HIGH+FLEA_OSC_NUM + jsl writeConsecSoundReg + + lda #FLEA_CONTROL + ldx #SOUND_REG_CONTROL+FLEA_OSC_NUM + jsl writeSoundReg rtl stopFleaSound entry -; Write this code... + lda #FLEA_CONTROL+SOUND_HALTED + ldx #SOUND_REG_CONTROL+FLEA_OSC_NUM + jsl writeConsecSoundReg + + lda #1 + sta fleaSoundIsPlaying rtl bonusSoundOscReg dc i2'SOUND_REG_CONTROL+BONUS_OSC_NUM' soundTableAddr dc i4'0' +fleaSoundIsPlaying dc i2'1' +fleaSoundFreqOffset dc i2'0' +fleaSoundFrame dc i2'0' end diff --git a/BuGS/gameSpider.s b/BuGS/gameSpider.s index 957a02f..c9e6a5e 100644 --- a/BuGS/gameSpider.s +++ b/BuGS/gameSpider.s @@ -143,7 +143,7 @@ updateSpider entry cmp #PLAYER_STATE_ONSCREEN beq updateSpider_cont ldx spiderState - cmp #SPIDER_STATE_EXPLODING + cpx #SPIDER_STATE_EXPLODING beq updateSpider_testState rtl updateSpider_cont anop diff --git a/BuGS/genData.pl b/BuGS/genData.pl index 90b2d23..908f15b 100755 --- a/BuGS/genData.pl +++ b/BuGS/genData.pl @@ -81,6 +81,7 @@ $gEquates{"P2_LIVES_OFFSET"} = ($gEquates{"LHS_FIRST_TILE"} + ($gEquates{"LHS_NU $gEquates{"HIGH_SCORE_ONES_OFFSET"} = ($gEquates{"LHS_FIRST_TILE"} + ($gEquates{"LHS_NUM_TILES_WIDE"} * 13) + ($gEquates{"LHS_NUM_TILES_WIDE"} - 2)) * $gEquates{"SIZEOF_TILE_INFO"}; +$gEquates{"NUM_FLEA_FREQS"} = 80; our @gTileDirty = ("TILE_STATE_CLEAN") x $gEquates{"TOTAL_NUM_TILES"}; our @gTileScreenOffset = (0) x $gEquates{"TOTAL_NUM_TILES"}; @@ -94,6 +95,8 @@ our @gTileBitMask = (0) x $gEquates{"NUM_GAME_TILES"}; our @gDirtyNonGameTiles = ("INVALID_TILE_NUM") x $gEquates{"NUM_NON_GAME_TILES"}; our $gNumDirtyNonGameTiles = 0; +our @gFleaFreqs = (0) x $gEquates{"NUM_FLEA_FREQS"}; + our @gMouseYAddress = (0) x $gEquates{"MOUSE_MAX_Y"}; our @gMouseYTileAbove = (0) x $gEquates{"MOUSE_MAX_Y"}; our @gMouseYTileBelow = (0) x $gEquates{"MOUSE_MAX_Y"}; @@ -458,8 +461,20 @@ sub initNonGameTiles } +sub initFleaFreqs +{ + $gFleaFreqs[0] = (197 * 256 * 32) / ( 2 * 1645); + + for (my $i = 1; $i < $gEquates{"NUM_FLEA_FREQS"}; $i++) + { + $gFleaFreqs[$i] = ($gFleaFreqs[$i - 1] * 100000000) / 101161944; + } +} + + initTiles(); initNonGameTiles(); +initFleaFreqs(); # Generate the tileData.s file open my $fh, ">", "$gGenDir/tileData.s" or die "$0: Unable to open $gGenDir/tileData.s for writing, $!"; @@ -489,6 +504,7 @@ printTileData($fh, "tileRight", @gTileRight); printTileData($fh, "tileBitOffset", @gTileBitOffset); printTileData($fh, "tileBitMask", @gTileBitMask); printTileData($fh, "dirtyNonGameTiles", @gDirtyNonGameTiles); +printTileData($fh, "fleaFreqs", @gFleaFreqs); printTileData($fh, "mouseYAddress", @gMouseYAddress); printTileData($fh, "mouseYTileAbove", @gMouseYTileAbove); printTileData($fh, "mouseYTileBelow", @gMouseYTileBelow); diff --git a/BuGS/main.c b/BuGS/main.c index b7415cf..4c905cb 100644 --- a/BuGS/main.c +++ b/BuGS/main.c @@ -109,6 +109,15 @@ void loadExtraLifeSound(word addr) } +void loadFleaSound(word addr) +{ + Handle handle = LoadResource(rRawSound, FLEA_SOUND); + HLock(handle); + WriteRamBlock(*handle, addr, GetHandleSize(handle)); + HUnlock(handle); +} + + int main(void) { int event; diff --git a/BuGS/main.h b/BuGS/main.h index 2855d21..38bf0f6 100644 --- a/BuGS/main.h +++ b/BuGS/main.h @@ -18,12 +18,13 @@ /* Sounds */ #define rRawSound 1 #define BONUS_SOUND 1 -#define DEATH_SOUND 4 -#define FIRE_SOUND 5 -#define KILL_SOUND 6 -#define SEGMENTS_SOUND 7 -#define SPIDER_SOUND 8 -#define EXTRA_LIFE_SOUND 9 +#define DEATH_SOUND 2 +#define FIRE_SOUND 3 +#define KILL_SOUND 4 +#define SEGMENTS_SOUND 5 +#define SPIDER_SOUND 6 +#define EXTRA_LIFE_SOUND 7 +#define FLEA_SOUND 8 #endif /* defined(_GUARD_PROJECTBuGS_FILEmain_) */ diff --git a/BuGS/main.rez b/BuGS/main.rez index 05c693b..2fe97bc 100644 --- a/BuGS/main.rez +++ b/BuGS/main.rez @@ -55,3 +55,4 @@ read rRawSound (KILL_SOUND) "sound/kill.raw"; read rRawSound (SEGMENTS_SOUND) "sound/segments.raw"; read rRawSound (SPIDER_SOUND) "sound/spider.raw"; read rRawSound (EXTRA_LIFE_SOUND) "sound/extralife.raw"; +read rRawSound (FLEA_SOUND) "sound/flea.raw"; diff --git a/BuGS/sound/flea.raw b/BuGS/sound/flea.raw new file mode 100644 index 0000000000000000000000000000000000000000..733b391e1804ff6af77abdb8ca4292154c1d0d79 GIT binary patch literal 256 zcmZ9C(Gh?!2t!@3U^mhqx6w~}*!2vg)jM-EFQk}RYt2$X43Wehf2d-ZcuT)F`AMaS zs7O%|ia1Z+Fbk36hCD31XMnrII*`R|QG7d+-{-y#DHxA7%2;c*2&C4^8)A6?9{Yat literal 0 HcmV?d00001