Checkpoint; blitter failing

This commit is contained in:
Lucas Scharenbroich 2022-08-14 07:45:58 -05:00
parent e378dc6e26
commit 3fce46872d
13 changed files with 170 additions and 74 deletions

View File

@ -58,6 +58,8 @@ appTmp0 equ 28
; Load a tileset ; Load a tileset
pea 0
pea 256
pea #^tiledata pea #^tiledata
pea #tiledata pea #tiledata
_GTELoadTileSet _GTELoadTileSet

View File

@ -37,6 +37,8 @@ MaxBG0X equ 20
MaxBG0Y equ 22 MaxBG0Y equ 22
OldOneSecondCounter equ 26 OldOneSecondCounter equ 26
appTmp0 equ 28 appTmp0 equ 28
appTmp1 equ 30
appTmp2 equ 32
phk phk
plb plb
@ -50,15 +52,39 @@ appTmp0 equ 28
lda #ENGINE_MODE_USER_TOOL+ENGINE_MODE_TWO_LAYER lda #ENGINE_MODE_USER_TOOL+ENGINE_MODE_TWO_LAYER
jsr GTEStartUp ; Load and install the GTE User Tool jsr GTEStartUp ; Load and install the GTE User Tool
; Initialize local variables pea $0000 ; Set the first two tiles
pea $0002
pea #^TileData
pea #TileData
_GTELoadTileSet
; pea $0000 pea $0000
; pea #^TileSetPalette pea #^TileSetPalette
; pea #TileSetPalette pea #TileSetPalette
; _GTESetPalette _GTESetPalette
; Set up our level data ; Fill in the field with a checkboard pattern
stz appTmp1
:tloop0 stz appTmp0
:tloop1 lda appTmp0 ; X
pha
pei appTmp1 ; Y
eor appTmp1
and #$0001
pha ; tile ID
_GTESetTile
inc appTmp0
lda #40
cmp appTmp0
bcs :tloop1
inc appTmp1
lda #25
cmp appTmp1
bcs :tloop0
; Set up a very specific test. First, we draw a sprite into the sprite plane, and then ; Set up a very specific test. First, we draw a sprite into the sprite plane, and then
; leave it alone. We are just testing the ability to merge sprite plane data into ; leave it alone. We are just testing the ability to merge sprite plane data into
@ -70,7 +96,8 @@ EvtLoop
jsr HandleKeys ; Do the generic key handlers jsr HandleKeys ; Do the generic key handlers
pea RENDER_PER_SCANLINE ; Scanline rendering pea #RENDER_PER_SCANLINE ; Scanline rendering
; pea $0000
_GTERender _GTERender
brl EvtLoop brl EvtLoop
@ -88,9 +115,12 @@ qtRec adrl $0000
da $00 da $00
; Color palette ; Color palette
TileSetPalette dw $0000,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF,$0FFF
MyDirectPage ds 2 MyDirectPage ds 2
; Stub ; Stub
SetLimits rts SetLimits rts
PUT ../kfest-2022/StartUp.s PUT ../kfest-2022/StartUp.s
PUT Tiles.s

View File

@ -5,7 +5,7 @@ REM
REM Pass the path of the Cadius tool as the first argument (%1) REM Pass the path of the Cadius tool as the first argument (%1)
set CADIUS="%1" set CADIUS="%1"
set IMAGE="..\\..\\..\\emu\\Target.2mg" set IMAGE="..\\..\\emu\\Target.2mg"
set FOLDER="/GTEDEV/TF4" set FOLDER="/GTEDEV/TF4"
REM Cadius does not overwrite files, so clear the root folder first REM Cadius does not overwrite files, so clear the root folder first
@ -14,4 +14,4 @@ REM Cadius does not overwrite files, so clear the root folder first
REM Now copy files and folders as needed REM Now copy files and folders as needed
%CADIUS% ADDFILE %IMAGE% %FOLDER% .\GTETF4 %CADIUS% ADDFILE %IMAGE% %FOLDER% .\GTETF4
%CADIUS% ADDFILE %IMAGE% %FOLDER% ..\src\Tool160 %CADIUS% ADDFILE %IMAGE% %FOLDER% ..\..\src\Tool160

View File

