Merge with new_config

This commit is contained in:
SarahW 2017-05-16 20:59:24 +01:00
commit 183350c82f
37 changed files with 1193 additions and 590 deletions

View file

@ -292,6 +292,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@

1
configs/configs.txt Normal file
View file

@ -0,0 +1 @@
This directory is used to store config files.

14
configure vendored
View file

@ -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]

View file

@ -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 dells200.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 \

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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,10 +169,12 @@ static int cdrom_empty()
cdrom_drive = -1;
cdrom_enabled = 1;
cdrom_null_open(cdrom_drive);
saveconfig();
saveconfig(NULL);
resetpchard();
cdrom_update();
}
return D_O_K;
}
static int cdrom_dev()
@ -188,10 +192,12 @@ static int cdrom_dev()
cdrom_drive = 1;
cdrom_enabled = 1;
ioctl_open(cdrom_drive);
saveconfig();
saveconfig(NULL);
resetpchard();
cdrom_update();
}
return D_O_K;
}
static int cdrom_iso()
@ -222,7 +228,7 @@ static int cdrom_iso()
resetpchard();
}
cdrom_update();
saveconfig();
saveconfig(NULL);
}
return D_O_K;
}

View file

@ -10,3 +10,6 @@ int disc_hdconf();
int settings_configure();
void deviceconfig_open(device_t *device);
int config_sel();
extern int has_been_inited;

View file

@ -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();

View file

@ -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 */

View file

@ -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(&current_section->list, &config_head);
list_add(&current_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)
{

View file

@ -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

View file

@ -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++;
}

View file

@ -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)

View file

@ -533,6 +533,7 @@ extern uint64_t timer_freq;
void loadconfig(char *fn);
extern int config_override;
extern int infocus;
@ -559,6 +560,7 @@ void resetpc();
void resetpchard();
void speedchanged();
void saveconfig();
void saveconfig(char *fn);
void getpath();
#define UNUSED(x) (void)x

View file

@ -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;

305
src/pc.c
View file

