Hard to give a definite answer without seeing the real structure. Even more as 'assemblers' isn't a singular language. each is different. A link to it's documentation would be very helpful and in what configuration (command line?) compilation is done.
From your write up it's possible to assume the whole project is not split in modules, assembled separate and linked later, but assembled as one source file into one object file. This structure is often the case with simple/beginner projects. Here every source file, no matter how you name it, is included into the assembled source at the point its 'include' statement is placed. Thus including the same 'header' in different files is producing an error.
Most C projects in contrast are build with each source file compiled separate and linked later on. Thus includes in one source file do not collide with the same include in any other.
The same can be done of course with assembler (*1). Assemble each of your source files into s distinct object module and link them at the end. That way each is handled at its own and no duplicates arise.
In your case this would look mean
- Compile MAIN.ASM and PLAYER.ASM separate using the RGBASM tool
- Each including all definition files needed.
- Link them into an executable using RGBLINK
Since each is a distinct compilation unit, no error arise and no hacks are needed to avoid multiple inclusion.
Of course, since these are now separate compilation units, access between them must be granted, as by default an Assembler treats everything in a separate unit as private to this unit. So if there's for example an init function named SetupPlayer
within PLAYER.ASM, then access to this must be allowed to external by exporting that entry point via an EXPORT directrive
EXPORT SetupPlayer
...
SetupPlayer: ...
Usually all exports get placed on a single line and near the start of a source file to improve readability.
Now that function can be used from MAIN.ASM without further action (*3)
CALL SetupPlayer
The whole point is to support separate compilation and linking while providing private name spaces.
That, or take into account that your source is a single item spread over different files and structure it accordingly - like include everything into a main file - only there and only once (*3).
*1 - C's capability of separate compilation is based on the object and link structure provided by its assembler base, so no difference if used right.
*2 - This is specific to RGBASM, which treats all unknown symbols as external. Other Assemblers may need some IMPORT
or EXTERN
directive, essentially creating a system of contracts, further enhancing encapsulation.
*3 - Naa, don't do there. Use the tools as intended, don't build 'hacks' to emulate separate compilation by some hack around includes. That is not only bad style, but a great way to introduce future issues - hard to solve issues.