For example, this is an ASM6 macro I have in my game that can be used in any entity's AI to accelerate the entity over time:
Code: Select all
.macro ACCELERATE Xhi,Xlo,Yhi,Ylo
; accelerate the current object
; pass arguments via the stack
lda #>(accelreturn-1) ; push return address in advance
pha
lda #<(accelreturn-1) ; push return address in advance
pha
; recognize and avoid unnecessary lda-s
lda #Yhi
pha
.if Yhi != Ylo
lda #Ylo
.endif
pha
.if Ylo != Xhi
lda #Xhi
.endif
pha
.if Xhi != Xlo
lda #Xlo
.endif
jmp AccelerateObject
accelreturn:
.endm
The other method I've used before was to pass arguments using zero page temporaries:
Code: Select all
.macro LOADPALETTE target,palID,amount
; Load palettes and raise the update flag
load=PaletteSet+(palID*4)
lda #<load
sta temp+14
lda #>load
sta temp+15 ; set up indirect vector
lda #amount ; number of extra palettes to load
sta temp+1
lda #target ; target in the buffer
jsr LoadThePalette
.endm
All in all, is there a generally acceptable "best way" of doing this, or is it always situational?