That's not really what I'm talking about.
Duplicating a struct would require manual synchronization between the two definitions just as well.
I would have to declare a struct in C and the same struct in Assembly again and pay attention that every little change is carried over from one struct to the other one.
I'm talking about a way of importing the separate members of a C struct into Assembly.
If I have a struct called Character and the character has a member named Energy and I have a global variable called Player, then I want to be able to use something like Player.Energy inside Assembly and let the compiler/linker find out what actual address this is.
Alternately, I would also be content with building something with the help of C preprocessors etc.
For example, if I could do something like this in C:
Code: Select all
#define PlayerEnergy (&Player.Energy)
and then import this in Assembly:
Code: Select all
.import _PlayerEnergy
LDA _PlayerEnergy
this would be fine as well.
However, something like this:
Code: Select all
byte *const PlayerEnergy = &Player.Energy;
(or however a pointer has to be declared whose address is fixed, but whose value can be written)
would not be good.
Because not only does the pointer occupy actual space in ROM, but in Assembly, I would have to use it this way:
Code: Select all
.import _PlayerEnergy
LDY #0
LDA (_PlayerEnergy), Y