Initial Tiled tile animation export support

* Tiled tile animations read from TSX files
* Hooks for initialization generated by the tiled export tool
* Animated tiles implements with dynamic tiles backed by 2KB of direct
  page space in Bank 00
* Animation resolution limited to 1/60th incremenents

TODO
* Fix crasher in the _DoScriptSequ timer callback
* Fix single-line of garbage on the top line of the dynamic tiles
This commit is contained in:
Lucas Scharenbroich 2021-10-06 07:10:09 -05:00
parent 7d7a54a731
commit 87ded17e20
23 changed files with 7023 additions and 885 deletions

View File

@ -1,229 +1,220 @@
MoveLeft
clc
adc StartX ; Increment the virtual X-position
jsl SetBG0XPos
adc StartX ; Increment the virtual X-position
jsl SetBG0XPos
lda StartX
lda StartX
lsr
jsl SetBG1XPos
jsl SetBG1XPos
jsl Render
jsl Render
rts
MoveRight
pha
lda StartX
lda StartX
sec
sbc 1,s
bpl *+5
lda #0
jsl SetBG0XPos
sbc 1,s
bpl *+5
lda #0
jsl SetBG0XPos
lda StartX
lda StartX
lsr
jsl SetBG1XPos
jsl SetBG1XPos
jsl Render
jsl Render
pla
rts
MoveUp
clc
adc StartY ; Increment the virtual Y-position
adc StartY ; Increment the virtual Y-position
pha
lda #240 ; virtual play field height
lda #240 ; virtual play field height
sec
sbc ScreenHeight
sbc ScreenHeight
tax
cmp 1,s
bcc *+4
lda 1,s
jsl SetBG0YPos
cmp 1,s
bcc *+4
lda 1,s
jsl SetBG0YPos
pla
; lda StartY
; lsr
; jsl SetBG1YPos
jsl Render
jsl Render
rts
MoveDown
pha
lda StartY
lda StartY
sec
sbc 1,s
bpl *+5
lda #0
jsl SetBG0YPos
sbc 1,s
bpl *+5
lda #0
jsl SetBG0YPos
; lda StartY
; lsr
; jsl SetBG1YPos
jsl Render
jsl Render
pla
rts
; Very simple, scroll as fast as possible
oldOneSecondCounter ds 2
frameCount ds 2
lastTick ds 2
oldOneSecondCounter ds 2
frameCount ds 2
Demo
ldal OneSecondCounter
sta oldOneSecondCounter
stz frameCount
ldal OneSecondCounter
sta oldOneSecondCounter
stz frameCount
; Every 3 ticks (20 fps) cycle some colors
lda #DoColorCycle
ldx #^DoColorCycle
ldy #3
jsl AddTimer
; lda #DoColorCycle
; ldx #^DoColorCycle
; ldy #3
; jsl AddTimer
:loop
PushLong #0
_GetTick
pla
plx
cmp lastTick ; Throttle to 60 fps
beq :loop
tax ; Calculate the increment
sec
sbc lastTick
stx lastTick
; jsr _DoTimers
jsl DoTimers
; lda #1
; jsr MoveLeft
jsr UpdateBG1Rotation
jsr UpdateBG1Rotation
; jsr DoColorCycle
jsl Render
jsl Render
inc frameCount
inc frameCount
ldal KBD_STROBE_REG
bit #$0080
beq :nokey
and #$007F
cmp #'s'
bne :nokey
ldal KBD_STROBE_REG
bit #$0080
beq :nokey
and #$007F
cmp #'s'
bne :nokey
rts
:nokey
ldal OneSecondCounter
cmp oldOneSecondCounter
beq :loop
ldal OneSecondCounter
cmp oldOneSecondCounter
beq :loop
sta oldOneSecondCounter
lda ScreenWidth
cmp #150
bcs :loop
sta oldOneSecondCounter
lda ScreenWidth
cmp #150
bcs :loop
lda #FPSStr
ldx #0 ; top-left corner
ldy #$7777
jsr DrawString
lda #FPSStr
ldx #0 ; top-left corner
ldy #$7777
jsr DrawString
lda frameCount
ldx #4*4
jsr DrawWord
lda frameCount
ldx #4*4
jsr DrawWord
stz frameCount
bra :loop
stz frameCount
bra :loop
FPSStr str 'FPS'
FPSStr str 'FPS'
; Move some colors around color (6 - 11) address 12 - 22
DoColorCycle
ldal $E19E0C
ldal $E19E0C
pha
ldal $E19E0E
ldal $E19E0E
pha
ldal $E19E10
ldal $E19E10
pha
ldal $E19E12
ldal $E19E12
pha
ldal $E19E14
ldal $E19E14
pha
ldal $E19E16
stal $E19E0C
ldal $E19E16
stal $E19E0C
pla
stal $E19E16
stal $E19E16
pla
stal $E19E14
stal $E19E14
pla
stal $E19E12
stal $E19E12
pla
stal $E19E10
stal $E19E10
pla
stal $E19E0E
stal $E19E0E
rts
; Triggered timer to sway the background
UpdateBG1Offset
lda BG1OffsetIndex
lda BG1OffsetIndex
inc
inc
cmp #32 ; 16 entries x 2 for indexing
bcc *+5
sbc #32
sta BG1OffsetIndex
cmp #32 ; 16 entries x 2 for indexing
bcc *+5
sbc #32
sta BG1OffsetIndex
rts
AngleUp
lda angle
lda angle
inc
cmp #64
bcc *+5
sbc #64
sta angle
jsr _ApplyAngle
jsl Render
cmp #64
bcc *+5
sbc #64
sta angle
jsr _ApplyAngle
jsl Render
rts
AngleDown
lda angle
lda angle
dec
bpl *+6
bpl *+6
clc
adc #64
sta angle
jsr _ApplyAngle
jsl Render
adc #64
sta angle
jsr _ApplyAngle
jsl Render
rts
angle dw 0
angle dw 0
UpdateBG1Rotation
jsr _ApplyAngle
jsr _ApplyAngle
; Increment the angle
lda angle
lda angle
inc
cmp #64
bcc *+5
lda #0
sta angle
cmp #64
bcc *+5
lda #0
sta angle
rts
x_angles EXT
y_angles EXT
_ApplyAngle
lda angle ; debug with angle = 0
lda angle ; debug with angle = 0
asl
tax
ldal x_angles,x ; load the address of addressed for this angle
ldal x_angles,x ; load the address of addressed for this angle
tay
phx
jsl ApplyBG1XPosAngle
jsl ApplyBG1XPosAngle
plx
ldal y_angles,x ; load the address of addresses for this angle
ldal y_angles,x ; load the address of addresses for this angle
tay
jsl ApplyBG1YPosAngle
jsl ApplyBG1YPosAngle
rts

