Start working to bring sprites rendering back into the pipeline

This commit is contained in:
Lucas Scharenbroich 2022-05-22 23:54:47 -05:00
parent d27b10b6fd
commit 9da3616c1d
10 changed files with 112 additions and 26 deletions

View File

@ -4,38 +4,53 @@
GTEToolNum equ $A0 GTEToolNum equ $A0
_GTEBootInit MAC _GTEBootInit MAC
UserTool $100+GTEToolNum UserTool $0100+GTEToolNum
<<< <<<
_GTEStartUp MAC _GTEStartUp MAC
UserTool $200+GTEToolNum UserTool $0200+GTEToolNum
<<< <<<
_GTEShutDown MAC _GTEShutDown MAC
UserTool $300+GTEToolNum UserTool $0300+GTEToolNum
<<< <<<
_GTEVersion MAC _GTEVersion MAC
UserTool $400+GTEToolNum UserTool $0400+GTEToolNum
<<< <<<
_GTEReset MAC _GTEReset MAC
UserTool $500+GTEToolNum UserTool $0500+GTEToolNum
<<< <<<
_GTEStatus MAC _GTEStatus MAC
UserTool $600+GTEToolNum UserTool $0600+GTEToolNum
<<< <<<
_GTEReadControl MAC _GTEReadControl MAC
UserTool $900+GTEToolNum UserTool $0900+GTEToolNum
<<< <<<
_GTESetScreenMode MAC _GTESetScreenMode MAC
UserTool $A00+GTEToolNum UserTool $0A00+GTEToolNum
<<< <<<
_GTESetTile MAC _GTESetTile MAC
UserTool $B00+GTEToolNum UserTool $0B00+GTEToolNum
<<< <<<
_GTESetBG0Origin MAC _GTESetBG0Origin MAC
UserTool $C00+GTEToolNum UserTool $0C00+GTEToolNum
<<< <<<
_GTERender MAC _GTERender MAC
UserTool $D00+GTEToolNum UserTool $0D00+GTEToolNum
<<< <<<
_GTELoadTileSet MAC _GTELoadTileSet MAC
UserTool $E00+GTEToolNum UserTool $0E00+GTEToolNum
<<< <<<
_GTECreateSpriteStamp MAC
UserTool $0F00+GTEToolNum
<<<
_GTEAddSprite MAC
UserTool $1000+GTEToolNum
<<<
_GTEMoveSprite MAC
UserTool $1100+GTEToolNum
<<<
_GTEUpdateSprite MAC
UserTool $1200+GTEToolNum
<<<
_GTERemoveSprite MAC
UserTool $1300+GTEToolNum
<<<

View File

@ -238,3 +238,5 @@ Timers EXT
DefaultPalette EXT DefaultPalette EXT
ScreenModeWidth EXT ScreenModeWidth EXT
ScreenModeHeight EXT ScreenModeHeight EXT
_SpriteBits EXT
_SpriteBitsNot EXT

View File

@ -97,6 +97,7 @@ InitMemory lda EngineMode
sta BTableHigh+]step+{208*2},x ; 16 lines per bank sta BTableHigh+]step+{208*2},x ; 16 lines per bank
]step equ ]step+2 ]step equ ]step+2
--^ --^
lda BlitBuff,y lda BlitBuff,y
sta BTableLow,x sta BTableLow,x
sta BTableLow+{208*2},x sta BTableLow+{208*2},x
@ -110,10 +111,12 @@ InitMemory lda EngineMode
--^ --^
txa txa
clc
adc #16*2 ; move to the next chunk of BTableHigh and BTableLow adc #16*2 ; move to the next chunk of BTableHigh and BTableLow
tax tax
tya tya
clc
adc #4 ; move to the next bank address adc #4 ; move to the next bank address
tay tay
cmp #4*13 cmp #4*13
@ -153,9 +156,6 @@ InitMemory lda EngineMode
:exit :exit
rts rts
;Buff00 ds 4
;Buff01 ds 4
; Bank allocator (for one full, fixed bank of memory. Can be immediately deferenced) ; Bank allocator (for one full, fixed bank of memory. Can be immediately deferenced)
AllocOneBank PushLong #0 AllocOneBank PushLong #0

View File

