mirror of
https://github.com/jeremysrand/BuGS.git
synced 2024-12-27 14:30:46 +00:00
Add collision detection for all of the bug types. Remove the debug code for shooting bugs. It is almost a functional game now!
This commit is contained in:
parent
64f96896f7
commit
520aaa5a34
@ -80,7 +80,7 @@
|
||||
9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameMushroom.s; sourceTree = "<group>"; };
|
||||
9D47CC14254A698900CDA5CB /* gamePlayer.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gamePlayer.s; sourceTree = "<group>"; };
|
||||
9D47CCBA25525C1A00CDA5CB /* tileData.pl */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = tileData.pl; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.perl; };
|
||||
9D53E5B32562320300E10169 /* gameShot.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameShot.s; sourceTree = "<group>"; };
|
||||
9D53E5B32562320300E10169 /* gameShot.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameShot.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||
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>"; };
|
||||
@ -89,11 +89,11 @@
|
||||
9D8FFC602491CA28005C9327 /* game.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = game.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||
9D8FFC612491CAF0005C9327 /* game.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = game.h; sourceTree = "<group>"; };
|
||||
9D9F07F92553AB3800875B29 /* TODO.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = TODO.md; sourceTree = "<group>"; };
|
||||
9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = "<group>"; };
|
||||
9DB1505124C6875C00558B87 /* gameScorpion.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameScorpion.s; sourceTree = "<group>"; };
|
||||
9DB1505024C3801100558B87 /* gameFlea.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameFlea.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||
9DB1505124C6875C00558B87 /* gameScorpion.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameScorpion.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||
9DB1505224C7495400558B87 /* globals.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = globals.s; sourceTree = "<group>"; };
|
||||
9DB1505324C9E54C00558B87 /* gameSpider.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSpider.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||
9DB1505424D3BF6C00558B87 /* gameSegments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSegments.s; sourceTree = "<group>"; };
|
||||
9DB1505424D3BF6C00558B87 /* gameSegments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameSegments.s; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; };
|
||||
9DB1505524D3BFCE00558B87 /* global.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = global.macros; sourceTree = "<group>"; };
|
||||
9DC4D7BD24B7652100BACF4B /* ship.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = ship.s; sourceTree = "<group>"; };
|
||||
9DC4D7BE24B80C9600BACF4B /* shot.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = shot.s; sourceTree = "<group>"; };
|
||||
|
32
BuGS/game.s
32
BuGS/game.s
@ -264,44 +264,12 @@ checkKey_loop2 anop
|
||||
beq checkKey_quit
|
||||
cmp #$001b
|
||||
beq checkKey_quit
|
||||
|
||||
cmp #'f'
|
||||
beq checkKey_shootFlea
|
||||
cmp #'F'
|
||||
beq checkKey_shootFlea
|
||||
|
||||
cmp #'s'
|
||||
beq checkKey_shootScorpion
|
||||
cmp #'S'
|
||||
beq checkKey_shootScorpion
|
||||
|
||||
cmp #'p'
|
||||
beq checkKey_shootSpider
|
||||
cmp #'P'
|
||||
beq checkKey_shootSpider
|
||||
|
||||
cmp #'g'
|
||||
beq checkKey_game
|
||||
|
||||
cmp #'c'
|
||||
beq checkKey_shootCentipede
|
||||
cmp #'C'
|
||||
beq checkKey_shootCentipede
|
||||
|
||||
checkKey_done anop
|
||||
rtl
|
||||
|
||||
checkKey_shootFlea anop
|
||||
jmp shootFlea
|
||||
|
||||
checkKey_shootScorpion anop
|
||||
jmp shootScorpion
|
||||
|
||||
checkKey_shootSpider anop
|
||||
jmp shootSpider
|
||||
|
||||
checkKey_shootCentipede anop
|
||||
jmp shootRandomSegment
|
||||
|
||||
checkKey_quit anop
|
||||
stz shouldQuit
|
||||
|
@ -253,6 +253,27 @@ setFleaSpeed_fast anop
|
||||
sta fleaUpdatePerTile
|
||||
rtl
|
||||
|
||||
|
||||
; See the isSpiderCollision for info about the requirements and limitations of this routine
|
||||
isFleaCollision entry
|
||||
ldx fleaState
|
||||
cpx #FLEA_STATE_FALLING
|
||||
bne isFleaCollision_returnFalse
|
||||
cmp fleaTileOffsets
|
||||
beq isFleaCollision_returnTrue
|
||||
cmp fleaTileOffsets+2
|
||||
beq isFleaCollision_returnTrue
|
||||
cmp fleaTileOffsets+4
|
||||
beq isFleaCollision_returnTrue
|
||||
cmp fleaTileOffsets+6
|
||||
bne isFleaCollision_returnFalse
|
||||
isFleaCollision_returnTrue anop
|
||||
sec
|
||||
rtl
|
||||
isFleaCollision_returnFalse anop
|
||||
clc
|
||||
rtl
|
||||
|
||||
|
||||
shootFlea entry
|
||||
lda fleaState
|
||||
|
@ -332,6 +332,29 @@ addScorpion_done anop
|
||||
rtl
|
||||
|
||||
|
||||
; See isSpiderCollision for the requirements of this routine and
|
||||
; for info about its limitation
|
||||
isScorpionCollision entry
|
||||
ldx scorpionState
|
||||
beq isScorpionCollision_returnFalse
|
||||
cpx #SCORPION_STATE_EXPLODING
|
||||
bne isScorpionCollision_test
|
||||
isScorpionCollision_returnFalse anop
|
||||
clc
|
||||
rtl
|
||||
|
||||
isScorpionCollision_test anop
|
||||
cmp scorpionTileOffsets
|
||||
beq isScorpionCollision_returnTrue
|
||||
cmp scorpionTileOffsets+2
|
||||
beq isScorpionCollision_returnTrue
|
||||
cmp scorpionTileOffsets+4
|
||||
bne isScorpionCollision_returnFalse
|
||||
isScorpionCollision_returnTrue anop
|
||||
sec
|
||||
rtl
|
||||
|
||||
|
||||
shootScorpion entry
|
||||
lda scorpionState
|
||||
beq shootScorpion_done
|
||||
|
@ -1677,8 +1677,46 @@ addCentipede_body anop
|
||||
plx
|
||||
addCentipede_done anop
|
||||
rtl
|
||||
|
||||
|
||||
|
||||
; The accummulator has the tile offset where the collision happened
|
||||
; The y register has the address where the collision happened
|
||||
;
|
||||
; The result is a clear carry if there is no collision found or
|
||||
; a set carry and the segment num * 2 in the X register
|
||||
isSegmentCollision entry
|
||||
ldy numSegments
|
||||
beq isSegmentCollision_returnFalse
|
||||
|
||||
ldx #SEGMENT_MAX_OFFSET
|
||||
isSegmentCollision_loop anop
|
||||
ldy segmentStates,x
|
||||
beq isSegmentCollision_nextSegment
|
||||
cpy #SEGMENT_STATE_EXPLODING
|
||||
beq isSegmentCollision_nextSegment
|
||||
ldy segmentPosOffset,x
|
||||
cmp segmentTileOffsetsLL,y
|
||||
beq isSegmentCollision_returnTrue
|
||||
cmp segmentTileOffsetsLR,y
|
||||
beq isSegmentCollision_returnTrue
|
||||
cmp segmentTileOffsetsUL,y
|
||||
beq isSegmentCollision_returnTrue
|
||||
cmp segmentTileOffsetsUR,y
|
||||
beq isSegmentCollision_returnTrue
|
||||
isSegmentCollision_nextSegment anop
|
||||
dex
|
||||
dex
|
||||
bpl isSegmentCollision_loop
|
||||
|
||||
isSegmentCollision_returnFalse anop
|
||||
clc
|
||||
rtl
|
||||
|
||||
isSegmentCollision_returnTrue anop
|
||||
sec
|
||||
rtl
|
||||
|
||||
|
||||
; Call this with the segment num * 2 in the X register
|
||||
shootSegment entry
|
||||
dec numSegments
|
||||
@ -1732,21 +1770,6 @@ shootSegment_skipMushroom anop
|
||||
sta segmentStates+2,x
|
||||
shootSegment_done anop
|
||||
rtl
|
||||
|
||||
|
||||
shootRandomSegment entry
|
||||
lda numSegments
|
||||
bne shootRandomSegment_hasSegments
|
||||
rtl
|
||||
shootRandomSegment_hasSegments anop
|
||||
lda #12
|
||||
jsl randN
|
||||
asl a
|
||||
tax
|
||||
lda segmentStates,x
|
||||
cmp #SEGMENT_STATE_HEAD
|
||||
blt shootRandomSegment_hasSegments
|
||||
jmp shootSegment
|
||||
|
||||
|
||||
segmentsAddEnabled dc i2'1'
|
||||
|
@ -142,8 +142,42 @@ updateShot_checkCollision anop
|
||||
updateShot_collision anop
|
||||
and #$3333
|
||||
bne updateShot_maybeMushroom
|
||||
; TODO - Write the code to test for a collision with fleas, spiders, scorpions or centipede segments
|
||||
bra updateShot_done
|
||||
|
||||
txy
|
||||
txa
|
||||
sec
|
||||
sbc #SCREEN_ADDRESS
|
||||
and #$fffc
|
||||
tax
|
||||
lda >screenToTileOffset,x
|
||||
cmp #SPIDER_STARTING_TOP_ROW_OFFSET
|
||||
blt updateShot_maybeScorpion
|
||||
jsl isSpiderCollision
|
||||
bcc updateShot_notSpiderOrScorpion
|
||||
lda #SHOT_STATE_NONE
|
||||
sta shotState
|
||||
jmp shootSpider
|
||||
|
||||
updateShot_maybeScorpion anop
|
||||
jsl isScorpionCollision
|
||||
bcc updateShot_notSpiderOrScorpion
|
||||
lda #SHOT_STATE_NONE
|
||||
sta shotState
|
||||
jmp shootScorpion
|
||||
|
||||
updateShot_notSpiderOrScorpion anop
|
||||
jsl isFleaCollision
|
||||
bcc updateShot_maybeSegment
|
||||
lda #SHOT_STATE_NONE
|
||||
sta shotState
|
||||
jmp shootFlea
|
||||
|
||||
updateShot_maybeSegment anop
|
||||
jsl isSegmentCollision
|
||||
bcc updateShot_done
|
||||
lda #SHOT_STATE_NONE
|
||||
sta shotState
|
||||
jmp shootSegment
|
||||
|
||||
updateShot_maybeMushroom anop
|
||||
txa
|
||||
|
@ -758,7 +758,44 @@ setSpiderSpeed_fast anop
|
||||
long i,m
|
||||
|
||||
rtl
|
||||
|
||||
|
||||
|
||||
; The accumulator has the tile where the collision occurred.
|
||||
; The y register has the address where the collision occurred.
|
||||
; This routine is expected to preserve the y register and the
|
||||
; accummulator. It can change the x register.
|
||||
;
|
||||
; For now, the implementation is very rough and just looks to see if
|
||||
; collision is in a tile overlapping with the spider. It would be
|
||||
; better to look closely at the address and try to figure out if it
|
||||
; really collided.
|
||||
;
|
||||
; The result here is returned in the C bit of the processor status
|
||||
; register
|
||||
isSpiderCollision entry
|
||||
ldx spiderState
|
||||
cpx #SPIDER_STATE_LEFT_DIAG_DOWN
|
||||
bge isSpiderCollision_test
|
||||
isSpiderCollision_returnFalse anop
|
||||
clc
|
||||
rtl
|
||||
isSpiderCollision_test anop
|
||||
cmp spiderTileOffsets
|
||||
beq isSpiderCollision_returnTrue
|
||||
cmp spiderTileOffsets+2
|
||||
beq isSpiderCollision_returnTrue
|
||||
cmp spiderTileOffsets+4
|
||||
beq isSpiderCollision_returnTrue
|
||||
cmp spiderTileOffsets+6
|
||||
beq isSpiderCollision_returnTrue
|
||||
cmp spiderTileOffsets+8
|
||||
beq isSpiderCollision_returnTrue
|
||||
cmp spiderTileOffsets+10
|
||||
bne isSpiderCollision_returnFalse
|
||||
isSpiderCollision_returnTrue anop
|
||||
sec
|
||||
rtl
|
||||
|
||||
|
||||
shootSpider entry
|
||||
lda spiderState
|
||||
|
@ -27,7 +27,7 @@ sed -i "" "s:^s7d1 *=.*$:s7d1 = $DISKIMAGE:" config.txt
|
||||
|
||||
# This magic ensure that clicking stop in Xcode results in the emulator terminating.
|
||||
|
||||
$EMULATORPATH &
|
||||
$EMULATORPATH -fullscreen &
|
||||
PID=$!
|
||||
|
||||
trap 'kill $PID' SIGTERM SIGINT SIGHUP EXIT
|
||||
|
Loading…
Reference in New Issue
Block a user