]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
RTC and Flash ROM file path late resolve support.
authorToni Wilen <twilen@winuae.net>
Tue, 10 Jul 2018 06:58:57 +0000 (09:58 +0300)
committerToni Wilen <twilen@winuae.net>
Tue, 10 Jul 2018 06:58:57 +0000 (09:58 +0300)
akiko.cpp
arcadia.cpp
cdtv.cpp
cdtvcr.cpp
cfgfile.cpp
cia.cpp
include/options.h
od-win32/win32gui.cpp
x86.cpp

index d4dbb717c01867caa6df97ac5a00a36e497f53fe..d916c76d9b81b3fa80a6f45015ad7d339d62a50b 100644 (file)
--- a/akiko.cpp
+++ b/akiko.cpp
@@ -86,9 +86,11 @@ static void nvram_read (void)
        if (is_board_enabled(&currprefs, ROMTYPE_CUBO, 0)) {
                cubo_nvram = cd32_nvram + currprefs.cs_cd32nvram_size;
        }
-       cd32_flashfile = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       TCHAR path[MAX_DPATH];
+       cfgfile_resolve_path_out(currprefs.flashfile, path, MAX_DPATH, PATH_ROM);
+       cd32_flashfile = zfile_fopen (path, _T("rb+"), ZFD_NORMAL);
        if (!cd32_flashfile)
