I have some concerns regarding macros, memory usage and speed. I have
written a macro that will update a sprite. The sprite table occupies
$0200 - $02FF in my game. Right now, my meta sprites are 16 bytes in
length.
The following will set the tiles for my 2x2 meta sprites:
Code:
.macro drwFrame frm, spr
ldy #0
@loop:
tya
asl a
asl a
tax
lda frm, y
sta spr, x+1
iny
cpy #4
bne @loop
.endm
drwFrame frm1, $0200
frm1: .db $00, $01, $02, $03
frm2: .db $05, $04, $06, $07
The neat part about this is that I can use the same code for any 2x2
tile. Not just my main character. When I call
drwFrame param 1
is the frame table to use, param 2 is the start address of the sprite
to alter.
So far, my game only uses this code 4 times. One for each frame of my
main character. The downside, is that every time I call this macro, it
re-writes the macro to memory right?
I've thought about using a zero-page pointer to use indirect Y to access
the frame table. This would not be as fast, but it would take up less
PRG-Memory. I could also just write several unique sub routines, but
that would be harder to maintain and take up the same space as the macro.
I'm just not sure how else to go about this. I can't seem to grasp whether or
not speed, space, or flexibility is more important.
Is the above solution sound? Do you recommend another approach?
Thanks