Start adding the code for supporting shooting.

This commit is contained in:
Jeremy Rand 2020-11-16 00:14:08 -05:00
parent 51b047e58b
commit 4e6bad0ae7
8 changed files with 218 additions and 153 deletions

View File

@ -78,8 +78,9 @@
9D33970024AEFBF2003222B3 /* segments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = segments.s; sourceTree = "<group>"; }; 9D33970024AEFBF2003222B3 /* segments.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = segments.s; sourceTree = "<group>"; };
9D33970124AF9D55003222B3 /* sprites.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = sprites.macros; sourceTree = "<group>"; }; 9D33970124AF9D55003222B3 /* sprites.macros */ = {isa = PBXFileReference; lastKnownFileType = text; path = sprites.macros; sourceTree = "<group>"; };
9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = gameMushroom.s; sourceTree = "<group>"; }; 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>"; xcLanguageSpecificationIdentifier = xcode.lang.asm.orcam; }; 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; }; 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>"; };
9D62AF3B249871A300348F45 /* colour.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = colour.s; sourceTree = "<group>"; }; 9D62AF3B249871A300348F45 /* colour.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = colour.s; sourceTree = "<group>"; };
9D62AF3F2499CD1E00348F45 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; 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>"; }; 9D62AF402499CD3A00348F45 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@ -143,6 +144,7 @@
9DB1505424D3BF6C00558B87 /* gameSegments.s */, 9DB1505424D3BF6C00558B87 /* gameSegments.s */,
9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */, 9D47CBE02547BEDB00CDA5CB /* gameMushroom.s */,
9D47CC14254A698900CDA5CB /* gamePlayer.s */, 9D47CC14254A698900CDA5CB /* gamePlayer.s */,
9D53E5B32562320300E10169 /* gameShot.s */,
9D8AF0B72535542400C10E3C /* level.s */, 9D8AF0B72535542400C10E3C /* level.s */,
9D8AF0B82535543000C10E3C /* score.s */, 9D8AF0B82535543000C10E3C /* score.s */,
9D62AF3B249871A300348F45 /* colour.s */, 9D62AF3B249871A300348F45 /* colour.s */,

View File

@ -106,6 +106,7 @@ gameLoop anop
long i,m long i,m
jsl updatePlayer jsl updatePlayer
jsl updateShot
jsl updateScorpion jsl updateScorpion
jsl updateSpider jsl updateSpider
jsl updateFlea jsl updateFlea
@ -219,6 +220,7 @@ startLevel entry
jsl scorpionInitLevel jsl scorpionInitLevel
jsl spiderInitLevel jsl spiderInitLevel
jsl fleaInitLevel jsl fleaInitLevel
jsl shotInitLevel
jsl playerLevelStart jsl playerLevelStart
jmp levelStart jmp levelStart

View File

@ -221,11 +221,16 @@ updatePlayer_negY anop
updatePlayer_doneY anop updatePlayer_doneY anop
sta mouseY sta mouseY
; The Y register also has a bit in it which indicates whether the ; The X and Y register also has a bit in each which indicates whether a
; mouse is down or not. ; mouse button is down or not.
txa
and #$0080
beq updatePlayer_mouseDown
tya tya
and #$0080 and #$0080
sta mouseDown bne updatePlayer_skipDeltas
updatePlayer_mouseDown anop
jsl maybeShoot
updatePlayer_skipDeltas anop updatePlayer_skipDeltas anop
lda mouseY lda mouseY
@ -318,10 +323,6 @@ updatePlayer_tileOffscreen2 anop
updatePlayer_done anop updatePlayer_done anop
rtl rtl
mouseX dc i2'0'
mouseY dc i2'0'
mouseDown dc i2'0'
playerFrameCount dc i2'0' playerFrameCount dc i2'0'
playerExplosionOffset dc i2'0' playerExplosionOffset dc i2'0'

84
BuGS/gameShot.s Normal file
View File

