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

View File

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

Binary file not shown.

View File

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

View File

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

124
terrain.s
View File

@ -12,7 +12,7 @@ VISIBLETERRAINWIDTH = TERRAINWIDTH/4 ; In words- width minus jump return padding
VISIBLETERRAINWINDOW = 80 ; In words
MAXSPANSPERROW = 15
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrain
;
@ -60,7 +60,7 @@ renderRowComplete:
renderTerrainDone:
SLOWGRAPHICS
rts
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrainSpans:
@ -68,17 +68,46 @@ renderTerrainDone:
;
renderTerrainSpans:
pha
lda #MAXTERRAINHEIGHT-1;-7;-36
stz terrainSpanWriteCacheLen
lda #MAXTERRAINHEIGHT-1
renderTerrainSpansLoop:
sta PARAML1
jsr renderTerrainRowSpans
dec
bpl renderTerrainSpansLoop
;brk
pla
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:
;
@ -105,7 +134,7 @@ renderTerrainRowSpans:
sec
sbc PARAML1
tax
jsr enableFillMode
;jsr enableFillMode
asl
tax
lda vramYOffset,x
@ -119,6 +148,7 @@ renderTerrainRowSpans:
lda #0
clc
renderTerrainRowSpansFindLeftLoop:
adc terrainSpanData+2,y
cmp leftScreenEdge
@ -144,6 +174,16 @@ renderTerrainRowSpansLoop:
lda SCRATCHL
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
clc
txa
@ -166,8 +206,7 @@ renderTerrainRowSpansDone:
RESTORE_AXY
rts
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrainFillMode:
;
@ -175,7 +214,7 @@ renderTerrainRowSpansDone:
;
renderTerrainFillMode:
jsr renderTerrainSpans
brk
rts
SAVE_AXY
ldy #0
@ -189,8 +228,8 @@ renderTerrainFillModeLoop:
iny
cpy #MAXTERRAINHEIGHT
bmi renderTerrainFillModeLoop
renderTerrainFillModeDone:
brk
RESTORE_AXY
rts
@ -261,7 +300,7 @@ renderTerrainRowFillCurrent:
.word 0
renderTerrainRowFillColumn:
.word 0
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; craterTerrain
@ -329,7 +368,7 @@ craterTerrainDone:
RESTORE_AX
rts
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; clipTerrain
;
@ -448,7 +487,7 @@ compileTerrainLoop:
bra compileTerrainLoop
compileTerrainDone:
jsr compileTerrainSpans
;jsr compileTerrainSpans
RESTORE_AY
rts
@ -582,7 +621,7 @@ compileTerrainColumn3BG:
compileTerrainOpcode:
.word 0
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compileTerrainSpans:
@ -590,7 +629,7 @@ compileTerrainOpcode:
;
compileTerrainSpans:
pha
lda #0; MAXTERRAINHEIGHT-7; 0
lda #0
compileTerrainSpansLoop:
sta PARAML1
@ -652,7 +691,6 @@ compileTerrainSpansRowBlackLoop:
bne compileTerrainSpansRowBlackLoop
compileTerrainSpansBlackEnd:
BREAK
tya ; Store this span's length
sta (SCRATCHL)
inc SCRATCHL
@ -690,11 +728,6 @@ compileTerrainSpansRowGreenLoop:
bne compileTerrainSpansRowGreenLoop
compileTerrainSpansGreenEnd:
; iny
; lda #1 ;
; sta breakpoint ;
tya ; Store this span's length
sta (SCRATCHL)
inc SCRATCHL
@ -707,6 +740,47 @@ compileTerrainSpansGreenEnd:
ldy #0
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
;
@ -720,7 +794,6 @@ generateTerrain:
sta SCRATCHL
generateTerrainLoop:
lda sineTable,x
lsr
@ -761,6 +834,7 @@ terrainData:
.endrepeat
terrainDataEnd:
.if 0
compiledTerrain:
.repeat COMPILEDTERRAINROW * MAXTERRAINHEIGHT
.byte 0
@ -771,6 +845,7 @@ clippedTerrainData:
.repeat MAXTERRAINHEIGHT
.byte 0,0,0,0 ; xx,jmp,addr
.endrepeat
.endif
terrainSpanData:
.repeat MAXTERRAINHEIGHT
@ -780,3 +855,10 @@ terrainSpanData:
.endrepeat
.endrepeat
terrainSpanWriteCache:
.repeat 512
.word 0
.endrepeat
terrainSpanWriteCacheLen:
.word 0