View File

@ -8,17 +8,15 @@
use EDS.GSOS.MACS.s
use Tool222.Macs.s
use Util.Macs.s
use CORE.MACS.s
use ../../src/GTE.s
use ../../src/Defs.s
mx %00
; External references
tiledata ext
; Feature flags
NO_INTERRUPTS equ 1 ; turn off for crossrunner debugging
NO_MUSIC equ 1 ; turn music + tool loading off
NO_INTERRUPTS equ 0 ; turn off for crossrunner debugging
NO_MUSIC equ 1 ; turn music + tool loading off
; Typical init
phk
@ -26,60 +24,119 @@ NO_MUSIC equ 1 ; turn music + tool loading of
jsl EngineStartUp
lda #^MyPalette
ldx #MyPalette
ldy #0
jsl SetPalette
ldx #0
jsl SetScreenMode
; Set up our level data
; jsr BG0SetUp
jsr BG0SetUp
; jsr BG1SetUp
jsr TileAnimInit
; Allocate room to load data
jsl AllocBank ; Alloc 64KB for Load/Unpack
sta BankLoad ; Store "Bank Pointer"
jsl AllocBank ; Alloc 64KB for Load/Unpack
sta BankLoad ; Store "Bank Pointer"
; jsr MovePlayerToOrigin ; Put the player at the beginning of the map
jsr MovePlayerToOrigin ; Put the player at the beginning of the map
; lda #DIRTY_BIT_BG0_REFRESH ; Redraw all of the tiles on the next Render
; ora #DIRTY_BIT_BG1_REFRESH
; tsb DirtyBits
lda #DIRTY_BIT_BG0_REFRESH ; Redraw all of the tiles on the next Render
ora #DIRTY_BIT_BG1_REFRESH
tsb DirtyBits
; lda #$FFFF
lda #$FFFF
jsl Render
EvtLoop
jsl ReadControl
and #$007F ; Ignore the buttons for now
and #$007F ; Ignore the buttons for now
cmp #'q'
bne :1
brl Exit
:1 cmp #'l'
tcounter dw 0
tileIDs dw 168,170,172,174,168,170,172,174
dw 169,171,173,175,169,171,173,175
dw 208,210,212,214,208,210,212,214
dw 209,211,213,215,209,211,213,215
;tileIDs dw 1,1,1,1,1,1,1,5
; dw 2,2,2,2,2,2,2,6
; dw 3,3,3,3,3,3,3,7
; dw 4,4,4,4,4,4,4,8
:1
cmp #'r'
bne EvtLoop
jsl DoTimers
inc tcounter
lda tcounter
and #$0007
asl
tay
lda tileIDs,y
pha
lda tileIDs+16,y
pha
lda tileIDs+32,y
pha
ldx tileIDs+48,y
inx
ldy #3
jsl CopyTileToDyn
plx
inx
ldy #2
jsl CopyTileToDyn
plx
inx
ldy #1
jsl CopyTileToDyn
plx
inx
ldy #0
jsl CopyTileToDyn
jsl Render
brl EvtLoop
cmp #'l'
bne :1_1
jsr DoLoadFG
bra EvtLoop
brl EvtLoop
:1_1 cmp #'b'
bne :2
jsr DoLoadBG1
bra EvtLoop
brl EvtLoop
:2 cmp #'m'
bne :3
jsr DumpBanks
bra EvtLoop
brl EvtLoop
:3 cmp #'f' ; render a 'f'rame
:3 cmp #'f' ; render a 'f'rame
bne :4
jsl Render
bra EvtLoop
brl EvtLoop
:4 cmp #'h' ; Show the 'h'eads up display
:4 cmp #'h' ; Show the 'h'eads up display
bne :5
jsr DoHUP
bra EvtLoop
brl EvtLoop
:5 cmp #'1' ; User selects a new screen size
:5 cmp #'1' ; User selects a new screen size
bcc :6
cmp #'9'+1
bcs :6
@ -95,7 +152,7 @@ EvtLoop
jsr DoTiles
brl EvtLoop
:7 cmp #$15 ; left = $08, right = $15, up = $0B, down = $0A
:7 cmp #$15 ; left = $08, right = $15, up = $0B, down = $0A
bne :8
lda #1
jsr MoveRight
@ -146,18 +203,20 @@ Exit
bcs Fatal
Fatal brk $00
MyPalette dw $0E51,$0EDA,$0000,$068F,$0BF1,$00A0,$0EEE,$0777,$0FA4,$0F59,$0F31,$02E3,$09B9,$01CE,$0EE6
StartMusic
pea #^MusicFile
pea #MusicFile
_NTPLoadOneMusic
pea $0001 ; loop
pea $0001 ; loop
_NTPPlayMusic
rts
; Position the screen with the botom-left corner of the tilemap visible
MovePlayerToOrigin
lda #0 ; Set the player's position
lda #0 ; Set the player's position
jsl SetBG0XPos
lda #0
jsl SetBG1XPos
@ -199,8 +258,8 @@ DoHUP
ldx #{160-12*4}
ldy #$7777
jsr DrawString
lda OneSecondCounter ; Number of elapsed seconds
ldx #{160-4*4} ; Render the word 4 charaters from right edge
lda OneSecondCounter ; Number of elapsed seconds
ldx #{160-4*4} ; Render the word 4 charaters from right edge
jsr DrawWord
lda #TicksStr
@ -221,7 +280,7 @@ DoTiles
:column equ 3
:tile equ 5
pea $0000 ; Allocate local variable space
pea $0000 ; Allocate local variable space
pea $0000
pea $0000
@ -251,7 +310,7 @@ DoTiles
cmp #26
bcc :rowloop
pla ; restore the stack
pla ; restore the stack
pla
pla
rts
@ -284,7 +343,7 @@ DoLoadFG
ldx #FGName
jsr LoadFile
ldx BankLoad ; Copy it into the code field
ldx BankLoad ; Copy it into the code field
lda #0
jsl CopyBinToField
rts
@ -292,10 +351,10 @@ DoLoadFG
; Load a simple picture format onto the SHR screen
DoLoadPic
lda BankLoad
ldx #ImageName ; Load+Unpack Boot Picture
jsr LoadPicture ; X=Name, A=Bank to use for loading
ldx #ImageName ; Load+Unpack Boot Picture
jsr LoadPicture ; X=Name, A=Bank to use for loading
ldx BankLoad ; Copy it into the code field
ldx BankLoad ; Copy it into the code field
lda #0
jsl CopyPicToField
rts
@ -336,43 +395,43 @@ DefaultPalette dw $0E51,$0EDB,$0000,$068F,$0BF1,$00A0,$0EEE,$0777,$
; Graphics helpers
LoadPicture
jsr LoadFile ; X=Nom Image, A=Banc de chargement XX/00
jsr LoadFile ; X=Nom Image, A=Banc de chargement XX/00
bcc :loadOK
rts
:loadOK
jsr UnpackPicture ; A=Packed Size
jsr UnpackPicture ; A=Packed Size
rts
UnpackPicture sta UP_PackedSize ; Size of Packed Data
lda #$8000 ; Size of output Data Buffer
UnpackPicture sta UP_PackedSize ; Size of Packed Data
lda #$8000 ; Size of output Data Buffer
sta UP_UnPackedSize
lda BankLoad ; Banc de chargement / Decompression
sta UP_Packed+1 ; Packed Data
lda BankLoad ; Banc de chargement / Decompression
sta UP_Packed+1 ; Packed Data
clc
adc #$0080
stz UP_UnPacked ; On remet a zero car modifie par l'appel
stz UP_UnPacked ; On remet a zero car modifie par l'appel
stz UP_UnPacked+2
sta UP_UnPacked+1 ; Unpacked Data buffer
sta UP_UnPacked+1 ; Unpacked Data buffer
PushWord #0 ; Space for Result : Number of bytes unpacked
PushLong UP_Packed ; Pointer to buffer containing the packed data
PushWord UP_PackedSize ; Size of the Packed Data
PushLong #UP_UnPacked ; Pointer to Pointer to unpacked buffer
PushLong #UP_UnPackedSize ; Pointer to a Word containing size of unpacked data
PushWord #0 ; Space for Result : Number of bytes unpacked
PushLong UP_Packed ; Pointer to buffer containing the packed data
PushWord UP_PackedSize ; Size of the Packed Data
PushLong #UP_UnPacked ; Pointer to Pointer to unpacked buffer
PushLong #UP_UnPackedSize ; Pointer to a Word containing size of unpacked data
_UnPackBytes
pla ; Number of byte unpacked
pla ; Number of byte unpacked
rts
UP_Packed hex 00000000 ; Address of Packed Data
UP_PackedSize hex 0000 ; Size of Packed Data
UP_UnPacked hex 00000000 ; Address of Unpacked Data Buffer (modified)
UP_UnPackedSize hex 0000 ; Size of Unpacked Data Buffer (modified)
UP_Packed hex 00000000 ; Address of Packed Data
UP_PackedSize hex 0000 ; Size of Packed Data
UP_UnPacked hex 00000000 ; Address of Unpacked Data Buffer (modified)
UP_UnPackedSize hex 0000 ; Size of Unpacked Data Buffer (modified)
; Basic I/O function to load files
LoadFile
stx openRec+4 ; X=File, A=Bank (high word) assumed zero for low
stx openRec+4 ; X=File, A=Bank (high word) assumed zero for low
stz readRec+4
sta readRec+6
jsr ClearBankLoad
@ -394,7 +453,7 @@ LoadFile
:closeFile _CloseGS closeRec
clc
lda eofRec+4 ; File Size
lda eofRec+4 ; File Size
rts
:openReadErr jsr :closeFile
@ -427,22 +486,22 @@ BG1AltDataFile strl '1/bg1b.bin'
ImageName strl '1/test.pic'
FGName strl '1/fg1.bin'
openRec dw 2 ; pCount
ds 2 ; refNum
adrl FGName ; pathname
openRec dw 2 ; pCount
ds 2 ; refNum
adrl FGName ; pathname
eofRec dw 2 ; pCount
ds 2 ; refNum
ds 4 ; eof
eofRec dw 2 ; pCount
ds 2 ; refNum
ds 4 ; eof
readRec dw 4 ; pCount
ds 2 ; refNum
ds 4 ; dataBuffer
ds 4 ; requestCount
ds 4 ; transferCount
readRec dw 4 ; pCount
ds 2 ; refNum
ds 4 ; dataBuffer
ds 4 ; requestCount
ds 4 ; transferCount
closeRec dw 1 ; pCount
ds 2 ; refNum
closeRec dw 1 ; pCount
ds 2 ; refNum
qtRec adrl $0000
da $00
@ -454,6 +513,66 @@ qtRec adrl $0000
PUT gen/App.TileMapBG0.s
PUT gen/App.TileMapBG1.s
PUT gen/App.TileSetAnim.s

