Add the code to handle restricting the spider to lower and lower rows as the score goes up. This is the final bit of game logic necessary for the bugs in the game I think.

This commit is contained in:
Jeremy Rand 2020-10-26 22:32:46 -04:00
parent 123c3a48ef
commit 0dd8222611
8 changed files with 76 additions and 38 deletions

View File

@ -161,10 +161,6 @@ drawTile entry
jumpInst jmp >mushroom1 jumpInst jmp >mushroom1
nop nop
addPlayer entry
; TODO - Write code to add a new life.
rtl
setupScreen entry setupScreen entry

View File

@ -163,7 +163,7 @@ updateFlea_nextTile anop
bne updateFlea_nextAction bne updateFlea_nextAction
lda #TILE_MUSHROOM4 lda #TILE_MUSHROOM4
sta tileType,x sta tileType,x
cpx #SPIDER_TOP_ROW_OFFSET cpx #SPIDER_STARTING_TOP_ROW_OFFSET
blt updateFlea_nextAction blt updateFlea_nextAction
inc numInfieldMushrooms inc numInfieldMushrooms
bra updateFlea_nextAction bra updateFlea_nextAction

View File

@ -1693,7 +1693,7 @@ shootSegment_doneScore anop
lda #TILE_POISON_MUSHROOM4 lda #TILE_POISON_MUSHROOM4
bra shootSegment_dirtyTile bra shootSegment_dirtyTile
shootSegment_noMushroom anop shootSegment_noMushroom anop
cpy #SPIDER_TOP_ROW_OFFSET cpy #SPIDER_STARTING_TOP_ROW_OFFSET
blt shootSegment_normalMushroom blt shootSegment_normalMushroom
inc numInfieldMushrooms inc numInfieldMushrooms
shootSegment_normalMushroom anop shootSegment_normalMushroom anop

View File

