One thing that this project is definitely missing is
#define.
When you have more than 50 different character types in your game and each of them has a huge bunch of fixed properties, then you can easily do this in C:
Code:
#define ALL_CHARACTERS(postfix)\
Hero##postfix,\
Monster##postfix,\
Boss##postfix
etc.
Then you do:
Code:
enum
{
ALL_CHARACTERS(Type)
};
And for the properties, you can do this:
Code:
#define HeroCanWalkThroughWalls false
#define MonsterCanWalkThroughWalls false
#define BossCanWalkThroughWalls true
const byte CanWalkThorughWallsProperties[] =
{
ALL_CHARACTERS(CanWalkThroughWalls)
};
Now, I can be sure that something like this:
Code:
if (CanWalkThorughWallsProperties[CurrentCharacter.Type])
will always be correct and that I can later shuffle around the order of the characters in any way I like without having to manually update a bazillion property arrays.
Also, when I add a new character, I simply put it into the macro and let the compiler tell me where it's missing some property names:
Code:
#define ALL_CHARACTERS(postfix)\
Hero##postfix,\
Companion##postfix,\
Monster##postfix,\
Boss##postfix
-->
Undefined symbol: CompanionCanWalkThroughWalls
Undefined symbol: CompanionMaxEnergy
Undefined symbol: CompanionMetaSprites
etc.
So, I can add these things piece by piece and don't have to search around manually, hoping that I haven't forgotten anything.
dougeff wrote:
That is disappointing.
cc65 would be much faster if the c stack was fixed to 1 page, and the stack pointer was 1 byte.
Then getting a parameter would work like...
ldy sp
lda stack, y
rather than indirect addresses. and 16 bit stack / stack pointer.
I would suggest not to use local variables and parameters at all when using C for an NES project, unless it's not time-critical and you have enough ROM space.
Again a situation where macros come in handy:
Code:
byte DoSomethingParamaterA;
byte DoSomethingParamaterB;
void __fastcall__ DoSomething_(void);
#define DoSomething(a, b)\
do\
{\
DoSomethingParameterA = a;\
DoSomethingParameterB = b;\
DoSomething_();\
}\
while (false)