Partial fill mode now working

This commit is contained in:
blondie7575 2017-12-24 12:36:31 -07:00
parent c55d07c16d
commit 157ec99cc7
6 changed files with 119 additions and 29 deletions

View File

@ -28,8 +28,9 @@ beginGameplay:
; Generate, compile, and clip terrain ; Generate, compile, and clip terrain
jsr generateTerrain jsr generateTerrain
jsr compileTerrain jsr compileTerrainSpans
jsr clipTerrain ; jsr compileTerrain
; jsr clipTerrain
; Create players ; Create players
lda #56 lda #56
@ -45,6 +46,7 @@ beginGameplay:
jsr protectPlayers jsr protectPlayers
jsr protectProjectiles jsr protectProjectiles
jsr prepareRowRendering
gameplayLoop: gameplayLoop:
@ -55,7 +57,8 @@ gameplayLoop:
; lda terrainDirty ; lda terrainDirty
; beq gameplayLoopKbd ; beq gameplayLoopKbd
BORDER_COLOR #$3 BORDER_COLOR #$3
jsr renderTerrainFillMode jsr renderTerrainSpans
; jsr unrenderTerrainSpans
stz terrainDirty stz terrainDirty
BORDER_COLOR #$1 BORDER_COLOR #$1
@ -222,7 +225,8 @@ endGame:
; A = New map scroll position ; A = New map scroll position
; ;
scrollMap: scrollMap:
jsr unclipTerrain ; jsr unclipTerrain
jsr unrenderTerrainSpans
jsr unrenderPlayers jsr unrenderPlayers
jsr unrenderProjectiles jsr unrenderProjectiles
@ -233,7 +237,7 @@ scrollMap:
adc #160-GAMEOBJECTWIDTH/4-1 adc #160-GAMEOBJECTWIDTH/4-1
sta rightScreenEdge sta rightScreenEdge
jsr clipTerrain ; jsr clipTerrain
lda #$ffff lda #$ffff
sta mapScrollRequested sta mapScrollRequested

View File

@ -106,11 +106,13 @@ enableFillMode:
; Trashes A ; Trashes A
disableFillMode: disableFillMode:
SAVE_AXY
BITS8 BITS8
lda $e19d00,x lda $e19d00,x
and #%11011111 and #%11011111
sta $e19d00,x sta $e19d00,x
BITS16 BITS16
RESTORE_AXY
rts rts
@ -195,12 +197,14 @@ drawNumber:
; Trashes A ; Trashes A
; ;
.macro BORDER_COLOR color .macro BORDER_COLOR color
SAVE_AXY
BITS8 BITS8
lda BORDERCOLOR lda BORDERCOLOR
and #$f0 and #$f0
ora color ora color
sta BORDERCOLOR sta BORDERCOLOR
BITS16 BITS16
RESTORE_AXY
.endmacro .endmacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Binary file not shown.

View File

@ -34,10 +34,10 @@ quitGame:
.include "graphics.s" .include "graphics.s"
.include "font.s" .include "font.s"
.include "player.s"
.include "terrain.s" .include "terrain.s"
.include "collision.s" .include "collision.s"
.include "gameobject.s" .include "gameobject.s"
.include "player.s"
.include "utility.s" .include "utility.s"
.include "tables.s" .include "tables.s"
.include "gamemanager.s" .include "gamemanager.s"

View File

@ -491,7 +491,7 @@ processTerrainImpact:
tay tay
jsr craterTerrain jsr craterTerrain
jsr compileTerrain ; jsr compileTerrain
jsr clipTerrain ; jsr clipTerrain
rts rts

124
terrain.s
View File

