Fixed crosshair rendering glitches on turn switch

This commit is contained in:
blondie7575 2023-12-24 12:16:27 -07:00
parent 11b2cc9048
commit c2dde9a4b7
3 changed files with 22 additions and 11 deletions

View File

@ -14,6 +14,9 @@ crosshairGameObject:
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .word 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
crosshairBackgroundStale:
.word 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; updateCrosshair ; updateCrosshair
@ -115,6 +118,8 @@ protectCrosshair:
sta PARAML0 sta PARAML0
jsr protectGameObject jsr protectGameObject
stz crosshairBackgroundStale
protectCrosshairDone: protectCrosshairDone:
pla pla
rts rts
@ -128,6 +133,9 @@ protectCrosshairDone:
unrenderCrosshair: unrenderCrosshair:
pha pha
lda crosshairBackgroundStale
bne unrenderCrosshairDone
lda #crosshairGameObject lda #crosshairGameObject
sta PARAML0 sta PARAML0
jsr unrenderGameObject jsr unrenderGameObject

View File

@ -44,6 +44,8 @@ beginGameplay:
jsr renderInventory jsr renderInventory
jsr protectPlayers jsr protectPlayers
jsr renderPlayers jsr renderPlayers
ldy #0
jsr updateCrosshair
; Fade in from menu ; Fade in from menu
lda #basePalette lda #basePalette
@ -95,6 +97,7 @@ gameplayLoopScroll:
bmi gameplayLoopAngleCheck bmi gameplayLoopAngleCheck
jsr scrollMap jsr scrollMap
ldy currentPlayer
jsr updateCrosshair jsr updateCrosshair
gameplayLoopAngleCheck: gameplayLoopAngleCheck:
@ -107,7 +110,7 @@ gameplayLoopRenderJmp:
gameplayLoopAngle: gameplayLoopAngle:
; Update aim angle if needed ; Update aim angle if needed
lda angleDeltaRequested lda angleDeltaRequested
beq gameplayLoopAim beq gameplayLoopPower
jsr changeAngle jsr changeAngle
gameplayLoopAim: gameplayLoopAim:
@ -155,8 +158,11 @@ gameplayLoopRender:
beq gameplayLoopRenderPlayersAnyway beq gameplayLoopRenderPlayersAnyway
jsr unrenderPlayers jsr unrenderPlayers
jsr protectPlayers jsr protectPlayers
jsr unrenderCrosshair
lda dirtExplosionActive ; Crosshair is dirty if map scrolled and dirt is finished
bne gameplayLoopRenderPlayersAnyway
jsr protectCrosshair jsr protectCrosshair
jsr renderCrosshair
gameplayLoopRenderPlayersAnyway: gameplayLoopRenderPlayersAnyway:
jsr renderPlayers jsr renderPlayers
@ -297,8 +303,6 @@ endTurnHeader:
jsr renderPlayerHeader jsr renderPlayerHeader
jsr renderInventory jsr renderInventory
stz turnRequested stz turnRequested
jsr protectCrosshair
rts rts
endTurnFocusPlayer0: endTurnFocusPlayer0:
@ -338,6 +342,8 @@ scrollMap:
lda projectileActive ; Crosshair is visible if projectile isn't lda projectileActive ; Crosshair is visible if projectile isn't
beq scrollMapApplyScrolling beq scrollMapApplyScrolling
jsr unrenderCrosshair jsr unrenderCrosshair
lda #1
sta crosshairBackgroundStale
scrollMapApplyScrolling: scrollMapApplyScrolling:
pla pla
@ -358,7 +364,6 @@ scrollMapApplyScrolling:
sta playersDirty sta playersDirty
sta projectilesDirty sta projectilesDirty
sta terrainDirty sta terrainDirty
sta crosshairDirty
rts rts
@ -486,9 +491,7 @@ playerMoveRequested:
terrainDirty: terrainDirty:
.word 1 .word 1
playersDirty: playersDirty:
.word 0 .word 1
crosshairDirty:
.word 0
projectilesDirty: projectilesDirty:
.word 1 .word 1
inventoryDirty: inventoryDirty:

View File

@ -180,8 +180,8 @@
pha pha
lda breakpoint lda breakpoint
beq nobrk beq nobrk
lda #1 ; lda #1
sta $e1c029 ; sta $e1c029
pla pla
brk brk
nobrk: nobrk: