Add the flea sound.

This commit is contained in:
Jeremy Rand 2020-12-22 01:00:10 -05:00
parent 2f3b04b306
commit d962e98368
12 changed files with 165 additions and 84 deletions

View File

@ -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.

View File

@ -94,6 +94,7 @@
9D62AF3B249871A300348F45 /* colour.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = colour.s; sourceTree = "<group>"; };
9D62AF3F2499CD1E00348F45 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
9D6DB0AE2591A67700CDBF05 /* flea.raw */ = {isa = PBXFileReference; lastKnownFileType = file; path = flea.raw; sourceTree = "<group>"; };
9D8AF0B72535542400C10E3C /* level.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = level.s; sourceTree = "<group>"; };
9D8AF0B82535543000C10E3C /* score.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = score.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; };
@ -124,6 +125,7 @@
isa = PBXGroup;
children = (
9D1553EA257F3E5200657188 /* bonus.raw */,
9D6DB0AE2591A67700CDBF05 /* flea.raw */,
9D0DC8EF258C715E00DE9E87 /* extralife.raw */,
9D1553EB257F3E5200657188 /* death.raw */,
9D1553E9257F3E5200657188 /* fire.raw */,

View File

@ -7,7 +7,7 @@
<key>Binary.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<key>BuGS.xcscheme_^#shared#^_</key>
<dict>
@ -22,7 +22,7 @@
<key>doNotBuild.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>2</integer>
</dict>
</dict>
</dict>

View File

@ -73,6 +73,7 @@ gameLoop anop
jsl updateFlea
jsl updateSegments
jsl updateLevel
jsl updateSounds
jsl checkKeyboard

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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_) */

View File

@ -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";

BIN
BuGS/sound/flea.raw Normal file

Binary file not shown.