@ -126,6 +126,9 @@ _GTEClearBG1Buffer MAC
_GTESetBG1Scale MAC _GTESetBG1Scale MAC
UserTool $2B00+GTEToolNum UserTool $2B00+GTEToolNum
<<< <<<
_GTEGetAddress MAC
UserTool $2C00+GTEToolNum
<<<
; EngineMode definitions ; EngineMode definitions
; Script definition ; Script definition
@ -155,6 +158,8 @@ RENDER_BG1_VERT_OFFSET equ $0004
RENDER_BG1_ROTATION equ $0008 RENDER_BG1_ROTATION equ $0008
RENDER_PER_SCANLINE equ $0010 RENDER_PER_SCANLINE equ $0010
; GetAddress table IDs
scanlineHorzOffset equ $0001
; Tile constants ; Tile constants
; TILE_RESERVED_BIT equ $8000 ; TILE_RESERVED_BIT equ $8000

View File

@ -233,6 +233,7 @@ EngineReset
sta tmp15 sta tmp15
stz tmp14 stz tmp14
; Rebuild all of the bank blitters
:loop :loop
ldx #BlitBuff ldx #BlitBuff
lda #^BlitBuff lda #^BlitBuff
@ -247,6 +248,15 @@ EngineReset
dec tmp15 dec tmp15
bne :loop bne :loop
; Set the scanline tables to reasonable default values
ldx #{416*2}-2
lda #0
:sxm_loop
sta StartXMod164Arr,x
dex
dex
bpl :sxm_loop
rts rts

View File

@ -184,6 +184,9 @@ DIRTY_BIT_BG0_REFRESH equ $0010
DIRTY_BIT_BG1_REFRESH equ $0020 DIRTY_BIT_BG1_REFRESH equ $0020
DIRTY_BIT_SPRITE_ARRAY equ $0040 DIRTY_BIT_SPRITE_ARRAY equ $0040
; GetAddress table IDs
scanlineHorzOffset equ $0001 ; table of 416 wors, a double-array of scanline offset values. Must be 0, 163
; Script definition ; Script definition
YIELD equ $8000 YIELD equ $8000
JUMP equ $4000 JUMP equ $4000

View File

@ -39,7 +39,6 @@ _Render
beq *+5 beq *+5
jmp _RenderScanlines ; Do the scanline-based renderer jmp _RenderScanlines ; Do the scanline-based renderer
jsr _ApplyBG0YPos ; Set stack addresses for the virtual lines to the physical screen jsr _ApplyBG0YPos ; Set stack addresses for the virtual lines to the physical screen
lda #RENDER_BG1_ROTATION lda #RENDER_BG1_ROTATION
@ -57,7 +56,7 @@ _Render
jsr _RenderSprites ; Once the BG0 X and Y positions are committed, update sprite data jsr _RenderSprites ; Once the BG0 X and Y positions are committed, update sprite data
jsr _UpdateBG0TileMap ; and the tile maps. These subroutines build up a list of tiles jsr _UpdateBG0TileMap ; and the tile maps. These subroutines build up a list of tiles
; jsr _UpdateBG1TileMap ; that need to be updated in the code field jsr _UpdateBG1TileMap ; that need to be updated in the code field
jsr _ApplyTiles ; This function actually draws the new tiles into the code field jsr _ApplyTiles ; This function actually draws the new tiles into the code field
@ -155,61 +154,63 @@ _DoOverlay
:disp jsl $000000 :disp jsl $000000
rts rts
; Use the per-scanline tables to set the screen. This is really meant to be used without the built-in tilemap ; Use the per-scanline tables to set the screen. This is really meant to be used without the built-in tilemap
; support and is more of a low-level way to control the background rendering ; support and is more of a low-level way to control the background rendering
_RenderScanlines _RenderScanlines
jsr _ApplyBG0YPos ; Set stack addresses for the virtual lines to the physical screen jsr _ApplyBG0YPos ; Set stack addresses for the virtual lines to the physical screen
; jsr _ApplyBG1YPos ; Set the y-register values of the blitter jsr _ApplyBG1YPos ; Set the y-register values of the blitter
; _ApplyBG0Xpos need to be split because we have to set the offsets, then draw in any updated tiles, and ; _ApplyBG0Xpos need to be split because we have to set the offsets, then draw in any updated tiles, and
; finally patch out the code field. Right now, the BRA operand is getting overwritten by tile data. ; finally patch out the code field. Right now, the BRA operand is getting overwritten by tile data.
jsr _ApplyBG0XPosPre jsr _ApplyBG0XPosPre
; jsr _ApplyBG1XPosPre jsr _ApplyBG1XPosPre
; jsr _RenderSprites ; Once the BG0 X and Y positions are committed, update sprite data ; jsr _RenderSprites ; Once the BG0 X and Y positions are committed, update sprite data
; jsr _ApplyTiles ; This function actually draws the new tiles into the code field ; jsr _ApplyTiles ; This function actually draws the new tiles into the code field
jsr _ScanlineBG0XPos ; Patch the code field instructions with exit BRA opcode jsr _ScanlineBG0XPos ; Patch the code field instructions with exit BRA opcode
; jsr _ApplyBG1XPos ; Update the direct page value based on the horizontal position ; jsr _ApplyBG1XPos ; Update the direct page value based on the horizontal position
; The code fields are locked in now and ready to be rendered. See if there is an overlay or any ; The code fields are locked in now and ready to be rendered. See if there is an overlay or any
; other reason to render with shadowing off. Otherwise, just do things quickly. ; other reason to render with shadowing off. Otherwise, just do things quickly.
lda Overlays ; lda Overlays
beq :no_ovrly ; beq :no_ovrly
jsr _ShadowOff ; jsr _ShadowOff
; Shadowing is turned off. Render all of the scan lines that need a second pass. One ; Shadowing is turned off. Render all of the scan lines that need a second pass. One
; optimization that can be done here is that the lines can be rendered in any order ; optimization that can be done here is that the lines can be rendered in any order
; since it is not shown on-screen yet. ; since it is not shown on-screen yet.
ldx Overlays+2 ; Blit the full virtual buffer to the screen ; ldx Overlays+2 ; Blit the full virtual buffer to the screen
ldy Overlays+4 ; ldy Overlays+4
jsr _BltRange ; jsr _BltRange
; Turn shadowing back on ; Turn shadowing back on
jsr _ShadowOn ; jsr _ShadowOn
; Now render all of the remaining lines in top-to-bottom (or bottom-to-top) order ; Now render all of the remaining lines in top-to-bottom (or bottom-to-top) order
ldx #0 ; ldx #0
ldy Overlays+2 ; ldy Overlays+2
beq :skip ; beq :skip
jsr _BltRange ; jsr _BltRange
:skip :skip
jsr _DoOverlay ; jsr _DoOverlay
ldx Overlays+4 ; ldx Overlays+4
cpx ScreenHeight ; cpx ScreenHeight
beq :done ; beq :done
ldy ScreenHeight ; ldy ScreenHeight
jsr _BltRange ; jsr _BltRange
bra :done ; bra :done
:no_ovrly :no_ovrly
ldx #0 ; Blit the full virtual buffer to the screen ldx #0 ; Blit the full virtual buffer to the screen
@ -217,9 +218,9 @@ _RenderScanlines
jsr _BltRange jsr _BltRange
:done :done
ldx #0 ; ldx #0
ldy ScreenHeight ; ldy ScreenHeight
jsr _BltSCB ; jsr _BltSCB
lda StartYMod208 ; Restore the fields back to their original state lda StartYMod208 ; Restore the fields back to their original state
ldx ScreenHeight ldx ScreenHeight

