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

View File

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

25
input.s
View File

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