Dear experienced ca65 users,
I've run into a problem and hope you can help me.
particle.s:
Now, what I can do outside of the scope is:
However, using the macros like this:
doesn't work.
Macros seem to be directly accessible from all scopes(?), so just calling them without the "peng::" part works. That defies the purpose of scopes, though.
My questions: Is there any way around this? Is it even good practice to write code like this or is there a better, recommended way?
It's the first time I've been using scopes in this way, but I've got older similar code that I want to convert to be more readable and organized.
I've run into a problem and hope you can help me.
particle.s:
Code:
.scope peng ;"P"article "ENG"ine
;init - initializes particle engine
init:
...
rts
;run - called once per frame, loops through all particles and updates their position etc.
run:
...
rts
;particle_create - create a particle and return its index in the X register
.macro particle_create
...
.endmacro
.macro particle_setpos px,py
...
.endmacro
;updates the particle specified in the X register
particle_run:
rts
.endscope
;init - initializes particle engine
init:
...
rts
;run - called once per frame, loops through all particles and updates their position etc.
run:
...
rts
;particle_create - create a particle and return its index in the X register
.macro particle_create
...
.endmacro
.macro particle_setpos px,py
...
.endmacro
;updates the particle specified in the X register
particle_run:
rts
.endscope
Now, what I can do outside of the scope is:
Code:
jsr peng::init
jsr peng::run
jsr peng::particle_func
jsr peng::run
jsr peng::particle_func
However, using the macros like this:
Code:
peng::particle_create #01
peng::particle_setpos #40,#120
peng::particle_setpos #40,#120
doesn't work.
Macros seem to be directly accessible from all scopes(?), so just calling them without the "peng::" part works. That defies the purpose of scopes, though.
My questions: Is there any way around this? Is it even good practice to write code like this or is there a better, recommended way?
It's the first time I've been using scopes in this way, but I've got older similar code that I want to convert to be more readable and organized.