Merge pull request #192 from chenchijung/master

modify for workaround <cannot map RAM:No Error> caused by confliction…
This commit is contained in:
kanjitalk755 2024-02-24 21:30:55 +09:00 committed by GitHub
commit aa9f112de3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -203,6 +203,50 @@ int main(int argc, char **argv)
// Read preferences
PrefsInit(NULL, argc, argv);
// #chenchijung 2024/2/21: move vm_init(), memory allocation for Mac RAM and Mac ROM here to avoid "cannot map RAM: no Error" bug.
// caused by MSI afterburner (RIVA Tuner statistic tuner Server?). It is a workaround since I don't know why. But it works in my test env.
//
// ------------ Start of workaround --------------
int sdl_flags = 0;
// Initialize VM system
vm_init();
// Create area for Mac RAM
RAMSize = PrefsFindInt32("ramsize");
if (RAMSize <= 1000) {
RAMSize *= 1024 * 1024;
}
if (RAMSize < 16 * 1024 * 1024) {
WarningAlert(GetString(STR_SMALL_RAM_WARN));
RAMSize = 16 * 1024 * 1024;
}
RAMBase = 0;
if (vm_mac_acquire(RAMBase, RAMSize) < 0) {
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno));
ErrorAlert(str);
goto quit;
}
RAMBaseHost = Mac2HostAddr(RAMBase);
ram_area_mapped = true;
D(bug("RAM area at %p (%08x)\n", RAMBaseHost, RAMBase));
// Create area for Mac ROM
if (vm_mac_acquire(ROM_BASE, ROM_AREA_SIZE) < 0) {
sprintf(str, GetString(STR_ROM_MMAP_ERR), strerror(errno));
ErrorAlert(str);
goto quit;
}
ROMBase = ROM_BASE;
ROMBaseHost = Mac2HostAddr(ROMBase);
rom_area_mapped = true;
D(bug("ROM area at %p (%08x)\n", ROMBaseHost, ROMBase));
if (RAMBase > ROMBase) {
ErrorAlert(GetString(STR_RAM_HIGHER_THAN_ROM_ERR));
goto quit;
}
//#chenchijung ----------------- end of workaround --------------
// Check we are using a Windows NT kernel >= 4.0
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
@ -232,7 +276,7 @@ int main(int argc, char **argv)
}
// Initialize SDL system
int sdl_flags = 0;
sdl_flags = 0; // #chenchijungtw move variable definition forward to avoid complication error
#ifdef USE_SDL_VIDEO
sdl_flags |= SDL_INIT_VIDEO;
#endif
@ -260,9 +304,6 @@ int main(int argc, char **argv)
goto quit;
}
// Initialize VM system
vm_init();
// Get system info
PVR = 0x00040000; // Default: 604
CPUClockSpeed = 100000000; // Default: 100MHz
@ -315,41 +356,6 @@ int main(int argc, char **argv)
goto quit;
}
// Create area for Mac ROM
if (vm_mac_acquire(ROM_BASE, ROM_AREA_SIZE) < 0) {
sprintf(str, GetString(STR_ROM_MMAP_ERR), strerror(errno));
ErrorAlert(str);
goto quit;
}
ROMBase = ROM_BASE;
ROMBaseHost = Mac2HostAddr(ROMBase);
rom_area_mapped = true;
D(bug("ROM area at %p (%08x)\n", ROMBaseHost, ROMBase));
// Create area for Mac RAM
RAMSize = PrefsFindInt32("ramsize");
if (RAMSize <= 1000) {
RAMSize *= 1024 * 1024;
}
if (RAMSize < 16 * 1024 * 1024) {
WarningAlert(GetString(STR_SMALL_RAM_WARN));
RAMSize = 16 * 1024 * 1024;
}
RAMBase = 0;
if (vm_mac_acquire(RAMBase, RAMSize) < 0) {
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno));
ErrorAlert(str);
goto quit;
}
RAMBaseHost = Mac2HostAddr(RAMBase);
ram_area_mapped = true;
D(bug("RAM area at %p (%08x)\n", RAMBaseHost, RAMBase));
if (RAMBase > ROMBase) {
ErrorAlert(GetString(STR_RAM_HIGHER_THAN_ROM_ERR));
goto quit;
}
// Load Mac ROM
rom_path = PrefsFindString("rom");
rom_fh = CreateFile(rom_path && *rom_path ? rom_path : ROM_FILE_NAME,