Work to expose times via Toolset

This commit is contained in:
Lucas Scharenbroich 2022-06-26 22:08:42 -05:00
parent c257d72060
commit 8aafd5812b
9 changed files with 156 additions and 107 deletions

View File

@ -68,7 +68,8 @@ ScreenHeight equ 14
; Set up our level data ; Set up our level data
jsr BG0SetUp jsr BG0SetUp
; jsr TileAnimInit
jsr TileAnimInit
jsr SetLimits jsr SetLimits
; jsr InitOverlay ; Initialize the status bar ; jsr InitOverlay ; Initialize the status bar
@ -145,6 +146,7 @@ HERO_VBUFF equ VBUFF_SPRITE_START+0*VBUFF_SPRITE_STEP
HERO_SLOT equ 1 HERO_SLOT equ 1
MUSHROOM_ID equ {SPRITE_16X16+255} MUSHROOM_ID equ {SPRITE_16X16+255}
MUSHROOM_VBUFF equ VBUFF_SPRITE_START+1*VBUFF_SPRITE_STEP MUSHROOM_VBUFF equ VBUFF_SPRITE_START+1*VBUFF_SPRITE_STEP
MUSHROOM_SLOT equ 0
pea HERO_ID ; sprint id pea HERO_ID ; sprint id
pea HERO_VBUFF ; vbuff address pea HERO_VBUFF ; vbuff address
@ -153,19 +155,19 @@ MUSHROOM_VBUFF equ VBUFF_SPRITE_START+1*VBUFF_SPRITE_STEP
pea MUSHROOM_ID ; sprint id pea MUSHROOM_ID ; sprint id
pea MUSHROOM_VBUFF ; vbuff address pea MUSHROOM_VBUFF ; vbuff address
_GTECreateSpriteStamp _GTECreateSpriteStamp
pea MUSHROOM_ID ; Put the mushroom in Slot 0 pea MUSHROOM_ID ; Put the mushroom in Slot 0
pea #80 ; at x=80, y=152 pea #80 ; at x=80, y=152
pea #152 pea #152
pea $0000 pea MUSHROOM_SLOT
_GTEAddSprite _GTEAddSprite
pea $0000 pea MUSHROOM_SLOT
pea $0000 ; with these flags (h/v flip) pea $0000 ; with these flags (h/v flip)
pea MUSHROOM_VBUFF ; and use this stamp pea MUSHROOM_VBUFF ; and use this stamp
_GTEUpdateSprite _GTEUpdateSprite
jsr UpdatePlayerLocal jsr UpdatePlayerLocal
pea HERO_ID pea HERO_ID
lda PlayerX lda PlayerX
@ -360,12 +362,23 @@ Exit
bcs Fatal bcs Fatal
Fatal brk $00 Fatal brk $00
Hold
_GTERender
:busy
pha
_GTEReadControl
pla
and #$00FF
cmp #'q'
bne :busy
jmp Exit
BG1DataFile strl '1/sunset.c1' BG1DataFile strl '1/sunset.c1'
; Color palette ; Color palette
MyPalette dw $068F,$0EDA,$0000,$0000,$0BF1,$00A0,$0EEE,$0456,$0FA4,$0F59,$0E30,$01CE,$02E3,$0870,$0F93,$0FD7 MyPalette dw $068F,$0EDA,$0000,$0000,$0BF1,$00A0,$0EEE,$0456,$0FA4,$0F59,$0E30,$01CE,$02E3,$0870,$0F93,$0FD7
; B&W Palette ; B&W Palette
;MyPalette dw $0000,$0EDA,$0000,$0E51,$0BF1,$00A0,$0EEE,$0456,$0FA4,$0F59,$0E30,$01CE,$02E3,$0870,$0F93,$0FFF ; MyPalette dw $0000,$0EDA,$0000,$0E51,$0BF1,$00A0,$0EEE,$0456,$0FA4,$0F59,$0E30,$01CE,$02E3,$0870,$0F93,$0FFF
PlayerGlobalX ds 2 PlayerGlobalX ds 2
PlayerGlobalY ds 2 PlayerGlobalY ds 2
@ -499,6 +512,7 @@ UpdatePlayerPos
; Check if the player is standing on the ground at their current local position ; Check if the player is standing on the ground at their current local position
pha ; space for result
lda PlayerX lda PlayerX
pha pha
lda PlayerY lda PlayerY
@ -770,4 +784,4 @@ _GetVBLTicks
; PUT ../shell/Overlay.s ; PUT ../shell/Overlay.s
PUT gen/App.TileMapBG0.s PUT gen/App.TileMapBG0.s
; PUT gen/App.TileSetAnim.s PUT gen/App.TileSetAnim.s

