mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-26 10:49:21 +00:00
use HOME/.basilisk_ii_xpram for saving + restoring XPRAM
This commit is contained in:
parent
b62b8fe5ad
commit
ad747d2049
@ -12,6 +12,7 @@
|
||||
752F26F91F240E51001032B4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 752F26F81F240E51001032B4 /* Foundation.framework */; };
|
||||
752F26FB1F240E69001032B4 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 752F26FA1F240E69001032B4 /* IOKit.framework */; };
|
||||
752F27011F242BAF001032B4 /* prefs_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752F27001F242BAF001032B4 /* prefs_sdl.cpp */; };
|
||||
752F27031F242F51001032B4 /* xpram_sdl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 752F27021F242F51001032B4 /* xpram_sdl.cpp */; };
|
||||
7539DFBF1F23B17E006B2DF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7539DFBE1F23B17E006B2DF2 /* Assets.xcassets */; };
|
||||
7539E1251F23B25A006B2DF2 /* adb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539DFC91F23B25A006B2DF2 /* adb.cpp */; };
|
||||
7539E1261F23B25A006B2DF2 /* audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539DFCA1F23B25A006B2DF2 /* audio.cpp */; };
|
||||
@ -90,7 +91,6 @@
|
||||
7539E2921F23C56F006B2DF2 /* scsi_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E2891F23C56F006B2DF2 /* scsi_dummy.cpp */; };
|
||||
7539E2931F23C56F006B2DF2 /* serial_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E28A1F23C56F006B2DF2 /* serial_dummy.cpp */; };
|
||||
7539E2941F23C56F006B2DF2 /* user_strings_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E28B1F23C56F006B2DF2 /* user_strings_dummy.cpp */; };
|
||||
7539E2951F23C56F006B2DF2 /* xpram_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E28C1F23C56F006B2DF2 /* xpram_dummy.cpp */; };
|
||||
7539E2971F23C5FD006B2DF2 /* newcpu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E2961F23C5FD006B2DF2 /* newcpu.cpp */; };
|
||||
7539E29D1F23C83F006B2DF2 /* sys_darwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E29C1F23C83F006B2DF2 /* sys_darwin.cpp */; };
|
||||
7539E29F1F23C939006B2DF2 /* fpu_uae.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7539E29E1F23C939006B2DF2 /* fpu_uae.cpp */; };
|
||||
@ -120,6 +120,7 @@
|
||||
752F26F81F240E51001032B4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
752F26FA1F240E69001032B4 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
|
||||
752F27001F242BAF001032B4 /* prefs_sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prefs_sdl.cpp; sourceTree = "<group>"; };
|
||||
752F27021F242F51001032B4 /* xpram_sdl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xpram_sdl.cpp; sourceTree = "<group>"; };
|
||||
7539DFB21F23B17E006B2DF2 /* BasiliskII.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasiliskII.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7539DFBE1F23B17E006B2DF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
7539DFC91F23B25A006B2DF2 /* adb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = adb.cpp; path = ../adb.cpp; sourceTree = "<group>"; };
|
||||
@ -268,7 +269,6 @@
|
||||
7539E2891F23C56F006B2DF2 /* scsi_dummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scsi_dummy.cpp; sourceTree = "<group>"; };
|
||||
7539E28A1F23C56F006B2DF2 /* serial_dummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = serial_dummy.cpp; sourceTree = "<group>"; };
|
||||
7539E28B1F23C56F006B2DF2 /* user_strings_dummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = user_strings_dummy.cpp; sourceTree = "<group>"; };
|
||||
7539E28C1F23C56F006B2DF2 /* xpram_dummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xpram_dummy.cpp; sourceTree = "<group>"; };
|
||||
7539E2961F23C5FD006B2DF2 /* newcpu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = newcpu.cpp; sourceTree = "<group>"; };
|
||||
7539E29C1F23C83F006B2DF2 /* sys_darwin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sys_darwin.cpp; sourceTree = "<group>"; };
|
||||
7539E29E1F23C939006B2DF2 /* fpu_uae.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fpu_uae.cpp; sourceTree = "<group>"; };
|
||||
@ -412,6 +412,7 @@
|
||||
7539E0711F23B25A006B2DF2 /* SDL */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
752F27021F242F51001032B4 /* xpram_sdl.cpp */,
|
||||
752F27001F242BAF001032B4 /* prefs_sdl.cpp */,
|
||||
7539E0721F23B25A006B2DF2 /* audio_sdl.cpp */,
|
||||
7539E0731F23B25A006B2DF2 /* keycodes */,
|
||||
@ -595,7 +596,6 @@
|
||||
7539E2891F23C56F006B2DF2 /* scsi_dummy.cpp */,
|
||||
7539E28A1F23C56F006B2DF2 /* serial_dummy.cpp */,
|
||||
7539E28B1F23C56F006B2DF2 /* user_strings_dummy.cpp */,
|
||||
7539E28C1F23C56F006B2DF2 /* xpram_dummy.cpp */,
|
||||
);
|
||||
name = dummy;
|
||||
path = ../dummy;
|
||||
@ -746,7 +746,6 @@
|
||||
7539E2921F23C56F006B2DF2 /* scsi_dummy.cpp in Sources */,
|
||||
7539E16F1F23B25A006B2DF2 /* prefs_items.cpp in Sources */,
|
||||
7539E18E1F23B25A006B2DF2 /* sony.cpp in Sources */,
|
||||
7539E2951F23C56F006B2DF2 /* xpram_dummy.cpp in Sources */,
|
||||
7539E2941F23C56F006B2DF2 /* user_strings_dummy.cpp in Sources */,
|
||||
7539E26F1F23B32A006B2DF2 /* timer_unix.cpp in Sources */,
|
||||
7539E2A91F23CB9B006B2DF2 /* defs68k.c in Sources */,
|
||||
@ -754,6 +753,7 @@
|
||||
7539E23F1F23B32A006B2DF2 /* bincue_unix.cpp in Sources */,
|
||||
7539E12C1F23B25A006B2DF2 /* emul_op.cpp in Sources */,
|
||||
7539E19D1F23B25A006B2DF2 /* mathlib.cpp in Sources */,
|
||||
752F27031F242F51001032B4 /* xpram_sdl.cpp in Sources */,
|
||||
7539E16D1F23B25A006B2DF2 /* pict.c in Sources */,
|
||||
7539E1251F23B25A006B2DF2 /* adb.cpp in Sources */,
|
||||
7539E12F1F23B25A006B2DF2 /* macos_util.cpp in Sources */,
|
||||
|
98
BasiliskII/src/SDL/xpram_sdl.cpp
Normal file
98
BasiliskII/src/SDL/xpram_sdl.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* xpram_sdl.cpp - XPRAM handling, SDL implementation
|
||||
*
|
||||
* Basilisk II (C) 1997-2008 Christian Bauer
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "sysdeps.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "xpram.h"
|
||||
|
||||
|
||||
// XPRAM file name and path
|
||||
const char XPRAM_FILE_NAME[] = ".basilisk_ii_xpram";
|
||||
|
||||
|
||||
/*
|
||||
* Load XPRAM from settings file
|
||||
*/
|
||||
|
||||
void LoadXPRAM(const char *dir)
|
||||
{
|
||||
// Build a full-path to the file
|
||||
char full_path[4096];
|
||||
if (!dir) {
|
||||
dir = SDL_getenv("HOME");
|
||||
}
|
||||
if (!dir) {
|
||||
dir = "./";
|
||||
}
|
||||
SDL_snprintf(full_path, sizeof(full_path), "%s/%s", dir, XPRAM_FILE_NAME);
|
||||
|
||||
// Open the XPRAM file
|
||||
FILE *f = fopen(full_path, "rb");
|
||||
if (f != NULL) {
|
||||
fread(XPRAM, 256, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Save XPRAM to settings file
|
||||
*/
|
||||
|
||||
void SaveXPRAM(void)
|
||||
{
|
||||
// Build a full-path to the file
|
||||
char full_path[4096];
|
||||
const char *dir = SDL_getenv("HOME");
|
||||
if (!dir) {
|
||||
dir = "./";
|
||||
}
|
||||
SDL_snprintf(full_path, sizeof(full_path), "%s/%s", dir, XPRAM_FILE_NAME);
|
||||
|
||||
// Save the XPRAM file
|
||||
FILE *f = fopen(XPRAM_FILE_NAME, "wb");
|
||||
if (f != NULL) {
|
||||
fwrite(XPRAM, 256, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete PRAM file
|
||||
*/
|
||||
|
||||
void ZapPRAM(void)
|
||||
{
|
||||
// Build a full-path to the file
|
||||
char full_path[4096];
|
||||
const char *dir = SDL_getenv("HOME");
|
||||
if (!dir) {
|
||||
dir = "./";
|
||||
}
|
||||
SDL_snprintf(full_path, sizeof(full_path), "%s/%s", dir, XPRAM_FILE_NAME);
|
||||
|
||||
// Delete the XPRAM file
|
||||
remove(full_path);
|
||||
}
|
Loading…
Reference in New Issue
Block a user