@ -12,7 +12,7 @@ VISIBLETERRAINWIDTH = TERRAINWIDTH/4 ; In words- width minus jump return padding
VISIBLETERRAINWINDOW = 80 ; In words VISIBLETERRAINWINDOW = 80 ; In words
MAXSPANSPERROW = 15 MAXSPANSPERROW = 15
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrain ; renderTerrain
; ;
@ -60,7 +60,7 @@ renderRowComplete:
renderTerrainDone: renderTerrainDone:
SLOWGRAPHICS SLOWGRAPHICS
rts rts
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrainSpans: ; renderTerrainSpans:
@ -68,17 +68,46 @@ renderTerrainDone:
; ;
renderTerrainSpans: renderTerrainSpans:
pha pha
lda #MAXTERRAINHEIGHT-1;-7;-36 stz terrainSpanWriteCacheLen
lda #MAXTERRAINHEIGHT-1
renderTerrainSpansLoop: renderTerrainSpansLoop:
sta PARAML1 sta PARAML1
jsr renderTerrainRowSpans jsr renderTerrainRowSpans
dec dec
bpl renderTerrainSpansLoop bpl renderTerrainSpansLoop
;brk
pla pla
rts rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; unrenderTerrainSpans:
;
;
unrenderTerrainSpans:
SAVE_AXY
ldy #0
unrenderTerrainSpansLoop:
lda terrainSpanWriteCache,y
tax
lda #0
sta VRAMBANK,x
iny
iny
cpy terrainSpanWriteCacheLen
bne unrenderTerrainSpansLoop
stz terrainSpanWriteCacheLen
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrainRowSpans: ; renderTerrainRowSpans:
; ;
@ -105,7 +134,7 @@ renderTerrainRowSpans:
sec sec
sbc PARAML1 sbc PARAML1
tax tax
jsr enableFillMode ;jsr enableFillMode
asl asl
tax tax
lda vramYOffset,x lda vramYOffset,x
@ -119,6 +148,7 @@ renderTerrainRowSpans:
lda #0 lda #0
clc clc
renderTerrainRowSpansFindLeftLoop: renderTerrainRowSpansFindLeftLoop:
adc terrainSpanData+2,y adc terrainSpanData+2,y
cmp leftScreenEdge cmp leftScreenEdge
@ -144,6 +174,16 @@ renderTerrainRowSpansLoop:
lda SCRATCHL lda SCRATCHL
sta VRAMBANK,x sta VRAMBANK,x
; Cache the index we wrote to so we can erase later
phy
ldy terrainSpanWriteCacheLen
txa
sta terrainSpanWriteCache,y
iny
iny
sty terrainSpanWriteCacheLen
ply
; Advance to end of span ; Advance to end of span
clc clc
txa txa
@ -166,8 +206,7 @@ renderTerrainRowSpansDone:
RESTORE_AXY RESTORE_AXY
rts rts
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrainFillMode: ; renderTerrainFillMode:
; ;
@ -175,7 +214,7 @@ renderTerrainRowSpansDone:
; ;
renderTerrainFillMode: renderTerrainFillMode:
jsr renderTerrainSpans jsr renderTerrainSpans
brk rts
SAVE_AXY SAVE_AXY
ldy #0 ldy #0
@ -189,8 +228,8 @@ renderTerrainFillModeLoop:
iny iny
cpy #MAXTERRAINHEIGHT cpy #MAXTERRAINHEIGHT
bmi renderTerrainFillModeLoop bmi renderTerrainFillModeLoop
renderTerrainFillModeDone: renderTerrainFillModeDone:
brk
RESTORE_AXY RESTORE_AXY
rts rts
@ -261,7 +300,7 @@ renderTerrainRowFillCurrent:
.word 0 .word 0
renderTerrainRowFillColumn: renderTerrainRowFillColumn:
.word 0 .word 0
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; craterTerrain ; craterTerrain
@ -329,7 +368,7 @@ craterTerrainDone:
RESTORE_AX RESTORE_AX
rts rts
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; clipTerrain ; clipTerrain
; ;
@ -448,7 +487,7 @@ compileTerrainLoop:
bra compileTerrainLoop bra compileTerrainLoop
compileTerrainDone: compileTerrainDone:
jsr compileTerrainSpans ;jsr compileTerrainSpans
RESTORE_AY RESTORE_AY
rts rts
@ -582,7 +621,7 @@ compileTerrainColumn3BG:
compileTerrainOpcode: compileTerrainOpcode:
.word 0 .word 0
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainSpans: ; compileTerrainSpans:
@ -590,7 +629,7 @@ compileTerrainOpcode:
; ;
compileTerrainSpans: compileTerrainSpans:
pha pha
lda #0; MAXTERRAINHEIGHT-7; 0 lda #0
compileTerrainSpansLoop: compileTerrainSpansLoop:
sta PARAML1 sta PARAML1
@ -652,7 +691,6 @@ compileTerrainSpansRowBlackLoop:
bne compileTerrainSpansRowBlackLoop bne compileTerrainSpansRowBlackLoop
compileTerrainSpansBlackEnd: compileTerrainSpansBlackEnd:
BREAK
tya ; Store this span's length tya ; Store this span's length
sta (SCRATCHL) sta (SCRATCHL)
inc SCRATCHL inc SCRATCHL
@ -690,11 +728,6 @@ compileTerrainSpansRowGreenLoop:
bne compileTerrainSpansRowGreenLoop bne compileTerrainSpansRowGreenLoop
compileTerrainSpansGreenEnd: compileTerrainSpansGreenEnd:
; iny
; lda #1 ;
; sta breakpoint ;
tya ; Store this span's length tya ; Store this span's length
sta (SCRATCHL) sta (SCRATCHL)
inc SCRATCHL inc SCRATCHL
@ -707,6 +740,47 @@ compileTerrainSpansGreenEnd:
ldy #0 ldy #0
bra compileTerrainSpansRowBlackStart bra compileTerrainSpansRowBlackStart
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; prepareRowRendering:
;
; Set SCBs to match rendering mode of each terrain line
;
; Trashes SCRATCHL, SCRATCHL2
;
prepareRowRendering:
SAVE_AXY
ldx #199
stz SCRATCHL2
prepareRowRenderingLoop:
lda #0
PLAYERPTR_Y
sec
lda playerData+GO_POSY,y
sbc #GAMEOBJECTHEIGHT
cmp SCRATCHL2
bcc prepareRowRenderingCompileMode
beq prepareRowRenderingCompileMode
jsr enableFillMode
bra prepareRowRenderingLoopNext
prepareRowRenderingCompileMode:
jsr disableFillMode
prepareRowRenderingLoopNext:
inc SCRATCHL2
dex
cpx #200-MAXTERRAINHEIGHT
bne prepareRowRenderingLoop
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; generateTerrain ; generateTerrain
; ;
@ -720,7 +794,6 @@ generateTerrain:
sta SCRATCHL sta SCRATCHL
generateTerrainLoop: generateTerrainLoop:
lda sineTable,x lda sineTable,x
lsr lsr
@ -761,6 +834,7 @@ terrainData:
.endrepeat .endrepeat
terrainDataEnd: terrainDataEnd:
.if 0
compiledTerrain: compiledTerrain:
.repeat COMPILEDTERRAINROW * MAXTERRAINHEIGHT .repeat COMPILEDTERRAINROW * MAXTERRAINHEIGHT
.byte 0 .byte 0
@ -771,6 +845,7 @@ clippedTerrainData:
.repeat MAXTERRAINHEIGHT .repeat MAXTERRAINHEIGHT
.byte 0,0,0,0 ; xx,jmp,addr .byte 0,0,0,0 ; xx,jmp,addr
.endrepeat .endrepeat
.endif
terrainSpanData: terrainSpanData:
.repeat MAXTERRAINHEIGHT .repeat MAXTERRAINHEIGHT
@ -780,3 +855,10 @@ terrainSpanData:
.endrepeat .endrepeat
.endrepeat .endrepeat
terrainSpanWriteCache:
.repeat 512
.word 0
.endrepeat
terrainSpanWriteCacheLen:
.word 0