View File

@ -2,4 +2,36 @@
<tileset version="1.5" tiledversion="1.7.2" name="App.TileSet" tilewidth="8" tileheight="8" tilecount="1000" columns="40">
<transformations hflip="1" vflip="1" rotate="0" preferuntransformed="0"/>
<image source="../tilesets/smb-16.png" trans="6b8cff" width="320" height="200"/>
<tile id="168">
<animation>
<frame tileid="168" duration="256"/>
<frame tileid="170" duration="256"/>
<frame tileid="172" duration="256"/>
<frame tileid="174" duration="256"/>
</animation>
</tile>
<tile id="169">
<animation>
<frame tileid="169" duration="256"/>
<frame tileid="171" duration="256"/>
<frame tileid="173" duration="256"/>
<frame tileid="175" duration="256"/>
</animation>
</tile>
<tile id="208">
<animation>
<frame tileid="208" duration="256"/>
<frame tileid="210" duration="256"/>
<frame tileid="212" duration="256"/>
<frame tileid="214" duration="256"/>
</animation>
</tile>
<tile id="209">
<animation>
<frame tileid="209" duration="256"/>
<frame tileid="211" duration="256"/>
<frame tileid="213" duration="256"/>
<frame tileid="215" duration="256"/>
</animation>
</tile>
</tileset>

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<export target="world_1-1.json" format="json"/>
</editorsettings>
<tileset firstgid="1" source="Overworld.tsx"/>
<layer id="3" name="App.TileMapBG1" width="256" height="30" parallaxx="0.5" parallaxy="0.5">
<layer id="3" name="App.TileMapBG1" width="256" height="30" locked="1" parallaxx="0.5" parallaxy="0.5">
<data encoding="csv">
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
@ -38,7 +38,7 @@
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41
</data>
</layer>
<layer id="1" name="App.TileMapBG0" width="256" height="30" visible="0" locked="1">
<layer id="1" name="App.TileMapBG0" width="256" height="30">
<data encoding="csv">
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
@ -64,8 +64,8 @@
41,41,41,41,57,58,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,15,16,17,18,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
41,41,41,56,21,62,59,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,11,12,13,14,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
41,41,56,21,21,21,21,59,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,57,2147483705,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,15,16,17,18,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
41,56,21,62,21,21,62,21,59,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,42,43,42,43,42,43,41,41,41,56,21,62,2147483704,41,41,41,41,41,41,41,41,41,41,41,42,43,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,42,43,42,43,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
56,21,21,21,21,21,21,21,21,59,41,41,41,41,41,41,41,41,41,41,41,41,41,44,45,45,45,45,45,45,46,41,56,21,21,21,21,2147483704,41,41,41,41,41,41,41,41,41,44,45,45,46,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,44,45,45,45,45,46,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
41,56,21,62,21,21,62,21,59,41,41,41,169,170,169,170,169,170,169,170,169,170,41,41,42,43,42,43,42,43,41,41,41,56,21,62,2147483704,41,41,41,41,41,41,41,41,41,41,41,42,43,41,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,41,42,43,42,43,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
56,21,21,21,21,21,21,21,21,59,41,41,209,210,209,210,209,210,209,210,209,210,41,44,45,45,45,45,45,45,46,41,56,21,21,21,21,2147483704,41,41,41,41,41,41,41,41,41,44,45,45,46,41,41,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,19,20,21,22,41,41,41,44,45,45,45,45,46,41,41,41,19,20,21,22,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,
3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,3,4,
1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -112,11 +112,11 @@ App_TileMapBG0
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1038,$0015,$003e,$0015,$0015,$003e,$0015,$103b,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$102a,$102b,$102a,$102b,$102a,$102b,$1029,$1029,$1029,$1038,$0015,$003e,$1238,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$102a,$102b,$1029,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029
dw $1029,$1038,$0015,$003e,$0015,$0015,$003e,$0015,$103b,$1029,$1029,$1029,$0800,$0801,$0800,$0801,$0800,$0801,$0800,$0801,$0800,$0801,$1029,$1029,$102a,$102b,$102a,$102b,$102a,$102b,$1029,$1029,$1029,$1038,$0015,$003e,$1238,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$102a,$102b,$1029,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029,$102a,$102b,$102a,$102b,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1038,$0015,$0015,$0015,$0015,$0015,$0015,$0015,$0015,$103b,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$102c,$002d,$002d,$002d,$002d,$002d,$002d,$102e,$1029,$1038,$0015,$0015,$0015,$0015,$1238,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$102c,$002d,$002d,$102e,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029
dw $1038,$0015,$0015,$0015,$0015,$0015,$0015,$0015,$0015,$103b,$1029,$1029,$0802,$0803,$0802,$0803,$0802,$0803,$0802,$0803,$0802,$0803,$1029,$102c,$002d,$002d,$002d,$002d,$002d,$002d,$102e,$1029,$1038,$0015,$0015,$0015,$0015,$1238,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$102c,$002d,$002d,$102e,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$102c,$002d,$002d,$002d,$002d,$102e,$1029,$1029,$1029,$1013,$0014,$0015,$1016,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029
dw $1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029,$1029

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
TileAnimInit ENT
ldx #168
ldy #0
jsl CopyTileToDyn
ldx #169
ldy #1
jsl CopyTileToDyn
ldx #208
ldy #2
jsl CopyTileToDyn
ldx #209
ldy #3
jsl CopyTileToDyn
lda #TileAnim_168
ldx #^TileAnim_168
ldy #15
jsl StartScript
lda #TileAnim_169
ldx #^TileAnim_169
ldy #15
jsl StartScript
lda #TileAnim_208
ldx #^TileAnim_208
ldy #15
jsl StartScript
lda #TileAnim_209
ldx #^TileAnim_209
ldy #15
jsl StartScript
rts
TileAnim_168
dw $8006,168,0,0
dw $8006,170,0,0
dw $8006,172,0,0
dw $cd06,174,0,0
TileAnim_169
dw $8006,169,1,0
dw $8006,171,1,0
dw $8006,173,1,0
dw $cd06,175,1,0
TileAnim_208
dw $8006,208,2,0
dw $8006,210,2,0
dw $8006,212,2,0
dw $cd06,214,2,0
TileAnim_209
dw $8006,209,3,0
dw $8006,211,3,0
dw $8006,213,3,0
dw $cd06,215,3,0

