From a3e6c4eeb3f9c4ce7d9b085584c31e259b08622c Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 27 Sep 2016 21:38:29 +0200 Subject: [PATCH] FDC DOR handler now does a sanity check when setting drive select, fixes OS/2 Setup fataling the emulator when reading Disk 2; FDC SEEK command now no longer incorrectly times out when seeking to the track the FDC thinks it's already at, fixes floppies in NT 3.1; Emulator now correctly saves configuration changes to the configuration files it was loaded with rather than always the default; Default path for NVR's can now be overridden by adding the nvr_path option to the cfg file. --- src/disc.c | 6 ++ src/disc_86f.c | 4 +- src/fdc.c | 59 ++++++++++++--- src/fdd.c | 1 + src/ibm.h | 5 ++ src/nvr.c | 168 ++++++++++++++++++++---------------------- src/pc.c | 34 ++++++++- src/sound_adlibgold.c | 4 +- src/tandy_eeprom.c | 8 +- 9 files changed, 178 insertions(+), 111 deletions(-) diff --git a/src/disc.c b/src/disc.c index 9bef44041..30f46140c 100644 --- a/src/disc.c +++ b/src/disc.c @@ -183,6 +183,12 @@ double disc_real_period() void disc_poll() { + if (disc_drivesel > 1) + { + disc_poll_time += (int64_t) (32.0 * TIMER_USEC); + return; + } + disc_poll_time += (int64_t) disc_real_period(); if (drives[disc_drivesel].poll) diff --git a/src/disc_86f.c b/src/disc_86f.c index f49d5bd78..5182490c2 100644 --- a/src/disc_86f.c +++ b/src/disc_86f.c @@ -1964,7 +1964,7 @@ void d86f_poll_find_format(int drive, int side) if (d86f[drive].track_index) { - // pclog("Index hole hit, formatting track...\n"); + pclog("Index hole hit, formatting track...\n"); d86f[drive].state = STATE_FORMAT; return; } @@ -2089,7 +2089,7 @@ void d86f_poll_format(int drive, int side) if (d86f[drive].track_index) { // pclog("Track position %08X\n", d86f[drive].track_pos); - // pclog("Index hole hit again, format finished\n"); + pclog("Index hole hit again, format finished\n"); d86f[drive].state = STATE_IDLE; if (!disable_write) d86f_handler[drive].writeback(drive); fdc_sector_finishread(drive); diff --git a/src/fdc.c b/src/fdc.c index 10b196524..215fd53f7 100644 --- a/src/fdc.c +++ b/src/fdc.c @@ -490,6 +490,8 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv) // pclog("Write FDC %04X %02X %04X:%04X %i %02X %i rate=%i %i\n",addr,val,cs>>4,pc,ins,fdc.st0,ins,fdc.rate, fdc.data_ready); int drive; int seek_time; + int temp_drive; + int temp_motoron; switch (addr&7) { @@ -538,11 +540,27 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_reset(); } timer_process(); - motoron = (val & 0xf0) ? 1 : 0; timer_update_outstanding(); - fdc.drive = val & 3; - disc_drivesel = fdc.drive & 1; - disc_set_drivesel(fdc.drive & 1); + val &= 0x3f; /* Drives 2 and 3 are not emulated, so their motors are always forced off. */ + temp_drive = val & 3; + temp_motoron = 0x10 << temp_drive; + temp_motoron = val & temp_motoron; + motoron = 0; + if (temp_motoron && (temp_drive <= 1)) + { + /* Selected drive is drive 0 or 1 and has motor on bit set too, change drive selection. */ + fdc.drive = temp_drive; + disc_drivesel = fdc.drive; + disc_set_drivesel(fdc.drive); + motoron = (val & 0xf0) ? 1 : 0; + val &= 0x3f; + } + else + { + /* Selected drive is either drive 2 or 3 or has motor on bit clear, turn off the motor. */ + motoron = 0; + val &= 0x0f; + } } fdc.dor=val; // printf("DOR now %02X\n",val); @@ -738,9 +756,18 @@ bad_command: disctime = 1024 * (1 << TIMER_SHIFT); timer_update_outstanding(); // fdc.drive = fdc.params[0] & 3; - disc_drivesel = fdc.drive & 1; fdc_reset_stat = 0; - disc_set_drivesel(fdc.drive & 1); + if (fdc.dor & (0x10 << fdc.drive)) + { + motoron = 0; + disc_drivesel = fdc.drive; + disc_set_drivesel(fdc.drive); + motoron = 1; + } + else + { + motoron = 0; + } switch (discint & 0x1F) { case 2: /*Read a track*/ @@ -881,23 +908,31 @@ bad_command: { break; } - if (fdc.command & 0x40) + if (fdc.params[1]) { - /* Relative seek inwards. */ - fdc_seek(fdc.drive, fdc.params[1]); + if (fdc.command & 0x40) + { + /* Relative seek inwards. */ + fdc_seek(fdc.drive, fdc.params[1]); + } + else + { + /* Relative seek outwards. */ + fdc_seek(fdc.drive, -fdc.params[1]); + } + disctime = ((int) fdc.params[1]) * 10 * TIMER_USEC; } else { - /* Relative seek outwards. */ - fdc_seek(fdc.drive, -fdc.params[1]); + disctime = 10 * TIMER_USEC; } - disctime = ((int) fdc.params[1]) * 10 * TIMER_USEC; } else { seek_time = ((int) (fdc.params[1] - fdc.track[fdc.drive])) * 10 * TIMER_USEC; if (!seek_time) { + disctime = 10 * TIMER_USEC; break; } fdc_seek(fdc.drive, fdc.params[1] - fdc.track[fdc.drive]); diff --git a/src/fdd.c b/src/fdd.c index c681a1c1b..44d3a7d89 100644 --- a/src/fdd.c +++ b/src/fdd.c @@ -105,6 +105,7 @@ void fdd_seek(int drive, int track_diff) if (!track_diff) { + disctime = 5000; return; } diff --git a/src/ibm.h b/src/ibm.h index 7d9090d2a..202dc9c3d 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -626,3 +626,8 @@ extern uint32_t eip_msr; extern uint64_t star; #define FPU_CW_Reserved_Bits (0xe0c0) + +extern char nvr_path[260]; +extern int path_len; + +char *nvr_concat(char *to_concat); diff --git a/src/nvr.c b/src/nvr.c index d39dec398..d4190e5c5 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -198,51 +198,45 @@ void loadnvr() oldromset=romset; switch (romset) { - case ROM_PC1512: f = romfopen("nvr/pc1512.nvr", "rb"); break; - case ROM_PC1640: f = romfopen("nvr/pc1640.nvr", "rb"); break; - case ROM_PC200: f = romfopen("nvr/pc200.nvr", "rb"); break; - case ROM_PC2086: f = romfopen("nvr/pc2086.nvr", "rb"); break; - case ROM_PC3086: f = romfopen("nvr/pc3086.nvr", "rb"); break; - case ROM_IBMAT: f = romfopen("nvr/at.nvr", "rb"); break; - case ROM_IBMPS1_2011: f = romfopen("nvr/ibmps1_2011.nvr", "rb"); /*nvrmask = 127; */break; - case ROM_IBMPS1_2121: f = romfopen("nvr/ibmps1_2121.nvr", "rb"); nvrmask = 127; break; - case ROM_CMDPC30: f = romfopen("nvr/cmdpc30.nvr", "rb"); nvrmask = 127; break; - case ROM_AMI286: f = romfopen("nvr/ami286.nvr", "rb"); nvrmask = 127; break; - case ROM_AWARD286: f = romfopen("nvr/award286.nvr", "rb"); nvrmask = 127; break; - case ROM_DELL200: f = romfopen("nvr/dell200.nvr", "rb"); nvrmask = 127; break; - case ROM_IBMAT386: f = romfopen("nvr/at386.nvr", "rb"); nvrmask = 127; break; - case ROM_DESKPRO_386: f = romfopen("nvr/deskpro386.nvr", "rb"); break; - case ROM_ACER386: f = romfopen("nvr/acer386.nvr", "rb"); nvrmask = 127; break; - case ROM_MEGAPC: f = romfopen("nvr/megapc.nvr", "rb"); nvrmask = 127; break; - case ROM_AMI386: f = romfopen("nvr/ami386.nvr", "rb"); nvrmask = 127; break; - case ROM_AMI486: f = romfopen("nvr/ami486.nvr", "rb"); nvrmask = 127; break; - case ROM_WIN486: f = romfopen("nvr/win486.nvr", "rb"); nvrmask = 127; break; - case ROM_PCI486: f = romfopen("nvr/hot-433.nvr", "rb"); nvrmask = 127; break; - case ROM_SIS496: f = romfopen("nvr/sis496.nvr", "rb"); nvrmask = 127; break; - case ROM_430VX: f = romfopen("nvr/430vx.nvr", "rb"); nvrmask = 127; break; - case ROM_REVENGE: f = romfopen("nvr/revenge.nvr", "rb"); nvrmask = 127; break; - case ROM_ENDEAVOR: f = romfopen("nvr/endeavor.nvr", "rb"); nvrmask = 127; break; - case ROM_PX386: f = romfopen("nvr/px386.nvr", "rb"); nvrmask = 127; break; - case ROM_DTK386: f = romfopen("nvr/dtk386.nvr", "rb"); nvrmask = 127; break; - case ROM_DTK486: f = romfopen("nvr/dtk486.nvr", "rb"); nvrmask = 127; break; - case ROM_R418: f = romfopen("nvr/r418.nvr", "rb"); nvrmask = 127; break; - case ROM_586MC1: f = romfopen("nvr/586mc1.nvr", "rb"); nvrmask = 127; break; - case ROM_PLATO: f = romfopen("nvr/plato.nvr", "rb"); nvrmask = 127; break; - case ROM_MB500N: f = romfopen("nvr/mb500n.nvr", "rb"); nvrmask = 127; break; -#if 0 - case ROM_P54TP4XE: f = romfopen("nvr/p54tp4xe.nvr", "rb"); nvrmask = 127; break; -#endif - case ROM_ACERM3A: f = romfopen("nvr/acerm3a.nvr", "rb"); nvrmask = 127; break; - case ROM_ACERV35N: f = romfopen("nvr/acerv35n.nvr", "rb"); nvrmask = 127; break; -#if 0 - case ROM_P55T2P4: f = romfopen("nvr/p55t2p4.nvr", "rb"); nvrmask = 127; break; -#endif - case ROM_P55TVP4: f = romfopen("nvr/p55tvp4.nvr", "rb"); nvrmask = 127; break; - case ROM_P55VA: f = romfopen("nvr/p55va.nvr", "rb"); nvrmask = 127; break; - case ROM_440FX: f = romfopen("nvr/440fx.nvr", "rb"); nvrmask = 127; break; - case ROM_KN97: f = romfopen("nvr/kn97.nvr", "rb"); nvrmask = 127; break; - case ROM_MARL: f = romfopen("nvr/marl.nvr", "rb"); nvrmask = 127; break; - case ROM_THOR: f = romfopen("nvr/thor.nvr", "rb"); nvrmask = 127; break; + case ROM_PC1512: f = romfopen(nvr_concat("pc1512.nvr"), "rb"); break; + case ROM_PC1640: f = romfopen(nvr_concat("pc1640.nvr"), "rb"); break; + case ROM_PC200: f = romfopen(nvr_concat("pc200.nvr"), "rb"); break; + case ROM_PC2086: f = romfopen(nvr_concat("pc2086.nvr"), "rb"); break; + case ROM_PC3086: f = romfopen(nvr_concat("pc3086.nvr"), "rb"); break; + case ROM_IBMAT: f = romfopen(nvr_concat("at.nvr"), "rb"); break; + case ROM_IBMPS1_2011: f = romfopen(nvr_concat("ibmps1_2011.nvr"), "rb"); /*nvrmask = 127; */break; + case ROM_IBMPS1_2121: f = romfopen(nvr_concat("ibmps1_2121.nvr"), "rb"); nvrmask = 127; break; + case ROM_CMDPC30: f = romfopen(nvr_concat("cmdpc30.nvr"), "rb"); nvrmask = 127; break; + case ROM_AMI286: f = romfopen(nvr_concat("ami286.nvr"), "rb"); nvrmask = 127; break; + case ROM_AWARD286: f = romfopen(nvr_concat("award286.nvr"), "rb"); nvrmask = 127; break; + case ROM_DELL200: f = romfopen(nvr_concat("dell200.nvr"), "rb"); nvrmask = 127; break; + case ROM_IBMAT386: f = romfopen(nvr_concat("at386.nvr"), "rb"); nvrmask = 127; break; + case ROM_DESKPRO_386: f = romfopen(nvr_concat("deskpro386.nvr"), "rb"); break; + case ROM_ACER386: f = romfopen(nvr_concat("acer386.nvr"), "rb"); nvrmask = 127; break; + case ROM_MEGAPC: f = romfopen(nvr_concat("megapc.nvr"), "rb"); nvrmask = 127; break; + case ROM_AMI386: f = romfopen(nvr_concat("ami386.nvr"), "rb"); nvrmask = 127; break; + case ROM_AMI486: f = romfopen(nvr_concat("ami486.nvr"), "rb"); nvrmask = 127; break; + case ROM_WIN486: f = romfopen(nvr_concat("win486.nvr"), "rb"); nvrmask = 127; break; + case ROM_PCI486: f = romfopen(nvr_concat("hot-433.nvr"), "rb"); nvrmask = 127; break; + case ROM_SIS496: f = romfopen(nvr_concat("sis496.nvr"), "rb"); nvrmask = 127; break; + case ROM_430VX: f = romfopen(nvr_concat("430vx.nvr"), "rb"); nvrmask = 127; break; + case ROM_REVENGE: f = romfopen(nvr_concat("revenge.nvr"), "rb"); nvrmask = 127; break; + case ROM_ENDEAVOR: f = romfopen(nvr_concat("endeavor.nvr"), "rb"); nvrmask = 127; break; + case ROM_PX386: f = romfopen(nvr_concat("px386.nvr"), "rb"); nvrmask = 127; break; + case ROM_DTK386: f = romfopen(nvr_concat("dtk386.nvr"), "rb"); nvrmask = 127; break; + case ROM_DTK486: f = romfopen(nvr_concat("dtk486.nvr"), "rb"); nvrmask = 127; break; + case ROM_R418: f = romfopen(nvr_concat("r418.nvr"), "rb"); nvrmask = 127; break; + case ROM_586MC1: f = romfopen(nvr_concat("586mc1.nvr"), "rb"); nvrmask = 127; break; + case ROM_PLATO: f = romfopen(nvr_concat("plato.nvr"), "rb"); nvrmask = 127; break; + case ROM_MB500N: f = romfopen(nvr_concat("mb500n.nvr"), "rb"); nvrmask = 127; break; + case ROM_ACERM3A: f = romfopen(nvr_concat("acerm3a.nvr"), "rb"); nvrmask = 127; break; + case ROM_ACERV35N: f = romfopen(nvr_concat("acerv35n.nvr"), "rb"); nvrmask = 127; break; + case ROM_P55TVP4: f = romfopen(nvr_concat("p55tvp4.nvr"), "rb"); nvrmask = 127; break; + case ROM_P55VA: f = romfopen(nvr_concat("p55va.nvr"), "rb"); nvrmask = 127; break; + case ROM_440FX: f = romfopen(nvr_concat("440fx.nvr"), "rb"); nvrmask = 127; break; + case ROM_KN97: f = romfopen(nvr_concat("kn97.nvr"), "rb"); nvrmask = 127; break; + case ROM_MARL: f = romfopen(nvr_concat("marl.nvr"), "rb"); nvrmask = 127; break; + case ROM_THOR: f = romfopen(nvr_concat("thor.nvr"), "rb"); nvrmask = 127; break; default: return; } if (!f) @@ -274,51 +268,45 @@ void savenvr() FILE *f; switch (oldromset) { - case ROM_PC1512: f = romfopen("nvr/pc1512.nvr", "wb"); break; - case ROM_PC1640: f = romfopen("nvr/pc1640.nvr", "wb"); break; - case ROM_PC200: f = romfopen("nvr/pc200.nvr", "wb"); break; - case ROM_PC2086: f = romfopen("nvr/pc2086.nvr", "wb"); break; - case ROM_PC3086: f = romfopen("nvr/pc3086.nvr", "wb"); break; - case ROM_IBMAT: f = romfopen("nvr/at.nvr", "wb"); break; - case ROM_IBMPS1_2011: f = romfopen("nvr/ibmps1_2011.nvr", "wb"); break; - case ROM_IBMPS1_2121: f = romfopen("nvr/ibmps1_2121.nvr", "wb"); break; - case ROM_CMDPC30: f = romfopen("nvr/cmdpc30.nvr", "wb"); break; - case ROM_AMI286: f = romfopen("nvr/ami286.nvr", "wb"); break; - case ROM_AWARD286: f = romfopen("nvr/award286.nvr", "wb"); break; - case ROM_DELL200: f = romfopen("nvr/dell200.nvr", "wb"); break; - case ROM_IBMAT386: f = romfopen("nvr/at386.nvr", "wb"); break; - case ROM_DESKPRO_386: f = romfopen("nvr/deskpro386.nvr", "wb"); break; - case ROM_ACER386: f = romfopen("nvr/acer386.nvr", "wb"); break; - case ROM_MEGAPC: f = romfopen("nvr/megapc.nvr", "wb"); break; - case ROM_AMI386: f = romfopen("nvr/ami386.nvr", "wb"); break; - case ROM_AMI486: f = romfopen("nvr/ami486.nvr", "wb"); break; - case ROM_WIN486: f = romfopen("nvr/win486.nvr", "wb"); break; - case ROM_PCI486: f = romfopen("nvr/hot-433.nvr", "wb"); break; - case ROM_SIS496: f = romfopen("nvr/sis496.nvr", "wb"); break; - case ROM_430VX: f = romfopen("nvr/430vx.nvr", "wb"); break; - case ROM_REVENGE: f = romfopen("nvr/revenge.nvr", "wb"); break; - case ROM_ENDEAVOR: f = romfopen("nvr/endeavor.nvr", "wb"); break; - case ROM_PX386: f = romfopen("nvr/px386.nvr", "wb"); break; - case ROM_DTK386: f = romfopen("nvr/dtk386.nvr", "wb"); break; - case ROM_DTK486: f = romfopen("nvr/dtk486.nvr", "wb"); break; - case ROM_R418: f = romfopen("nvr/r418.nvr", "wb"); break; - case ROM_586MC1: f = romfopen("nvr/586mc1.nvr", "wb"); break; - case ROM_PLATO: f = romfopen("nvr/plato.nvr", "wb"); break; - case ROM_MB500N: f = romfopen("nvr/mb500n.nvr", "wb"); break; -#if 0 - case ROM_P54TP4XE: f = romfopen("nvr/p54tp4xe.nvr", "wb"); break; -#endif - case ROM_ACERM3A: f = romfopen("nvr/acerm3a.nvr", "wb"); break; - case ROM_ACERV35N: f = romfopen("nvr/acerv35n.nvr", "wb"); break; -#if 0 - case ROM_P55T2P4: f = romfopen("nvr/p55t2p4.nvr", "wb"); break; -#endif - case ROM_P55TVP4: f = romfopen("nvr/p55tvp4.nvr", "wb"); break; - case ROM_P55VA: f = romfopen("nvr/p55va.nvr", "wb"); break; - case ROM_440FX: f = romfopen("nvr/440fx.nvr", "wb"); break; - case ROM_KN97: f = romfopen("nvr/kn97.nvr", "wb"); break; - case ROM_MARL: f = romfopen("nvr/marl.nvr", "wb"); break; - case ROM_THOR: f = romfopen("nvr/thor.nvr", "wb"); break; + case ROM_PC1512: f = romfopen(nvr_concat("pc1512.nvr"), "wb"); break; + case ROM_PC1640: f = romfopen(nvr_concat("pc1640.nvr"), "wb"); break; + case ROM_PC200: f = romfopen(nvr_concat("pc200.nvr"), "wb"); break; + case ROM_PC2086: f = romfopen(nvr_concat("pc2086.nvr"), "wb"); break; + case ROM_PC3086: f = romfopen(nvr_concat("pc3086.nvr"), "wb"); break; + case ROM_IBMAT: f = romfopen(nvr_concat("at.nvr"), "wb"); break; + case ROM_IBMPS1_2011: f = romfopen(nvr_concat("ibmps1_2011.nvr"), "wb"); break; + case ROM_IBMPS1_2121: f = romfopen(nvr_concat("ibmps1_2121.nvr"), "wb"); break; + case ROM_CMDPC30: f = romfopen(nvr_concat("cmdpc30.nvr"), "wb"); break; + case ROM_AMI286: f = romfopen(nvr_concat("ami286.nvr"), "wb"); break; + case ROM_AWARD286: f = romfopen(nvr_concat("award286.nvr"), "wb"); break; + case ROM_DELL200: f = romfopen(nvr_concat("dell200.nvr"), "wb"); break; + case ROM_IBMAT386: f = romfopen(nvr_concat("at386.nvr"), "wb"); break; + case ROM_DESKPRO_386: f = romfopen(nvr_concat("deskpro386.nvr"), "wb"); break; + case ROM_ACER386: f = romfopen(nvr_concat("acer386.nvr"), "wb"); break; + case ROM_MEGAPC: f = romfopen(nvr_concat("megapc.nvr"), "wb"); break; + case ROM_AMI386: f = romfopen(nvr_concat("ami386.nvr"), "wb"); break; + case ROM_AMI486: f = romfopen(nvr_concat("ami486.nvr"), "wb"); break; + case ROM_WIN486: f = romfopen(nvr_concat("win486.nvr"), "wb"); break; + case ROM_PCI486: f = romfopen(nvr_concat("hot-433.nvr"), "wb"); break; + case ROM_SIS496: f = romfopen(nvr_concat("sis496.nvr"), "wb"); break; + case ROM_430VX: f = romfopen(nvr_concat("430vx.nvr"), "wb"); break; + case ROM_REVENGE: f = romfopen(nvr_concat("revenge.nvr"), "wb"); break; + case ROM_ENDEAVOR: f = romfopen(nvr_concat("endeavor.nvr"), "wb"); break; + case ROM_PX386: f = romfopen(nvr_concat("px386.nvr"), "wb"); break; + case ROM_DTK386: f = romfopen(nvr_concat("dtk386.nvr"), "wb"); break; + case ROM_DTK486: f = romfopen(nvr_concat("dtk486.nvr"), "wb"); break; + case ROM_R418: f = romfopen(nvr_concat("r418.nvr"), "wb"); break; + case ROM_586MC1: f = romfopen(nvr_concat("586mc1.nvr"), "wb"); break; + case ROM_PLATO: f = romfopen(nvr_concat("plato.nvr"), "wb"); break; + case ROM_MB500N: f = romfopen(nvr_concat("mb500n.nvr"), "wb"); break; + case ROM_ACERM3A: f = romfopen(nvr_concat("acerm3a.nvr"), "wb"); break; + case ROM_ACERV35N: f = romfopen(nvr_concat("acerv35n.nvr"), "wb"); break; + case ROM_P55TVP4: f = romfopen(nvr_concat("p55tvp4.nvr"), "wb"); break; + case ROM_P55VA: f = romfopen(nvr_concat("p55va.nvr"), "wb"); break; + case ROM_440FX: f = romfopen(nvr_concat("440fx.nvr"), "wb"); break; + case ROM_KN97: f = romfopen(nvr_concat("kn97.nvr"), "wb"); break; + case ROM_MARL: f = romfopen(nvr_concat("marl.nvr"), "wb"); break; + case ROM_THOR: f = romfopen(nvr_concat("thor.nvr"), "wb"); break; default: return; } fwrite(nvrram,128,1,f); diff --git a/src/pc.c b/src/pc.c index 705689980..71b9cdcfe 100644 --- a/src/pc.c +++ b/src/pc.c @@ -49,6 +49,9 @@ uint8_t ethif; int inum; +char nvr_path[260]; +int path_len; + int window_w, window_h, window_x, window_y, window_remember; int start_in_fullscreen = 0; @@ -239,7 +242,14 @@ void initpc(int argc, char *argv[]) joystick_init(); midi_init(); - append_filename(config_file_default, pcempath, "86box.cfg", 511); + if (config_file == NULL) + { + append_filename(config_file_default, pcempath, "86box.cfg", 511); + } + else + { + append_filename(config_file_default, pcempath, config_file, 511); + } loadconfig(config_file); pclog("Config loaded\n"); @@ -725,6 +735,28 @@ void loadconfig(char *fn) } } } + + memset(nvr_path, 0, 260); + p = (char *)config_get_string(NULL, "nvr_path", "nvr"); + if (p) { + if (strlen(p) <= 228) strcpy(nvr_path, p); + else strcpy(nvr_path, "nvr"); + } + else strcpy(nvr_path, "nvr"); + + if (nvr_path[strlen(nvr_path)] != '/') + { + nvr_path[strlen(nvr_path)] = '/'; + } + + path_len = strlen(nvr_path); +} + +char *nvr_concat(char *to_concat) +{ + memset(nvr_path + path_len, 0, 260 - path_len); + strcpy(nvr_path + path_len, to_concat); + return nvr_path; } void saveconfig() diff --git a/src/sound_adlibgold.c b/src/sound_adlibgold.c index f03997877..b56cc4ee1 100644 --- a/src/sound_adlibgold.c +++ b/src/sound_adlibgold.c @@ -790,7 +790,7 @@ void *adgold_init() for (; c >= 0; c--) attenuation[c] = 0; - f = romfopen("nvr/adgold.bin", "rb"); + f = romfopen(nvr_concat("adgold.bin"), "rb"); if (f) { fread(adgold->adgold_eeprom, 0x18, 1, f); @@ -830,7 +830,7 @@ void adgold_close(void *p) FILE *f; adgold_t *adgold = (adgold_t *)p; - f = romfopen("nvr/adgold.bin", "wb"); + f = romfopen(nvr_concat("adgold.bin"), "wb"); if (f) { fwrite(adgold->adgold_eeprom, 0x18, 1, f); diff --git a/src/tandy_eeprom.c b/src/tandy_eeprom.c index 53dbe576d..2803960cd 100644 --- a/src/tandy_eeprom.c +++ b/src/tandy_eeprom.c @@ -128,10 +128,10 @@ void *tandy_eeprom_init() switch (romset) { case ROM_TANDY1000HX: - f = romfopen("nvr/tandy1000hx.bin" ,"rb"); + f = romfopen(nvr_concat("tandy1000hx.bin"), "rb"); break; case ROM_TANDY1000SL2: - f = romfopen("nvr/tandy1000sl2.bin" ,"rb"); + f = romfopen(nvr_concat("tandy1000sl2.bin"), "rb"); break; } if (f) @@ -155,10 +155,10 @@ void tandy_eeprom_close(void *p) switch (eeprom->romset) { case ROM_TANDY1000HX: - f = romfopen("nvr/tandy1000hx.bin" ,"wb"); + f = romfopen(nvr_concat("tandy1000hx.bin"), "wb"); break; case ROM_TANDY1000SL2: - f = romfopen("nvr/tandy1000sl2.bin" ,"wb"); + f = romfopen(nvr_concat("tandy1000sl2.bin"), "wb"); break; } fwrite(eeprom->store, 128, 1, f);