mirror of
https://github.com/blondie7575/GSCats.git
synced 2024-06-15 11:29:36 +00:00
parent
af525a26fe
commit
2ce5b45a91
BIN
gscats.2mg
BIN
gscats.2mg
Binary file not shown.
3
gscats.s
3
gscats.s
|
@ -30,7 +30,6 @@ mainBank2:
|
||||||
jsr colorFill
|
jsr colorFill
|
||||||
|
|
||||||
jsr generateTerrain
|
jsr generateTerrain
|
||||||
jsr computeScrollClipBoundaries
|
|
||||||
|
|
||||||
mainGameLoop:
|
mainGameLoop:
|
||||||
ldy mapScrollPos
|
ldy mapScrollPos
|
||||||
|
@ -108,7 +107,7 @@ kbdScanSpace:
|
||||||
basePalette:
|
basePalette:
|
||||||
.word $0800,$0080,$0000,$000F,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
|
.word $0800,$0080,$0000,$000F,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
|
||||||
mapScrollPos: ; 4-pixel columns distance from right terrain edge
|
mapScrollPos: ; 4-pixel columns distance from right terrain edge
|
||||||
.word 0
|
.word 80
|
||||||
quitRequested:
|
quitRequested:
|
||||||
.word $0000
|
.word $0000
|
||||||
|
|
||||||
|
|
105
terrain.s
105
terrain.s
|
@ -13,9 +13,6 @@ MAXTERRAINHEIGHT = 100 ; In pixels
|
||||||
;
|
;
|
||||||
; No stack operations permitted here!
|
; No stack operations permitted here!
|
||||||
;
|
;
|
||||||
; Initial implementation: 535 cycles per row
|
|
||||||
; Current implementation: 443 cycles per row
|
|
||||||
;
|
|
||||||
renderTerrain:
|
renderTerrain:
|
||||||
lda #199*2
|
lda #199*2
|
||||||
sta <ROWINDEX
|
sta <ROWINDEX
|
||||||
|
@ -65,14 +62,15 @@ renderClippedSpanChain:
|
||||||
lda #renderClippedSpanChainRenderNext ; 2
|
lda #renderClippedSpanChainRenderNext ; 2
|
||||||
sta renderSpanComplete+1 ; 4
|
sta renderSpanComplete+1 ; 4
|
||||||
|
|
||||||
; Look up right edge clipping data from precalculated table
|
; Find right edge of screen within span chains
|
||||||
; = 15 cycles per row
|
; = 27 cycles per skipped span
|
||||||
renderClippedSpanChainLoop:
|
renderClippedSpanChainLoop:
|
||||||
lda <MAPSCROLLPOS ; 3
|
|
||||||
asl ; 2
|
lda spanChain,y ; 4
|
||||||
tax ; 2
|
sec ; 2
|
||||||
ldy scrollClipIndices,x ; 4
|
sbc <RIGHTEDGE ; 3
|
||||||
lda scrollClipIndices+2,x ; 4
|
bmi renderClippedSpanChainNextSpan ; 2/3
|
||||||
|
beq renderClippedSpanChainNextSpan ; 2/3
|
||||||
|
|
||||||
renderClippedSpanChainLoop2:
|
renderClippedSpanChainLoop2:
|
||||||
; Now render spans until left edge of screen
|
; Now render spans until left edge of screen
|
||||||
|
@ -93,6 +91,7 @@ renderSpanComplete:
|
||||||
; unrolled span rendering blocks
|
; unrolled span rendering blocks
|
||||||
jmp renderClippedSpanChainRenderNext ; 3
|
jmp renderClippedSpanChainRenderNext ; 3
|
||||||
|
|
||||||
|
|
||||||
renderClippedSpanChainRenderNext:
|
renderClippedSpanChainRenderNext:
|
||||||
; Track remaining words until left edge
|
; Track remaining words until left edge
|
||||||
; = 26 cycles per span rendered
|
; = 26 cycles per span rendered
|
||||||
|
@ -109,6 +108,16 @@ renderClippedSpanChainRenderNext:
|
||||||
lda spanChain,y ; 5
|
lda spanChain,y ; 5
|
||||||
bra renderClippedSpanChainLoop2 ; 3
|
bra renderClippedSpanChainLoop2 ; 3
|
||||||
|
|
||||||
|
renderClippedSpanChainNextSpan:
|
||||||
|
; Track remaining distance from right edge and
|
||||||
|
; continue searching for visible right edge
|
||||||
|
eor #$ffff ; 2
|
||||||
|
inc ; 2
|
||||||
|
sta <RIGHTEDGE ; 3
|
||||||
|
dey ; 2
|
||||||
|
dey ; 2
|
||||||
|
bra renderClippedSpanChainLoop ; 3
|
||||||
|
|
||||||
renderClippedSpanChainLastSpan:
|
renderClippedSpanChainLastSpan:
|
||||||
; Render visible portion of last visible span
|
; Render visible portion of last visible span
|
||||||
; = 26 cycles per row
|
; = 26 cycles per row
|
||||||
|
@ -142,75 +151,6 @@ spanColors:
|
||||||
spanChainIndex:
|
spanChainIndex:
|
||||||
.word 0
|
.word 0
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
; computeScrollClipBoundaries
|
|
||||||
;
|
|
||||||
; Generates a table of the clipped span indices for the right edge
|
|
||||||
; at every possible scroll position
|
|
||||||
;
|
|
||||||
computeScrollClipBoundaries:
|
|
||||||
SAVE_AXY
|
|
||||||
|
|
||||||
lda #0
|
|
||||||
sta <MAPSCROLLPOS
|
|
||||||
|
|
||||||
computeScrollClipBoundariesOuterLoop:
|
|
||||||
; Prepare our state
|
|
||||||
lda #80 ; 2
|
|
||||||
sta <XLEFT ; 3
|
|
||||||
ldy #spanChainEnd-spanChain-2 ; 2
|
|
||||||
lda <MAPSCROLLPOS ; 3
|
|
||||||
sta <RIGHTEDGE ; 3
|
|
||||||
|
|
||||||
; Find right edge of screen within span chains
|
|
||||||
computeScrollClipBoundariesInnerLoop:
|
|
||||||
|
|
||||||
lda spanChain,y ; 4
|
|
||||||
sec ; 2
|
|
||||||
sbc <RIGHTEDGE ; 3
|
|
||||||
bmi computeScrollClipBoundariesNextSpan ; 2/3
|
|
||||||
beq computeScrollClipBoundariesNextSpan ; 2/3
|
|
||||||
|
|
||||||
; Y now contains the pointer to span that will be clipped at this scroll position
|
|
||||||
; A now contains remaining words of clipped span to render
|
|
||||||
; Write these values into our tuple data structure
|
|
||||||
pha
|
|
||||||
ldx <MAPSCROLLPOS
|
|
||||||
txa
|
|
||||||
asl
|
|
||||||
tax
|
|
||||||
tya
|
|
||||||
sta scrollClipIndices,x
|
|
||||||
inx
|
|
||||||
inx
|
|
||||||
pla
|
|
||||||
sta scrollClipIndices,x
|
|
||||||
|
|
||||||
; On to the next scroll position
|
|
||||||
lda <MAPSCROLLPOS
|
|
||||||
inc
|
|
||||||
inc
|
|
||||||
cmp #(TERRAINWIDTH-320)/4+2
|
|
||||||
beq computeScrollClipBoundariesDone
|
|
||||||
sta <MAPSCROLLPOS
|
|
||||||
bra computeScrollClipBoundariesOuterLoop
|
|
||||||
|
|
||||||
computeScrollClipBoundariesNextSpan:
|
|
||||||
; Track remaining distance from right edge and
|
|
||||||
; continue searching for visible right edge
|
|
||||||
eor #$ffff ; 2
|
|
||||||
inc ; 2
|
|
||||||
sta <RIGHTEDGE ; 3
|
|
||||||
dey ; 2
|
|
||||||
dey ; 2
|
|
||||||
bra computeScrollClipBoundariesInnerLoop ; 3
|
|
||||||
|
|
||||||
computeScrollClipBoundariesDone:
|
|
||||||
RESTORE_AXY
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; generateTerrain
|
; generateTerrain
|
||||||
;
|
;
|
||||||
|
@ -246,14 +186,9 @@ generateTerrainLoop:
|
||||||
|
|
||||||
terrainData:
|
terrainData:
|
||||||
.repeat TERRAINWIDTH/2
|
.repeat TERRAINWIDTH/2
|
||||||
.word 0
|
.byte 0
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
scrollClipIndices:
|
|
||||||
; Tuples: (Clipped span, Words to Render)
|
|
||||||
.repeat (TERRAINWIDTH-320)/4+2 ; Always scroll by two words
|
|
||||||
.word 0
|
|
||||||
.endrepeat
|
|
||||||
|
|
||||||
.if 0
|
.if 0
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user