From 807b710a5d6c14da16226b3700570211522228b9 Mon Sep 17 00:00:00 2001 From: SarahW Date: Thu, 6 Jul 2017 21:25:10 +0100 Subject: [PATCH] Improvements to path handling. Patch from bit. --- src/808x.c | 3 +- src/Makefile.am | 2 +- src/Makefile.linux32 | 2 +- src/Makefile.linux32-wx-sdl2 | 2 +- src/Makefile.linux64 | 2 +- src/Makefile.linux64-wx-sdl2 | 2 +- src/Makefile.mingw | 2 +- src/Makefile.mingw-wx-sdl2 | 2 +- src/Makefile.mingw64 | 2 +- src/Makefile.osx64-wx-sdl2 | 2 +- src/allegro-gui-config-sel.c | 13 +-- src/allegro-main.c | 80 +++++++++++++++- src/config.c | 14 ++- src/config.h | 3 + src/hdd_esdi.c | 4 +- src/ibm.h | 5 - src/intel_flash.c | 6 +- src/mem.c | 178 +++++++++++++++++------------------ src/mfm_xebec.c | 8 +- src/nvr.c | 140 ++++++++++++++------------- src/nvr.h | 2 + src/pc.c | 85 +++++++++-------- src/ps1.c | 8 +- src/ps2_nvr.c | 5 +- src/rom.c | 25 +++-- src/sound_adlibgold.c | 5 +- src/sound_emu8k.c | 4 +- src/sound_sb.c | 2 +- src/tandy_eeprom.c | 9 +- src/tandy_rom.c | 4 +- src/vid_ati18800.c | 4 +- src/vid_ati28800.c | 4 +- src/vid_ati_mach64.c | 8 +- src/vid_cl5429.c | 4 +- src/vid_ega.c | 4 +- src/vid_et4000.c | 4 +- src/vid_et4000w32.c | 4 +- src/vid_genius.c | 2 +- src/vid_oti067.c | 6 +- src/vid_paradise.c | 8 +- src/vid_pc1640.c | 2 +- src/vid_s3.c | 16 ++-- src/vid_s3_virge.c | 8 +- src/vid_tgui9440.c | 4 +- src/vid_tvga.c | 4 +- src/vid_vga.c | 4 +- src/win-config_sel.c | 19 ++-- src/win.c | 38 +++++--- src/wx-config_sel.c | 28 +++--- src/wx-main.cc | 8 +- src/wx-sdl2.c | 51 ++++++++-- src/wx-utils.cc | 57 +++++++++++ src/wx-utils.h | 7 ++ src/x86seg.c | 33 ++++--- src/xtide.c | 8 +- 55 files changed, 588 insertions(+), 368 deletions(-) diff --git a/src/808x.c b/src/808x.c index a78b52c..2f71e08 100644 --- a/src/808x.c +++ b/src/808x.c @@ -23,6 +23,7 @@ #include "timer.h" #include "x86.h" #include "x87.h" +#include "paths.h" int xt_cpu_multi; int nmi = 0; @@ -507,7 +508,7 @@ void dumpregs() // return; // savenvr(); // return; -chdir(pcempath); + chdir(logs_path); nopageerrors=1; /* f=fopen("rram3.dmp","wb"); for (c=0;c<0x8000000;c++) putc(readmemb(c+0x10000000),f); diff --git a/src/Makefile.am b/src/Makefile.am index 2ab6bbc..b5c1e19 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,7 @@ dac.c dells200.c device.c disc.c disc_fdi.c disc_img.c disc_sector.c dma.c esdi_ hdd.c hdd_esdi.c hdd_file.c headland.c i430lx.c i430fx.c i430vx.c ide.c intel.c intel_flash.c io.c jim.c joystick_ch_flightstick_pro.c joystick_standard.c joystick_sw_pad.c \ joystick_tm_fcs.c keyboard.c keyboard_amstrad.c keyboard_at.c keyboard_olim24.c keyboard_pcjr.c keyboard_xt.c \ laserxt.c lpt.c mca.c mcr.c mem.c mfm_at.c mfm_xebec.c model.c mouse.c mouse_ps2.c mouse_serial.c neat.c nmi.c nvr.c olivetti_m24.c \ -opti495.c pc.c pci.c pic.c piix.c pit.c ppi.c ps1.c ps2.c ps2_mca.c ps2_nvr.c rom.c rtc.c scat.c serial.c sio.c sis496.c sound.c \ +opti495.c paths.c pc.c pci.c pic.c piix.c pit.c ppi.c ps1.c ps2.c ps2_mca.c ps2_nvr.c rom.c rtc.c scat.c serial.c sio.c sis496.c sound.c \ sound_ad1848.c sound_adlib.c sound_adlibgold.c sound_cms.c sound_emu8k.c sound_gus.c \ sound_mpu401_uart.c sound_opl.c sound_pas16.c sound_ps1.c sound_pssj.c sound_sb.c sound_sb_dsp.c sound_sn76489.c \ sound_speaker.c sound_ssi2001.c sound_wss.c sound_ym7128.c soundopenal.c tandy_eeprom.c tandy_rom.c \ diff --git a/src/Makefile.linux32 b/src/Makefile.linux32 index 40a175b..5a82431 100644 --- a/src/Makefile.linux32 +++ b/src/Makefile.linux32 @@ -11,7 +11,7 @@ dac.o dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_ hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o \ joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o \ laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o \ -opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ +opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_emu8k.o sound_gus.o \ sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_sb.o sound_sb_dsp.o sound_sn76489.o \ sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o soundopenal.o tandy_eeprom.o tandy_rom.o thread-pthread.o \ diff --git a/src/Makefile.linux32-wx-sdl2 b/src/Makefile.linux32-wx-sdl2 index c0cb649..fe9abe5 100644 --- a/src/Makefile.linux32-wx-sdl2 +++ b/src/Makefile.linux32-wx-sdl2 @@ -9,7 +9,7 @@ dac.o dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_ hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o \ joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o \ laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o \ -opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ +opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_emu8k.o sound_gus.o \ sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_sb.o sound_sb_dsp.o sound_sn76489.o \ sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o soundopenal.o tandy_eeprom.o tandy_rom.o \ diff --git a/src/Makefile.linux64 b/src/Makefile.linux64 index 1234299..1d55536 100644 --- a/src/Makefile.linux64 +++ b/src/Makefile.linux64 @@ -10,7 +10,7 @@ dac.o dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_ hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o \ joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o \ laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o \ -opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ +opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_emu8k.o sound_gus.o \ sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_sb.o sound_sb_dsp.o sound_sn76489.o \ sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o soundopenal.o tandy_eeprom.o tandy_rom.o thread-pthread.o \ diff --git a/src/Makefile.linux64-wx-sdl2 b/src/Makefile.linux64-wx-sdl2 index d4f5305..15c98c1 100644 --- a/src/Makefile.linux64-wx-sdl2 +++ b/src/Makefile.linux64-wx-sdl2 @@ -9,7 +9,7 @@ dac.o dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_ hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o \ joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o \ laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o \ -opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ +opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_emu8k.o sound_gus.o \ sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_sb.o sound_sb_dsp.o sound_sn76489.o \ sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o soundopenal.o tandy_eeprom.o tandy_rom.o \ diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 9e34408..7c8259e 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -8,7 +8,7 @@ OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o ali1429.o amstrad dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o \ i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \ keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o \ - mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o \ + mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o \ scat.o serial.o sio.o sis496.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_dbopl.o \ sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \ sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o \ diff --git a/src/Makefile.mingw-wx-sdl2 b/src/Makefile.mingw-wx-sdl2 index bd47f6a..60feb55 100644 --- a/src/Makefile.mingw-wx-sdl2 +++ b/src/Makefile.mingw-wx-sdl2 @@ -8,7 +8,7 @@ OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o ali1429.o amstrad device.o dells200.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o \ i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \ keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o \ - mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o \ + mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o \ scat.o serial.o sio.o sis496.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_dbopl.o \ sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \ sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o \ diff --git a/src/Makefile.mingw64 b/src/Makefile.mingw64 index 1e108c4..2454ecb 100644 --- a/src/Makefile.mingw64 +++ b/src/Makefile.mingw64 @@ -8,7 +8,7 @@ OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o ali1429.o amstrad dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o \ i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \ keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o \ - mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o \ + mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o \ scat.o serial.o sio.o sis496.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_dbopl.o \ sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \ sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o \ diff --git a/src/Makefile.osx64-wx-sdl2 b/src/Makefile.osx64-wx-sdl2 index a93c541..5e05dc1 100644 --- a/src/Makefile.osx64-wx-sdl2 +++ b/src/Makefile.osx64-wx-sdl2 @@ -9,7 +9,7 @@ dac.o device.o dells200.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_ hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o i430vx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o \ joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o \ laserxt.o lpt.o mca.o mcr.o mem.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_ps2.o mouse_serial.o neat.o nmi.o nvr.o olivetti_m24.o \ -opti495.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ +opti495.o paths.o pc.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o scat.o serial.o sio.o sis496.o sound.o \ sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o sound_emu8k.o sound_gus.o \ sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_sb.o sound_sb_dsp.o sound_sn76489.o \ sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o soundopenal.o tandy_eeprom.o tandy_rom.o \ diff --git a/src/allegro-gui-config-sel.c b/src/allegro-gui-config-sel.c index 5f2b7ff..708889b 100644 --- a/src/allegro-gui-config-sel.c +++ b/src/allegro-gui-config-sel.c @@ -3,6 +3,7 @@ #include "allegro-main.h" #include "allegro-gui.h" #include "config.h" +#include "paths.h" #undef printf typedef struct config_t { @@ -83,7 +84,7 @@ static int new_proc(int msg, DIALOG *d, int c) if (c == 1) { - sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, config_name); + sprintf(config_file_default, "%s%s.cfg", configs_path, config_name); c = settings_configure(); free_configs(); populate_configs(); @@ -106,7 +107,7 @@ static int config_proc(int msg, DIALOG *d, int c) if (name) { - sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, name); + sprintf(config_file_default, "%s%s.cfg", configs_path, name); loadconfig(NULL); return settings_configure(); } @@ -127,7 +128,7 @@ static int hdd_proc(int msg, DIALOG *d, int c) if (name) { - sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, name); + sprintf(config_file_default, "%s%s.cfg", configs_path, name); loadconfig(NULL); return disc_hdconf(); } @@ -165,8 +166,8 @@ static void populate_configs() char cfg[512]; config_t *config = NULL; - strcpy(cfg, pcempath); - strcat(cfg, "/configs/*.cfg"); + strcpy(cfg, configs_path); + strcat(cfg, "*.cfg"); printf("cfg %s\n", cfg); if (al_findfirst(cfg, &info, FA_ALL)) return; @@ -247,7 +248,7 @@ int config_sel() if (name) { - sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, name); + sprintf(config_file_default, "%s%s.cfg", configs_path, name); pclog("config_file_default=%s\n", config_file_default); free_configs(); return 0; diff --git a/src/allegro-main.c b/src/allegro-main.c index 47098f6..2d60650 100644 --- a/src/allegro-main.c +++ b/src/allegro-main.c @@ -14,7 +14,13 @@ #include "plat-mouse.h" #include "sound.h" #include "video.h" - +#include +#include +#include +#include +#include +#include "paths.h" + #undef printf int has_been_inited = 0; @@ -60,10 +66,41 @@ uint64_t timer_read() return 0; } +int dir_exists(char *path) +{ + DIR *dir = opendir(path); + if (dir) + { + closedir(dir); + return 1; + } + return 0; +} + +int create_dir(char *path) +{ + if (!mkdir(path, 0755)) + return 1; + return 0; +} + +void get_pcem_path(char *s, int size) +{ + struct passwd *pw = getpwuid(getuid()); + + strncpy(s, pw->pw_dir, size-10); + append_slash(s, size); + strcat(s, ".pcem/"); + //get_executable_name(s, size); +} + int main(int argc, char *argv[]) { + char s[512]; int frames = 0; int c; + FILE *f; + allegro_init(); allegro_video_init(); install_timer(); @@ -71,12 +108,51 @@ int main(int argc, char *argv[]) install_int_ex(onesec, BPS_TO_TIMER(1)); midi_init(); - getpath(); + paths_init(); + /* create directories if they don't exist */ + if (!dir_exists(pcem_path)) { + if (!create_dir(pcem_path)) + return 0; + append_filename(s, pcem_path, "configs", 511); + if (!dir_exists(s) && !create_dir(s)) + return 0; + + append_filename(s, pcem_path, "roms", 511); + if (!dir_exists(s) && !create_dir(s)) + return 0; + + append_filename(s, pcem_path, "nvr", 511); + if (!dir_exists(s) && !create_dir(s)) + return 0; + + append_filename(s, pcem_path, "logs", 511); + if (!dir_exists(s) && !create_dir(s)) + return 0; + } + + /* set up default paths */ + sprintf(s, "%s%s%c%s", pcem_path, "roms/", get_path_separator(), "/usr/share/pcem/roms/"); + set_default_roms_paths(s); + append_filename(s, pcem_path, "nvr/", 511); + set_default_nvr_path(s); + append_filename(s, pcem_path, "configs/", 511); + set_default_configs_path(s); + append_filename(s, pcem_path, "logs/", 511); + set_default_logs_path(s); + sound_init(); initpc(argc, argv); + /* check if cfg exists, and if not create it */ + append_filename(s, pcem_path, "pcem.cfg", 511); + f = fopen(s, "r"); + if (f) + fclose(f); + else + saveconfig(NULL); + keyboard_init(); mouse_init(); joystick_init(); diff --git a/src/config.c b/src/config.c index ca2a184..48c917a 100644 --- a/src/config.c +++ b/src/config.c @@ -190,8 +190,6 @@ void config_load(int is_global, char *fn) } fclose(f); - - config_dump(is_global); } @@ -353,6 +351,18 @@ void append_filename(char *dest, char *s1, char *s2, int size) sprintf(dest, "%s%s", s1, s2); } +void append_slash(char *s, int size) +{ + int c = strlen(s)-1; + if (s[c] != '/' && s[c] != '\\') + { + if (c < size-2) + strcat(s, "/"); + else + s[c] = '/'; + } +} + void put_backslash(char *s) { int c = strlen(s) - 1; diff --git a/src/config.h b/src/config.h index 23b0a48..174c437 100644 --- a/src/config.h +++ b/src/config.h @@ -3,8 +3,11 @@ char *config_get_string(int is_global, char *head, char *name, char *def); void config_set_int(int is_global, char *head, char *name, int val); void config_set_string(int is_global, char *head, char *name, char *val); +void add_config_callback(void (*loadconfig)(), void (*saveconfig)(), void (*onloaded)()); + char *get_filename(char *s); void append_filename(char *dest, char *s1, char *s2, int size); +void append_slash(char *s, int size); void put_backslash(char *s); char *get_extension(char *s); diff --git a/src/hdd_esdi.c b/src/hdd_esdi.c index 6226425..1b32b1b 100644 --- a/src/hdd_esdi.c +++ b/src/hdd_esdi.c @@ -822,7 +822,7 @@ static void *esdi_init() esdi_t *esdi = malloc(sizeof(esdi_t)); memset(esdi, 0, sizeof(esdi_t)); - rom_init_interleaved(&esdi->bios_rom, "roms/90x8970.bin", "roms/90x8969.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + rom_init_interleaved(&esdi->bios_rom, "90x8970.bin", "90x8969.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); mem_mapping_disable(&esdi->bios_rom.mapping); hdd_load(&esdi->hdd_file[0], 0, ide_fn[0]); @@ -854,7 +854,7 @@ static void esdi_close(void *p) static int esdi_available() { - return rom_present("roms/90x8969.bin") && rom_present("roms/90x8970.bin"); + return rom_present("90x8969.bin") && rom_present("90x8970.bin"); } device_t hdd_esdi_device = diff --git a/src/ibm.h b/src/ibm.h index 47ba64b..81e5ae4 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -503,8 +503,6 @@ int gated,speakval,speakon; #define SND_WSS 9 /*Windows Sound System*/ #define SND_PAS16 10 /*Pro Audio Spectrum 16*/ -char pcempath[512]; - /*Hard disc*/ @@ -561,8 +559,6 @@ void resetpc_cad(); extern int start_in_fullscreen; extern int window_w, window_h, window_x, window_y, window_remember; -void get_executable_name(char *s, int size); - void startblit(); void endblit(); @@ -578,6 +574,5 @@ void resetpchard(); void speedchanged(); void saveconfig(char *fn); -void getpath(); #define UNUSED(x) (void)x diff --git a/src/intel_flash.c b/src/intel_flash.c index 304e873..9846b93 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -162,13 +162,13 @@ void *intel_flash_init(uint8_t type) switch(romset) { case ROM_REVENGE: - strcpy(flash_path, "roms/revenge/"); + strcpy(flash_path, "revenge/"); break; case ROM_ENDEAVOR: - strcpy(flash_path, "roms/endeavor/"); + strcpy(flash_path, "endeavor/"); break; case ROM_430VX: - strcpy(flash_path, "roms/430vx/"); + strcpy(flash_path, "430vx/"); break; default: fatal("intel_flash_init on unsupported ROM set %i\n", romset); diff --git a/src/mem.c b/src/mem.c index e1ae279..a9eb585 100644 --- a/src/mem.c +++ b/src/mem.c @@ -60,7 +60,7 @@ uint8_t romext[32768]; static void mem_load_atide115_bios() { FILE *f; - f=romfopen("roms/ide_at_1_1_5.bin","rb"); + f=romfopen("ide_at_1_1_5.bin","rb"); // is486=0; if (f) @@ -114,9 +114,9 @@ int loadbios() FILE *f=NULL,*ff=NULL; int c; - loadfont("roms/mda.rom", 0); - loadfont("roms/wy700.rom", 3); - loadfont("roms/8x12.bin", 4); + loadfont("mda.rom", 0); + loadfont("wy700.rom", 3); + loadfont("8x12.bin", 4); biosmask = 0xffff; @@ -130,8 +130,8 @@ int loadbios() switch (romset) { case ROM_PC1512: - f=romfopen("roms/pc1512/40043.v1","rb"); - ff=romfopen("roms/pc1512/40044.v1","rb"); + f=romfopen("pc1512/40043.v1","rb"); + ff=romfopen("pc1512/40044.v1","rb"); if (!f || !ff) break; for (c=0xC000;c<0x10000;c+=2) { @@ -140,11 +140,11 @@ int loadbios() } fclose(ff); fclose(f); - loadfont("roms/pc1512/40078.ic127", 2); + loadfont("pc1512/40078.ic127", 2); return 1; case ROM_PC1640: - f=romfopen("roms/pc1640/40044.v3","rb"); - ff=romfopen("roms/pc1640/40043.v3","rb"); + f=romfopen("pc1640/40044.v3","rb"); + ff=romfopen("pc1640/40043.v3","rb"); if (!f || !ff) break; for (c=0xC000;c<0x10000;c+=2) { @@ -153,13 +153,13 @@ int loadbios() } fclose(ff); fclose(f); - f=romfopen("roms/pc1640/40100","rb"); + f=romfopen("pc1640/40100","rb"); if (!f) break; fclose(f); return 1; case ROM_PC200: - f=romfopen("roms/pc200/pc20v2.1","rb"); - ff=romfopen("roms/pc200/pc20v2.0","rb"); + f=romfopen("pc200/pc20v2.1","rb"); + ff=romfopen("pc200/pc20v2.0","rb"); if (!f || !ff) break; for (c=0xC000;c<0x10000;c+=2) { @@ -168,24 +168,24 @@ int loadbios() } fclose(ff); fclose(f); - loadfont("roms/pc200/40109.bin", 1); + loadfont("pc200/40109.bin", 1); return 1; case ROM_TANDY: - f=romfopen("roms/tandy/tandy1t1.020","rb"); + f=romfopen("tandy/tandy1t1.020","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); return 1; case ROM_TANDY1000HX: - f = romfopen("roms/tandy1000hx/v020000.u12", "rb"); + f = romfopen("tandy1000hx/v020000.u12", "rb"); if (!f) break; fread(rom, 0x20000, 1, f); fclose(f); biosmask = 0x1ffff; return 1; case ROM_TANDY1000SL2: - f = romfopen("roms/tandy1000sl2/8079047.hu1" ,"rb"); - ff = romfopen("roms/tandy1000sl2/8079048.hu2","rb"); + f = romfopen("tandy1000sl2/8079047.hu1" ,"rb"); + ff = romfopen("tandy1000sl2/8079048.hu2","rb"); if (!f || !ff) break; fseek(f, 0x30000/2, SEEK_SET); fseek(ff, 0x30000/2, SEEK_SET); @@ -206,11 +206,11 @@ int loadbios() fclose(f); break;*/ case ROM_IBMXT: - f=romfopen("roms/ibmxt/xt.rom","rb"); + f=romfopen("ibmxt/xt.rom","rb"); if (!f) { - f = romfopen("roms/ibmxt/5000027.u19", "rb"); - ff = romfopen("roms/ibmxt/1501512.u18","rb"); + f = romfopen("ibmxt/5000027.u19", "rb"); + ff = romfopen("ibmxt/1501512.u18","rb"); if (!f || !ff) break; fread(rom, 0x8000, 1, f); fread(rom + 0x8000, 0x8000, 1, ff); @@ -227,27 +227,27 @@ int loadbios() break; case ROM_IBMPCJR: - f = romfopen("roms/ibmpcjr/bios.rom","rb"); + f = romfopen("ibmpcjr/bios.rom","rb"); if (!f) break; fread(rom, 0x10000, 1, f); fclose(f); return 1; case ROM_GENXT: - f=romfopen("roms/genxt/pcxt.rom","rb"); + f=romfopen("genxt/pcxt.rom","rb"); if (!f) break; fread(rom+0xE000,8192,1,f); fclose(f); return 1; case ROM_DTKXT: - f=romfopen("roms/dtk/dtk_erso_2.42_2764.bin","rb"); + f=romfopen("dtk/dtk_erso_2.42_2764.bin","rb"); if (!f) break; fread(rom+0xE000,8192,1,f); fclose(f); return 1; case ROM_OLIM24: - f = romfopen("roms/olivetti_m24/olivetti_m24_version_1.43_low.bin" ,"rb"); - ff = romfopen("roms/olivetti_m24/olivetti_m24_version_1.43_high.bin","rb"); + f = romfopen("olivetti_m24/olivetti_m24_version_1.43_low.bin" ,"rb"); + ff = romfopen("olivetti_m24/olivetti_m24_version_1.43_high.bin","rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x4000; c += 2) { @@ -259,8 +259,8 @@ int loadbios() return 1; case ROM_PC2086: - f = romfopen("roms/pc2086/40179.ic129" ,"rb"); - ff = romfopen("roms/pc2086/40180.ic132","rb"); + f = romfopen("pc2086/40179.ic129" ,"rb"); + ff = romfopen("pc2086/40180.ic132","rb"); if (!f || !ff) break; pclog("Loading BIOS\n"); for (c = 0x0000; c < 0x4000; c += 2) @@ -271,32 +271,32 @@ int loadbios() pclog("%02X %02X %02X\n", rom[0xfff0], rom[0xfff1], rom[0xfff2]); fclose(ff); fclose(f); - f = romfopen("roms/pc2086/40186.ic171", "rb"); + f = romfopen("pc2086/40186.ic171", "rb"); if (!f) break; fclose(f); biosmask = 0x3fff; return 1; case ROM_PC3086: - f = romfopen("roms/pc3086/fc00.bin" ,"rb"); + f = romfopen("pc3086/fc00.bin" ,"rb"); if (!f) break; fread(rom, 0x4000, 1, f); fclose(f); - f = romfopen("roms/pc3086/c000.bin", "rb"); + f = romfopen("pc3086/c000.bin", "rb"); if (!f) break; fclose(f); biosmask = 0x3fff; return 1; case ROM_IBMAT: -/* f=romfopen("roms/amic206.bin","rb"); +/* f=romfopen("amic206.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); return 1;*/ case ROM_IBMAT386: - f = romfopen("roms/ibmat/62x0820.u27", "rb"); - ff =romfopen("roms/ibmat/62x0821.u47", "rb"); + f = romfopen("ibmat/62x0820.u27", "rb"); + ff =romfopen("ibmat/62x0821.u47", "rb"); if (!f || !ff) break; for (c=0x0000;c<0x10000;c+=2) { @@ -307,8 +307,8 @@ int loadbios() fclose(f); return 1; case ROM_CMDPC30: - f = romfopen("roms/cmdpc30/commodore pc 30 iii even.bin", "rb"); - ff = romfopen("roms/cmdpc30/commodore pc 30 iii odd.bin", "rb"); + f = romfopen("cmdpc30/commodore pc 30 iii even.bin", "rb"); + ff = romfopen("cmdpc30/commodore pc 30 iii odd.bin", "rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x8000; c += 2) { @@ -320,8 +320,8 @@ int loadbios() biosmask = 0x7fff; return 1; case ROM_DELL200: - f=romfopen("roms/dells200/dell0.bin","rb"); - ff=romfopen("roms/dells200/dell1.bin","rb"); + f=romfopen("dells200/dell0.bin","rb"); + ff=romfopen("dells200/dell1.bin","rb"); if (!f || !ff) break; for (c=0x0000;c<0x10000;c+=2) { @@ -332,46 +332,46 @@ int loadbios() fclose(f); return 1; /* case ROM_IBMAT386: - f=romfopen("roms/at386/at386.bin","rb"); + f=romfopen("at386/at386.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); return 1;*/ case ROM_AMI386SX: -// f=romfopen("roms/at386/at386.bin","rb"); - f=romfopen("roms/ami386/ami386.bin","rb"); +// f=romfopen("at386/at386.bin","rb"); + f=romfopen("ami386/ami386.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); return 1; case ROM_AMI386DX_OPTI495: /*This uses the OPTi 82C495 chipset*/ - f=romfopen("roms/ami386dx/opt495sx.ami","rb"); + f=romfopen("ami386dx/opt495sx.ami","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); return 1; case ROM_MR386DX_OPTI495: /*This uses the OPTi 82C495 chipset*/ - f=romfopen("roms/mr386dx/opt495sx.mr","rb"); + f=romfopen("mr386dx/opt495sx.mr","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); return 1; case ROM_ACER386: - f=romfopen("roms/acer386/acer386.bin","rb"); + f=romfopen("acer386/acer386.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); rom[0xB0]=0xB0-0x51; rom[0x40d4]=0x51; /*PUSH CX*/ - f=romfopen("roms/acer386/oti067.bin","rb"); + f=romfopen("acer386/oti067.bin","rb"); if (!f) break; fclose(f); return 1; case ROM_AMI286: - f=romfopen("roms/ami286/amic206.bin","rb"); + f=romfopen("ami286/amic206.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); @@ -379,7 +379,7 @@ int loadbios() return 1; case ROM_AWARD286: - f=romfopen("roms/award286/award.bin","rb"); + f=romfopen("award286/award.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); @@ -387,7 +387,7 @@ int loadbios() case ROM_EUROPC: // return 0; - f=romfopen("roms/europc/50145","rb"); + f=romfopen("europc/50145","rb"); if (!f) break; fread(rom+0x8000,32768,1,f); fclose(f); @@ -395,18 +395,18 @@ int loadbios() return 1; case ROM_IBMPC: - f=romfopen("roms/ibmpc/pc102782.bin","rb"); + f=romfopen("ibmpc/pc102782.bin","rb"); if (!f) break; // f=fopen("pc081682.bin","rb"); fread(rom+0xE000,8192,1,f); fclose(f); - if (!mem_load_basic("roms/ibmpc")) + if (!mem_load_basic("ibmpc")) break; return 1; case ROM_MEGAPC: - f = romfopen("roms/megapc/41651-bios lo.u18", "rb"); - ff = romfopen("roms/megapc/211253-bios hi.u19", "rb"); + f = romfopen("megapc/41651-bios lo.u18", "rb"); + ff = romfopen("megapc/211253-bios hi.u19", "rb"); if (!f || !ff) break; fseek(f, 0x8000, SEEK_SET); fseek(ff, 0x8000, SEEK_SET); @@ -420,7 +420,7 @@ int loadbios() return 1; case ROM_AMI486: - f=romfopen("roms/ami486/ami486.bin","rb"); + f=romfopen("ami486/ami486.bin","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); @@ -428,8 +428,8 @@ int loadbios() return 1; case ROM_WIN486: -// f=romfopen("roms/win486/win486.bin","rb"); - f=romfopen("roms/win486/ali1429g.amw","rb"); +// f=romfopen("win486/win486.bin","rb"); + f=romfopen("win486/ali1429g.amw","rb"); if (!f) break; fread(rom,65536,1,f); fclose(f); @@ -437,7 +437,7 @@ int loadbios() return 1; case ROM_PCI486: - f=romfopen("roms/hot-433/hot-433.ami","rb"); + f=romfopen("hot-433/hot-433.ami","rb"); if (!f) break; fread(rom, 0x20000, 1, f); fclose(f); @@ -446,7 +446,7 @@ int loadbios() return 1; case ROM_SIS496: - f = romfopen("roms/sis496/sis496-1.awa", "rb"); + f = romfopen("sis496/sis496-1.awa", "rb"); if (!f) break; fread(rom, 0x20000, 1, f); fclose(f); @@ -455,10 +455,10 @@ int loadbios() return 1; case ROM_430VX: -// f = romfopen("roms/430vx/ga586atv.bin", "rb"); -// f = fopen("roms/430vx/vx29.bin", "rb"); - f = romfopen("roms/430vx/55xwuq0e.bin", "rb"); -// f=romfopen("roms/430vx/430vx","rb"); +// f = romfopen("430vx/ga586atv.bin", "rb"); +// f = fopen("430vx/vx29.bin", "rb"); + f = romfopen("430vx/55xwuq0e.bin", "rb"); +// f=romfopen("430vx/430vx","rb"); if (!f) break; fread(rom, 0x20000, 1, f); fclose(f); @@ -467,12 +467,12 @@ int loadbios() return 1; case ROM_REVENGE: - f = romfopen("roms/revenge/1009af2_.bio", "rb"); + f = romfopen("revenge/1009af2_.bio", "rb"); if (!f) break; fseek(f, 0x80, SEEK_SET); fread(rom + 0x10000, 0x10000, 1, f); fclose(f); - f = romfopen("roms/revenge/1009af2_.bi1", "rb"); + f = romfopen("revenge/1009af2_.bi1", "rb"); if (!f) break; fseek(f, 0x80, SEEK_SET); fread(rom, 0xc000, 1, f); @@ -481,12 +481,12 @@ int loadbios() //is486=1; return 1; case ROM_ENDEAVOR: - f = romfopen("roms/endeavor/1006cb0_.bio", "rb"); + f = romfopen("endeavor/1006cb0_.bio", "rb"); if (!f) break; fseek(f, 0x80, SEEK_SET); fread(rom + 0x10000, 0x10000, 1, f); fclose(f); - f = romfopen("roms/endeavor/1006cb0_.bi1", "rb"); + f = romfopen("endeavor/1006cb0_.bi1", "rb"); if (!f) break; fseek(f, 0x80, SEEK_SET); fread(rom, 0xd000, 1, f); @@ -497,8 +497,8 @@ int loadbios() case ROM_IBMPS1_2011: #if 0 - f=romfopen("roms/ibmps1es/ibm_1057757_24-05-90.bin","rb"); - ff=romfopen("roms/ibmps1es/ibm_1057757_29-15-90.bin","rb"); + f=romfopen("ibmps1es/ibm_1057757_24-05-90.bin","rb"); + ff=romfopen("ibmps1es/ibm_1057757_29-15-90.bin","rb"); fseek(f, 0x10000, SEEK_SET); fseek(ff, 0x10000, SEEK_SET); if (!f || !ff) break; @@ -511,7 +511,7 @@ int loadbios() fclose(f); #endif //#if 0 - f = romfopen("roms/ibmps1es/f80000.bin", "rb"); + f = romfopen("ibmps1es/f80000.bin", "rb"); if (!f) break; fseek(f, 0x60000, SEEK_SET); fread(rom, 0x20000, 1, f); @@ -522,7 +522,7 @@ int loadbios() return 1; case ROM_IBMPS1_2121: - f = romfopen("roms/ibmps1_2121/fc0000.bin", "rb"); + f = romfopen("ibmps1_2121/fc0000.bin", "rb"); if (!f) break; fseek(f, 0x20000, SEEK_SET); fread(rom, 0x20000, 1, f); @@ -531,8 +531,8 @@ int loadbios() return 1; case ROM_DESKPRO_386: - f=romfopen("roms/deskpro386/109592-005.u11.bin","rb"); - ff=romfopen("roms/deskpro386/109591-005.u13.bin","rb"); + f=romfopen("deskpro386/109592-005.u11.bin","rb"); + ff=romfopen("deskpro386/109591-005.u13.bin","rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x8000; c += 2) { @@ -545,33 +545,33 @@ int loadbios() return 1; case ROM_AMIXT: - f = romfopen("roms/amixt/ami_8088_bios_31jan89.bin", "rb"); + f = romfopen("amixt/ami_8088_bios_31jan89.bin", "rb"); if (!f) break; fread(rom + 0xE000, 8192, 1, f); fclose(f); return 1; case ROM_LTXT: - f = romfopen("roms/ltxt/27c64.bin", "rb"); + f = romfopen("ltxt/27c64.bin", "rb"); if (!f) break; fread(rom + 0xE000, 8192, 1, f); fclose(f); - if (!mem_load_basic("roms/ltxt")) + if (!mem_load_basic("ltxt")) break; return 1; case ROM_LXT3: - f = romfopen("roms/lxt3/27c64d.bin", "rb"); + f = romfopen("lxt3/27c64d.bin", "rb"); if (!f) break; fread(rom + 0xE000, 8192, 1, f); fclose(f); - if (!mem_load_basic("roms/lxt3")) + if (!mem_load_basic("lxt3")) break; return 1; case ROM_PX386: /*Phoenix 80386 BIOS*/ - f=romfopen("roms/px386/3iip001l.bin","rb"); - ff=romfopen("roms/px386/3iip001h.bin","rb"); + f=romfopen("px386/3iip001l.bin","rb"); + ff=romfopen("px386/3iip001h.bin","rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x10000; c += 2) { @@ -583,28 +583,28 @@ int loadbios() return 1; case ROM_DTK386: /*Uses NEAT chipset*/ - f = romfopen("roms/dtk386/3cto001.bin", "rb"); + f = romfopen("dtk386/3cto001.bin", "rb"); if (!f) break; fread(rom, 65536, 1, f); fclose(f); return 1; case ROM_PXXT: - f = romfopen("roms/pxxt/000p001.bin", "rb"); + f = romfopen("pxxt/000p001.bin", "rb"); if (!f) break; fread(rom + 0xE000, 8192, 1, f); fclose(f); return 1; case ROM_JUKOPC: - f = romfopen("roms/jukopc/000o001.bin", "rb"); + f = romfopen("jukopc/000o001.bin", "rb"); if (!f) break; fread(rom + 0xE000, 8192, 1, f); fclose(f); return 1; case ROM_IBMPS2_M30_286: - f = romfopen("roms/ibmps2_m30_286/33f5381a.bin", "rb"); + f = romfopen("ibmps2_m30_286/33f5381a.bin", "rb"); if (!f) break; fread(rom, 0x20000, 1, f); fclose(f); @@ -612,8 +612,8 @@ int loadbios() return 1; case ROM_IBMPS2_M50: - f=romfopen("roms/i8550021/90x7423.zm14","rb"); - ff=romfopen("roms/i8550021/90x7426.zm16","rb"); + f=romfopen("i8550021/90x7423.zm14","rb"); + ff=romfopen("i8550021/90x7426.zm16","rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x10000; c += 2) { @@ -622,8 +622,8 @@ int loadbios() } fclose(ff); fclose(f); - f=romfopen("roms/i8550021/90x7420.zm13","rb"); - ff=romfopen("roms/i8550021/90x7429.zm18","rb"); + f=romfopen("i8550021/90x7420.zm13","rb"); + ff=romfopen("i8550021/90x7429.zm18","rb"); if (!f || !ff) break; for (c = 0x10000; c < 0x20000; c += 2) { @@ -636,8 +636,8 @@ int loadbios() return 1; case ROM_IBMPS2_M55SX: - f=romfopen("roms/i8555081/33f8146.zm41","rb"); - ff=romfopen("roms/i8555081/33f8145.zm40","rb"); + f=romfopen("i8555081/33f8146.zm41","rb"); + ff=romfopen("i8555081/33f8145.zm40","rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x20000; c += 2) { @@ -650,8 +650,8 @@ int loadbios() return 1; case ROM_IBMPS2_M80: - f=romfopen("roms/i8580111/15f6637.bin","rb"); - ff=romfopen("roms/i8580111/15f6639.bin","rb"); + f=romfopen("i8580111/15f6637.bin","rb"); + ff=romfopen("i8580111/15f6639.bin","rb"); if (!f || !ff) break; for (c = 0x0000; c < 0x20000; c += 2) { diff --git a/src/mfm_xebec.c b/src/mfm_xebec.c index 9cfdf23..7c185f2 100644 --- a/src/mfm_xebec.c +++ b/src/mfm_xebec.c @@ -825,7 +825,7 @@ static void *xebec_init() hdd_load(&xebec->drives[1].hdd_file, 1, ide_fn[1]); xebec_set_switches(xebec); - rom_init(&xebec->bios_rom, "roms/ibm_xebec_62x0822_1985.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&xebec->bios_rom, "ibm_xebec_62x0822_1985.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); io_sethandler(0x0320, 0x0004, xebec_read, NULL, NULL, xebec_write, NULL, NULL, xebec); @@ -846,7 +846,7 @@ static void xebec_close(void *p) static int xebec_available() { - return rom_present("roms/ibm_xebec_62x0822_1985.bin"); + return rom_present("ibm_xebec_62x0822_1985.bin"); } device_t mfm_xebec_device = @@ -876,7 +876,7 @@ static void *dtc_5150x_init() xebec->drives[1].cfg_cyl = xebec->drives[1].hdd_file.tracks; xebec->drives[1].cfg_hpc = xebec->drives[1].hdd_file.hpc; - rom_init(&xebec->bios_rom, "roms/dtc_cxd21a.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&xebec->bios_rom, "dtc_cxd21a.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); io_sethandler(0x0320, 0x0004, xebec_read, NULL, NULL, xebec_write, NULL, NULL, xebec); @@ -886,7 +886,7 @@ static void *dtc_5150x_init() } static int dtc_5150x_available() { - return rom_present("roms/dtc_cxd21a.bin"); + return rom_present("dtc_cxd21a.bin"); } device_t dtc_5150x_device = diff --git a/src/nvr.c b/src/nvr.c index 419e7b9..33df4b6 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -5,6 +5,8 @@ #include "pic.h" #include "timer.h" #include "rtc.h" +#include "paths.h" +#include "config.h" int oldromset; int nvrmask=63; @@ -17,6 +19,16 @@ static int nvr_onesec_time = 0, nvr_onesec_cnt = 0; static int rtctime; +FILE *nvrfopen(char *fn, char *mode) +{ + char s[512]; + + strcpy(s, nvr_path); + put_backslash(s); + strcat(s, fn); + return fopen(s, mode); +} + void getnvrtime() { time_get(nvrram); @@ -200,38 +212,38 @@ 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_IBMPS2_M30_286: f = romfopen("nvr/ibmps2_m30_286.nvr", "rb"); /*nvrmask = 127; */break; - case ROM_IBMPS2_M50: f = romfopen("nvr/ibmps2_m50.nvr", "rb"); break; - case ROM_IBMPS2_M55SX: f = romfopen("nvr/ibmps2_m55sx.nvr", "rb"); break; - case ROM_IBMPS2_M80: f = romfopen("nvr/ibmps2_m80.nvr", "rb"); 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_AMI386SX: 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_MR386DX_OPTI495: f = romfopen("nvr/mr386dx_opti495.nvr", "rb"); nvrmask = 127; break; - case ROM_AMI386DX_OPTI495: f = romfopen("nvr/ami386dx_opti495.nvr", "rb"); nvrmask = 127; break; + case ROM_PC1512: f = nvrfopen("pc1512.nvr", "rb"); break; + case ROM_PC1640: f = nvrfopen("pc1640.nvr", "rb"); break; + case ROM_PC200: f = nvrfopen("pc200.nvr", "rb"); break; + case ROM_PC2086: f = nvrfopen("pc2086.nvr", "rb"); break; + case ROM_PC3086: f = nvrfopen("pc3086.nvr", "rb"); break; + case ROM_IBMAT: f = nvrfopen("at.nvr", "rb"); break; + case ROM_IBMPS1_2011: f = nvrfopen("ibmps1_2011.nvr", "rb"); /*nvrmask = 127; */break; + case ROM_IBMPS1_2121: f = nvrfopen("ibmps1_2121.nvr", "rb"); nvrmask = 127; break; + case ROM_IBMPS2_M30_286: f = nvrfopen("ibmps2_m30_286.nvr", "rb"); /*nvrmask = 127; */break; + case ROM_IBMPS2_M50: f = nvrfopen("ibmps2_m50.nvr", "rb"); break; + case ROM_IBMPS2_M55SX: f = nvrfopen("ibmps2_m55sx.nvr", "rb"); break; + case ROM_IBMPS2_M80: f = nvrfopen("ibmps2_m80.nvr", "rb"); break; + case ROM_CMDPC30: f = nvrfopen("cmdpc30.nvr", "rb"); nvrmask = 127; break; + case ROM_AMI286: f = nvrfopen("ami286.nvr", "rb"); nvrmask = 127; break; + case ROM_AWARD286: f = nvrfopen("award286.nvr", "rb"); nvrmask = 127; break; + case ROM_DELL200: f = nvrfopen("dell200.nvr", "rb"); nvrmask = 127; break; + case ROM_IBMAT386: f = nvrfopen("at386.nvr", "rb"); nvrmask = 127; break; + case ROM_DESKPRO_386: f = nvrfopen("deskpro386.nvr", "rb"); break; + case ROM_ACER386: f = nvrfopen("acer386.nvr", "rb"); nvrmask = 127; break; + case ROM_MEGAPC: f = nvrfopen("megapc.nvr", "rb"); nvrmask = 127; break; + case ROM_AMI386SX: f = nvrfopen("ami386.nvr", "rb"); nvrmask = 127; break; + case ROM_AMI486: f = nvrfopen("ami486.nvr", "rb"); nvrmask = 127; break; + case ROM_WIN486: f = nvrfopen("win486.nvr", "rb"); nvrmask = 127; break; + case ROM_PCI486: f = nvrfopen("hot-433.nvr", "rb"); nvrmask = 127; break; + case ROM_SIS496: f = nvrfopen("sis496.nvr", "rb"); nvrmask = 127; break; + case ROM_430VX: f = nvrfopen("430vx.nvr", "rb"); nvrmask = 127; break; + case ROM_REVENGE: f = nvrfopen("revenge.nvr", "rb"); nvrmask = 127; break; + case ROM_ENDEAVOR: f = nvrfopen("endeavor.nvr", "rb"); nvrmask = 127; break; + case ROM_PX386: f = nvrfopen("px386.nvr", "rb"); nvrmask = 127; break; + case ROM_DTK386: f = nvrfopen("dtk386.nvr", "rb"); nvrmask = 127; break; + case ROM_MR386DX_OPTI495: f = nvrfopen("mr386dx_opti495.nvr", "rb"); nvrmask = 127; break; + case ROM_AMI386DX_OPTI495: f = nvrfopen("ami386dx_opti495.nvr", "rb"); nvrmask = 127; break; default: return; } if (!f) @@ -263,38 +275,38 @@ 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_IBMPS2_M30_286: f = romfopen("nvr/ibmps2_m30_286.nvr", "wb"); break; - case ROM_IBMPS2_M50: f = romfopen("nvr/ibmps2_m50.nvr", "wb"); break; - case ROM_IBMPS2_M55SX: f = romfopen("nvr/ibmps2_m55sx.nvr", "wb"); break; - case ROM_IBMPS2_M80: f = romfopen("nvr/ibmps2_m80.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_AMI386SX: 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_MR386DX_OPTI495: f = romfopen("nvr/mr386dx_opti495.nvr", "wb"); break; - case ROM_AMI386DX_OPTI495: f = romfopen("nvr/ami386dx_opti495.nvr", "wb"); break; + case ROM_PC1512: f = nvrfopen("pc1512.nvr", "wb"); break; + case ROM_PC1640: f = nvrfopen("pc1640.nvr", "wb"); break; + case ROM_PC200: f = nvrfopen("pc200.nvr", "wb"); break; + case ROM_PC2086: f = nvrfopen("pc2086.nvr", "wb"); break; + case ROM_PC3086: f = nvrfopen("pc3086.nvr", "wb"); break; + case ROM_IBMAT: f = nvrfopen("at.nvr", "wb"); break; + case ROM_IBMPS1_2011: f = nvrfopen("ibmps1_2011.nvr", "wb"); break; + case ROM_IBMPS1_2121: f = nvrfopen("ibmps1_2121.nvr", "wb"); break; + case ROM_IBMPS2_M30_286: f = nvrfopen("ibmps2_m30_286.nvr", "wb"); break; + case ROM_IBMPS2_M50: f = nvrfopen("ibmps2_m50.nvr", "wb"); break; + case ROM_IBMPS2_M55SX: f = nvrfopen("ibmps2_m55sx.nvr", "wb"); break; + case ROM_IBMPS2_M80: f = nvrfopen("ibmps2_m80.nvr", "wb"); break; + case ROM_CMDPC30: f = nvrfopen("cmdpc30.nvr", "wb"); break; + case ROM_AMI286: f = nvrfopen("ami286.nvr", "wb"); break; + case ROM_AWARD286: f = nvrfopen("award286.nvr", "wb"); break; + case ROM_DELL200: f = nvrfopen("dell200.nvr", "wb"); break; + case ROM_IBMAT386: f = nvrfopen("at386.nvr", "wb"); break; + case ROM_DESKPRO_386: f = nvrfopen("deskpro386.nvr", "wb"); break; + case ROM_ACER386: f = nvrfopen("acer386.nvr", "wb"); break; + case ROM_MEGAPC: f = nvrfopen("megapc.nvr", "wb"); break; + case ROM_AMI386SX: f = nvrfopen("ami386.nvr", "wb"); break; + case ROM_AMI486: f = nvrfopen("ami486.nvr", "wb"); break; + case ROM_WIN486: f = nvrfopen("win486.nvr", "wb"); break; + case ROM_PCI486: f = nvrfopen("hot-433.nvr", "wb"); break; + case ROM_SIS496: f = nvrfopen("sis496.nvr", "wb"); break; + case ROM_430VX: f = nvrfopen("430vx.nvr", "wb"); break; + case ROM_REVENGE: f = nvrfopen("revenge.nvr", "wb"); break; + case ROM_ENDEAVOR: f = nvrfopen("endeavor.nvr", "wb"); break; + case ROM_PX386: f = nvrfopen("px386.nvr", "wb"); break; + case ROM_DTK386: f = nvrfopen("dtk386.nvr", "wb"); break; + case ROM_MR386DX_OPTI495: f = nvrfopen("mr386dx_opti495.nvr", "wb"); break; + case ROM_AMI386DX_OPTI495: f = nvrfopen("ami386dx_opti495.nvr", "wb"); break; default: return; } fwrite(nvrram,128,1,f); diff --git a/src/nvr.h b/src/nvr.h index c04289f..1a60fdf 100644 --- a/src/nvr.h +++ b/src/nvr.h @@ -8,3 +8,5 @@ void loadnvr(); void savenvr(); void nvr_recalc(); + +FILE *nvrfopen(char *fn, char *mode); diff --git a/src/pc.c b/src/pc.c index 0e900ed..ac44c99 100644 --- a/src/pc.c +++ b/src/pc.c @@ -47,6 +47,7 @@ #include "amstrad.h" #include "hdd.h" #include "x86.h" +#include "paths.h" int window_w, window_h, window_x, window_y, window_remember; @@ -79,37 +80,47 @@ FILE *pclogf; void pclog(const char *format, ...) { #ifndef RELEASE_BUILD - char buf[1024]; - //return; - if (!pclogf) - pclogf=fopen("pclog.txt","wt"); -//return; - va_list ap; - va_start(ap, format); - vsprintf(buf, format, ap); - va_end(ap); - fputs(buf,pclogf); -//fflush(pclogf); + char buf[1024]; + //return; + if (!pclogf) + { + strcpy(buf, logs_path); + put_backslash(buf); + strcat(buf, "pcem.log"); + pclogf=fopen(buf, "wt"); + } + //return; + va_list ap; + va_start(ap, format); + vsprintf(buf, format, ap); + va_end(ap); + fputs(buf,pclogf); + //fflush(pclogf); #endif } void fatal(const char *format, ...) { - char buf[256]; -// return; - if (!pclogf) - pclogf=fopen("pclog.txt","wt"); -//return; - va_list ap; - va_start(ap, format); - vsprintf(buf, format, ap); - va_end(ap); - fputs(buf,pclogf); - fflush(pclogf); - savenvr(); - dumppic(); - dumpregs(); - exit(-1); + char buf[256]; + // return; + if (!pclogf) + { + strcpy(buf, logs_path); + put_backslash(buf); + strcat(buf, "pcem.log"); + pclogf=fopen(buf, "wt"); + } + //return; + va_list ap; + va_start(ap, format); + vsprintf(buf, format, ap); + va_end(ap); + fputs(buf,pclogf); + fflush(pclogf); + savenvr(); + dumppic(); + dumpregs(); + exit(-1); } uint8_t cgastat; @@ -205,16 +216,7 @@ void pc_reset() // video_init(); } #undef printf -void getpath() -{ - char *p; - - get_executable_name(pcempath,511); - pclog("executable_name = %s\n", pcempath); - p=get_filename(pcempath); - *p=0; - pclog("path = %s\n", pcempath); -} + void initpc(int argc, char *argv[]) { @@ -246,7 +248,7 @@ void initpc(int argc, char *argv[]) } } -// append_filename(config_file_default, pcempath, "pcem.cfg", 511); +// append_filename(config_file_default, pcempath, "pcem.cfg", 511); loadconfig(NULL); pclog("Config loaded\n"); @@ -613,7 +615,7 @@ void loadconfig(char *fn) char global_config_file[512]; char *p; - append_filename(global_config_file, pcempath, "pcem.cfg", 511); + append_filename(global_config_file, pcem_path, "pcem.cfg", 511); config_load(CFG_GLOBAL, global_config_file); @@ -765,6 +767,9 @@ void loadconfig(char *fn) for (d = 0; d < num_config_callbacks; ++d) if (config_callbacks[d].onloaded) config_callbacks[d].onloaded(); + + config_dump(CFG_GLOBAL); + config_dump(CFG_MACHINE); } void saveconfig(char *fn) @@ -772,7 +777,7 @@ void saveconfig(char *fn) int c, d; char global_config_file[512]; - append_filename(global_config_file, pcempath, "pcem.cfg", 511); + append_filename(global_config_file, pcem_path, "pcem.cfg", 511); config_set_int(CFG_GLOBAL, NULL, "vid_resize", vid_resize); config_set_int(CFG_GLOBAL, NULL, "vid_force_aspect_ratio", video_force_aspect_ration); @@ -877,7 +882,7 @@ void saveconfig(char *fn) pclog("config_save(%s)\n", config_file_default); if (fn) config_save(CFG_MACHINE, fn); - else + else if (strlen(config_file_default)) config_save(CFG_MACHINE, config_file_default); config_save(CFG_GLOBAL, global_config_file); diff --git a/src/ps1.c b/src/ps1.c index 72fa773..6450767 100644 --- a/src/ps1.c +++ b/src/ps1.c @@ -131,15 +131,15 @@ void ps1mb_init() io_sethandler(0x0324, 0x0001, ps1_read, NULL, NULL, ps1_write, NULL, NULL, NULL); rom_init(&ps1_high_rom, - "roms/ibmps1es/f80000.bin", + "ibmps1es/f80000.bin", 0xf80000, 0x80000, 0x7ffff, 0, MEM_MAPPING_EXTERNAL); /* rom_init_interleaved(&ps1_high_rom, - "roms/ibmps1es/ibm_1057757_24-05-90.bin", - "roms/ibmps1es/ibm_1057757_29-15-90.bin", + "ibmps1es/ibm_1057757_24-05-90.bin", + "ibmps1es/ibm_1057757_29-15-90.bin", 0xfc0000, 0x40000, 0x3ffff, @@ -283,7 +283,7 @@ void ps1mb_m2121_init() io_sethandler(0x0190, 0x0001, ps1_m2121_read, NULL, NULL, ps1_m2121_write, NULL, NULL, NULL); rom_init(&ps1_high_rom, - "roms/ibmps1_2121/fc0000.bin", + "ibmps1_2121/fc0000.bin", 0xfc0000, 0x40000, 0x3ffff, diff --git a/src/ps2_nvr.c b/src/ps2_nvr.c index 1225f69..ed1896b 100644 --- a/src/ps2_nvr.c +++ b/src/ps2_nvr.c @@ -3,6 +3,7 @@ #include "device.h" #include "io.h" #include "ps2_nvr.h" +#include "nvr.h" typedef struct ps2_nvr_t { @@ -57,7 +58,7 @@ static void *ps2_nvr_init() switch (romset) { - case ROM_IBMPS2_M80: f = romfopen("nvr/ibmps2_m80_sec.nvr", "rb"); break; + case ROM_IBMPS2_M80: f = nvrfopen("ibmps2_m80_sec.nvr", "rb"); break; } if (f) { @@ -77,7 +78,7 @@ static void ps2_nvr_close(void *p) switch (romset) { - case ROM_IBMPS2_M80: f = romfopen("nvr/ibmps2_m80_sec.nvr", "wb"); break; + case ROM_IBMPS2_M80: f = nvrfopen("ibmps2_m80_sec.nvr", "wb"); break; } if (f) { diff --git a/src/rom.c b/src/rom.c index b83b098..49f0fc1 100644 --- a/src/rom.c +++ b/src/rom.c @@ -4,25 +4,30 @@ #include "config.h" #include "mem.h" #include "rom.h" +#include "paths.h" FILE *romfopen(char *fn, char *mode) { + FILE *f; char s[512]; - strcpy(s, pcempath); - put_backslash(s); - strcat(s, fn); - return fopen(s, mode); + int i; + + for (i = 0; i < num_roms_paths; ++i) + { + get_roms_path(i, s, 511); + put_backslash(s); + strcat(s, fn); + f = fopen(s, mode); + if (f) + return f; + } + return 0; } int rom_present(char *fn) { FILE *f; - char s[512]; - - strcpy(s, pcempath); - put_backslash(s); - strcat(s, fn); - f = fopen(s, "rb"); + f = romfopen(fn, "rb"); if (f) { fclose(f); diff --git a/src/sound_adlibgold.c b/src/sound_adlibgold.c index 1f62dc4..507751c 100644 --- a/src/sound_adlibgold.c +++ b/src/sound_adlibgold.c @@ -11,6 +11,7 @@ #include "pit.h" #include "sound.h" #include "timer.h" +#include "nvr.h" #include "filters.h" @@ -788,7 +789,7 @@ void *adgold_init() for (; c >= 0; c--) attenuation[c] = 0; - f = romfopen("nvr/adgold.bin", "rb"); + f = nvrfopen("adgold.bin", "rb"); if (f) { fread(adgold->adgold_eeprom, 0x18, 1, f); @@ -828,7 +829,7 @@ void adgold_close(void *p) FILE *f; adgold_t *adgold = (adgold_t *)p; - f = romfopen("nvr/adgold.bin", "wb"); + f = nvrfopen("adgold.bin", "wb"); if (f) { fwrite(adgold->adgold_eeprom, 0x18, 1, f); diff --git a/src/sound_emu8k.c b/src/sound_emu8k.c index 49d8216..640eb06 100644 --- a/src/sound_emu8k.c +++ b/src/sound_emu8k.c @@ -676,9 +676,9 @@ void emu8k_init(emu8k_t *emu8k, int onboard_ram) int c; double out; - f = romfopen("roms/awe32.raw", "rb"); + f = romfopen("awe32.raw", "rb"); if (!f) - fatal("ROMS/AWE32.RAW not found\n"); + fatal("AWE32.RAW not found\n"); if (onboard_ram) { diff --git a/src/sound_sb.c b/src/sound_sb.c index 8b27138..f52fea6 100644 --- a/src/sound_sb.c +++ b/src/sound_sb.c @@ -619,7 +619,7 @@ void *sb_16_init() int sb_awe32_available() { - return rom_present("roms/awe32.raw"); + return rom_present("awe32.raw"); } void *sb_awe32_init() diff --git a/src/tandy_eeprom.c b/src/tandy_eeprom.c index a29e272..0682a52 100644 --- a/src/tandy_eeprom.c +++ b/src/tandy_eeprom.c @@ -3,6 +3,7 @@ #include "io.h" #include "device.h" #include "tandy_eeprom.h" +#include "nvr.h" typedef struct { @@ -126,10 +127,10 @@ void *tandy_eeprom_init() switch (romset) { case ROM_TANDY1000HX: - f = romfopen("nvr/tandy1000hx.bin" ,"rb"); + f = nvrfopen("tandy1000hx.bin" ,"rb"); break; case ROM_TANDY1000SL2: - f = romfopen("nvr/tandy1000sl2.bin" ,"rb"); + f = nvrfopen("tandy1000sl2.bin" ,"rb"); break; } if (f) @@ -153,10 +154,10 @@ void tandy_eeprom_close(void *p) switch (eeprom->romset) { case ROM_TANDY1000HX: - f = romfopen("nvr/tandy1000hx.bin" ,"wb"); + f = nvrfopen("tandy1000hx.bin" ,"wb"); break; case ROM_TANDY1000SL2: - f = romfopen("nvr/tandy1000sl2.bin" ,"wb"); + f = nvrfopen("tandy1000sl2.bin" ,"wb"); break; } fwrite(eeprom->store, 128, 1, f); diff --git a/src/tandy_rom.c b/src/tandy_rom.c index becf8d7..df49d87 100644 --- a/src/tandy_rom.c +++ b/src/tandy_rom.c @@ -56,8 +56,8 @@ void *tandy_rom_init() tandy_rom = malloc(0x80000); - f = romfopen("roms/tandy1000sl2/8079047.hu1" ,"rb"); - ff = romfopen("roms/tandy1000sl2/8079048.hu2","rb"); + f = romfopen("tandy1000sl2/8079047.hu1" ,"rb"); + ff = romfopen("tandy1000sl2/8079048.hu2","rb"); for (c = 0x0000; c < 0x80000; c += 2) { tandy_rom[c] = getc(f); diff --git a/src/vid_ati18800.c b/src/vid_ati18800.c index f3a9cac..7e672a0 100644 --- a/src/vid_ati18800.c +++ b/src/vid_ati18800.c @@ -128,7 +128,7 @@ void *ati18800_init() ati18800_t *ati18800 = malloc(sizeof(ati18800_t)); memset(ati18800, 0, sizeof(ati18800_t)); - rom_init(&ati18800->bios_rom, "roms/vgaedge16.vbi", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&ati18800->bios_rom, "vgaedge16.vbi", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); svga_init(&ati18800->svga, ati18800, 1 << 19, /*512kb*/ NULL, @@ -148,7 +148,7 @@ void *ati18800_init() static int ati18800_available() { - return rom_present("roms/vgaedge16.vbi"); + return rom_present("vgaedge16.vbi"); } void ati18800_close(void *p) diff --git a/src/vid_ati28800.c b/src/vid_ati28800.c index 2ab7e07..393f41e 100644 --- a/src/vid_ati28800.c +++ b/src/vid_ati28800.c @@ -149,7 +149,7 @@ void *ati28800_init() ati28800_t *ati28800 = malloc(sizeof(ati28800_t)); memset(ati28800, 0, sizeof(ati28800_t)); - rom_init(&ati28800->bios_rom, "roms/bios.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&ati28800->bios_rom, "bios.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); svga_init(&ati28800->svga, ati28800, 1 << 19, /*512kb*/ ati28800_recalctimings, @@ -169,7 +169,7 @@ void *ati28800_init() static int ati28800_available() { - return rom_present("roms/bios.bin"); + return rom_present("bios.bin"); } void ati28800_close(void *p) diff --git a/src/vid_ati_mach64.c b/src/vid_ati_mach64.c index a608060..371638e 100644 --- a/src/vid_ati_mach64.c +++ b/src/vid_ati_mach64.c @@ -3378,7 +3378,7 @@ static void *mach64gx_init() ati_eeprom_load(&mach64->eeprom, "mach64.nvr", 1); - rom_init(&mach64->bios_rom, "roms/mach64gx/bios.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&mach64->bios_rom, "mach64gx/bios.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); return mach64; } @@ -3396,7 +3396,7 @@ static void *mach64vt2_init() ati_eeprom_load(&mach64->eeprom, "mach64vt.nvr", 1); - rom_init(&mach64->bios_rom, "roms/atimach64vt2pci.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&mach64->bios_rom, "atimach64vt2pci.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); svga->vblank_start = mach64_vblank_start; @@ -3405,11 +3405,11 @@ static void *mach64vt2_init() int mach64gx_available() { - return rom_present("roms/mach64gx/bios.bin"); + return rom_present("mach64gx/bios.bin"); } int mach64vt2_available() { - return rom_present("roms/atimach64vt2pci.bin"); + return rom_present("atimach64vt2pci.bin"); } void mach64_close(void *p) diff --git a/src/vid_cl5429.c b/src/vid_cl5429.c index 13ff6df..6616b59 100644 --- a/src/vid_cl5429.c +++ b/src/vid_cl5429.c @@ -822,7 +822,7 @@ void *gd5429_init() svga_t *svga = &gd5429->svga; memset(gd5429, 0, sizeof(gd5429_t)); - rom_init(&gd5429->bios_rom, "roms/5429.vbi", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&gd5429->bios_rom, "5429.vbi", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); svga_init(&gd5429->svga, gd5429, 1 << 21, /*2mb*/ gd5429_recalctimings, @@ -847,7 +847,7 @@ void *gd5429_init() static int gd5429_available() { - return rom_present("roms/5429.vbi"); + return rom_present("5429.vbi"); } void gd5429_close(void *p) diff --git a/src/vid_ega.c b/src/vid_ega.c index 106af91..d212b59 100644 --- a/src/vid_ega.c +++ b/src/vid_ega.c @@ -836,7 +836,7 @@ void *ega_standalone_init() ega_t *ega = malloc(sizeof(ega_t)); memset(ega, 0, sizeof(ega_t)); - rom_init(&ega->bios_rom, "roms/ibm_6277356_ega_card_u44_27128.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&ega->bios_rom, "ibm_6277356_ega_card_u44_27128.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); if (ega->bios_rom.rom[0x3ffe] == 0xaa && ega->bios_rom.rom[0x3fff] == 0x55) { @@ -861,7 +861,7 @@ void *ega_standalone_init() static int ega_standalone_available() { - return rom_present("roms/ibm_6277356_ega_card_u44_27128.bin"); + return rom_present("ibm_6277356_ega_card_u44_27128.bin"); } void ega_close(void *p) diff --git a/src/vid_et4000.c b/src/vid_et4000.c index 483ce94..f24acbc 100644 --- a/src/vid_et4000.c +++ b/src/vid_et4000.c @@ -148,7 +148,7 @@ void *et4000_init() et4000_t *et4000 = malloc(sizeof(et4000_t)); memset(et4000, 0, sizeof(et4000_t)); - rom_init(&et4000->bios_rom, "roms/et4000.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&et4000->bios_rom, "et4000.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); io_sethandler(0x03c0, 0x0020, et4000_in, NULL, NULL, et4000_out, NULL, NULL, et4000); @@ -163,7 +163,7 @@ void *et4000_init() static int et4000_available() { - return rom_present("roms/et4000.bin"); + return rom_present("et4000.bin"); } void et4000_close(void *p) diff --git a/src/vid_et4000w32.c b/src/vid_et4000w32.c index f0b936a..97fca5f 100644 --- a/src/vid_et4000w32.c +++ b/src/vid_et4000w32.c @@ -1176,7 +1176,7 @@ void *et4000w32p_init() et4000w32p_hwcursor_draw, NULL); - rom_init(&et4000->bios_rom, "roms/et4000w32.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&et4000->bios_rom, "et4000w32.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); /*Some BIOSes (eg Diamond Stealth 32 VLB) have a PCI data structure, but with the wrong PCI device ID. The BIOSes on the Intel boards detect this @@ -1212,7 +1212,7 @@ void *et4000w32p_init() int et4000w32p_available() { - return rom_present("roms/et4000w32.bin"); + return rom_present("et4000w32.bin"); } void et4000w32p_close(void *p) diff --git a/src/vid_genius.c b/src/vid_genius.c index c608071..088cdf2 100644 --- a/src/vid_genius.c +++ b/src/vid_genius.c @@ -615,7 +615,7 @@ void genius_close(void *p) static int genius_available() { - return rom_present("roms/8x12.bin"); + return rom_present("8x12.bin"); } void genius_speed_changed(void *p) diff --git a/src/vid_oti067.c b/src/vid_oti067.c index 6d8b8a6..7088bbf 100644 --- a/src/vid_oti067.c +++ b/src/vid_oti067.c @@ -174,12 +174,12 @@ void *oti067_common_init(char *bios_fn, int vram_size) void *oti067_init() { int vram_size = device_get_config_int("memory"); - return oti067_common_init("roms/oti067/bios.bin", vram_size); + return oti067_common_init("oti067/bios.bin", vram_size); } void *oti067_acer386_init() { - oti067_t *oti067 = oti067_common_init("roms/acer386/oti067.bin", 512); + oti067_t *oti067 = oti067_common_init("acer386/oti067.bin", 512); if (oti067) oti067->bios_rom.rom[0x5d] = 0x74; @@ -189,7 +189,7 @@ void *oti067_acer386_init() static int oti067_available() { - return rom_present("roms/oti067/bios.bin"); + return rom_present("oti067/bios.bin"); } void oti067_close(void *p) diff --git a/src/vid_paradise.c b/src/vid_paradise.c index dc90657..6e12061 100644 --- a/src/vid_paradise.c +++ b/src/vid_paradise.c @@ -323,7 +323,7 @@ static void *paradise_pvga1a_pc2086_init() paradise_t *paradise = paradise_pvga1a_init(); if (paradise) - rom_init(¶dise->bios_rom, "roms/pc2086/40186.ic171", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(¶dise->bios_rom, "pc2086/40186.ic171", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); return paradise; } @@ -332,7 +332,7 @@ static void *paradise_pvga1a_pc3086_init() paradise_t *paradise = paradise_pvga1a_init(); if (paradise) - rom_init(¶dise->bios_rom, "roms/pc3086/c000.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(¶dise->bios_rom, "pc3086/c000.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); return paradise; } @@ -343,8 +343,8 @@ static void *paradise_wd90c11_megapc_init() if (paradise) rom_init_interleaved(¶dise->bios_rom, - "roms/megapc/41651-bios lo.u18", - "roms/megapc/211253-bios hi.u19", + "megapc/41651-bios lo.u18", + "megapc/211253-bios hi.u19", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); return paradise; diff --git a/src/vid_pc1640.c b/src/vid_pc1640.c index e7327e1..9c65ca4 100644 --- a/src/vid_pc1640.c +++ b/src/vid_pc1640.c @@ -117,7 +117,7 @@ void *pc1640_init() ega_t *ega = &pc1640->ega; memset(pc1640, 0, sizeof(pc1640_t)); - rom_init(&pc1640->bios_rom, "roms/pc1640/40100", 0xc0000, 0x8000, 0x7fff, 0, 0); + rom_init(&pc1640->bios_rom, "pc1640/40100", 0xc0000, 0x8000, 0x7fff, 0, 0); ega_init(&pc1640->ega); pc1640->cga.vram = pc1640->ega.vram; diff --git a/src/vid_s3.c b/src/vid_s3.c index 53b3324..13f71cf 100644 --- a/src/vid_s3.c +++ b/src/vid_s3.c @@ -2246,7 +2246,7 @@ static void *s3_init(char *bios_fn, int chip) void *s3_bahamas64_init() { - s3_t *s3 = s3_init("roms/bahamas64.bin", S3_VISION864); + s3_t *s3 = s3_init("bahamas64.bin", S3_VISION864); s3->id = 0xc0; /*Vision864P*/ s3->id_ext = s3->id_ext_pci = 0xc0; @@ -2260,12 +2260,12 @@ void *s3_bahamas64_init() int s3_bahamas64_available() { - return rom_present("roms/bahamas64.bin"); + return rom_present("bahamas64.bin"); } void *s3_9fx_init() { - s3_t *s3 = s3_init("roms/s3_764.bin", S3_TRIO64); + s3_t *s3 = s3_init("s3_764.bin", S3_TRIO64); s3->id = 0xe1; /*Trio64*/ s3->id_ext = s3->id_ext_pci = 0x11; @@ -2279,12 +2279,12 @@ void *s3_9fx_init() int s3_9fx_available() { - return rom_present("roms/s3_764.bin"); + return rom_present("s3_764.bin"); } void *s3_phoenix_trio32_init() { - s3_t *s3 = s3_init("roms/86c732p.bin", S3_TRIO32); + s3_t *s3 = s3_init("86c732p.bin", S3_TRIO32); s3->id = 0xe1; /*Trio32*/ s3->id_ext = 0x10; @@ -2299,12 +2299,12 @@ void *s3_phoenix_trio32_init() int s3_phoenix_trio32_available() { - return rom_present("roms/86c732p.bin"); + return rom_present("86c732p.bin"); } void *s3_phoenix_trio64_init() { - s3_t *s3 = s3_init("roms/86c764x1.bin", S3_TRIO64); + s3_t *s3 = s3_init("86c764x1.bin", S3_TRIO64); s3->id = 0xe1; /*Trio64*/ s3->id_ext = s3->id_ext_pci = 0x11; @@ -2318,7 +2318,7 @@ void *s3_phoenix_trio64_init() int s3_phoenix_trio64_available() { - return rom_present("roms/86c764x1.bin"); + return rom_present("86c764x1.bin"); } void s3_close(void *p) diff --git a/src/vid_s3_virge.c b/src/vid_s3_virge.c index 8df14e0..625901b 100644 --- a/src/vid_s3_virge.c +++ b/src/vid_s3_virge.c @@ -3802,7 +3802,7 @@ static void *s3_virge_init() s3_virge_hwcursor_draw, s3_virge_overlay_draw); - rom_init(&virge->bios_rom, "roms/s3virge.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&virge->bios_rom, "s3virge.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); if (PCI) mem_mapping_disable(&virge->bios_rom.mapping); @@ -3897,7 +3897,7 @@ static void *s3_virge_375_init() s3_virge_overlay_draw); virge->svga.vblank_start = s3_virge_vblank_start; - rom_init(&virge->bios_rom, "roms/86c375_1.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&virge->bios_rom, "86c375_1.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); if (PCI) mem_mapping_disable(&virge->bios_rom.mapping); @@ -4003,12 +4003,12 @@ static void s3_virge_close(void *p) static int s3_virge_available() { - return rom_present("roms/s3virge.bin"); + return rom_present("s3virge.bin"); } static int s3_virge_375_available() { - return rom_present("roms/86c375_1.bin"); + return rom_present("86c375_1.bin"); } static void s3_virge_speed_changed(void *p) diff --git a/src/vid_tgui9440.c b/src/vid_tgui9440.c index 6a93aec..06c6d4e 100644 --- a/src/vid_tgui9440.c +++ b/src/vid_tgui9440.c @@ -517,7 +517,7 @@ void *tgui9440_init() tgui->vram_size = device_get_config_int("memory") << 20; tgui->vram_mask = tgui->vram_size - 1; - rom_init(&tgui->bios_rom, "roms/9440.vbi", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&tgui->bios_rom, "9440.vbi", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); svga_init(&tgui->svga, tgui, tgui->vram_size, tgui_recalctimings, @@ -543,7 +543,7 @@ void *tgui9440_init() static int tgui9440_available() { - return rom_present("roms/9440.vbi"); + return rom_present("9440.vbi"); } void tgui_close(void *p) diff --git a/src/vid_tvga.c b/src/vid_tvga.c index e3a3df0..a5c6ae6 100644 --- a/src/vid_tvga.c +++ b/src/vid_tvga.c @@ -288,7 +288,7 @@ void *tvga8900d_init() tvga->vram_size = device_get_config_int("memory") << 10; tvga->vram_mask = tvga->vram_size - 1; - rom_init(&tvga->bios_rom, "roms/trident.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&tvga->bios_rom, "trident.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); svga_init(&tvga->svga, tvga, tvga->vram_size, tvga_recalctimings, @@ -303,7 +303,7 @@ void *tvga8900d_init() static int tvga8900d_available() { - return rom_present("roms/trident.bin"); + return rom_present("trident.bin"); } void tvga_close(void *p) diff --git a/src/vid_vga.c b/src/vid_vga.c index 6f4d639..40472f7 100644 --- a/src/vid_vga.c +++ b/src/vid_vga.c @@ -84,7 +84,7 @@ void *vga_init() vga_t *vga = malloc(sizeof(vga_t)); memset(vga, 0, sizeof(vga_t)); - rom_init(&vga->bios_rom, "roms/ibm_vga.bin", 0xc0000, 0x8000, 0x7fff, 0x2000, MEM_MAPPING_EXTERNAL); + rom_init(&vga->bios_rom, "ibm_vga.bin", 0xc0000, 0x8000, 0x7fff, 0x2000, MEM_MAPPING_EXTERNAL); svga_init(&vga->svga, vga, 1 << 18, /*256kb*/ NULL, @@ -122,7 +122,7 @@ void *ps1vga_init() static int vga_available() { - return rom_present("roms/ibm_vga.bin"); + return rom_present("ibm_vga.bin"); } void vga_close(void *p) diff --git a/src/win-config_sel.c b/src/win-config_sel.c index 5ce9427..83d08c4 100644 --- a/src/win-config_sel.c +++ b/src/win-config_sel.c @@ -9,6 +9,7 @@ #include "config.h" #include "resources.h" #include "win.h" +#include "paths.h" static void config_list_update(HWND hdlg) { @@ -16,9 +17,9 @@ static void config_list_update(HWND hdlg) int num, c; HWND h; - strcpy(s, pcempath); + strcpy(s, configs_path); put_backslash(s); - strcat(s, "configs\\*.cfg"); + strcat(s, "*.cfg"); pclog("Dir %s\n", s); DlgDirList(hdlg, s, IDC_LIST, 0, 0); @@ -71,12 +72,11 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP { char cfg[512]; - strcpy(cfg, pcempath); + strcpy(cfg, configs_path); put_backslash(cfg); - strcat(cfg, "configs\\"); strcat(cfg, s); strcat(cfg, "cfg"); -// sprintf(cfg, "%s\\configs\\%scfg", pcempath, s); +// sprintf(cfg, "%s\\configs\\%scfg", configs_path, s); pclog("Config name %s\n", cfg); strcpy(config_file_default, cfg); @@ -97,9 +97,8 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP { char s[512]; - strcpy(s, pcempath); + strcpy(s, configs_path); put_backslash(s); - strcat(s, "configs\\"); pclog("Dir %s\n", s); if (!getsfile(hdlg, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", "", s, "cfg")) @@ -125,9 +124,8 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP { char cfg[512]; - strcpy(cfg, pcempath); + strcpy(cfg, configs_path); put_backslash(cfg); - strcat(cfg, "configs\\"); strcat(cfg, s); strcat(cfg, "cfg"); pclog("Config name %s\n", cfg); @@ -151,9 +149,8 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP { char cfg[512]; - strcpy(cfg, pcempath); + strcpy(cfg, configs_path); put_backslash(cfg); - strcat(cfg, "configs\\"); strcat(cfg, s); strcat(cfg, "cfg"); pclog("Config name %s\n", cfg); diff --git a/src/win.c b/src/win.c index 9769261..7ba7943 100644 --- a/src/win.c +++ b/src/win.c @@ -41,6 +41,7 @@ #include "win-ddraw-fs.h" #include "win-d3d.h" #include "win-d3d-fs.h" +#include "paths.h" //#include "win-opengl.h" #ifndef MAPVK_VK_TO_VSC @@ -314,7 +315,15 @@ static void initmenu(void) } } -void get_executable_name(char *s, int size) +int dir_exists(char *path) +{ + DWORD dwAttrib = GetFileAttributes(path); + + return (dwAttrib != INVALID_FILE_ATTRIBUTES && + (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); +} + +void get_pcem_path(char *s, int size) { GetModuleFileName(hinstance, s, size); } @@ -486,7 +495,7 @@ static void process_command_line() argbuf[i] = 0; i++; } - pclog("Arg %i - %s\n",argc-1,argv[argc-1]); + //pclog("Arg %i - %s\n",argc-1,argv[argc-1]); } } @@ -535,7 +544,19 @@ int WINAPI WinMain (HINSTANCE hThisInstance, if (!RegisterClassEx(&wincl)) return 0; - getpath(); + paths_init(); + + timeBeginPeriod(1); + + atexit(releasemouse); + + QueryPerformanceFrequency(&qpc_freq); + timer_freq = qpc_freq.QuadPart; + + sound_init(); + + initpc(argc, argv); + d = romset; for (c = 0; c < ROM_MAX; c++) @@ -561,17 +582,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance, for (c = 0; c < GFX_MAX; c++) gfx_present[c] = video_card_available(video_old_to_new(c)); - timeBeginPeriod(1); - - atexit(releasemouse); - - QueryPerformanceFrequency(&qpc_freq); - timer_freq = qpc_freq.QuadPart; - - sound_init(); - - initpc(argc, argv); - while (1) { quited = 0; diff --git a/src/wx-config_sel.c b/src/wx-config_sel.c index 0025bb0..dda0fe7 100644 --- a/src/wx-config_sel.c +++ b/src/wx-config_sel.c @@ -2,6 +2,7 @@ #include "config.h" #include "wx-utils.h" #include "wx-sdl2.h" +#include "paths.h" extern void config_open(void* hwnd); extern void hdconf_open(void* hwnd); @@ -12,9 +13,9 @@ static void config_list_update(void* hdlg) int num, c; void* h; - strcpy(s, pcempath); + strcpy(s, configs_path); put_backslash(s); - strcat(s, "configs/*.cfg"); + strcat(s, "*.cfg"); pclog("Dir %s\n", s); wx_dlgdirlist(hdlg, s, WX_ID("IDC_LIST"), 0, 0); @@ -67,12 +68,11 @@ static int config_selection_dlgproc(void* hdlg, int message, INT_PARAM wParam, L { char cfg[512]; - strcpy(cfg, pcempath); + strcpy(cfg, configs_path); put_backslash(cfg); - strcat(cfg, "configs/"); strcat(cfg, s); strcat(cfg, "cfg"); -// sprintf(cfg, "%s\\configs\\%scfg", pcempath, s); +// sprintf(cfg, "%s\\configs\\%scfg", config_path, s); pclog("Config name %s\n", cfg); strcpy(config_file_default, cfg); @@ -96,9 +96,8 @@ static int config_selection_dlgproc(void* hdlg, int message, INT_PARAM wParam, L // if (!getsfile(hdlg, "Configuration (*.cfg)|*.cfg|All files (*.*)|*.*", "", s, "cfg")) if (wx_textentrydialog(hdlg, "Enter name:", "New config", 0, 1, 64, (LONG_PARAM)name)) { - strcpy(openfilestring, pcempath); + strcpy(openfilestring, configs_path); put_backslash(openfilestring); - strcat(openfilestring, "configs/"); strcat(openfilestring, name); strcat(openfilestring, ".cfg"); @@ -124,9 +123,8 @@ static int config_selection_dlgproc(void* hdlg, int message, INT_PARAM wParam, L { char cfg[512]; - strcpy(cfg, pcempath); + strcpy(cfg, configs_path); put_backslash(cfg); - strcat(cfg, "configs/"); strcat(cfg, s); strcat(cfg, "cfg"); pclog("Config name %s\n", cfg); @@ -149,9 +147,8 @@ static int config_selection_dlgproc(void* hdlg, int message, INT_PARAM wParam, L { char cfg[512]; - strcpy(cfg, pcempath); + strcpy(cfg, configs_path); put_backslash(cfg); - strcat(cfg, "configs/"); strcat(cfg, s); strcat(cfg, "cfg"); pclog("Config name %s\n", cfg); @@ -181,15 +178,13 @@ static int config_selection_dlgproc(void* hdlg, int message, INT_PARAM wParam, L char old_path[512]; char new_path[512]; - strcpy(old_path, pcempath); + strcpy(old_path, configs_path); put_backslash(old_path); - strcat(old_path, "configs/"); strcat(old_path, old_name); strcat(old_path, ".cfg"); - strcpy(new_path, pcempath); + strcpy(new_path, configs_path); put_backslash(new_path); - strcat(new_path, "configs/"); strcat(new_path, name); strcat(new_path, ".cfg"); @@ -217,9 +212,8 @@ static int config_selection_dlgproc(void* hdlg, int message, INT_PARAM wParam, L sprintf(s, "Do you want to delete \"%s\"?", name); if (wx_messagebox(NULL, s, "PCem", WX_MB_OKCANCEL) == WX_IDOK) { - strcpy(s, pcempath); + strcpy(s, configs_path); put_backslash(s); - strcat(s, "configs/"); strcat(s, name); strcat(s, ".cfg"); diff --git a/src/wx-main.cc b/src/wx-main.cc index e5790dc..393eb0e 100644 --- a/src/wx-main.cc +++ b/src/wx-main.cc @@ -7,9 +7,11 @@ int pc_main(int, char**); int main(int argc, char **argv) { - pc_main(argc, argv); + if (!pc_main(argc, argv)) + return -1; - wxApp::SetInstance(new App()); - wxEntry(argc, argv); + wxApp::SetInstance(new App()); + wxEntry(argc, argv); + return 0; } diff --git a/src/wx-sdl2.c b/src/wx-sdl2.c index fcafbc0..ce343e8 100644 --- a/src/wx-sdl2.c +++ b/src/wx-sdl2.c @@ -31,6 +31,7 @@ #include "disc.h" #include "disc_img.h" #include "mem.h" +#include "paths.h" #include "wx-sdl2-video.h" #include "wx-utils.h" @@ -89,8 +90,6 @@ int video_height = 480; char menuitem[60]; -extern void add_config_callback(void(*loadconfig)(), void(*saveconfig)(), void(*onloaded)()); - extern int config_selection_open(void* hwnd, int inited); extern void sdl_set_window_title(const char* title); @@ -190,10 +189,20 @@ int mainthread(void* param) return TRUE; } -void get_executable_name(char *s, int size) +int dir_exists(char* path) { + return wx_dir_exists(path); +} + +void get_pcem_path(char *s, int size) +{ +#ifdef __linux + wx_get_home_directory(s); + strcat(s, ".pcem/"); +#else char* path = SDL_GetBasePath(); strcpy(s, path); +#endif } void set_window_title(const char *s) @@ -335,20 +344,44 @@ extern void wx_saveconfig(); int pc_main(int argc, char** argv) { -#ifndef __APPLE__ - display_init(); + char s[512]; + paths_init(); + +#ifdef __linux__ + /* create directories if they don't exist */ + if (!wx_setup(pcem_path)) + return FALSE; + + /* set up default paths */ + sprintf(s, "%s%s%c%s", pcem_path, "roms/", get_path_separator(), "/usr/share/pcem/roms/"); + set_default_roms_paths(s); + append_filename(s, pcem_path, "nvr/", 511); + set_default_nvr_path(s); + append_filename(s, pcem_path, "configs/", 511); + set_default_configs_path(s); + append_filename(s, pcem_path, "logs/", 511); + set_default_logs_path(s); #endif - sdl_video_init(); add_config_callback(sdl_loadconfig, sdl_saveconfig, sdl_onconfigloaded); add_config_callback(wx_loadconfig, wx_saveconfig, 0); - getpath(); + initpc(argc, argv); + resetpchard(); sound_init(); - initpc(argc, argv); - resetpchard(); +#ifdef __linux__ + /* check if cfg exists, and if not create it */ + append_filename(s, pcem_path, "pcem.cfg", 511); + if (!wx_file_exists(s)) + saveconfig(NULL); +#endif + +#ifndef __APPLE__ + display_init(); +#endif + sdl_video_init(); return TRUE; } diff --git a/src/wx-utils.cc b/src/wx-utils.cc index 398a6d9..598efc8 100644 --- a/src/wx-utils.cc +++ b/src/wx-utils.cc @@ -440,3 +440,60 @@ void wx_close_status(void* window) status->Close(); } } + +void wx_get_home_directory(char* path) +{ + wxString home = wxFileName::GetHomeDir(); + if (!home.EndsWith(wxFileName::GetPathSeparator())) { + home.Append(wxFileName::GetPathSeparator()); + } + strcpy(path, home); +} + +int wx_create_directory(char* path) +{ + return wxFileName::Mkdir(path); +} + +int wx_setup(char* path) +{ + wxFileName p(path); + if (!p.DirExists()) + { + if (!p.Mkdir()) + return FALSE; + wxFileName configs(p); + configs.AppendDir("configs"); + if (!configs.DirExists() && !configs.Mkdir()) + return FALSE; + + wxFileName roms(p); + roms.AppendDir("roms"); + if (!roms.DirExists() && !roms.Mkdir()) + return FALSE; + + wxFileName nvr(p); + nvr.AppendDir("nvr"); + if (!nvr.DirExists() && !nvr.Mkdir()) + return FALSE; + + wxFileName logs(p); + logs.AppendDir("logs"); + if (!logs.DirExists() && !logs.Mkdir()) + return FALSE; + } + + return TRUE; +} + +int wx_file_exists(char* path) +{ + wxFileName p(path); + return p.Exists(); +} + +int wx_dir_exists(char* path) +{ + wxFileName p(path); + return p.DirExists(); +} diff --git a/src/wx-utils.h b/src/wx-utils.h index 84296bf..719e224 100644 --- a/src/wx-utils.h +++ b/src/wx-utils.h @@ -65,6 +65,13 @@ extern "C" { void wx_show_status(void* window); void wx_close_status(void* window); + void wx_get_home_directory(char* path); + int wx_create_directory(char* path); + + int wx_setup(char* path); + int wx_file_exists(char* path); + int wx_dir_exists(char* path); + int confirm(); #ifdef __cplusplus } diff --git a/src/x86seg.c b/src/x86seg.c index 2da6a43..a465f0a 100644 --- a/src/x86seg.c +++ b/src/x86seg.c @@ -8,6 +8,8 @@ #include "386.h" #include "386_common.h" #include "cpu.h" +#include "config.h" +#include "paths.h" /*Controls whether the accessed bit in a descriptor is set when CS is loaded.*/ #define CS_ACCESSED @@ -38,19 +40,24 @@ int output; FILE *pclogf; void x86abort(const char *format, ...) { - char buf[256]; -// return; - if (!pclogf) - pclogf=fopen("pclog.txt","wt"); -//return; - va_list ap; - va_start(ap, format); - vsprintf(buf, format, ap); - va_end(ap); - fputs(buf,pclogf); - fflush(pclogf); - dumpregs(); - exit(-1); + char buf[256]; + // return; + if (!pclogf) + { + strcpy(buf, logs_path); + put_backslash(buf); + strcat(buf, "pcem.log"); + pclogf=fopen(buf, "wt"); + } + //return; + va_list ap; + va_start(ap, format); + vsprintf(buf, format, ap); + va_end(ap); + fputs(buf,pclogf); + fflush(pclogf); + dumpregs(); + exit(-1); } uint8_t opcode2; diff --git a/src/xtide.c b/src/xtide.c index 15954ab..5178a5c 100644 --- a/src/xtide.c +++ b/src/xtide.c @@ -70,7 +70,7 @@ static void *xtide_init() xtide_t *xtide = malloc(sizeof(xtide_t)); memset(xtide, 0, sizeof(xtide_t)); - rom_init(&xtide->bios_rom, "roms/ide_xt.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&xtide->bios_rom, "ide_xt.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); ide_init(); ide_pri_disable(); ide_sec_disable(); @@ -84,7 +84,7 @@ static void *xtide_at_init() xtide_t *xtide = malloc(sizeof(xtide_t)); memset(xtide, 0, sizeof(xtide_t)); - rom_init(&xtide->bios_rom, "roms/ide_at.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&xtide->bios_rom, "ide_at.bin", 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); ide_init(); return xtide; @@ -99,12 +99,12 @@ static void xtide_close(void *p) static int xtide_available() { - return rom_present("roms/ide_xt.bin"); + return rom_present("ide_xt.bin"); } static int xtide_at_available() { - return rom_present("roms/ide_at.bin"); + return rom_present("ide_at.bin"); } device_t xtide_device =