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

View File

@ -1,52 +1,41 @@
TileAnimInit ENT
ldx #137
ldy #0
jsl CopyTileToDyn
ldx #138
ldy #1
jsl CopyTileToDyn
ldx #169
ldy #2
jsl CopyTileToDyn
ldx #170
ldy #3
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
TileAnimInit
pea #137
pea #0
_GTECopyTileToDynamic
pea #138
pea #1
_GTECopyTileToDynamic
pea #169
pea #2
_GTECopyTileToDynamic
pea #170
pea #3
_GTECopyTileToDynamic
rts
TileAnim_136
dw $8006,137,0,0
dw $8006,139,0,0
dw $8006,141,0,0
dw $cd06,143,0,0
TileAnim_137
dw $8006,138,1,0
dw $8006,140,1,0
dw $8006,142,1,0
dw $cd06,144,1,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
pea #15
pea #^TileAnim
pea #TileAnim
_GTEStartScript
rts
TileAnim
dw $0006,137,0,0
dw $0006,138,1,0
dw $0006,169,2,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 $0006,141,0,0
dw $0006,142,1,0
dw $0006,173,2,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
UserTool $1E00+GTEToolNum
<<<
_GTEAddTimer MAC
UserTool $1F00+GTEToolNum
<<<
_GTERemoveTimer MAC
UserTool $2000+GTEToolNum
<<<
_GTEStartScript MAC
UserTool $2100+GTEToolNum
<<<
; EngineMode definitions
; Script definition

View File

@ -254,3 +254,6 @@ VBuffArray EXT
_stamp_step EXT
VBuffVertTableSelect 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 _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 _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
; timer's user data section.
StartScript ENT
phb
jsr _SetDataBank
phx ; Save the script array address
_StartScript phx ; Save the script array address
pha
lda #_DoScriptSeq ; Try to create a timer for this script
ldx #^_DoScriptSeq
clc
jsl AddTimer
jsr _AddTimer
bcs :err ; No timer slots available :(
tax ; Initialize the UserData with the command pointer
@ -52,14 +48,12 @@ StartScript ENT
pla
sta Timers+10,x
plb
rtl
rts
:err
pla ; Pop the values and return with the carry flag set
pla
plb
rtl
rts
; 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.
@ -107,18 +101,20 @@ _dss_cmd_rtn
; to the next entry.
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
:retry lda #$0100
:move_addr and #$0F00 ; mask out the number of commands to move
:retry lda #$0040
: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.
xba ; put it in the low byte
cmp #$0008 ; Sign-extend the 4-bit value
cmp #$0800 ; Sign-extend the 6-bit value
bcc *+5
ora #$FFF0
ora #$F000
asl ; multiply by 8
asl
asl
cmp #$8000 ; make it a multiple of 8 (preserve sign)
ror
cmp #$8000
ror
cmp #$8000
ror
clc
adc 3,s ; add it to the saved command address
sta 3,s

View File

@ -10,12 +10,6 @@
; in actual games since the primary background is often large empty areas, or runs
; 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
; if we are drawing all 41 tiles (Index 0 through 40). The :Bottom value can be
; at most 25.
@ -222,17 +216,6 @@ _UpdateBG0TileMap
:NoXUpdate
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
; data from the tilemap and the local :Top, :Left, :Bottom and :Right parameters.
:DrawRectBG0
@ -639,7 +622,7 @@ _DrawRectBG1
ldx :BlkX
ldy :BlkY
jsr _CopyBG1Tile
; jsr _CopyBG1Tile
lda :BlkX
inc
@ -676,4 +659,3 @@ _DrawRectBG1
pla
rts

View File

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

View File

@ -30,6 +30,14 @@ _TSExit mac
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
mx %00
@ -71,6 +79,10 @@ _CallTable
adrl _TSSetBG0TileMapInfo-1
adrl _TSSetBG1TileMapInfo-1
adrl _TSAddTimer-1
adrl _TSRemoveTimer-1
adrl _TSStartScript-1
_CTEnd
_GTEAddSprite MAC
UserTool $1000+GTEToolNum
@ -551,13 +563,66 @@ _TSSetBG1TileMapInfo
sta TileMapPtr+2
_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
put Math.s
put CoreImpl.s
put Memory.s
put Timer.s
put Script.s
put TileMap.s
put Graphics.s
put Tiles.s