From 3b7ab683422e269e49e5ec1803a90c8150dc5da0 Mon Sep 17 00:00:00 2001 From: blondie7575 Date: Sat, 24 Jun 2023 15:25:08 -0700 Subject: [PATCH] Fixed many bugs in crosshair and input processing --- crosshair.s | 11 +++++------ gamemanager.s | 21 +++++++++++++++++---- input.s | 25 ++++++++++++++++++------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/crosshair.s b/crosshair.s index bb16077..6aaa9af 100644 --- a/crosshair.s +++ b/crosshair.s @@ -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 diff --git a/gamemanager.s b/gamemanager.s index 00e3401..158c4b6 100644 --- a/gamemanager.s +++ b/gamemanager.s @@ -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 diff --git a/input.s b/input.s index c3255a9..8c76e9c 100644 --- a/input.s +++ b/input.s @@ -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