View File

@ -1,52 +1,41 @@
TileAnimInit ENT TileAnimInit
pea #137
ldx #137 pea #0
ldy #0 _GTECopyTileToDynamic
jsl CopyTileToDyn pea #138
ldx #138 pea #1
ldy #1 _GTECopyTileToDynamic
jsl CopyTileToDyn pea #169
ldx #169 pea #2
ldy #2 _GTECopyTileToDynamic
jsl CopyTileToDyn pea #170
ldx #170 pea #3
ldy #3 _GTECopyTileToDynamic
jsl CopyTileToDyn
lda #TileAnim_136
ldx #^TileAnim_136
ldy #15
jsl StartScript
lda #TileAnim_137
ldx #^TileAnim_137
ldy #15
jsl StartScript
lda #TileAnim_168
ldx #^TileAnim_168
ldy #15
jsl StartScript
lda #TileAnim_169
ldx #^TileAnim_169
ldy #15
jsl StartScript
rts rts
TileAnim_136
dw $8006,137,0,0 pea #15
dw $8006,139,0,0 pea #^TileAnim
dw $8006,141,0,0 pea #TileAnim
dw $cd06,143,0,0 _GTEStartScript
TileAnim_137 rts
dw $8006,138,1,0 TileAnim
dw $8006,140,1,0 dw $0006,137,0,0
dw $8006,142,1,0 dw $0006,138,1,0
dw $cd06,144,1,0 dw $0006,169,2,0
TileAnim_168
dw $8006,169,2,0
dw $8006,171,2,0
dw $8006,173,2,0
dw $cd06,175,2,0
TileAnim_169
dw $8006,170,3,0 dw $8006,170,3,0
dw $0006,139,0,0
dw $0006,140,1,0
dw $0006,171,2,0
dw $8006,172,3,0 dw $8006,172,3,0
dw $0006,141,0,0
dw $0006,142,1,0
dw $0006,173,2,0
dw $8006,174,3,0 dw $8006,174,3,0
dw $cd06,176,3,0
dw $0006,143,0,0
dw $0006,144,1,0
dw $0006,175,2,0
dw $cc46,176,3,0 ; STOP; JUMP(-15) -15 = $31 (6 bit) = %110001 = 1100 0100 = C4

View File

@ -87,6 +87,15 @@ _GTESetBG0TileMapInfo MAC
_GTESetBG1TileMapInfo MAC _GTESetBG1TileMapInfo MAC
UserTool $1E00+GTEToolNum UserTool $1E00+GTEToolNum
<<< <<<
_GTEAddTimer MAC
UserTool $1F00+GTEToolNum
<<<
_GTERemoveTimer MAC
UserTool $2000+GTEToolNum
<<<
_GTEStartScript MAC
UserTool $2100+GTEToolNum
<<<
; EngineMode definitions ; EngineMode definitions
; Script definition ; Script definition

View File

@ -254,3 +254,6 @@ VBuffArray EXT
_stamp_step EXT _stamp_step EXT
VBuffVertTableSelect EXT VBuffVertTableSelect EXT
VBuffHorzTableSelect EXT VBuffHorzTableSelect EXT
; Tool error codes
NO_TIMERS_AVAILABLE equ 10

View File

@ -34,7 +34,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 _ApplyTilesFast ; This function actually draws the new tiles into the code field jsr _ApplyTilesFast ; This function actually draws the new tiles into the code field

View File