View File

@ -24,7 +24,7 @@
"build:assets-woz-fatbits": "node %npm_package_config_png2iigs% ./assets/woz-pixelated.png ./emu/bg1a.bin --start-index 6 && node %npm_package_config_png2iigs% ./assets/woz-shifted.png ./emu/bg1b.bin --start-index 6 && node %npm_package_config_png2iigs% ./assets/donut-plains-1-6-color.png ./emu/fg1.bin",
"build:assets-color-cycle": "node %npm_package_config_png2iigs% ./assets/rotopattern.png ./emu/bg1a.bin --start-index 6 && node %npm_package_config_png2iigs% ./assets/woz-shifted.png ./emu/bg1b.bin --start-index 6 && node %npm_package_config_png2iigs% ./assets/donut-plains-1-6-color.png ./emu/fg1.bin",
"build:map": "node %npm_package_config_tiled2iigs% ./assets/tiled/world_1-1.json --output-dir ./gen",
"build:tiles": "node %npm_package_config_png2iigs% ./assets/tilesets/smb-16.png --as-tile-data --transparent-color-index 3 > ./gen/App.TileSet.s"
"build:tiles": "node %npm_package_config_png2iigs% ./assets/tilesets/smb-16.png --max-tiles 224 --as-tile-data --transparent-color-index 3 > ./gen/App.TileSet.s"
},
"repository": {
"type": "git",

View File

@ -119,6 +119,15 @@ min mac
lda ]1
mout <<<
; Macro to define script steps
ScriptStep MAC
IF #=]5
dw {]1+{{]5&#$000F}<<8}},]2,]3,]4
ELSE
dw ]1,]2,]3,]4
FIN
<<<
; Macros to use in the Masked Tile renderer
;
; ]1 : tiledata offset
@ -174,3 +183,14 @@ transparent
sta: ]3+1,y
next
eom

View File

