Fixed many bugs in crosshair and input processing

This commit is contained in:
blondie7575 2023-06-24 15:25:08 -07:00
parent 509af5c166
commit 3b7ab68342
3 changed files with 40 additions and 17 deletions

View File

@ -36,7 +36,7 @@ updateCrosshair:
; Compute screenspace X ; Compute screenspace X
sta SCRATCHL sta SCRATCHL
clc clc
lda playerData+GO_POSX lda playerData+GO_POSX,y
adc SCRATCHL adc SCRATCHL
sta crosshairGameObject+GO_POSX sta crosshairGameObject+GO_POSX
bra updateCrosshairCalcY bra updateCrosshairCalcY
@ -48,7 +48,7 @@ updateCrosshairNegX:
; Compute screenspace X ; Compute screenspace X
sta SCRATCHL sta SCRATCHL
sec sec
lda playerData+GO_POSX lda playerData+GO_POSX,y
sbc SCRATCHL sbc SCRATCHL
sta crosshairGameObject+GO_POSX sta crosshairGameObject+GO_POSX
@ -62,7 +62,7 @@ updateCrosshairCalcY:
; Compute screenspace Y ; Compute screenspace Y
clc clc
lda playerData+GO_POSY lda playerData+GO_POSY,y
adc SCRATCHL adc SCRATCHL
sta crosshairGameObject+GO_POSY sta crosshairGameObject+GO_POSY
@ -77,15 +77,14 @@ updateCrosshairDone:
; ;
; ;
renderCrosshair: renderCrosshair:
SAVE_AXY pha
lda #crosshairGameObject lda #crosshairGameObject
sta PARAML0 sta PARAML0
lda #15 lda #15
jsr renderGameObject jsr renderGameObject
renderCrosshairDone: renderCrosshairDone:
RESTORE_AXY pla
rts rts

View File

@ -76,7 +76,13 @@ beginGameplay:
; jsr clipTerrain ; jsr clipTerrain
gameplayLoop: gameplayLoop:
jsr kbdScan lda projectileActive
bpl gameplayLoopKeyboardSkip
jsr kbdScanGameplay
gameplayLoopKeyboardSkip:
jsr kbdScanDebug
; BORDER_COLOR #$F ; BORDER_COLOR #$F
jsr nextVBL jsr nextVBL
@ -94,8 +100,10 @@ gameplayLoopBeginUpdate:
; ;
lda #1 lda #1
sta projectilesDirty sta projectilesDirty
lda projectileActive lda projectileActive ; Skip interactivity during shots, but still allow map scrolling
bpl gameplayLoopShotTracking ; Skip input during shots bpl gameplayLoopShotTracking
lda dirtExplosionActive
bne gameplayLoopRender ; Skip interactivity during dirt explosions
bra gameplayLoopScroll bra gameplayLoopScroll
gameplayLoopShotTracking: gameplayLoopShotTracking:
@ -107,9 +115,13 @@ gameplayLoopScroll:
; Scroll map if needed ; Scroll map if needed
lda mapScrollRequested lda mapScrollRequested
bmi gameplayLoopAngle bmi gameplayLoopAngleCheck
jsr scrollMap jsr scrollMap
gameplayLoopAngleCheck:
lda projectileActive ; Skip interactivity during shots
bpl gameplayLoopRender
gameplayLoopAngle: gameplayLoopAngle:
; Update aim angle if needed ; Update aim angle if needed
lda angleDeltaRequested lda angleDeltaRequested
@ -131,6 +143,7 @@ gameplayLoopPower:
gameplayLoopFire: gameplayLoopFire:
lda fireRequested lda fireRequested
beq gameplayLoopRender beq gameplayLoopRender
jsr unrenderCrosshair
jsr fire jsr fire
; BORDER_COLOR #$2 ; BORDER_COLOR #$2

25
input.s
View File

@ -6,13 +6,13 @@
; ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; kbdScan ; kbdScanGameplay/Debug
; Processes keyboard input ; Processes keyboard input
; ;
; Trashes A ; Trashes A
; ;
kbdScan: kbdScanGameplay:
BITS8 BITS8
lda KBD lda KBD
bpl kbdScanDone bpl kbdScanDone
@ -34,18 +34,29 @@ kbdScan:
beq kbdScanX beq kbdScanX
cmp #(' ' + $80) cmp #(' ' + $80)
beq kbdScanSpace beq kbdScanSpace
cmp #(9 + $80)
bne kbdScanDone
jmp kbdScanTab
kbdScanDone:
BITS16
rts
kbdScanDebug:
BITS8
lda KBD
bpl kbdScanDone
sta KBDSTROBE
cmp #(27 + $80) cmp #(27 + $80)
beq kbdScanESC beq kbdScanESC
cmp #(127 + $80) cmp #(127 + $80)
beq kbdScanDEL beq kbdScanDEL
cmp #('=' + $80) cmp #('=' + $80)
beq kbdScanEquals beq kbdScanEquals
cmp #(9 + $80) bra kbdScanDone
beq kbdScanTab
kbdScanDone:
BITS16
rts
kbdScanRightArrow: kbdScanRightArrow:
BITS16 BITS16