2020-08-23 05:25:39 +00:00
|
|
|
; Template and equates for GTE blitter
|
|
|
|
|
2021-07-16 13:38:14 +00:00
|
|
|
mx %00
|
|
|
|
|
2021-10-07 23:33:06 +00:00
|
|
|
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
|
|
|
|
STK_ADDR equ entry_3-base+1 ; offset to patch in the stack (SHR) right edge address
|
2022-08-14 12:45:58 +00:00
|
|
|
; BNK_ADDR equ entry_0-base+1 ; offset to patch in the address of a Bank 0 memory location to load the bank register
|
2021-07-16 13:38:14 +00:00
|
|
|
|
|
|
|
DP_ENTRY equ entry_1-base
|
|
|
|
TWO_LYR_ENTRY equ entry_2-base
|
|
|
|
ONE_LYR_ENTRY equ entry_3-base
|
2022-08-14 12:45:58 +00:00
|
|
|
; BANK_ENTRY equ entry_0-base
|
2021-07-16 13:38:14 +00:00
|
|
|
|
|
|
|
CODE_ENTRY_OPCODE equ entry_jmp-base
|
2021-10-07 23:33:06 +00:00
|
|
|
CODE_ENTRY equ entry_jmp-base+1 ; low byte of the page-aligned jump address
|
2021-07-16 13:38:14 +00:00
|
|
|
ODD_ENTRY equ odd_entry-base+1
|
|
|
|
CODE_TOP equ loop-base
|
|
|
|
CODE_LEN equ top-base
|
|
|
|
CODE_EXIT equ even_exit-base
|
2023-03-07 23:32:46 +00:00
|
|
|
OPCODE_SAVE equ odd_low_save-base ; spot to save the code field opcode when patching exit BRA
|
|
|
|
OPCODE_HIGH_SAVE equ odd_high_save-base ; save the second and third byte
|
2021-10-07 23:33:06 +00:00
|
|
|
FULL_RETURN equ full_return-base ; offset that returns from the blitter
|
|
|
|
ENABLE_INT equ enable_int-base ; offset that re-enable interrupts and continues
|
2021-07-16 13:38:14 +00:00
|
|
|
LINES_PER_BANK equ 16
|
2021-07-17 04:09:08 +00:00
|
|
|
SNIPPET_BASE equ snippets-base
|
2020-08-23 05:25:39 +00:00
|
|
|
|
2023-03-03 05:24:03 +00:00
|
|
|
; offsets from each snippet base address for the different entry points
|
|
|
|
|
|
|
|
SNIPPET_ENTRY_1 equ 0 ; two layer + dynamic tile + sprite
|
|
|
|
SNIPPET_ENTRY_2 equ 4 ; (two layer | dynamic tile) + sprite
|
2023-03-04 03:44:39 +00:00
|
|
|
SNIPPET_ENTRY_3 equ 18 ; sprite under dynamic tile
|
|
|
|
SNIPPET_ENTRY_4 equ 19 ; two layer + dynamic tile (no sprite)
|
2023-03-03 05:24:03 +00:00
|
|
|
|
2020-08-23 05:25:39 +00:00
|
|
|
; Locations that need the page offset added
|
2021-07-16 13:38:14 +00:00
|
|
|
PagePatches da {long_0-base+2}
|
|
|
|
da {long_1-base+2}
|
|
|
|
da {long_2-base+2}
|
|
|
|
da {long_3-base+2}
|
2023-03-07 23:32:46 +00:00
|
|
|
; da {long_4-base+2}
|
2021-07-16 13:38:14 +00:00
|
|
|
da {long_5-base+2}
|
|
|
|
da {long_6-base+2}
|
|
|
|
da {odd_entry-base+2}
|
|
|
|
da {loop_exit_1-base+2}
|
|
|
|
da {loop_exit_2-base+2}
|
|
|
|
da {loop_back-base+2}
|
|
|
|
da {loop_exit_3-base+2}
|
|
|
|
da {even_exit-base+2}
|
2021-11-19 16:24:09 +00:00
|
|
|
da {jmp_rtn_1-base+2}
|
2021-11-22 22:13:29 +00:00
|
|
|
; da {jmp_rtn_2-base+2}
|
2021-11-19 16:24:09 +00:00
|
|
|
|
|
|
|
]index equ 0
|
2023-03-03 05:24:03 +00:00
|
|
|
lup 82 ; Patch anything that needs updating within the snippets
|
|
|
|
da {snippets-base+{]index*32}+17}
|
2023-03-04 03:44:39 +00:00
|
|
|
da {snippets-base+{]index*32}+29}
|
2021-11-19 16:24:09 +00:00
|
|
|
]index equ ]index+1
|
|
|
|
--^
|
2021-07-16 13:38:14 +00:00
|
|
|
PagePatchNum equ *-PagePatches
|
|
|
|
|
2021-11-19 16:24:09 +00:00
|
|
|
; Location that need a bank byte set for long addressing modes
|
2021-07-16 13:38:14 +00:00
|
|
|
BankPatches da {long_0-base+3}
|
|
|
|
da {long_1-base+3}
|
|
|
|
da {long_2-base+3}
|
|
|
|
da {long_3-base+3}
|
2023-03-07 23:32:46 +00:00
|
|
|
; da {long_4-base+3}
|
2021-07-16 13:38:14 +00:00
|
|
|
da {long_5-base+3}
|
|
|
|
da {long_6-base+3}
|
|
|
|
BankPatchNum equ *-BankPatches
|
2020-11-30 12:39:14 +00:00
|
|
|
|
2021-07-08 12:46:35 +00:00
|
|
|
; Start of the template code. This code is replicated 16 times per bank and spans
|
|
|
|
; 13 banks for a total of 208 lines, which is what is required to render 26 tiles
|
|
|
|
; to cover the full screen vertical scrolling.
|
|
|
|
;
|
2021-11-19 16:24:09 +00:00
|
|
|
; The 'base' location is always assumed to be on a 4kb ($1000) boundary. We make sure that
|
2022-02-02 16:21:31 +00:00
|
|
|
; the code is assembled on a page boundary to help with alignment
|
2021-11-19 16:24:09 +00:00
|
|
|
ds \,$00 ; pad to the next page boundary
|
2020-08-23 05:25:39 +00:00
|
|
|
base
|
2022-08-14 12:45:58 +00:00
|
|
|
;entry_0 lda #0000 ; Used to set per-scanline bank register
|
|
|
|
; tcs
|
|
|
|
; plb
|
2022-02-02 16:21:31 +00:00
|
|
|
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)
|
2021-10-07 23:33:06 +00:00
|
|
|
entry_3 lda #0000 ; Sets screen address (right edge)
|
2021-07-16 13:38:14 +00:00
|
|
|
tcs
|
2020-08-23 05:25:39 +00:00
|
|
|
|
|
|
|
long_0
|
2021-07-16 13:38:14 +00:00
|
|
|
entry_jmp jmp $0100
|
2021-10-07 23:33:06 +00:00
|
|
|
dfb $00 ; if the screen is odd-aligned, then the opcode is set to
|
|
|
|
; $AF to convert to a LDA long instruction. This puts the
|
|
|
|
; first two bytes of the instruction field in the accumulator
|
|
|
|
; and falls through to the next instruction.
|
2021-07-16 13:38:14 +00:00
|
|
|
|
2021-10-07 23:33:06 +00:00
|
|
|
; We structure the line so that the entry point only needs to
|
|
|
|
; update the low-byte of the address, the means it takes only
|
|
|
|
; an amortized 4-cycles per line to set the entry point break
|
2021-07-16 13:38:14 +00:00
|
|
|
|
2023-03-09 06:26:31 +00:00
|
|
|
bit #$000B ; Check the bottom nibble to quickly identify a PEA instruction
|
2022-02-02 20:30:48 +00:00
|
|
|
bne r_is_not_pea ; This costs 5 cycles in the fast-path
|
2021-07-16 13:38:14 +00:00
|
|
|
|
2022-02-02 20:30:48 +00:00
|
|
|
xba ; fast code for PEA
|
2021-10-07 23:33:06 +00:00
|
|
|
r_jmp_rtn sep #$20 ; shared return code path by all methods
|
2022-02-02 20:30:48 +00:00
|
|
|
two_byte_rtn pha
|
2021-11-22 22:13:29 +00:00
|
|
|
rep #$61 ; Clear Carry, Overflow and M bits #$20
|
2021-10-07 23:33:06 +00:00
|
|
|
odd_entry jmp $0100 ; unconditionally jump into the "next" instruction in the
|
|
|
|
; code field. This is OK, even if the entry point was the
|
|
|
|
; last instruction, because there is a JMP at the end of
|
|
|
|
; the code field, so the code will simply jump to that
|
|
|
|
; instruction directly.
|
|
|
|
;
|
|
|
|
; As with the original entry point, because all of the
|
|
|
|
; code field is page-aligned, only the low byte needs to
|
|
|
|
; be updated when the scroll position changes
|
|
|
|
|
2022-02-02 20:30:48 +00:00
|
|
|
r_is_not_pea bit #$0040 ; Check bit 6 to distinguish between JMP and all of the LDA variants
|
|
|
|
bne r_is_jmp
|
|
|
|
|
|
|
|
long_1 stal *+6-base ; Everything else is a two-byte LDA opcode + PHA
|
|
|
|
sep #$20 ; Lift 8-bit mode here to save a cycle in the LDA
|
|
|
|
dfb $00,$00
|
|
|
|
bra two_byte_rtn
|
|
|
|
|
2021-10-07 23:33:06 +00:00
|
|
|
r_is_jmp sep #$41 ; Set the C and V flags which tells a snippet to push only the low byte
|
2021-07-16 13:38:14 +00:00
|
|
|
long_2 ldal entry_jmp+1-base
|
|
|
|
long_3 stal *+5-base
|
2021-10-07 23:33:06 +00:00
|
|
|
jmp $0000 ; Jumps into the exception code, which returns to r_jmp_rtn
|
2021-07-08 12:46:35 +00:00
|
|
|
|
2021-07-08 13:17:38 +00:00
|
|
|
; 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
|
|
|
|
; by patching the low byte of the JMP instructions.
|
|
|
|
|
|
|
|
; Return to caller -- the even_exit JMP from the previous line will jump here when a render is complete
|
2021-10-07 23:33:06 +00:00
|
|
|
full_return jml blt_return ; Full exit
|
2020-08-23 05:25:39 +00:00
|
|
|
|
2021-11-22 22:13:29 +00:00
|
|
|
|
|
|
|
; The even/odd branch of this line's exception handler will return here. This is mostly
|
2022-02-02 23:24:27 +00:00
|
|
|
; a space-saving measure to allow for more code in the exeption handers themselves, but
|
|
|
|
; also simplifies the relocation process since we only have to update a single address
|
2021-11-22 22:13:29 +00:00
|
|
|
; in each exception handler, rather than two.
|
|
|
|
;
|
2022-02-02 23:24:27 +00:00
|
|
|
; Once working, this code should be able to be interleaved with the r_jmp_rtn code
|
2021-11-22 22:13:29 +00:00
|
|
|
; above to eliminate a couple of branches
|
|
|
|
jmp_rtn
|
|
|
|
bvs r_jmp_rtn
|
|
|
|
jmp_rtn_1 jmp l_jmp_rtn-base ; Could inline the code and save 3 cycles / line
|
2022-02-02 23:24:27 +00:00
|
|
|
; If we switch even/odd exit points, could fall through
|
|
|
|
; to the even_exit JMP at the head of the PEA field to
|
|
|
|
; save 6 cycles.
|
2021-11-22 22:13:29 +00:00
|
|
|
|
2021-07-09 19:18:49 +00:00
|
|
|
; Re-enable interrupts and continue -- the even_exit JMP from the previous line will jump here every
|
2021-11-19 16:24:09 +00:00
|
|
|
; 8 or 16 lines in order to give the system time to handle interrupts.
|
2021-10-07 23:33:06 +00:00
|
|
|
enable_int ldal stk_save+1 ; restore the stack
|
2021-07-16 13:38:14 +00:00
|
|
|
tcs
|
2023-04-28 04:38:26 +00:00
|
|
|
sep #$30 ; 8-bit mode
|
|
|
|
ldal STATE_REG
|
|
|
|
tax ; Save the value
|
|
|
|
and #$CF ; Read Bank 0 / Write Bank 0
|
2021-07-16 13:38:14 +00:00
|
|
|
stal STATE_REG
|
|
|
|
cli
|
2021-10-07 23:33:06 +00:00
|
|
|
nop ; Give a couple of cycles
|
2021-07-16 13:38:14 +00:00
|
|
|
sei
|
2023-04-28 04:38:26 +00:00
|
|
|
txa ; Restore the state
|
2021-07-16 13:38:14 +00:00
|
|
|
stal STATE_REG
|
2023-04-28 04:38:26 +00:00
|
|
|
rep #$30
|
2021-07-16 13:38:14 +00:00
|
|
|
bra entry_1
|
2021-07-08 13:17:38 +00:00
|
|
|
|
2020-08-23 05:25:39 +00:00
|
|
|
; This is the spot that needs to be page-aligned. In addition to simplifying the entry address
|
|
|
|
; and only needing to update a byte instad of a word, because the code breaks out of the
|
|
|
|
; code field with a BRA instruction, we keep everything within a page to avoid the 1-cycle
|
|
|
|
; page-crossing penalty of the branch.
|
2021-07-08 12:46:35 +00:00
|
|
|
|
2021-11-19 16:24:09 +00:00
|
|
|
ds \,$00 ; pad to the next page boundary
|
2021-10-07 23:33:06 +00:00
|
|
|
loop_exit_1 jmp odd_exit-base ; +0 Alternate exit point depending on whether the left edge is
|
|
|
|
loop_exit_2 jmp even_exit-base ; +3 odd-aligned
|
2021-07-08 12:46:35 +00:00
|
|
|
|
2021-10-07 23:33:06 +00:00
|
|
|
loop lup 82 ; +6 Set up 82 PEA instructions, which is 328 pixels and consumes 246 bytes
|
|
|
|
pea $0000 ; This is 41 8x8 tiles in width. Need to have N+1 tiles for screen overlap
|
2021-07-16 13:38:14 +00:00
|
|
|
--^
|
2021-10-07 23:33:06 +00:00
|
|
|
loop_back jmp loop-base ; +252 Ensure execution continues to loop around
|
|
|
|
loop_exit_3 jmp even_exit-base ; +255
|
2021-07-08 12:46:35 +00:00
|
|
|
|
2023-03-07 23:32:46 +00:00
|
|
|
odd_exit sep #$21 ; 8-bit mode and set the carry just in case we get to a snippet JMP
|
|
|
|
long_5 ldal OPCODE_SAVE ; Load the opcode that was saved
|
|
|
|
bit #$0B
|
2021-07-16 13:38:14 +00:00
|
|
|
bne :chk_jmp
|
2023-03-07 23:32:46 +00:00
|
|
|
long_6 ldal OPCODE_HIGH_SAVE+1 ; get the high byte of the PEA operand
|
2021-07-16 02:00:35 +00:00
|
|
|
|
2021-10-06 12:10:09 +00:00
|
|
|
; Fall-through when we have to push a byte on the left edge. Must be 8-bit on entry. Optimized
|
2023-03-07 23:32:46 +00:00
|
|
|
; for the PEA $0000 case -- only 17 cycles to handle the edge, so pretty good
|
|
|
|
|
2021-07-16 13:38:14 +00:00
|
|
|
pha
|
2023-03-07 23:32:46 +00:00
|
|
|
rep #$21
|
2021-07-16 02:00:35 +00:00
|
|
|
|
|
|
|
; JMP opcode = $4C, JML opcode = $5C
|
2021-10-07 23:33:06 +00:00
|
|
|
even_exit jmp $1000 ; Jump to the next line.
|
|
|
|
ds 1 ; space so that the last line in a bank can be patched into a JML
|
2021-07-16 02:00:35 +00:00
|
|
|
|
2023-03-07 23:32:46 +00:00
|
|
|
:chk_jmp mx %10 ; 8-bit accumulator / 16-bit registers
|
|
|
|
bit #$40
|
2021-07-17 04:09:08 +00:00
|
|
|
bne l_is_jmp
|
2021-07-08 12:46:35 +00:00
|
|
|
|
2023-03-07 23:32:46 +00:00
|
|
|
rep #$20 ; saved 3 cycles using 8-bit mode, but give it back here.
|
|
|
|
odd_low_save dfb $00,$00 ; save the first and second bytes of the code field. Works for LDA dp,x and LDA (0),y
|
2021-07-17 04:09:08 +00:00
|
|
|
l_jmp_rtn xba
|
2021-07-16 13:38:14 +00:00
|
|
|
sep #$20
|
2021-07-16 18:09:16 +00:00
|
|
|
pha
|
2022-02-02 23:24:27 +00:00
|
|
|
rep #$61 ; Clear everything C, V and M
|
2021-07-16 18:09:16 +00:00
|
|
|
bra even_exit
|
2021-07-16 02:00:35 +00:00
|
|
|
|
2023-03-07 23:32:46 +00:00
|
|
|
l_is_jmp
|
|
|
|
rep #$20 ; Back to 16-bit mode (carry was set above)
|
|
|
|
; sec ; Set the C flag (V is always cleared at this point) which tells a snippet to push only the high byte
|
|
|
|
dfb $4C ; Expect a JMP instruction
|
|
|
|
odd_high_save dfb $00,$00 ; The high 2 bytes of the 3-byte code field sequence is always stashed here
|
2020-08-25 02:59:58 +00:00
|
|
|
|
|
|
|
; Special epilogue: skip a number of bytes and jump back into the code field. This is useful for
|
|
|
|
; large, floating panels in the attract mode of a game, or to overlay solid
|
2021-07-08 12:46:35 +00:00
|
|
|
; dialog while still animating the play field
|
2020-08-25 02:59:58 +00:00
|
|
|
|
2021-07-16 13:38:14 +00:00
|
|
|
epilogue_1 tsc
|
|
|
|
sec
|
|
|
|
sbc #0
|
|
|
|
tcs
|
2021-10-07 23:33:06 +00:00
|
|
|
jmp $0000 ; This jumps back into the code field
|
|
|
|
:out jmp $0000 ; This jumps to the next epilogue chain element
|
2021-07-16 13:38:14 +00:00
|
|
|
ds 1
|
2020-08-25 02:59:58 +00:00
|
|
|
|
2020-08-23 05:25:39 +00:00
|
|
|
; These are the special code snippets -- there is a 1:1 relationship between each snippet space
|
|
|
|
; and a 3-byte entry in the code field. Thus, each snippet has a hard-coded JMP to return to
|
|
|
|
; the next code field location
|
|
|
|
;
|
|
|
|
; The snippet is required to handle the odd-alignment in-line; there is no facility for
|
|
|
|
; patching or intercepting these values due to their complexity. The only requirements
|
|
|
|
; are:
|
|
|
|
;
|
|
|
|
; 1. Carry Clear -> 16-bit write and return to the next code field operand
|
2021-07-16 02:00:35 +00:00
|
|
|
; 2. Carry Set
|
2020-08-23 05:25:39 +00:00
|
|
|
; 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
|
2021-10-06 12:10:09 +00:00
|
|
|
; its passed state, because having the carry bit clear prevents evaluation of
|
2020-08-23 05:25:39 +00:00
|
|
|
; the V bit.
|
|
|
|
;
|
2023-04-28 05:13:05 +00:00
|
|
|
; In order to improve performance, especially for two-layer tiles + sprites, the
|
|
|
|
; snippet code has a fixed structure so that the constant DATA and MASK values
|
|
|
|
; always exist in the same location, regarless of the tile type. The
|
|
|
|
; tradeoff is that there is a different entry point into the snippet based on the
|
|
|
|
; tile type, but that is significantly cheaper to lookup and patch into the code
|
|
|
|
; field JMP instruction than it is to rebuild 20+ bytes of code each time.
|
2023-02-27 21:30:56 +00:00
|
|
|
;
|
2023-04-28 05:13:05 +00:00
|
|
|
; There are different snippet templates + offset tables based on the EngineMode
|
2023-02-27 21:30:56 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; EngineMode
|
2020-08-23 05:25:39 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; ENGINE_MODE_TWO_LAYER NO
|
|
|
|
; ENGINE_MODE_DYN_TILES NO
|
2021-07-16 02:00:35 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; Snippet Template
|
|
|
|
; None.
|
2021-07-16 02:00:35 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; ENGINE_MODE_TWO_LAYER YES
|
|
|
|
; ENGINE_MODE_DYN_TILES NO
|
2021-08-13 16:38:06 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; Snippet Template
|
2021-08-13 16:38:06 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; ds 4
|
|
|
|
; lda (00),y <-- Single Entry Point
|
|
|
|
; and #MASK <-- Mask is always at byte 8
|
|
|
|
; ora #DATA <-- Data is always at byte 11
|
|
|
|
; bcs _alt
|
|
|
|
; pha
|
|
|
|
; jmp NEXT
|
|
|
|
; _alt jmp RTN
|
2021-08-13 16:38:06 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; ENGINE_MODE_TWO_LAYER NO
|
|
|
|
; ENGINE_MODE_DYN_TILES YES
|
2021-10-11 19:09:38 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; Snippet Template
|
2021-10-11 19:09:38 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; ds 4
|
|
|
|
; lda 00,x <-- Single Entry Point
|
|
|
|
; and #MASK
|
|
|
|
; ora #DATA
|
|
|
|
; bcs _alt
|
|
|
|
; pha
|
|
|
|
; jmp NEXT
|
|
|
|
; _alt jmp RTN
|
|
|
|
;
|
|
|
|
; ENGINE_MODE_TWO_LAYER YES
|
|
|
|
; ENGINE_MODE_DYN_TILES YES
|
2021-10-11 19:09:38 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; Snippet Template
|
2021-11-19 16:24:09 +00:00
|
|
|
;
|
2023-03-03 05:24:03 +00:00
|
|
|
; lda (00),y <-- Entry Point 1
|
|
|
|
; and $80,x
|
|
|
|
; ora $00,x <-- Entry Point 2 (Change this word to "lda (00),y" or "lda 00,x", or "ora 00,x" depending on combination)
|
|
|
|
; and #MASK
|
|
|
|
; ora #DATA
|
|
|
|
; bcs _alt
|
|
|
|
; _16bit pha
|
|
|
|
; jmp NEXT
|
2023-03-04 03:44:39 +00:00
|
|
|
; db 1 <--- Entry Point 3 (opcode for an LDA #DATA instruction)
|
|
|
|
; lda (00),y <--- Entry Point 4 (sneak this in here to avoid extra branch)
|
2023-03-03 05:24:03 +00:00
|
|
|
; and $80,x
|
|
|
|
; ora $00,x
|
|
|
|
; bcc _16bit
|
|
|
|
; _alt jmp RTN (29 bytes)
|
|
|
|
;
|
|
|
|
; Note that the code that's assembled in these snippets is just a template. Every routine that utilizes
|
|
|
|
; an exception handler *MUST* patch up the routines. There are different routines based on the Engine Mode.
|
|
|
|
;
|
|
|
|
; The LDA (00),y opcodes have a fixed operand, but the dynamic tile instructions are determined by the
|
|
|
|
; dynamic tile id and must be set each time.
|
|
|
|
|
2021-10-07 23:33:06 +00:00
|
|
|
ds \,$00 ; pad to the next page boundary
|
2021-07-17 04:09:08 +00:00
|
|
|
]index equ 0
|
|
|
|
snippets lup 82
|
2023-03-03 05:24:03 +00:00
|
|
|
lda ({{81-]index}*2}),y ; 0: Pre-set the LDA (XX),y instructions
|
|
|
|
and $80,x ; 2: The direct page instructions are placeholders and get overwritten
|
|
|
|
ora $00,x ; 4: This gets patched out often
|
|
|
|
and #$0000 ; 6: the mask operand will be set when the tile is drawn
|
|
|
|
ora #$0000 ; 9: the data operand will be set when the tile is drawn
|
|
|
|
bcs :byte ; 12: if C = 0, just push the data and return
|
|
|
|
:word pha ; 14:
|
|
|
|
jmp loop+3+{3*]index}-base ; 15: Return address offset within the code field
|
2023-03-04 03:44:39 +00:00
|
|
|
db $A9 ; 18: LDA #DATA opcode
|
|
|
|
lda ({{81-]index}*2}),y ; 19: Pre-set the LDA (XX),y instructions
|
|
|
|
and $80,x ; 21:
|
|
|
|
ora $00,x ; 23:
|
|
|
|
bcc :word ; 25:
|
|
|
|
:byte jmp jmp_rtn-base ; 27:
|
|
|
|
ds 2 ; 30: Padding to make a full 32 bytes
|
2021-07-17 04:09:08 +00:00
|
|
|
]index equ ]index+1
|
|
|
|
--^
|
2021-11-19 16:24:09 +00:00
|
|
|
top
|