@ -39,28 +39,12 @@ AnimatePath
; at a time . The slope of the lines are (X1 - X0) / Duration and (Y1 - Y0) / Duration.
;
; The tricky bit is that we *always* single-step in the "Y" direction (duration), so we
; actaully need to use two differenct algorithms.
; actually need to use two differenct algorithms.
;
; If |X1 - X0| <= Duration, use a standard line-drawing approach (Bresenham's, DDA, etc.)
; If |X1 - X0| <= Duration, use a standard Bresenham's
; If |X1 - X0| > Duration, use the Run-Length Slice algorithm (https://www.phatcode.net/res/224/files/html/ch36/36-02.html)
lda AnimX1
lda AnimY
:stepx lda
cmp AnimDuration ; Handle the two cases

View File

@ -109,3 +109,13 @@ DIRTY_BIT_BG1_X equ $0004
DIRTY_BIT_BG1_Y equ $0008
DIRTY_BIT_BG0_REFRESH equ $0010
DIRTY_BIT_BG1_REFRESH equ $0020
; Script definition
YIELD equ $8000
JUMP equ $4000
SET_PALETTE_ENTRY equ $0002
SWAP_PALETTE_ENTRY equ $0004
SET_DYN_TILE equ $0006
CALLBACK equ $0010

View File

@ -7,12 +7,18 @@ EngineShutDown EXT
SetScreenMode EXT
ReadControl EXT
; Low-Level Functions
SetPalette EXT
GetVBLTicks EXT
; Tilemap functions
SetBG0XPos EXT
SetBG0YPos EXT
SetBG1XPos EXT
SetBG1YPos EXT
CopyBG0Tile EXT
CopyBG1Tile EXT
CopyTileToDyn EXT
Render EXT
; Rotation
@ -40,3 +46,6 @@ ScreenAddr EXT
OneSecondCounter EXT
BlitBuff EXT

View File

@ -1,123 +1,153 @@
; Graphic screen initialization
InitGraphics
jsr ShadowOn
jsr GrafOn
lda #0
jsr ClearToColor
lda #0
jsr SetSCBs
ldx #DefaultPalette
lda #0
jsr SetPalette
jsr _ShadowOn
jsr _GrafOn
lda #0
jsr _ClearToColor
lda #0
jsr _SetSCBs
ldx #DefaultPalette
lda #0
jsr _SetPalette
jsr _InitBG0 ; Initialize the background layers
jsr _InitBG1
jsr _InitBG0 ; Initialize the background layers
jsr _InitBG1
lda #0
jsr _ClearBG1Buffer
lda #0
jsr _ClearBG1Buffer
rts
rts
DefaultPalette dw $0000,$007F,$0090,$0FF0
dw $000F,$0080,$0f70,$0FFF
dw $0fa9,$0ff0,$00e0,$04DF
dw $0d00,$078f,$0ccc,$0FFF
DefaultPalette dw $0000,$007F,$0090,$0FF0
dw $000F,$0080,$0f70,$0FFF
dw $0fa9,$0ff0,$00e0,$04DF
dw $0d00,$078f,$0ccc,$0FFF
; Return the current border color ($0 - $F) in the accumulator
GetBorderColor lda #0000
sep #$20
ldal BORDER_REG
and #$0F
rep #$20
rts
_GetBorderColor lda #0000
sep #$20
ldal BORDER_REG
and #$0F
rep #$20
rts
; Set the border color to the accumulator value.
SetBorderColor sep #$20 ; ACC = $X_Y, REG = $W_Z
eorl BORDER_REG ; ACC = $(X^Y)_(Y^Z)
and #$0F ; ACC = $0_(Y^Z)
eorl BORDER_REG ; ACC = $W_(Y^Z^Z) = $W_Y
stal BORDER_REG
rep #$20
rts
SetBorderColor ENT
jsr _SetBorderColor
rtl
_SetBorderColor sep #$20 ; ACC = $X_Y, REG = $W_Z
eorl BORDER_REG ; ACC = $(X^Y)_(Y^Z)
and #$0F ; ACC = $0_(Y^Z)
eorl BORDER_REG ; ACC = $W_(Y^Z^Z) = $W_Y
stal BORDER_REG
rep #$20
rts
; Clear to SHR screen to a specific color
ClearToColor ldx #$7D00 ;start at top of pixel data! ($2000-9D00)
:clearloop dex
dex
stal SHR_SCREEN,x ;screen location
bne :clearloop ;loop until we've worked our way down to 0
rts
_ClearToColor
ldx #$7D00 ;start at top of pixel data! ($2000-9D00)
:clearloop dex
dex
stal SHR_SCREEN,x ;screen location
bne :clearloop ;loop until we've worked our way down to 0
rts
; Set a palette values
; A = palette number, X = palette address
SetPalette
and #$000F ; palette values are 0 - 15 and each palette is 32 bytes
asl
asl
asl
asl
asl
txy
tax
; A = high word of palette data pointer, X = low word of palette data pointer, Y = palette number
SetPalette ENT
phb ; save old data bank
pha ; push 16-bit value
plb ; pop 8-bit bank register
tya
jsr _SetPalette
plb ; pop the other half og the 16-bit push off
plb ; restore the original data bank
rtl
]idx equ 0
lup 16
lda: $0000+]idx,y
stal SHR_PALETTES+]idx,x
]idx equ ]idx+2
--^
rts
; A = palette number, X = palette address
_SetPalette
and #$000F ; palette values are 0 - 15 and each palette is 32 bytes
asl
asl
asl
asl
asl
txy
tax
]idx equ 0
lup 16
lda: $0000+]idx,y
stal SHR_PALETTES+]idx,x
]idx equ ]idx+2
--^
rts
; Initialize the SCB
SetSCBs ldx #$0100 ;set all $100 scbs to A
:scbloop dex
dex
stal SHR_SCB,x
bne :scbloop
rts
_SetSCBs
ldx #$0100 ;set all $100 scbs to A
:scbloop dex
dex
stal SHR_SCB,x
bne :scbloop
rts
; Turn SHR screen On/Off
GrafOn sep #$20
lda #$81
stal NEW_VIDEO_REG
rep #$20
rts
_GrafOn
sep #$20
lda #$81
stal NEW_VIDEO_REG
rep #$20
rts
GrafOff sep #$20
lda #$01
stal NEW_VIDEO_REG
rep #$20
rts
_GrafOff
sep #$20
lda #$01
stal NEW_VIDEO_REG
rep #$20
rts
; Enable/Disable Shadowing.
ShadowOn sep #$20
ldal SHADOW_REG
and #$F7
stal SHADOW_REG
rep #$20
rts
_ShadowOn
sep #$20
ldal SHADOW_REG
and #$F7
stal SHADOW_REG
rep #$20
rts
_ShadowOff
sep #$20
ldal SHADOW_REG
ora #$08
stal SHADOW_REG
rep #$20
rts
_GetVBL
sep #$20
ldal VBL_HORZ_REG
asl
ldal VBL_VERT_REG
rol ; put V5 into carry bit, if needed. See TN #39 for details.
rep #$20
and #$00FF
rts
_WaitForVBL
sep #$20
:wait1 ldal VBL_STATE_REG ; If we are already in VBL, then wait
bmi :wait1
:wait2 ldal VBL_STATE_REG
bpl :wait2 ; spin until transition into VBL
rep #$20
rts
ShadowOff sep #$20
ldal SHADOW_REG
ora #$08
stal SHADOW_REG
rep #$20
rts
GetVBL sep #$20
ldal VBL_HORZ_REG
asl
ldal VBL_VERT_REG
rol ; put V5 into carry bit, if needed. See TN #39 for details.
rep #$20
and #$00FF
rts
WaitForVBL sep #$20
:wait1 ldal VBL_STATE_REG ; If we are already in VBL, then wait
bmi :wait1
:wait2 ldal VBL_STATE_REG
bpl :wait2 ; spin until transition into VBL
rep #$20
rts

