Groundwork for optimizing terrain clipping in merged renderer

This commit is contained in:
blondie7575 2018-01-21 14:21:44 -08:00
parent f0631386b1
commit 82f829befc
3 changed files with 49 additions and 38 deletions

View File

@ -39,7 +39,7 @@ lastCompiledTerrainY = $75 ; The highest Y value that the compiled renderer must
; Terrain constants ; Terrain constants
TERRAINWIDTH = 640 ; In pixels TERRAINWIDTH = 640 ; In pixels
MAXTERRAINHEIGHT = 100 ; In pixels MAXTERRAINHEIGHT = 100 ; In pixels
COMPILEDTERRAINROW = TERRAINWIDTH/4+3 ; In words, +2 to make room for clipping jump at end of row COMPILEDTERRAINROW = TERRAINWIDTH/4+3 ; In words, +3 to make room for clipping jump at end of row
VISIBLETERRAINWIDTH = TERRAINWIDTH/4 ; In words- width minus jump return padding VISIBLETERRAINWIDTH = TERRAINWIDTH/4 ; In words- width minus jump return padding
VISIBLETERRAINWINDOW = 80 ; In words VISIBLETERRAINWINDOW = 80 ; In words
MAXSPANSPERROW = 15 MAXSPANSPERROW = 15

View File

@ -31,7 +31,7 @@ beginGameplay:
jsr generateTerrain jsr generateTerrain
; Create players ; Create players
lda #106;#56 lda #56
ldy #0 ldy #0
jsr playerCreate jsr playerCreate
@ -48,35 +48,24 @@ beginGameplay:
jsr compileTerrain jsr compileTerrain
jsr clipTerrain jsr clipTerrain
jsl renderTerrainSpans
gameplayLoop: gameplayLoop:
jsr syncVBL jsr syncVBL
BORDER_COLOR #$0 BORDER_COLOR #$0
; Render the terrain if needed ;;;;;;;;;;;
lda terrainDirty ; Update
beq gameplayLoopKbd ;
BORDER_COLOR #$3 ; lda projectileActive
jsl renderTerrainSpans ; bpl gameplayLoopShotTracking ; Skip input during shots
jsr renderTerrain
stz terrainDirty
BORDER_COLOR #$1
; Render players
jsr renderPlayers
gameplayLoopKbd:
lda projectileActive
bpl gameplayLoopShotTracking ; Skip input during shots
; Check for keys down ; Check for keys down
jsr kbdScan jsr kbdScan
; Check for pause ; Check for pause
lda paused ; lda paused
bne gameplayLoopEndFrame ; bne gameplayLoopEndFrame
gameplayLoopScroll: gameplayLoopScroll:
@ -99,20 +88,42 @@ gameplayLoopPower:
gameplayLoopFire: gameplayLoopFire:
lda fireRequested lda fireRequested
beq gameplayLoopProjectiles beq gameplayLoopRender
jsr fire jsr fire
gameplayLoopProjectiles: gameplayLoopRender:
sta KBDSTROBE sta KBDSTROBE
jsr unrenderProjectiles
jsr updateProjectilePhysics
jsr protectProjectiles
jsr renderProjectiles
jsr updateProjectileCollisions
lda turnRequested ;;;;;;;;;;;
beq gameplayLoopVictoryCondition ; Render
jsr endTurn ;
; Render the terrain if needed
; lda terrainDirty
; beq gameplayLoopProjectiles
BORDER_COLOR #$3
jsr unclipTerrain
jsl unrenderTerrainSpans
jsr clipTerrain
jsl renderTerrainSpans
jsr renderTerrain
stz terrainDirty
BORDER_COLOR #$1
; Render players
; jsr renderPlayers
gameplayLoopProjectiles:
; jsr unrenderProjectiles
; jsr updateProjectilePhysics
; jsr protectProjectiles
; jsr renderProjectiles
; jsr updateProjectileCollisions
; lda turnRequested
; beq gameplayLoopVictoryCondition
; jsr endTurn
gameplayLoopVictoryCondition: gameplayLoopVictoryCondition:
lda gameOver lda gameOver
@ -127,8 +138,8 @@ gameplayLoopContinue:
jmp gameplayLoop jmp gameplayLoop
gameplayLoopShotTracking: gameplayLoopShotTracking:
jsr trackActiveShot ; jsr trackActiveShot
bra gameplayLoopScroll ; bra gameplayLoopScroll
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -229,8 +240,8 @@ endGame:
scrollMap: scrollMap:
jsr unclipTerrain jsr unclipTerrain
jsl unrenderTerrainSpans jsl unrenderTerrainSpans
jsr unrenderPlayers ; jsr unrenderPlayers
jsr unrenderProjectiles ; jsr unrenderProjectiles
sta mapScrollPos sta mapScrollPos
asl asl
@ -243,9 +254,9 @@ scrollMap:
lda #$ffff lda #$ffff
sta mapScrollRequested sta mapScrollRequested
jsr protectPlayers ; jsr protectPlayers
jsr protectProjectiles ; jsr protectProjectiles
jsr renderPlayers ; jsr renderPlayers
lda #1 lda #1
sta terrainDirty sta terrainDirty
rts rts

Binary file not shown.