Hello to everyone,
I'm implementing a Macro that put an enemy on the screen in this way:
And i use it like this:
The problem, if I try to use the macro again, for example:
The compiler give me an error of duplicate label, it seems it "copy" the label everytime the macro is called. There is a way to put "generic" label or something like that to use the macro with a label inside? Because macros allow me to reduce a lot of duplicate code.
Thanks.
I'm implementing a Macro that put an enemy on the screen in this way:
Code:
MACROPutEnemyOnScene .macro
lda $2002
lda #$20
sta $2006
lda #$00
sta $2006
ldy #$00
LoadTargetSpriteLoop:
lda \1, y
sta \2, y
iny
cpy #$08
bne LoadTargetSpriteLoop
.endm
lda $2002
lda #$20
sta $2006
lda #$00
sta $2006
ldy #$00
LoadTargetSpriteLoop:
lda \1, y
sta \2, y
iny
cpy #$08
bne LoadTargetSpriteLoop
.endm
And i use it like this:
Code:
lda #LOW( target_up )
sta TARGET_TO_LOAD + 0
lda #HIGH( target_up )
sta TARGET_TO_LOAD + 1
MACROPutEnemyOnScene [TARGET_TO_LOAD], RAM_TARGET_UP
sta TARGET_TO_LOAD + 0
lda #HIGH( target_up )
sta TARGET_TO_LOAD + 1
MACROPutEnemyOnScene [TARGET_TO_LOAD], RAM_TARGET_UP
The problem, if I try to use the macro again, for example:
Code:
lda #LOW( target_down )
sta TARGET_TO_LOAD + 0
lda #HIGH( target_down )
sta TARGET_TO_LOAD + 1
MACROPutEnemyOnScene [TARGET_TO_LOAD], RAM_TARGET_DOWN
sta TARGET_TO_LOAD + 0
lda #HIGH( target_down )
sta TARGET_TO_LOAD + 1
MACROPutEnemyOnScene [TARGET_TO_LOAD], RAM_TARGET_DOWN
The compiler give me an error of duplicate label, it seems it "copy" the label everytime the macro is called. There is a way to put "generic" label or something like that to use the macro with a label inside? Because macros allow me to reduce a lot of duplicate code.
Thanks.