@ -26,8 +26,8 @@ SPIDER_STATE_RIGHT_DOWN equ 9
SPIDER_STATE_RIGHT_UP equ 10 SPIDER_STATE_RIGHT_UP equ 10
SPIDER_LHS_TILE_OFFSET equ SPIDER_TOP_ROW_OFFSET SPIDER_LHS_TILE_OFFSET equ SPIDER_STARTING_TOP_ROW_OFFSET
SPIDER_RHS_TILE_OFFSET equ SPIDER_TOP_ROW_OFFSET+(GAME_NUM_TILES_WIDE-1)*SIZEOF_TILE_INFO SPIDER_RHS_TILE_OFFSET equ SPIDER_STARTING_TOP_ROW_OFFSET+(GAME_NUM_TILES_WIDE-1)*SIZEOF_TILE_INFO
; The spider starts 2 pixel rows above the top row offset so it can slide in on the edge of ; The spider starts 2 pixel rows above the top row offset so it can slide in on the edge of
; the screen on a diagonal and hit the centre of the tiles with the middle of its body. ; the screen on a diagonal and hit the centre of the tiles with the middle of its body.
@ -63,6 +63,8 @@ SPIDER_ADD_TIME equ 120
spiderInitGame entry spiderInitGame entry
stz spiderAddTime stz spiderAddTime
stz spiderState stz spiderState
lda #SPIDER_STARTING_TOP_ROW
sta spiderTopRow
lda #SPRITE_SPEED_SLOW lda #SPRITE_SPEED_SLOW
jmp setSpiderSpeed jmp setSpiderSpeed
@ -418,7 +420,7 @@ updateSpider_tilesUp anop
beq updateSpider_tilesUpCont beq updateSpider_tilesUpCont
lda #TILE_EMPTY lda #TILE_EMPTY
sta tileType,x sta tileType,x
cpx #SPIDER_TOP_ROW_OFFSET cpx #SPIDER_STARTING_TOP_ROW_OFFSET
blt updateSpider_tilesUpCont blt updateSpider_tilesUpCont
dec numInfieldMushrooms dec numInfieldMushrooms
@ -493,7 +495,7 @@ updateSpider_tilesDown anop
beq updateSpider_tilesDownCont beq updateSpider_tilesDownCont
lda #TILE_EMPTY lda #TILE_EMPTY
sta tileType,x sta tileType,x
cpx #SPIDER_TOP_ROW_OFFSET cpx #SPIDER_STARTING_TOP_ROW_OFFSET
blt updateSpider_tilesDownCont blt updateSpider_tilesDownCont
dec numInfieldMushrooms dec numInfieldMushrooms
@ -507,17 +509,10 @@ updateSpider_tilesDownCont anop
updateSpider_downChangeDir anop updateSpider_downChangeDir anop
lda spiderTargetRow lda spiderTargetRow
sec sec
; TODO - The actual top row of the spider changes as the score goes up. sbc spiderTopRow
; The top row of the spider based on the score is:
; 0 to 119,000 - 10th row
; 120,000 to 139,999 - 9th row
; 140,000 to 159,999 - 8th row
; 160,000 to ... - 7th row
sbc #SPIDER_TOP_ROW
jsl randN jsl randN
inc a
clc clc
adc #SPIDER_TOP_ROW-1 adc spiderTopRow
sta spiderTargetRow sta spiderTargetRow
jsl rand0_to_65534 jsl rand0_to_65534
@ -561,14 +556,42 @@ addSpider_checkSpeed anop
bne addSpider_fast bne addSpider_fast
lda gameScore lda gameScore
cmp #5000 cmp #5000
blt addSpider_doit bge addSpider_fast
lda #SPRITE_SPEED_SLOW
bra addSpider_setSpeed
addSpider_fast anop addSpider_fast anop
lda #SPRITE_SPEED_FAST lda #SPRITE_SPEED_FAST
addSpider_setSpeed anop
cmp spiderSpeed cmp spiderSpeed
beq addSpider_doit beq addSpider_setHeight
jsl setSpiderSpeed jsl setSpiderSpeed
addSpider_doit anop addSpider_setHeight anop
; The actual top row of the spider changes as the score goes up.
; The top row of the spider based on the score is:
; 0 to 119,000 - 10th row from bottom
; 120,000 to 139,999 - 9th row from bottom
; 140,000 to 159,999 - 8th row from bottom
; 160,000 to ... - 7th row from bottom
lda scoreNum20000
cmp #6
blt addSpider_height10
beq addSpider_height9
cmp #7
beq addSpider_height8
lda #SPIDER_STARTING_TOP_ROW+3
bra addSpider_doneHeight
addSpider_height10 anop
lda #SPIDER_STARTING_TOP_ROW
bra addSpider_doneHeight
addSpider_height9 anop
lda #SPIDER_STARTING_TOP_ROW+1
bra addSpider_doneHeight
addSpider_height8 anop
lda #SPIDER_STARTING_TOP_ROW+2
addSpider_doneHeight anop
sta spiderTopRow
lda spiderStartingShift lda spiderStartingShift
sta spiderShiftInTile sta spiderShiftInTile
@ -578,12 +601,18 @@ addSpider_doit anop
lda #SPIDER_SPRITE_REFRESH_COUNT lda #SPIDER_SPRITE_REFRESH_COUNT
sta spiderSpriteRefresh sta spiderSpriteRefresh
lda #SPIDER_TOP_ROW-1 lda #SPIDER_STARTING_TOP_ROW-1
sta spiderCurrentRow sta spiderCurrentRow
lda #SPIDER_NUM_POSSIBLE_ROWS-1 lda #GAME_NUM_TILES_TALL-1
sec
sbc spiderTopRow
jsl randN jsl randN
adc #SPIDER_TOP_ROW+1 ; We intentionally set carry before adding here. I want to add (spiderTopRow + 1) to the
; random number we already got. That way, the target row is (spiderTopRow + 1) to
; (GAME_NUM_TILES_TALL - 1)
sec
adc spiderTopRow
sta spiderTargetRow sta spiderTargetRow
jsl rand0_to_65534 jsl rand0_to_65534
@ -768,6 +797,7 @@ spiderScreenShift dc i2'0'
spiderShiftInTile dc i2'0' spiderShiftInTile dc i2'0'
spiderAddTime dc i2'0' spiderAddTime dc i2'0'
spiderTopRow dc i2'SPIDER_STARTING_TOP_ROW'
spiderCurrentRow dc i2'0' spiderCurrentRow dc i2'0'
spiderTargetRow dc i2'0' spiderTargetRow dc i2'0'