-               cd32_flashfile = zfile_fopen (currprefs.flashfile, _T("wb"), 0);
+               cd32_flashfile = zfile_fopen (path, _T("wb"), 0);
        if (cd32_flashfile) {
                int size = zfile_fread(cd32_nvram, 1, currprefs.cs_cd32nvram_size, cd32_flashfile);
                if (size == currprefs.cs_cd32nvram_size && maxlen > currprefs.cs_cd32nvram_size)
index b2551ee376cb46c0c70b60db763f55f80657f1e5..82cff02ace0b10f094b31814923ef825fc787f5c 100644 (file)
@@ -449,9 +449,11 @@ int is_arcadia_rom (const TCHAR *path)
 
 static void nvram_write (void)
 {
-       struct zfile *f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       TCHAR path[MAX_DPATH];
+       cfgfile_resolve_path_out(currprefs.flashfile, path, MAX_DPATH, PATH_ROM);
+       struct zfile *f = zfile_fopen (path, _T("rb+"), ZFD_NORMAL);
        if (!f) {
-               f = zfile_fopen (currprefs.flashfile, _T("wb"), 0);
+               f = zfile_fopen (path, _T("wb"), 0);
                if (!f)
                        return;
        }
@@ -463,7 +465,9 @@ static void nvram_read (void)
 {
        struct zfile *f;
 
-       f = zfile_fopen (currprefs.flashfile, _T("rb"), ZFD_NORMAL);
+       TCHAR path[MAX_DPATH];
+       cfgfile_resolve_path_out(currprefs.flashfile, path, MAX_DPATH, PATH_ROM);
+       f = zfile_fopen (path, _T("rb"), ZFD_NORMAL);
        memset (arbmemory + nvram_offset, 0, NVRAM_SIZE);
        if (!f)
                return;
@@ -595,9 +599,11 @@ static int algmemory_initialized;
 
 static void alg_nvram_write (void)
 {
-       struct zfile *f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       TCHAR path[MAX_DPATH];
+       cfgfile_resolve_path_out(currprefs.flashfile, path, MAX_DPATH, PATH_ROM);
+       struct zfile *f = zfile_fopen (path, _T("rb+"), ZFD_NORMAL);
        if (!f) {
-               f = zfile_fopen (currprefs.flashfile, _T("wb"), 0);
+               f = zfile_fopen (path, _T("wb"), 0);
                if (!f)
                        return;
        }
@@ -609,7 +615,9 @@ static void alg_nvram_read (void)
 {
        struct zfile *f;
 
-       f = zfile_fopen (currprefs.flashfile, _T("rb"), ZFD_NORMAL);
+       TCHAR path[MAX_DPATH];
+       cfgfile_resolve_path_out(currprefs.flashfile, path, MAX_DPATH, PATH_ROM);
+       f = zfile_fopen (path, _T("rb"), ZFD_NORMAL);
        memset (algmemory, 0, ALG_NVRAM_SIZE);
        if (!f)
                return;
index 71f2e1efb9d38dce4f9d13832ea53bb322060fa1..a4f03894704098a7fceb2b3c348fee7f37b26f36 100644 (file)
--- a/cdtv.cpp
+++ b/cdtv.cpp
@@ -1534,6 +1534,7 @@ addrbank dmac_bank = {
 #define CDTV_NVRAM_MASK 16383
 #define CDTV_NVRAM_SIZE 32768
 static uae_u8 cdtv_battram[CDTV_NVRAM_SIZE];
+static TCHAR flashfilepath[MAX_DPATH];
 
 static void cdtv_loadcardmem (uae_u8 *p, int size)
 {
@@ -1542,7 +1543,8 @@ static void cdtv_loadcardmem (uae_u8 *p, int size)
        if (!size)
                return;
        memset (p, 0, size);
-       f = zfile_fopen (currprefs.flashfile, _T("rb"), ZFD_NORMAL);
+       cfgfile_resolve_path_out(currprefs.flashfile, flashfilepath, MAX_DPATH, PATH_ROM);
+       f = zfile_fopen (flashfilepath, _T("rb"), ZFD_NORMAL);
        if (!f)
                return;
        zfile_fseek (f, CDTV_NVRAM_SIZE, SEEK_SET);
@@ -1556,7 +1558,8 @@ static void cdtv_savecardmem (uae_u8 *p, int size)
 
        if (!size)
                return;
-       f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       cfgfile_resolve_path_out(currprefs.flashfile, flashfilepath, MAX_DPATH, PATH_ROM);
+       f = zfile_fopen (flashfilepath, _T("rb+"), ZFD_NORMAL);
        if (!f)
                return;
        zfile_fseek (f, CDTV_NVRAM_SIZE, SEEK_SET);
@@ -1570,9 +1573,10 @@ static void cdtv_battram_reset (void)
        int v;
 
        memset (cdtv_battram, 0, CDTV_NVRAM_SIZE);
-       f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       cfgfile_resolve_path_out(currprefs.flashfile, flashfilepath, MAX_DPATH, PATH_ROM);
+       f = zfile_fopen (flashfilepath, _T("rb+"), ZFD_NORMAL);
        if (!f) {
-               f = zfile_fopen (currprefs.flashfile, _T("wb"), 0);
+               f = zfile_fopen (flashfilepath, _T("wb"), 0);
                if (f) {
                        zfile_fwrite (cdtv_battram, CDTV_NVRAM_SIZE, 1, f);
                        zfile_fclose (f);
@@ -1596,7 +1600,7 @@ void cdtv_battram_write (int addr, int v)
        if (cdtv_battram[offset] == v)
                return;
        cdtv_battram[offset] = v;
-       f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       f = zfile_fopen (flashfilepath, _T("rb+"), ZFD_NORMAL);
        if (!f)
                return;
        zfile_fseek (f, offset, SEEK_SET);
index 17fddad08f58a193274aa104a94c22d55a73676e..5d91be72059a4bf063c65bd878fe545d4c44122b 100644 (file)
@@ -102,6 +102,7 @@ static int cd_led;
 static volatile int subcodebufferoffset, subcodebufferoffsetw;
 static uae_u8 subcodebufferinuse[MAX_SUBCODEBUFFER];
 static uae_u8 subcodebuffer[MAX_SUBCODEBUFFER * SUB_CHANNEL_SIZE];
+static TCHAR flashfilepath[MAX_DPATH];
 
 static void cdtvcr_battram_reset (void)
 {
@@ -109,9 +110,10 @@ static void cdtvcr_battram_reset (void)
        int v;
 
        memset (cdtvcr_ram, 0, CDTVCR_RAM_SIZE);
-       f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       cfgfile_resolve_path_out(currprefs.flashfile, flashfilepath, MAX_DPATH, PATH_ROM);
+       f = zfile_fopen (flashfilepath, _T("rb+"), ZFD_NORMAL);
        if (!f) {
-               f = zfile_fopen (currprefs.flashfile, _T("wb"), 0);
+               f = zfile_fopen (flashfilepath, _T("wb"), 0);
                if (f) {
                        zfile_fwrite (cdtvcr_ram, CDTVCR_RAM_SIZE, 1, f);
                        zfile_fclose (f);
@@ -135,7 +137,7 @@ static void cdtvcr_battram_write (int addr, int v)
        if (cdtvcr_ram[offset] == v)
                return;
        cdtvcr_ram[offset] = v;
-       f = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+       f = zfile_fopen (flashfilepath, _T("rb+"), ZFD_NORMAL);
        if (!f)
                return;
        zfile_fseek (f, offset, SEEK_SET);
index f939ca2889b332ba54b3ccd7722a671e3a4c2305..27d996e2f220e9852387680214a3bda38870d6d7 100644 (file)
@@ -992,6 +992,9 @@ void cfgfile_resolve_path_out(const TCHAR *path, TCHAR *out, int size, int type)
        case PATH_CD:
                s = cfgfile_subst_path_load(UNEXPANDED, &p->path_cd, path, false);
                break;
+       case PATH_ROM:
+               s = cfgfile_subst_path_load(UNEXPANDED, &p->path_rom, path, false);
+               break;
        case PATH_FLOPPY:
                _tcscpy(out, path);
                cfgfile_adjust_path(out, MAX_DPATH, &p->path_floppy);
@@ -1679,9 +1682,9 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
                cfgfile_write_board_rom(p, f, &p->path_rom, &p->expansionboard[i]);
        }
 
-       cfgfile_write_path (f, &p->path_rom, _T("flash_file"), p->flashfile);
+       cfgfile_write_str(f, _T("flash_file"), p->flashfile);
        cfgfile_write_path (f, &p->path_rom, _T("cart_file"), p->cartfile);
-       cfgfile_write_path (f, &p->path_rom, _T("rtc_file"), p->rtcfile);
+       cfgfile_write_str(f, _T("rtc_file"), p->rtcfile);
        if (p->cartident[0])
                cfgfile_write_str (f, _T("cart"), p->cartident);
        cfgfile_dwrite_path (f, &p->path_rom, _T("picassoiv_rom_file"), p->picassoivromfile);
@@ -5280,9 +5283,9 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
                || cfgfile_path (option, value, _T("kickstart_ext_rom_file2"), p->romextfile2, sizeof p->romextfile2 / sizeof (TCHAR), &p->path_rom)
                || cfgfile_rom(option, value, _T("kickstart_rom_file_id"), p->romfile, sizeof p->romfile / sizeof(TCHAR))
                || cfgfile_rom (option, value, _T("kickstart_ext_rom_file_id"), p->romextfile, sizeof p->romextfile / sizeof (TCHAR))
-               || cfgfile_path (option, value, _T("flash_file"), p->flashfile, sizeof p->flashfile / sizeof (TCHAR), &p->path_rom)
+               || cfgfile_string(option, value, _T("flash_file"), p->flashfile, sizeof p->flashfile / sizeof (TCHAR))
                || cfgfile_path (option, value, _T("cart_file"), p->cartfile, sizeof p->cartfile / sizeof (TCHAR), &p->path_rom)
-               || cfgfile_path (option, value, _T("rtc_file"), p->rtcfile, sizeof p->rtcfile / sizeof (TCHAR), &p->path_rom)
+               || cfgfile_string(option, value, _T("rtc_file"), p->rtcfile, sizeof p->rtcfile / sizeof (TCHAR))
                || cfgfile_path(option, value, _T("picassoiv_rom_file"), p->picassoivromfile, sizeof p->picassoivromfile / sizeof(TCHAR), &p->path_rom)
                || cfgfile_string(option, value, _T("genlock_image"), p->genlock_image_file, sizeof p->genlock_image_file / sizeof(TCHAR))
                || cfgfile_string(option, value, _T("genlock_video"), p->genlock_video_file, sizeof p->genlock_video_file / sizeof(TCHAR))
diff --git a/cia.cpp b/cia.cpp
index bf5db603dabd48498728c48c008e85827020e1fa..fff9d29f25da06145ce2dc9d54a7a287f0229929 100644 (file)
--- a/cia.cpp
+++ b/cia.cpp
@@ -2173,7 +2173,9 @@ static void write_battclock (void)
 {
        if (!currprefs.rtcfile[0] || currprefs.cs_rtc == 0)
                return;
-       struct zfile *f = zfile_fopen (currprefs.rtcfile, _T("wb"));
+       TCHAR path[MAX_DPATH];
+       cfgfile_resolve_path_out(currprefs.rtcfile, path, MAX_DPATH, PATH_ROM);
+       struct zfile *f = zfile_fopen (path, _T("wb"));
        if (f) {
                struct tm *ct;
                time_t t = time (0);
@@ -2228,7 +2230,9 @@ void rtc_hardreset (void)
                rtc_ricoh.delayed_write = 0;
        }
        if (currprefs.rtcfile[0]) {
-               struct zfile *f = zfile_fopen (currprefs.rtcfile, _T("rb"));
+               TCHAR path[MAX_DPATH];
+               cfgfile_resolve_path_out(currprefs.rtcfile, path, MAX_DPATH, PATH_ROM);
+               struct zfile *f = zfile_fopen (path, _T("rb"));
                if (f) {
                        uae_u8 empty[13];
                        zfile_fread (empty, 13, 1, f);
index ce6fdcad28cd95fee7f192c07c621a0eca589572..3a9b336f9ef26ef1791e76767aed58d80b5040ce 100644 (file)
@@ -40,6 +40,7 @@ struct multipath {
 #define PATH_GENLOCK_IMAGE 6
 #define PATH_GENLOCK_VIDEO 7
 #define PATH_GEO 8
+#define PATH_ROM 9
 
 struct strlist {
        struct strlist *next;
index 63c5488548965e6bf4e922f14012c3de794d920c..62b54fd0303a6e22fb1d1fbe6d8a897926069c86 100644 (file)
@@ -2150,6 +2150,7 @@ void target_multipath_modified(struct uae_prefs *p)
        memcpy(&currprefs.path_hardfile, &p->path_hardfile, sizeof(struct multipath));
        memcpy(&currprefs.path_floppy, &p->path_floppy, sizeof(struct multipath));
        memcpy(&currprefs.path_cd, &p->path_cd, sizeof(struct multipath));
+       memcpy(&currprefs.path_rom, &p->path_rom, sizeof(struct multipath));
 }
 
 int target_cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int type, int isdefault)
@@ -2200,10 +2201,6 @@ int target_cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int type, i
        ct2 = 0;
        regqueryint (NULL, _T("ConfigFile_NoAuto"), &ct2);
        v = cfgfile_load (p, fname, &type2, ct2, isdefault ? 0 : 1);
-       if (p == &workprefs) {
-               memcpy(&currprefs.path_hardfile, &p->path_hardfile, sizeof(struct multipath));
-               memcpy(&currprefs.path_floppy, &p->path_floppy, sizeof(struct multipath));
-       }
        if (!v)
                return v;
        if (type > 0)
@@ -3093,11 +3090,9 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
                        break;
                case IDC_FLASHFILE:
                        _tcscpy (workprefs.flashfile, full_path);
-                       fullpath (workprefs.flashfile, MAX_DPATH);
                        break;
                case IDC_RTCFILE:
                        _tcscpy (workprefs.rtcfile, full_path);
-                       fullpath (workprefs.rtcfile, MAX_DPATH);
                        break;
                case IDC_CARTFILE:
                        _tcscpy (workprefs.cartfile, full_path);
diff --git a/x86.cpp b/x86.cpp
index 626bb8fd1805b067ade8464179e3ebfebfa8eeca..7a76447e137f1177f017876b65b6149e64079a9b 100644 (file)
--- a/x86.cpp
+++ b/x86.cpp
@@ -3386,10 +3386,12 @@ bool x86_bridge_init(struct autoconfig_info *aci, uae_u32 romtype, int type)
                TIMER_Init(dosbox_sec);
                FPU_Init(dosbox_sec);
                if (xb->type >= TYPE_2286) {
+                       TCHAR path[MAX_DPATH];
+                       cfgfile_resolve_path_out(currprefs.flashfile, path, MAX_DPATH, PATH_ROM);
                        xb->cmossize = xb->type == TYPE_2386 ? 192 : 64;
-                       xb->cmosfile = zfile_fopen(currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+                       xb->cmosfile = zfile_fopen(path, _T("rb+"), ZFD_NORMAL);
                        if (!xb->cmosfile) {
-                               xb->cmosfile = zfile_fopen(currprefs.flashfile, _T("wb"));
+                               xb->cmosfile = zfile_fopen(path, _T("wb"));
                        }
                        memset(xb->cmosregs, 0, sizeof xb->cmosregs);
                        if (xb->cmosfile) {