@ -74,7 +74,7 @@ _Render
; ldy ScreenHeight ; ldy ScreenHeight
; jsr _BltSCB ; jsr _BltSCB
lda StartY ; Restore the fields back to their original state lda StartYMod208 ; Restore the fields back to their original state
ldx ScreenHeight ldx ScreenHeight
jsr _RestoreBG0Opcodes jsr _RestoreBG0Opcodes

View File

@ -117,7 +117,6 @@ _AddSprite
sta _Sprites+SPRITE_X,x ; X coordinate sta _Sprites+SPRITE_X,x ; X coordinate
jsr _PrecalcAllSpriteInfo ; Cache sprite property values (simple stuff) jsr _PrecalcAllSpriteInfo ; Cache sprite property values (simple stuff)
; jsr _DrawSpriteSheet ; Render the sprite into internal space
; Mark the dirty bit to indicate that the active sprite list needs to be rebuilt in the next ; Mark the dirty bit to indicate that the active sprite list needs to be rebuilt in the next
; render call ; render call
@ -535,7 +534,7 @@ _DoPhase2
; can be drawn to the screen. This routine is also responsible for setting the specific ; can be drawn to the screen. This routine is also responsible for setting the specific
; VBUFF address for each sprite's tile sheet position ; VBUFF address for each sprite's tile sheet position
jmp _MarkDirtySprite ; jmp _MarkDirtySprite
:out :out
rts rts
@ -867,7 +866,7 @@ _RemoveSprite
; Update the sprite's flags. We do not allow the size of a sprite to be changed. That requires ; Update the sprite's flags. We do not allow the size of a sprite to be changed. That requires
; the sprite to be removed and re-added. ; the sprite to be removed and re-added.
; ;
; A = Sprite ID ; A = Sprite slot
; X = New Sprite Flags ; X = New Sprite Flags
; Y = New Sprite Stamp Address ; Y = New Sprite Stamp Address
_UpdateSprite _UpdateSprite

View File

@ -51,6 +51,7 @@ _CallTable
adrl _TSSetBG0Origin-1 adrl _TSSetBG0Origin-1
adrl _TSRender-1 adrl _TSRender-1
adrl _TSLoadTileSet-1 adrl _TSLoadTileSet-1
adrl _TSCreateSpriteStamp-1
_CTEnd _CTEnd
; Helper function to set the data back to the toolset default ; Helper function to set the data back to the toolset default
@ -222,6 +223,8 @@ xPos equ FirstParam+2
lda xPos,s lda xPos,s
jsr _SetBG0XPos jsr _SetBG0XPos
lda yPos,s lda yPos,s
bpl *+5
lda #0
jsr _SetBG0YPos jsr _SetBG0YPos
_TSExit #0;#4 _TSExit #0;#4
@ -245,6 +248,60 @@ TSPtr equ FirstParam
_TSExit #0;#4 _TSExit #0;#4
; CreateSpriteStamp(spriteId: Word, vbuffAddr: Word)
_TSCreateSpriteStamp
:vbuff equ FirstParam
:spriteId equ FirstParam+2
_TSEntry
lda :vbuff,s
tay
lda :spriteId,s
jsr _CreateSpriteStamp
_TSExit #0;#4
_TSAddSprite
:spriteSlot equ FirstParam+0
:spriteY equ FirstParam+2
:spriteX equ FirstParam+4
:spriteId equ FirstParam+6
_TSEntry
lda :spriteY,s
and #$00FF
xba
sta :spriteY,s
lda :spriteX,s
and #$00FF
ora :spriteY,s
tay
lda :spriteSlot,s
tax
lda :spriteId,s
jsr _AddSprite
_TSExit #0;#8
_TSUpdateSprite
:vbuff equ FirstParam+0
:spriteFlags equ FirstParam+2
:spriteSlot equ FirstParam+4
_TSEntry
lda :spriteFlags,s
tax
lda :vbuff,s
tay
lda :spriteSlot,s
jsr _UpdateSprite
_TSExit #0;#6
; Insert the GTE code ; Insert the GTE code
put Math.s put Math.s
@ -253,6 +310,8 @@ TSPtr equ FirstParam
put Timer.s put Timer.s
put Graphics.s put Graphics.s
put Tiles.s put Tiles.s
put Sprite.s
put SpriteRender.s
put Render.s put Render.s
put tiles/DirtyTileQueue.s put tiles/DirtyTileQueue.s
put tiles/FastRenderer.s put tiles/FastRenderer.s

View File

