mirror of
https://github.com/jeremysrand/BuGS.git
synced 2024-12-29 13:29:27 +00:00
Add the code to start a game and iterate through levels. We don't detect the end of a level yet though.
This commit is contained in:
parent
04d2e74f15
commit
6c3b8398a8
@ -240,7 +240,10 @@ checkKey_loop2 anop
|
||||
beq checkKey_fast
|
||||
cmp #'-'
|
||||
beq checkKey_slow
|
||||
|
||||
|
||||
cmp #'g'
|
||||
beq checkKey_game
|
||||
|
||||
cmp #'c'
|
||||
beq checkKey_centipede
|
||||
cmp #'C'
|
||||
@ -299,6 +302,10 @@ checkKey_slow anop
|
||||
lda #SPRITE_SPEED_SLOW
|
||||
jmp setScorpionSpeed
|
||||
|
||||
checkKey_game anop
|
||||
jsl levelInit
|
||||
jmp levelStart
|
||||
|
||||
checkKey_centipede anop
|
||||
jsl addFastHeadSegment
|
||||
jsl addSlowHeadSegment
|
||||
|
@ -1627,6 +1627,126 @@ addFastHeadSegment entry
|
||||
sta segmentsAddEnabled
|
||||
|
||||
rtl
|
||||
|
||||
|
||||
; This method is called with X register pointing to a structure which has the following info in it:
|
||||
; - segment speed (2 bytes)
|
||||
; - segment direction (2 bytes)
|
||||
; - tile offset (2 bytes)
|
||||
; - number of body segments (2 bytes)
|
||||
;
|
||||
; It reads this info and sets up the appropriate centipede segments. Also, it is expected to
|
||||
; preserve the X register.
|
||||
addCentipede entry
|
||||
lda numSegments
|
||||
asl a
|
||||
tay
|
||||
|
||||
lda #SEGMENT_STATE_HEAD
|
||||
sta segmentStates,y
|
||||
|
||||
lda |$0,x
|
||||
sta segmentSpeed,y
|
||||
|
||||
tya
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
sta segmentPosOffset,y
|
||||
tay
|
||||
|
||||
lda #SEGMENT_DIR_DOWN
|
||||
sta segmentVerticalDir,y
|
||||
|
||||
lda |$2,x
|
||||
sta segmentHorizontalDir,y
|
||||
|
||||
phx
|
||||
lda |$4,x
|
||||
tax
|
||||
lda tileScreenOffset,x
|
||||
; We will correct this later to adjust for speed and direction.
|
||||
sta segmentScreenOffsets,y
|
||||
|
||||
lda segmentHorizontalDir,y
|
||||
beq addCentipede_left anop
|
||||
|
||||
txa
|
||||
sta segmentTileOffsetsUL,y
|
||||
sta segmentTileOffsetsLL,y
|
||||
sta segmentCurrentTile,y
|
||||
lda tileRight,x
|
||||
sta segmentTileOffsetsUR,y
|
||||
sta segmentTileOffsetsLR,y
|
||||
|
||||
plx
|
||||
lda |$0,x
|
||||
beq addCentipede_rightFast anop
|
||||
|
||||
lda segmentScreenOffsets,y
|
||||
sec
|
||||
sbc #SCREEN_BYTES_PER_ROW*7+2
|
||||
bra addCentipede_rightFacing
|
||||
|
||||
addCentipede_rightFast anop
|
||||
lda segmentScreenOffsets,y
|
||||
sec
|
||||
sbc #SCREEN_BYTES_PER_ROW*8+2
|
||||
|
||||
addCentipede_rightFacing anop
|
||||
sta segmentScreenOffsets,y
|
||||
lda #SEGMENT_FACING_DOWN_LEFT
|
||||
bra addCentipede_facing
|
||||
|
||||
addCentipede_left anop
|
||||
txa
|
||||
sta segmentTileOffsetsUR,y
|
||||
sta segmentTileOffsetsLR,y
|
||||
sta segmentCurrentTile,y
|
||||
lda tileLeft,x
|
||||
sta segmentTileOffsetsUL,y
|
||||
sta segmentTileOffsetsLL,y
|
||||
|
||||
plx
|
||||
|
||||
lda |$0,x
|
||||
beq addCentipede_leftFast anop
|
||||
|
||||
lda segmentScreenOffsets,y
|
||||
sec
|
||||
sbc #SCREEN_BYTES_PER_ROW*7+4
|
||||
bra addCentipede_leftFacing
|
||||
|
||||
addCentipede_leftFast anop
|
||||
lda segmentScreenOffsets,y
|
||||
sec
|
||||
sbc #SCREEN_BYTES_PER_ROW*8+4
|
||||
|
||||
addCentipede_leftFacing anop
|
||||
sta segmentScreenOffsets,y
|
||||
lda #SEGMENT_FACING_DOWN_RIGHT
|
||||
|
||||
addCentipede_facing anop
|
||||
sta segmentFacing,y
|
||||
|
||||
inc numSegments
|
||||
lda #5
|
||||
sta segmentPixelOffset
|
||||
lda #1
|
||||
sta segmentsAddEnabled
|
||||
|
||||
ldy |$6,x
|
||||
beq addCentipede_done
|
||||
phx
|
||||
addCentipede_body anop
|
||||
phy
|
||||
jsl addBodySegment
|
||||
ply
|
||||
dey
|
||||
bne addCentipede_body
|
||||
plx
|
||||
addCentipede_done anop
|
||||
rtl
|
||||
|
||||
|
||||
; Call this with the segment num * 2 in the X register
|
||||
|
64
BuGS/level.s
64
BuGS/level.s
@ -14,13 +14,69 @@ level start
|
||||
using globalData
|
||||
|
||||
|
||||
levelInit entry
|
||||
stz centipedeLevelNum
|
||||
stz colourLevelNum
|
||||
rtl
|
||||
|
||||
|
||||
levelStart entry
|
||||
lda colourLevelNum
|
||||
jsl setColour
|
||||
|
||||
ldx centipedeLevelNum
|
||||
lda levelTable,x
|
||||
tax
|
||||
lda |$0,x
|
||||
sta centipedeNum
|
||||
inx
|
||||
inx
|
||||
levelStart_loop anop
|
||||
jsl addCentipede
|
||||
dec centipedeNum
|
||||
beq levelStart_done
|
||||
txa
|
||||
clc
|
||||
adc #8
|
||||
tax
|
||||
bra levelStart_loop
|
||||
levelStart_done anop
|
||||
rtl
|
||||
|
||||
|
||||
levelNext entry
|
||||
lda colourLevelNum
|
||||
inc a
|
||||
cmp #NUM_COLOUR_PALETTES
|
||||
blt levelNext_skip
|
||||
lda #0
|
||||
levelNext_skip anop
|
||||
sta colourLevelNum
|
||||
|
||||
lda centipedeLevelNum
|
||||
cmp #LEVEL_TABLE_LAST_OFFSET
|
||||
bge levelNext_wrap
|
||||
inc a
|
||||
inc a
|
||||
bra levelNext_noWrap
|
||||
levelNext_wrap anop
|
||||
lda #LEVEL_TABLE_REPEAT_OFFSET
|
||||
levelNext_noWrap anop
|
||||
sta centipedeLevelNum
|
||||
rtl
|
||||
|
||||
|
||||
centipedeLevelNum dc i2'0'
|
||||
colourLevelNum dc i2'0'
|
||||
centipedeNum dc i2'0'
|
||||
|
||||
; The level structure looks like this:
|
||||
; number of independent centipedes (2 bytes)
|
||||
; { (for each independent centipede)
|
||||
; segment speed (2 bytes)
|
||||
; segment direction (2 bytes)
|
||||
; tile offset where it appears (2 bytes)
|
||||
; number of body segments
|
||||
; number of body segments (2 bytes)
|
||||
; }
|
||||
levelOne dc i2'1'
|
||||
dc i2'SEGMENT_SPEED_FAST'
|
||||
@ -638,6 +694,12 @@ levelTwentySix dc i2'7'
|
||||
dc i2'46' ; Tile offset
|
||||
dc i2'0' ; Number of body segments
|
||||
|
||||
; Once we reach level 26 of the centipede levels, we go back to level 15. This is because
|
||||
; we only have fast speed centipedes, with one more head at the start and one less body
|
||||
; segment until they are all head segments and then back to a single 12 segment centipede at
|
||||
; fast speed. By looping back from 26th level to the 15th level, we do this.
|
||||
LEVEL_TABLE_LAST_OFFSET gequ 25*2
|
||||
LEVEL_TABLE_REPEAT_OFFSET gequ 14*2
|
||||
levelTable dc i2'levelOne'
|
||||
dc i2'levelTwo'
|
||||
dc i2'levelThree'
|
||||
|
@ -8,6 +8,7 @@ s6d2 =
|
||||
|
||||
s7d1 = /Users/jrand/Library/Developer/Xcode/DerivedData/BuGS-bffpexoblaghkzcbtjtzxeulnuto/Build/Products/Debug/BuGS.2mg
|
||||
|
||||
g_limit_speed = 3
|
||||
|
||||
|
||||
bram1[00] = 00 00 00 01 00 00 0d 06 02 01 01 00 01 00 00 00
|
||||
|
Loading…
Reference in New Issue
Block a user