Things I stumbled over with CPP projects on Saturn (Lynx and Wonderswan emu) were:
the link script may have to contain some additional sections
in SGL examples, function main() is located in a seperate C file. Because of linking problems, better place main() in a C++ file.
a lot of additional stuff is linked to the binary, making it very big
to reduce executable size, I overloaded the new and delete constructors with custom memory allocators and specified -fno-rtti (real time type invokation) and -fno-exceptions. Then the result should be comparable to standard C. Google for "embedded C++"
If you use a C library like SGL or SBL, special care must be taken when calling them from C++. Declarations of functions must be labeled as C, an example:
to reduce executable size, I overloaded the new and delete constructors with custom memory allocators and specified -fno-rtti (real time type invokation) and -fno-exceptions. Then the result should be comparable to standard C. Google for "embedded C++"
Recently, I've had problems getting a c++ game to run on Saturn. It didn't enter main() or ss_main(), must have hanged up in some startup code linked in by the linker. Looking at yabause's CPU debugger and at my map file, I found out that it hangs in a function called __sccl, somehow related to vfprintf and __main().
So I put a dummy function void __main() {} in a seperate .c file, linked it to the other .c++ files and the game started up correctly . It won't work when you compile that dummy function as c++ file. Obviously, it hanged in __main(), but I can't say why.
On a different note, with COFF compiler the function __main() is the reason why malloc() and free() are linked to the binary, even if it's not used in the game at all. Defining a dummy function void __main() {} in a c file (not c++) helps here. This can be useful when you want to save some kBytes of binary size, or if you must be sure to not use malloc somewhere, because you use a different memory allocator.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.