@ -51,6 +51,11 @@ _BltRange
lda #FULL_RETURN ; this is the offset of the return code lda #FULL_RETURN ; this is the offset of the return code
sta [:exit_ptr],y ; patch out the low byte of the JMP/JML sta [:exit_ptr],y ; patch out the low byte of the JMP/JML
; lda StartYMod208
; cmp #63
; bne *+4
; brk $40
; Now we need to set up the Bank, Stack Pointer and Direct Page registers for calling into ; Now we need to set up the Bank, Stack Pointer and Direct Page registers for calling into
; the code field ; the code field

View File

@ -28,10 +28,10 @@ _BltSCB
lda SCBArrayPtr+2 lda SCBArrayPtr+2
bpl :bind_to_bg0 bpl :bind_to_bg0
lda BG1StartY lda BG1StartYMod208
bra :bind_to_bg1 bra :bind_to_bg1
:bind_to_bg0 :bind_to_bg0
lda StartY lda StartYMod208
:bind_to_bg1 :bind_to_bg1
clc clc
adc SCBArrayPtr adc SCBArrayPtr

View File

@ -91,8 +91,9 @@ _ApplyBG0YPos
sta :lines_left sta :lines_left
jne :loop jne :loop
plb plb
:out
rts rts
; Unrolled copy routine to move RTable intries into STK_ADDR position. ; Unrolled copy routine to move RTable intries into STK_ADDR position.
@ -145,7 +146,7 @@ CopyRTableToStkAddr
:x14 ldal RTable+26,x :x14 ldal RTable+26,x
sta STK_ADDR+$D000,y sta STK_ADDR+$D000,y
:x13 ldal RTable+24,x :x13 ldal RTable+24,x
sta: STK_ADDR+$C000,y sta STK_ADDR+$C000,y
:x12 ldal RTable+22,x :x12 ldal RTable+22,x
sta STK_ADDR+$B000,y sta STK_ADDR+$B000,y
:x11 ldal RTable+20,x :x11 ldal RTable+20,x
@ -153,7 +154,7 @@ CopyRTableToStkAddr
:x10 ldal RTable+18,x :x10 ldal RTable+18,x
sta STK_ADDR+$9000,y sta STK_ADDR+$9000,y
:x09 ldal RTable+16,x :x09 ldal RTable+16,x
sta: STK_ADDR+$8000,y sta STK_ADDR+$8000,y
:x08 ldal RTable+14,x :x08 ldal RTable+14,x
sta STK_ADDR+$7000,y sta STK_ADDR+$7000,y
:x07 ldal RTable+12,x :x07 ldal RTable+12,x
@ -161,7 +162,7 @@ CopyRTableToStkAddr
:x06 ldal RTable+10,x :x06 ldal RTable+10,x
sta STK_ADDR+$5000,y sta STK_ADDR+$5000,y
:x05 ldal RTable+08,x :x05 ldal RTable+08,x
sta: STK_ADDR+$4000,y sta STK_ADDR+$4000,y
:x04 ldal RTable+06,x :x04 ldal RTable+06,x
sta STK_ADDR+$3000,y sta STK_ADDR+$3000,y
:x03 ldal RTable+04,x :x03 ldal RTable+04,x

View File

@ -308,7 +308,6 @@ RTable ENT
; Array of addresses for the banks that hold the blitter. ; Array of addresses for the banks that hold the blitter.
BlitBuff ENT BlitBuff ENT
dw $5a5a
ds 4*13 ds 4*13
; The blitter table (BTable) is a double-length table that holds the full 4-byte address of each ; The blitter table (BTable) is a double-length table that holds the full 4-byte address of each
@ -374,5 +373,11 @@ ScreenModeWidth ENT
ScreenModeHeight ENT ScreenModeHeight ENT
dw 200,192,200,176,160,160,160,128,144,192,102,1 dw 200,192,200,176,160,160,160,128,144,192,102,1
; Convert sprite index to a bit position
_SpriteBits ENT
dw $0001,$0002,$0004,$0008,$0010,$0020,$0040,$0080,$0100,$0200,$0400,$0800,$1000,$2000,$4000,$8000
_SpriteBitsNot ENT
dw $FFFE,$FFFD,$FFFB,$FFF7,$FFEF,$FFDF,$FFBF,$FF7F,$FEFF,$FDFF,$FBFF,$F7FF,$EFFF,$DFFF,$BFFF,$7FFF
blt_return blt_return
stk_save stk_save