diff --git a/src/3ds/Platform_3DS.c b/src/3ds/Platform_3DS.c index 2c2d6a6a9..c60a85335 100644 --- a/src/3ds/Platform_3DS.c +++ b/src/3ds/Platform_3DS.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -28,7 +29,6 @@ #include #include <3ds.h> #include -#include "../_PlatformConsole.h" #define US_PER_SEC 1000000LL #define NS_PER_MS 1000000LL @@ -42,6 +42,7 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " 3DS"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" // https://gbatemp.net/threads/homebrew-development.360646/page-245 @@ -49,6 +50,22 @@ cc_bool Platform_ReadonlyFilesystem; unsigned int __stacksize__ = 256 * 1024; +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -466,6 +483,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/ClassiCube.vcxproj b/src/ClassiCube.vcxproj index 7682f5336..dfdc53356 100644 --- a/src/ClassiCube.vcxproj +++ b/src/ClassiCube.vcxproj @@ -448,7 +448,6 @@ - diff --git a/src/ClassiCube.vcxproj.filters b/src/ClassiCube.vcxproj.filters index 12c91f621..2f98b9136 100644 --- a/src/ClassiCube.vcxproj.filters +++ b/src/ClassiCube.vcxproj.filters @@ -342,9 +342,6 @@ Header Files\Network - - Header Files\Platform - Header Files\Entities @@ -1001,4 +998,4 @@ Resource Files - \ No newline at end of file + diff --git a/src/Platform_WinCE.c b/src/Platform_WinCE.c index 80a7701a0..bc7d4bda6 100644 --- a/src/Platform_WinCE.c +++ b/src/Platform_WinCE.c @@ -38,8 +38,8 @@ cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; // Current directory management for Windows CE static WCHAR current_directory[MAX_PATH] = L"\\"; static cc_string Platform_NextArg(STRING_REF cc_string* args); - static CRITICAL_SECTION dir_lock; + /*########################################################################################################################* *-----------------------------------------------------Main entrypoint-----------------------------------------------------* *#########################################################################################################################*/ @@ -51,13 +51,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL do { res = RunProgram(0, NULL); - } while (Platform_IsSingleProcess() && Window_Main.Exists); + } while (Window_Main.Exists); Window_Free(); ExitProcess(res); return res; } + /*########################################################################################################################* *---------------------------------------------------------Memory----------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/Platform_Windows.c b/src/Platform_Windows.c index 50146b886..604521857 100644 --- a/src/Platform_Windows.c +++ b/src/Platform_Windows.c @@ -1,6 +1,7 @@ #include "Core.h" #if defined CC_BUILD_WIN +#include "String.h" #include "Stream.h" #include "SystemFonts.h" #include "Funcs.h" @@ -36,6 +37,7 @@ cc_bool Platform_ReadonlyFilesystem; cc_uint8 Platform_Flags; #include "_PlatformBase.h" + /*########################################################################################################################* *-----------------------------------------------------Main entrypoint-----------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/_PlatformBase.h b/src/_PlatformBase.h index ed9bd1c0a..a1c4dcb34 100644 --- a/src/_PlatformBase.h +++ b/src/_PlatformBase.h @@ -159,7 +159,7 @@ void Platform_LogConst(const char* message) { } /*########################################################################################################################* -*-----------------------------------------------------Process/Module------------------------------------------------------* +*---------------------------------------------------Command line args-----------------------------------------------------* *#########################################################################################################################*/ static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE]; static int gameNumArgs; @@ -189,6 +189,27 @@ static CC_INLINE int GetGameArgs(cc_string* args) { return count; } +#ifdef DEFAULT_COMMANDLINE_FUNC +int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) { + if (gameHasArgs) return GetGameArgs(args); + /* Consoles *sometimes* doesn't use argv[0] for program name and so argc will be 0 */ + //* (e.g. when running via some emulators) */ + if (!argc) return 0; + + argc--; argv++; /* skip executable path argument */ + + int count = min(argc, GAME_MAX_CMDARGS); + Platform_Log1("ARGS: %i", &count); + + for (int i = 0; i < count; i++) + { + args[i] = String_FromReadonly(argv[i]); + Platform_Log2(" ARG %i = %c", &i, argv[i]); + } + return count; +} +#endif + /*########################################################################################################################* *----------------------------------------------------------Misc-----------------------------------------------------------* diff --git a/src/_PlatformConsole.h b/src/_PlatformConsole.h deleted file mode 100644 index 36a5607d5..000000000 --- a/src/_PlatformConsole.h +++ /dev/null @@ -1,49 +0,0 @@ -cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; - -/*########################################################################################################################* -*-----------------------------------------------------Main entrypoint-----------------------------------------------------* -*#########################################################################################################################*/ -#include "main_impl.h" - -int main(int argc, char** argv) { - SetupProgram(argc, argv); - while (Window_Main.Exists) { - RunProgram(argc, argv); - } - - Window_Free(); - return 0; -} - - -/*########################################################################################################################* -*-----------------------------------------------------Process/Module------------------------------------------------------* -*#########################################################################################################################*/ -cc_result Process_StartGame2(const cc_string* args, int numArgs) { - Platform_LogConst("START CLASSICUBE"); - return SetGameArgs(args, numArgs); -} - -int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) { - if (gameHasArgs) return GetGameArgs(args); - // Consoles *sometimes* doesn't use argv[0] for program name and so argc will be 0 - // (e.g. when running via some emulators) - if (!argc) return 0; - - argc--; argv++; // skip executable path argument - - int count = min(argc, GAME_MAX_CMDARGS); - Platform_Log1("ARGS: %i", &count); - - for (int i = 0; i < count; i++) - { - args[i] = String_FromReadonly(argv[i]); - Platform_Log2(" ARG %i = %c", &i, argv[i]); - } - return count; -} - -cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { - return 0; -} - diff --git a/src/amiga/Platform_Amiga.c b/src/amiga/Platform_Amiga.c index 7d49ab2a4..070ca5ba6 100644 --- a/src/amiga/Platform_Amiga.c +++ b/src/amiga/Platform_Amiga.c @@ -41,7 +41,7 @@ size_t __stack = 65536; // vbcc /*########################################################################################################################* *-----------------------------------------------------Main entrypoint-----------------------------------------------------* *#########################################################################################################################*/ -#include "main_impl.h" +#include "../main_impl.h" int main(int argc, char** argv) { cc_result res; diff --git a/src/dreamcast/Platform_Dreamcast.c b/src/dreamcast/Platform_Dreamcast.c index 276a61d2d..e981c0da8 100644 --- a/src/dreamcast/Platform_Dreamcast.c +++ b/src/dreamcast/Platform_Dreamcast.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -24,7 +25,6 @@ #include #include #include -#include "../_PlatformConsole.h" KOS_INIT_FLAGS(INIT_CONTROLLER | INIT_KEYBOARD | INIT_MOUSE | INIT_VMU | INIT_CDROM | INIT_NET); @@ -35,11 +35,28 @@ const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; const cc_result ReturnCode_SocketDropped = EPIPE; +static cc_bool usingSD; const char* Platform_AppNameSuffix = " Dreamcast"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" -static cc_bool usingSD; + + +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} /*########################################################################################################################* @@ -768,6 +785,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/gba/Platform_GBA.c b/src/gba/Platform_GBA.c index ec080dbbe..3e21b58b7 100644 --- a/src/gba/Platform_GBA.c +++ b/src/gba/Platform_GBA.c @@ -52,6 +52,7 @@ int main(int argc, char** argv) { return 0; } + /*########################################################################################################################* *---------------------------------------------------------Memory----------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/gcwii/Platform_GCWii.h b/src/gcwii/Platform_GCWii.h index 7407fde6b..6fc5edbbc 100644 --- a/src/gcwii/Platform_GCWii.h +++ b/src/gcwii/Platform_GCWii.h @@ -481,3 +481,12 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + diff --git a/src/gcwii/Platform_Gamecube.c b/src/gcwii/Platform_Gamecube.c index 49d389c34..0973e2ed8 100644 --- a/src/gcwii/Platform_Gamecube.c +++ b/src/gcwii/Platform_Gamecube.c @@ -27,7 +27,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; @@ -38,10 +37,27 @@ const cc_result ReturnCode_SocketDropped = -EPIPE; const char* Platform_AppNameSuffix = " GameCube"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" #include "Platform_GCWii.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *---------------------------------------------------------Socket----------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/gcwii/Platform_Wii.c b/src/gcwii/Platform_Wii.c index 4cf4f9ff7..37694d273 100644 --- a/src/gcwii/Platform_Wii.c +++ b/src/gcwii/Platform_Wii.c @@ -4,6 +4,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -28,7 +29,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; @@ -39,10 +39,27 @@ const cc_result ReturnCode_SocketDropped = -EPIPE; const char* Platform_AppNameSuffix = " Wii"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" #include "Platform_GCWii.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *---------------------------------------------------------Socket----------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/nds/Platform_NDS.c b/src/nds/Platform_NDS.c index f5d8605a5..8e0d6042e 100644 --- a/src/nds/Platform_NDS.c +++ b/src/nds/Platform_NDS.c @@ -3,6 +3,7 @@ #ifdef NDS_NONET #define CC_NO_SOCKETS #endif +#define DEFAULT_COMMANDLINE_FUNC #define CC_XTEA_ENCRYPTION #include "../Stream.h" @@ -41,7 +42,6 @@ #include #include #endif -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; @@ -52,9 +52,26 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " NDS"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -643,6 +660,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/ps1/Platform_PS1.c b/src/ps1/Platform_PS1.c index 6e2944878..e1a6dd2ad 100644 --- a/src/ps1/Platform_PS1.c +++ b/src/ps1/Platform_PS1.c @@ -42,6 +42,22 @@ cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/ps2/Platform_PS2.c b/src/ps2/Platform_PS2.c index 0758aefe6..79e72353d 100644 --- a/src/ps2/Platform_PS2.c +++ b/src/ps2/Platform_PS2.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -39,7 +40,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = -4; @@ -50,6 +50,7 @@ const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " PS2"; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; cc_bool Platform_ReadonlyFilesystem; #include "../_PlatformBase.h" @@ -63,6 +64,22 @@ cc_bool Platform_ReadonlyFilesystem; if (ret < 0) Platform_Log1("SifExecModuleBuffer " STRINGIFY(name) " failed: %i", &ret); +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -757,6 +774,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/ps3/Platform_PS3.c b/src/ps3/Platform_PS3.c index c49621aa2..ac561f808 100644 --- a/src/ps3/Platform_PS3.c +++ b/src/ps3/Platform_PS3.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -32,7 +33,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = 0x80010006; // ENOENT; @@ -42,11 +42,29 @@ const cc_result ReturnCode_SocketWouldBlock = NET_EWOULDBLOCK; const cc_result ReturnCode_SocketDropped = NET_EPIPE; const char* Platform_AppNameSuffix = " PS3"; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; cc_bool Platform_ReadonlyFilesystem; #include "../_PlatformBase.h" SYS_PROCESS_PARAM(1001, 256 * 1024); // 256kb stack size + +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -501,6 +519,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/ps4/Platform_PS4.c b/src/ps4/Platform_PS4.c index 82f63272b..c2dbe8558 100644 --- a/src/ps4/Platform_PS4.c +++ b/src/ps4/Platform_PS4.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -31,7 +32,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; @@ -42,9 +42,26 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " PS4"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -547,6 +564,15 @@ void Platform_Init(void) { Platform_LogConst("initing 2.."); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/psp/Platform_PSP.c b/src/psp/Platform_PSP.c index dfbcbc645..357ca077a 100644 --- a/src/psp/Platform_PSP.c +++ b/src/psp/Platform_PSP.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -21,7 +22,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; @@ -32,6 +32,7 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " PSP"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" PSP_MODULE_INFO("ClassiCube", PSP_MODULE_USER, 1, 0); @@ -43,6 +44,22 @@ PSP_DISABLE_AUTOSTART_PTHREAD() PSP_DISABLE_NEWLIB_TIMEZONE_SUPPORT() +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -501,6 +518,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/psvita/Platform_PSVita.c b/src/psvita/Platform_PSVita.c index e6a11fe91..0e3d0a983 100644 --- a/src/psvita/Platform_PSVita.c +++ b/src/psvita/Platform_PSVita.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -26,9 +27,26 @@ static int stdout_fd; const char* Platform_AppNameSuffix = " PS Vita"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -454,6 +472,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/switch/Platform_Switch.c b/src/switch/Platform_Switch.c index a6cecd99a..349e83183 100644 --- a/src/switch/Platform_Switch.c +++ b/src/switch/Platform_Switch.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -37,6 +38,7 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " Switch"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" alignas(16) u8 __nx_exception_stack[0x1000]; @@ -69,6 +71,22 @@ void __libnx_exception_handler(ThreadExceptionDump *ctx) } +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -546,6 +564,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/wiiu/Platform_WiiU.c b/src/wiiu/Platform_WiiU.c index 96120a518..25af9135f 100644 --- a/src/wiiu/Platform_WiiU.c +++ b/src/wiiu/Platform_WiiU.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../ExtMath.h" @@ -41,8 +42,6 @@ #include #include -#include "../_PlatformConsole.h" - const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; const cc_result ReturnCode_DirectoryExists = EEXIST; @@ -52,9 +51,26 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " Wii U"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -480,6 +496,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/xbox/Platform_Xbox.c b/src/xbox/Platform_Xbox.c index 7c30ad780..fd641e6d2 100644 --- a/src/xbox/Platform_Xbox.c +++ b/src/xbox/Platform_Xbox.c @@ -1,6 +1,7 @@ #define CC_XTEA_ENCRYPTION #define CC_NO_UPDATER #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../Funcs.h" @@ -16,7 +17,6 @@ #include #include #include -#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION; const cc_result ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND; @@ -27,9 +27,26 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " XBox"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* *#########################################################################################################################*/ @@ -475,6 +492,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* diff --git a/src/xbox360/Platform_Xbox360.c b/src/xbox360/Platform_Xbox360.c index 1c0aae698..7f4ac500e 100644 --- a/src/xbox360/Platform_Xbox360.c +++ b/src/xbox360/Platform_Xbox360.c @@ -2,6 +2,7 @@ #define CC_NO_UPDATER #define CC_NO_SOCKETS #define CC_NO_DYNLIB +#define DEFAULT_COMMANDLINE_FUNC #include "../Stream.h" #include "../Funcs.h" @@ -26,8 +27,6 @@ #include #include -#include "../_PlatformConsole.h" - const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; const cc_result ReturnCode_DirectoryExists = EEXIST; @@ -37,8 +36,24 @@ const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " XBox 360"; cc_bool Platform_ReadonlyFilesystem; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; #include "../_PlatformBase.h" +/*########################################################################################################################* +*-----------------------------------------------------Main entrypoint-----------------------------------------------------* +*#########################################################################################################################*/ +#include "../main_impl.h" + +int main(int argc, char** argv) { + SetupProgram(argc, argv); + while (Window_Main.Exists) { + RunProgram(argc, argv); + } + + Window_Free(); + return 0; +} + /*########################################################################################################################* *------------------------------------------------------Logging/Time-------------------------------------------------------* @@ -313,6 +328,15 @@ cc_result Process_StartOpen(const cc_string* args) { void Process_Exit(cc_result code) { exit(code); } +cc_result Process_StartGame2(const cc_string* args, int numArgs) { + Platform_LogConst("START CLASSICUBE"); + return SetGameArgs(args, numArgs); +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + return 0; +} + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------*