@ -0,0 +1,84 @@
;
; gameShot.s
; BuGS
;
; Created by Jeremy Rand on 2020-11-15.
;Copyright © 2020 Jeremy Rand. All rights reserved.
;
case on
mcopy gameShot.macros
keep gameShot
gameShot start
using globalData
using tileData
using screenData
SHOT_STATE_NONE equ 0
SHOT_STATE_START_SHOOTING equ 1
SHOT_STATE_SHOOTING equ 2
shotInitLevel entry
stz shotState
rtl
maybeShoot entry
lda shotState
bne maybeShoot_alreadyShooting
lda #SHOT_STATE_START_SHOOTING
sta shotState
maybeShoot_alreadyShooting anop
rtl
updateShot entry
lda playerState
cmp #PLAYER_STATE_ONSCREEN
beq updateShot_playerOnscreen
rtl
updateShot_playerOnscreen anop
lda shotState
bne updateShot_notNone
lda mouseX
and #1
bne updateShot_shifted
lda mouseAddress
sec
sbc #$1df
tay
sec
sbc #SCREEN_ADDRESS
and #$fffc
tax
lda >screenToTileOffset,x
tax
lda #TILE_STATE_DIRTY
sta tileDirty,x
jmp >drawHalfShot
updateShot_shifted anop
lda mouseAddress
sec
sbc #$1de
tay
sec
sbc #SCREEN_ADDRESS
and #$fffc
tax
lda >screenToTileOffset,x
tax
lda #TILE_STATE_DIRTY
sta tileDirty,x
jmp >drawHalfShotShift
updateShot_notNone anop
rtl
shotState dc i2'SHOT_STATE_NONE'
shotShifted dc i2'0'
shotAddress dc i2'0'
end

View File

@ -138,6 +138,8 @@ numInfieldMushrooms dc i2'0'
playerState dc i2'PLAYER_STATE_NONE' playerState dc i2'PLAYER_STATE_NONE'
mouseX dc i2'0'
mouseY dc i2'0'
mouseAddress dc i2'0' mouseAddress dc i2'0'
backupStack dc i2'0' backupStack dc i2'0'

View File