View File

@ -158,7 +158,7 @@ _incrementScore_noCarry&SYSCNT anop
sec sec
sbc #12000 sbc #12000
pha pha
jsl addPlayer jsl scoreEvery12000
pla pla
_incrementScore_noExtraMan&SYSCNT anop _incrementScore_noExtraMan&SYSCNT anop
sta scoreWithin12000 sta scoreWithin12000

View File

@ -29,9 +29,9 @@ SEGMENT_SPEED_FAST equ 0
SEGMENT_SPEED_SLOW equ 1 SEGMENT_SPEED_SLOW equ 1
; A spider only travels in the bottom N rows. This defines that number. ; A spider only travels in the bottom N rows. This defines that number.
SPIDER_NUM_POSSIBLE_ROWS equ 10 SPIDER_MAX_NUM_POSSIBLE_ROWS equ 10
SPIDER_TOP_ROW equ GAME_NUM_TILES_TALL-SPIDER_NUM_POSSIBLE_ROWS SPIDER_STARTING_TOP_ROW equ GAME_NUM_TILES_TALL-SPIDER_MAX_NUM_POSSIBLE_ROWS
SPIDER_TOP_ROW_OFFSET equ SPIDER_TOP_ROW*GAME_NUM_TILES_WIDE*SIZEOF_TILE_INFO SPIDER_STARTING_TOP_ROW_OFFSET equ SPIDER_STARTING_TOP_ROW*GAME_NUM_TILES_WIDE*SIZEOF_TILE_INFO
SCREEN_BYTES_PER_ROW gequ 160 SCREEN_BYTES_PER_ROW gequ 160
@ -141,11 +141,23 @@ BORDER_COLOUR_REGISTER gequ $e0c034
STATE_REGISTER gequ $e1c068 STATE_REGISTER gequ $e1c068
VERTICAL_COUNTER gequ $e0c02e VERTICAL_COUNTER gequ $e0c02e
gameRunning dc i2'1' gameRunning dc i2'1'
numSegments dc i2'0'
gameLevel dc i2'0' ; The following data values hold the game state and when/if 2 player is supported,
gameScore dc i4'0' ; this information will need to be copied to a backup location when the player
scoreNum20000 dc i2'0' ; switches.
numSegments dc i2'0'
gameLevel dc i2'0'
gameScore dc i4'0'
scoreWithin12000 dc i2'0'
scoreWithin20000 dc i2'0'
scoreNum20000 dc i2'0'
centipedeLevelNum dc i2'0'
colourLevelNum dc i2'0'
; numInfieldMushrooms
; tileType
backupStack dc i2'0' backupStack dc i2'0'

View File

@ -144,8 +144,6 @@ levelNext_fastNoWrap anop
rtl rtl
centipedeLevelNum dc i2'0'
colourLevelNum dc i2'0'
centipedeNum dc i2'0' centipedeNum dc i2'0'
nextLevelFrameCount dc i2'0' nextLevelFrameCount dc i2'0'

View File

@ -328,9 +328,11 @@ scoreAddTwentyThousand entry
jmp scoreAddToTile jmp scoreAddToTile
scoreEvery12000 entry
; TODO - Write code to add a new life.
rtl
highScore dc i4'0' highScore dc i4'0'
scoreWithin12000 dc i2'0'
scoreWithin20000 dc i2'0'
end end