View File

@ -86,13 +86,13 @@ _Render
; The code fields are locked in now and reder to be rendered
jsr ShadowOff
jsr _ShadowOff
; ldx #0 ; Blit the full virtual buffer to the screen
; ldy #8
; jsr _BltRange
jsr ShadowOn
jsr _ShadowOn
; ldx #0 ; Expose the top 8 rows
; ldy #8
@ -124,3 +124,4 @@ _Render
stz DirtyBits
rts

View File

@ -9,7 +9,7 @@
;
; The COMMAND word has its bits defined as:
;
; bit 15 = 1 if the end of a sequece
; bit 15 = 1 if the end of a sequence
; bit 14 = 0 proceed to next action, 1 jump
; bit 13 = 0 (Reserved)
; bit 12 = 0 (Reserved)
@ -22,6 +22,7 @@
; -----------------------------------------------------
; $0002 SET_PALETTE_ENTRY ADDR COLOR ---- : Set the palette entry at ARG1 to the color in ARG2
; $0004 SWAP_PALETTE_ENTRY ADDR1 ADDR2 ---- : Swap the palette entries in ADDR1 <-> ADDR2
; $0006 SET_DYN_TILE TILE_ID DTILE_ID ---- : Copy data from TileData into Dynamic Tile Area
; $0010 CALLBACK LONG_ADDR PARAM : Call a user-defined function (JSL) with a parameter value in accumulator
; Start a new script
@ -37,16 +38,16 @@ StartScript ENT
phk
plb
phx ; Save the script array address
phx ; Save the script array address
pha
lda #_DoScriptSeq ; Try to create a timer for this script
lda #_DoScriptSeq ; Try to create a timer for this script
ldx #^_DoScriptSeq
clc
jsl 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
pla
sta Timers+8,x
pla
@ -56,117 +57,129 @@ StartScript ENT
rtl
:err
pla ; Pop the values and return with the carry flag set
pla ; Pop the values and return with the carry flag set
pla
plb
rtl
; 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-levellanguages.
_DoScriptSeq
phx ; save the timer index; will need to update user data at the end
phb ; save the current data bank
; sense, the stop bit acts like a "yield" in high-level languages.
sep #$20 ; push the bank byte of the command list pointer on the stack
ARG1 equ 2
ARG2 equ 4
ARG3 equ 6
_DoScriptSeq
phx ; save the timer index; will need to update user data at the end
phb ; save the current data bank
sep #$20 ; push the bank byte of the command list pointer on the stack
lda Timers+10,x
pha
rep #$20
lda Timers+8,x ; get the current address of the command sequence
lda Timers+8,x ; get the current address of the command sequence
tax
plb ; pop the bank
plb ; pop the bank
; Now we are ready to process commands until reaching one with the STOP bit set. Each command
; is 8 bytes, so we just have to do a very simple fetch/execute/increment loop. The only
; exception is handling the JUMP bit which requires moving the script pc stored in the
; x-register.
:loop phx ; Save the command address
_dss_loop phx ; Save the command address
txy ; Cache in the y-register
lda: 0,x ; Load the command word
pha ; Stash it
lda: 0,x ; Load the command word
pha ; Stash it
and #$001E ; Only have 16 built-in command. Use the _UserCallback
tax ; command for custom functionality
jsr (:commands,x)
and #$001E ; Only have 16 built-in commands. Use the _UserCallback
tax ; command for custom functionality
jmp (_dss_commands,x)
lda 1,s ; Reload the command word
_dss_commands dw _Null,_SetPalEntry,_SwapPalEntry,_SetDTile,_Null,_Null,_Null,_Null
dw _UserCallback,_Null,_Null,_Null,_Null,_Null,_Null,_Null
_dss_cmd_rtn
lda 1,s ; Reload the command word
; Move to the next instruction. If the JUMP bit is set, we move the address forward or
; backward N commands (8 bytes at a time). If the JUMP bit is not set, then just move
; to the next entry.
bit #$4000 ; 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
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
beq :retry ; Don't allow zeros; will cause infinite loop. Just advance by one.
:move_addr and #$0F00 ; 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
xba ; put it in the low byte
cmp #$0008 ; Sign-extend the 4-bit value
bcc *+5
ora #$FFF0
asl ; multiply by 8
asl ; multiply by 8
asl
asl
clc
adc 3,s ; add it to the saved command address
adc 3,s ; add it to the saved command address
sta 3,s
; Check to see if we stop on this instruction, or continue executing commands
pla ; Reload the command word
plx ; Pop off the update command address
pla ; Reload the command word
plx ; Pop off the update command address
bit #$8000 ; If the stop bit is set, we're done with this sequence
beq :loop ; Otherwise, keep going and fetch the next command word
bit #YIELD ; If the stop bit is set, we're done with this sequence
beq _dss_loop ; Otherwise, keep going and fetch the next command word
txa ; save the current command address
plb ; restore the data bank and the timer index
txa ; save the current command address
plb ; restore the data bank and the timer index
plx
sta Timers+8,x ; store the command address back into the timer user data space
sta Timers+8,x ; store the command address back into the timer user data space
rtl
:commands dw _Null,_SetPalEntry,_SwapPalEntry,_Null,_Null,_Null,_Null,_Null
dw _UserCallback,_Null,_Null,_Null,_Null,_Null,_Null,_Null
ARG1 equ 2
ARG2 equ 4
ARG3 equ 6
; Implementation of the built-in commands
_Null rts
_Null brl _dss_cmd_rtn
_SetPalEntry
txy
ldx: ARG1,y
lda: ARG2,y
stal SHR_PALETTES,x
rts
brl _dss_cmd_rtn
_SwapPalEntry txy
ldx: ARG1,y ; Load palette values
_SwapPalEntry
ldx: ARG1,y ; Load palette values
ldal SHR_PALETTES,x
pha
ldx: ARG2,y
ldal SHR_PALETTES,x
ldx: ARG1,y ; and swap
ldx: ARG1,y ; and swap
stal SHR_PALETTES,x
ldx: ARG2,y
pla
stal SHR_PALETTES,x
rts
brl _dss_cmd_rtn
_UserCallback lda: ARG1,x
_SetDTile
ldx: ARG1,y
lda: ARG2,y
tay
jsl CopyTileToDyn
brl _dss_cmd_rtn
_UserCallback
lda: ARG1,y
sta :dispatch+1
lda: ARG1+1,x
lda: ARG1+1,y
sta :dispatch+2
lda: ARG3,x
lda: ARG3,y
:dispatch jsl $000000
rts
brl _dss_cmd_rtn