View File

@ -1,20 +1,29 @@
; Basic tile functions ; Basic tile functions
; Copy tileset data from a pointer in memory to the tiledata back ; Copy tileset data from a pointer in memory to the tiledata back
; X = high word ;
; A = low word ; tmp0 = Pointer to tile data
; X = first tile
; Y = last tile
;
; To copy in three tiles starting at tile 5, for example, X = 5 and Y = 9
_LoadTileSet _LoadTileSet
sta tmp0 txa
stx tmp1 _Mul128 ; Jump to the target location
tax
tya
_Mul128
sta tmp2 ; This is the terminating byte
ldy #0 ldy #0
tyx
:loop lda [tmp0],y :loop lda [tmp0],y
stal tiledata,x stal tiledata,x
dex inx
dex inx
dey iny
dey iny
bne :loop cpx tmp2
bne :loop ; Use BNE so when Y=512 => $0000, we wait for wrap-around
rts rts

View File

@ -96,6 +96,7 @@ _CallTable
adrl _TSClearBG1Buffer-1 adrl _TSClearBG1Buffer-1
adrl _TSSetBG1Scale-1 adrl _TSSetBG1Scale-1
adrl _TSGetAddress-1
_CTEnd _CTEnd
_GTEAddSprite MAC _GTEAddSprite MAC
UserTool $1000+GTEToolNum UserTool $1000+GTEToolNum
@ -183,7 +184,9 @@ _TSShutDown
jsr _CoreShutDown ; Shut down the library jsr _CoreShutDown ; Shut down the library
plb plb
pea $8000 lda EngineMode ; $0000 = system tool, $8000 = user tool set
and #$8000
pha
pei ToolNum pei ToolNum
pea $0000 ; Set WAP to null pea $0000 ; Set WAP to null
pea $0000 pea $0000
@ -303,18 +306,27 @@ _TSRenderDirty
jsr _RenderDirty jsr _RenderDirty
_TSExit #0;#2 _TSExit #0;#2
; LoadTileSet(Pointer) ; LoadTileSet(Start, Finish, Pointer)
_TSLoadTileSet _TSLoadTileSet
TSPtr equ FirstParam :TSPtr equ FirstParam
:finish equ FirstParam+4
:start equ FirstParam+6
_TSEntry _TSEntry
lda TSPtr+2,s lda :TSPtr+2,s ; stuff the pointer in the direct page
sta tmp1
lda :TSPtr,s
sta tmp0
lda :start,s ; put the range in the registers
tax tax
lda TSPtr,s lda :finish,s
tay
jsr _LoadTileSet jsr _LoadTileSet
_TSExit #0;#4 _TSExit #0;#8
; CreateSpriteStamp(spriteDescriptor: Word, vbuffAddr: Word) ; CreateSpriteStamp(spriteDescriptor: Word, vbuffAddr: Word)
_TSCreateSpriteStamp _TSCreateSpriteStamp
@ -805,6 +817,27 @@ _TSSetBG1Scale
sta BG1Scaling sta BG1Scaling
_TSExit #0;#2 _TSExit #0;#2
_TSGetAddress
:output equ FirstParam+0
:tblId equ FirstParam+4
_TSEntry
lda #0
sta :output,s
sta :output+2,s
lda :value,s
cmp #scanlineHorzOffset
bne :out
lda #StartXMod164Arr
sta :output,s
lda #^StartXMod164Arr
sta :output+2,s
:out
_TSExit #0;#2
; Insert the GTE code ; Insert the GTE code
put Math.s put Math.s