@ -33,17 +33,13 @@
; ;
; A pointer to the current command instruction is stored in the first 4 bytes of the ; A pointer to the current command instruction is stored in the first 4 bytes of the
; timer's user data section. ; timer's user data section.
StartScript ENT _StartScript phx ; Save the script array address
phb
jsr _SetDataBank
phx ; Save the script array address
pha pha
lda #_DoScriptSeq ; Try to create a timer for this script lda #_DoScriptSeq ; Try to create a timer for this script
ldx #^_DoScriptSeq ldx #^_DoScriptSeq
clc clc
jsl AddTimer jsr _AddTimer
bcs :err ; No timer slots available :( bcs :err ; No timer slots available :(
tax ; Initialize the UserData with the command pointer tax ; Initialize the UserData with the command pointer
@ -52,14 +48,12 @@ StartScript ENT
pla pla
sta Timers+10,x sta Timers+10,x
plb rts
rtl
:err :err
pla ; Pop the values and return with the carry flag set pla ; Pop the values and return with the carry flag set
pla pla
plb rts
rtl
; This routine executes script command until it encounters one with the STOP bit set. In some ; This routine executes script command until it encounters one with the STOP bit set. In some
; sense, the stop bit acts like a "yield" in high-level languages. ; sense, the stop bit acts like a "yield" in high-level languages.
@ -107,18 +101,20 @@ _dss_cmd_rtn
; to the next entry. ; to the next entry.
bit #JUMP ; Just do a fall through and set the jump offset to bit #JUMP ; Just do a fall through and set the jump offset to
bne :move_addr ; a hard-coded value of 1 if the jump bit is not set bne :move_addr ; a hard-coded value of 1 if the jump bit is not set
:retry lda #$0100 :retry lda #$0040
:move_addr and #$0F00 ; mask out the number of commands to move :move_addr and #$0FC0 ; mask out the number of commands to move
beq :retry ; Don't allow zeros; will cause infinite loop. Just advance by one. beq :retry ; Don't allow zeros; will cause infinite loop. Just advance by one.
xba ; put it in the low byte cmp #$0800 ; Sign-extend the 6-bit value
cmp #$0008 ; Sign-extend the 4-bit value
bcc *+5 bcc *+5
ora #$FFF0 ora #$F000
asl ; multiply by 8 cmp #$8000 ; make it a multiple of 8 (preserve sign)
asl ror
asl cmp #$8000
ror
cmp #$8000
ror
clc clc
adc 3,s ; add it to the saved command address adc 3,s ; add it to the saved command address
sta 3,s sta 3,s

View File

@ -10,12 +10,6 @@
; in actual games since the primary background is often large empty areas, or runs ; in actual games since the primary background is often large empty areas, or runs
; of repeating tiles. ; of repeating tiles.
; Debug locations
LastTop ds 2
LastBottom ds 2
LastLeft ds 2
LastRight ds 2
; The ranges are [:Left, :Right] and [:Top, :Bottom], so :Right can be, at most, 40 ; The ranges are [:Left, :Right] and [:Top, :Bottom], so :Right can be, at most, 40
; if we are drawing all 41 tiles (Index 0 through 40). The :Bottom value can be ; if we are drawing all 41 tiles (Index 0 through 40). The :Bottom value can be
; at most 25. ; at most 25.
@ -222,17 +216,6 @@ _UpdateBG0TileMap
:NoXUpdate :NoXUpdate
rts rts
;:Debug
; lda :Top ; Debugging
; sta LastTop
; lda :Bottom
; sta LastBottom
; lda :Left
; sta LastLeft
; lda :Right
; sta LastRight
; rts
; This is a private subroutine that draws in tiles into the code fields using the ; This is a private subroutine that draws in tiles into the code fields using the
; data from the tilemap and the local :Top, :Left, :Bottom and :Right parameters. ; data from the tilemap and the local :Top, :Left, :Bottom and :Right parameters.
:DrawRectBG0 :DrawRectBG0
@ -639,7 +622,7 @@ _DrawRectBG1
ldx :BlkX ldx :BlkX
ldy :BlkY ldy :BlkY
jsr _CopyBG1Tile ; jsr _CopyBG1Tile
lda :BlkX lda :BlkX
inc inc
@ -676,4 +659,3 @@ _DrawRectBG1
pla pla
rts rts

View File

@ -31,16 +31,12 @@ InitTimers
; Return ; Return
; C = 0 if success, 1 if no timer slots are available ; C = 0 if success, 1 if no timer slots are available
; A = timer slot ID if C = 0 ; A = timer slot ID if C = 0
AddTimer ENT _AddTimer
phb
php ; Save the input parameters php ; Save the input parameters
phx phx
pha pha
phy phy
jsr _SetDataBank
ldx #0 ldx #0
:loop lda Timers,x ; If the counter is zero, timer is free :loop lda Timers,x ; If the counter is zero, timer is free
beq :freeslot beq :freeslot
@ -72,8 +68,7 @@ AddTimer ENT
lda Timers+0,x ; if not a one-shot, put the counter lda Timers+0,x ; if not a one-shot, put the counter
sta Timers+2,x ; value into the reset field sta Timers+2,x ; value into the reset field
:oneshot plb :oneshot txa ; return the slot ID and a success status
txa ; return the slot ID and a success status
clc clc
rtl rtl
@ -81,18 +76,15 @@ AddTimer ENT
pla pla
plx plx
plp plp
plb
sec ; Return an error status sec ; Return an error status
lda #0 lda #0
rtl rts
; Small function to remove a timer ; Small function to remove a timer
; ;
; A = Timer ID ; A = Timer ID
RemoveTimer ENT _RemoveTimer
phb
jsr _SetDataBank
cmp #{TIMER_REC_SIZE*{MAX_TIMERS-1}}+1 cmp #{TIMER_REC_SIZE*{MAX_TIMERS-1}}+1
bcs :exit bcs :exit
@ -103,8 +95,7 @@ RemoveTimer ENT
stz Timers+6,x stz Timers+6,x
:exit :exit
plb rts
rtl
; Execute the timer functions ; Execute the timer functions
;DoTimers ENT ;DoTimers ENT

View File

@ -30,6 +30,14 @@ _TSExit mac
jml ToStrip jml ToStrip
<<< <<<
_TSExit1 mac
plb
pld
; ldx ]1 ; Error code already in X
ldy ]1 ; Number of stack bytes to remove
jml ToStrip
<<<
FirstParam equ 10 ; When using the _TSEntry macro, the first parameter is at 10,s FirstParam equ 10 ; When using the _TSEntry macro, the first parameter is at 10,s
mx %00 mx %00
@ -71,6 +79,10 @@ _CallTable
adrl _TSSetBG0TileMapInfo-1 adrl _TSSetBG0TileMapInfo-1
adrl _TSSetBG1TileMapInfo-1 adrl _TSSetBG1TileMapInfo-1
adrl _TSAddTimer-1
adrl _TSRemoveTimer-1
adrl _TSStartScript-1
_CTEnd _CTEnd
_GTEAddSprite MAC _GTEAddSprite MAC
UserTool $1000+GTEToolNum UserTool $1000+GTEToolNum
@ -551,13 +563,66 @@ _TSSetBG1TileMapInfo
sta TileMapPtr+2 sta TileMapPtr+2
_TSExit #0;#8 _TSExit #0;#8
; AddTimer(numTicks, callback, flags)
_TSAddTimer
:flags equ FirstParam+0
:callback equ FirstParam+2
:numTicks equ FirstParam+6
:output equ FirstParam+8
_TSEntry
lda :callback+2,s
tax
lda :callback,s
tay
lda :flags,s
lsr ; put low bit into carry
lda :numTicks,s
jsr _AddTimer
sta :output,s
ldx #0
bcc :no_err
ldx #NO_TIMERS_AVAILABLE
:no_err
_TSExit1 #8
; RemoveTimer(timerId)
_TSRemoveTimer
:timerId equ FirstParam+0
_TSEntry
lda :timerId,s
jsr _RemoveTimer
_TSExit #0;#2
; StartScript(timerId)
_TSStartScript
:scriptAddr equ FirstParam+0
:numTicks equ FirstParam+4
_TSEntry
lda :numTicks,s
tay
lda :scriptAddr+2,s
tax
lda :scriptAddr,s
jsr _StartScript
_TSExit #0;#6
; Insert the GTE code ; Insert the GTE code
put Math.s put Math.s
put CoreImpl.s put CoreImpl.s
put Memory.s put Memory.s
put Timer.s put Timer.s
put Script.s
put TileMap.s put TileMap.s
put Graphics.s put Graphics.s
put Tiles.s put Tiles.s