From aef9cb26cb84549cb142fdacac1c9ddb5d06faf5 Mon Sep 17 00:00:00 2001 From: Bottersnike Date: Thu, 16 Feb 2023 06:39:14 +0000 Subject: [PATCH] Work on master --- src/micetools/dll/hooks/registry.c | 6 +- src/micetools/dll/util/log.c | 2 +- src/micetools/micemaster/appLauncher.c | 126 +++++++++++++----- src/micetools/micemaster/appLauncher.h | 28 +++- .../micemaster/callbacks/foreground.c | 36 +++-- src/micetools/micemaster/config.def | 27 ++-- src/micetools/micemaster/main.c | 58 +++++--- src/micetools/micemaster/mxm.c | 36 ++++- src/micetools/micemaster/mxm.h | 20 +-- subprojects/inih_dep/meson.build | 100 ++++++-------- 10 files changed, 289 insertions(+), 150 deletions(-) diff --git a/src/micetools/dll/hooks/registry.c b/src/micetools/dll/hooks/registry.c index e805dd5..22e0b5d 100644 --- a/src/micetools/dll/hooks/registry.c +++ b/src/micetools/dll/hooks/registry.c @@ -22,7 +22,11 @@ LSTATUS WINAPI FakeRegDeleteKeyValueA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpValue LSTATUS WINAPI FakeRegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcchName, LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcchClass, PFILETIME lpftLastWriteTime) { - log_trace("registry", "RegEnumKeyExA %08x %s", hKey, lpName); + log_trace("registry", "RegEnumKeyExA %08x[%d]", hKey, dwIndex); + if (dwIndex == 0) { + strcpy(lpName, "Direct3D HAL"); + return ERROR_SUCCESS; + } return ERROR_NO_MORE_ITEMS; } LSTATUS WINAPI FakeRegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName, diff --git a/src/micetools/dll/util/log.c b/src/micetools/dll/util/log.c index 7fd0e00..de88533 100644 --- a/src/micetools/dll/util/log.c +++ b/src/micetools/dll/util/log.c @@ -173,7 +173,7 @@ VOID trace_hook(char* output) { void setup_logging() { // Force stdio even for GUI applications - // AttachConsole(ATTACH_PARENT_PROCESS); + AttachConsole(ATTACH_PARENT_PROCESS); // Enable colour in CMD HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/src/micetools/micemaster/appLauncher.c b/src/micetools/micemaster/appLauncher.c index b898288..c4319fe 100644 --- a/src/micetools/micemaster/appLauncher.c +++ b/src/micetools/micemaster/appLauncher.c @@ -1,15 +1,53 @@ -#include "appLauncher.h" - #include #include +#include #include -#include "config.h" +#include "mxm.h" + +/* +"SOFTWARE\\Microsoft\\Direct3D\\Drivers" + "Direct3D HAL" /3 +"SOFTWARE\\Microsoft\\Direct3D" + "Drivers" /2 +"SOFTWARE\\Microsoft\\DirectDraw" + "Compatibility" /1 +"SOFTWARE\\Microsoft\\DirectInput" + "Compatibility" /1 +"SOFTWARE\\Microsoft\\DirectMusic" + "Defaults" /2 + "GMFilePath" /1 +*/ void appLauncherDefaultRegSet() { // TODO: This } +#ifdef MXM_APM2 +void nxAuthStart(LPPROCESS_INFORMATION procInfo) { + if (procInfo->hProcess != NULL) return; + + STARTUPINFOW startupInfo = { 0 }; + startupInfo.cb = 0x44; + startupInfo.dwFlags = 1; + startupInfo.wShowWindow = 0; + + wchar_t commandLine[64] = { 0 }; + wchar_t path[64] = { 0 }; + + MultiByteToWideChar(0, 0, Config.binary.nxAuth, -1, commandLine, + _countof(commandLine)); + wcscpy_s(path, _countof(path), commandLine); + PathRemoveFileSpecW(path); + + BOOL success = + CreateProcessW(NULL, commandLine, NULL, NULL, 0, 0, NULL, NULL, &startupInfo, procInfo); + if (!success) { + amiDebugLog("ERROR : start %S\n", commandLine); + } +} +#endif + char GAME_EXTENSIONS[3][4] = { { 'c', 'o', 'm', '\0' }, { 'e', 'x', 'e', '\0' }, @@ -19,7 +57,7 @@ char GAME_EXTENSIONS[3][4] = { DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { if (appInfo == NULL || appInfo->m_appLauncher == NULL) { amiDebugLog("param error %p %p", appInfo, appInfo->m_appLauncher); - return 0xffffffff; + return (DWORD)-1; } PROCESS_INFORMATION processInformation; @@ -34,27 +72,27 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { struct _finddata_t next_file; bool skipSpawn = false; - bool appUser = false; + appLauncherUser_t launchUser = appLauncherUserSystemUser; switch (appInfo->m_mode) { - case 1: + case appLauncherLaunchSegabootR: sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, Config.binary.segaboot_r); break; - case 3: + case appLauncherLaunchSegabootTR: sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, Config.binary.segaboot_tr); break; - case 5: + case appLauncherLaunchSegabootD: sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, Config.binary.segaboot_d); break; - case 6: + case appLauncherLaunchSegaboot: sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, Config.binary.segaboot); break; - case 2: + case appLauncherLaunchGame: if (appInfo->m_path[0] != '\0') { sprintf_s(commandLine, sizeof commandLine, "%s", appInfo->m_path); hFile = _findfirst(commandLine, &next_file); @@ -80,7 +118,7 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { if (strcmp(findPath, next_file.name) == 0) { sprintf_s(commandLine, 0x40, "%s%s", "x:\\", findPath); _findclose(hFile); - appUser = true; + launchUser = appLauncherUserAppUser; goto game_found; } } @@ -93,7 +131,7 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { game_found: break; - case 4: + case appLauncherLaunchGameTest: sprintf_s(findPath, 0x40, "%s%s.*", "x:\\", "gametest"); hFile = _findfirst(findPath, &next_file); if (hFile == -1) { @@ -110,7 +148,7 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { if (strcmp(findPath, next_file.name) == 0) { sprintf_s(commandLine, 0x40, "%s%s", "x:\\", findPath); _findclose(hFile); - appUser = true; + launchUser = appLauncherUserAppUser; goto gametest_found; } } @@ -120,11 +158,18 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, Config.binary.segaboot_r); _findclose(hFile); - appUser = true; + launchUser = appLauncherUserAppUser; gametest_found: break; +#ifdef MXM_APM2 + case appLauncherLaunchAPM2: + sprintf_s(commandLine, sizeof commandLine, "%s%s", "n:\\", "game.bat"); + launchUser = appLauncherUserAppUser; + break; +#endif + default: amiDebugLog("Error : Error Process"); sprintf_s(commandLine, sizeof commandLine, "%s%s", Config.dir.execute, @@ -133,21 +178,27 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { ZeroMemory(&startupInfoA, sizeof startupInfoA); startupInfoA.cb = sizeof startupInfoA; - startupInfoA.dwFlags = 1; - startupInfoA.wShowWindow = 1; + startupInfoA.dwFlags = STARTF_USESHOWWINDOW; + startupInfoA.wShowWindow = SW_NORMAL; ZeroMemory(&startupInfoW, sizeof startupInfoW); startupInfoW.cb = sizeof startupInfoW; - startupInfoW.dwFlags = 1; - startupInfoW.wShowWindow = 1; + startupInfoW.dwFlags = STARTF_USESHOWWINDOW; + startupInfoW.wShowWindow = SW_NORMAL; if (!skipSpawn) { BOOL success; - if (appUser) { + + if (launchUser == appLauncherUserSystemUser) { + amiDebugLog("Creating process: %s", commandLine); + success = CreateProcessA(NULL, commandLine, NULL, NULL, FALSE, + CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS, NULL, NULL, + &startupInfoA, &processInformation); + } else { // appLauncherUserAppUser DWORD dwCreationFlags = 0; if (strstr(commandLine, "bat") != NULL) { dwCreationFlags = CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS; - startupInfoW.wShowWindow = 0; + startupInfoW.wShowWindow = SW_HIDE; } ZeroMemory(wCommandLine, sizeof wCommandLine); @@ -172,17 +223,14 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { success = CreateProcessWithLogonW(username, NULL, password, 0, NULL, wCommandLine, dwCreationFlags, NULL, workingDirectory, &startupInfoW, &processInformation); - } else { - amiDebugLog("Creating process: %s", commandLine); - success = CreateProcessA(NULL, commandLine, NULL, NULL, FALSE, - CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS, NULL, NULL, - &startupInfoA, &processInformation); } if (!success) { - CloseHandle(processInformation.hProcess); - CloseHandle(processInformation.hThread); - amiDebugLog("ERROR : Close Process %s", commandLine); + if (processInformation.hProcess != INVALID_HANDLE_VALUE) + CloseHandle(processInformation.hProcess); + if (processInformation.hThread != INVALID_HANDLE_VALUE) + CloseHandle(processInformation.hThread); + amiDebugLog("ERROR : Close Process %ghis", commandLine); } else { if (WaitForSingleObject(processInformation.hProcess, INFINITE) == WAIT_FAILED) { amiDebugLog("WaitForSingleObject Error:%d", GetLastError()); @@ -192,11 +240,19 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { } } +#ifdef MXM_APM2 + if (appInfo->m_mode == appLauncherLaunchSegabootR || + appInfo->m_mode == appLauncherLaunchSegabootD || + appInfo->m_mode == appLauncherLaunchSegaboot) { + nxAuthStart(&appInfo->m_nxAuthProcInfo); + } +#endif + pcpa_t *stream = &(appInfo->m_appLauncher->m_pcp); e_pcpa_t err; if ((err = pcpaInitStream(stream)) != e_pcpa_ok) { amiDebugLog("Error pcpaInitStream. Code %d", err); - return 0xffffffff; + return (DWORD)-1; } do { err = pcpaOpenClient(stream, "127.0.0.1", 40100, 60000, TIMEOUT_NONE); @@ -206,13 +262,13 @@ DWORD __stdcall appLauncherAppThread(appLauncherAppInfo_t *appInfo) { if (pcpaSetSendPacket(stream, "mxmaster.foreground.active", "0") == NULL) { pcpaClose(stream); amiDebugLog("Error pcpaSetSendPacket return NULL"); - return 0xffffffff; + return (DWORD)-1; } if ((err = pcpaAccessClient(stream, TIMEOUT_NONE)) != e_pcpa_ok) { amiDebugLog("Error : Not Access Master Thread. Code %d", err); pcpaClose(stream); - return 0xffffffff; + return (DWORD)-1; } pcpaClose(stream); return 0; @@ -224,14 +280,16 @@ int appLauncherCreateThread(appLauncherAppInfo_t *appInfo, appLauncher_t *appLau return 3; } - unsigned int mode = appInfo->m_mode; + appLauncherLaunch_t mode = appInfo->m_mode; appLauncher->m_appInfo.m_mode = mode; strcpy_s(appLauncher->m_appInfo.m_path, sizeof appLauncher->m_appInfo.m_path, appInfo->m_path); - if (mode == 1 || mode == 3 || mode == 5 || mode == 6) appLauncherDefaultRegSet(); + if (mode == appLauncherLaunchSegabootR || mode == appLauncherLaunchSegabootTR || + mode == appLauncherLaunchSegabootD || mode == appLauncherLaunchSegaboot) + appLauncherDefaultRegSet(); HANDLE hThread = CreateThread(NULL, 0, &appLauncherAppThread, &appLauncher->m_appInfo, 0, - &appLauncher->m_threadAddr); + &appLauncher->m_threadAddr); appLauncher->m_hThread = hThread; if (hThread == 0) { diff --git a/src/micetools/micemaster/appLauncher.h b/src/micetools/micemaster/appLauncher.h index fbd3ce0..ea07e66 100644 --- a/src/micetools/micemaster/appLauncher.h +++ b/src/micetools/micemaster/appLauncher.h @@ -1,13 +1,36 @@ +#include #include #include #include "lib/libpcp/libpcp.h" +typedef enum appLauncherUser_ { + appLauncherUserSystemUser = 0, + appLauncherUserAppUser, +} appLauncherUser_t; + +// TODO: Rename the segaboots +typedef enum appLauncherLaunch_ { + appLauncherLaunchSegabootR = 1, + appLauncherLaunchGame, + appLauncherLaunchSegabootTR, + appLauncherLaunchGameTest, + appLauncherLaunchSegabootD, + appLauncherLaunchSegaboot, +#ifdef MXM_APM2 + appLauncherLaunchAPM2 = 10, +#endif +} appLauncherLaunch_t; + struct appLauncher_; typedef struct { struct appLauncher_* m_appLauncher; - unsigned int m_mode; + appLauncherLaunch_t m_mode; char m_path[64]; +#ifdef MXM_APM2 + // mxmaster seems to be doing m_appLauncher[1] which is weird and so we're not gonna do that + PROCESS_INFORMATION m_nxAuthProcInfo; +#endif } appLauncherAppInfo_t; typedef struct appLauncher_ { @@ -20,4 +43,7 @@ typedef struct appLauncher_ { wchar_t m_password[64]; } appLauncher_t; +#ifdef MXM_APM2 +void nxAuthStart(LPPROCESS_INFORMATION procInfo); +#endif int appLauncherCreateThread(appLauncherAppInfo_t* appInfo, appLauncher_t* appLauncher); diff --git a/src/micetools/micemaster/callbacks/foreground.c b/src/micetools/micemaster/callbacks/foreground.c index 596e691..d02fd6d 100644 --- a/src/micetools/micemaster/callbacks/foreground.c +++ b/src/micetools/micemaster/callbacks/foreground.c @@ -66,9 +66,12 @@ void mxmPcpNextFgprocess(pcpa_t* stream, MX_MASTER* mxMaster) { } if (lCommand >= 0 && lCommand <= 5) { +#ifdef MXM_APM2 + lCommand = apmsTranslateNext(lCommand); +#endif mxMaster->m_next = lCommand; - if (lCommand == 2) { + if (lCommand == appLauncherLaunchGame) { if (path == NULL) mxMaster->m_nextPath[0] = '\0'; else { @@ -89,7 +92,7 @@ void mxmPcpNextFgprocess(pcpa_t* stream, MX_MASTER* mxMaster) { sprintf_s(next, sizeof next, "%d", mxMaster->m_next); pcpaSetSendPacket(stream, MXM_FG_NEXT, next); - if (lCommand != 1) return; + if (lCommand != appLauncherLaunchSegabootR) return; if (errormsg != NULL) { if (!mxMaster->m_develop) { @@ -222,22 +225,29 @@ void mxmPcpGetStartCount(pcpa_t* stream, MX_MASTER* mxMaster) { } long lWhich = strtol(command, NULL, 10); +#ifdef MXM_APM2 + lWhich = apmsTranslateNext(lWhich); +#endif + int count = 0; bool valid = false; switch (lWhich) { - case 1: + case appLauncherLaunchSegabootR: count = mxMaster->m_countSystemBoot; valid = true; break; - case 2: + case appLauncherLaunchGame: +#ifdef MXM_APM2 + case appLauncherLaunchAPM2: +#endif count = mxMaster->m_countGameBoot; valid = true; break; - case 3: + case appLauncherLaunchSegabootTR: count = mxMaster->m_countSystemTest; valid = true; break; - case 4: + case appLauncherLaunchGameTest: count = mxMaster->m_countGameTest; valid = true; break; @@ -273,23 +283,29 @@ void mxmPcpSetStartCount(pcpa_t* stream, MX_MASTER* mxMaster) { } long lWhich = strtol(command, NULL, 10); +#ifdef MXM_APM2 + lWhich = apmsTranslateNext(lWhich); +#endif long lCount = strtol(sCount, NULL, 10); bool valid = false; switch (lWhich) { - case 1: + case appLauncherLaunchSegabootR: mxMaster->m_countSystemBoot = lCount; valid = true; break; - case 2: + case appLauncherLaunchGame: +#ifdef MXM_APM2 + case appLauncherLaunchAPM2: +#endif mxMaster->m_countGameBoot = lCount; valid = true; break; - case 3: + case appLauncherLaunchSegabootTR: mxMaster->m_countSystemTest = lCount; valid = true; break; - case 4: + case appLauncherLaunchGameTest: mxMaster->m_countGameTest = lCount; valid = true; break; diff --git a/src/micetools/micemaster/config.def b/src/micetools/micemaster/config.def index e8eb6f6..dee7818 100644 --- a/src/micetools/micemaster/config.def +++ b/src/micetools/micemaster/config.def @@ -11,19 +11,26 @@ SECTION(dir, "Base directories") CFG_str(dir, execute, "c:\\System\\Execute\\", "The system bootstrap directory") CFG_str(dir, system, "s:\\", "The system binary directory") +#ifdef MXM_APM2 +CFG_str(dir, execute_firm, "c:\\Syetem\\Execute\\firm\\", "") +CFG_str(dir, firm, "s:\\firm\\", "") +#endif CFG_str(dir, game, "x:\\", "The game working directory") ENDSECTION(dir) -SECTION(binary, "Binary names (command line arguments can be included)") -COMMENT("The following values are relative to [dir.system]") -CFG_str(binary, mxkeychip, "mxkeychip.exe", "") -CFG_str(binary, mxnetwork, "mxnetwork.exe -p 40104", "") -CFG_str(binary, mxstorage, "mxstorage.exe", "") -CFG_str(binary, mxjvs, "mxjvs.exe", "") -CFG_str(binary, mxinstaller, "mxinstaller.exe -cmdport 40102 -binport 40103", "") -CFG_str(binary, mxgcatcher, "mxgcatcher.exe", "") -CFG_str(binary, mxgfetcher, "mxgfetcher.exe", "") -CFG_str(binary, mxgdeliver, "mxgdeliver.exe", "") +SECTION(binary, "Binaries that will be executed during startup") +CFG_str(binary, mxkeychip, "s:\\mxkeychip.exe", "") +CFG_str(binary, mxnetwork, "s:\\mxnetwork.exe -p 40104", "") +CFG_str(binary, mxstorage, "s:\\mxstorage.exe", "") +CFG_str(binary, mxjvs, "s:\\mxjvs.exe", "") +#ifdef MXM_APM2 +CFG_str(binary, nxMount, "s:\\nxMount.exe", "") +CFG_str(binary, nxAuth, "c:\\System\\Execute\\nxAuth.exe", "") +#endif +CFG_str(binary, mxinstaller, "s:\\mxinstaller.exe -cmdport 40102 -binport 40103", "") +CFG_str(binary, mxgcatcher, "s:\\mxgcatcher.exe", "") +CFG_str(binary, mxgfetcher, "s:\\mxgfetcher.exe", "") +CFG_str(binary, mxgdeliver, "s:\\mxgdeliver.exe", "") COMMENT("--------------------------------------------------") COMMENT("The following values are relative to [dir.execute]") CFG_str(binary, segaboot, "mxsegaboot.exe", "") diff --git a/src/micetools/micemaster/main.c b/src/micetools/micemaster/main.c index 331ee53..6eb4b97 100644 --- a/src/micetools/micemaster/main.c +++ b/src/micetools/micemaster/main.c @@ -70,6 +70,13 @@ bool mxMasterInit(MX_MASTER* mxMaster) { mxmCopySystemFile("d3dref9.dll"); mxmCopySystemFile("mxsegaboot_2052.dll"); +#ifdef MXM_APM2 + mxmCopySystemFile("nxAuth.exe"); + mxmCopySystemFile("SBYG_Table.dat"); + mxmCopySystemFirmwareFile("315-6691A.bin"); + mxmCopySystemFirmwareFile("TN32MSEC003S_V12.hex"); +#endif + return mxMasterInitPcp(mxMaster); } @@ -180,19 +187,28 @@ bool mxMasterLoadKeychipInfo(MX_MASTER* mxMaster) { } void mxMasterSysProcessesStart(MX_MASTER* mxMaster) { - char startup[4][128]; + char startup[ +#ifdef MXM_APM2 + 5 +#else + 4 +#endif + ][128]; strcpy_s(startup[0], sizeof startup[0], Config.binary.mxkeychip); strcpy_s(startup[1], sizeof startup[1], Config.binary.mxnetwork); strcpy_s(startup[2], sizeof startup[2], Config.binary.mxstorage); strcpy_s(startup[3], sizeof startup[3], Config.binary.mxjvs); +#ifdef MXM_APM2 + strcpy_s(startup[4], sizeof startup[4], Config.binary.nxMount); +#endif STARTUPINFOA startupInfo; PROCESS_INFORMATION processInformation; DWORD dwCreationFlags; BOOL ret; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < _countof(startup); i++) { dwCreationFlags = CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS; ZeroMemory(&startupInfo, sizeof startupInfo); startupInfo.cb = sizeof startupInfo; @@ -291,28 +307,30 @@ void mxMasterFirstFgProcessesStart(MX_MASTER* mxMaster) { appLauncherAppInfo_t appInfo; appInfo.m_mode = mxMaster->m_current; - if (appInfo.m_mode == 1) { - appInfo.m_mode = 6; - } else if (appInfo.m_mode != 2 && appInfo.m_mode != 3 && appInfo.m_mode != 4 && - appInfo.m_mode != 5) { + if (appInfo.m_mode == appLauncherLaunchSegabootR) { + appInfo.m_mode = appLauncherLaunchSegaboot; + } else if (appInfo.m_mode != appLauncherLaunchGame && + appInfo.m_mode != appLauncherLaunchSegabootTR && + appInfo.m_mode != appLauncherLaunchGameTest && + appInfo.m_mode != appLauncherLaunchSegabootD) { amiDebugLog("Error : Not Process Mode"); mxMaster->m_current = 1; - appInfo.m_mode = 6; + appInfo.m_mode = appLauncherLaunchSegaboot; } switch (appInfo.m_mode) { - case 1: - case 5: - case 6: + case appLauncherLaunchSegabootR: + case appLauncherLaunchSegabootD: + case appLauncherLaunchSegaboot: mxMaster->m_countSystemBoot = mxMaster->m_countSystemBoot + 1; break; - case 2: + case appLauncherLaunchGame: mxMaster->m_countGameBoot = mxMaster->m_countGameBoot + 1; break; - case 3: + case appLauncherLaunchSegabootTR: mxMaster->m_countSystemTest = mxMaster->m_countSystemTest + 1; break; - case 4: + case appLauncherLaunchGameTest: mxMaster->m_countGameTest = mxMaster->m_countGameTest + 1; break; } @@ -391,23 +409,23 @@ void mxMasterMainLoop(MX_MASTER* mxMaster) { if (!mxMaster->m_develop || mxMaster->m_changeIsSpawn) { appInfo[0].m_mode = mxMaster->m_current; mxMaster->m_changeIsSpawn = 0; - if (appInfo[0].m_mode == 2) { + if (appInfo[0].m_mode == appLauncherLaunchGame) { sprintf_s(appInfo[0].m_path, sizeof appInfo[0].m_path, "%s", mxMaster->m_nextPath); } switch (appInfo[0].m_mode) { - case 1: - case 5: - case 6: + case appLauncherLaunchSegabootR: + case appLauncherLaunchSegabootD: + case appLauncherLaunchSegaboot: mxMaster->m_countSystemBoot++; break; - case 2: + case appLauncherLaunchGame: mxMaster->m_countGameBoot++; break; - case 3: + case appLauncherLaunchSegabootTR: mxMaster->m_countSystemTest++; break; - case 4: + case appLauncherLaunchGameTest: mxMaster->m_countGameTest++; } appLauncherCreateThread(appInfo, mxMaster->m_appLauncher); diff --git a/src/micetools/micemaster/mxm.c b/src/micetools/micemaster/mxm.c index f87fe2b..e0f15c4 100644 --- a/src/micetools/micemaster/mxm.c +++ b/src/micetools/micemaster/mxm.c @@ -4,6 +4,27 @@ #define TICK_MS 16 +#ifdef MXM_APM2 +appLauncherLaunch_t apmsTranslateNext(appLauncherLaunch_t which) { + switch (which) { + case appLauncherLaunchSegabootR: + return appLauncherLaunchSegabootR; + case appLauncherLaunchGame: + return appLauncherLaunchGame; + case appLauncherLaunchSegabootTR: + return appLauncherLaunchSegabootTR; + case appLauncherLaunchGameTest: + return appLauncherLaunchGameTest; + // TODO: Inversigate this. `segaboot -d` translates to `n:\\game.bat` for APM? + case appLauncherLaunchSegabootD: + return appLauncherLaunchAPM2; + default: + return 0; + } +} + +#endif + void mxmBeforeBinaryCallback(pcpa_t *stream, MX_MASTER *mxMaster) { pcpaSetSendBinaryBuffer(stream, mxMaster->m_binaryMessage, mxMaster->m_binaryMessageLen); } @@ -26,6 +47,20 @@ void mxmCopySystemFile(char *filename) { if (!PathFileExistsA(dest)) CopyFileA(src, dest, 0); } +void mxmCopySystemFirmwareFile(char *filename) { + char dest[256]; + char src[256]; + + sprintf_s(src, sizeof src, "%s%s", Config.dir.firm, filename); + sprintf_s(dest, sizeof dest, "%s%s", Config.dir.execute_firm, filename); + + if (!PathFileExistsA(src)) { + amiDebugLog("Error copy %s not exist", src); + return; + } + if (!PathFileExistsA(dest)) CopyFileA(src, dest, 0); +} + int mxmBackupEventlog(int destination) { if (!MxmEventLog.m_logDriveFound) return 0; @@ -42,7 +77,6 @@ int mxmBackupEventlog(int destination) { DWORD numberOfRecords = 0; if (!GetNumberOfEventLogRecords(hEventLog, &numberOfRecords)) { - printf("%d\n", hEventLog); amiDebugLog("Error GetNumberOf-EventLogRecords(%d). Code %d", destination, GetLastError()); CloseEventLog(hEventLog); return -3; diff --git a/src/micetools/micemaster/mxm.h b/src/micetools/micemaster/mxm.h index 684133e..789dbaf 100644 --- a/src/micetools/micemaster/mxm.h +++ b/src/micetools/micemaster/mxm.h @@ -1,5 +1,7 @@ #include +#define MXM_APM2 + #include "appLauncher.h" #include "callbacks/callbacks.h" #include "config.h" @@ -7,20 +9,6 @@ #include "lib/libpcp/libpcp.h" #include "mxmEventLog.h" -typedef enum { - mxMasterStartType_0 = 0, - mxMasterStartType_1 = 1, // Stores system message - mxMasterStartType_2 = 2, // Stores "path" into m_nextPath - mxMasterStartType_3 = 3, - mxMasterStartType_4 = 4, - mxMasterStartType_5 = 5, - - // Segaboot: 1, 5, 6 - // Gameboot: 2 - // Systemtest: 3 - -} mxMasterStartType_t; - typedef struct MX_MASTER_ { ushort m_controlPort; ushort m_dataPort; @@ -64,3 +52,7 @@ void mxmBeforeBinaryCallback(pcpa_t* stream, MX_MASTER* mxMaster); void mxmAfterBinaryCallback(pcpa_t* stream, MX_MASTER* mxMaster); void mxmCopySystemFile(char* filename); int mxmBackupEventlog(int destination); +#ifdef MXM_APM2 +void mxmCopySystemFirmwareFile(char* filename); +appLauncherLaunch_t apmsTranslateNext(appLauncherLaunch_t which); +#endif diff --git a/subprojects/inih_dep/meson.build b/subprojects/inih_dep/meson.build index 4f16b33..f7005e3 100644 --- a/subprojects/inih_dep/meson.build +++ b/subprojects/inih_dep/meson.build @@ -6,55 +6,50 @@ project('inih', #### options #### arg_static = [] -distro_install = get_option('distro_install') extra_args = [] -if distro_install - pkg = import('pkgconfig') -else - if not get_option('multi-line_entries') - arg_static += ['-DINI_ALLOW_MULTILINE=0'] - endif - if not get_option('utf-8_bom') - arg_static += ['-DINI_ALLOW_BOM=0'] - endif - if not get_option('inline_comments') - arg_static += ['-DINI_ALLOW_INLINE_COMMENTS=0'] - endif - inline_comment_prefix = get_option('inline_comment_prefix') - if inline_comment_prefix != ';' - arg_static += ['-DINI_INLINE_COMMENT_PREFIXES="' + inline_comment_prefix + '"'] - endif - sol_comment_prefix = get_option('start-of-line_comment_prefix') - if sol_comment_prefix != ';#' - arg_static += ['-DINI_START_COMMENT_PREFIXES="' + start-of-line_comment_prefix + '"'] - endif - if get_option('allow_no_value') - arg_static += ['-DINI_ALLOW_NO_VALUE=1'] - endif - if get_option('stop_on_first_error') - arg_static += ['-DINI_STOP_ON_FIRST_ERROR=1'] - endif - if get_option('report_line_numbers') - arg_static += ['-DINI_HANDLER_LINENO=1'] - endif - if get_option('call_handler_on_new_section') - arg_static += ['-DINI_CALL_HANDLER_ON_NEW_SECTION=1'] - endif - if get_option('use_heap') - arg_static += ['-DINI_USE_STACK=0'] - endif - max_line_length = get_option('max_line_length') - if max_line_length != 200 - arg_static += ['-DINI_MAX_LINE=' + max_line_length.to_string()] - endif - initial_malloc_size = get_option('initial_malloc_size') - if initial_malloc_size != 200 - arg_static += ['-DINI_INITIAL_ALLOC=' + initial_malloc_size.to_string()] - endif - if get_option('allow_realloc') - arg_static += ['-DINI_ALLOW_REALLOC=1'] - endif +if not get_option('multi-line_entries') + arg_static += ['-DINI_ALLOW_MULTILINE=0'] +endif +if not get_option('utf-8_bom') + arg_static += ['-DINI_ALLOW_BOM=0'] +endif +if not get_option('inline_comments') + arg_static += ['-DINI_ALLOW_INLINE_COMMENTS=0'] +endif +inline_comment_prefix = get_option('inline_comment_prefix') +if inline_comment_prefix != ';' + arg_static += ['-DINI_INLINE_COMMENT_PREFIXES="' + inline_comment_prefix + '"'] +endif +sol_comment_prefix = get_option('start-of-line_comment_prefix') +if sol_comment_prefix != ';#' + arg_static += ['-DINI_START_COMMENT_PREFIXES="' + start-of-line_comment_prefix + '"'] +endif +if get_option('allow_no_value') + arg_static += ['-DINI_ALLOW_NO_VALUE=1'] +endif +if get_option('stop_on_first_error') + arg_static += ['-DINI_STOP_ON_FIRST_ERROR=1'] +endif +if get_option('report_line_numbers') + arg_static += ['-DINI_HANDLER_LINENO=1'] +endif +if get_option('call_handler_on_new_section') + arg_static += ['-DINI_CALL_HANDLER_ON_NEW_SECTION=1'] +endif +if get_option('use_heap') + arg_static += ['-DINI_USE_STACK=0'] +endif +max_line_length = get_option('max_line_length') +if max_line_length != 200 + arg_static += ['-DINI_MAX_LINE=' + max_line_length.to_string()] +endif +initial_malloc_size = get_option('initial_malloc_size') +if initial_malloc_size != 200 + arg_static += ['-DINI_INITIAL_ALLOC=' + initial_malloc_size.to_string()] +endif +if get_option('allow_realloc') + arg_static += ['-DINI_ALLOW_REALLOC=1'] endif if host_machine.system() == 'windows' @@ -74,21 +69,10 @@ lib_inih = static_library('inih', ['ini.c'], include_directories : inc_inih, c_args : [arg_static, extra_args], - install : distro_install, # soversion : '0', gnu_symbol_visibility: 'hidden' ) -if distro_install - install_headers('ini.h') - - pkg.generate(lib_inih, - name : 'inih', - description : 'simple .INI file parser', - extra_cflags : extra_args, - ) -endif - inih_dep = declare_dependency( link_with : lib_inih, compile_args : arg_static + extra_args,