scopes, modules, and symbols in ca65
Posted: Sat Sep 11, 2021 11:30 pm
My project is getting quite large, and it can no longer fit in a main.s file with everything at global scope. I have started moving every module into its own scope, and it has made my code much more readable
however, now I am running into a scope run-around. especially when modules use symbols or labels outside their scope. For instance, I cant include the player metasprite constant from my sprites module in the player module, because at that point my sprites module hasnt been defined yet. I am using explicit scope in these scenarios
as of now, all my .includes live in my main.s file (I know this is wrong). And i have to shuffle them around to make sure scopes exist before they are used. I've tried using a
and then including that file in every file that uses it, but it doesnt seem to be working
In C, I would make a header file and declare these before I defined them so they can be used in other modules (right?) and include the header file whenever I needed it. I am not sure what is the """"right way"""" to do this in assembly, but I have a vested interest in doing this per-industry-standard as I begin searching for careers in the tech field. Any input or words of wisdom about program structure would be greatly appreciated
Code: Select all
jsr player::move
jsr player::bullets::move
jsr player::shoot
jsr enemies::move
Code: Select all
lda ::player::Y_H
Code: Select all
.if .define(module)In C, I would make a header file and declare these before I defined them so they can be used in other modules (right?) and include the header file whenever I needed it. I am not sure what is the """"right way"""" to do this in assembly, but I have a vested interest in doing this per-industry-standard as I begin searching for careers in the tech field. Any input or words of wisdom about program structure would be greatly appreciated