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