@ -32,19 +32,19 @@ drawShip entry
stz collision stz collision
lda $0,s lda $0,s
_collision #$0c00 _collision #$0c00,#$0
and #$f0ff and #$f0ff
ora #$0800 ora #$0800
sta $0,s sta $0,s
lda $a0,s lda $a0,s
_collision #$cc00 _collision #$cc00,#$a0
and #$00ff and #$00ff
ora #$8800 ora #$8800
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$00c0 _collision #$00c0,#$a2
and #$ff0f and #$ff0f
ora #$0080 ora #$0080
sta $a2,s sta $a2,s
@ -54,24 +54,24 @@ drawShip entry
tcs tcs
lda $0,s lda $0,s
_collision #$cc0c _collision #$cc0c,#$0
and #$00f0 and #$00f0
ora #$4804 ora #$4804
sta $0,s sta $0,s
lda $2,s lda $2,s
_collision #$00cc _collision #$00cc,#$2
and #$ff00 and #$ff00
ora #$0044 ora #$0044
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$cccc _collision #$cccc,#$a0
lda #$4884 lda #$4884
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$c0cc _collision #$c0cc,#$a2
and #$0f00 and #$0f00
ora #$8044 ora #$8044
sta $a2,s sta $a2,s
@ -81,24 +81,24 @@ drawShip entry
tcs tcs
lda $a0,s lda $a0,s
_collision #$cccc _collision #$cccc,#$a0
lda #$8888 lda #$8888
sta $0,s sta $0,s
lda $2,s lda $2,s
_collision #$c0cc _collision #$c0cc,#$2
and #$0f00 and #$0f00
ora #$8088 ora #$8088
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$cc0c _collision #$cc0c,#$a0
and #$00f0 and #$00f0
ora #$8808 ora #$8808
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$00cc _collision #$00cc,#$a2
and #$ff00 and #$ff00
ora #$0088 ora #$0088
sta $a2,s sta $a2,s
@ -108,32 +108,33 @@ drawShip entry
tcs tcs
lda $0,s lda $0,s
_collision #$cc00 _collision #$cc00,#$0
and #$00ff and #$00ff
ora #$8800 ora #$8800
sta $0,s sta $0,s
lda $2,s lda $2,s
_collision #$00c0 _collision #$00c0,#$2
and #$ff0f and #$ff0f
ora #$0080 ora #$0080
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$cc00 _collision #$cc00,#$a0
and #$00ff and #$00ff
ora #$8800 ora #$8800
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$00c0 _collision #$00c0,#$a2
and #$ff0f and #$ff0f
ora #$0080 ora #$0080
sta $a2,s sta $a2,s
_spriteFooter _spriteFooter
lda collision ldx collisionAddr
lda collision
rtl rtl
@ -156,19 +157,19 @@ drawShipShift entry
stz collision stz collision
lda $2,s lda $2,s
_collision #$00c0 _collision #$00c0,#$2
and #$ff0f and #$ff0f
ora #$0080 ora #$0080
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$0c00 _collision #$0c00,#$a0
and #$f0ff and #$f0ff
ora #$0800 ora #$0800
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$00cc _collision #$00cc,#$a2
and #$ff00 and #$ff00
ora #$0088 ora #$0088
sta $a2,s sta $a2,s
@ -178,25 +179,25 @@ drawShipShift entry
tcs tcs
lda $0,s lda $0,s
_collision #$cc00 _collision #$cc00,#$0
and #$00ff and #$00ff
ora #$4400 ora #$4400
sta $0,s sta $0,s
lda $2,s lda $2,s
_collision #$c0cc _collision #$c0cc,#$2
and #$0f00 and #$0f00
ora #$4084 ora #$4084
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$cc0c _collision #$cc0c,#$a0
and #$00f0 and #$00f0
ora #$4408 ora #$4408
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$cccc _collision #$cccc,#$a2
lda #$4884 lda #$4884
sta $a2,s sta $a2,s
@ -205,24 +206,24 @@ drawShipShift entry
tcs tcs
lda $0,s lda $0,s
_collision #$cc0c _collision #$cc0c,#$0
and #$00f0 and #$00f0
ora #$8808 ora #$8808
sta $0,s sta $0,s
lda $2,s lda $2,s
_collision #$cccc _collision #$cccc,#$2
lda #$8888 lda #$8888
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$cc00 _collision #$cc00,#$a0
and #$00ff and #$00ff
ora #$8800 ora #$8800
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$c0cc _collision #$c0cc,#$a2
and #$0f00 and #$0f00
ora #$8088 ora #$8088
sta $a2,s sta $a2,s
@ -232,31 +233,32 @@ drawShipShift entry
tcs tcs
lda $0,s lda $0,s
_collision #$0c00 _collision #$0c00,#$0
and #$f0ff and #$f0ff
ora #$0800 ora #$0800
sta $0,s sta $0,s
lda $2,s lda $2,s
_collision #$00cc _collision #$00cc,#$2
and #$ff00 and #$ff00
ora #$0088 ora #$0088
sta $2,s sta $2,s
lda $a0,s lda $a0,s
_collision #$0c00 _collision #$0c00,#$a0
and #$f0ff and #$f0ff
ora #$0800 ora #$0800
sta $a0,s sta $a0,s
lda $a2,s lda $a2,s
_collision #$00cc _collision #$00cc,#$a2
and #$ff00 and #$ff00
ora #$0088 ora #$0088
sta $a2,s sta $a2,s
_spriteFooter _spriteFooter
ldx collisionAddr
lda collision lda collision
rtl rtl
@ -342,5 +344,6 @@ drawPlayer entry
collision dc i2'0' collision dc i2'0'
collisionAddr dc i2'0'
end end

View File

