From 1c2158e00f0f29971c4d6824d04d9e008c1d53b5 Mon Sep 17 00:00:00 2001 From: pcem_emulator Date: Thu, 4 May 2017 16:04:50 +0000 Subject: [PATCH 01/11] Created new branch new_config From 8538116c197ef3977ab7d437599a6f51c37b84e2 Mon Sep 17 00:00:00 2001 From: SarahW Date: Thu, 4 May 2017 18:27:10 +0100 Subject: [PATCH 02/11] Initial commit for config rework. Work in progress! --- configs/configs.txt | 1 + src/ibm.h | 3 +- src/mem.c | 6 ++- src/pc.c | 30 ++++++++----- src/pc.rc | 15 ++++++- src/resources.h | 6 ++- src/win-config.c | 21 ++++++--- src/win-deviceconfig.c | 2 +- src/win-hdconf.c | 4 +- src/win.c | 100 ++++++++++++++++++++++++----------------- src/win.h | 6 ++- 11 files changed, 125 insertions(+), 69 deletions(-) create mode 100644 configs/configs.txt diff --git a/configs/configs.txt b/configs/configs.txt new file mode 100644 index 0000000..f2396cc --- /dev/null +++ b/configs/configs.txt @@ -0,0 +1 @@ +This directory is used to store config files. \ No newline at end of file diff --git a/src/ibm.h b/src/ibm.h index 559ef45..a59c16e 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -559,6 +559,7 @@ void resetpc(); void resetpchard(); void speedchanged(); -void saveconfig(); +void saveconfig(char *fn); +void getpath(); #define UNUSED(x) (void)x diff --git a/src/mem.c b/src/mem.c index 20279cd..ecfc949 100644 --- a/src/mem.c +++ b/src/mem.c @@ -54,7 +54,7 @@ uint32_t biosmask; int readlnum=0,writelnum=0; int cachesize=256; -uint8_t *ram,*rom; +uint8_t *ram, *rom = NULL; uint8_t romext[32768]; static void mem_load_atide115_bios() @@ -81,6 +81,8 @@ int loadbios() biosmask = 0xffff; + if (!rom) + rom = malloc(0x20000); memset(romext,0x63,0x4000); memset(rom, 0xff, 0x20000); @@ -1774,7 +1776,7 @@ void mem_init() int c; ram = malloc((mem_size + 384) * 1024); - rom = malloc(0x20000); +// rom = malloc(0x20000); readlookup2 = malloc(1024 * 1024 * sizeof(uintptr_t)); writelookup2 = malloc(1024 * 1024 * sizeof(uintptr_t)); biosmask = 0xffff; diff --git a/src/pc.c b/src/pc.c index 547d50b..48a6767 100644 --- a/src/pc.c +++ b/src/pc.c @@ -69,7 +69,7 @@ int framecount,fps; int output; int atfullspeed; -void saveconfig(); +void saveconfig(char *fn); int infocus; int mousecapture; FILE *pclogf; @@ -202,17 +202,23 @@ void pc_reset() // video_init(); } #undef printf -void initpc(int argc, char *argv[]) +void getpath() { char *p; - char *config_file = NULL; - int c; -// allegro_init(); + 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[]) +{ + //char *p; + char *config_file = NULL; + int c; +// allegro_init(); for (c = 1; c < argc; c++) { @@ -241,12 +247,12 @@ void initpc(int argc, char *argv[]) joystick_init(); midi_init(); - append_filename(config_file_default, pcempath, "pcem.cfg", 511); +// append_filename(config_file_default, pcempath, "pcem.cfg", 511); loadconfig(config_file); pclog("Config loaded\n"); - if (config_file) - saveconfig(); +// if (config_file) +// saveconfig(); cpuspeed2=(AT)?2:1; // cpuspeed2=cpuspeed; @@ -713,7 +719,7 @@ void loadconfig(char *fn) enable_sync = config_get_int(NULL, "enable_sync", 1); } -void saveconfig() +void saveconfig(char *fn) { int c, d; @@ -810,5 +816,9 @@ void saveconfig() config_set_int(NULL, "enable_sync", enable_sync); - config_save(config_file_default); + pclog("config_save(%s)\n", config_file_default); + if (fn) + config_save(fn); + else + config_save(config_file_default); } diff --git a/src/pc.rc b/src/pc.rc index a5a35b5..d581364 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -54,8 +54,7 @@ BEGIN MENUITEM "Disc activity indicator", IDM_VID_DISC END MENUITEM SEPARATOR - MENUITEM "&Load configuration...", IDM_CONFIG_LOAD - MENUITEM "&Save configuration...", IDM_CONFIG_SAVE + MENUITEM "&Select configuration...", IDM_CONFIG_SELECT END POPUP "&Misc" BEGIN @@ -317,3 +316,15 @@ BEGIN COMBOBOX IDC_HDTYPE, 7,54,172,120,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP END + +ConfigureSelectionDlg DIALOGEX 0, 0, 200, 150 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select Configuration" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK", IDOK, 200-54, 4, 50, 14, WS_TABSTOP + DEFPUSHBUTTON "Cancel", IDCANCEL, 200-54,22, 50, 14, WS_TABSTOP + DEFPUSHBUTTON "New...", IDC_NEW, 200-54,40, 50, 14, WS_TABSTOP + + LISTBOX IDC_LIST, 4, 4,140,142, WS_TABSTOP +END diff --git a/src/resources.h b/src/resources.h index f5f3cd1..bc4184b 100644 --- a/src/resources.h +++ b/src/resources.h @@ -9,8 +9,7 @@ #define IDM_HDCONF 40014 #define IDM_BPB_DISABLE 40015 #define IDM_CONFIG 40020 -#define IDM_CONFIG_LOAD 40021 -#define IDM_CONFIG_SAVE 40022 +#define IDM_CONFIG_SELECT 40021 #define IDM_STATUS 40030 #define IDM_VID_RESIZE 40050 #define IDM_VID_REMEMBER 40051 @@ -134,3 +133,6 @@ #define WM_RESETD3D WM_USER #define WM_LEAVEFULLSCREEN WM_USER + 1 + +#define IDC_NEW 1200 +#define IDC_LIST 1201 diff --git a/src/win-config.c b/src/win-config.c index 02a25d2..e03f0aa 100644 --- a/src/win-config.c +++ b/src/win-config.c @@ -27,6 +27,8 @@ static int settings_sound_to_list[20], settings_list_to_sound[20]; static int settings_mouse_to_list[20], settings_list_to_mouse[20]; static char *hdd_names[16]; +static int has_been_inited = 0; + static int mouse_valid(int type, int model) { if ((type & MOUSE_TYPE_IF_MASK) == MOUSE_TYPE_PS2 && !(models[model].flags & MODEL_PS2)) @@ -471,7 +473,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR temp_fda_type != fdd_get_type(0) || temp_fdb_type != fdd_get_type(1) || temp_mouse_type != mouse_type || hdd_changed) { - if (MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK) + if (!has_been_inited || MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK) { savenvr(); model = temp_model; @@ -496,10 +498,12 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR else strcpy(hdd_controller_name, "none"); - - mem_resize(); - loadbios(); - resetpchard(); + if (has_been_inited) + { + mem_resize(); + loadbios(); + resetpchard(); + } } else { @@ -520,7 +524,8 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR cpu_waitstates = SendMessage(h, CB_GETCURSEL, 0, 0); cpu_update_waitstates(); - saveconfig(); + if (has_been_inited) + saveconfig(NULL); speedchanged(); @@ -810,7 +815,9 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return FALSE; } -void config_open(HWND hwnd) +void config_open(HWND hwnd, int inited) { + has_been_inited = inited; + DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, (DLGPROC)config_dlgproc); } diff --git a/src/win-deviceconfig.c b/src/win-deviceconfig.c index 5481269..50fe626 100644 --- a/src/win-deviceconfig.c +++ b/src/win-deviceconfig.c @@ -178,7 +178,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam config++; } - saveconfig(); + saveconfig(NULL); resetpchard(); diff --git a/src/win-hdconf.c b/src/win-hdconf.c index add5e40..edcc586 100644 --- a/src/win-hdconf.c +++ b/src/win-hdconf.c @@ -205,7 +205,7 @@ static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARA return TRUE; case IDC_CFILE: - if (!getsfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", "")) + if (!getsfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", "", NULL)) { h = GetDlgItem(hdlg, IDC_EDITC); SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring); @@ -515,7 +515,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR cdrom_channel = new_cdrom_channel; - saveconfig(); + saveconfig(NULL); resetpchard(); } diff --git a/src/win.c b/src/win.c index 5cff840..c6fecf8 100644 --- a/src/win.c +++ b/src/win.c @@ -173,6 +173,7 @@ void mainthread(LPVOID param) // Sleep(500); drawits=0; old_time = GetTickCount(); + while (!quited) { if (updatestatus) @@ -555,6 +556,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, /* Make the window visible on the screen */ ShowWindow (hwnd, nFunsterStil); + ghMutex = CreateMutex(NULL, FALSE, NULL); // win_set_window(hwnd); memset(rawinputkey, 0, sizeof(rawinputkey)); @@ -571,11 +573,9 @@ int WINAPI WinMain (HINSTANCE hThisInstance, get_registry_key_map(); ghwnd=hwnd; - - initpc(argc, argv); - - vid_apis[0][vid_api].init(ghwnd); + getpath(); + if (vid_resize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE); else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)|WS_VISIBLE); @@ -618,9 +618,18 @@ int WINAPI WinMain (HINSTANCE hThisInstance, } romset=d; - c=loadbios(); + + for (c = 0; c < GFX_MAX; c++) + gfx_present[c] = video_card_available(video_old_to_new(c)); - if (!c) + loadconfig(NULL); + + if (!config_selection_open(ghwnd, 0)) + return 0; + + initpc(argc, argv); + + if (!loadbios()) { if (romset!=-1) MessageBox(hwnd,"Configured romset not available.\nDefaulting to available romset.","PCem error",MB_OK); for (c=0;c Date: Thu, 4 May 2017 20:44:05 +0100 Subject: [PATCH 03/11] Add missing file. --- src/Makefile.mingw | 2 +- src/win-config_sel.c | 129 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/win-config_sel.c diff --git a/src/Makefile.mingw b/src/Makefile.mingw index e790238..9d143f9 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -18,7 +18,7 @@ OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o ali1429.o amstrad vid_olivetti_m24.o vid_oti067.o vid_paradise.o vid_pc1512.o vid_pc1640.o vid_pc200.o \ vid_pcjr.o vid_ps1_svga.o vid_s3.o vid_s3_virge.o vid_sdac_ramdac.o vid_stg_ramdac.o vid_svga.o \ vid_svga_render.o vid_tandy.o vid_tandysl.o vid_tgui9440.o vid_tkd8001_ramdac.o vid_tvga.o vid_unk_ramdac.o \ - vid_vga.o vid_voodoo.o vid_wy700.o video.o wd76c10.o win.o win-config.o win-d3d.o win-d3d-fs.o win-ddraw.o \ + vid_vga.o vid_voodoo.o vid_wy700.o video.o wd76c10.o win.o win-config.o win-config_sel.o win-d3d.o win-d3d-fs.o win-ddraw.o \ win-ddraw-fs.o win-deviceconfig.o win-hdconf.o win-joystick.o win-joystickconfig.o win-keyboard.o win-midi.o win-mouse.o \ win-status.o win-video.o x86seg.o x87.o xtide.o pc.res DBOBJ = dbopl.o vid_cga_comp.o diff --git a/src/win-config_sel.c b/src/win-config_sel.c new file mode 100644 index 0000000..adeee10 --- /dev/null +++ b/src/win-config_sel.c @@ -0,0 +1,129 @@ +#define BITMAP WINDOWS_BITMAP +#include +#include +#undef BITMAP + +#include + +#include "ibm.h" +#include "config.h" +#include "resources.h" +#include "win.h" + +static int has_been_inited = 0; + +static void config_list_update(HWND hdlg) +{ + char s[512]; + int num, c; + HWND h; + + strcpy(s, pcempath); + put_backslash(s); + strcat(s, "configs\\*.cfg"); + pclog("Dir %s\n", s); + + DlgDirList(hdlg, s, IDC_LIST, 0, 0); + + h = GetDlgItem(hdlg, IDC_LIST); + num = SendMessage(h, LB_GETCOUNT, 0, 0); + + for (c = 0; c < num; c++) + { + char *ext; + + SendMessage(h, LB_GETTEXT, c, (LPARAM)s); + ext = get_extension(s); + if (ext && ext[0]) + { + ext--; + *ext = 0; + } + + SendMessage(h, LB_DELETESTRING, c, 0); + SendMessage(h, LB_INSERTSTRING, c, (LPARAM)s); + } +} + +static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + //HWND h; + + switch (message) + { + case WM_INITDIALOG: +// pause = 1; + config_list_update(hdlg); +// h = GetDlgItem(hdlg, IDC_LIST); +// SendMessage(h, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)"AAA"); +// SendMessage(h, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)"BBB"); + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + { + char s[512]; + + int ret = DlgDirSelectEx(hdlg, s, 512, IDC_LIST); + + pclog("DlgDirSelectEx returned %i %s\n", ret, s); + if (s[0]) + { + char cfg[512]; + + strcpy(cfg, pcempath); + put_backslash(cfg); + strcat(cfg, "configs\\"); + strcat(cfg, s); + strcat(cfg, "cfg"); +// sprintf(cfg, "%s\\configs\\%scfg", pcempath, s); + pclog("Config name %s\n", cfg); + + strcpy(config_file_default, cfg); + + EndDialog(hdlg, 1); +// pause = 0; + return TRUE; + } + } + return FALSE; + + case IDCANCEL: + EndDialog(hdlg, 0); +// pause = 0; + return TRUE; + + case IDC_NEW: + { + char s[512]; + + strcpy(s, pcempath); + put_backslash(s); + strcat(s, "configs\\"); + pclog("Dir %s\n", s); + + if (!getsfile(hdlg, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", "", s)) + { + config_open(hdlg, has_been_inited); + + saveconfig(openfilestring); + } + + config_list_update(hdlg); + + return TRUE; + } + } + break; + } + return FALSE; +} + +int config_selection_open(HWND hwnd, int inited) +{ + has_been_inited = inited; + + return DialogBox(hinstance, TEXT("ConfigureSelectionDlg"), hwnd, (DLGPROC)config_selection_dlgproc); +} From 3356e7fdf0e5c2ca7587fcdbcf524f17dffdd5fc Mon Sep 17 00:00:00 2001 From: SarahW Date: Sat, 6 May 2017 15:15:12 +0100 Subject: [PATCH 04/11] Seperated configuration into global and per-machine config files. --- src/config.c | 67 ++++++----- src/config.h | 19 +-- src/device.c | 8 +- src/pc.c | 265 +++++++++++++++++++++-------------------- src/win-config.c | 6 +- src/win-config_sel.c | 4 +- src/win-deviceconfig.c | 23 ++-- src/win-midi.c | 2 +- src/win.c | 2 +- src/win.h | 4 +- 10 files changed, 210 insertions(+), 190 deletions(-) diff --git a/src/config.c b/src/config.c index 20e9df4..ca2a184 100644 --- a/src/config.c +++ b/src/config.c @@ -13,7 +13,8 @@ typedef struct list_t struct list_t *next; } list_t; -static list_t config_head; +static list_t global_config_head; +static list_t machine_config_head; typedef struct section_t { @@ -43,13 +44,14 @@ typedef struct entry_t (new)->next = NULL; \ } -void config_dump() +void config_dump(int is_global) { section_t *current_section; - + list_t *head = is_global ? &global_config_head : &machine_config_head; + pclog("Config data :\n"); - current_section = (section_t *)config_head.next; + current_section = (section_t *)head->next; while (current_section) { @@ -70,10 +72,11 @@ void config_dump() } } -void config_free() +void config_free(int is_global) { section_t *current_section; - current_section = (section_t *)config_head.next; + list_t *head = is_global ? &global_config_head : &machine_config_head; + current_section = (section_t *)head->next; while (current_section) { @@ -95,16 +98,17 @@ void config_free() } } -void config_load(char *fn) +void config_load(int is_global, char *fn) { FILE *f = fopen(fn, "rt"); section_t *current_section; + list_t *head = is_global ? &global_config_head : &machine_config_head; - memset(&config_head, 0, sizeof(list_t)); + memset(head, 0, sizeof(list_t)); current_section = malloc(sizeof(section_t)); memset(current_section, 0, sizeof(section_t)); - list_add(¤t_section->list, &config_head); + list_add(¤t_section->list, head); if (!f) return; @@ -144,7 +148,7 @@ void config_load(char *fn) new_section = malloc(sizeof(section_t)); memset(new_section, 0, sizeof(section_t)); strncpy(new_section->name, name, 256); - list_add(&new_section->list, &config_head); + list_add(&new_section->list, head); current_section = new_section; @@ -187,7 +191,7 @@ void config_load(char *fn) fclose(f); - config_dump(); + config_dump(is_global); } @@ -198,12 +202,13 @@ void config_new() fclose(f); } -static section_t *find_section(char *name) +static section_t *find_section(char *name, int is_global) { section_t *current_section; char blank[] = ""; - - current_section = (section_t *)config_head.next; + list_t *head = is_global ? &global_config_head : &machine_config_head; + + current_section = (section_t *)head->next; if (!name) name = blank; @@ -233,13 +238,14 @@ static entry_t *find_entry(section_t *section, char *name) return NULL; } -static section_t *create_section(char *name) +static section_t *create_section(char *name, int is_global) { section_t *new_section = malloc(sizeof(section_t)); - + list_t *head = is_global ? &global_config_head : &machine_config_head; + memset(new_section, 0, sizeof(section_t)); strncpy(new_section->name, name, 256); - list_add(&new_section->list, &config_head); + list_add(&new_section->list, head); return new_section; } @@ -254,13 +260,13 @@ static entry_t *create_entry(section_t *section, char *name) return new_entry; } -int config_get_int(char *head, char *name, int def) +int config_get_int(int is_global, char *head, char *name, int def) { section_t *section; entry_t *entry; int value; - section = find_section(head); + section = find_section(head, is_global); if (!section) return def; @@ -275,12 +281,12 @@ int config_get_int(char *head, char *name, int def) return value; } -char *config_get_string(char *head, char *name, char *def) +char *config_get_string(int is_global, char *head, char *name, char *def) { section_t *section; entry_t *entry; - section = find_section(head); + section = find_section(head, is_global); if (!section) return def; @@ -293,15 +299,15 @@ char *config_get_string(char *head, char *name, char *def) return entry->data; } -void config_set_int(char *head, char *name, int val) +void config_set_int(int is_global, char *head, char *name, int val) { section_t *section; entry_t *entry; - section = find_section(head); + section = find_section(head, is_global); if (!section) - section = create_section(head); + section = create_section(head, is_global); entry = find_entry(section, name); @@ -311,15 +317,15 @@ void config_set_int(char *head, char *name, int val) sprintf(entry->data, "%i", val); } -void config_set_string(char *head, char *name, char *val) +void config_set_string(int is_global, char *head, char *name, char *val) { section_t *section; entry_t *entry; - section = find_section(head); + section = find_section(head, is_global); if (!section) - section = create_section(head); + section = create_section(head, is_global); entry = find_entry(section, name); @@ -370,12 +376,13 @@ char *get_extension(char *s) return &s[c+1]; } -void config_save(char *fn) +void config_save(int is_global, char *fn) { FILE *f = fopen(fn, "wt"); section_t *current_section; - - current_section = (section_t *)config_head.next; + list_t *head = is_global ? &global_config_head : &machine_config_head; + + current_section = (section_t *)head->next; while (current_section) { diff --git a/src/config.h b/src/config.h index d8710b0..23b0a48 100644 --- a/src/config.h +++ b/src/config.h @@ -1,16 +1,19 @@ -int config_get_int(char *head, char *name, int def); -char *config_get_string(char *head, char *name, char *def); -void config_set_int(char *head, char *name, int val); -void config_set_string(char *head, char *name, char *val); +int config_get_int(int is_global, char *head, char *name, int def); +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); char *get_filename(char *s); void append_filename(char *dest, char *s1, char *s2, int size); void put_backslash(char *s); char *get_extension(char *s); -void config_load(char *fn); -void config_save(char *fn); -void config_dump(); -void config_free(); +void config_load(int is_global, char *fn); +void config_save(int is_global, char *fn); +void config_dump(int is_global); +void config_free(int is_global); extern char config_file_default[256]; + +#define CFG_MACHINE 0 +#define CFG_GLOBAL 1 diff --git a/src/device.c b/src/device.c index 65526d5..c94b7b2 100644 --- a/src/device.c +++ b/src/device.c @@ -121,7 +121,7 @@ int device_get_config_int(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_int(current_device->name, s, config->default_int); + return config_get_int(CFG_MACHINE, current_device->name, s, config->default_int); config++; } @@ -135,7 +135,7 @@ char *device_get_config_string(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_string(current_device->name, s, config->default_string); + return config_get_string(CFG_MACHINE, current_device->name, s, config->default_string); config++; } @@ -155,7 +155,7 @@ int model_get_config_int(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_int(device->name, s, config->default_int); + return config_get_int(CFG_MACHINE, device->name, s, config->default_int); config++; } @@ -175,7 +175,7 @@ char *model_get_config_string(char *s) while (config->type != -1) { if (!strcmp(s, config->name)) - return config_get_string(device->name, s, config->default_string); + return config_get_string(CFG_MACHINE, device->name, s, config->default_string); config++; } diff --git a/src/pc.c b/src/pc.c index 48a6767..29b0c05 100644 --- a/src/pc.c +++ b/src/pc.c @@ -579,19 +579,37 @@ void loadconfig(char *fn) { int c, d; char s[512]; + char global_config_file[512]; char *p; + + append_filename(global_config_file, pcempath, "pcem.cfg", 511); + + config_load(CFG_GLOBAL, global_config_file); if (!fn) - config_load(config_file_default); + config_load(CFG_MACHINE, config_file_default); else - config_load(fn); + config_load(CFG_MACHINE, fn); + + vid_resize = config_get_int(CFG_GLOBAL, NULL, "vid_resize", 0); + video_force_aspect_ration = config_get_int(CFG_GLOBAL, NULL, "vid_force_aspect_ratio", 0); + vid_disc_indicator = config_get_int(CFG_GLOBAL, NULL, "vid_disc_indicator", 1); + vid_api = config_get_int(CFG_GLOBAL, NULL, "vid_api", 0); + video_fullscreen_scale = config_get_int(CFG_GLOBAL, NULL, "video_fullscreen_scale", 0); + video_fullscreen_first = config_get_int(CFG_GLOBAL, NULL, "video_fullscreen_first", 1); + + window_w = config_get_int(CFG_GLOBAL, NULL, "window_w", 0); + window_h = config_get_int(CFG_GLOBAL, NULL, "window_h", 0); + window_x = config_get_int(CFG_GLOBAL, NULL, "window_x", 0); + window_y = config_get_int(CFG_GLOBAL, NULL, "window_y", 0); + window_remember = config_get_int(CFG_GLOBAL, NULL, "window_remember", 0); - GAMEBLASTER = config_get_int(NULL, "gameblaster", 0); - GUS = config_get_int(NULL, "gus", 0); - SSI2001 = config_get_int(NULL, "ssi2001", 0); - voodoo_enabled = config_get_int(NULL, "voodoo", 0); + GAMEBLASTER = config_get_int(CFG_MACHINE, NULL, "gameblaster", 0); + GUS = config_get_int(CFG_MACHINE, NULL, "gus", 0); + SSI2001 = config_get_int(CFG_MACHINE, NULL, "ssi2001", 0); + voodoo_enabled = config_get_int(CFG_MACHINE, NULL, "voodoo", 0); - p = (char *)config_get_string(NULL, "model", ""); + p = (char *)config_get_string(CFG_MACHINE, NULL, "model", ""); if (p) model = model_get_model_from_internal_name(p); else @@ -601,224 +619,217 @@ void loadconfig(char *fn) model = model_count() - 1; romset = model_getromset(); - cpu_manufacturer = config_get_int(NULL, "cpu_manufacturer", 0); - cpu = config_get_int(NULL, "cpu", 0); - cpu_use_dynarec = config_get_int(NULL, "cpu_use_dynarec", 0); - cpu_waitstates = config_get_int(NULL, "cpu_waitstates", 0); + cpu_manufacturer = config_get_int(CFG_MACHINE, NULL, "cpu_manufacturer", 0); + cpu = config_get_int(CFG_MACHINE, NULL, "cpu", 0); + cpu_use_dynarec = config_get_int(CFG_MACHINE, NULL, "cpu_use_dynarec", 0); + cpu_waitstates = config_get_int(CFG_MACHINE, NULL, "cpu_waitstates", 0); - p = (char *)config_get_string(NULL, "gfxcard", ""); + p = (char *)config_get_string(CFG_MACHINE, NULL, "gfxcard", ""); if (p) gfxcard = video_get_video_from_internal_name(p); else gfxcard = 0; - video_speed = config_get_int(NULL, "video_speed", 3); - p = (char *)config_get_string(NULL, "sndcard", ""); + video_speed = config_get_int(CFG_MACHINE, NULL, "video_speed", 3); + p = (char *)config_get_string(CFG_MACHINE, NULL, "sndcard", ""); if (p) sound_card_current = sound_card_get_from_internal_name(p); else sound_card_current = 0; - p = (char *)config_get_string(NULL, "disc_a", ""); + p = (char *)config_get_string(CFG_MACHINE, NULL, "disc_a", ""); if (p) strcpy(discfns[0], p); else strcpy(discfns[0], ""); - p = (char *)config_get_string(NULL, "disc_b", ""); + p = (char *)config_get_string(CFG_MACHINE, NULL, "disc_b", ""); if (p) strcpy(discfns[1], p); else strcpy(discfns[1], ""); - p = (char *)config_get_string(NULL, "hdd_controller", ""); + p = (char *)config_get_string(CFG_MACHINE, NULL, "hdd_controller", ""); if (p) strncpy(hdd_controller_name, p, sizeof(hdd_controller_name)-1); else strncpy(hdd_controller_name, "none", sizeof(hdd_controller_name)-1); - mem_size = config_get_int(NULL, "mem_size", 4096); + mem_size = config_get_int(CFG_MACHINE, NULL, "mem_size", 4096); if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram)) mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram); - cdrom_drive = config_get_int(NULL, "cdrom_drive", 0); - cdrom_enabled = config_get_int(NULL, "cdrom_enabled", 0); - cdrom_channel = config_get_int(NULL, "cdrom_channel", 2); + cdrom_drive = config_get_int(CFG_MACHINE, NULL, "cdrom_drive", 0); + cdrom_enabled = config_get_int(CFG_MACHINE, NULL, "cdrom_enabled", 0); + cdrom_channel = config_get_int(CFG_MACHINE, NULL, "cdrom_channel", 2); - p = (char *)config_get_string(NULL, "cdrom_path", ""); + p = (char *)config_get_string(CFG_MACHINE, NULL, "cdrom_path", ""); if (p) strcpy(iso_path, p); else strcpy(iso_path, ""); - vid_resize = config_get_int(NULL, "vid_resize", 0); - video_force_aspect_ration = config_get_int(NULL, "vid_force_aspect_ratio", 0); - vid_disc_indicator = config_get_int(NULL, "vid_disc_indicator", 1); - vid_api = config_get_int(NULL, "vid_api", 0); - video_fullscreen_scale = config_get_int(NULL, "video_fullscreen_scale", 0); - video_fullscreen_first = config_get_int(NULL, "video_fullscreen_first", 1); - - hdc[0].spt = config_get_int(NULL, "hdc_sectors", 0); - hdc[0].hpc = config_get_int(NULL, "hdc_heads", 0); - hdc[0].tracks = config_get_int(NULL, "hdc_cylinders", 0); - p = (char *)config_get_string(NULL, "hdc_fn", ""); + hdc[0].spt = config_get_int(CFG_MACHINE, NULL, "hdc_sectors", 0); + hdc[0].hpc = config_get_int(CFG_MACHINE, NULL, "hdc_heads", 0); + hdc[0].tracks = config_get_int(CFG_MACHINE, NULL, "hdc_cylinders", 0); + p = (char *)config_get_string(CFG_MACHINE, NULL, "hdc_fn", ""); if (p) strcpy(ide_fn[0], p); else strcpy(ide_fn[0], ""); - hdc[1].spt = config_get_int(NULL, "hdd_sectors", 0); - hdc[1].hpc = config_get_int(NULL, "hdd_heads", 0); - hdc[1].tracks = config_get_int(NULL, "hdd_cylinders", 0); - p = (char *)config_get_string(NULL, "hdd_fn", ""); + hdc[1].spt = config_get_int(CFG_MACHINE, NULL, "hdd_sectors", 0); + hdc[1].hpc = config_get_int(CFG_MACHINE, NULL, "hdd_heads", 0); + hdc[1].tracks = config_get_int(CFG_MACHINE, NULL, "hdd_cylinders", 0); + p = (char *)config_get_string(CFG_MACHINE, NULL, "hdd_fn", ""); if (p) strcpy(ide_fn[1], p); else strcpy(ide_fn[1], ""); - hdc[2].spt = config_get_int(NULL, "hde_sectors", 0); - hdc[2].hpc = config_get_int(NULL, "hde_heads", 0); - hdc[2].tracks = config_get_int(NULL, "hde_cylinders", 0); - p = (char *)config_get_string(NULL, "hde_fn", ""); + hdc[2].spt = config_get_int(CFG_MACHINE, NULL, "hde_sectors", 0); + hdc[2].hpc = config_get_int(CFG_MACHINE, NULL, "hde_heads", 0); + hdc[2].tracks = config_get_int(CFG_MACHINE, NULL, "hde_cylinders", 0); + p = (char *)config_get_string(CFG_MACHINE, NULL, "hde_fn", ""); if (p) strcpy(ide_fn[2], p); else strcpy(ide_fn[2], ""); - hdc[3].spt = config_get_int(NULL, "hdf_sectors", 0); - hdc[3].hpc = config_get_int(NULL, "hdf_heads", 0); - hdc[3].tracks = config_get_int(NULL, "hdf_cylinders", 0); - p = (char *)config_get_string(NULL, "hdf_fn", ""); + hdc[3].spt = config_get_int(CFG_MACHINE, NULL, "hdf_sectors", 0); + hdc[3].hpc = config_get_int(CFG_MACHINE, NULL, "hdf_heads", 0); + hdc[3].tracks = config_get_int(CFG_MACHINE, NULL, "hdf_cylinders", 0); + p = (char *)config_get_string(CFG_MACHINE, NULL, "hdf_fn", ""); if (p) strcpy(ide_fn[3], p); else strcpy(ide_fn[3], ""); - fdd_set_type(0, config_get_int(NULL, "drive_a_type", 7)); - fdd_set_type(1, config_get_int(NULL, "drive_b_type", 7)); - bpb_disable = config_get_int(NULL, "bpb_disable", 0); + fdd_set_type(0, config_get_int(CFG_MACHINE, NULL, "drive_a_type", 7)); + fdd_set_type(1, config_get_int(CFG_MACHINE, NULL, "drive_b_type", 7)); + bpb_disable = config_get_int(CFG_MACHINE, NULL, "bpb_disable", 0); - window_w = config_get_int(NULL, "window_w", 0); - window_h = config_get_int(NULL, "window_h", 0); - window_x = config_get_int(NULL, "window_x", 0); - window_y = config_get_int(NULL, "window_y", 0); - window_remember = config_get_int(NULL, "window_remember", 0); - - joystick_type = config_get_int(NULL, "joystick_type", 0); - mouse_type = config_get_int(NULL, "mouse_type", 0); + joystick_type = config_get_int(CFG_MACHINE, NULL, "joystick_type", 0); + mouse_type = config_get_int(CFG_MACHINE, NULL, "mouse_type", 0); for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { sprintf(s, "joystick_%i_nr", c); - joystick_state[c].plat_joystick_nr = config_get_int("Joysticks", s, 0); + joystick_state[c].plat_joystick_nr = config_get_int(CFG_MACHINE, "Joysticks", s, 0); if (joystick_state[c].plat_joystick_nr) { for (d = 0; d < joystick_get_axis_count(joystick_type); d++) { sprintf(s, "joystick_%i_axis_%i", c, d); - joystick_state[c].axis_mapping[d] = config_get_int("Joysticks", s, d); + joystick_state[c].axis_mapping[d] = config_get_int(CFG_MACHINE, "Joysticks", s, d); } for (d = 0; d < joystick_get_button_count(joystick_type); d++) { sprintf(s, "joystick_%i_button_%i", c, d); - joystick_state[c].button_mapping[d] = config_get_int("Joysticks", s, d); + joystick_state[c].button_mapping[d] = config_get_int(CFG_MACHINE, "Joysticks", s, d); } for (d = 0; d < joystick_get_pov_count(joystick_type); d++) { sprintf(s, "joystick_%i_pov_%i_x", c, d); - joystick_state[c].pov_mapping[d][0] = config_get_int("Joysticks", s, d); + joystick_state[c].pov_mapping[d][0] = config_get_int(CFG_MACHINE, "Joysticks", s, d); sprintf(s, "joystick_%i_pov_%i_y", c, d); - joystick_state[c].pov_mapping[d][1] = config_get_int("Joysticks", s, d); + joystick_state[c].pov_mapping[d][1] = config_get_int(CFG_MACHINE, "Joysticks", s, d); } } } - enable_sync = config_get_int(NULL, "enable_sync", 1); + enable_sync = config_get_int(CFG_MACHINE, NULL, "enable_sync", 1); } void saveconfig(char *fn) { int c, d; - - config_set_int(NULL, "gameblaster", GAMEBLASTER); - config_set_int(NULL, "gus", GUS); - config_set_int(NULL, "ssi2001", SSI2001); - config_set_int(NULL, "voodoo", voodoo_enabled); - - config_set_string(NULL, "model", model_get_internal_name()); - config_set_int(NULL, "cpu_manufacturer", cpu_manufacturer); - config_set_int(NULL, "cpu", cpu); - config_set_int(NULL, "cpu_use_dynarec", cpu_use_dynarec); - config_set_int(NULL, "cpu_waitstates", cpu_waitstates); - - config_set_string(NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard))); - config_set_int(NULL, "video_speed", video_speed); - config_set_string(NULL, "sndcard", sound_card_get_internal_name(sound_card_current)); - config_set_int(NULL, "cpu_speed", cpuspeed); - config_set_int(NULL, "has_fpu", hasfpu); - config_set_string(NULL, "disc_a", discfns[0]); - config_set_string(NULL, "disc_b", discfns[1]); - config_set_string(NULL, "hdd_controller", hdd_controller_name); + char global_config_file[512]; - config_set_int(NULL, "mem_size", mem_size); - config_set_int(NULL, "cdrom_drive", cdrom_drive); - config_set_int(NULL, "cdrom_enabled", cdrom_enabled); - config_set_int(NULL, "cdrom_channel", cdrom_channel); - config_set_string(NULL, "cdrom_path", iso_path); - config_set_int(NULL, "vid_resize", vid_resize); - config_set_int(NULL, "vid_force_aspect_ratio", video_force_aspect_ration); - config_set_int(NULL, "vid_disc_indicator", vid_disc_indicator); - config_set_int(NULL, "vid_api", vid_api); - config_set_int(NULL, "video_fullscreen_scale", video_fullscreen_scale); - config_set_int(NULL, "video_fullscreen_first", video_fullscreen_first); + append_filename(global_config_file, pcempath, "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); + config_set_int(CFG_GLOBAL, NULL, "vid_disc_indicator", vid_disc_indicator); + config_set_int(CFG_GLOBAL, NULL, "vid_api", vid_api); + config_set_int(CFG_GLOBAL, NULL, "video_fullscreen_scale", video_fullscreen_scale); + config_set_int(CFG_GLOBAL, NULL, "video_fullscreen_first", video_fullscreen_first); + + config_set_int(CFG_GLOBAL, NULL, "window_w", window_w); + config_set_int(CFG_GLOBAL, NULL, "window_h", window_h); + config_set_int(CFG_GLOBAL, NULL, "window_x", window_x); + config_set_int(CFG_GLOBAL, NULL, "window_y", window_y); + config_set_int(CFG_GLOBAL, NULL, "window_remember", window_remember); - config_set_int(NULL, "hdc_sectors", hdc[0].spt); - config_set_int(NULL, "hdc_heads", hdc[0].hpc); - config_set_int(NULL, "hdc_cylinders", hdc[0].tracks); - config_set_string(NULL, "hdc_fn", ide_fn[0]); - config_set_int(NULL, "hdd_sectors", hdc[1].spt); - config_set_int(NULL, "hdd_heads", hdc[1].hpc); - config_set_int(NULL, "hdd_cylinders", hdc[1].tracks); - config_set_string(NULL, "hdd_fn", ide_fn[1]); - config_set_int(NULL, "hde_sectors", hdc[2].spt); - config_set_int(NULL, "hde_heads", hdc[2].hpc); - config_set_int(NULL, "hde_cylinders", hdc[2].tracks); - config_set_string(NULL, "hde_fn", ide_fn[2]); - config_set_int(NULL, "hdf_sectors", hdc[3].spt); - config_set_int(NULL, "hdf_heads", hdc[3].hpc); - config_set_int(NULL, "hdf_cylinders", hdc[3].tracks); - config_set_string(NULL, "hdf_fn", ide_fn[3]); + config_set_int(CFG_MACHINE, NULL, "gameblaster", GAMEBLASTER); + config_set_int(CFG_MACHINE, NULL, "gus", GUS); + config_set_int(CFG_MACHINE, NULL, "ssi2001", SSI2001); + config_set_int(CFG_MACHINE, NULL, "voodoo", voodoo_enabled); + + config_set_string(CFG_MACHINE, NULL, "model", model_get_internal_name()); + config_set_int(CFG_MACHINE, NULL, "cpu_manufacturer", cpu_manufacturer); + config_set_int(CFG_MACHINE, NULL, "cpu", cpu); + config_set_int(CFG_MACHINE, NULL, "cpu_use_dynarec", cpu_use_dynarec); + config_set_int(CFG_MACHINE, NULL, "cpu_waitstates", cpu_waitstates); + + config_set_string(CFG_MACHINE, NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard))); + config_set_int(CFG_MACHINE, NULL, "video_speed", video_speed); + config_set_string(CFG_MACHINE, NULL, "sndcard", sound_card_get_internal_name(sound_card_current)); + config_set_int(CFG_MACHINE, NULL, "cpu_speed", cpuspeed); + config_set_int(CFG_MACHINE, NULL, "has_fpu", hasfpu); + config_set_string(CFG_MACHINE, NULL, "disc_a", discfns[0]); + config_set_string(CFG_MACHINE, NULL, "disc_b", discfns[1]); + config_set_string(CFG_MACHINE, NULL, "hdd_controller", hdd_controller_name); - config_set_int(NULL, "drive_a_type", fdd_get_type(0)); - config_set_int(NULL, "drive_b_type", fdd_get_type(1)); - config_set_int(NULL, "bpb_disable", bpb_disable); + config_set_int(CFG_MACHINE, NULL, "mem_size", mem_size); + config_set_int(CFG_MACHINE, NULL, "cdrom_drive", cdrom_drive); + config_set_int(CFG_MACHINE, NULL, "cdrom_enabled", cdrom_enabled); + config_set_int(CFG_MACHINE, NULL, "cdrom_channel", cdrom_channel); + config_set_string(CFG_MACHINE, NULL, "cdrom_path", iso_path); + + config_set_int(CFG_MACHINE, NULL, "hdc_sectors", hdc[0].spt); + config_set_int(CFG_MACHINE, NULL, "hdc_heads", hdc[0].hpc); + config_set_int(CFG_MACHINE, NULL, "hdc_cylinders", hdc[0].tracks); + config_set_string(CFG_MACHINE, NULL, "hdc_fn", ide_fn[0]); + config_set_int(CFG_MACHINE, NULL, "hdd_sectors", hdc[1].spt); + config_set_int(CFG_MACHINE, NULL, "hdd_heads", hdc[1].hpc); + config_set_int(CFG_MACHINE, NULL, "hdd_cylinders", hdc[1].tracks); + config_set_string(CFG_MACHINE, NULL, "hdd_fn", ide_fn[1]); + config_set_int(CFG_MACHINE, NULL, "hde_sectors", hdc[2].spt); + config_set_int(CFG_MACHINE, NULL, "hde_heads", hdc[2].hpc); + config_set_int(CFG_MACHINE, NULL, "hde_cylinders", hdc[2].tracks); + config_set_string(CFG_MACHINE, NULL, "hde_fn", ide_fn[2]); + config_set_int(CFG_MACHINE, NULL, "hdf_sectors", hdc[3].spt); + config_set_int(CFG_MACHINE, NULL, "hdf_heads", hdc[3].hpc); + config_set_int(CFG_MACHINE, NULL, "hdf_cylinders", hdc[3].tracks); + config_set_string(CFG_MACHINE, NULL, "hdf_fn", ide_fn[3]); - config_set_int(NULL, "window_w", window_w); - config_set_int(NULL, "window_h", window_h); - config_set_int(NULL, "window_x", window_x); - config_set_int(NULL, "window_y", window_y); - config_set_int(NULL, "window_remember", window_remember); + config_set_int(CFG_MACHINE, NULL, "drive_a_type", fdd_get_type(0)); + config_set_int(CFG_MACHINE, NULL, "drive_b_type", fdd_get_type(1)); + config_set_int(CFG_MACHINE, NULL, "bpb_disable", bpb_disable); - config_set_int(NULL, "joystick_type", joystick_type); - config_set_int(NULL, "mouse_type", mouse_type); + config_set_int(CFG_MACHINE, NULL, "joystick_type", joystick_type); + config_set_int(CFG_MACHINE, NULL, "mouse_type", mouse_type); for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { char s[80]; sprintf(s, "joystick_%i_nr", c); - config_set_int("Joysticks", s, joystick_state[c].plat_joystick_nr); + config_set_int(CFG_MACHINE, "Joysticks", s, joystick_state[c].plat_joystick_nr); if (joystick_state[c].plat_joystick_nr) { for (d = 0; d < joystick_get_axis_count(joystick_type); d++) { sprintf(s, "joystick_%i_axis_%i", c, d); - config_set_int("Joysticks", s, joystick_state[c].axis_mapping[d]); + config_set_int(CFG_MACHINE, "Joysticks", s, joystick_state[c].axis_mapping[d]); } for (d = 0; d < joystick_get_button_count(joystick_type); d++) { sprintf(s, "joystick_%i_button_%i", c, d); - config_set_int("Joysticks", s, joystick_state[c].button_mapping[d]); + config_set_int(CFG_MACHINE, "Joysticks", s, joystick_state[c].button_mapping[d]); } for (d = 0; d < joystick_get_pov_count(joystick_type); d++) { sprintf(s, "joystick_%i_pov_%i_x", c, d); - config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][0]); + config_set_int(CFG_MACHINE, "Joysticks", s, joystick_state[c].pov_mapping[d][0]); sprintf(s, "joystick_%i_pov_%i_y", c, d); - config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][1]); + config_set_int(CFG_MACHINE, "Joysticks", s, joystick_state[c].pov_mapping[d][1]); } } } - config_set_int(NULL, "enable_sync", enable_sync); + config_set_int(CFG_MACHINE, NULL, "enable_sync", enable_sync); pclog("config_save(%s)\n", config_file_default); if (fn) - config_save(fn); + config_save(CFG_MACHINE, fn); else - config_save(config_file_default); + config_save(CFG_MACHINE, config_file_default); + + config_save(CFG_GLOBAL, global_config_file); } diff --git a/src/win-config.c b/src/win-config.c index e03f0aa..0a4032f 100644 --- a/src/win-config.c +++ b/src/win-config.c @@ -27,7 +27,7 @@ static int settings_sound_to_list[20], settings_list_to_sound[20]; static int settings_mouse_to_list[20], settings_list_to_mouse[20]; static char *hdd_names[16]; -static int has_been_inited = 0; +int has_been_inited = 0; static int mouse_valid(int type, int model) { @@ -815,9 +815,7 @@ static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR return FALSE; } -void config_open(HWND hwnd, int inited) +void config_open(HWND hwnd) { - has_been_inited = inited; - DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, (DLGPROC)config_dlgproc); } diff --git a/src/win-config_sel.c b/src/win-config_sel.c index adeee10..5b4711e 100644 --- a/src/win-config_sel.c +++ b/src/win-config_sel.c @@ -10,8 +10,6 @@ #include "resources.h" #include "win.h" -static int has_been_inited = 0; - static void config_list_update(HWND hdlg) { char s[512]; @@ -106,7 +104,7 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP if (!getsfile(hdlg, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", "", s)) { - config_open(hdlg, has_been_inited); + config_open(hdlg); saveconfig(openfilestring); } diff --git a/src/win-deviceconfig.c b/src/win-deviceconfig.c index 50fe626..4160523 100644 --- a/src/win-deviceconfig.c +++ b/src/win-deviceconfig.c @@ -33,7 +33,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam switch (config->type) { case CONFIG_BINARY: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int); SendMessage(h, BM_SETCHECK, val_int, 0); @@ -41,7 +41,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_SELECTION: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int); c = 0; while (selection->description[0]) @@ -57,7 +57,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_MIDI: - val_int = config_get_int(NULL, config->name, config->default_int); + val_int = config_get_int(CFG_MACHINE, NULL, config->name, config->default_int); num = midi_get_num_devs(); for (c = 0; c < num; c++) @@ -95,7 +95,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam switch (config->type) { case CONFIG_BINARY: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int); if (val_int != SendMessage(h, BM_GETCHECK, 0, 0)) changed = 1; @@ -104,7 +104,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_SELECTION: - val_int = config_get_int(config_device->name, config->name, config->default_int); + val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); @@ -118,7 +118,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam break; case CONFIG_MIDI: - val_int = config_get_int(NULL, config->name, config->default_int); + val_int = config_get_int(CFG_MACHINE, NULL, config->name, config->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); @@ -137,7 +137,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam return TRUE; } - if (MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) != IDOK) + if (has_been_inited && MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) != IDOK) { EndDialog(hdlg, 0); return TRUE; @@ -154,7 +154,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam switch (config->type) { case CONFIG_BINARY: - config_set_int(config_device->name, config->name, SendMessage(h, BM_GETCHECK, 0, 0)); + config_set_int(CFG_MACHINE, config_device->name, config->name, SendMessage(h, BM_GETCHECK, 0, 0)); id++; break; @@ -163,14 +163,14 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) selection++; - config_set_int(config_device->name, config->name, selection->value); + config_set_int(CFG_MACHINE, config_device->name, config->name, selection->value); id += 2; break; case CONFIG_MIDI: c = SendMessage(h, CB_GETCURSEL, 0, 0); - config_set_int(NULL, config->name, c); + config_set_int(CFG_MACHINE, NULL, config->name, c); id += 2; break; @@ -180,7 +180,8 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam saveconfig(NULL); - resetpchard(); + if (has_been_inited) + resetpchard(); EndDialog(hdlg, 0); return TRUE; diff --git a/src/win-midi.c b/src/win-midi.c index 895df6a..3a94427 100644 --- a/src/win-midi.c +++ b/src/win-midi.c @@ -13,7 +13,7 @@ void midi_init() { MMRESULT hr; - midi_id = config_get_int(NULL, "midi", 0); + midi_id = config_get_int(CFG_MACHINE, NULL, "midi", 0); hr = midiOutOpen(&midi_out_device, midi_id, 0, 0, CALLBACK_NULL); diff --git a/src/win.c b/src/win.c index c6fecf8..b4b68d4 100644 --- a/src/win.c +++ b/src/win.c @@ -969,7 +969,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM hdconf_open(hwnd); break; case IDM_CONFIG: - config_open(hwnd, 1); + config_open(hwnd); break; case IDM_STATUS: status_open(hwnd); diff --git a/src/win.h b/src/win.h index c3f418f..ed12875 100644 --- a/src/win.h +++ b/src/win.h @@ -22,7 +22,7 @@ extern int status_is_open; void hdconf_open(HWND hwnd); -void config_open(HWND hwnd, int inited); +void config_open(HWND hwnd); int config_selection_open(HWND hwnd, int inited); @@ -37,3 +37,5 @@ int getfile(HWND hwnd, char *f, char *fn); int getsfile(HWND hwnd, char *f, char *fn, char *dir); extern int pause; + +extern int has_been_inited; From beecfd838119cfeb525e85b933ab3615dd244fbe Mon Sep 17 00:00:00 2001 From: SarahW Date: Sat, 6 May 2017 20:45:44 +0100 Subject: [PATCH 05/11] Machine can now be configured from selection dialogue. --- src/pc.rc | 2 ++ src/resources.h | 2 ++ src/win-config_sel.c | 60 +++++++++++++++++++++++++++++++++++++++++++- src/win-hdconf.c | 11 +++++--- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/src/pc.rc b/src/pc.rc index d581364..d2d5d11 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -325,6 +325,8 @@ BEGIN DEFPUSHBUTTON "OK", IDOK, 200-54, 4, 50, 14, WS_TABSTOP DEFPUSHBUTTON "Cancel", IDCANCEL, 200-54,22, 50, 14, WS_TABSTOP DEFPUSHBUTTON "New...", IDC_NEW, 200-54,40, 50, 14, WS_TABSTOP + DEFPUSHBUTTON "Configuration...", IDC_CONFIG, 200-54,58, 50, 14, WS_TABSTOP + DEFPUSHBUTTON "HDD...", IDC_HDCONF, 200-54,76, 50, 14, WS_TABSTOP LISTBOX IDC_LIST, 4, 4,140,142, WS_TABSTOP END diff --git a/src/resources.h b/src/resources.h index bc4184b..a4acd50 100644 --- a/src/resources.h +++ b/src/resources.h @@ -136,3 +136,5 @@ #define IDC_NEW 1200 #define IDC_LIST 1201 +#define IDC_CONFIG 1202 +#define IDC_HDCONF 1203 diff --git a/src/win-config_sel.c b/src/win-config_sel.c index 5b4711e..9e3ef03 100644 --- a/src/win-config_sel.c +++ b/src/win-config_sel.c @@ -113,6 +113,58 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP return TRUE; } + + case IDC_CONFIG: + { + char s[512]; + + int ret = DlgDirSelectEx(hdlg, s, 512, IDC_LIST); + + pclog("DlgDirSelectEx returned %i %s\n", ret, s); + if (s[0]) + { + char cfg[512]; + + strcpy(cfg, pcempath); + put_backslash(cfg); + strcat(cfg, "configs\\"); + strcat(cfg, s); + strcat(cfg, "cfg"); + pclog("Config name %s\n", cfg); + + loadconfig(cfg); + config_open(hdlg); + saveconfig(cfg); + } + + return TRUE; + } + + case IDC_HDCONF: + { + char s[512]; + + int ret = DlgDirSelectEx(hdlg, s, 512, IDC_LIST); + + pclog("DlgDirSelectEx returned %i %s\n", ret, s); + if (s[0]) + { + char cfg[512]; + + strcpy(cfg, pcempath); + put_backslash(cfg); + strcat(cfg, "configs\\"); + strcat(cfg, s); + strcat(cfg, "cfg"); + pclog("Config name %s\n", cfg); + + loadconfig(cfg); + hdconf_open(hdlg); + saveconfig(cfg); + } + + return TRUE; + } } break; } @@ -121,7 +173,13 @@ static BOOL CALLBACK config_selection_dlgproc(HWND hdlg, UINT message, WPARAM wP int config_selection_open(HWND hwnd, int inited) { + int ret; + has_been_inited = inited; - return DialogBox(hinstance, TEXT("ConfigureSelectionDlg"), hwnd, (DLGPROC)config_selection_dlgproc); + ret = DialogBox(hinstance, TEXT("ConfigureSelectionDlg"), hwnd, (DLGPROC)config_selection_dlgproc); + + has_been_inited = 1; + + return ret; } diff --git a/src/win-hdconf.c b/src/win-hdconf.c index edcc586..184b370 100644 --- a/src/win-hdconf.c +++ b/src/win-hdconf.c @@ -458,7 +458,7 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR case IDOK: if (hd_changed || cdrom_channel != new_cdrom_channel) { - if (MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) == IDOK) + if (!has_been_inited || MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) == IDOK) { h = GetDlgItem(hdlg, IDC_EDIT_C_SPT); SendMessage(h, WM_GETTEXT, 255, (LPARAM)s); @@ -514,10 +514,13 @@ static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPAR hdc[3] = hd[3]; cdrom_channel = new_cdrom_channel; - - saveconfig(NULL); + + if (has_been_inited) + { + saveconfig(NULL); - resetpchard(); + resetpchard(); + } } } case IDCANCEL: From 172e88ed8bfeec831e9109f38c399c1fb311aa10 Mon Sep 17 00:00:00 2001 From: SarahW Date: Wed, 10 May 2017 20:27:52 +0100 Subject: [PATCH 06/11] Configuration manager now bookends the emulator - running before emulation starts and after the main window is closed. --- src/pc.c | 7 - src/pc.rc | 6 +- src/resources.h | 1 - src/win-d3d.cc | 4 +- src/win-mouse.cc | 2 - src/win.c | 415 +++++++++++++++++++++-------------------------- 6 files changed, 192 insertions(+), 243 deletions(-) diff --git a/src/pc.c b/src/pc.c index 29b0c05..113fcee 100644 --- a/src/pc.c +++ b/src/pc.c @@ -242,11 +242,6 @@ void initpc(int argc, char *argv[]) } } - keyboard_init(); - mouse_init(); - joystick_init(); - midi_init(); - // append_filename(config_file_default, pcempath, "pcem.cfg", 511); loadconfig(config_file); @@ -279,7 +274,6 @@ void initpc(int argc, char *argv[]) //loadfont(); loadnvr(); - sound_init(); resetide(); #if __unix if (cdrom_drive == -1) @@ -558,7 +552,6 @@ void closepc() closevideo(); mouse_emu_close(); device_close_all(); - midi_close(); } /*int main() diff --git a/src/pc.rc b/src/pc.rc index d2d5d11..11f4c23 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -53,8 +53,6 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Disc activity indicator", IDM_VID_DISC END - MENUITEM SEPARATOR - MENUITEM "&Select configuration...", IDM_CONFIG_SELECT END POPUP "&Misc" BEGIN @@ -318,8 +316,8 @@ BEGIN END ConfigureSelectionDlg DIALOGEX 0, 0, 200, 150 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Select Configuration" +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTER +CAPTION "PCem Configuration Manager" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK", IDOK, 200-54, 4, 50, 14, WS_TABSTOP diff --git a/src/resources.h b/src/resources.h index a4acd50..932eda4 100644 --- a/src/resources.h +++ b/src/resources.h @@ -9,7 +9,6 @@ #define IDM_HDCONF 40014 #define IDM_BPB_DISABLE 40015 #define IDM_CONFIG 40020 -#define IDM_CONFIG_SELECT 40021 #define IDM_STATUS 40030 #define IDM_VID_RESIZE 40050 #define IDM_VID_REMEMBER 40051 diff --git a/src/win-d3d.cc b/src/win-d3d.cc index dcaecb8..58ef2b6 100644 --- a/src/win-d3d.cc +++ b/src/win-d3d.cc @@ -173,7 +173,9 @@ void d3d_resize(int x, int y) void d3d_reset() { HRESULT hr; - + + if (!d3ddev) + return; memset(&d3dpp, 0, sizeof(d3dpp)); d3dpp.Flags = 0; diff --git a/src/win-mouse.cc b/src/win-mouse.cc index 7593b64..df37162 100644 --- a/src/win-mouse.cc +++ b/src/win-mouse.cc @@ -21,8 +21,6 @@ int mouse_buttons = 0; void mouse_init() { - atexit(mouse_close); - if (FAILED(DirectInputCreate(hinstance, DIRECTINPUT_VERSION, &lpdi, NULL))) fatal("mouse_init : DirectInputCreate failed\n"); if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &lpdi_mouse, NULL))) diff --git a/src/win.c b/src/win.c index b4b68d4..66ea519 100644 --- a/src/win.c +++ b/src/win.c @@ -31,6 +31,7 @@ #include "thread.h" #include "video.h" +#include "plat-joystick.h" #include "plat-midi.h" #include "plat-mouse.h" #include "plat-keyboard.h" @@ -534,75 +535,13 @@ int WINAPI WinMain (HINSTANCE hThisInstance, if (!RegisterClassEx(&wincl)) return 0; - menu = LoadMenu(hThisInstance, TEXT("MainMenu")); - initmenu(); - - /* The class is registered, let's create the program*/ - hwnd = CreateWindowEx ( - 0, /* Extended possibilites for variation */ - szClassName, /* Classname */ - "PCem v12", /* Title Text */ - WS_OVERLAPPEDWINDOW&~WS_SIZEBOX, /* default window */ - CW_USEDEFAULT, /* Windows decides the position */ - CW_USEDEFAULT, /* where the window ends up on the screen */ - 640+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* The programs width */ - 480+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */ - HWND_DESKTOP, /* The window is a child-window to desktop */ - menu, /* Menu */ - hThisInstance, /* Program Instance handler */ - NULL /* No Window Creation data */ - ); - - /* Make the window visible on the screen */ - ShowWindow (hwnd, nFunsterStil); - - ghMutex = CreateMutex(NULL, FALSE, NULL); -// win_set_window(hwnd); - - memset(rawinputkey, 0, sizeof(rawinputkey)); - device.usUsagePage = 0x01; - device.usUsage = 0x06; - device.dwFlags = RIDEV_NOHOTKEYS; - device.hwndTarget = hwnd; - - if (RegisterRawInputDevices(&device, 1, sizeof(device))) - pclog("Raw input registered!\n"); - else - pclog("Raw input registration failed!\n"); - - get_registry_key_map(); - - ghwnd=hwnd; - getpath(); - - if (vid_resize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE); - else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)|WS_VISIBLE); - if (!cdrom_enabled) - CheckMenuItem(menu, IDM_CDROM_DISABLED, MF_CHECKED); - else + d = romset; + for (c = 0; c < ROM_MAX; c++) { - if (cdrom_drive == CDROM_ISO) - CheckMenuItem(menu, IDM_CDROM_ISO, MF_CHECKED); - else - CheckMenuItem(menu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED); - } - if (vid_resize) CheckMenuItem(menu, IDM_VID_RESIZE, MF_CHECKED); - if (video_force_aspect_ration) - CheckMenuItem(menu, IDM_VID_ASPECT, MF_CHECKED); - CheckMenuItem(menu, IDM_VID_DDRAW + vid_api, MF_CHECKED); - CheckMenuItem(menu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED); - CheckMenuItem(menu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(menu, IDM_BPB_DISABLE, bpb_disable ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(menu, IDM_VID_DISC, vid_disc_indicator ? MF_CHECKED : MF_UNCHECKED); -// set_display_switch_mode(SWITCH_BACKGROUND); - - d=romset; - for (c=0;c= 0; c--) - { - if (gfx_present[c]) - { - gfxcard = c; -// saveconfig(); -// resetpchard(); - break; - } - } - } - - loadbios(); - resetpchard(); - timeBeginPeriod(1); atexit(releasemouse); - vid_apis[0][vid_api].init(ghwnd); - -// QueryPerformanceFrequency(&counter_base); -/// QueryPerformanceCounter(&counter_posold); -// counter_posold.QuadPart*=100; - - mainthreadh=(HANDLE)_beginthread(mainthread,0,NULL); - SetThreadPriority(mainthreadh, THREAD_PRIORITY_HIGHEST); - - - updatewindowsize(640, 480); - QueryPerformanceFrequency(&qpc_freq); timer_freq = qpc_freq.QuadPart; - -// focus=1; -// setrefresh(100); - -// ShowCursor(TRUE); - -// return 0; - if (start_in_fullscreen) - { - startblit(); - mouse_close(); - vid_apis[0][vid_api].close(); - video_fullscreen = 1; - vid_apis[1][vid_api].init(ghwnd); - mouse_init(); - leave_fullscreen_flag = 0; - endblit(); - device_force_redraw(); - } - if (window_remember) - { - MoveWindow(hwnd, window_x, window_y, - window_w, - window_h, - TRUE); - } - - /* Run the message loop. It will run until GetMessage() returns 0 */ - while (!quited) - { -/* if (infocus) - { - if (drawits) - { - drawits--; - if (drawits>10) drawits=0; - runpc(); - } -//; else -// sleep(0); - if ((pcem_key[KEY_LCONTROL] || pcem_key[KEY_RCONTROL]) && pcem_key[KEY_END] && mousecapture) - { - ClipCursor(&oldclip); - mousecapture=0; - } - }*/ + sound_init(); - while (GetMessage(&messages,NULL,0,0) && !quited) + initpc(argc, argv); + + while (1) + { + quited = 0; + + if (!config_selection_open(NULL, 0)) + break; + + ghMutex = CreateMutex(NULL, FALSE, NULL); + menu = LoadMenu(hThisInstance, TEXT("MainMenu")); + + initmenu(); + + /* The class is registered, let's create the program*/ + hwnd = CreateWindowEx ( + 0, /* Extended possibilites for variation */ + szClassName, /* Classname */ + "PCem v12", /* Title Text */ + WS_OVERLAPPEDWINDOW&~WS_SIZEBOX, /* default window */ + CW_USEDEFAULT, /* Windows decides the position */ + CW_USEDEFAULT, /* where the window ends up on the screen */ + 640+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* The programs width */ + 480+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */ + HWND_DESKTOP, /* The window is a child-window to desktop */ + menu, /* Menu */ + hThisInstance, /* Program Instance handler */ + NULL /* No Window Creation data */ + ); + + /* Make the window visible on the screen */ + ShowWindow (hwnd, nFunsterStil); + + memset(rawinputkey, 0, sizeof(rawinputkey)); + device.usUsagePage = 0x01; + device.usUsage = 0x06; + device.dwFlags = RIDEV_NOHOTKEYS; + device.hwndTarget = hwnd; + + if (RegisterRawInputDevices(&device, 1, sizeof(device))) + pclog("Raw input registered!\n"); + else + pclog("Raw input registration failed!\n"); + + get_registry_key_map(); + + ghwnd = hwnd; + + if (vid_resize) + SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE); + else + SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)|WS_VISIBLE); + + if (!cdrom_enabled) + CheckMenuItem(menu, IDM_CDROM_DISABLED, MF_CHECKED); + else { - if (messages.message==WM_QUIT) quited=1; - TranslateMessage(&messages); - DispatchMessage(&messages); - if ((pcem_key[KEY_LCONTROL] || pcem_key[KEY_RCONTROL]) && pcem_key[KEY_END] && mousecapture) + if (cdrom_drive == CDROM_ISO) + CheckMenuItem(menu, IDM_CDROM_ISO, MF_CHECKED); + else + CheckMenuItem(menu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED); + } + if (vid_resize) + CheckMenuItem(menu, IDM_VID_RESIZE, MF_CHECKED); + if (video_force_aspect_ration) + CheckMenuItem(menu, IDM_VID_ASPECT, MF_CHECKED); + CheckMenuItem(menu, IDM_VID_DDRAW + vid_api, MF_CHECKED); + CheckMenuItem(menu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED); + CheckMenuItem(menu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(menu, IDM_BPB_DISABLE, bpb_disable ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(menu, IDM_VID_DISC, vid_disc_indicator ? MF_CHECKED : MF_UNCHECKED); + + loadconfig(NULL); + + if (!loadbios()) + { + if (romset != -1) + MessageBox(hwnd,"Configured romset not available.\nDefaulting to available romset.","PCem error",MB_OK); + for (c = 0; c < ROM_MAX; c++) { - ClipCursor(&oldclip); - ShowCursor(TRUE); - mousecapture=0; + if (romspresent[c]) + { + romset = c; + model = model_getmodel(romset); + break; + } } } - quited=1; -// else -// sleep(10); - } + if (!video_card_available(video_old_to_new(gfxcard))) + { + if (romset != -1) + MessageBox(hwnd,"Configured video BIOS not available.\nDefaulting to available romset.","PCem error",MB_OK); + for (c = GFX_MAX-1; c >= 0; c--) + { + if (gfx_present[c]) + { + gfxcard = c; + break; + } + } + } + + loadbios(); + resetpchard(); - startblit(); + vid_apis[0][vid_api].init(ghwnd); + + mainthreadh=(HANDLE)_beginthread(mainthread,0,NULL); + SetThreadPriority(mainthreadh, THREAD_PRIORITY_HIGHEST); + + updatewindowsize(640, 480); + + keyboard_init(); + mouse_init(); + joystick_init(); + midi_init(); + + if (start_in_fullscreen) + { + startblit(); + mouse_close(); + vid_apis[0][vid_api].close(); + video_fullscreen = 1; + vid_apis[1][vid_api].init(ghwnd); + mouse_init(); + leave_fullscreen_flag = 0; + endblit(); + device_force_redraw(); + } + if (window_remember) + { + MoveWindow(hwnd, window_x, window_y, + window_w, + window_h, + TRUE); + } + + /* Run the message loop. It will run until GetMessage() returns 0 */ + while (!quited) + { + while (GetMessage(&messages,NULL,0,0) && !quited) + { + if (messages.message==WM_QUIT) quited=1; + TranslateMessage(&messages); + DispatchMessage(&messages); + if ((pcem_key[KEY_LCONTROL] || pcem_key[KEY_RCONTROL]) && pcem_key[KEY_END] && mousecapture) + { + ClipCursor(&oldclip); + ShowCursor(TRUE); + mousecapture=0; + } + } + + quited=1; + } + + startblit(); // pclog("Sleep 1000\n"); - Sleep(200); + Sleep(200); // pclog("TerminateThread\n"); - TerminateThread(mainthreadh,0); + TerminateThread(mainthreadh,0); + +// endblit(); + // pclog("Quited? %i\n",quited); // pclog("Closepc\n"); - savenvr(); - if (save_window_pos && window_remember) - saveconfig(NULL); - closepc(); + savenvr(); + if (save_window_pos && window_remember) + saveconfig(NULL); // pclog("dumpregs\n"); - vid_apis[video_fullscreen][vid_api].close(); - + vid_apis[video_fullscreen][vid_api].close(); + + if (mousecapture) + { + ClipCursor(&oldclip); + ShowCursor(TRUE); + } + + keyboard_close(); + mouse_close(); + joystick_close(); + midi_close(); + + DestroyWindow(hwnd); + CloseHandle(ghMutex); + } + + closepc(); + timeEndPeriod(1); // dumpregs(); - if (mousecapture) - { - ClipCursor(&oldclip); - ShowCursor(TRUE); - } UnregisterClass(szSubClassName, hinstance); UnregisterClass(szClassName, hinstance); @@ -1050,41 +1044,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM saveconfig(NULL); break; - case IDM_CONFIG_SELECT: - pause = 1; - if (config_selection_open(ghwnd, 1)) - { - loadconfig(NULL); - mem_resize(); - loadbios(); - resetpchard(); - } - pause = 0; - 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", "", NULL)) - config_save(openfilestring); - pause = 0; - break;*/ - case IDM_CDROM_DISABLED: if (cdrom_enabled) { From aad1179e47e8d68a262c82cef32c25e24b3a96d1 Mon Sep 17 00:00:00 2001 From: SarahW Date: Wed, 10 May 2017 20:55:08 +0100 Subject: [PATCH 07/11] --config command line option now bypasses configuration manager. --- src/ibm.h | 1 + src/pc.c | 9 ++++++--- src/win.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ibm.h b/src/ibm.h index a59c16e..c06010f 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -533,6 +533,7 @@ extern uint64_t timer_freq; void loadconfig(char *fn); +extern int config_override; extern int infocus; diff --git a/src/pc.c b/src/pc.c index 113fcee..2c38c83 100644 --- a/src/pc.c +++ b/src/pc.c @@ -57,6 +57,8 @@ int vid_resize, vid_api; int cycles_lost = 0; +int config_override = 0; + int clockrate; int insc=0; float mips,flops; @@ -216,7 +218,7 @@ void getpath() void initpc(int argc, char *argv[]) { //char *p; - char *config_file = NULL; +// char *config_file = NULL; int c; // allegro_init(); @@ -237,14 +239,15 @@ void initpc(int argc, char *argv[]) { if ((c+1) == argc) break; - config_file = argv[c+1]; + strncpy(config_file_default, argv[c+1], 256); + config_override = 1; c++; } } // append_filename(config_file_default, pcempath, "pcem.cfg", 511); - loadconfig(config_file); + loadconfig(NULL); pclog("Config loaded\n"); // if (config_file) // saveconfig(); diff --git a/src/win.c b/src/win.c index 66ea519..e839c5c 100644 --- a/src/win.c +++ b/src/win.c @@ -576,8 +576,11 @@ int WINAPI WinMain (HINSTANCE hThisInstance, { quited = 0; - if (!config_selection_open(NULL, 0)) - break; + if (!config_override) + { + if (!config_selection_open(NULL, 0)) + break; + } ghMutex = CreateMutex(NULL, FALSE, NULL); menu = LoadMenu(hThisInstance, TEXT("MainMenu")); @@ -618,6 +621,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, ghwnd = hwnd; + loadconfig(NULL); + if (vid_resize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE); else @@ -642,8 +647,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance, CheckMenuItem(menu, IDM_BPB_DISABLE, bpb_disable ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(menu, IDM_VID_DISC, vid_disc_indicator ? MF_CHECKED : MF_UNCHECKED); - loadconfig(NULL); - if (!loadbios()) { if (romset != -1) @@ -757,6 +760,9 @@ int WINAPI WinMain (HINSTANCE hThisInstance, DestroyWindow(hwnd); CloseHandle(ghMutex); + + if (config_override) + break; } closepc(); From d2245f2d450174684055e613e5b282b873620334 Mon Sep 17 00:00:00 2001 From: pcem_emulator Date: Mon, 15 May 2017 22:03:38 +0100 Subject: [PATCH 08/11] Ported configuration manager to Allegro GUI --- Makefile.in | 1 + configure | 14 +- src/Makefile.am | 2 +- src/Makefile.in | 73 +++++---- src/allegro-gui-config-sel.c | 265 +++++++++++++++++++++++++++++++++ src/allegro-gui-configure.c | 8 +- src/allegro-gui-deviceconfig.c | 14 +- src/allegro-gui-hdconf.c | 12 +- src/allegro-gui.c | 18 ++- src/allegro-gui.h | 3 + src/allegro-main.c | 197 ++++++++++++++---------- src/cdrom-null.h | 12 +- src/thread-pthread.c | 2 +- src/vid_ati_mach64.c | 4 + src/vid_s3_virge.c | 10 ++ src/vid_voodoo.c | 10 ++ src/video.h | 2 + 17 files changed, 502 insertions(+), 145 deletions(-) create mode 100644 src/allegro-gui-config-sel.c diff --git a/Makefile.in b/Makefile.in index 121d849..78e714f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -292,6 +292,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/configure b/configure index e93fe20..3fa2a2d 100755 --- a/configure +++ b/configure @@ -676,6 +676,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -754,6 +755,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1006,6 +1008,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1143,7 +1154,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1296,6 +1307,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff --git a/src/Makefile.am b/src/Makefile.am index 3552a0d..e2928a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,7 @@ pcem_CFLAGS = $(allegro_CFLAGS) pcem_LDADD = $(allegro_LIBS) -lopenal pcem_SOURCES = 386.c 386_dynarec.c 386_dynarec_ops.c 808x.c acer386sx.c ali1429.c allegro-gui.c \ -allegro-gui-configure.c allegro-gui-deviceconfig.c allegro-gui-hdconf.c allegro-joystick.c allegro-keyboard.c allegro-main.c \ +allegro-gui-config-sel.c allegro-gui-configure.c allegro-gui-deviceconfig.c allegro-gui-hdconf.c allegro-joystick.c allegro-keyboard.c allegro-main.c \ allegro-midi.c allegro-mouse.c allegro-video.c amstrad.c cdrom-ioctl-linux.c cdrom-iso.c cdrom-null.c \ codegen.c codegen_ops.c codegen_timing_486.c codegen_timing_686.c codegen_timing_pentium.c codegen_timing_winchip.c compaq.c config.c cpu.c \ dac.c device.c disc.c disc_fdi.c disc_img.c disc_sector.c dma.c fdc.c fdc37c665.c fdd.c fdi2raw.c gameport.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 80e07be..8066b6a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -108,20 +108,20 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__pcem_SOURCES_DIST = 386.c 386_dynarec.c 386_dynarec_ops.c 808x.c \ - acer386sx.c ali1429.c allegro-gui.c allegro-gui-configure.c \ - allegro-gui-deviceconfig.c allegro-gui-hdconf.c \ - allegro-joystick.c allegro-keyboard.c allegro-main.c \ - allegro-midi.c allegro-mouse.c allegro-video.c amstrad.c \ - cdrom-ioctl-linux.c cdrom-iso.c cdrom-null.c codegen.c \ - codegen_ops.c codegen_timing_486.c codegen_timing_686.c \ - codegen_timing_pentium.c codegen_timing_winchip.c compaq.c \ - config.c cpu.c dac.c device.c disc.c disc_fdi.c disc_img.c \ - disc_sector.c dma.c fdc.c fdc37c665.c fdd.c fdi2raw.c \ - gameport.c hdd.c hdd_esdi.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 \ + acer386sx.c ali1429.c allegro-gui.c allegro-gui-config-sel.c \ + allegro-gui-configure.c allegro-gui-deviceconfig.c \ + allegro-gui-hdconf.c allegro-joystick.c allegro-keyboard.c \ + allegro-main.c allegro-midi.c allegro-mouse.c allegro-video.c \ + amstrad.c cdrom-ioctl-linux.c cdrom-iso.c cdrom-null.c \ + codegen.c codegen_ops.c codegen_timing_486.c \ + codegen_timing_686.c codegen_timing_pentium.c \ + codegen_timing_winchip.c compaq.c config.c cpu.c dac.c \ + device.c disc.c disc_fdi.c disc_img.c disc_sector.c dma.c \ + fdc.c fdc37c665.c fdd.c fdi2raw.c gameport.c hdd.c hdd_esdi.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 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 \ @@ -159,6 +159,7 @@ am_pcem_OBJECTS = pcem-386.$(OBJEXT) pcem-386_dynarec.$(OBJEXT) \ pcem-386_dynarec_ops.$(OBJEXT) pcem-808x.$(OBJEXT) \ pcem-acer386sx.$(OBJEXT) pcem-ali1429.$(OBJEXT) \ pcem-allegro-gui.$(OBJEXT) \ + pcem-allegro-gui-config-sel.$(OBJEXT) \ pcem-allegro-gui-configure.$(OBJEXT) \ pcem-allegro-gui-deviceconfig.$(OBJEXT) \ pcem-allegro-gui-hdconf.$(OBJEXT) \ @@ -414,6 +415,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -427,20 +429,20 @@ CLEANFILES = $(noinst_SCRIPTS) pcem_CFLAGS = $(allegro_CFLAGS) $(am__append_2) pcem_LDADD = $(allegro_LIBS) -lopenal pcem_SOURCES = 386.c 386_dynarec.c 386_dynarec_ops.c 808x.c \ - acer386sx.c ali1429.c allegro-gui.c allegro-gui-configure.c \ - allegro-gui-deviceconfig.c allegro-gui-hdconf.c \ - allegro-joystick.c allegro-keyboard.c allegro-main.c \ - allegro-midi.c allegro-mouse.c allegro-video.c amstrad.c \ - cdrom-ioctl-linux.c cdrom-iso.c cdrom-null.c codegen.c \ - codegen_ops.c codegen_timing_486.c codegen_timing_686.c \ - codegen_timing_pentium.c codegen_timing_winchip.c compaq.c \ - config.c cpu.c dac.c device.c disc.c disc_fdi.c disc_img.c \ - disc_sector.c dma.c fdc.c fdc37c665.c fdd.c fdi2raw.c \ - gameport.c hdd.c hdd_esdi.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 \ + acer386sx.c ali1429.c allegro-gui.c allegro-gui-config-sel.c \ + allegro-gui-configure.c allegro-gui-deviceconfig.c \ + allegro-gui-hdconf.c allegro-joystick.c allegro-keyboard.c \ + allegro-main.c allegro-midi.c allegro-mouse.c allegro-video.c \ + amstrad.c cdrom-ioctl-linux.c cdrom-iso.c cdrom-null.c \ + codegen.c codegen_ops.c codegen_timing_486.c \ + codegen_timing_686.c codegen_timing_pentium.c \ + codegen_timing_winchip.c compaq.c config.c cpu.c dac.c \ + device.c disc.c disc_fdi.c disc_img.c disc_sector.c dma.c \ + fdc.c fdc37c665.c fdd.c fdi2raw.c gameport.c hdd.c hdd_esdi.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 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 \ @@ -570,6 +572,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-808x.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-acer386sx.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-ali1429.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-allegro-gui-config-sel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-allegro-gui-configure.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-allegro-gui-deviceconfig.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcem-allegro-gui-hdconf.Po@am__quote@ @@ -857,6 +860,20 @@ pcem-allegro-gui.obj: allegro-gui.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -c -o pcem-allegro-gui.obj `if test -f 'allegro-gui.c'; then $(CYGPATH_W) 'allegro-gui.c'; else $(CYGPATH_W) '$(srcdir)/allegro-gui.c'; fi` +pcem-allegro-gui-config-sel.o: allegro-gui-config-sel.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -MT pcem-allegro-gui-config-sel.o -MD -MP -MF $(DEPDIR)/pcem-allegro-gui-config-sel.Tpo -c -o pcem-allegro-gui-config-sel.o `test -f 'allegro-gui-config-sel.c' || echo '$(srcdir)/'`allegro-gui-config-sel.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pcem-allegro-gui-config-sel.Tpo $(DEPDIR)/pcem-allegro-gui-config-sel.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='allegro-gui-config-sel.c' object='pcem-allegro-gui-config-sel.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -c -o pcem-allegro-gui-config-sel.o `test -f 'allegro-gui-config-sel.c' || echo '$(srcdir)/'`allegro-gui-config-sel.c + +pcem-allegro-gui-config-sel.obj: allegro-gui-config-sel.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -MT pcem-allegro-gui-config-sel.obj -MD -MP -MF $(DEPDIR)/pcem-allegro-gui-config-sel.Tpo -c -o pcem-allegro-gui-config-sel.obj `if test -f 'allegro-gui-config-sel.c'; then $(CYGPATH_W) 'allegro-gui-config-sel.c'; else $(CYGPATH_W) '$(srcdir)/allegro-gui-config-sel.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pcem-allegro-gui-config-sel.Tpo $(DEPDIR)/pcem-allegro-gui-config-sel.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='allegro-gui-config-sel.c' object='pcem-allegro-gui-config-sel.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -c -o pcem-allegro-gui-config-sel.obj `if test -f 'allegro-gui-config-sel.c'; then $(CYGPATH_W) 'allegro-gui-config-sel.c'; else $(CYGPATH_W) '$(srcdir)/allegro-gui-config-sel.c'; fi` + pcem-allegro-gui-configure.o: allegro-gui-configure.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pcem_CFLAGS) $(CFLAGS) -MT pcem-allegro-gui-configure.o -MD -MP -MF $(DEPDIR)/pcem-allegro-gui-configure.Tpo -c -o pcem-allegro-gui-configure.o `test -f 'allegro-gui-configure.c' || echo '$(srcdir)/'`allegro-gui-configure.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pcem-allegro-gui-configure.Tpo $(DEPDIR)/pcem-allegro-gui-configure.Po diff --git a/src/allegro-gui-config-sel.c b/src/allegro-gui-config-sel.c new file mode 100644 index 0000000..5f2b7ff --- /dev/null +++ b/src/allegro-gui-config-sel.c @@ -0,0 +1,265 @@ +#include "ibm.h" +#include "device.h" +#include "allegro-main.h" +#include "allegro-gui.h" +#include "config.h" +#undef printf +typedef struct config_t +{ + char name[512]; + struct config_t *next; +} config_t; + +static config_t *config_head; + +static char *get_config(int nr); +static int get_config_nr(); +static void free_configs(); +static void populate_configs(); + +static char *list_proc_joystick(int index, int *list_size) +{ + int c = 0; + config_t *config = config_head; + + if (index < 0) + { + while (config) + { + c++; + config = config->next; + } + + *list_size = c; + return NULL; + } + + for (; c < index; c++) + { + if (!config) + return NULL; + config = config->next; + } + + if (!config) + return NULL; + + return config->name; +// return joystick_list[index].name; +} + +static char config_name[256]; + +static DIALOG new_config_dialog[] = +{ + {d_shadow_box_proc, 0, 0, 480,80,0,0xffffff,0,0, 0,0,0,0,0}, // 0 + + {d_button_proc, 240-148, 56, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "OK", 0, 0}, // 1 + {d_button_proc, 240+4, 56, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "Cancel", 0, 0}, // 2 + + {d_edit_proc, 8, 32, 464, 16, 0, 0xffffff, 0, 0, 255, 0, config_name, 0, 0}, // 3 + + {d_text_proc, 240-29*4, 16, 29*8, 16, 0, 0xffffff, 0, 0, 255, 0, "Please type new config name :", 0, 0}, + + {0,0,0,0,0,0,0,0,0,0,0,NULL,NULL,NULL} +}; + +static int new_proc(int msg, DIALOG *d, int c) +{ + int ret = d_button_proc(msg, d, c); + + if (ret == D_CLOSE) + { + int c; + + config_name[0] = 0; + new_config_dialog[3].d2 = 0; + + position_dialog(new_config_dialog, SCREEN_W/2 - new_config_dialog[0].w/2, SCREEN_H/2 - new_config_dialog[0].h/2); + + c = popup_dialog(new_config_dialog, 1); + + position_dialog(new_config_dialog, -(SCREEN_W/2 - new_config_dialog[0].w/2), -(SCREEN_H/2 - new_config_dialog[0].h/2)); + + if (c == 1) + { + sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, config_name); + c = settings_configure(); + free_configs(); + populate_configs(); + return c; + } + + return D_O_K; + } + + return ret; +} + +static int config_proc(int msg, DIALOG *d, int c) +{ + int ret = d_button_proc(msg, d, c); + + if (ret == D_CLOSE) + { + char *name = get_config(get_config_nr()); + + if (name) + { + sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, name); + loadconfig(NULL); + return settings_configure(); + } + + return D_O_K; + } + + return ret; +} + +static int hdd_proc(int msg, DIALOG *d, int c) +{ + int ret = d_button_proc(msg, d, c); + + if (ret == D_CLOSE) + { + char *name = get_config(get_config_nr()); + + if (name) + { + sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, name); + loadconfig(NULL); + return disc_hdconf(); + } + + return D_O_K; + } + + return ret; +} + +static DIALOG config_sel_dialog[] = +{ + {d_shadow_box_proc, 0, 0, 568,372,0,0xffffff,0,0, 0,0,0,0,0}, // 0 + + {d_button_proc, 416, 8, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "Load", 0, 0}, // 1 + {d_button_proc, 416, 348, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "Quit", 0, 0}, // 2 + + {new_proc, 416, 56, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "New...", 0, 0}, // 3 + {config_proc, 416, 80, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "Configure...", 0, 0}, // 4 + {hdd_proc, 416, 104, 144, 16, 0, 0xffffff, 0, D_EXIT, 0, 0, "HDD...", 0, 0}, // 5 + + {d_list_proc, 8, 8, 400, 356, 0, 0xffffff, 0, 0, 0, 0, list_proc_joystick, 0, 0}, // 6 + + {0,0,0,0,0,0,0,0,0,0,0,NULL,NULL,NULL} +}; + +static int get_config_nr() +{ + return config_sel_dialog[6].d1; +} + +static void populate_configs() +{ + struct al_ffblk info; + char cfg[512]; + config_t *config = NULL; + + strcpy(cfg, pcempath); + strcat(cfg, "/configs/*.cfg"); + printf("cfg %s\n", cfg); + if (al_findfirst(cfg, &info, FA_ALL)) + return; + + do + { + config_t *old_config = config; + char *ext; + + config = malloc(sizeof(config_t)); + if (old_config) + old_config->next = config; + else + config_head = config; + config->next = 0; + strcpy(config->name, info.name); + + ext = get_extension(config->name); + if (ext && ext[0]) + { + ext--; + *ext = 0; + } + + printf("Found %s\n", info.name); + } while (al_findnext(&info) == 0); + + al_findclose(&info); +} + +static char *get_config(int nr) +{ + config_t *config = config_head; + int c; + + for (c = 0; c < nr; c++) + { + if (!config) + return NULL; + config = config->next; + } + if (!config) + return NULL; + + return config->name; +} + +static void free_configs() +{ + config_t *config = config_head; + + while (config) + { + config_t *old_config = config; + + config = config->next; + free(old_config); + } +} + +int config_sel() +{ + populate_configs(); + set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); + while (1) + { + int c; + + position_dialog(config_sel_dialog, SCREEN_W/2 - config_sel_dialog[0].w/2, SCREEN_H/2 - config_sel_dialog[0].h/2); + + c = popup_dialog(config_sel_dialog, 1); + + position_dialog(config_sel_dialog, -(SCREEN_W/2 - config_sel_dialog[0].w/2), -(SCREEN_H/2 - config_sel_dialog[0].h/2)); + + if (c == 1) + { + char *name = get_config(config_sel_dialog[6].d1); + + if (name) + { + sprintf(config_file_default, "%sconfigs/%s.cfg", pcempath, name); + pclog("config_file_default=%s\n", config_file_default); + free_configs(); + return 0; + } + } + + if (c == 2) + return 1; + } + + free_configs(); + + return 1; +} + diff --git a/src/allegro-gui-configure.c b/src/allegro-gui-configure.c index 2f36ac3..cdd16a3 100644 --- a/src/allegro-gui-configure.c +++ b/src/allegro-gui-configure.c @@ -6,14 +6,14 @@ #include "fdd.h" #include "gameport.h" #include "hdd.h" +#include "mem.h" #include "model.h" #include "mouse.h" #include "sound.h" #include "video.h" #include "vid_voodoo.h" -static int romstolist[ROM_MAX], listtomodel[ROM_MAX], romstomodel[ROM_MAX], modeltolist[ROM_MAX]; -static int settings_sound_to_list[20], settings_list_to_sound[20]; +static int romstolist[ROM_MAX]; static int settings_mouse_to_list[20], settings_list_to_mouse[20]; typedef struct allegro_list_t @@ -779,7 +779,7 @@ pclog("video_card_available : %i\n", c); new_dynarec != cpu_use_dynarec || new_fda != fdd_get_type(0) || new_fdb != fdd_get_type(1) || new_mouse != mouse_type || strncmp(hdd_list[new_hdd].internal_name, hdd_controller_name, sizeof(hdd_controller_name)-1)) { - if (alert("This will reset PCem!", "Okay to continue?", NULL, "OK", "Cancel", 0, 0) != 1) + if (has_been_inited && alert("This will reset PCem!", "Okay to continue?", NULL, "OK", "Cancel", 0, 0) != 1) continue; model = new_model; @@ -821,7 +821,7 @@ pclog("video_card_available : %i\n", c); joystick_type = configure_dialog[31].d1; gameport_update_joystick_type(); - saveconfig(); + saveconfig(NULL); speedchanged(); diff --git a/src/allegro-gui-deviceconfig.c b/src/allegro-gui-deviceconfig.c index a5029f8..3899ce9 100644 --- a/src/allegro-gui-deviceconfig.c +++ b/src/allegro-gui-deviceconfig.c @@ -73,7 +73,7 @@ void deviceconfig_open(device_t *device) d->dp = config->description; d->proc = d_check_proc; - d->flags = config_get_int(device->name, config->name, config->default_int) ? D_SELECTED : 0; + d->flags = config_get_int(CFG_MACHINE, device->name, config->name, config->default_int) ? D_SELECTED : 0; d->bg = 0xffffff; d->fg = 0; @@ -129,7 +129,7 @@ void deviceconfig_open(device_t *device) c = 0; while (config->selection[c].description[0]) { - if (config_get_int(device->name, config->name, config->default_int) == config->selection[c].value) + if (config_get_int(CFG_MACHINE, device->name, config->name, config->default_int) == config->selection[c].value) d->d1 = c; c++; } @@ -212,7 +212,7 @@ void deviceconfig_open(device_t *device) case CONFIG_BINARY: val = (d->flags & D_SELECTED) ? 1 : 0; - if (val != config_get_int(device->name, config->name, config->default_int)) + if (val != config_get_int(CFG_MACHINE, device->name, config->name, config->default_int)) changed = 1; dialog_pos++; @@ -226,7 +226,7 @@ void deviceconfig_open(device_t *device) val = config->selection[d->d1].value; - if (val != config_get_int(device->name, config->name, config->default_int)) + if (val != config_get_int(CFG_MACHINE, device->name, config->name, config->default_int)) changed = 1; dialog_pos += 2; @@ -262,7 +262,7 @@ void deviceconfig_open(device_t *device) case CONFIG_BINARY: val = (d->flags & D_SELECTED) ? 1 : 0; - config_set_int(config_device->name, config->name, val); + config_set_int(CFG_MACHINE, config_device->name, config->name, val); dialog_pos++; break; @@ -275,7 +275,7 @@ void deviceconfig_open(device_t *device) val = config->selection[d->d1].value; - config_set_int(config_device->name, config->name, val); + config_set_int(CFG_MACHINE, config_device->name, config->name, val); dialog_pos += 2; break; @@ -290,7 +290,7 @@ void deviceconfig_open(device_t *device) break; } - saveconfig(); + saveconfig(NULL); resetpchard(); diff --git a/src/allegro-gui-hdconf.c b/src/allegro-gui-hdconf.c index 6f1809f..493c3ff 100644 --- a/src/allegro-gui-hdconf.c +++ b/src/allegro-gui-hdconf.c @@ -198,10 +198,8 @@ static DIALOG hdnew_dialog[]= static int create_hd(char *fn, int cyl, int hpc, int spt) { int c; - int e; uint8_t buf[512]; FILE *f = fopen64(hd_path_new, "wb"); - e = errno; if (!f) { alert("Can't open file for write", NULL, NULL, "OK", NULL, 0, 0); @@ -213,6 +211,8 @@ static int create_hd(char *fn, int cyl, int hpc, int spt) fwrite(buf, 512, 1, f); } fclose(f); + + return 0; } static int hdconf_new(int msg, DIALOG *d, int c) @@ -238,9 +238,6 @@ static int hdconf_new(int msg, DIALOG *d, int c) if (ret == 1) { int spt, hpc, cyl; - int c, d; - FILE *f; - uint8_t *buf; sscanf(hd_sectors_new, "%i", &spt); sscanf(hd_heads_new, "%i", &hpc); @@ -470,7 +467,6 @@ static int hdconf_radio_cd(int msg, DIALOG *d, int c) int disc_hdconf() { int c; - int changed=0; hdc_new[0] = hdc[0]; hdc_new[1] = hdc[1]; @@ -511,7 +507,7 @@ int disc_hdconf() if (c == 1) { - if (alert("This will reset PCem!", "Okay to continue?", NULL, "OK", "Cancel", 0, 0) == 1) + if (!has_been_inited || alert("This will reset PCem!", "Okay to continue?", NULL, "OK", "Cancel", 0, 0) == 1) { hdc[0] = hdc_new[0]; hdc[1] = hdc_new[1]; @@ -525,7 +521,7 @@ int disc_hdconf() cdrom_channel = new_cdrom_channel; - saveconfig(); + saveconfig(NULL); resetpchard(); diff --git a/src/allegro-gui.c b/src/allegro-gui.c index ec70b25..19cadb9 100644 --- a/src/allegro-gui.c +++ b/src/allegro-gui.c @@ -4,7 +4,9 @@ #include "allegro-gui.h" #include "disc.h" #include "ide.h" +#include "cdrom-ioctl.h" #include "cdrom-iso.h" +#include "cdrom-null.h" void warning(const char *format, ...) { @@ -63,7 +65,7 @@ static int disc_load_a() { disc_close(0); disc_load(0, fn); - saveconfig(); + saveconfig(NULL); } return D_O_K; } @@ -79,7 +81,7 @@ static int disc_load_b() { disc_close(1); disc_load(1, fn); - saveconfig(); + saveconfig(NULL); } return D_O_K; } @@ -87,7 +89,7 @@ static int disc_load_b() static int disc_eject_a() { disc_close(0); - saveconfig(); + saveconfig(NULL); return D_O_K; } @@ -95,7 +97,7 @@ static int disc_eject_a() static int disc_eject_b() { disc_close(1); - saveconfig(); + saveconfig(NULL); return D_O_K; } @@ -144,7 +146,7 @@ static int cdrom_disabled() { atapi->exit(); cdrom_enabled = 0; - saveconfig(); + saveconfig(NULL); resetpchard(); cdrom_update(); } @@ -167,7 +169,7 @@ static int cdrom_empty() cdrom_drive = -1; cdrom_enabled = 1; cdrom_null_open(cdrom_drive); - saveconfig(); + saveconfig(NULL); resetpchard(); cdrom_update(); } @@ -188,7 +190,7 @@ static int cdrom_dev() cdrom_drive = 1; cdrom_enabled = 1; ioctl_open(cdrom_drive); - saveconfig(); + saveconfig(NULL); resetpchard(); cdrom_update(); } @@ -222,7 +224,7 @@ static int cdrom_iso() resetpchard(); } cdrom_update(); - saveconfig(); + saveconfig(NULL); } return D_O_K; } diff --git a/src/allegro-gui.h b/src/allegro-gui.h index 3f53b59..2c98f82 100644 --- a/src/allegro-gui.h +++ b/src/allegro-gui.h @@ -10,3 +10,6 @@ int disc_hdconf(); int settings_configure(); void deviceconfig_open(device_t *device); +int config_sel(); + +extern int has_been_inited; diff --git a/src/allegro-main.c b/src/allegro-main.c index cb2d526..47098f6 100644 --- a/src/allegro-main.c +++ b/src/allegro-main.c @@ -1,11 +1,23 @@ -#include "allegro-main.h" #include "ibm.h" +#include "device.h" +#include "allegro-gui.h" +#include "allegro-main.h" +#include "allegro-video.h" +#include "config.h" #include "cpu.h" +#include "mem.h" #include "model.h" #include "nvr.h" +#include "plat-joystick.h" +#include "plat-keyboard.h" +#include "plat-midi.h" +#include "plat-mouse.h" +#include "sound.h" #include "video.h" - -#undef printf + + #undef printf + +int has_been_inited = 0; int mousecapture = 0; int quited = 0; @@ -51,7 +63,7 @@ uint64_t timer_read() int main(int argc, char *argv[]) { int frames = 0; - int c, d; + int c; allegro_init(); allegro_video_init(); install_timer(); @@ -59,9 +71,16 @@ int main(int argc, char *argv[]) install_int_ex(onesec, BPS_TO_TIMER(1)); midi_init(); + getpath(); + + sound_init(); + initpc(argc, argv); - d = romset; + keyboard_init(); + mouse_init(); + joystick_init(); + for (c = 0; c < ROM_MAX; c++) { romset = c; @@ -80,90 +99,106 @@ int main(int argc, char *argv[]) return 0; } - romset=d; - c=loadbios(); - - if (!c) - { - if (romset != -1) - printf("Configured romset not available.\nDefaulting to available romset."); - for (c = 0; c < ROM_MAX; c++) - { - if (romspresent[c]) - { - romset = c; - model = model_getmodel(romset); - saveconfig(); - resetpchard(); - break; - } - } - } - for (c = 0; c < GFX_MAX; c++) gfx_present[c] = video_card_available(video_old_to_new(c)); - if (!video_card_available(video_old_to_new(gfxcard))) + while (1) { - if (gfxcard) printf("Configured video BIOS not available.\nDefaulting to available romset."); - for (c = GFX_MAX-1; c >= 0; c--) - { - if (gfx_present[c]) - { - gfxcard = c; - saveconfig(); - resetpchard(); - break; - } - } - } - - resetpchard(); - - ticks = 0; - while (!quited) - { - if (ticks) - { - ticks--; - runpc(); - frames++; - if (frames >= 200 && nvr_dosave) - { - frames = 0; - nvr_dosave = 0; - savenvr(); - } - } - else - rest(1); - - if (ticks > 10) - ticks = 0; + has_been_inited = 0; + if (config_sel()) + return 0; + has_been_inited = 1; - if ((mouse_b & 1) && !mousecapture) - mousecapture = 1; - - if (((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_END]) || (mouse_b & 4)) - mousecapture = 0; - - if ((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_ALT] && key[KEY_PGDN]) - { - int old_winsizex = winsizex, old_winsizey = winsizey; - if (winsizex < 512 || winsizey < 350) - updatewindowsize(512, 350); - gui_enter(); - if (old_winsizex < 512 || old_winsizey < 350) - updatewindowsize(old_winsizex, old_winsizey); - ticks = 0; - } - } + quited = 0; - closepc(); + loadconfig(NULL); - midi_close(); + c=loadbios(); - return 0; + if (!c) + { + if (romset != -1) + printf("Configured romset not available.\nDefaulting to available romset."); + for (c = 0; c < ROM_MAX; c++) + { + if (romspresent[c]) + { + romset = c; + model = model_getmodel(romset); + saveconfig(NULL); + resetpchard(); + break; + } + } + } + + if (!video_card_available(video_old_to_new(gfxcard))) + { + if (gfxcard) printf("Configured video BIOS not available.\nDefaulting to available romset."); + for (c = GFX_MAX-1; c >= 0; c--) + { + if (gfx_present[c]) + { + gfxcard = c; + saveconfig(NULL); + resetpchard(); + break; + } + } + } + + resetpchard(); + + ticks = 0; + while (!quited) + { + if (ticks) + { + ticks--; + runpc(); + frames++; + if (frames >= 200 && nvr_dosave) + { + frames = 0; + nvr_dosave = 0; + savenvr(); + } + } + else + rest(1); + + if (ticks > 10) + ticks = 0; + + if ((mouse_b & 1) && !mousecapture) + mousecapture = 1; + + if (((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_END]) || (mouse_b & 4)) + mousecapture = 0; + + if ((key[KEY_LCONTROL] || key[KEY_RCONTROL]) && key[KEY_ALT] && key[KEY_PGDN]) + { + int old_winsizex = winsizex, old_winsizey = winsizey; + if (winsizex < 512 || winsizey < 350) + updatewindowsize(512, 350); + gui_enter(); + if (old_winsizex < 512 || old_winsizey < 350) + updatewindowsize(old_winsizex, old_winsizey); + ticks = 0; + } + } + + savenvr(); + } + + closepc(); + + joystick_close(); + mouse_close(); + keyboard_close(); + midi_close(); + + return 0; } END_OF_MAIN(); diff --git a/src/cdrom-null.h b/src/cdrom-null.h index b5a0e1c..98f042a 100644 --- a/src/cdrom-null.h +++ b/src/cdrom-null.h @@ -1,11 +1,11 @@ -#ifndef CDROM_IOCTL_H -#define CDROM_IOCTL_H +#ifndef CDROM_NULL_H +#define CDROM_NULL_H /* this header file lists the functions provided by various platform specific cdrom-ioctl files */ -extern int cdrom_null_open(char d); -extern void cdrom_null_reset(); -extern void null_close(); +int cdrom_null_open(char d); +void cdrom_null_reset(); +void null_close(); -#endif /* ! CDROM_IOCTL_H */ +#endif /* ! CDROM_NULL_H */ diff --git a/src/thread-pthread.c b/src/thread-pthread.c index 51d7d8a..7d29698 100644 --- a/src/thread-pthread.c +++ b/src/thread-pthread.c @@ -14,7 +14,7 @@ thread_t *thread_create(void (*thread_rout)(void *param), void *param) { pthread_t *thread = malloc(sizeof(pthread_t)); - pthread_create(thread, NULL, thread_rout, param); + pthread_create(thread, NULL, (void *)thread_rout, param); return thread; } diff --git a/src/vid_ati_mach64.c b/src/vid_ati_mach64.c index d746b0c..e7ff3f0 100644 --- a/src/vid_ati_mach64.c +++ b/src/vid_ati_mach64.c @@ -14,6 +14,10 @@ #include "vid_ati_eeprom.h" #include "vid_ics2595.h" +#ifdef CLAMP +#undef CLAMP +#endif + //#define MACH64_DEBUG #define FIFO_SIZE 65536 diff --git a/src/vid_s3_virge.c b/src/vid_s3_virge.c index 8811ddb..cb30cee 100644 --- a/src/vid_s3_virge.c +++ b/src/vid_s3_virge.c @@ -12,6 +12,16 @@ #include "vid_svga.h" #include "vid_svga_render.h" +#ifdef MIN +#undef MIN +#endif +#ifdef MAX +#undef MAX +#endif +#ifdef CLAMP +#undef CLAMP +#endif + static uint64_t virge_time = 0; static uint64_t status_time = 0; static int reg_writes = 0, reg_reads = 0; diff --git a/src/vid_voodoo.c b/src/vid_voodoo.c index 747316b..b77a14a 100644 --- a/src/vid_voodoo.c +++ b/src/vid_voodoo.c @@ -12,6 +12,16 @@ #include "vid_voodoo.h" #include "vid_voodoo_dither.h" +#ifdef MIN +#undef MIN +#endif +#ifdef ABS +#undef ABS +#endif +#ifdef CLAMP +#undef CLAMP +#endif + #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define CLAMP(x) (((x) < 0) ? 0 : (((x) > 0xff) ? 0xff : (x))) diff --git a/src/video.h b/src/video.h index 42454d1..f7fa3e7 100644 --- a/src/video.h +++ b/src/video.h @@ -1,6 +1,8 @@ #ifdef __unix +#undef MAX_JOYSTICKS #include "allegro-main.h" +#define MAX_JOYSTICKS 4 #else From 7af913b1b7b21c20b51ee612515bdae72597a3f2 Mon Sep 17 00:00:00 2001 From: SarahW Date: Tue, 16 May 2017 20:56:32 +0100 Subject: [PATCH 09/11] Fixed a couple of missing returns in Allegro GUI. --- src/allegro-gui.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/allegro-gui.c b/src/allegro-gui.c index 19cadb9..43914e6 100644 --- a/src/allegro-gui.c +++ b/src/allegro-gui.c @@ -173,6 +173,8 @@ static int cdrom_empty() resetpchard(); cdrom_update(); } + + return D_O_K; } static int cdrom_dev() @@ -194,6 +196,8 @@ static int cdrom_dev() resetpchard(); cdrom_update(); } + + return D_O_K; } static int cdrom_iso() From 3fd4391289d95c4a0bf61ee943fefc9d746a7fab Mon Sep 17 00:00:00 2001 From: SarahW Date: Tue, 16 May 2017 20:57:01 +0100 Subject: [PATCH 10/11] HDD controller type now correctly determined when editing hard disc parameters from configuration manager. --- src/hdd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hdd.c b/src/hdd.c index 45ed5ab..41e5a1d 100644 --- a/src/hdd.c +++ b/src/hdd.c @@ -53,7 +53,20 @@ int hdd_controller_available(int hdd) int hdd_controller_current_is_mfm() { - return hdd_controllers[hdd_controller_current].is_mfm; + int c = 0; + + while (hdd_controllers[c].device) + { + if (!strcmp(hdd_controller_name, hdd_controllers[c].internal_name)) + { + hdd_controller_current = c; + if (strcmp(hdd_controller_name, "none")) + return hdd_controllers[c].is_mfm; + } + c++; + } + + return 0; } void hdd_controller_init(char *internal_name) From 950ea99c014ebbe641a6eb8dd5c2616ba09c6359 Mon Sep 17 00:00:00 2001 From: SarahW Date: Tue, 16 May 2017 20:57:13 +0100 Subject: [PATCH 11/11] Tweak configuration manager dialogue. --- src/pc.rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pc.rc b/src/pc.rc index 11f4c23..0c3ab71 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -320,8 +320,8 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "PCem Configuration Manager" FONT 8, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "OK", IDOK, 200-54, 4, 50, 14, WS_TABSTOP - DEFPUSHBUTTON "Cancel", IDCANCEL, 200-54,22, 50, 14, WS_TABSTOP + DEFPUSHBUTTON "Load", IDOK, 200-54, 4, 50, 14, WS_TABSTOP + DEFPUSHBUTTON "Quit", IDCANCEL, 200-54,132,50, 14, WS_TABSTOP DEFPUSHBUTTON "New...", IDC_NEW, 200-54,40, 50, 14, WS_TABSTOP DEFPUSHBUTTON "Configuration...", IDC_CONFIG, 200-54,58, 50, 14, WS_TABSTOP DEFPUSHBUTTON "HDD...", IDC_HDCONF, 200-54,76, 50, 14, WS_TABSTOP