View File

@ -316,7 +316,7 @@ _UpdateBG0TileMap
; Handle fringe tiles -- if the fringe bit is set, then we need to get the fringe tile index
; and merge the tiles before rendering
bit #$TILE_FRINGE_BIT
bit #TILE_FRINGE_BIT
beq :no_fringe
jsr _GetTileAddr
tax
@ -675,3 +675,4 @@ _DrawRectBG1
pla
rts

View File

@ -29,6 +29,9 @@ TIMER_REC_SIZE equ 16
lastTick ds 2
Timers ds TIMER_REC_SIZE*MAX_TIMERS
GetVBLTicks ENT
jsr _GetVBLTicks
rtl
_GetVBLTicks
PushLong #0
_GetTick
@ -150,6 +153,12 @@ DoTimers ENT
sec
sbc lastTick
stx lastTick
; We don't want times to fire excessively. If the timer has nt been evaluated for over
; one second, then just skip processing and wait for the next call.
cmp #60
bcs :exit
jsr _DoTimers
:exit plb
@ -196,9 +205,9 @@ _DoTimers
:skip txa
clc
adc #8
adc #TIMER_REC_SIZE
tax
cpx #8*MAX_TIMERS
cpx #{TIMER_REC_SIZE*MAX_TIMERS}
bcc :loop
pla
@ -227,6 +236,24 @@ _DoTimers

View File

@ -118,7 +118,7 @@ SetScreenRect sty ScreenHeight ; Save the screen height
; Clear the SHR screen and then infill the defined field
FillScreen lda #0
jsr ClearToColor
jsr _ClearToColor
ldy ScreenY0
:yloop
@ -272,6 +272,48 @@ SetConst ; Need a blank line here,
sta: $0000,y
:bottom rts
; SetDPAddrs
;
; A = absolute address (largest)
; Y = offset
;
; Initializes a bank of direct page offsets
SetDPAddrs
lda #$0800
sta $F000,y
lda #$0700
sta $E000,y
lda #$0600
sta $D000,y
lda #$0500
sta $C000,y
lda #$0400
sta $B000,y
lda #$0300
sta $A000,y
lda #$0200
sta $9000,y
lda #$0100
sta: $8000,y
lda #$0800
sta $7000,y
lda #$0700
sta $6000,y
lda #$0600
sta $5000,y
lda #$0500
sta $4000,y
lda #$0400
sta $3000,y
lda #$0300
sta $2000,y
lda #$0200
sta $1000,y
lda #$0100
sta: $0000,y
rts
; SetAbsAddrs
;
; A = absolute address (largest)
@ -361,11 +403,17 @@ BuildBank
plb
plb
lda #$F000+{TWO_LYR_ENTRY} ; Set the address from each line to the next
; Change the patched value to one of DP_ENTRY, TWO_LYR_ENTRY or ONE_LYR_ENTRY based on the capabilities
; that the engine needs.
lda #$F000+{DP_ENTRY} ; Set the address from each line to the next
ldy #CODE_EXIT+1
ldx #15*2
jsr SetAbsAddrs
ldy #DP_ADDR
jsr SetDPAddrs
ldy #$F000+CODE_EXIT ; Patch the last line with a JML to go to the next bank
lda #{$005C+{TWO_LYR_ENTRY}*256}
sta [:target],y
@ -480,7 +528,7 @@ odd_entry jmp $0100 ; unconditionally jump in
r_is_jmp sep #$41 ; Set the C and V flags which tells a snippet to push only the low byte
long_2 ldal entry_jmp+1-base
long_3 stal *+5-base
jmp $0000 ; Jumps into the exception code, which return to r_jmp_rtn
jmp $0000 ; Jumps into the exception code, which returns to r_jmp_rtn
; The next labels are special, in that they are entry points into special subroutines. They are special
; because they are within the first 256 bytes of each code field, which allows them to be selectable
@ -530,7 +578,7 @@ odd_exit ldal l_is_jmp+1-base
sep #$20
long_6 ldal l_is_jmp+3-base ; get the high byte of the PEA operand
; Fall-through when we have to push a byte on the left edge. Must be 8-bit on entry. Optimize
; Fall-through when we have to push a byte on the left edge. Must be 8-bit on entry. Optimized
; for the PEA $0000 case -- only 19 cycles to handle the edge, so pretty good
:left_byte
pha
@ -580,7 +628,7 @@ epilogue_1 tsc
; a. Overflow set -> Low 8-bit write and return to the next code field operand
; b. Overflow clear -> High 8-bit write and exit the line
; c. Always clear the Carry flags. It's actually OK to leave the overflow bit in
; its passed state, because having the carry bit clear prevent evaluation of
; its passed state, because having the carry bit clear prevents evaluation of
; the V bit.
;
; Snippet Samples:
@ -637,3 +685,11 @@ snippets lup 82
]index equ ]index+1
--^
top

View File

@ -48,7 +48,7 @@ TILE_CTRL_MASK equ $1E00 ; Deliberatel
; Low-level function to take a tile descriptor and return the address in the tiledata
; bank. This is not too useful in the fast-path because the fast-path does more
; incremental calculations, but it is handy for other utilitiy function
; incremental calculations, but it is handy for other utility functions
;
; A = tile descriptor
;
@ -58,7 +58,7 @@ _GetTileAddr
bit #2*TILE_HFLIP_BIT ; Check if the horizontal flip bit is set
beq :no_flip
inc ; Set the LSB
:no_flip and #$02FF ; Mask out non-id bits
:no_flip and #TILE_ID_MASK ; Mask out non-id bits
asl ; x4
asl ; x8
asl ; x16
@ -529,7 +529,24 @@ DynamicTile
rep #$20
rts
; Helper function to copy tile data to the appropriate location in Bank 0
; Helper functions to copy tile data to the appropriate location in Bank 0
; X = tile ID
; Y = dynamic tile ID
CopyTileToDyn ENT
txa
jsr _GetTileAddr
tax
tya
and #$001F ; Maximum of 32 dynamic tiles
asl
asl ; 4 bytes per page
adc BlitterDP ; Add to the bank 00 base address
adc #$0100 ; Go to the next page
tay
jsr CopyTileDToDyn ; Copy the tile data
rtl
; X = address of tile
; Y = tile address in bank 0
CopyTileDToDyn
@ -681,7 +698,8 @@ dynamic
pla
asl
asl
xba ; Undo the x128 we just need x2
asl
xba ; Undo the x128 we just need x4
plx
brl DynamicTile
@ -824,3 +842,21 @@ _CopyBG1Tile
plx ; pop the x-register
plb ; restore the data bank and return
rts