View File

@ -58,6 +58,8 @@ _BltRange
bit #ENGINE_MODE_TWO_LAYER bit #ENGINE_MODE_TWO_LAYER
beq :skip_bank beq :skip_bank
; TODO: Switch to loading the selected BG1 bank. No special "Alt" bank
lda RenderFlags lda RenderFlags
bit #RENDER_ALT_BG1 bit #RENDER_ALT_BG1
beq :primary beq :primary

View File

@ -205,9 +205,8 @@ _ApplyBG0XPos
; where the exit will be patched in ; where the exit will be patched in
dec ; (a - 1) % 164 dec ; (a - 1) % 164
bpl :hop1 bpl *+5
lda #163 lda #163
:hop1
; If the exit byte is odd, then the left edge is even-aligned and we round down and exit at at ; If the exit byte is odd, then the left edge is even-aligned and we round down and exit at at
; that word. ; that word.
@ -243,7 +242,7 @@ _ApplyBG0XPos
dec ; to get the index of the first on-screen byte dec ; to get the index of the first on-screen byte
cmp #164 ; Keep the value in range cmp #164 ; Keep the value in range
bcc :hop2 bcc *+5
sbc #164 sbc #164
:hop2 :hop2

View File

@ -20,6 +20,7 @@ _ScanlineBG0XPos
:opcode equ tmp9 :opcode equ tmp9
:odd_entry_offset equ tmp10 :odd_entry_offset equ tmp10
brk $AB
lda StartYMod208 ; This is the base line of the virtual screen lda StartYMod208 ; This is the base line of the virtual screen
asl asl
sta :virt_line_x2 ; Keep track of it sta :virt_line_x2 ; Keep track of it
@ -38,8 +39,8 @@ _ScanlineBG0XPos
:loop :loop
ldx :virt_line_x2 ldx :virt_line_x2
lda StartXMod164Arr,x ; Get the offset for this line
lda StartXMod164Arr,x ; Get the offset for this line
dec ; The exit point is one byte sooner dec ; The exit point is one byte sooner
bpl *+5 bpl *+5
lda #163 lda #163
@ -100,7 +101,7 @@ _ScanlineBG0XPos
sta :opcode sta :opcode
:prep_complete :prep_complete
; Not patch in the code field line ; Now patch in the code field line
ldy BTableLow,x ; Get the address of the first code field line ldy BTableLow,x ; Get the address of the first code field line
clc clc
@ -124,9 +125,9 @@ _ScanlineBG0XPos
sta: OPCODE_SAVE+$0000,y sta: OPCODE_SAVE+$0000,y
;SetConst ;SetConst
txy ; ldy :exit_address -- starting at this address ; txy ; ldy :exit_address -- starting at this address
ldx :exit_bra ; Copy this value into all of the lines lda :exit_bra ; Copy this value into all of the lines
sta: $0000,y sta: $0000,x
; Next, patch in the CODE_ENTRY value, which is the low byte of a JMP instruction. This is an ; Next, patch in the CODE_ENTRY value, which is the low byte of a JMP instruction. This is an
; 8-bit operation and, since the PEA code is bank aligned, we use the entry_offset value directly ; 8-bit operation and, since the PEA code is bank aligned, we use the entry_offset value directly
@ -135,7 +136,7 @@ _ScanlineBG0XPos
; SetCodeEntry ; SetCodeEntry
lda :entry_offset lda :entry_offset
ldy :base_address ; ldy :base_address
sta: CODE_ENTRY+$0000,y sta: CODE_ENTRY+$0000,y
; SetCodeEntryOpcode ; SetCodeEntryOpcode
@ -151,11 +152,11 @@ _ScanlineBG0XPos
; SetOddCodeEntry ; SetOddCodeEntry
sta: ODD_ENTRY+$0000,y sta: ODD_ENTRY+$0000,y
; SaveHighOperand ; SaveHighOperand
ldx :exit_address ; ldx :exit_address
lda: $0002,x lda: $0002,x
sta: OPCODE_HIGH_SAVE+$0000,y sta: OPCODE_HIGH_SAVE+$0000,y
:not_odd :not_odd
rep #$21 ; clear the carry rep #$20 ; clear the carry
; Do the end of the loop -- update the virtual line counter and reduce the number ; Do the end of the loop -- update the virtual line counter and reduce the number
; of lines left to render ; of lines left to render
@ -193,18 +194,19 @@ _RestoreScanlineBG0Opcodes
:loop :loop
ldx :virt_line_x2 ldx :virt_line_x2
ldy BTableLow,x ; Get the address of the first code field line
lda BTableHigh,x lda BTableHigh,x
ora :src_bank ora :src_bank
pha pha
lda LastPatchOffsetArr,x lda BTableLow,x ; Get the address of the first code field line
clc
adc LastPatchOffsetArr,x
tax tax
plb plb
lda OPCODE_SAVE+$0000,y lda: OPCODE_SAVE+$0000,y
sta $0000,x sta: $0000,x
; Do the end of the loop -- update the virtual line counter and reduce the number ; Do the end of the loop -- update the virtual line counter and reduce the number
; of lines left to render ; of lines left to render

