mirror of
https://github.com/jeremysrand/BuGS.git
synced 2024-10-17 10:23:54 +00:00
Implement the code to add the flea at the right time. This includes tracking the score in multiples of 20,000 and adjusting the number of mushrooms required in the infield before a flea will appear. Simplify the other score based thresholds which are based on multiples of 20,000 to use this test. Add debug which allows me to add 20,000 to the score whenever I want so I can test these thresholds more easily.
This commit is contained in:
parent
bb1cd9b7ba
commit
96a6b6f51f
@ -7,7 +7,7 @@
|
||||
<key>Binary.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>BuGS.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
@ -17,12 +17,12 @@
|
||||
<key>DiskImage.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>3</integer>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>doNotBuild.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
24
BuGS/game.s
24
BuGS/game.s
@ -162,6 +162,10 @@ drawTile entry
|
||||
jumpInst jmp >mushroom1
|
||||
nop
|
||||
|
||||
addPlayer entry
|
||||
; TODO - Write code to add a new life.
|
||||
rtl
|
||||
|
||||
|
||||
setupScreen entry
|
||||
short i,m
|
||||
@ -229,7 +233,7 @@ checkKey_loop2 anop
|
||||
beq checkKey_quit
|
||||
|
||||
cmp #'f'
|
||||
beq checkKey_addFlea
|
||||
beq checkKey_shootFlea
|
||||
cmp #'F'
|
||||
beq checkKey_shootFlea
|
||||
|
||||
@ -244,9 +248,7 @@ checkKey_loop2 anop
|
||||
beq checkKey_shootSpider
|
||||
|
||||
cmp #'+'
|
||||
beq checkKey_fast
|
||||
cmp #'-'
|
||||
beq checkKey_slow
|
||||
beq checkKey_scoreAdd
|
||||
|
||||
cmp #'g'
|
||||
beq checkKey_game
|
||||
@ -259,9 +261,6 @@ checkKey_loop2 anop
|
||||
checkKey_done anop
|
||||
rtl
|
||||
|
||||
checkKey_addFlea anop
|
||||
jmp addFlea
|
||||
|
||||
checkKey_shootFlea anop
|
||||
jmp shootFlea
|
||||
|
||||
@ -274,18 +273,13 @@ checkKey_shootSpider anop
|
||||
checkKey_shootCentipede anop
|
||||
jmp shootRandomSegment
|
||||
|
||||
checkKey_scoreAdd anop
|
||||
jmp scoreAddTwentyThousand
|
||||
|
||||
checkKey_quit anop
|
||||
stz shouldQuit
|
||||
rtl
|
||||
|
||||
checkKey_fast anop
|
||||
lda #SPRITE_SPEED_FAST
|
||||
jsl setFleaSpeed
|
||||
|
||||
checkKey_slow anop
|
||||
lda #SPRITE_SPEED_SLOW
|
||||
jsl setFleaSpeed
|
||||
|
||||
checkKey_game anop
|
||||
jmp startGame
|
||||
|
||||
|
@ -64,11 +64,10 @@ jumpInst jmp >flea1
|
||||
|
||||
updateFlea entry
|
||||
lda fleaState
|
||||
bne updateFlea_cont
|
||||
beq updateFlea_maybeAdd
|
||||
|
||||
updateFlea_cont anop
|
||||
cmp #FLEA_STATE_FALLING
|
||||
beq updateFlea_cont2
|
||||
beq updateFlea_cont
|
||||
|
||||
; Handle explosion
|
||||
lda fleaSprite
|
||||
@ -82,7 +81,38 @@ updateFlea_explosionDone anop
|
||||
stz fleaState
|
||||
rtl
|
||||
|
||||
updateFlea_cont2 anop
|
||||
updateFlea_maybeAdd anop
|
||||
lda gameRunning
|
||||
bne updateFlea_doNotAdd
|
||||
lda gameLevel
|
||||
beq updateFlea_doNotAdd
|
||||
lda scoreNum20000
|
||||
bne updateFlea_moreThan20000
|
||||
; Below 20000 points, 5 or more mushrooms do not result in a flea
|
||||
lda #4
|
||||
bra updateFlea_checkNumMushrooms
|
||||
updateFlea_moreThan20000 anop
|
||||
cmp #6
|
||||
bge updateFlea_moreThan120000
|
||||
; Between 20000 and 120000, 9 or more mushrooms do not result in a flea
|
||||
lda #8
|
||||
bra updateFlea_checkNumMushrooms
|
||||
updateFlea_moreThan120000 anop
|
||||
; Above 120000, 15 or more mushrooms do not result in a flea and for every
|
||||
; 20000 more points, this goes up by 1 more mushroom. So, the accumulator
|
||||
; has 6 in it for scores from 120000 to 139999. Add 8 to that to get 14
|
||||
; which is the threshold at which fleas appear.
|
||||
clc
|
||||
adc #8
|
||||
updateFlea_checkNumMushrooms anop
|
||||
cmp numInfieldMushrooms
|
||||
blt updateFlea_doNotAdd
|
||||
jmp addFlea
|
||||
|
||||
updateFlea_doNotAdd anop
|
||||
rtl
|
||||
|
||||
updateFlea_cont anop
|
||||
lda fleaHeightInTile
|
||||
beq updateFlea_nextTile
|
||||
dec a
|
||||
@ -133,7 +163,9 @@ updateFlea_nextTile anop
|
||||
bne updateFlea_nextAction
|
||||
lda #TILE_MUSHROOM4
|
||||
sta tileType,x
|
||||
|
||||
cpx #SPIDER_TOP_ROW_OFFSET
|
||||
blt updateFlea_nextAction
|
||||
inc numInfieldMushrooms
|
||||
bra updateFlea_nextAction
|
||||
|
||||
updateFlea_bottom anop
|
||||
@ -156,7 +188,15 @@ addFlea entry
|
||||
lda fleaState
|
||||
bne addFlea_done
|
||||
|
||||
lda fleaSpriteSpeed
|
||||
lda scoreNum20000
|
||||
cmp #3
|
||||
bge addFlea_fast
|
||||
lda #SEGMENT_SPEED_SLOW
|
||||
bra addFlea_setSpeed
|
||||
addFlea_fast anop
|
||||
lda #SEGMENT_SPEED_FAST
|
||||
addFlea_setSpeed anop
|
||||
sta fleaSpriteSpeed
|
||||
jsl setFleaSpeed
|
||||
|
||||
lda #FLEA_STATE_FALLING
|
||||
|
@ -245,11 +245,8 @@ addScorpion entry
|
||||
rtl
|
||||
|
||||
addScorpion_doit anop
|
||||
lda gameScore+2
|
||||
lda scoreNum20000
|
||||
bne addScorpion_randomSpeed
|
||||
lda gameScore
|
||||
cmp #20000
|
||||
bge addScorpion_randomSpeed
|
||||
addScorpion_slow anop
|
||||
lda #SPRITE_SPEED_SLOW
|
||||
bra addScorpion_setSpeed
|
||||
|
@ -1687,14 +1687,17 @@ shootSegment_doneScore anop
|
||||
bge shootSegment_skipMushroom
|
||||
tay
|
||||
lda tileType,y
|
||||
beq shootSegment_normalMushroom
|
||||
beq shootSegment_noMushroom
|
||||
cmp #TILE_POISON_MUSHROOM1
|
||||
bge shootSegment_poisonMushroom
|
||||
blt shootSegment_normalMushroom
|
||||
lda #TILE_POISON_MUSHROOM4
|
||||
bra shootSegment_dirtyTile
|
||||
shootSegment_noMushroom anop
|
||||
cpy #SPIDER_TOP_ROW_OFFSET
|
||||
blt shootSegment_normalMushroom
|
||||
inc numInfieldMushrooms
|
||||
shootSegment_normalMushroom anop
|
||||
lda #TILE_MUSHROOM4
|
||||
bra shootSegment_dirtyTile
|
||||
shootSegment_poisonMushroom anop
|
||||
lda #TILE_POISON_MUSHROOM4
|
||||
shootSegment_dirtyTile anop
|
||||
sta tileType,y
|
||||
lda #TILE_STATE_DIRTY
|
||||
|
@ -26,10 +26,6 @@ SPIDER_STATE_RIGHT_DOWN equ 9
|
||||
SPIDER_STATE_RIGHT_UP equ 10
|
||||
|
||||
|
||||
; A spider only travels in the bottom N rows. This defines that number.
|
||||
SPIDER_NUM_POSSIBLE_ROWS equ 10
|
||||
SPIDER_TOP_ROW equ GAME_NUM_TILES_TALL-SPIDER_NUM_POSSIBLE_ROWS
|
||||
SPIDER_TOP_ROW_OFFSET equ SPIDER_TOP_ROW*GAME_NUM_TILES_WIDE*SIZEOF_TILE_INFO
|
||||
SPIDER_LHS_TILE_OFFSET equ SPIDER_TOP_ROW_OFFSET
|
||||
SPIDER_RHS_TILE_OFFSET equ SPIDER_TOP_ROW_OFFSET+(GAME_NUM_TILES_WIDE-1)*SIZEOF_TILE_INFO
|
||||
|
||||
@ -422,6 +418,9 @@ updateSpider_tilesUp anop
|
||||
beq updateSpider_tilesUpCont
|
||||
lda #TILE_EMPTY
|
||||
sta tileType,x
|
||||
cpx #SPIDER_TOP_ROW_OFFSET
|
||||
blt updateSpider_tilesUpCont
|
||||
dec numInfieldMushrooms
|
||||
|
||||
updateSpider_tilesUpCont anop
|
||||
ldx spiderTileOffsets+10
|
||||
@ -494,6 +493,9 @@ updateSpider_tilesDown anop
|
||||
beq updateSpider_tilesDownCont
|
||||
lda #TILE_EMPTY
|
||||
sta tileType,x
|
||||
cpx #SPIDER_TOP_ROW_OFFSET
|
||||
blt updateSpider_tilesDownCont
|
||||
dec numInfieldMushrooms
|
||||
|
||||
updateSpider_tilesDownCont anop
|
||||
ldx spiderTileOffsets+8
|
||||
|
@ -138,3 +138,38 @@ _dirtyGameTile_skip&SYSCNT anop
|
||||
|
||||
_dirtyNonGameTile_skip&SYSCNT anop
|
||||
mend
|
||||
|
||||
|
||||
; Update the score
|
||||
macro
|
||||
_incrementScore &increment
|
||||
lda #&increment
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc _incrementScore_noCarry&SYSCNT
|
||||
inc gameScore+2
|
||||
_incrementScore_noCarry&SYSCNT anop
|
||||
lda #&increment
|
||||
clc
|
||||
adc scoreWithin12000
|
||||
cmp #12000
|
||||
blt _incrementScore_noExtraMan&SYSCNT
|
||||
sec
|
||||
sbc #12000
|
||||
pha
|
||||
jsl addPlayer
|
||||
pla
|
||||
_incrementScore_noExtraMan&SYSCNT anop
|
||||
sta scoreWithin12000
|
||||
lda #&increment
|
||||
clc
|
||||
adc scoreWithin20000
|
||||
cmp #20000
|
||||
blt _incrementScore_no2000&SYSCNT
|
||||
sec
|
||||
sbc #20000
|
||||
inc scoreNum20000
|
||||
_incrementScore_no2000&SYSCNT anop
|
||||
sta scoreWithin20000
|
||||
mend
|
||||
|
@ -28,6 +28,11 @@ SEGMENT_DIR_RIGHT equ 1
|
||||
SEGMENT_SPEED_FAST equ 0
|
||||
SEGMENT_SPEED_SLOW equ 1
|
||||
|
||||
; A spider only travels in the bottom N rows. This defines that number.
|
||||
SPIDER_NUM_POSSIBLE_ROWS equ 10
|
||||
SPIDER_TOP_ROW equ GAME_NUM_TILES_TALL-SPIDER_NUM_POSSIBLE_ROWS
|
||||
SPIDER_TOP_ROW_OFFSET equ SPIDER_TOP_ROW*GAME_NUM_TILES_WIDE*SIZEOF_TILE_INFO
|
||||
|
||||
SCREEN_BYTES_PER_ROW gequ 160
|
||||
|
||||
SIZEOF_TILE_INFO gequ 2
|
||||
@ -140,6 +145,7 @@ gameRunning dc i2'1'
|
||||
numSegments dc i2'0'
|
||||
gameLevel dc i2'0'
|
||||
gameScore dc i4'0'
|
||||
scoreNum20000 dc i2'0'
|
||||
|
||||
backupStack dc i2'0'
|
||||
|
||||
|
@ -95,10 +95,8 @@ levelNext_skip anop
|
||||
sta colourLevelNum
|
||||
inc gameLevel
|
||||
|
||||
lda gameScore+2
|
||||
bne levelNext_fastOnly
|
||||
lda gameScore
|
||||
cmp #40000
|
||||
lda scoreNum20000
|
||||
cmp #2
|
||||
bge levelNext_fastOnly
|
||||
|
||||
ldy centipedeLevelNum
|
||||
|
86
BuGS/score.s
86
BuGS/score.s
@ -19,10 +19,14 @@ TILE_SCORE_ONES_OFFSET equ TILE_SCORE_ONES*SIZEOF_TILE_INFO
|
||||
TILE_SCORE_TENS_OFFSET equ TILE_SCORE_ONES_OFFSET-SIZEOF_TILE_INFO
|
||||
TILE_SCORE_HUNDREDS_OFFSET equ TILE_SCORE_TENS_OFFSET-SIZEOF_TILE_INFO
|
||||
TILE_SCORE_THOUSANDS_OFFSET equ TILE_SCORE_HUNDREDS_OFFSET-SIZEOF_TILE_INFO
|
||||
TILE_SCORE_TEN_THOUSANDS_OFFSET equ TILE_SCORE_THOUSANDS_OFFSET-SIZEOF_TILE_INFO
|
||||
|
||||
scoreStartGame entry
|
||||
stz gameScore
|
||||
stz gameScore+2
|
||||
stz scoreWithin12000
|
||||
stz scoreWithin20000
|
||||
stz scoreNum20000
|
||||
|
||||
ldx #TILE_SCORE_ONES_OFFSET
|
||||
lda #TILE_NUMBER_0
|
||||
@ -158,35 +162,20 @@ scoreAddToTile_done anop
|
||||
|
||||
|
||||
scoreAddOne entry
|
||||
inc gameScore
|
||||
bne scoreAddOne_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddOne_noCarry anop
|
||||
_incrementScore 1
|
||||
ldx #TILE_SCORE_ONES_OFFSET
|
||||
jmp scoreAddOneToTile
|
||||
|
||||
|
||||
scoreAddFive entry
|
||||
lda #5
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddFive_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddFive_noCarry anop
|
||||
_incrementScore 5
|
||||
ldx #TILE_SCORE_ONES_OFFSET
|
||||
lda #5*4
|
||||
jmp scoreAddToTile
|
||||
|
||||
|
||||
scoreAddTen entry
|
||||
lda #10
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddTen_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddTen_noCarry anop
|
||||
_incrementScore 10
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddTen_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -199,13 +188,7 @@ scoreAddTen_skipZeroOnes anop
|
||||
|
||||
|
||||
scoreAddOneHundred entry
|
||||
lda #100
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddHundred_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddHundred_noCarry anop
|
||||
_incrementScore 100
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddHundred_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -225,13 +208,7 @@ scoreAddHundred_skipZeroTens anop
|
||||
|
||||
|
||||
scoreAddTwoHundred entry
|
||||
lda #200
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddTwoHundred_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddTwoHundred_noCarry anop
|
||||
_incrementScore 200
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddTwoHundred_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -252,13 +229,7 @@ scoreAddTwoHundred_skipZeroTens anop
|
||||
|
||||
|
||||
scoreAddThreeHundred entry
|
||||
lda #300
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddThreeHundred_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddThreeHundred_noCarry anop
|
||||
_incrementScore 300
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddThreeHundred_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -279,13 +250,7 @@ scoreAddThreeHundred_skipZeroTens anop
|
||||
|
||||
|
||||
scoreAddSixHundred entry
|
||||
lda #600
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddSixHundred_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddSixHundred_noCarry anop
|
||||
_incrementScore 600
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddSixHundred_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -306,13 +271,7 @@ scoreAddSixHundred_skipZeroTens anop
|
||||
|
||||
|
||||
scoreAddNineHundred entry
|
||||
lda #900
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddNineHundred_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddNineHundred_noCarry anop
|
||||
_incrementScore 900
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddNineHundred_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -333,13 +292,7 @@ scoreAddNineHundred_skipZeroTens anop
|
||||
|
||||
|
||||
scoreAddOneThousand entry
|
||||
lda #1000
|
||||
clc
|
||||
adc gameScore
|
||||
sta gameScore
|
||||
bcc scoreAddOneThousand_noCarry
|
||||
inc gameScore+2
|
||||
scoreAddOneThousand_noCarry anop
|
||||
_incrementScore 1000
|
||||
lda tileType+TILE_SCORE_ONES_OFFSET
|
||||
bne scoreAddOneThousand_skipZeroOnes
|
||||
lda #TILE_NUMBER_0
|
||||
@ -365,6 +318,19 @@ scoreAddOneThousand_skipZeroHundreds anop
|
||||
jmp scoreAddOneToTile
|
||||
|
||||
|
||||
; This function is used purely for debug to test high score threshold stuff. It
|
||||
; doesn't do all the right things though to update the score on the display so I am
|
||||
; cheating a bit here.
|
||||
scoreAddTwentyThousand entry
|
||||
_incrementScore 20000
|
||||
ldx #TILE_SCORE_TEN_THOUSANDS_OFFSET
|
||||
lda #2*4
|
||||
jmp scoreAddToTile
|
||||
|
||||
|
||||
|
||||
highScore dc i4'0'
|
||||
scoreWithin12000 dc i2'0'
|
||||
scoreWithin20000 dc i2'0'
|
||||
|
||||
end
|
||||
|
@ -63,6 +63,8 @@ word numDirtyNonGameTiles;
|
||||
|
||||
word numPlayers;
|
||||
|
||||
word numInfieldMushrooms;
|
||||
|
||||
|
||||
/* Implementation */
|
||||
|
||||
@ -282,6 +284,7 @@ void addStartingMushrooms(void)
|
||||
{
|
||||
tTileNum tileNum;
|
||||
unsigned int numMushrooms = 0;
|
||||
numInfieldMushrooms = 0;
|
||||
|
||||
while (numMushrooms < STARTING_NUM_MUSHROOMS)
|
||||
{
|
||||
@ -294,5 +297,7 @@ void addStartingMushrooms(void)
|
||||
tileType[tileNum] = TILE_MUSHROOM4;
|
||||
ADD_DIRTY_GAME_TILE(tileNum);
|
||||
numMushrooms++;
|
||||
if ((tileNum / GAME_NUM_TILES_WIDE) >= GAME_NUM_TILES_TALL - 10)
|
||||
numInfieldMushrooms++;
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,7 @@ extern word tileBitMask[NUM_GAME_TILES];
|
||||
|
||||
extern tTileOffset dirtyNonGameTiles[NUM_NON_GAME_TILES];
|
||||
extern word numDirtyNonGameTiles;
|
||||
extern word numInfieldMushrooms;
|
||||
|
||||
|
||||
/* API */
|
||||
|
Loading…
Reference in New Issue
Block a user