28 lines
959 B
Plaintext
28 lines
959 B
Plaintext
macro RepeatProc,addr,count ;VASM macro syntax
|
|
; input:
|
|
; addr = the label of the routine you wish to call repeatedly
|
|
; count = how many times you want to DO the procedure. 1 = once, 2 = twice, 3 = three times, etc. Enter "0" for 256 times.
|
|
lda #<\addr
|
|
sta z_L ;a label for a zero-page memory address
|
|
lda #>\addr
|
|
sta z_H ;a label for the zero-page memory address immediately after z_L
|
|
lda \count
|
|
jsr doRepeatProc
|
|
endm
|
|
|
|
doRepeatProc:
|
|
sta z_C ;another zero-page memory location
|
|
loop_RepeatProc:
|
|
jsr Trampoline_RepeatProc
|
|
dec z_C
|
|
lda z_C
|
|
bne loop_RepeatProc
|
|
rts
|
|
|
|
Trampoline_RepeatProc:
|
|
db $6c,z_L,$00
|
|
;when executed, becomes an indirect JMP to the address stored at z_L and z_H. Some assemblers will let you type
|
|
;JMP (z_L) and it will automatically replace it with the above during the assembly process.
|
|
;This causes an indirect JMP to the routine. Its RTS will return execution to just after the "JSR Trampoline_RepeatProc"
|
|
;and flow into the loop overhead.
|