mirror of
https://github.com/blondie7575/GSCats.git
synced 2025-02-20 21:29:00 +00:00
Groundwork for span-based fill mode rendering
This commit is contained in:
parent
6832c9adea
commit
c55d07c16d
BIN
V2Make.scpt
BIN
V2Make.scpt
Binary file not shown.
@ -49,12 +49,15 @@ beginGameplay:
|
|||||||
gameplayLoop:
|
gameplayLoop:
|
||||||
|
|
||||||
jsr syncVBL
|
jsr syncVBL
|
||||||
|
BORDER_COLOR #$0
|
||||||
|
|
||||||
; Render the terrain if needed
|
; Render the terrain if needed
|
||||||
lda terrainDirty
|
; lda terrainDirty
|
||||||
beq gameplayLoopKbd
|
; beq gameplayLoopKbd
|
||||||
jsr renderTerrain
|
BORDER_COLOR #$3
|
||||||
|
jsr renderTerrainFillMode
|
||||||
stz terrainDirty
|
stz terrainDirty
|
||||||
|
BORDER_COLOR #$1
|
||||||
|
|
||||||
; Render players
|
; Render players
|
||||||
jsr renderPlayers
|
jsr renderPlayers
|
||||||
@ -113,8 +116,10 @@ gameplayLoopVictoryCondition:
|
|||||||
|
|
||||||
gameplayLoopEndFrame:
|
gameplayLoopEndFrame:
|
||||||
lda quitRequested
|
lda quitRequested
|
||||||
beq gameplayLoop
|
beq gameplayLoopContinue
|
||||||
jmp quitGame
|
jmp quitGame
|
||||||
|
gameplayLoopContinue:
|
||||||
|
jmp gameplayLoop
|
||||||
|
|
||||||
gameplayLoopShotTracking:
|
gameplayLoopShotTracking:
|
||||||
jsr trackActiveShot
|
jsr trackActiveShot
|
||||||
@ -287,7 +292,7 @@ fire:
|
|||||||
|
|
||||||
|
|
||||||
basePalette:
|
basePalette:
|
||||||
.word $0aef,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$0000,$07b,$0000,$0000,$0000,$0000,$0000,$0000,$0FFF
|
.word $0aef,$0080,$0861,$0c93,$0eb4,$0d66,$0f9a,$0000,$007b,$0000,$0000,$0000,$0000,$0000,$0000,$0FFF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,14 +86,14 @@ initSCBsLoop:
|
|||||||
;
|
;
|
||||||
; X = Scan line
|
; X = Scan line
|
||||||
;
|
;
|
||||||
; Trashes A
|
|
||||||
|
|
||||||
enableFillMode:
|
enableFillMode:
|
||||||
|
SAVE_AXY
|
||||||
BITS8
|
BITS8
|
||||||
lda $e19d00,x
|
lda $e19d00,x
|
||||||
ora #%00100000
|
ora #%00100000
|
||||||
sta $e19d00,x
|
sta $e19d00,x
|
||||||
BITS16
|
BITS16
|
||||||
|
RESTORE_AXY
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
4
input.s
4
input.s
@ -48,7 +48,7 @@ kbdScanRightArrow:
|
|||||||
lda mapScrollPos
|
lda mapScrollPos
|
||||||
cmp #VISIBLETERRAINWIDTH-VISIBLETERRAINWINDOW
|
cmp #VISIBLETERRAINWIDTH-VISIBLETERRAINWINDOW
|
||||||
beq kbdScanDone
|
beq kbdScanDone
|
||||||
inc
|
; inc
|
||||||
inc
|
inc
|
||||||
sta mapScrollRequested
|
sta mapScrollRequested
|
||||||
rts
|
rts
|
||||||
@ -59,7 +59,7 @@ kbdScanLeftArrow:
|
|||||||
lda mapScrollPos
|
lda mapScrollPos
|
||||||
beq kbdScanDone
|
beq kbdScanDone
|
||||||
dec
|
dec
|
||||||
dec
|
; dec
|
||||||
sta mapScrollRequested
|
sta mapScrollRequested
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
9
macros.s
9
macros.s
@ -168,6 +168,15 @@ nobrk:
|
|||||||
pla
|
pla
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
.macro HARDBRK
|
||||||
|
pha
|
||||||
|
lda #1
|
||||||
|
sta $e1c029
|
||||||
|
pla
|
||||||
|
brk
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;
|
;;;;;;;;;;
|
||||||
; Stack Macros
|
; Stack Macros
|
||||||
|
|
||||||
|
336
terrain.s
336
terrain.s
@ -10,13 +10,14 @@ 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, +2 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
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; renderTerrain
|
; renderTerrain
|
||||||
;
|
;
|
||||||
; No stack operations permitted here!
|
; No stack operations permitted here!
|
||||||
;
|
;
|
||||||
; Current implementation: Unknown cycles per row
|
|
||||||
; Trashes all registers
|
; Trashes all registers
|
||||||
;
|
;
|
||||||
renderTerrain:
|
renderTerrain:
|
||||||
@ -61,6 +62,207 @@ renderTerrainDone:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; renderTerrainSpans:
|
||||||
|
;
|
||||||
|
;
|
||||||
|
renderTerrainSpans:
|
||||||
|
pha
|
||||||
|
lda #MAXTERRAINHEIGHT-1;-7;-36
|
||||||
|
|
||||||
|
renderTerrainSpansLoop:
|
||||||
|
sta PARAML1
|
||||||
|
jsr renderTerrainRowSpans
|
||||||
|
dec
|
||||||
|
bpl renderTerrainSpansLoop
|
||||||
|
;brk
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; renderTerrainRowSpans:
|
||||||
|
;
|
||||||
|
; PARAML1 = Row index (bottom relative)
|
||||||
|
;
|
||||||
|
; Trashes SCRATCHL,SCRATCHL2,PARAML0
|
||||||
|
;
|
||||||
|
renderTerrainRowSpans:
|
||||||
|
SAVE_AXY
|
||||||
|
|
||||||
|
; Find row data
|
||||||
|
lda PARAML1
|
||||||
|
asl ; Shifts must match MAXSPANSPERROW*2 + 2
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
tay
|
||||||
|
lda terrainSpanData,y
|
||||||
|
sta SCRATCHL ; Track span color
|
||||||
|
|
||||||
|
; Find VRAM row
|
||||||
|
lda #200
|
||||||
|
sec
|
||||||
|
sbc PARAML1
|
||||||
|
tax
|
||||||
|
jsr enableFillMode
|
||||||
|
asl
|
||||||
|
tax
|
||||||
|
lda vramYOffset,x
|
||||||
|
clc
|
||||||
|
adc #$2000
|
||||||
|
tax
|
||||||
|
adc #160
|
||||||
|
sta PARAML0 ; Watch for end of VRAM row
|
||||||
|
|
||||||
|
; Find span that intersects left logical edge
|
||||||
|
lda #0
|
||||||
|
clc
|
||||||
|
|
||||||
|
renderTerrainRowSpansFindLeftLoop:
|
||||||
|
adc terrainSpanData+2,y
|
||||||
|
cmp leftScreenEdge
|
||||||
|
bpl renderTerrainRowSpansFoundLeft
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
pha
|
||||||
|
lda SCRATCHL
|
||||||
|
eor #%110000 ; Toggle span color cache
|
||||||
|
sta SCRATCHL
|
||||||
|
pla
|
||||||
|
bra renderTerrainRowSpansFindLeftLoop
|
||||||
|
|
||||||
|
renderTerrainRowSpansFoundLeft:
|
||||||
|
sec
|
||||||
|
sbc leftScreenEdge ; A now holds remainder of leftmost span
|
||||||
|
; and Y points to leftmost span
|
||||||
|
|
||||||
|
renderTerrainRowSpansLoop:
|
||||||
|
sta SCRATCHL2
|
||||||
|
|
||||||
|
; Set fill mode byte for this span
|
||||||
|
lda SCRATCHL
|
||||||
|
sta VRAMBANK,x
|
||||||
|
|
||||||
|
; Advance to end of span
|
||||||
|
clc
|
||||||
|
txa
|
||||||
|
adc SCRATCHL2
|
||||||
|
cmp PARAML0
|
||||||
|
bpl renderTerrainRowSpansDone
|
||||||
|
tax
|
||||||
|
|
||||||
|
; Prepare for next span
|
||||||
|
iny
|
||||||
|
iny
|
||||||
|
lda SCRATCHL
|
||||||
|
eor #%110000 ; Toggle span color cache
|
||||||
|
sta SCRATCHL
|
||||||
|
|
||||||
|
lda terrainSpanData+2,y
|
||||||
|
bra renderTerrainRowSpansLoop
|
||||||
|
|
||||||
|
renderTerrainRowSpansDone:
|
||||||
|
RESTORE_AXY
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; renderTerrainFillMode:
|
||||||
|
;
|
||||||
|
; Trashes all registers
|
||||||
|
;
|
||||||
|
renderTerrainFillMode:
|
||||||
|
jsr renderTerrainSpans
|
||||||
|
brk
|
||||||
|
|
||||||
|
SAVE_AXY
|
||||||
|
ldy #0
|
||||||
|
ldx #200-MAXTERRAINHEIGHT
|
||||||
|
|
||||||
|
renderTerrainFillModeLoop:
|
||||||
|
jsr enableFillMode
|
||||||
|
sty PARAML1
|
||||||
|
jsr renderTerrainRowFillMode
|
||||||
|
inx
|
||||||
|
iny
|
||||||
|
cpy #MAXTERRAINHEIGHT
|
||||||
|
bmi renderTerrainFillModeLoop
|
||||||
|
renderTerrainFillModeDone:
|
||||||
|
brk
|
||||||
|
RESTORE_AXY
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; renderTerrainRowFillMode:
|
||||||
|
;
|
||||||
|
; PARAML1 = Row index (top relative)
|
||||||
|
;
|
||||||
|
; Trashes PARAML1
|
||||||
|
;
|
||||||
|
renderTerrainRowFillMode:
|
||||||
|
SAVE_AXY
|
||||||
|
lda PARAML1
|
||||||
|
asl
|
||||||
|
tay
|
||||||
|
ldx vramYOffset,y
|
||||||
|
|
||||||
|
stz renderTerrainRowFillCurrent
|
||||||
|
|
||||||
|
sec
|
||||||
|
lda #MAXTERRAINHEIGHT
|
||||||
|
sbc PARAML1
|
||||||
|
sta PARAML1
|
||||||
|
|
||||||
|
ldy leftScreenEdge
|
||||||
|
sty renderTerrainRowFillColumn
|
||||||
|
|
||||||
|
renderTerrainRowFillModeColumnLoop:
|
||||||
|
tya
|
||||||
|
asl
|
||||||
|
tay
|
||||||
|
|
||||||
|
lda terrainData,y
|
||||||
|
cmp PARAML1
|
||||||
|
bmi renderTerrainRowFillModeBlack
|
||||||
|
|
||||||
|
lda renderTerrainRowFillCurrent
|
||||||
|
cmp #$10
|
||||||
|
beq renderTerrainRowFillModeColumnLoopNext
|
||||||
|
|
||||||
|
lda #$10
|
||||||
|
sta renderTerrainRowFillCurrent
|
||||||
|
sta VRAM+(200-MAXTERRAINHEIGHT)*160,x
|
||||||
|
|
||||||
|
renderTerrainRowFillModeColumnLoopNext:
|
||||||
|
inx
|
||||||
|
inc renderTerrainRowFillColumn
|
||||||
|
ldy renderTerrainRowFillColumn
|
||||||
|
cpy rightScreenEdge
|
||||||
|
bne renderTerrainRowFillModeColumnLoop
|
||||||
|
|
||||||
|
renderTerrainRowFillModeDone:
|
||||||
|
RESTORE_AXY
|
||||||
|
rts
|
||||||
|
|
||||||
|
renderTerrainRowFillModeBlack:
|
||||||
|
lda renderTerrainRowFillCurrent
|
||||||
|
cmp #$70
|
||||||
|
beq renderTerrainRowFillModeColumnLoopNext
|
||||||
|
|
||||||
|
lda #$70
|
||||||
|
sta renderTerrainRowFillCurrent
|
||||||
|
sta VRAM+(200-MAXTERRAINHEIGHT)*160,x
|
||||||
|
bra renderTerrainRowFillModeColumnLoopNext
|
||||||
|
|
||||||
|
renderTerrainRowFillCurrent:
|
||||||
|
.word 0
|
||||||
|
renderTerrainRowFillColumn:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; craterTerrain
|
; craterTerrain
|
||||||
;
|
;
|
||||||
@ -246,6 +448,7 @@ compileTerrainLoop:
|
|||||||
bra compileTerrainLoop
|
bra compileTerrainLoop
|
||||||
|
|
||||||
compileTerrainDone:
|
compileTerrainDone:
|
||||||
|
jsr compileTerrainSpans
|
||||||
RESTORE_AY
|
RESTORE_AY
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -381,6 +584,129 @@ compileTerrainOpcode:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; compileTerrainSpans:
|
||||||
|
;
|
||||||
|
;
|
||||||
|
compileTerrainSpans:
|
||||||
|
pha
|
||||||
|
lda #0; MAXTERRAINHEIGHT-7; 0
|
||||||
|
|
||||||
|
compileTerrainSpansLoop:
|
||||||
|
sta PARAML1
|
||||||
|
jsr compileTerrainSpansRow
|
||||||
|
lda PARAML1
|
||||||
|
inc
|
||||||
|
cmp #MAXTERRAINHEIGHT
|
||||||
|
bne compileTerrainSpansLoop
|
||||||
|
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; compileTerrainSpansRow:
|
||||||
|
;
|
||||||
|
; PARAML1 = Row index (bottom relative)
|
||||||
|
;
|
||||||
|
; Trashes SCRATCHL
|
||||||
|
;
|
||||||
|
compileTerrainSpansRow:
|
||||||
|
SAVE_AXY
|
||||||
|
|
||||||
|
lda PARAML1
|
||||||
|
asl ; Shifts must match MAXSPANSPERROW*2 + 2
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
clc
|
||||||
|
adc #terrainSpanData
|
||||||
|
sta SCRATCHL
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
ldx #TERRAINWIDTH-2
|
||||||
|
|
||||||
|
lda terrainData,x ; Figure out start value for row
|
||||||
|
cmp PARAML1
|
||||||
|
bcs compileTerrainSpansRowInitGreen
|
||||||
|
|
||||||
|
compileTerrainSpansRowInitBlack:
|
||||||
|
lda #$0020 ; First span is black
|
||||||
|
sta (SCRATCHL) ; Initialize the row
|
||||||
|
inc SCRATCHL
|
||||||
|
inc SCRATCHL
|
||||||
|
ldy #-1
|
||||||
|
|
||||||
|
compileTerrainSpansRowBlackStart:
|
||||||
|
iny
|
||||||
|
|
||||||
|
compileTerrainSpansRowBlackLoop:
|
||||||
|
lda terrainData,x
|
||||||
|
cmp PARAML1
|
||||||
|
bcs compileTerrainSpansBlackEnd
|
||||||
|
dex
|
||||||
|
dex
|
||||||
|
iny
|
||||||
|
cpx #-2
|
||||||
|
bne compileTerrainSpansRowBlackLoop
|
||||||
|
|
||||||
|
compileTerrainSpansBlackEnd:
|
||||||
|
BREAK
|
||||||
|
tya ; Store this span's length
|
||||||
|
sta (SCRATCHL)
|
||||||
|
inc SCRATCHL
|
||||||
|
inc SCRATCHL
|
||||||
|
|
||||||
|
dex ; Begin searching for next span
|
||||||
|
dex
|
||||||
|
cpx #0
|
||||||
|
bmi compileTerrainSpansRowDone
|
||||||
|
ldy #0
|
||||||
|
bra compileTerrainSpansRowGreenStart
|
||||||
|
|
||||||
|
compileTerrainSpansRowDone:
|
||||||
|
RESTORE_AXY
|
||||||
|
rts
|
||||||
|
|
||||||
|
compileTerrainSpansRowInitGreen:
|
||||||
|
lda #$0010 ; First span is green
|
||||||
|
sta (SCRATCHL) ; Initialize the row
|
||||||
|
inc SCRATCHL
|
||||||
|
inc SCRATCHL
|
||||||
|
ldy #-1
|
||||||
|
|
||||||
|
compileTerrainSpansRowGreenStart:
|
||||||
|
iny
|
||||||
|
|
||||||
|
compileTerrainSpansRowGreenLoop:
|
||||||
|
lda terrainData,x
|
||||||
|
cmp PARAML1
|
||||||
|
bcc compileTerrainSpansGreenEnd
|
||||||
|
dex
|
||||||
|
dex
|
||||||
|
iny
|
||||||
|
cpx #-2
|
||||||
|
bne compileTerrainSpansRowGreenLoop
|
||||||
|
|
||||||
|
compileTerrainSpansGreenEnd:
|
||||||
|
; iny
|
||||||
|
|
||||||
|
; lda #1 ;
|
||||||
|
; sta breakpoint ;
|
||||||
|
|
||||||
|
tya ; Store this span's length
|
||||||
|
sta (SCRATCHL)
|
||||||
|
inc SCRATCHL
|
||||||
|
inc SCRATCHL
|
||||||
|
|
||||||
|
dex ; Begin searching for next span
|
||||||
|
dex
|
||||||
|
cpx #0
|
||||||
|
bmi compileTerrainSpansRowDone
|
||||||
|
ldy #0
|
||||||
|
bra compileTerrainSpansRowBlackStart
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; generateTerrain
|
; generateTerrain
|
||||||
;
|
;
|
||||||
@ -446,3 +772,11 @@ clippedTerrainData:
|
|||||||
.byte 0,0,0,0 ; xx,jmp,addr
|
.byte 0,0,0,0 ; xx,jmp,addr
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
|
terrainSpanData:
|
||||||
|
.repeat MAXTERRAINHEIGHT
|
||||||
|
.word 0 ; Start value (0=BG)
|
||||||
|
.repeat MAXSPANSPERROW
|
||||||
|
.word 0 ; Length (in bytes)
|
||||||
|
.endrepeat
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user