@ -20,23 +20,18 @@ drawHalfShot entry
; $4 - Red ; $4 - Red
; $8 - Off-white ; $8 - Off-white
; ;
; ....|.... ; .R..
; ....|.... ; .R..
; ....|.... ; .R..
; ....|....
; ....|....
; ...R|....
; ...R|....
; ...R|....
tsc lda $0,s
adc #$280 and #$fff0
tcs ora #$0004
sta $0,s
lda $a0,s lda $a0,s
_collision #$0f00 and #$fff0
and #$f0ff ora #$0004
ora #$0400
sta $a0,s sta $a0,s
tsc tsc
@ -44,20 +39,11 @@ drawHalfShot entry
tcs tcs
lda $0,s lda $0,s
_collision #$0f00 and #$fff0
and #$f0ff ora #$0004
ora #$0400
sta $0,s sta $0,s
lda $a0,s
_collision #$0f00
and #$f0ff
ora #$0400
sta $a0,s
_spriteFooter _spriteFooter
lda collision
rtl rtl
@ -68,44 +54,30 @@ drawHalfShotShift entry
; $4 - Red ; $4 - Red
; $8 - Off-white ; $8 - Off-white
; ;
; ....|.... ; R...
; ....|.... ; R...
; ....|.... ; R...
; ....|....
; ....|....
; ....|R...
; ....|R...
; ....|R...
tsc lda $0,s
adc #$280 and #$ff0f
tcs ora #$0040
sta $0,s
lda $a2,s lda $a0,s
_collision #$00f0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $a2,s sta $a0,s
tsc tsc
adc #$140 adc #$140
tcs tcs
lda $2,s lda $0,s
_collision #$00f0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $2,s sta $0,s
lda $a2,s
_collision #$00f0
and #$ff0f
ora #$0040
sta $a2,s
_spriteFooter _spriteFooter
lda collision
rtl rtl
@ -116,29 +88,25 @@ drawShot entry
; $4 - Red ; $4 - Red
; $8 - Off-white ; $8 - Off-white
; ;
; ....|.... ; .R..
; ....|.... ; .R..
; ...R|.... ; .R..
; ...R|.... ; .R..
; ...R|.... ; .R..
; ...R|.... ; .R..
; ...R|....
; ...R|....
tsc stz collision
adc #$140
tcs
lda $0,s lda $0,s
_collision #$0f00 _collision #$000f,#$0
and #$f0ff and #$fff0
ora #$0400 ora #$0004
sta $0,s sta $0,s
lda $a0,s lda $a0,s
_collision #$0f00 _collision #$000f,#$a0
and #$f0ff and #$fff0
ora #$0400 ora #$0004
sta $a0,s sta $a0,s
tsc tsc
@ -146,15 +114,15 @@ drawShot entry
tcs tcs
lda $0,s lda $0,s
_collision #$0f00 _collision #$000f,#$0
and #$f0ff and #$fff0
ora #$0400 ora #$0004
sta $0,s sta $0,s
lda $a0,s lda $a0,s
_collision #$0f00 _collision #$000f,#$a0
and #$f0ff and #$fff0
ora #$0400 ora #$0004
sta $a0,s sta $a0,s
tsc tsc
@ -162,19 +130,20 @@ drawShot entry
tcs tcs
lda $0,s lda $0,s
_collision #$0f00 _collision #$000f,#$0
and #$f0ff and #$fff0
ora #$0400 ora #$0004
sta $0,s sta $0,s
lda $a0,s lda $a0,s
_collision #$0f00 _collision #$000f,#$a0
and #$f0ff and #$fff0
ora #$0400 ora #$0004
sta $a0,s sta $a0,s
_spriteFooter _spriteFooter
ldx collisionAddr
lda collision lda collision
rtl rtl
@ -186,69 +155,67 @@ drawShotShift entry
; $4 - Red ; $4 - Red
; $8 - Off-white ; $8 - Off-white
; ;
; ....|.... ; R...
; ....|.... ; R...
; ....|R... ; R...
; ....|R... ; R...
; ....|R... ; R...
; ....|R... ; R...
; ....|R...
; ....|R...
tsc stz collision
adc #$140
tcs
lda $2,s lda $0,s
_collision #$00f0 _collision #$00f0,#$0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $2,s sta $0,s
lda $a2,s lda $a0,s
_collision #$00f0 _collision #$00f0,#$a0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $a2,s sta $a0,s
tsc tsc
adc #$140 adc #$140
tcs tcs
lda $2,s lda $0,s
_collision #$00f0 _collision #$00f0,#$0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $2,s sta $0,s
lda $a2,s lda $a0,s
_collision #$00f0 _collision #$00f0,#$a0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $a2,s sta $a0,s
tsc tsc
adc #$140 adc #$140
tcs tcs
lda $2,s lda $0,s
_collision #$00f0 _collision #$00f0,#$0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $2,s sta $0,s
lda $a2,s lda $a0,s
_collision #$00f0 _collision #$00f0,#$a0
and #$ff0f and #$ff0f
ora #$0040 ora #$0040
sta $a2,s sta $a0,s
_spriteFooter _spriteFooter
ldx collisionAddr
lda collision lda collision
rtl rtl
collision dc i2'0' collision dc i2'0'
collisionAddr dc i2'0'
end end

View File

@ -704,14 +704,18 @@
mend mend
macro macro
_collision &mask _collision &mask,&addr
ldy collision
bne _alreadyCollided_&SYSCNT
tax tax
and &mask and &mask
beq _noCollision_&SYSCNT beq _noCollision_&SYSCNT
sta collision sta collision
tsc
clc
adc &addr
sta collisionAddr
_noCollision_&SYSCNT anop _noCollision_&SYSCNT anop
txa txa
_alreadyCollided_&SYSCNT anop
mend mend