diff --git a/src/config.c b/src/config.c index de353b6..a6dcccf 100644 --- a/src/config.c +++ b/src/config.c @@ -3,6 +3,8 @@ #include #include "config.h" +char config_file_default[256]; + static char config_file[256]; typedef struct list_t @@ -92,9 +94,9 @@ void config_free() } } -void config_load() +void config_load(char *fn) { - FILE *f = fopen(config_file, "rt"); + FILE *f = fopen(fn, "rt"); section_t *current_section; memset(&config_head, 0, sizeof(list_t)); @@ -357,9 +359,9 @@ void put_backslash(char *s) s[c] = '/'; } -void config_save() +void config_save(char *fn) { - FILE *f = fopen(config_file, "wt"); + FILE *f = fopen(fn, "wt"); section_t *current_section; current_section = (section_t *)config_head.next; diff --git a/src/config.h b/src/config.h index 68dac96..b9bbd11 100644 --- a/src/config.h +++ b/src/config.h @@ -8,7 +8,9 @@ char *get_filename(char *s); void append_filename(char *dest, char *s1, char *s2, int size); void put_backslash(char *s); -void config_load(); -void config_save(); +void config_load(char *fn); +void config_save(char *fn); void config_dump(); void config_free(); + +extern char config_file_default[256]; diff --git a/src/ibm.h b/src/ibm.h index a44250f..f29a4b5 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -470,3 +470,6 @@ uint8_t *vramp; uint64_t timer_read(); extern uint64_t timer_freq; + + +void loadconfig(char *fn); diff --git a/src/pc.c b/src/pc.c index 87f77ab..f1cabd0 100644 --- a/src/pc.c +++ b/src/pc.c @@ -52,7 +52,7 @@ int intcount; int output; int atfullspeed; -void loadconfig(); + void saveconfig(); int infocus; int mousecapture; @@ -198,7 +198,7 @@ void initpc() mouse_init(); joystick_init(); - loadconfig(); + loadconfig(NULL); pclog("Config loaded\n"); cpuspeed2=(AT)?2:1; @@ -424,14 +424,19 @@ END_OF_MAIN();*/ int cga_comp=0; -void loadconfig() +void loadconfig(char *fn) { char s[512]; char *p; - append_filename(s, pcempath, "pcem.cfg", 511); - set_config_file(s); - config_load(); + if (!fn) + { + append_filename(config_file_default, pcempath, "pcem.cfg", 511); + + config_load(config_file_default); + } + else + config_load(fn); GAMEBLASTER = get_config_int(NULL, "gameblaster", 0); GUS = get_config_int(NULL, "gus", 0); @@ -522,5 +527,5 @@ void saveconfig() set_config_int(NULL, "hdd_cylinders", hdc[1].tracks); set_config_string(NULL, "hdd_fn", ide_fn[1]); - config_save(); + config_save(config_file_default); } diff --git a/src/pc.rc b/src/pc.rc index 92badcb..5bbd0da 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -40,6 +40,9 @@ BEGIN MENUITEM "&Integer scale", IDM_VID_FS_INT END END + MENUITEM SEPARATOR + MENUITEM "&Load configuration...", IDM_CONFIG_LOAD + MENUITEM "&Save configuration...", IDM_CONFIG_SAVE END POPUP "&Misc" BEGIN diff --git a/src/resources.h b/src/resources.h index f7c67ff..2071201 100644 --- a/src/resources.h +++ b/src/resources.h @@ -7,6 +7,8 @@ #define IDM_EJECT_B 40013 #define IDM_HDCONF 40014 #define IDM_CONFIG 40020 +#define IDM_CONFIG_LOAD 40021 +#define IDM_CONFIG_SAVE 40022 #define IDM_STATUS 40030 #define IDM_VID_RESIZE 40050 #define IDM_VID_DDRAW 40060 diff --git a/src/win.c b/src/win.c index 4a40f17..975ea82 100644 --- a/src/win.c +++ b/src/win.c @@ -14,6 +14,7 @@ #include #include #include "ibm.h" +#include "config.h" #include "video.h" #include "resources.h" #include "cpu.h" @@ -840,6 +841,29 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED); saveconfig(); break; + + case IDM_CONFIG_LOAD: + pause = 1; + if (!getfile(hwnd, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", "")) + { + if (MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) == IDOK) + { + loadconfig(openfilestring); + config_save(config_file_default); + mem_resize(); + loadbios(); + resetpchard(); + } + } + pause = 0; + break; + + case IDM_CONFIG_SAVE: + pause = 1; + if (!getsfile(hwnd, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", "")) + config_save(openfilestring); + pause = 0; + break; case IDM_CDROM_DISABLED: if (cdrom_enabled)