Added configuration load/save options.
This commit is contained in:
parent
262b188790
commit
66b9ccf1ab
7 changed files with 54 additions and 13 deletions
10
src/config.c
10
src/config.c
|
|
@ -3,6 +3,8 @@
|
|||
#include <stdlib.h>
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -470,3 +470,6 @@ uint8_t *vramp;
|
|||
|
||||
uint64_t timer_read();
|
||||
extern uint64_t timer_freq;
|
||||
|
||||
|
||||
void loadconfig(char *fn);
|
||||
|
|
|
|||
19
src/pc.c
19
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
24
src/win.c
24
src/win.c
|
|
@ -14,6 +14,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue