Port ngage to header-only SDL_main + SDL_RunApp()

For some reason, ngage doesn't seem to be handled in any of the
build systems, so I couldn't add SDL_ngage_runapp.cpp to any buildscript
This commit is contained in:
Daniel Gibson
2022-12-12 18:30:05 +01:00
committed by Sam Lantinga
parent 7bfc41db3c
commit 544f2c7982
4 changed files with 109 additions and 79 deletions

View File

@@ -110,6 +110,14 @@
*/
#define SDL_MAIN_AVAILABLE
#elif defined(__NGAGE__)
/*
TODO: not sure if it should be SDL_MAIN_NEEDED, in SDL2 ngage had a
main implementation, but wasn't mentioned in SDL_main.h
*/
#define SDL_MAIN_AVAILABLE
#endif
#endif /* SDL_MAIN_HANDLED */
@@ -272,7 +280,7 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
/* include header-only SDL_main implementations */
#if defined(__WIN32__) || defined(__GDK__) || defined(__IOS__) || defined(__TVOS__) \
|| defined(__3DS__) /* TODO: other platforms */
|| defined(__3DS__) || defined(__NGAGE__) /* TODO: other platforms */
#include <SDL3/SDL_main_impl.h>
#elif defined(__WINRT__) /* TODO: other C++ platforms */

View File

@@ -156,7 +156,22 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
}
/* end of WinRT impl */
#elif defined(__IOS__) || defined(__TVOS__) || defined(__3DS__)
#elif defined(__NGAGE__)
/* same typedef as in ngage SDKs e32def.h */
typedef signed int TInt;
/* TODO: if it turns out that this only works when built as C++,
move __NGAGE__ into the C++ section in SDL_main.h */
TInt E32Main()
{
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
/* end of __NGAGE__ impl */
/* TODO: remaining platforms */
#else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */
#include <SDL3/begin_code.h>
@@ -175,9 +190,7 @@ int main(int argc, char *argv[])
#include <SDL3/close_code.h>
/* end of __IOS__, __3DS__, __TVOS__ impls */
/* TODO: remaining platforms */
/* end of impls for standard-conforming platforms */
#endif /* __WIN32__ etc */