View File

@ -133,6 +133,7 @@ async function main(argv) {
startIndex = getArg(argv, '--start-index', x => parseInt(x, 10), 0);
asTileData = getArg(argv, '--as-tile-data', null, 0);
maxTiles = getArg(argv, '--max-tiles', x => parseInt(x, 10), 64);
transparentColor = getArg(argv, '--transparent-color-index', x => parseInt(x, 10), -1);
transparentIndex = transparentColor;
@ -175,7 +176,7 @@ async function main(argv) {
if (buff && argv[1]) {
if (asTileData) {
writeToTileDataSource(buff, png.width / 2);
writeToTileDataSource(buff, png.width / 2, maxTiles);
}
else {
console.log(`; Writing to output file ${argv[1]}`);
@ -355,14 +356,12 @@ function buildMerlinCodeForTiles(tiles, label='tiledata') {
return sb.toString();
}
function writeToTileDataSource(buff, width) {
function writeToTileDataSource(buff, width, MAX_TILES = 64) {
console.log('tiledata ENT');
console.log();
console.log('; Reserved space (tile 0 is special...');
console.log(' ds 128');
const MAX_TILES = 64;
let count = 0;
for (let y = 0; ; y += 8) {
for (let x = 0; x < width; x += 4, count += 1) {

View File

@ -102,7 +102,7 @@ function writeTileAnimations(filename, animations) {
// Create code to copy it into the dynamic tile index location
init.appendLine(' ldx #' + firstTileId);
init.appendLine(' ldy #' + animation.dynTileId);
init.appendLine(' jsr CopyTileToDyn');
init.appendLine(' jsl CopyTileToDyn');
}
// Next, create the scripts to change the tile data based on the configured ticks delays.
@ -122,13 +122,30 @@ function writeTileAnimations(filename, animations) {
init.appendLine(` ldy #${numTicks}`);
init.appendLine(` jsl StartScript`);
scripts.appendLine(label);
for (let i = 0; i < frames.length ; i += 1) {
const last = (i === (frames.length - 1));
const command = 'YIELD+SET_DYN_TILE' + (last ? '+JUMP' : '');
const jump = last ? `,-${frames.length - 1}` : '';
// bit 15 = 1 if the end of a sequence
// bit 14 = 0 proceed to next action, 1 jump
// bit 13 = 0 (Reserved)
// bit 12 = 0 (Reserved)
// bit 11 - 8 = signed jump displacement F = -1, E = -2, D = -3, C = -4, B = -5, A = -6, 9 = -7, 8 = -8, 7 = 7, 6 = 6, ....
// bit 8 - 0 = command number
const YIELD = 0x8000;
const JUMP = 0x4000;
const SET_DYN_TILE = 0x0006; // Command number
scripts.appendLine(` dw ${command},${frames[i].tileId},${animation.dynTileId}${jump}`);
scripts.appendLine(label);
const lastValidIndex = frames.length - 1;
for (let i = 0; i < frames.length ; i += 1) {
const isLast = (i === lastValidIndex);
let command = YIELD | SET_DYN_TILE;
if (isLast) {
command |= JUMP;
const offset = ((0x0010 - lastValidIndex) & 0x000F) * 256;
command |= offset;
}
command = '$' + toHex(command, 4);
// scripts.appendLine(` ScriptStep #${command};#${frames[i].tileId};#${animation.dynTileId};#0`);
scripts.appendLine(` dw ${command},${frames[i].tileId},${animation.dynTileId},0`);
}
}
@ -242,11 +259,11 @@ async function main(argv) {
console.log(`Writing tiles to ${outputFilename}`);
writeTiles(outputFilename, tiles);
console.log(`Writing complete`);
// Look for tiles with animation sequences. If found, this information need to be propagated
// to the tilemap export to mark those tile IDs as Dynamic Tiles.
//
// Exporting the "animations" actually created two code stubs; one to copy the first
// Exporting the "animations" actually creates two code stubs; one to copy the first
// tile of the animation into the dynamic tile space during initialization and a second
// that created the timer callbacks that replace the tile data based on the time animation
// rate. We only have a VBL timer, so the animation time is rounded to the nearest
@ -257,7 +274,12 @@ async function main(argv) {
writeTileAnimations(animationFilename, animations);
console.log(`Writing complete`);
// Modify the entries in the tileset that are animated
for (const animation of animations) {
tiles[animation.tileId].animation = animation;
}
}
bg0TileSet = tiles;
}
@ -351,6 +373,7 @@ function emitLayerData(sb, layer, tileset) {
*/
function convertTileID(tileId, tileset) {
const GTE_MASK_BIT = 0x1000;
const GTE_DYN_BIT = 0x0800;
const GTE_VFLIP_BIT = 0x0400;
const GTE_HFLIP_BIT = 0x0200;
const TILED_VFLIP_BIT = 0x40000000;
@ -375,5 +398,16 @@ function convertTileID(tileId, tileset) {
// because a special zero tile is inserted, but we have to manually adjust here
const mask_bit = !tileset[tileIndex - 1].isSolid;
return (tileId & 0x1FFFFFFF) + (mask_bit ? GTE_MASK_BIT : 0) + (hflip ? GTE_HFLIP_BIT : 0) + (vflip ? GTE_VFLIP_BIT : 0);
// Build up a partial set of control bits
let control_bits = (mask_bit ? GTE_MASK_BIT : 0) + (hflip ? GTE_HFLIP_BIT : 0) + (vflip ? GTE_VFLIP_BIT : 0);
// Check if this is an animated tile. If so, substitute the index of the animation slot for
// the tile ID
if (tileset[tileIndex - 1].animation) {
const animation = tileset[tileIndex - 1].animation;
tileId = animation.dynTileId;
control_bits = GTE_DYN_BIT;
}
return (tileId & 0x1FFFFFFF) + control_bits;
}