2021-10-21 13:50:07 +00:00
|
|
|
; _TBDynamicTile
|
|
|
|
;
|
|
|
|
; These subroutines fill in the code field with the instructions to render data from the dynamic
|
|
|
|
; code buffer. This is a bit different, because no tile data is manipulated. It is the
|
|
|
|
; responsibiliy of the user of the API to use the CopyTileToDyn subroutine to get data
|
|
|
|
; into the correct location.
|
|
|
|
;
|
|
|
|
; This tile type does not explicitly support horizontal or vertical flipping. An appropriate tile
|
|
|
|
; descriptor should be passed into CopyTileToDyn to put the horizontally or vertically flipped source
|
|
|
|
; data into the dynamic tile buffer
|
|
|
|
_TBDynamicTile_00
|
|
|
|
jsr _TBDynamicData
|
|
|
|
jmp _TBFillLdaDpOpcode
|
|
|
|
|
2022-06-20 20:55:09 +00:00
|
|
|
_TBDynamic
|
|
|
|
ldal TileStore+TS_TILE_ID,x
|
|
|
|
and #$007F
|
|
|
|
ora #$4800
|
|
|
|
|
|
|
|
]line equ 0 ; render the first column
|
|
|
|
lup 8
|
|
|
|
sta: $0004+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
|
|
|
--^
|
|
|
|
|
|
|
|
inc ; advance to the next word
|
|
|
|
inc
|
|
|
|
|
|
|
|
]line equ 0 ; render the second column
|
|
|
|
lup 8
|
|
|
|
sta: $0001+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
|
|
|
--^
|
|
|
|
|
|
|
|
sep #$20
|
|
|
|
lda #$B5
|
|
|
|
sta: $0000,y
|
|
|
|
sta: $0003,y
|
|
|
|
sta $1000,y
|
|
|
|
sta $1003,y
|
|
|
|
sta $2000,y
|
|
|
|
sta $2003,y
|
|
|
|
sta $3000,y
|
|
|
|
sta $3003,y
|
|
|
|
sta $4000,y
|
|
|
|
sta $4003,y
|
|
|
|
sta $5000,y
|
|
|
|
sta $5003,y
|
|
|
|
sta $6000,y
|
|
|
|
sta $6003,y
|
|
|
|
sta $7000,y
|
|
|
|
sta $7003,y
|
|
|
|
rep #$20
|
|
|
|
|
|
|
|
plb
|
|
|
|
rts
|
2021-11-12 21:11:29 +00:00
|
|
|
; Primitive to render a dynamic tile
|
2021-10-21 13:50:07 +00:00
|
|
|
;
|
|
|
|
; LDA 00,x / PHA where the operand is fixed when the tile is rendered
|
|
|
|
; $B5 $00 $48
|
|
|
|
_TBDynamicData
|
2021-11-19 19:00:59 +00:00
|
|
|
lda _TILE_ID ; Get the original tile descriptor
|
2021-10-21 13:50:07 +00:00
|
|
|
and #$007F ; clamp to < (32 * 4)
|
|
|
|
ora #$4800 ; insert the PHA instruction
|
|
|
|
|
|
|
|
]line equ 0 ; render the first column
|
|
|
|
lup 8
|
|
|
|
sta: $0004+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
|
|
|
--^
|
|
|
|
|
|
|
|
inc ; advance to the next word
|
|
|
|
inc
|
|
|
|
|
|
|
|
]line equ 0 ; render the second column
|
|
|
|
lup 8
|
|
|
|
sta: $0001+{]line*$1000},y
|
|
|
|
]line equ ]line+1
|
2021-11-12 21:11:29 +00:00
|
|
|
--^
|
2021-10-21 13:50:07 +00:00
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
; A simple helper function that fill in all of the opcodes of a tile with the LDA dp,x opcode.
|
|
|
|
_TBFillLdaDpOpcode
|
|
|
|
sep #$20
|
|
|
|
lda #$B5
|
|
|
|
sta: $0000,y
|
|
|
|
sta: $0003,y
|
|
|
|
sta $1000,y
|
|
|
|
sta $1003,y
|
|
|
|
sta $2000,y
|
|
|
|
sta $2003,y
|
|
|
|
sta $3000,y
|
|
|
|
sta $3003,y
|
|
|
|
sta $4000,y
|
|
|
|
sta $4003,y
|
|
|
|
sta $5000,y
|
|
|
|
sta $5003,y
|
|
|
|
sta $6000,y
|
|
|
|
sta $6003,y
|
|
|
|
sta $7000,y
|
|
|
|
sta $7003,y
|
|
|
|
rep #$20
|
|
|
|
rts
|