mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-06-28 07:29:31 +00:00
Compare commits
5 Commits
3176aa887d
...
aa9f112de3
Author | SHA1 | Date | |
---|---|---|---|
|
aa9f112de3 | ||
|
784ac7bb7e | ||
|
45e3bd1d3e | ||
|
08707d3a25 | ||
|
0a1d9c35bf |
|
@ -47,6 +47,10 @@ prefs_desc platform_prefs_items[] = {
|
||||||
{NULL, TYPE_END, false, NULL} // End of list
|
{NULL, TYPE_END, false, NULL} // End of list
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
|
||||||
|
|
||||||
// Standard file names and paths
|
// Standard file names and paths
|
||||||
#ifdef SHEEPSHAVER
|
#ifdef SHEEPSHAVER
|
||||||
static const char PREFS_FILE_NAME[] = "/.sheepshaver_prefs";
|
static const char PREFS_FILE_NAME[] = "/.sheepshaver_prefs";
|
||||||
|
@ -185,9 +189,9 @@ void LoadPrefs(const char* vmdir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// No prefs file, save defaults in $XDG_CONFIG_HOME directory
|
// No prefs file, save defaults in $XDG_CONFIG_HOME directory
|
||||||
#ifdef __linux__
|
//#ifdef __linux__
|
||||||
PrefsAddString("cdrom", "/dev/cdrom");
|
PrefsAddString("cdrom", "/dev/cdrom");
|
||||||
#endif
|
//#endif
|
||||||
printf("No prefs file found, creating new one at %s\n", prefs_name.c_str());
|
printf("No prefs file found, creating new one at %s\n", prefs_name.c_str());
|
||||||
SavePrefs();
|
SavePrefs();
|
||||||
}
|
}
|
||||||
|
@ -250,6 +254,82 @@ void SavePrefs(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else // __linux__
|
||||||
|
|
||||||
|
|
||||||
|
// Prefs file name and path
|
||||||
|
#ifdef SHEEPSHAVER
|
||||||
|
static const char PREFS_FILE_NAME[] = ".sheepshaver_prefs";
|
||||||
|
#else
|
||||||
|
static const char PREFS_FILE_NAME[] = ".basilisk_ii_prefs";
|
||||||
|
#endif
|
||||||
|
string UserPrefsPath;
|
||||||
|
static string prefs_path;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load preferences from settings file
|
||||||
|
*/
|
||||||
|
|
||||||
|
void LoadPrefs(const char *vmdir)
|
||||||
|
{
|
||||||
|
if (vmdir) {
|
||||||
|
prefs_path = string(vmdir) + '/' + string("prefs");
|
||||||
|
FILE *prefs = fopen(prefs_path.c_str(), "r");
|
||||||
|
if (!prefs) {
|
||||||
|
printf("No file at %s found.\n", prefs_path.c_str());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
LoadPrefsFromStream(prefs);
|
||||||
|
fclose(prefs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct prefs path
|
||||||
|
if (UserPrefsPath.empty()) {
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
if (home)
|
||||||
|
prefs_path = string(home) + '/';
|
||||||
|
prefs_path += PREFS_FILE_NAME;
|
||||||
|
} else
|
||||||
|
prefs_path = UserPrefsPath;
|
||||||
|
|
||||||
|
// Read preferences from settings file
|
||||||
|
FILE *f = fopen(prefs_path.c_str(), "r");
|
||||||
|
if (f != NULL) {
|
||||||
|
|
||||||
|
// Prefs file found, load settings
|
||||||
|
LoadPrefsFromStream(f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//#ifdef __linux__
|
||||||
|
// PrefsAddString("cdrom", "/dev/cdrom");
|
||||||
|
//#endif
|
||||||
|
// No prefs file, save defaults
|
||||||
|
SavePrefs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Save preferences to settings file
|
||||||
|
*/
|
||||||
|
|
||||||
|
void SavePrefs(void)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
if ((f = fopen(prefs_path.c_str(), "w")) != NULL) {
|
||||||
|
SavePrefsToStream(f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add defaults of platform-specific prefs items
|
* Add defaults of platform-specific prefs items
|
||||||
* You may also override the defaults set in PrefsInit()
|
* You may also override the defaults set in PrefsInit()
|
||||||
|
|
|
@ -25,6 +25,10 @@ using std::string;
|
||||||
|
|
||||||
#include "xpram.h"
|
#include "xpram.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
|
||||||
|
|
||||||
// XPRAM file name, set by LoadPrefs() in prefs_unix.cpp
|
// XPRAM file name, set by LoadPrefs() in prefs_unix.cpp
|
||||||
string xpram_name;
|
string xpram_name;
|
||||||
|
|
||||||
|
@ -73,3 +77,85 @@ void ZapPRAM(void)
|
||||||
assert(!xpram_name.empty());
|
assert(!xpram_name.empty());
|
||||||
unlink(xpram_name.c_str());
|
unlink(xpram_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else // __linux__
|
||||||
|
|
||||||
|
|
||||||
|
// XPRAM file name and path
|
||||||
|
#if POWERPC_ROM
|
||||||
|
const char XPRAM_FILE_NAME[] = ".sheepshaver_nvram";
|
||||||
|
#else
|
||||||
|
const char XPRAM_FILE_NAME[] = ".basilisk_ii_xpram";
|
||||||
|
#endif
|
||||||
|
static char xpram_path[1024];
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load XPRAM from settings file
|
||||||
|
*/
|
||||||
|
|
||||||
|
void LoadXPRAM(const char *vmdir)
|
||||||
|
{
|
||||||
|
if (vmdir) {
|
||||||
|
#if POWERPC_ROM
|
||||||
|
snprintf(xpram_path, sizeof(xpram_path), "%s/nvram", vmdir);
|
||||||
|
#else
|
||||||
|
snprintf(xpram_path, sizeof(xpram_path), "%s/xpram", vmdir);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
// Construct XPRAM path
|
||||||
|
xpram_path[0] = 0;
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
if (home != NULL && strlen(home) < 1000) {
|
||||||
|
strncpy(xpram_path, home, 1000);
|
||||||
|
strcat(xpram_path, "/");
|
||||||
|
}
|
||||||
|
strcat(xpram_path, XPRAM_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load XPRAM from settings file
|
||||||
|
int fd;
|
||||||
|
if ((fd = open(xpram_path, O_RDONLY)) >= 0) {
|
||||||
|
read(fd, XPRAM, XPRAM_SIZE);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Save XPRAM to settings file
|
||||||
|
*/
|
||||||
|
|
||||||
|
void SaveXPRAM(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
if ((fd = open(xpram_path, O_WRONLY | O_CREAT, 0666)) >= 0) {
|
||||||
|
write(fd, XPRAM, XPRAM_SIZE);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete PRAM file
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ZapPRAM(void)
|
||||||
|
{
|
||||||
|
// Construct PRAM path
|
||||||
|
xpram_path[0] = 0;
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
if (home != NULL && strlen(home) < 1000) {
|
||||||
|
strncpy(xpram_path, home, 1000);
|
||||||
|
strcat(xpram_path, "/");
|
||||||
|
}
|
||||||
|
strcat(xpram_path, XPRAM_FILE_NAME);
|
||||||
|
|
||||||
|
// Delete file
|
||||||
|
unlink(xpram_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __linux__
|
||||||
|
|
||||||
|
|
|
@ -1263,9 +1263,11 @@ EOF
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$target_cpu" = "arm" -o "$target_cpu" = "aarch64" ]]; then
|
case "$host" in
|
||||||
|
arm-apple-*)
|
||||||
AC_DEFINE_UNQUOTED(NATMEM_OFFSET, 0x400000000000, [Define constant offset for Mac address translation])
|
AC_DEFINE_UNQUOTED(NATMEM_OFFSET, 0x400000000000, [Define constant offset for Mac address translation])
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
AC_MSG_RESULT($WANT_ADDRESSING_MODE)
|
AC_MSG_RESULT($WANT_ADDRESSING_MODE)
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,50 @@ int main(int argc, char **argv)
|
||||||
// Read preferences
|
// Read preferences
|
||||||
PrefsInit(NULL, argc, argv);
|
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
|
// Check we are using a Windows NT kernel >= 4.0
|
||||||
OSVERSIONINFO osvi;
|
OSVERSIONINFO osvi;
|
||||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||||
|
@ -232,7 +276,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize SDL system
|
// Initialize SDL system
|
||||||
int sdl_flags = 0;
|
sdl_flags = 0; // #chenchijungtw move variable definition forward to avoid complication error
|
||||||
#ifdef USE_SDL_VIDEO
|
#ifdef USE_SDL_VIDEO
|
||||||
sdl_flags |= SDL_INIT_VIDEO;
|
sdl_flags |= SDL_INIT_VIDEO;
|
||||||
#endif
|
#endif
|
||||||
|
@ -260,9 +304,6 @@ int main(int argc, char **argv)
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize VM system
|
|
||||||
vm_init();
|
|
||||||
|
|
||||||
// Get system info
|
// Get system info
|
||||||
PVR = 0x00040000; // Default: 604
|
PVR = 0x00040000; // Default: 604
|
||||||
CPUClockSpeed = 100000000; // Default: 100MHz
|
CPUClockSpeed = 100000000; // Default: 100MHz
|
||||||
|
@ -315,41 +356,6 @@ int main(int argc, char **argv)
|
||||||
goto quit;
|
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
|
// Load Mac ROM
|
||||||
rom_path = PrefsFindString("rom");
|
rom_path = PrefsFindString("rom");
|
||||||
rom_fh = CreateFile(rom_path && *rom_path ? rom_path : ROM_FILE_NAME,
|
rom_fh = CreateFile(rom_path && *rom_path ? rom_path : ROM_FILE_NAME,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user