From 1eb1af9389eda7a98445ee96b1d503ce0e55a079 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 1 Jun 2025 11:36:10 +1000 Subject: [PATCH] DOS: Launcher shows Exit button now --- misc/UWP/Platform_UWP.cpp | 5 +++-- src/LScreens.c | 24 +++++++++++------------- src/Platform.h | 3 +++ src/Platform_Dreamcast.c | 2 +- src/Platform_MSDOS.c | 2 +- src/Platform_MacClassic.c | 1 + src/Platform_Symbian.cpp | 2 +- src/Window_MSDOS.c | 10 +++++++++- src/_PlatformConsole.h | 2 +- 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/misc/UWP/Platform_UWP.cpp b/misc/UWP/Platform_UWP.cpp index 9727b91b1..c42713b99 100644 --- a/misc/UWP/Platform_UWP.cpp +++ b/misc/UWP/Platform_UWP.cpp @@ -37,7 +37,7 @@ const cc_result ReturnCode_SocketDropped = WSAECONNRESET; const char* Platform_AppNameSuffix = ""; cc_bool Platform_ReadonlyFilesystem; -cc_bool Platform_SingleProcess = true; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; #define UWP_STRING(str) ((wchar_t*)(str)->uni) /*########################################################################################################################* @@ -550,7 +550,8 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) { cc_result res; int len, i; - if (Platform_SingleProcess) return SetGameArgs(args, numArgs); + if (Platform_IsSingleProcess()) return SetGameArgs(args, numArgs); + if ((res = Process_RawGetExePath(&path, &len))) return res; si.wide.cb = sizeof(STARTUPINFOW); diff --git a/src/LScreens.c b/src/LScreens.c index 0ae4aea7f..f83b7563f 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -839,11 +839,9 @@ static void MainScreen_ApplyUpdateLabel(struct MainScreen* s) { } } -#if defined CC_BUILD_CONSOLE || defined CC_BUILD_SYMBIAN static void MainScreen_ExitApp(void* w) { Window_Main.Exists = false; } -#endif static void MainScreen_Activated(struct LScreen* s_) { struct MainScreen* s = (struct MainScreen*)s_; @@ -880,18 +878,18 @@ static void MainScreen_Activated(struct LScreen* s_) { LButton_Add(s, &s->btnOptions, 100, 35, "Options", SwitchToSettings, main_btnOptions); -#if defined CC_BUILD_CONSOLE || defined CC_BUILD_SYMBIAN - LLabel_Add(s, &s->lblUpdate, "&eChecking..", main_lblUpdate_N); - LButton_Add(s, &s->btnUpdates, 100, 35, "Exit", - MainScreen_ExitApp, main_btnUpdates); -#else - LLabel_Add(s, &s->lblUpdate, "&eChecking..", - Updater_Supported ? main_lblUpdate_N : main_lblUpdate_H); - if (Updater_Supported) { - LButton_Add(s, &s->btnUpdates, 100, 35, "Updates", - SwitchToUpdates, main_btnUpdates); + if (Platform_Flags & PLAT_FLAG_APP_EXIT) { + LLabel_Add(s, &s->lblUpdate, "&eChecking..", main_lblUpdate_N); + LButton_Add(s, &s->btnUpdates, 100, 35, "Exit", + MainScreen_ExitApp, main_btnUpdates); + } else { + LLabel_Add(s, &s->lblUpdate, "&eChecking..", + Updater_Supported ? main_lblUpdate_N : main_lblUpdate_H); + if (Updater_Supported) { + LButton_Add(s, &s->btnUpdates, 100, 35, "Updates", + SwitchToUpdates, main_btnUpdates); + } } -#endif #ifdef CC_BUILD_NETWORKING s->btnResume.OnHover = MainScreen_ResumeHover; diff --git a/src/Platform.h b/src/Platform.h index d3977b092..6074e6421 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -66,6 +66,9 @@ cc_result Platform_GetEntropy(void* data, int len); /* Whether the launcher and game must both be run in the same process */ /* (e.g. can't start a separate process on Mobile or Consoles) */ #define PLAT_FLAG_SINGLE_PROCESS 0x01 +/* Whether button in the launcher should be available to exit the app */ +/* (e.g. necessary in MS DOS, game consoles ) */ +#define PLAT_FLAG_APP_EXIT 0x02 /* Platform specific runtime behaviour flags (See PLAT_FLAG members) */ extern cc_uint8 Platform_Flags; diff --git a/src/Platform_Dreamcast.c b/src/Platform_Dreamcast.c index 1ba30c018..ce5c5e054 100644 --- a/src/Platform_Dreamcast.c +++ b/src/Platform_Dreamcast.c @@ -236,7 +236,7 @@ static int VMUFile_Do(cc_file* file, int mode) { data = Mem_Alloc(len, 1, "VMU data"); fs_read(fd, data, len); - err = vmu_pkg_parse(data, len, &pkg); + err = vmu_pkg_parse(data, &pkg); fs_close(fd); } diff --git a/src/Platform_MSDOS.c b/src/Platform_MSDOS.c index 2e3829e6f..8b6c6845d 100644 --- a/src/Platform_MSDOS.c +++ b/src/Platform_MSDOS.c @@ -33,7 +33,7 @@ const cc_result ReturnCode_SocketWouldBlock = -10002; const cc_result ReturnCode_SocketDropped = -10002; const char* Platform_AppNameSuffix = " DOS"; -cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; cc_bool Platform_ReadonlyFilesystem; /*########################################################################################################################* diff --git a/src/Platform_MacClassic.c b/src/Platform_MacClassic.c index 8e3d30986..592c9c595 100644 --- a/src/Platform_MacClassic.c +++ b/src/Platform_MacClassic.c @@ -34,6 +34,7 @@ const char* Platform_AppNameSuffix = " MAC 68k"; #else const char* Platform_AppNameSuffix = " MAC PPC"; #endif + cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_Symbian.cpp b/src/Platform_Symbian.cpp index c4249d842..f394d7a68 100644 --- a/src/Platform_Symbian.cpp +++ b/src/Platform_Symbian.cpp @@ -52,7 +52,7 @@ const cc_result ReturnCode_SocketDropped = EPIPE; #define SUPPORTS_GETADDRINFO 1 const char* Platform_AppNameSuffix = ""; -cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Window_MSDOS.c b/src/Window_MSDOS.c index 3e4388aaa..a1cc10a97 100644 --- a/src/Window_MSDOS.c +++ b/src/Window_MSDOS.c @@ -192,7 +192,15 @@ void Window_Init(void) { Mouse_Init(); } -void Window_Free(void) { } +void Window_Free(void) { + if (__djgpp_nearptr_enable() == 0) return; + + char* screen = (char*)0xa0000 + __djgpp_conventional_base; + Mem_Set(screen, 0, DISP_WIDTH * DISP_HEIGHT); + + __djgpp_nearptr_disable(); + // TODO restore VGA mode and palette? +} static void DoCreateWindow(int width, int height) { Window_Main.Width = 320; diff --git a/src/_PlatformConsole.h b/src/_PlatformConsole.h index d2c7b69ad..c2701a2ed 100644 --- a/src/_PlatformConsole.h +++ b/src/_PlatformConsole.h @@ -1,4 +1,4 @@ -cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS; +cc_uint8 Platform_Flags = PLAT_FLAG_SINGLE_PROCESS | PLAT_FLAG_APP_EXIT; /*########################################################################################################################*