View File

@ -5,12 +5,12 @@
DP_ADDR equ entry_1-base+1 ; offset to patch in the direct page for dynamic tiles DP_ADDR equ entry_1-base+1 ; offset to patch in the direct page for dynamic tiles
BG1_ADDR equ entry_2-base+1 ; offset to patch in the Y-reg for BG1 (dp),y addressing BG1_ADDR equ entry_2-base+1 ; offset to patch in the Y-reg for BG1 (dp),y addressing
STK_ADDR equ entry_3-base+1 ; offset to patch in the stack (SHR) right edge address STK_ADDR equ entry_3-base+1 ; offset to patch in the stack (SHR) right edge address
BNK_ADDR equ entry_0-base+1 ; offset to patch in the address of a Bank 0 memory location to load the bank register ; BNK_ADDR equ entry_0-base+1 ; offset to patch in the address of a Bank 0 memory location to load the bank register
DP_ENTRY equ entry_1-base DP_ENTRY equ entry_1-base
TWO_LYR_ENTRY equ entry_2-base TWO_LYR_ENTRY equ entry_2-base
ONE_LYR_ENTRY equ entry_3-base ONE_LYR_ENTRY equ entry_3-base
BANK_ENTRY equ entry_0-base ; BANK_ENTRY equ entry_0-base
CODE_ENTRY_OPCODE equ entry_jmp-base CODE_ENTRY_OPCODE equ entry_jmp-base
CODE_ENTRY equ entry_jmp-base+1 ; low byte of the page-aligned jump address CODE_ENTRY equ entry_jmp-base+1 ; low byte of the page-aligned jump address
@ -68,9 +68,9 @@ BankPatchNum equ *-BankPatches
; the code is assembled on a page boundary to help with alignment ; the code is assembled on a page boundary to help with alignment
ds \,$00 ; pad to the next page boundary ds \,$00 ; pad to the next page boundary
base base
entry_0 lda #0000 ; Used to set per-scanline bank register ;entry_0 lda #0000 ; Used to set per-scanline bank register
tcs ; tcs
plb ; plb
entry_1 ldx #0000 ; Used for LDA 00,x addressing (Dynamic Tiles) entry_1 ldx #0000 ; Used for LDA 00,x addressing (Dynamic Tiles)
entry_2 ldy #0000 ; Used for LDA (00),y addressing (Second Layer; BG1) entry_2 ldy #0000 ; Used for LDA (00),y addressing (Second Layer; BG1)
entry_3 lda #0000 ; Sets screen address (right edge) entry_3 lda #0000 ; Sets screen address (right edge)