mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 08:56:25 +00:00
PortNintendo 3DS SDL_main to header-only + SDL_N3DSRunApp()
and move the #undef main and #define main SDL_main to the start/end of SDL_main_impl.h instead of repeating it in every platform implementation Thanks to SDL_N3DSRunApp we don't need the #include <3ds.h> in SDL_main_impl.h - that caused conflicts with testthread.c, because both have (different) ThreadFunc typedefs.
This commit is contained in:

committed by
Sam Lantinga

parent
2aee3e654d
commit
1de559248e
49
src/core/n3ds/SDL_n3ds.c
Normal file
49
src/core/n3ds/SDL_n3ds.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef __3DS__
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
DECLSPEC int
|
||||
SDL_N3DSRunApp(int argc, char *argv[], SDL_main_func mainFunction)
|
||||
{
|
||||
int result;
|
||||
/* init */
|
||||
osSetSpeedupEnable(true);
|
||||
romfsInit();
|
||||
|
||||
SDL_SetMainReady();
|
||||
result = mainFunction(argc, argv);
|
||||
|
||||
/* quit */
|
||||
romfsExit();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -886,3 +886,4 @@
|
||||
#define SDL_GetEventState SDL_GetEventState_REAL
|
||||
#define SDL_GetRenderDriver SDL_GetRenderDriver_REAL
|
||||
#define SDL_Win32RunApp SDL_Win32RunApp_REAL
|
||||
#define SDL_N3DSRunApp SDL_N3DSRunApp_REAL
|
||||
|
@@ -964,3 +964,6 @@ SDL_DYNAPI_PROC(const char*,SDL_GetRenderDriver,(int a),(a),return)
|
||||
#if defined(__WIN32__)
|
||||
SDL_DYNAPI_PROC(int,SDL_Win32RunApp,(SDL_main_func a, void *b),(a,b),return)
|
||||
#endif
|
||||
#if defined(__3DS__)
|
||||
SDL_DYNAPI_PROC(int,SDL_N3DSRunApp,(int a, char *b[], SDL_main_func c),(a,b,c),return)
|
||||
#endif
|
||||
|
@@ -17,44 +17,9 @@
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Nothing to do here, the code moved into SDL_main_impl.h
|
||||
TODO: remove this file
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h> /* until this SDL_main impl is converted to header-only.. */
|
||||
|
||||
#ifdef __3DS__
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#ifdef main
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
SDL_FORCE_INLINE void N3DS_Init(void);
|
||||
SDL_FORCE_INLINE void N3DS_Quit(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int result;
|
||||
N3DS_Init();
|
||||
SDL_SetMainReady();
|
||||
result = SDL_main(argc, argv);
|
||||
N3DS_Quit();
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE void
|
||||
N3DS_Init(void)
|
||||
{
|
||||
osSetSpeedupEnable(true);
|
||||
romfsInit();
|
||||
}
|
||||
|
||||
SDL_FORCE_INLINE void
|
||||
N3DS_Quit(void)
|
||||
{
|
||||
romfsExit();
|
||||
}
|
||||
|
||||
#endif /* __3DS__ */
|
||||
|
||||
/* vi: set sts=4 ts=4 sw=4 expandtab: */
|
||||
|
Reference in New Issue
Block a user