I want to take a modular approach to my code so that I can separate logic and
routines into specific files - much the way it would be done in C.
So far, I can see this being done by using pointers and sub routines. If I
were to send in the start address, the module could alter the memory offsets
and initialize and dispose the game-objects respectively.
This would be a more, somewhat, object-oriented approach which would make me
very pleased.
I would like to consider using MACROs to facilitate a better way of sending
parameters, which leads me to have a few questions.
For instance, let's say we have a "goomba.asm" file that handles all goomba
game object behavior. I could initialize the video memory and send in the
start address:
Code:
LDA #$00 ; LSB
LDY #$02 ; MSB
JSR INIT_GOOMBA
; in goomba.asm
ME = $00 ; identifier for zero page pointer
INIT_GOOMBA:
STA ME ; store pointer in zp
STY ME+1 ; MSB follows
LDY #$00 ; set Y back to 0
LDA #$32 ; store tile 32 at start address
STA (ME), Y
RTS
Of course, much more would come into play here. Based on my
current understanding, the only way to send in the 16-bit address of the starting point is to use that whacky indirect-indexed-Y mode. I suppose it makes sense that the MSB comes second if you consider it like a Stack, but I digress...
I would like to have some input here. I am hoping that this
makes sense and is scalable.
Is there a way to use a MACRO to make this even clearer / easier?
Thanks again!