@ -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;
@ -69,7 +71,7 @@ int framecount,fps;
int output;
int atfullspeed;
void saveconfig();
void saveconfig(char *fn);
int infocus;
int mousecapture;
FILE *pclogf;
@ -202,17 +204,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++)
{
@ -231,22 +239,18 @@ 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++;
}
}
keyboard_init();
mouse_init();
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);
loadconfig(NULL);
pclog("Config loaded\n");
if (config_file)
saveconfig();
// if (config_file)
// saveconfig();
cpuspeed2=(AT)?2:1;
// cpuspeed2=cpuspeed;
@ -273,7 +277,6 @@ void initpc(int argc, char *argv[])
//loadfont();
loadnvr();
sound_init();
resetide();
#if __unix
if (cdrom_drive == -1)
@ -552,7 +555,6 @@ void closepc()
closevideo();
mouse_emu_close();
device_close_all();
midi_close();
}
/*int main()
@ -573,19 +575,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
@ -595,220 +615,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()
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);
config_save(config_file_default);
pclog("config_save(%s)\n", config_file_default);
if (fn)
config_save(CFG_MACHINE, fn);
else
config_save(CFG_MACHINE, config_file_default);
config_save(CFG_GLOBAL, global_config_file);
}

View file

@ -53,9 +53,6 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Disc activity indicator", IDM_VID_DISC
END
MENUITEM SEPARATOR
MENUITEM "&Load configuration...", IDM_CONFIG_LOAD
MENUITEM "&Save configuration...", IDM_CONFIG_SAVE
END
POPUP "&Misc"
BEGIN
@ -317,3 +314,17 @@ 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 | DS_CENTER
CAPTION "PCem Configuration Manager"
FONT 8, "MS Sans Serif"
BEGIN
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
LISTBOX IDC_LIST, 4, 4,140,142, WS_TABSTOP
END

View file

@ -9,8 +9,6 @@
#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_STATUS 40030
#define IDM_VID_RESIZE 40050
#define IDM_VID_REMEMBER 40051
@ -134,3 +132,8 @@
#define WM_RESETD3D WM_USER
#define WM_LEAVEFULLSCREEN WM_USER + 1
#define IDC_NEW 1200
#define IDC_LIST 1201
#define IDC_CONFIG 1202
#define IDC_HDCONF 1203

View file

@ -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;
}

View file

@ -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

View file

@ -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;

View file

@ -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)))

View file

@ -1,6 +1,8 @@
#ifdef __unix
#undef MAX_JOYSTICKS
#include "allegro-main.h"
#define MAX_JOYSTICKS 4
#else

View file

@ -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];
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();

185
src/win-config_sel.c Normal file
View file

@ -0,0 +1,185 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include <commctrl.h>
#include "ibm.h"
#include "config.h"
#include "resources.h"
#include "win.h"
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);
saveconfig(openfilestring);
}
config_list_update(hdlg);
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;
}
return FALSE;
}
int config_selection_open(HWND hwnd, int inited)
{
int ret;
has_been_inited = inited;
ret = DialogBox(hinstance, TEXT("ConfigureSelectionDlg"), hwnd, (DLGPROC)config_selection_dlgproc);
has_been_inited = 1;
return ret;
}

View file

@ -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;

View file

@ -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;
@ -178,9 +178,10 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
config++;
}
saveconfig();
saveconfig(NULL);
resetpchard();
if (has_been_inited)
resetpchard();
EndDialog(hdlg, 0);
return TRUE;

View file

@ -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);
@ -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();
if (has_been_inited)
{
saveconfig(NULL);
resetpchard();
resetpchard();
}
}
}
case IDCANCEL:

View file

@ -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);

View file

@ -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)))

441
src/win.c
View file

@ -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"
@ -173,6 +174,7 @@ void mainthread(LPVOID param)
// Sleep(500);
drawits=0;
old_time = GetTickCount();
while (!quited)
{
if (updatestatus)
@ -533,76 +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 */
);
getpath();
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
// 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;
initpc(argc, argv);
vid_apis[0][vid_api].init(ghwnd);
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<ROM_MAX;c++)
{
romset=c;
romspresent[c]=loadbios();
romset = c;
romspresent[c] = loadbios();
pclog("romset %i - %i\n", c, romspresent[c]);
}
@ -613,154 +552,223 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
}
if (c == ROM_MAX)
{
MessageBox(hwnd,"No ROMs present!\nYou must have at least one romset to use PCem.","PCem fatal error",MB_OK);
MessageBox(NULL, "No ROMs present!\nYou must have at least one romset to use PCem.","PCem fatal error",MB_OK);
return 0;
}
romset=d;
c=loadbios();
if (!c)
{
if (romset!=-1) MessageBox(hwnd,"Configured romset not available.\nDefaulting to available romset.","PCem error",MB_OK);
for (c=0;c<ROM_MAX;c++)
{
if (romspresent[c])
{
romset = c;
model = model_getmodel(romset);
saveconfig();
resetpchard();
break;
}
}
}
romset = d;
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)))
{
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;
saveconfig();
resetpchard();
break;
}
}
}
loadbios();
resetpchard();
timeBeginPeriod(1);
atexit(releasemouse);
// QueryPerformanceFrequency(&counter_base);
/// QueryPerformanceCounter(&counter_posold);
// counter_posold.QuadPart*=100;
ghMutex = CreateMutex(NULL, FALSE, NULL);
mainthreadh=(HANDLE)_beginthread(mainthread,0,NULL);
SetThreadPriority(mainthreadh, THREAD_PRIORITY_HIGHEST);
updatewindowsize(640, 480);
QueryPerformanceFrequency(&qpc_freq);
timer_freq = qpc_freq.QuadPart;
sound_init();
// focus=1;
// setrefresh(100);
initpc(argc, argv);
while (1)
{
quited = 0;
// ShowCursor(TRUE);
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 (!config_override)
{
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;
}
}*/
if (!config_selection_open(NULL, 0))
break;
}
while (GetMessage(&messages,NULL,0,0) && !quited)
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;
loadconfig(NULL);
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);
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();
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);
if (config_override)
break;
}
closepc();
timeEndPeriod(1);
// dumpregs();
if (mousecapture)
{
ClipCursor(&oldclip);
ShowCursor(TRUE);
}
UnregisterClass(szSubClassName, hinstance);
UnregisterClass(szClassName, hinstance);
@ -810,7 +818,7 @@ int getfile(HWND hwnd, char *f, char *fn)
return 1;
}
int getsfile(HWND hwnd, char *f, char *fn)
int getsfile(HWND hwnd, char *f, char *fn, char *dir)
{
OPENFILENAME ofn; // common dialog box structure
BOOL r;
@ -832,7 +840,7 @@ int getsfile(HWND hwnd, char *f, char *fn)
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.lpstrInitialDir = dir;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box.
@ -933,7 +941,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
{
disc_close(0);
disc_load(0, openfilestring);
saveconfig();
saveconfig(NULL);
}
break;
case IDM_DISC_B:
@ -941,21 +949,21 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
{
disc_close(1);
disc_load(1, openfilestring);
saveconfig();
saveconfig(NULL);
}
break;
case IDM_EJECT_A:
disc_close(0);
saveconfig();
saveconfig(NULL);
break;
case IDM_EJECT_B:
disc_close(1);
saveconfig();
saveconfig(NULL);
break;
case IDM_BPB_DISABLE:
bpb_disable = !bpb_disable;
CheckMenuItem(hmenu, IDM_BPB_DISABLE, bpb_disable ? MF_CHECKED : MF_UNCHECKED);
saveconfig();
saveconfig(NULL);
break;
case IDM_HDCONF:
hdconf_open(hwnd);
@ -974,12 +982,12 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)|WS_VISIBLE);
GetWindowRect(hwnd,&rect);
SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED);
saveconfig();
saveconfig(NULL);
break;
case IDM_VID_ASPECT:
video_force_aspect_ration = !video_force_aspect_ration;
CheckMenuItem(hmenu, IDM_VID_ASPECT, video_force_aspect_ration ? MF_CHECKED : MF_UNCHECKED);
saveconfig();
saveconfig(NULL);
break;
case IDM_VID_REMEMBER:
window_remember = !window_remember;
@ -992,7 +1000,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
window_w = rect.right - rect.left;
window_h = rect.bottom - rect.top;
}
saveconfig();
saveconfig(NULL);
break;
case IDM_VID_DDRAW: case IDM_VID_D3D:
@ -1004,7 +1012,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheckMenuItem(hmenu, IDM_VID_DDRAW + vid_api, MF_CHECKED);
vid_apis[0][vid_api].init(ghwnd);
endblit();
saveconfig();
saveconfig(NULL);
device_force_redraw();
break;
@ -1033,36 +1041,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_UNCHECKED);
video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL;
CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED);
saveconfig();
saveconfig(NULL);
break;
case IDM_VID_DISC:
vid_disc_indicator = !vid_disc_indicator;
CheckMenuItem(hmenu, IDM_VID_DISC, vid_disc_indicator ? MF_CHECKED : MF_UNCHECKED);
saveconfig();
break;
case IDM_CONFIG_LOAD:
pause = 1;
if (!getfile(hwnd, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", ""))
{
if (MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) == IDOK)
{
loadconfig(openfilestring);
config_save(config_file_default);
mem_resize();
loadbios();
resetpchard();
}
}
pause = 0;
break;
case IDM_CONFIG_SAVE:
pause = 1;
if (!getsfile(hwnd, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", ""))
config_save(openfilestring);
pause = 0;
saveconfig(NULL);
break;
case IDM_CDROM_DISABLED:
@ -1090,7 +1075,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
pause = 1;
Sleep(100);
cdrom_enabled = 0;
saveconfig();
saveconfig(NULL);
resetpchard();
pause = 0;
}
@ -1121,13 +1106,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
old_cdrom_drive = cdrom_drive;
cdrom_drive=0;
CheckMenuItem(hmenu, IDM_CDROM_EMPTY, MF_CHECKED);
saveconfig();
saveconfig(NULL);
if (!cdrom_enabled)
{
pause = 1;
Sleep(100);
cdrom_enabled = 1;
saveconfig();
saveconfig(NULL);
resetpchard();
pause = 0;
}
@ -1161,13 +1146,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheckMenuItem(hmenu, IDM_CDROM_ISO, MF_UNCHECKED);
cdrom_drive = CDROM_ISO;
CheckMenuItem(hmenu, IDM_CDROM_ISO, MF_CHECKED);
saveconfig();
saveconfig(NULL);
if (!cdrom_enabled)
{
pause = 1;
Sleep(100);
cdrom_enabled = 1;
saveconfig();
saveconfig(NULL);
resetpchard();
pause = 0;
}
@ -1202,13 +1187,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
CheckMenuItem(hmenu, IDM_CDROM_ISO, MF_UNCHECKED);
cdrom_drive = new_cdrom_drive;
CheckMenuItem(hmenu, IDM_CDROM_REAL + cdrom_drive, MF_CHECKED);
saveconfig();
saveconfig(NULL);
if (!cdrom_enabled)
{
pause = 1;
Sleep(100);
cdrom_enabled = 1;
saveconfig();
saveconfig(NULL);
resetpchard();
pause = 0;
}

View file

@ -24,6 +24,8 @@ void hdconf_open(HWND hwnd);
void config_open(HWND hwnd);
int config_selection_open(HWND hwnd, int inited);
struct device_t;
void deviceconfig_open(HWND hwnd, struct device_t *device);
@ -32,6 +34,8 @@ void joystickconfig_open(HWND hwnd, int joy_nr, int type);
extern char openfilestring[260];
int getfile(HWND hwnd, char *f, char *fn);
int getsfile(HWND hwnd, char *f, char *fn);
int getsfile(HWND hwnd, char *f, char *fn, char *dir);
extern int pause;
extern int has_been_inited;