Removed old bitrotted Win32 port.

This commit is contained in:
SarahW 2018-06-04 22:08:38 +01:00
commit e44ca65ad6
24 changed files with 0 additions and 6551 deletions

View file

@ -1,47 +0,0 @@
VPATH = . dosbox resid-fp
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
CFLAGS = -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign -Wall -Werror -fno-strict-aliasing
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acc2036.o acer386sx.o ali1429.o amstrad.o cbm_io.o cdrom-ioctl.o cdrom-image.o \
cmd640.o codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_common.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86.o compaq.o config.o cpu.o \
dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o \
i430vx.o ide.o ide_atapi.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \
keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o laserxt.o lpt.o lpt_dac.o lpt_dss.o mca.o mcr.o mem.o mem_bios.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_msystems.o mouse_ps2.o \
mouse_serial.o neat.o nmi.o nvr.o nvr_tc8521.o olivetti_m24.o opti495.o paths.o pc.o pc87306.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o rtc_tc8521.o \
scat.o scsi.o scsi_53c400.o scsi_aha1540.o scsi_cd.o scsi_hd.o scsi_zip.o serial.o sio.o sis496.o sl82c460.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_audiopci.o sound_cms.o sound_dbopl.o \
sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o \
sound_ym7128.o soundopenal.o t1000.o t3100e.o tandy_eeprom.o tandy_rom.o timer.o um8881f.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
vid_ati28800.o vid_ati68860_ramdac.o vid_cga.o vid_cl5429.o vid_colorplus.o vid_compaq_cga.o vid_ega.o vid_et4000.o \
vid_et4000w32.o vid_et4000w32i.o vid_genius.o vid_hercules.o vid_icd2061.o vid_ics2595.o vid_incolor.o vid_mda.o \
vid_olivetti_m24.o vid_oti037.c 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_t1000.o vid_t3100e.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-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 xi8088.c xtide.o pc.res
DBOBJ = cdrom_image.o dbopl.o nukedopl.o vid_cga_comp.o
SIDOBJ = convolve.o convolve-sse.o envelope.o extfilt.o filter.o pot.o sid.o voice.o wave6581__ST.o wave6581_P_T.o wave6581_PS_.o wave6581_PST.o wave8580__ST.o wave8580_P_T.o wave8580_PS_.o wave8580_PST.o wave.o
LIBS = -mwindows -lwinmm -lopenal32 -lddraw -ldinput -ldxguid -ld3d9 -lstdc++
PCem.exe: $(OBJ) $(DBOBJ) $(SIDOBJ)
$(CC) $(OBJ) $(DBOBJ) $(SIDOBJ) -o "PCem.exe" $(LIBS)
all : PCem.exe
clean :
rm *.o
rm *.exe
rm *.res
%.o : %.c
$(CC) $(CFLAGS) -c $<
%.o : %.cc
$(CPP) $(CFLAGS) -c $<
pc.res: pc.rc
$(WINDRES) -i pc.rc --input-format=rc -o pc.res -O coff

View file

@ -1,51 +0,0 @@
VPATH = . dosbox resid-fp
CPP = g++.exe
CC = gcc.exe
MAKE = make.exe
WINDRES = windres.exe
CFLAGS = -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign -Wall -Werror -fno-strict-aliasing -DUSE_NETWORKING
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acc2036.o acer386sx.o ali1429.o amstrad.o cbm_io.o cdrom-ioctl.o cdrom-image.o \
cmd640.o codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_common.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86.o compaq.o config.o cpu.o \
dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o \
i430vx.o ide.o ide_atapi.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \
keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o laserxt.o lpt.o lpt_dac.o lpt_dss.o mca.o mcr.o mem.o mem_bios.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_msystems.o mouse_ps2.o \
mouse_serial.o neat.o nmi.o nvr.o nvr_tc8521.o olivetti_m24.o opti495.o paths.o pc.o pc87306.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o rtc_tc8521.o \
scat.o scsi.o scsi_53c400.o scsi_aha1540.o scsi_cd.o scsi_hd.o scsi_zip.o serial.o sio.o sis496.o sl82c460.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_audiopci.o sound_cms.o sound_dbopl.o \
sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o \
sound_ym7128.o soundopenal.o t1000.o t3100e.o tandy_eeprom.o tandy_rom.o timer.o um8881f.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
vid_ati28800.o vid_ati68860_ramdac.o vid_cga.o vid_cl5429.o vid_colorplus.o vid_compaq_cga.o vid_ega.o vid_et4000.o \
vid_et4000w32.o vid_et4000w32i.o vid_genius.o vid_hercules.o vid_icd2061.o vid_ics2595.o vid_incolor.o vid_mda.o \
vid_olivetti_m24.o vid_oti037.c 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_t1000.o vid_t3100e.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-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-networkconfig.o win-status.o win-video.o x86seg.o x87.o xi8088.c xtide.o pc.res
DBOBJ = cdrom_image.o dbopl.o nukedopl.o vid_cga_comp.o
SIDOBJ = convolve.o convolve-sse.o envelope.o extfilt.o filter.o pot.o sid.o voice.o wave6581__ST.o wave6581_P_T.o wave6581_PS_.o wave6581_PST.o wave8580__ST.o wave8580_P_T.o wave8580_PS_.o wave8580_PST.o wave.o
NETOBJ = ne2000.o nethandler.o
LIBS = -mwindows -lwinmm -lopenal32 -lddraw -ldinput -ldxguid -ld3d9 -lwsock32 -liphlpapi -lstdc++
PCem.exe: $(OBJ) $(DBOBJ) $(SIDOBJ) $(NETOBJ) libslirp.a
$(CC) $(OBJ) $(DBOBJ) $(SIDOBJ) $(NETOBJ) slirp/libslirp.a -o "PCem.exe" $(LIBS)
libslirp.a:
$(MAKE) -C slirp
all : libslirp.a PCem.exe
clean :
rm *.o
rm *.exe
rm *.res
%.o : %.c
$(CC) $(CFLAGS) -c $<
%.o : %.cc
$(CPP) $(CFLAGS) -c $<
pc.res: pc.rc
$(WINDRES) -i pc.rc --input-format=rc -o pc.res -O coff -D USE_NETWORKING

View file

@ -1,47 +0,0 @@
VPATH = . dosbox resid-fp
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
CFLAGS = -O3 -fomit-frame-pointer -msse2 -Wall -Werror -fno-strict-aliasing
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acc2036.o acer386sx.o ali1429.o amstrad.o cbm_io.o cdrom-ioctl.o cdrom-image.o \
cmd640.o codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_common.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86-64.o compaq.o config.o cpu.o \
dells200.o device.o disc.o disc_fdi.o disc_img.o disc_sector.o dma.o esdi_at.o fdc.o fdc37c665.o fdd.o fdi2raw.o gameport.o hdd.o hdd_esdi.o hdd_file.o headland.o i430lx.o i430fx.o \
i430vx.o ide.o ide_atapi.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \
keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o laserxt.o lpt.o lpt_dac.o lpt_dss.o mca.o mcr.o mem.o mem_bios.o mfm_at.o mfm_xebec.o model.o mouse.o mouse_msystems.o mouse_ps2.o \
mouse_serial.o neat.o nmi.o nvr.o nvr_tc8521.o olivetti_m24.o opti495.o paths.o pc.o pc87306.o pci.o pic.o piix.o pit.o ppi.o ps1.o ps2.o ps2_mca.o ps2_nvr.o rom.o rtc.o rtc_tc8521.o \
scat.o scsi.o scsi_53c400.o scsi_aha1540.o scsi_cd.o scsi_hd.o scsi_zip.o serial.o sio.o sis496.o sl82c460.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_audiopci.o sound_cms.o sound_dbopl.o \
sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o \
soundopenal.o t1000.o t3100e.o tandy_eeprom.o tandy_rom.o timer.o um8881f.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
vid_ati28800.o vid_ati68860_ramdac.o vid_cga.o vid_cl5429.o vid_colorplus.o vid_compaq_cga.o vid_ega.o vid_et4000.o \
vid_et4000w32.o vid_et4000w32i.o vid_genius.o vid_hercules.o vid_icd2061.o vid_ics2595.o vid_incolor.o vid_mda.o \
vid_olivetti_m24.o vid_oti037.c 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_t1000.o vid_t3100e.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-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 xi8088.c xtide.o pc.res
DBOBJ = cdrom_image.o dbopl.o nukedopl.o vid_cga_comp.o
SIDOBJ = convolve.o convolve-sse.o envelope.o extfilt.o filter.o pot.o sid.o voice.o wave6581__ST.o wave6581_P_T.o wave6581_PS_.o wave6581_PST.o wave8580__ST.o wave8580_P_T.o wave8580_PS_.o wave8580_PST.o wave.o
LIBS = -mwindows -lwinmm -lopenal32 -lddraw -ldinput -ldxguid -ld3d9 -lstdc++
PCem64.exe: $(OBJ) $(DBOBJ) $(SIDOBJ)
$(CC) $(OBJ) $(DBOBJ) $(SIDOBJ) -o "PCem64.exe" $(LIBS)
all : PCem64.exe
clean :
rm *.o
rm *.exe
rm *.res
%.o : %.c
$(CC) $(CFLAGS) -c $<
%.o : %.cc
$(CPP) $(CFLAGS) -c $<
pc.res: pc.rc
$(WINDRES) -i pc.rc --input-format=rc -o pc.res -O coff

View file

@ -1,914 +0,0 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include <commctrl.h>
#include "ibm.h"
#include "cpu.h"
#include "device.h"
#include "fdd.h"
#include "gameport.h"
#include "hdd.h"
#include "mem.h"
#include "model.h"
#include "mouse.h"
#include "nvr.h"
#include "resources.h"
#include "sound.h"
#include "video.h"
#include "vid_voodoo.h"
#include "win.h"
#ifdef USE_NETWORKING
#include "nethandler.h"
#endif
extern int is486;
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 settings_mouse_to_list[20], settings_list_to_mouse[20];
#ifdef USE_NETWORKING
static int settings_network_to_list[20], settings_list_to_network[20];
#endif
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))
return 0;
if ((type & MOUSE_TYPE_IF_MASK) == MOUSE_TYPE_AMSTRAD && !(models[model].flags & MODEL_AMSTRAD))
return 0;
if ((type & MOUSE_TYPE_IF_MASK) == MOUSE_TYPE_OLIM24 && !(models[model].flags & MODEL_OLIM24))
return 0;
return 1;
}
static void recalc_vid_list(HWND hdlg, int model)
{
HWND h = GetDlgItem(hdlg, IDC_COMBOVID);
int c = 0, d = 0;
int found_card = 0;
SendMessage(h, CB_RESETCONTENT, 0, 0);
SendMessage(h, CB_SETCURSEL, 0, 0);
while (1)
{
char *s = video_card_getname(c);
if (!s[0])
break;
if (video_card_available(c) && gfx_present[video_new_to_old(c)] &&
((models[model].flags & MODEL_PCI) || !(video_card_getdevice(c)->flags & DEVICE_PCI)))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
if (video_new_to_old(c) == gfxcard)
{
SendMessage(h, CB_SETCURSEL, d, 0);
found_card = 1;
}
d++;
}
c++;
}
if (!found_card)
SendMessage(h, CB_SETCURSEL, 0, 0);
EnableWindow(h, models[model].fixed_gfxcard ? FALSE : TRUE);
h = GetDlgItem(hdlg, IDC_CHECKVOODOO);
EnableWindow(h, (models[model].flags & MODEL_PCI) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_CONFIGUREVOODOO);
EnableWindow(h, (models[model].flags & MODEL_PCI) ? TRUE : FALSE);
}
static void recalc_snd_list(HWND hdlg, int model)
{
HWND h = GetDlgItem(hdlg, IDC_COMBOSND);
int c = 0, d = 0;
SendMessage(h, CB_RESETCONTENT, 0, 0);
while (1)
{
char *s = sound_card_getname(c);
if (!s[0])
break;
settings_sound_to_list[c] = d;
if (sound_card_available(c))
{
device_t *sound_dev = sound_card_getdevice(c);
if (!sound_dev || (sound_dev->flags & DEVICE_MCA) == (models[model].flags & MODEL_MCA))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
settings_list_to_sound[d] = c;
d++;
}
}
c++;
}
SendMessage(h, CB_SETCURSEL, settings_sound_to_list[sound_card_current], 0);
}
#ifdef USE_NETWORKING
static void recalc_net_list(HWND hdlg, int model)
{
HWND h = GetDlgItem(hdlg, IDC_COMBONETCARD);
int c = 0, d = 0;
int set_zero = 0;
SendMessage(h, CB_RESETCONTENT, 0, 0);
while (1)
{
char *s = network_card_getname(c);
if (!s[0])
break;
settings_network_to_list[c] = d;
if (network_card_available(c))
{
device_t *network_dev = network_card_getdevice(c);
if (!network_dev || (network_dev->flags & DEVICE_MCA) == (models[model].flags & MODEL_MCA))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
settings_list_to_network[d] = c;
d++;
}
else if (c == network_card_current)
set_zero = 1;
}
c++;
}
if (set_zero)
SendMessage(h, CB_SETCURSEL, 0, 0);
else
SendMessage(h, CB_SETCURSEL, settings_network_to_list[network_card_current], 0);
}
#endif
static void recalc_hdd_list(HWND hdlg, int model, int use_selected_hdd)
{
HWND h;
h = GetDlgItem(hdlg, IDC_COMBOHDD);
if (models[model].flags & MODEL_HAS_IDE)
{
SendMessage(h, CB_RESETCONTENT, 0, 0);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Internal IDE");
EnableWindow(h, FALSE);
SendMessage(h, CB_SETCURSEL, 0, 0);
}
else
{
char *s;
int valid = 0;
char old_name[16];
int c, d;
if (use_selected_hdd)
{
c = SendMessage(h, CB_GETCURSEL, 0, 0);
if (c != -1 && hdd_names[c])
strncpy(old_name, hdd_names[c], sizeof(old_name)-1);
else
strcpy(old_name, "none");
}
else
strncpy(old_name, hdd_controller_name, sizeof(old_name)-1);
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = d = 0;
while (1)
{
s = hdd_controller_get_name(c);
if (s[0] == 0)
break;
if ((((hdd_controller_get_flags(c) & DEVICE_AT) && !(models[model].flags & MODEL_AT)) ||
(hdd_controller_get_flags(c) & DEVICE_MCA) != (models[model].flags & MODEL_MCA)) && c)
{
c++;
continue;
}
if (!hdd_controller_available(c))
{
c++;
continue;
}
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
hdd_names[d] = hdd_controller_get_internal_name(c);
if (!strcmp(old_name, hdd_names[d]))
{
SendMessage(h, CB_SETCURSEL, d, 0);
valid = 1;
}
c++;
d++;
}
if (!valid)
SendMessage(h, CB_SETCURSEL, 0, 0);
EnableWindow(h, TRUE);
}
}
static BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char temp_str[256];
HWND h;
int c, d;
int gfx, mem, fpu;
int temp_cpu, temp_cpu_m, temp_model;
int temp_GAMEBLASTER, temp_GUS, temp_SSI2001, temp_voodoo, temp_sound_card_current;
int temp_dynarec;
int cpu_flags;
int temp_fda_type, temp_fdb_type;
int temp_joystick_type;
int cpu_type;
int temp_mouse_type;
int hdd_changed = 0;
#ifdef USE_NETWORKING
int temp_network_card;
#endif
UDACCEL accel;
// pclog("Dialog msg %i %08X\n",message,message);
switch (message)
{
case WM_INITDIALOG:
pause = 1;
h = GetDlgItem(hdlg, IDC_COMBO1);
for (c = 0; c < ROM_MAX; c++)
romstolist[c] = 0;
c = d = 0;
while (models[c].id != -1)
{
pclog("INITDIALOG : %i %i %i\n",c,models[c].id,romspresent[models[c].id]);
if (romspresent[models[c].id])
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)models[c].name);
modeltolist[c] = d;
listtomodel[d] = c;
romstolist[models[c].id] = d;
romstomodel[models[c].id] = c;
d++;
}
c++;
}
SendMessage(h, CB_SETCURSEL, modeltolist[model], 0);
recalc_vid_list(hdlg, romstomodel[romset]);
h = GetDlgItem(hdlg, IDC_COMBOCPUM);
c = 0;
while (models[romstomodel[romset]].cpu[c].cpus != NULL && c < 3)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)models[romstomodel[romset]].cpu[c].name);
c++;
}
EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL, cpu_manufacturer, 0);
if (c == 1) EnableWindow(h, FALSE);
else EnableWindow(h, TRUE);
h = GetDlgItem(hdlg, IDC_COMBO3);
c = 0;
while (models[romstomodel[romset]].cpu[cpu_manufacturer].cpus[c].cpu_type != -1)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)models[romstomodel[romset]].cpu[cpu_manufacturer].cpus[c].name);
c++;
}
EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL, cpu, 0);
recalc_snd_list(hdlg, romstomodel[romset]);
h=GetDlgItem(hdlg, IDC_CHECK3);
SendMessage(h, BM_SETCHECK, GAMEBLASTER, 0);
h=GetDlgItem(hdlg, IDC_CHECKGUS);
SendMessage(h, BM_SETCHECK, GUS, 0);
h=GetDlgItem(hdlg, IDC_CHECKSSI);
SendMessage(h, BM_SETCHECK, SSI2001, 0);
h=GetDlgItem(hdlg, IDC_CHECKSYNC);
SendMessage(h, BM_SETCHECK, enable_sync, 0);
h=GetDlgItem(hdlg, IDC_CHECKVOODOO);
SendMessage(h, BM_SETCHECK, voodoo_enabled, 0);
cpu_flags = models[romstomodel[romset]].cpu[cpu_manufacturer].cpus[cpu].cpu_flags;
h=GetDlgItem(hdlg, IDC_CHECKDYNAREC);
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) || (cpu_flags & CPU_REQUIRES_DYNAREC))
EnableWindow(h, FALSE);
else
EnableWindow(h, TRUE);
SendMessage(h, BM_SETCHECK, ((cpu_flags & CPU_SUPPORTS_DYNAREC) && cpu_use_dynarec) || (cpu_flags & CPU_REQUIRES_DYNAREC), 0);
h = GetDlgItem(hdlg, IDC_COMBOSPD);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"8-bit");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Slow 16-bit");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Fast 16-bit");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Slow VLB/PCI");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Mid VLB/PCI");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Fast VLB/PCI");
SendMessage(h, CB_SETCURSEL, video_speed, 0);
h = GetDlgItem(hdlg, IDC_MEMSPIN);
SendMessage(h, UDM_SETBUDDY, (WPARAM)GetDlgItem(hdlg, IDC_MEMTEXT), 0);
SendMessage(h, UDM_SETRANGE, 0, (models[romstomodel[romset]].min_ram << 16) | models[romstomodel[romset]].max_ram);
if (!((models[model].flags & MODEL_AT) && models[model].ram_granularity < 128))
SendMessage(h, UDM_SETPOS, 0, mem_size);
else
SendMessage(h, UDM_SETPOS, 0, mem_size / 1024);
accel.nSec = 0;
accel.nInc = models[model].ram_granularity;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel);
h = GetDlgItem(hdlg, IDC_CONFIGUREMOD);
if (model_getdevice(model))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_CONFIGUREVID);
if (video_card_has_config(video_old_to_new(gfxcard)))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_CONFIGURESND);
if (sound_card_has_config(sound_card_current))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_COMBODRA);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 360k");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 1.2M");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 1.2M Dual RPM");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 720k");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 1.44M");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 1.44M 3-Mode");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 2.88M");
SendMessage(h, CB_SETCURSEL, fdd_get_type(0), 0);
h = GetDlgItem(hdlg, IDC_COMBODRB);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 360k");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 1.2M");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5.25\" 1.2M Dual RPM");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 720k");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 1.44M");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 1.44M 3-Mode");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3.5\" 2.88M");
SendMessage(h, CB_SETCURSEL, fdd_get_type(1), 0);
h = GetDlgItem(hdlg, IDC_TEXT_MB);
if ((models[model].flags & MODEL_AT) && models[model].ram_granularity < 128)
SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"MB");
else
SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"KB");
h = GetDlgItem(hdlg, IDC_COMBOJOY);
c = 0;
while (joystick_get_name(c))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)joystick_get_name(c));
c++;
}
EnableWindow(h, TRUE);
SendMessage(h, CB_SETCURSEL, joystick_type, 0);
h = GetDlgItem(hdlg, IDC_JOY1);
EnableWindow(h, (joystick_get_max_joysticks(joystick_type) >= 1) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_JOY2);
EnableWindow(h, (joystick_get_max_joysticks(joystick_type) >= 2) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_JOY3);
EnableWindow(h, (joystick_get_max_joysticks(joystick_type) >= 3) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_JOY4);
EnableWindow(h, (joystick_get_max_joysticks(joystick_type) >= 4) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_COMBOWS);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"System default");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"0 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"1 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"2 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"3 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"4 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"5 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"6 W/S");
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"7 W/S");
SendMessage(h, CB_SETCURSEL, cpu_waitstates, 0);
cpu_type = models[romstomodel[romset]].cpu[cpu_manufacturer].cpus[cpu].cpu_type;
if (cpu_type >= CPU_286 && cpu_type <= CPU_386DX)
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_COMBOMOUSE);
c = d = 0;
while (1)
{
char *s = mouse_get_name(c);
int type;
if (!s)
break;
type = mouse_get_type(c);
settings_mouse_to_list[c] = d;
if (mouse_valid(type, model))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
settings_list_to_mouse[d] = c;
d++;
}
c++;
}
SendMessage(h, CB_SETCURSEL, settings_mouse_to_list[mouse_type], 0);
recalc_hdd_list(hdlg, romstomodel[romset], 0);
#ifdef USE_NETWORKING
recalc_net_list(hdlg, romstomodel[romset]);
h = GetDlgItem(hdlg, IDC_CONFIGURENETCARD);
if (network_card_has_config(network_card_current))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
#endif
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
h = GetDlgItem(hdlg, IDC_COMBO1);
temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_MEMTEXT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)temp_str);
sscanf(temp_str, "%i", &mem);
mem &= ~(models[temp_model].ram_granularity - 1);
if (mem < models[temp_model].min_ram)
mem = models[temp_model].min_ram;
else if (mem > models[temp_model].max_ram)
mem = models[temp_model].max_ram;
if ((models[temp_model].flags & MODEL_AT) && models[temp_model].ram_granularity < 128)
mem *= 1024;
h = GetDlgItem(hdlg, IDC_COMBOVID);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp_str);
gfx = video_new_to_old(video_card_getid(temp_str));
h = GetDlgItem(hdlg, IDC_COMBOCPUM);
temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBO3);
temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
fpu = (models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type >= CPU_i486DX) ? 1 : 0;
h = GetDlgItem(hdlg, IDC_CHECK3);
temp_GAMEBLASTER = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECKGUS);
temp_GUS = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECKSSI);
temp_SSI2001 = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECKSYNC);
enable_sync = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECKVOODOO);
temp_voodoo = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBOSND);
temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_CHECKDYNAREC);
temp_dynarec = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBODRA);
temp_fda_type = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBODRB);
temp_fdb_type = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBOMOUSE);
temp_mouse_type = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_COMBOHDD);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
if (hdd_names[c])
hdd_changed = strncmp(hdd_names[c], hdd_controller_name, sizeof(hdd_controller_name)-1);
#ifdef USE_NETWORKING
h = GetDlgItem(hdlg, IDC_COMBONETCARD);
temp_network_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)];
#endif
if (temp_model != model || gfx != gfxcard || mem != mem_size ||
fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS ||
temp_SSI2001 != SSI2001 || temp_sound_card_current != sound_card_current ||
temp_voodoo != voodoo_enabled || temp_dynarec != cpu_use_dynarec ||
temp_fda_type != fdd_get_type(0) || temp_fdb_type != fdd_get_type(1) ||
temp_mouse_type != mouse_type || hdd_changed
#ifdef USE_NETWORKING
|| temp_network_card != network_card_current
#endif
)
{
if (!has_been_inited || MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK)
{
savenvr();
model = temp_model;
romset = model_getromset();
gfxcard = gfx;
mem_size = mem;
cpu_manufacturer = temp_cpu_m;
cpu = temp_cpu;
GAMEBLASTER = temp_GAMEBLASTER;
GUS = temp_GUS;
SSI2001 = temp_SSI2001;
sound_card_current = temp_sound_card_current;
voodoo_enabled = temp_voodoo;
cpu_use_dynarec = temp_dynarec;
mouse_type = temp_mouse_type;
#ifdef USE_NETWORKING
network_card_current = temp_network_card;
#endif
fdd_set_type(0, temp_fda_type);
fdd_set_type(1, temp_fdb_type);
if (hdd_names[c])
strncpy(hdd_controller_name, hdd_names[c], sizeof(hdd_controller_name)-1);
else
strcpy(hdd_controller_name, "none");
if (has_been_inited)
{
mem_resize();
loadbios();
resetpchard();
}
}
else
{
EndDialog(hdlg, 0);
pause = 0;
return TRUE;
}
}
h = GetDlgItem(hdlg, IDC_COMBOSPD);
video_speed = SendMessage(h, CB_GETCURSEL, 0, 0);
cpu_manufacturer = temp_cpu_m;
cpu = temp_cpu;
cpu_set();
h = GetDlgItem(hdlg, IDC_COMBOWS);
cpu_waitstates = SendMessage(h, CB_GETCURSEL, 0, 0);
cpu_update_waitstates();
if (has_been_inited)
saveconfig(NULL);
speedchanged();
joystick_type = temp_joystick_type;
gameport_update_joystick_type();
case IDCANCEL:
EndDialog(hdlg, 0);
pause=0;
return TRUE;
case IDC_COMBO1:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
h = GetDlgItem(hdlg,IDC_COMBO1);
temp_model = listtomodel[SendMessage(h,CB_GETCURSEL,0,0)];
/*Rebuild manufacturer list*/
h = GetDlgItem(hdlg, IDC_COMBOCPUM);
temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = 0;
while (models[temp_model].cpu[c].cpus != NULL && c < 3)
{
SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)models[temp_model].cpu[c].name);
c++;
}
if (temp_cpu_m >= c) temp_cpu_m = c - 1;
SendMessage(h, CB_SETCURSEL, temp_cpu_m, 0);
if (c == 1) EnableWindow(h, FALSE);
else EnableWindow(h, TRUE);
/*Rebuild CPU list*/
h = GetDlgItem(hdlg, IDC_COMBO3);
temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = 0;
while (models[temp_model].cpu[temp_cpu_m].cpus[c].cpu_type != -1)
{
SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)models[temp_model].cpu[temp_cpu_m].cpus[c].name);
c++;
}
if (temp_cpu >= c) temp_cpu = c - 1;
SendMessage(h, CB_SETCURSEL, temp_cpu, 0);
h = GetDlgItem(hdlg, IDC_CHECKDYNAREC);
temp_dynarec = SendMessage(h, BM_GETCHECK, 0, 0);
cpu_flags = models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_flags;
h=GetDlgItem(hdlg, IDC_CHECKDYNAREC);
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) || (cpu_flags & CPU_REQUIRES_DYNAREC))
EnableWindow(h, FALSE);
else
EnableWindow(h, TRUE);
SendMessage(h, BM_SETCHECK, ((cpu_flags & CPU_SUPPORTS_DYNAREC) && temp_dynarec) || (cpu_flags & CPU_REQUIRES_DYNAREC), 0);
h = GetDlgItem(hdlg, IDC_TEXT_MB);
if ((models[temp_model].flags & MODEL_AT) && models[temp_model].ram_granularity < 128)
SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"MB");
else
SendMessage(h, WM_SETTEXT, 0, (LPARAM)(LPCSTR)"KB");
h = GetDlgItem(hdlg, IDC_MEMTEXT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)temp_str);
sscanf(temp_str, "%i", &mem);
h = GetDlgItem(hdlg, IDC_MEMSPIN);
SendMessage(h, UDM_SETRANGE, 0, (models[temp_model].min_ram << 16) | models[temp_model].max_ram);
mem &= ~(models[temp_model].ram_granularity - 1);
if (mem < models[temp_model].min_ram)
mem = models[temp_model].min_ram;
else if (mem > models[temp_model].max_ram)
mem = models[temp_model].max_ram;
SendMessage(h, UDM_SETPOS, 0, mem);
accel.nSec = 0;
accel.nInc = models[temp_model].ram_granularity;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel);
h = GetDlgItem(hdlg, IDC_COMBOWS);
cpu_type = models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
if (cpu_type >= CPU_286 && cpu_type <= CPU_386DX)
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_CONFIGUREMOD);
if (model_getdevice(temp_model))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
h = GetDlgItem(hdlg, IDC_COMBOMOUSE);
temp_mouse_type = settings_list_to_mouse[SendMessage(h, CB_GETCURSEL, 0, 0)];
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = d = 0;
while (1)
{
char *s = mouse_get_name(c);
int type;
if (!s)
break;
type = mouse_get_type(c);
settings_mouse_to_list[c] = d;
if (mouse_valid(type, temp_model))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
settings_list_to_mouse[d] = c;
d++;
}
c++;
}
if (mouse_valid(temp_mouse_type, temp_model))
SendMessage(h, CB_SETCURSEL, settings_mouse_to_list[temp_mouse_type], 0);
else
SendMessage(h, CB_SETCURSEL, 0, 0);
recalc_vid_list(hdlg, temp_model);
recalc_hdd_list(hdlg, temp_model, 1);
recalc_snd_list(hdlg, temp_model);
#ifdef USE_NETWORKING
recalc_net_list(hdlg, temp_model);
#endif
}
break;
case IDC_COMBOCPUM:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
h = GetDlgItem(hdlg, IDC_COMBO1);
temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_COMBOCPUM);
temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
/*Rebuild CPU list*/
h=GetDlgItem(hdlg, IDC_COMBO3);
temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
SendMessage(h, CB_RESETCONTENT, 0, 0);
c = 0;
while (models[temp_model].cpu[temp_cpu_m].cpus[c].cpu_type != -1)
{
SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)models[temp_model].cpu[temp_cpu_m].cpus[c].name);
c++;
}
if (temp_cpu >= c) temp_cpu = c - 1;
SendMessage(h, CB_SETCURSEL, temp_cpu, 0);
h = GetDlgItem(hdlg, IDC_CHECKDYNAREC);
temp_dynarec = SendMessage(h, BM_GETCHECK, 0, 0);
cpu_flags = models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_flags;
h=GetDlgItem(hdlg, IDC_CHECKDYNAREC);
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) || (cpu_flags & CPU_REQUIRES_DYNAREC))
EnableWindow(h, FALSE);
else
EnableWindow(h, TRUE);
SendMessage(h, BM_SETCHECK, ((cpu_flags & CPU_SUPPORTS_DYNAREC) && temp_dynarec) || (cpu_flags & CPU_REQUIRES_DYNAREC), 0);
h = GetDlgItem(hdlg, IDC_COMBOWS);
cpu_type = models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
if (cpu_type >= CPU_286 && cpu_type <= CPU_386DX)
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
}
break;
case IDC_COMBO3:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
h = GetDlgItem(hdlg, IDC_COMBO1);
temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_COMBOCPUM);
temp_cpu_m = SendMessage(h, CB_GETCURSEL, 0, 0);
h=GetDlgItem(hdlg, IDC_COMBO3);
temp_cpu = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_CHECKDYNAREC);
temp_dynarec = SendMessage(h, BM_GETCHECK, 0, 0);
cpu_flags = models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_flags;
h=GetDlgItem(hdlg, IDC_CHECKDYNAREC);
if (!(cpu_flags & CPU_SUPPORTS_DYNAREC) || (cpu_flags & CPU_REQUIRES_DYNAREC))
EnableWindow(h, FALSE);
else
EnableWindow(h, TRUE);
SendMessage(h, BM_SETCHECK, ((cpu_flags & CPU_SUPPORTS_DYNAREC) && temp_dynarec) || (cpu_flags & CPU_REQUIRES_DYNAREC), 0);
h = GetDlgItem(hdlg, IDC_COMBOWS);
cpu_type = models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type;
if (cpu_type >= CPU_286 && cpu_type <= CPU_386DX)
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
}
break;
case IDC_CONFIGUREMOD:
h = GetDlgItem(hdlg, IDC_COMBO1);
temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)model_getdevice(temp_model));
break;
case IDC_CONFIGUREVID:
h = GetDlgItem(hdlg, IDC_COMBOVID);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp_str);
deviceconfig_open(hdlg, (void *)video_card_getdevice(video_card_getid(temp_str)));
break;
case IDC_COMBOVID:
h = GetDlgItem(hdlg, IDC_COMBOVID);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp_str);
gfx = video_card_getid(temp_str);
h = GetDlgItem(hdlg, IDC_CONFIGUREVID);
if (video_card_has_config(gfx))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
break;
case IDC_CONFIGURESND:
h = GetDlgItem(hdlg, IDC_COMBOSND);
temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card_current));
break;
case IDC_COMBOSND:
h = GetDlgItem(hdlg, IDC_COMBOSND);
temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_CONFIGURESND);
if (sound_card_has_config(temp_sound_card_current))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
break;
case IDC_CONFIGUREVOODOO:
deviceconfig_open(hdlg, (void *)&voodoo_device);
break;
case IDC_COMBOJOY:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_JOY1);
EnableWindow(h, (joystick_get_max_joysticks(temp_joystick_type) >= 1) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_JOY2);
EnableWindow(h, (joystick_get_max_joysticks(temp_joystick_type) >= 2) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_JOY3);
EnableWindow(h, (joystick_get_max_joysticks(temp_joystick_type) >= 3) ? TRUE : FALSE);
h = GetDlgItem(hdlg, IDC_JOY4);
EnableWindow(h, (joystick_get_max_joysticks(temp_joystick_type) >= 4) ? TRUE : FALSE);
}
break;
case IDC_JOY1:
h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0);
joystickconfig_open(hdlg, 0, temp_joystick_type);
break;
case IDC_JOY2:
h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0);
joystickconfig_open(hdlg, 1, temp_joystick_type);
break;
case IDC_JOY3:
h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0);
joystickconfig_open(hdlg, 2, temp_joystick_type);
break;
case IDC_JOY4:
h = GetDlgItem(hdlg, IDC_COMBOJOY);
temp_joystick_type = SendMessage(h, CB_GETCURSEL, 0, 0);
joystickconfig_open(hdlg, 3, temp_joystick_type);
break;
#ifdef USE_NETWORKING
case IDC_COMBONETCARD:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
h = GetDlgItem(hdlg, IDC_COMBONETCARD);
temp_network_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_CONFIGURENETCARD);
if (network_card_has_config(temp_network_card))
EnableWindow(h, TRUE);
else
EnableWindow(h, FALSE);
}
break;
case IDC_CONFIGURENETCARD:
h = GetDlgItem(hdlg, IDC_COMBONETCARD);
temp_network_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)network_card_getdevice(temp_network_card));
break;
#endif
}
break;
}
return FALSE;
}
void config_open(HWND hwnd)
{
DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, (DLGPROC)config_dlgproc);
}

View file

@ -1,193 +0,0 @@
#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"
#include "paths.h"
static void config_list_update(HWND hdlg)
{
char s[512];
int num, c;
HWND h;
strcpy(s, configs_path);
put_backslash(s);
strcat(s, "*.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, configs_path);
put_backslash(cfg);
strcat(cfg, s);
strcat(cfg, "cfg");
// sprintf(cfg, "%s\\configs\\%scfg", configs_path, 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];
int c;
strcpy(s, configs_path);
put_backslash(s);
strcat(s, "*.cfg");
for (c = 0; c < strlen(s); c++)
{
if (s[c] == '/')
s[c] = '\\';
}
if (!getsfile(hdlg, "Configuration (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0", s, s, "cfg"))
{
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, configs_path);
put_backslash(cfg);
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, configs_path);
put_backslash(cfg);
strcat(cfg, s);
strcat(cfg, "cfg");
pclog("Config name %s\n", cfg);
loadconfig(cfg);
hdconf_open(hdlg);
saveconfig(cfg);
}
return TRUE;
}
#ifdef USE_NETWORKING
case IDC_NETWORK:
networkconfig_open(hdlg);
return TRUE;
#endif
}
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

@ -1,386 +0,0 @@
#include <stdint.h>
#define BITMAP WINDOWS_BITMAP
#include <d3d9.h>
#undef BITMAP
#include "resources.h"
#include "video.h"
#include "win-d3d-fs.h"
#include "win.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void device_force_redraw();
static void d3d_fs_init_objects();
static void d3d_fs_close_objects();
static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
extern "C" void video_blit_complete();
static LPDIRECT3D9 d3d = NULL;
static LPDIRECT3DDEVICE9 d3ddev = NULL;
static LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL;
static LPDIRECT3DTEXTURE9 d3dTexture = NULL;
static D3DPRESENT_PARAMETERS d3dpp;
static HWND d3d_hwnd;
static HWND d3d_device_window;
static int d3d_fs_w, d3d_fs_h;
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
DWORD color;
FLOAT tu, tv;
};
static CUSTOMVERTEX d3d_verts[] =
{
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f},
{ 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f},
{ 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}
};
void d3d_fs_init(HWND h)
{
d3d_fs_w = GetSystemMetrics(SM_CXSCREEN);
d3d_fs_h = GetSystemMetrics(SM_CYSCREEN);
d3d_hwnd = h;
d3d_device_window = CreateWindowEx (
0,
szSubClassName,
"PCem v12",
WS_POPUP,
CW_USEDEFAULT,
CW_USEDEFAULT,
640,
480,
HWND_DESKTOP,
NULL,
NULL,
NULL
);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = d3d_device_window;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = false;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = d3d_fs_w;
d3dpp.BackBufferHeight = d3d_fs_h;
if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev)))
fatal("CreateDevice failed\n");
d3d_fs_init_objects();
video_blit_memtoscreen_func = d3d_fs_blit_memtoscreen;
}
static void d3d_fs_close_objects()
{
if (d3dTexture)
{
d3dTexture->Release();
d3dTexture = NULL;
}
if (v_buffer)
{
v_buffer->Release();
v_buffer = NULL;
}
}
static void d3d_fs_init_objects()
{
D3DLOCKED_RECT dr;
int y;
RECT r;
if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
&v_buffer,
NULL)))
fatal("CreateVertexBuffer failed\n");
if (FAILED(d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL)))
fatal("CreateTexture failed\n");
r.top = r.left = 0;
r.bottom = r.right = 2047;
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
fatal("LockRect failed\n");
for (y = 0; y < 2048; y++)
{
uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch));
memset(p, 0, 2048 * 4);
}
d3dTexture->UnlockRect(0);
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
}
/*void d3d_resize(int x, int y)
{
HRESULT hr;
d3dpp.BackBufferWidth = x;
d3dpp.BackBufferHeight = y;
d3d_reset();
}*/
void d3d_fs_reset()
{
HRESULT hr;
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = d3d_device_window;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = false;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = d3d_fs_w;
d3dpp.BackBufferHeight = d3d_fs_h;
hr = d3ddev->Reset(&d3dpp);
if (hr == D3DERR_DEVICELOST)
return;
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device_force_redraw();
}
void d3d_fs_close()
{
d3d_fs_close_objects();
if (d3ddev)
{
d3ddev->Release();
d3ddev = NULL;
}
if (d3d)
{
d3d->Release();
d3d = NULL;
}
DestroyWindow(d3d_device_window);
}
static void d3d_fs_size(RECT window_rect, double *l, double *t, double *r, double *b, int w, int h)
{
int ratio_w, ratio_h;
switch (video_fullscreen_scale)
{
case FULLSCR_SCALE_FULL:
*l = -0.5;
*t = -0.5;
*r = (window_rect.right - window_rect.left) - 0.5;
*b = (window_rect.bottom - window_rect.top) - 0.5;
break;
case FULLSCR_SCALE_43:
*t = -0.5;
*b = (window_rect.bottom - window_rect.top) - 0.5;
*l = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * 4) / (3 * 2)) - 0.5;
*r = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * 4) / (3 * 2)) - 0.5;
if (*l < -0.5)
{
*l = -0.5;
*r = (window_rect.right - window_rect.left) - 0.5;
*t = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * 3) / (4 * 2)) - 0.5;
*b = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * 3) / (4 * 2)) - 0.5;
}
break;
case FULLSCR_SCALE_SQ:
*t = -0.5;
*b = (window_rect.bottom - window_rect.top) - 0.5;
*l = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * w) / (h * 2)) - 0.5;
*r = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * w) / (h * 2)) - 0.5;
if (*l < -0.5)
{
*l = -0.5;
*r = (window_rect.right - window_rect.left) - 0.5;
*t = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * h) / (w * 2)) - 0.5;
*b = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * h) / (w * 2)) - 0.5;
}
break;
case FULLSCR_SCALE_INT:
ratio_w = (window_rect.right - window_rect.left) / w;
ratio_h = (window_rect.bottom - window_rect.top) / h;
if (ratio_h < ratio_w)
ratio_w = ratio_h;
*l = ((window_rect.right - window_rect.left) / 2) - ((w * ratio_w) / 2) - 0.5;
*r = ((window_rect.right - window_rect.left) / 2) + ((w * ratio_w) / 2) - 0.5;
*t = ((window_rect.bottom - window_rect.top) / 2) - ((h * ratio_w) / 2) - 0.5;
*b = ((window_rect.bottom - window_rect.top) / 2) + ((h * ratio_w) / 2) - 0.5;
break;
}
}
static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
{
HRESULT hr = D3D_OK;
VOID* pVoid;
D3DLOCKED_RECT dr;
RECT window_rect;
int yy;
double l = 0, t = 0, r = 0, b = 0;
if (y1 == y2)
{
video_blit_complete();
return; /*Nothing to do*/
}
if (hr == D3D_OK && !(y1 == 0 && y2 == 0))
{
RECT lock_rect;
lock_rect.top = y1;
lock_rect.left = 0;
lock_rect.bottom = y2;
lock_rect.right = 2047;
hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0);
if (hr == D3D_OK)
{
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
video_blit_complete();
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
}
else
video_blit_complete();
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;
d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0;
d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0;
d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color =
d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color =
d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color =
d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff;
GetClientRect(d3d_device_window, &window_rect);
d3d_fs_size(window_rect, &l, &t, &r, &b, w, h);
d3d_verts[0].x = l;
d3d_verts[0].y = t;
d3d_verts[1].x = r;
d3d_verts[1].y = b;
d3d_verts[2].x = l;
d3d_verts[2].y = b;
d3d_verts[3].x = l;
d3d_verts[3].y = t;
d3d_verts[4].x = r;
d3d_verts[4].y = t;
d3d_verts[5].x = r;
d3d_verts[5].y = b;
d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = r - 40.5;
d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = t + 8.5;
d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = r - 8.5;
d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = t + 14.5;
if (hr == D3D_OK)
hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0);
if (hr == D3D_OK)
memcpy(pVoid, d3d_verts, sizeof(d3d_verts));
if (hr == D3D_OK)
hr = v_buffer->Unlock();
if (hr == D3D_OK)
hr = d3ddev->BeginScene();
if (hr == D3D_OK)
{
if (hr == D3D_OK)
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0, 0);
if (hr == D3D_OK)
hr = d3ddev->SetTexture(0, d3dTexture);
if (hr == D3D_OK)
hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
if (hr == D3D_OK)
hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
if (hr == D3D_OK)
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
if (hr == D3D_OK)
hr = d3ddev->SetTexture(0, NULL);
if (hr == D3D_OK && readflash && vid_disc_indicator)
{
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 6, 2);
readflash = 0;
}
if (hr == D3D_OK)
hr = d3ddev->EndScene();
}
if (hr == D3D_OK)
hr = d3ddev->Present(NULL, NULL, d3d_device_window, NULL);
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
PostMessage(ghwnd, WM_RESETD3D, 0, 0);
}

View file

@ -1,10 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
void d3d_fs_init(HWND h);
void d3d_fs_close();
void d3d_fs_reset();
void d3d_fs_resize(int x, int y);
#ifdef __cplusplus
}
#endif

View file

@ -1,303 +0,0 @@
#include <stdint.h>
#define BITMAP WINDOWS_BITMAP
#include <d3d9.h>
#undef BITMAP
#include "resources.h"
#include "win-d3d.h"
#include "video.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void device_force_redraw();
extern "C" void video_blit_complete();
void d3d_init_objects();
void d3d_close_objects();
void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
static LPDIRECT3D9 d3d = NULL;
static LPDIRECT3DDEVICE9 d3ddev = NULL;
static LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL;
static LPDIRECT3DTEXTURE9 d3dTexture = NULL;
static D3DPRESENT_PARAMETERS d3dpp;
static HWND d3d_hwnd;
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
DWORD color;
FLOAT tu, tv;
};
static CUSTOMVERTEX d3d_verts[] =
{
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f},
{ 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f},
{ 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f},
{ 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f},
{2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f},
{2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}
};
void d3d_init(HWND h)
{
d3d_hwnd = h;
d3d = Direct3DCreate9(D3D_SDK_VERSION);
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = h;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev)))
fatal("CreateDevice failed\n");
d3d_init_objects();
video_blit_memtoscreen_func = d3d_blit_memtoscreen;
}
void d3d_close_objects()
{
if (d3dTexture)
{
d3dTexture->Release();
d3dTexture = NULL;
}
if (v_buffer)
{
v_buffer->Release();
v_buffer = NULL;
}
}
void d3d_init_objects()
{
D3DLOCKED_RECT dr;
int y;
RECT r;
if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
&v_buffer,
NULL)))
fatal("CreateVertexBuffer failed\n");
if (FAILED(d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL)))
fatal("CreateTexture failed\n");
r.top = r.left = 0;
r.bottom = r.right = 2047;
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
fatal("LockRect failed\n");
for (y = 0; y < 2048; y++)
{
uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch));
memset(p, 0, 2048 * 4);
}
d3dTexture->UnlockRect(0);
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
}
void d3d_resize(int x, int y)
{
d3dpp.BackBufferWidth = x;
d3dpp.BackBufferHeight = y;
d3d_reset();
}
void d3d_reset()
{
HRESULT hr;
if (!d3ddev)
return;
memset(&d3dpp, 0, sizeof(d3dpp));
d3dpp.Flags = 0;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = d3d_hwnd;
d3dpp.BackBufferCount = 1;
d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp.MultiSampleQuality = 0;
d3dpp.EnableAutoDepthStencil = false;
d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.Windowed = true;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
hr = d3ddev->Reset(&d3dpp);
if (hr == D3DERR_DEVICELOST)
return;
d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device_force_redraw();
}
void d3d_close()
{
if (d3dTexture)
{
d3dTexture->Release();
d3dTexture = NULL;
}
if (v_buffer)
{
v_buffer->Release();
v_buffer = NULL;
}
if (d3ddev)
{
d3ddev->Release();
d3ddev = NULL;
}
if (d3d)
{
d3d->Release();
d3d = NULL;
}
}
void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
{
HRESULT hr = D3D_OK;
VOID* pVoid;
D3DLOCKED_RECT dr;
RECT r;
int yy;
if (y1 == y2 || h <= 0)
{
video_blit_complete();
return; /*Nothing to do*/
}
r.top = y1;
r.left = 0;
r.bottom = y2;
r.right = 2047;
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (hr == D3D_OK)
{
for (yy = y1; yy < y2; yy++)
{
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
}
video_blit_complete();
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;//0.5 / 2048.0;
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0;
d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0;
d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0;
d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color =
d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color =
d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color =
d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff;
GetClientRect(d3d_hwnd, &r);
d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = -0.5;
d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = -0.5;
d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = (r.right - r.left) - 0.5;
d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = (r.bottom - r.top) - 0.5;
d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = (r.right - r.left) - 40.5;
d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = 8.5;
d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = (r.right - r.left) - 8.5;
d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = 14.5;
if (hr == D3D_OK)
hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // lock the vertex buffer
if (hr == D3D_OK)
memcpy(pVoid, d3d_verts, sizeof(d3d_verts)); // copy the vertices to the locked buffer
if (hr == D3D_OK)
hr = v_buffer->Unlock(); // unlock the vertex buffer
if (hr == D3D_OK)
hr = d3ddev->BeginScene();
if (hr == D3D_OK)
{
if (hr == D3D_OK)
hr = d3ddev->SetTexture(0, d3dTexture);
if (hr == D3D_OK)
hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
if (hr == D3D_OK)
hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));
if (hr == D3D_OK)
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
if (hr == D3D_OK)
hr = d3ddev->SetTexture(0, NULL);
if (hr == D3D_OK && readflash && vid_disc_indicator)
{
hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 6, 2);
readflash = 0;
}
if (hr == D3D_OK)
hr = d3ddev->EndScene();
}
if (hr == D3D_OK)
hr = d3ddev->Present(NULL, NULL, d3d_hwnd, NULL);
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
PostMessage(d3d_hwnd, WM_RESETD3D, 0, 0);
}

View file

@ -1,10 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
void d3d_init(HWND h);
void d3d_close();
void d3d_reset();
void d3d_resize(int x, int y);
#ifdef __cplusplus
}
#endif

View file

@ -1,237 +0,0 @@
#include <stdint.h>
#define BITMAP WINDOWS_BITMAP
#include <ddraw.h>
#undef BITMAP
#include "win-ddraw-fs.h"
#include "video.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void device_force_redraw();
extern "C" void ddraw_fs_init(HWND h);
extern "C" void ddraw_fs_close();
extern "C" void video_blit_complete();
static void ddraw_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
static LPDIRECTDRAW lpdd = NULL;
static LPDIRECTDRAW4 lpdd4 = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_pri = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_back = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_back2 = NULL;
static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL;
static DDSURFACEDESC2 ddsd;
static HWND ddraw_hwnd;
static int ddraw_w, ddraw_h;
void ddraw_fs_init(HWND h)
{
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
fatal("DirectDrawCreate failed\n");
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4)))
fatal("QueryInterface failed\n");
lpdd->Release();
lpdd = NULL;
atexit(ddraw_fs_close);
if (FAILED(lpdd4->SetCooperativeLevel(h, DDSCL_SETFOCUSWINDOW |
DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT)))
fatal("SetCooperativeLevel failed\n");
if (FAILED(lpdd4->SetDisplayMode(ddraw_w, ddraw_h, 32, 0 ,0)))
fatal("SetDisplayMode failed\n");
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount = 1;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_pri, NULL)))
fatal("CreateSurface failed\n");
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpdds_pri->GetAttachedSurface(&ddsd.ddsCaps, &lpdds_back2)))
fatal("CreateSurface back failed\n");
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL)))
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL)))
fatal("CreateSurface back failed\n");
}
pclog("DDRAW_INIT complete\n");
ddraw_hwnd = h;
video_blit_memtoscreen_func = ddraw_fs_blit_memtoscreen;
}
void ddraw_fs_close()
{
if (lpdds_back2)
{
lpdds_back2->Release();
lpdds_back2 = NULL;
}
if (lpdds_back)
{
lpdds_back->Release();
lpdds_back = NULL;
}
if (lpdds_pri)
{
lpdds_pri->Release();
lpdds_pri = NULL;
}
if (lpdd_clipper)
{
lpdd_clipper->Release();
lpdd_clipper = NULL;
}
if (lpdd4)
{
lpdd4->Release();
lpdd4 = NULL;
}
}
static void ddraw_fs_size(RECT window_rect, RECT *r_dest, int w, int h)
{
int ratio_w, ratio_h;
switch (video_fullscreen_scale)
{
case FULLSCR_SCALE_FULL:
r_dest->left = 0;
r_dest->top = 0;
r_dest->right = (window_rect.right - window_rect.left) - 1;
r_dest->bottom = (window_rect.bottom - window_rect.top) - 1;
break;
case FULLSCR_SCALE_43:
r_dest->top = 0;
r_dest->bottom = (window_rect.bottom - window_rect.top) - 1;
r_dest->left = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * 4) / (3 * 2));
r_dest->right = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * 4) / (3 * 2)) - 1;
if (r_dest->left < 0)
{
r_dest->left = 0;
r_dest->right = (window_rect.right - window_rect.left) - 1;
r_dest->top = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * 3) / (4 * 2));
r_dest->bottom = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * 3) / (4 * 2)) - 1;
}
break;
case FULLSCR_SCALE_SQ:
r_dest->top = 0;
r_dest->bottom = (window_rect.bottom - window_rect.top) - 1;
r_dest->left = ((window_rect.right - window_rect.left) / 2) - (((window_rect.bottom - window_rect.top) * w) / (h * 2));
r_dest->right = ((window_rect.right - window_rect.left) / 2) + (((window_rect.bottom - window_rect.top) * w) / (h * 2)) - 1;
if (r_dest->left < 0)
{
r_dest->left = 0;
r_dest->right = (window_rect.right - window_rect.left) - 1;
r_dest->top = ((window_rect.bottom - window_rect.top) / 2) - (((window_rect.right - window_rect.left) * h) / (w * 2));
r_dest->bottom = ((window_rect.bottom - window_rect.top) / 2) + (((window_rect.right - window_rect.left) * h) / (w * 2)) - 1;
}
break;
case FULLSCR_SCALE_INT:
ratio_w = (window_rect.right - window_rect.left) / w;
ratio_h = (window_rect.bottom - window_rect.top) / h;
if (ratio_h < ratio_w)
ratio_w = ratio_h;
r_dest->left = ((window_rect.right - window_rect.left) / 2) - ((w * ratio_w) / 2);
r_dest->right = ((window_rect.right - window_rect.left) / 2) + ((w * ratio_w) / 2) - 1;
r_dest->top = ((window_rect.bottom - window_rect.top) / 2) - ((h * ratio_w) / 2);
r_dest->bottom = ((window_rect.bottom - window_rect.top) / 2) + ((h * ratio_w) / 2) - 1;
break;
}
}
static void ddraw_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
{
RECT r_src;
RECT r_dest;
RECT window_rect;
int yy;
HRESULT hr;
DDBLTFX ddbltfx;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
hr = lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr == DDERR_SURFACELOST)
{
lpdds_back->Restore();
lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
device_force_redraw();
}
if (!ddsd.lpSurface)
{
video_blit_complete();
return;
}
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
video_blit_complete();
lpdds_back->Unlock(NULL);
window_rect.left = 0;
window_rect.top = 0;
window_rect.right = ddraw_w;
window_rect.bottom = ddraw_h;
ddraw_fs_size(window_rect, &r_dest, w, h);
r_src.left = 0;
r_src.top = 0;
r_src.right = w;
r_src.bottom = h;
ddbltfx.dwSize = sizeof(ddbltfx);
ddbltfx.dwFillColor = 0;
lpdds_back2->Blt(&window_rect, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
hr = lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
if (hr == DDERR_SURFACELOST)
{
lpdds_back2->Restore();
lpdds_back2->Blt(&r_dest, lpdds_back, &r_src, DDBLT_WAIT, NULL);
}
if (readflash && vid_disc_indicator)
{
RECT r;
r.left = window_rect.right - 40;
r.right = window_rect.right - 8;
r.top = 8;
r.bottom = 14;
ddbltfx.dwFillColor = 0xffffff;
lpdds_back2->Blt(&r, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx);
}
hr = lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
if (hr == DDERR_SURFACELOST)
{
lpdds_pri->Restore();
lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC);
}
}

View file

@ -1,8 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
void ddraw_fs_init(HWND h);
void ddraw_fs_close();
#ifdef __cplusplus
}
#endif

View file

@ -1,213 +0,0 @@
#include <stdint.h>
#define BITMAP WINDOWS_BITMAP
#include <ddraw.h>
#undef BITMAP
#include "win-ddraw.h"
#include "video.h"
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void device_force_redraw();
extern "C" void ddraw_init(HWND h);
extern "C" void ddraw_close();
extern "C" void video_blit_complete();
static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h);
static LPDIRECTDRAW lpdd = NULL;
static LPDIRECTDRAW4 lpdd4 = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_pri = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_back = NULL;
static LPDIRECTDRAWSURFACE4 lpdds_back2 = NULL;
static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL;
static DDSURFACEDESC2 ddsd;
static HWND ddraw_hwnd;
void ddraw_init(HWND h)
{
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
fatal("DirectDrawCreate failed\n");
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4)))
fatal("QueryInterface failed\n");
lpdd->Release();
lpdd = NULL;
atexit(ddraw_close);
if (FAILED(lpdd4->SetCooperativeLevel(h, DDSCL_NORMAL)))
fatal("SetCooperativeLevel failed\n");
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_pri, NULL)))
fatal("CreateSurface failed\n");
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL)))
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL)))
fatal("CreateSurface back failed\n");
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back2, NULL)))
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back2, NULL)))
fatal("CreateSurface back failed\n");
}
if (FAILED(lpdd4->CreateClipper(0, &lpdd_clipper, NULL)))
fatal("CreateClipper failed\n");
if (FAILED(lpdd_clipper->SetHWnd(0, h)))
fatal("SetHWnd failed\n");
if (FAILED(lpdds_pri->SetClipper(lpdd_clipper)))
fatal("SetClipper failed\n");
pclog("DDRAW_INIT complete\n");
ddraw_hwnd = h;
video_blit_memtoscreen_func = ddraw_blit_memtoscreen;
}
void ddraw_close()
{
if (lpdds_back2)
{
lpdds_back2->Release();
lpdds_back2 = NULL;
}
if (lpdds_back)
{
lpdds_back->Release();
lpdds_back = NULL;
}
if (lpdds_pri)
{
lpdds_pri->Release();
lpdds_pri = NULL;
}
if (lpdd_clipper)
{
lpdd_clipper->Release();
lpdd_clipper = NULL;
}
if (lpdd4)
{
lpdd4->Release();
lpdd4 = NULL;
}
}
static void ddraw_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
{
RECT r_src;
RECT r_dest;
int xx, yy;
POINT po;
uint32_t *p;
HRESULT hr;
// pclog("Blit memtoscreen %i,%i %i %i %i,%i\n", x, y, y1, y2, w, h);
if (h <= 0)
{
video_blit_complete();
return;
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
hr = lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr == DDERR_SURFACELOST)
{
lpdds_back->Restore();
lpdds_back->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
device_force_redraw();
}
if (!ddsd.lpSurface)
{
video_blit_complete();
return;
}
for (yy = y1; yy < y2; yy++)
{
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4);
}
video_blit_complete();
lpdds_back->Unlock(NULL);
po.x = po.y = 0;
ClientToScreen(ddraw_hwnd, &po);
GetClientRect(ddraw_hwnd, &r_dest);
OffsetRect(&r_dest, po.x, po.y);
r_src.left = 0;
r_src.top = 0;
r_src.right = w;
r_src.bottom = h;
hr = lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
if (hr == DDERR_SURFACELOST)
{
lpdds_back2->Restore();
lpdds_back2->Blt(&r_src, lpdds_back, &r_src, DDBLT_WAIT, NULL);
}
if (readflash && vid_disc_indicator)
{
readflash = 0;
hr = lpdds_back2->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (hr == DDERR_SURFACELOST)
{
lpdds_back2->Restore();
lpdds_back2->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
device_force_redraw();
}
if (!ddsd.lpSurface) return;
for (yy = 8; yy < 14; yy++)
{
p = (uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch));
for (xx = (w - 40); xx < (w - 8); xx++)
p[xx] = 0xffffffff;
}
}
lpdds_back2->Unlock(NULL);
// pclog("Blit from %i,%i %i,%i to %i,%i %i,%i\n", r_src.left, r_src.top, r_src.right, r_src.bottom, r_dest.left, r_dest.top, r_dest.right, r_dest.bottom);
hr = lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
if (hr == DDERR_SURFACELOST)
{
lpdds_pri->Restore();
lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL);
}
}

View file

@ -1,9 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
void ddraw_init(HWND h);
void ddraw_close();
#ifdef __cplusplus
}
#endif

View file

@ -1,352 +0,0 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include "ibm.h"
#include "config.h"
#include "device.h"
#include "plat-midi.h"
#include "resources.h"
#include "win.h"
static device_t *config_device;
static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
int id = IDC_CONFIG_BASE;
device_config_t *config = config_device->config;
int c;
while (config->type != -1)
{
device_config_selection_t *selection = config->selection;
HWND h = GetDlgItem(hdlg, id);
int val_int;
int num;
char s[80];
switch (config->type)
{
case CONFIG_BINARY:
val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int);
SendMessage(h, BM_SETCHECK, val_int, 0);
id++;
break;
case CONFIG_SELECTION:
val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int);
c = 0;
while (selection->description[0])
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)selection->description);
if (val_int == selection->value)
SendMessage(h, CB_SETCURSEL, c, 0);
selection++;
c++;
}
id += 2;
break;
case CONFIG_MIDI:
val_int = config_get_int(CFG_MACHINE, NULL, config->name, config->default_int);
num = midi_get_num_devs();
for (c = 0; c < num; c++)
{
midi_get_dev_name(c, s);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
if (val_int == c)
SendMessage(h, CB_SETCURSEL, c, 0);
}
id += 2;
break;
}
config++;
}
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
{
int id = IDC_CONFIG_BASE;
device_config_t *config = config_device->config;
int c;
int changed = 0;
while (config->type != -1)
{
device_config_selection_t *selection = config->selection;
HWND h = GetDlgItem(hdlg, id);
int val_int;
switch (config->type)
{
case CONFIG_BINARY:
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;
id++;
break;
case CONFIG_SELECTION:
val_int = config_get_int(CFG_MACHINE, config_device->name, config->name, config->default_int);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
for (; c > 0; c--)
selection++;
if (val_int != selection->value)
changed = 1;
id += 2;
break;
case CONFIG_MIDI:
val_int = config_get_int(CFG_MACHINE, NULL, config->name, config->default_int);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
if (val_int != c)
changed = 1;
id += 2;
break;
}
config++;
}
if (!changed)
{
EndDialog(hdlg, 0);
return TRUE;
}
if (has_been_inited && MessageBox(NULL, "This will reset PCem!\nOkay to continue?", "PCem", MB_OKCANCEL) != IDOK)
{
EndDialog(hdlg, 0);
return TRUE;
}
id = IDC_CONFIG_BASE;
config = config_device->config;
while (config->type != -1)
{
device_config_selection_t *selection = config->selection;
HWND h = GetDlgItem(hdlg, id);
switch (config->type)
{
case CONFIG_BINARY:
config_set_int(CFG_MACHINE, config_device->name, config->name, SendMessage(h, BM_GETCHECK, 0, 0));
id++;
break;
case CONFIG_SELECTION:
c = SendMessage(h, CB_GETCURSEL, 0, 0);
for (; c > 0; c--)
selection++;
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(CFG_MACHINE, NULL, config->name, c);
id += 2;
break;
}
config++;
}
saveconfig(NULL);
if (has_been_inited)
resetpchard();
EndDialog(hdlg, 0);
return TRUE;
}
case IDCANCEL:
EndDialog(hdlg, 0);
return TRUE;
}
break;
}
return FALSE;
}
void deviceconfig_open(HWND hwnd, device_t *device)
{
device_config_t *config = device->config;
uint16_t *data_block = malloc(16384);
uint16_t *data;
DLGTEMPLATE *dlg = (DLGTEMPLATE *)data_block;
DLGITEMTEMPLATE *item;
int y = 10;
int id = IDC_CONFIG_BASE;
memset(data_block, 0, 4096);
dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU;
dlg->x = 10;
dlg->y = 10;
dlg->cx = 220;
dlg->cy = 70;
data = (uint16_t *)(dlg + 1);
*data++ = 0; /*no menu*/
*data++ = 0; /*predefined dialog box class*/
data += MultiByteToWideChar(CP_ACP, 0, "Device Configuration", -1, data, 50);
*data++ = 8; /*Point*/
data += MultiByteToWideChar(CP_ACP, 0, "MS Sans Serif", -1, data, 50);
if (((uintptr_t)data) & 2)
data++;
while (config->type != -1)
{
switch (config->type)
{
case CONFIG_BINARY:
item = (DLGITEMTEMPLATE *)data;
item->x = 10;
item->y = y;
item->id = id++;
item->cx = 200;
item->cy = 15;
item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; // button class
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; // no creation data
y += 20;
break;
case CONFIG_SELECTION:
case CONFIG_MIDI:
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item->x = 70;
item->y = y;
item->id = id++;
item->cx = 140;
item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; // combo box class
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item->x = 10;
item->y = y;
item->id = id++;
item->cx = 60;
item->cy = 15;
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; // static class
data += MultiByteToWideChar(CP_ACP, 0, config->description, -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
y += 20;
break;
}
if (((uintptr_t)data) & 2)
data++;
config++;
}
dlg->cdit = (id - IDC_CONFIG_BASE) + 2;
// DEFPUSHBUTTON "OK",IDOK,64,232,50,14, WS_TABSTOP
// PUSHBUTTON "Cancel",IDCANCEL,128,232,50,14, WS_TABSTOP
item = (DLGITEMTEMPLATE *)data;
item->x = 20;
item->y = y;
item->cx = 50;
item->cy = 14;
item->id = IDOK; // OK button identifier
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; // button class
data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
item = (DLGITEMTEMPLATE *)data;
item->x = 80;
item->y = y;
item->cx = 50;
item->cy = 14;
item->id = IDCANCEL; // OK button identifier
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; // button class
data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50);
*data++ = 0; // no creation data
dlg->cy = y + 20;
config_device = device;
DialogBoxIndirect(hinstance, dlg, hwnd, (DLGPROC)deviceconfig_dlgproc);
free(data_block);
}

View file

@ -1,934 +0,0 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include "ibm.h"
#include "hdd.h"
#include "ide.h"
#include "resources.h"
#include "win.h"
static struct
{
int cylinders;
int heads;
} hd_types[] =
{
{306, 4}, {615, 4}, {615, 6}, {940, 8},
{940, 6}, {615, 4}, {462, 8}, {733, 5},
{900, 15}, {820, 3}, {855, 5}, {855, 7},
{306, 8}, {733, 7}, {0, 0}, {612, 4},
{977, 5}, {977, 7}, {1024, 7}, {733, 5},
{733, 7}, {733, 5}, {306, 4}, {925, 7},
{925, 9}, {754, 7}, {754, 11}, {699, 7},
{823, 10}, {918, 7}, {1024, 11}, {1024, 15},
{1024, 5}, {612, 2}, {1024, 9}, {1024, 8},
{615, 8}, {987, 3}, {462, 7}, {820, 6},
{977, 5}, {981, 5}, {830, 7}, {830, 10},
{917, 15}, {1224, 15}
};
static int hd_changed = 0;
static char hd_new_name[512];
static int hd_new_spt, hd_new_hpc, hd_new_cyl;
static int hd_new_type;
static int new_cdrom_channel;
static void check_hd_type(off64_t sz)
{
int c;
hd_new_type = 0;
if (hdd_controller_current_is_mfm())
{
for (c = 0; c < 46; c++)
{
if ((hd_types[c].cylinders * hd_types[c].heads * 17 * 512) == sz)
{
hd_new_spt = 17;
hd_new_hpc = hd_types[c].heads;
hd_new_cyl = hd_types[c].cylinders;
hd_new_type = c+1;
return;
}
}
hd_new_spt = 63;
hd_new_hpc = 16;
hd_new_cyl = ((sz / 512) / 16) / 63;
}
else
{
if ((sz % 17) == 0 && sz <= 142606336)
{
hd_new_spt = 17;
if (sz <= 26738688)
hd_new_hpc = 4;
else if ((sz % 3072) == 0 && sz <= 53477376)
hd_new_hpc = 6;
else
{
for (c=5;c<16;c++)
{
if((sz % (c * 512)) == 0 && sz <= 1024*c*17*512) break;
if (c == 5) c++;
}
hd_new_hpc = c;
}
hd_new_cyl = (int)((sz / 512) / hd_new_hpc) / 17;
}
else
{
hd_new_spt = 63;
hd_new_hpc = 16;
hd_new_cyl = ((sz / 512) / 16) / 63;
}
}
}
static void update_hdd_cdrom(HWND hdlg)
{
HWND h;
h = GetDlgItem(hdlg, IDC_CHDD);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 0) ? 0 : 1, 0);
h = GetDlgItem(hdlg, IDC_CCDROM);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 0) ? 1 : 0, 0);
h = GetDlgItem(hdlg, IDC_DHDD);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 1) ? 0 : 1, 0);
h = GetDlgItem(hdlg, IDC_DCDROM);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 1) ? 1 : 0, 0);
h = GetDlgItem(hdlg, IDC_EHDD);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 2) ? 0 : 1, 0);
h = GetDlgItem(hdlg, IDC_ECDROM);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 2) ? 1 : 0, 0);
h = GetDlgItem(hdlg, IDC_FHDD);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 3) ? 0 : 1, 0);
h = GetDlgItem(hdlg, IDC_FCDROM);
SendMessage(h, BM_SETCHECK, (new_cdrom_channel == 3) ? 1 : 0, 0);
}
static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char s[260];
HWND h;
int c;
PcemHDC hd[4];
FILE *f;
uint8_t buf[512];
int hd_type;
switch (message)
{
case WM_INITDIALOG:
h = GetDlgItem(hdlg, IDC_EDIT1);
sprintf(s, "%i", 63);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT2);
sprintf(s, "%i", 16);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT3);
sprintf(s, "%i", 511);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDITC);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)"");
h = GetDlgItem(hdlg, IDC_TEXT1);
sprintf(s, "Size : %imb", (((511*16*63)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
// hd_type = 0;
h = GetDlgItem(hdlg, IDC_HDTYPE);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Custom type");
for (c = 1; c <= 46; c++)
{
sprintf(s, "Type %02i : cylinders=%i, heads=%i, size=%iMB", c, hd_types[c-1].cylinders, hd_types[c-1].heads, (hd_types[c-1].cylinders * hd_types[c-1].heads * 17 * 512) / (1024 * 1024));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
}
SendMessage(h, CB_SETCURSEL, 0, 0);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
h = GetDlgItem(hdlg, IDC_EDITC);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)hd_new_name);
if (!hd_new_name[0])
{
MessageBox(ghwnd,"Please enter a valid filename","PCem error",MB_OK);
return TRUE;
}
h = GetDlgItem(hdlg, IDC_EDIT1);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd_new_spt);
h = GetDlgItem(hdlg, IDC_EDIT2);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd_new_hpc);
h = GetDlgItem(hdlg, IDC_EDIT3);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd_new_cyl);
if (hd_new_spt > 63)
{
MessageBox(ghwnd, "Drive has too many sectors (maximum is 63)", "PCem error", MB_OK);
return TRUE;
}
if (hd_new_hpc > 16)
{
MessageBox(ghwnd, "Drive has too many heads (maximum is 16)", "PCem error", MB_OK);
return TRUE;
}
if (hd_new_cyl > 16383)
{
MessageBox(ghwnd, "Drive has too many cylinders (maximum is 16383)", "PCem error", MB_OK);
return TRUE;
}
f = fopen64(hd_new_name, "wb");
if (!f)
{
MessageBox(ghwnd, "Can't open file for write", "PCem error", MB_OK);
return TRUE;
}
memset(buf, 0, 512);
for (c = 0; c < (hd_new_cyl * hd_new_hpc * hd_new_spt); c++)
fwrite(buf, 512, 1, f);
fclose(f);
MessageBox(ghwnd, "Remember to partition and format the new drive", "PCem", MB_OK);
EndDialog(hdlg, 1);
return TRUE;
case IDCANCEL:
EndDialog(hdlg, 0);
return TRUE;
case IDC_CFILE:
if (!getsfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", "", NULL, "img"))
{
h = GetDlgItem(hdlg, IDC_EDITC);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
}
return TRUE;
case IDC_EDIT1: case IDC_EDIT2: case IDC_EDIT3:
h = GetDlgItem(hdlg, IDC_EDIT1);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
pclog("EDIT1: %s\n", s);
sscanf(s, "%i", &hd[0].spt);
h = GetDlgItem(hdlg, IDC_EDIT2);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
pclog("EDIT2: %s\n", s);
sscanf(s, "%i", &hd[0].hpc);
h = GetDlgItem(hdlg, IDC_EDIT3);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
pclog("EDIT3: %s\n", s);
sscanf(s, "%i", &hd[0].tracks);
h = GetDlgItem(hdlg, IDC_TEXT1);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_type = 0;
for (c = 1; c <= 46; c++)
{
pclog("Compare %i,%i %i,%i %i,%i\n", hd[0].spt,17, hd[0].hpc,hd_types[c-1].heads, hd[0].tracks,hd_types[c-1].cylinders);
if (hd[0].spt == 17 && hd[0].hpc == hd_types[c-1].heads && hd[0].tracks == hd_types[c-1].cylinders)
{
hd_type = c;
break;
}
}
h = GetDlgItem(hdlg, IDC_HDTYPE);
SendMessage(h, CB_SETCURSEL, hd_type, 0);
return TRUE;
case IDC_HDTYPE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
h = GetDlgItem(hdlg, IDC_HDTYPE);
hd_type = SendMessage(h, CB_GETCURSEL, 0, 0);
if (hd_type)
{
h = GetDlgItem(hdlg, IDC_EDIT3);
sprintf(s, "%i", hd_types[hd_type-1].cylinders);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT2);
sprintf(s, "%i", hd_types[hd_type-1].heads);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT1);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)"17");
h = GetDlgItem(hdlg, IDC_TEXT1);
sprintf(s, "Size : %imb", (int)(((uint64_t)hd_types[hd_type-1].cylinders*hd_types[hd_type-1].heads*17*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
}
}
return TRUE;
}
break;
}
return FALSE;
}
BOOL CALLBACK hdsize_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char s[260];
HWND h;
PcemHDC hd[2];
int c;
switch (message)
{
case WM_INITDIALOG:
h = GetDlgItem(hdlg, IDC_HDTYPE);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Custom type");
for (c = 1; c <= 46; c++)
{
sprintf(s, "Type %02i : cylinders=%i, heads=%i, size=%iMB", c, hd_types[c-1].cylinders, hd_types[c-1].heads, (hd_types[c-1].cylinders * hd_types[c-1].heads * 17 * 512) / (1024 * 1024));
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
}
SendMessage(h, CB_SETCURSEL, hd_new_type, 0);
h = GetDlgItem(hdlg, IDC_EDIT1);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT2);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT3);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_TEXT1);
sprintf(s, "Size : %imb", (int)((((uint64_t)hd_new_spt*(uint64_t)hd_new_hpc*(uint64_t)hd_new_cyl)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
h = GetDlgItem(hdlg, IDC_EDIT1);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd_new_spt);
h = GetDlgItem(hdlg, IDC_EDIT2);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd_new_hpc);
h = GetDlgItem(hdlg, IDC_EDIT3);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd_new_cyl);
if (hd_new_spt > 63)
{
MessageBox(ghwnd,"Drive has too many sectors (maximum is 63)","PCem error",MB_OK);
return TRUE;
}
if (hd_new_hpc > 16)
{
MessageBox(ghwnd,"Drive has too many heads (maximum is 16)","PCem error",MB_OK);
return TRUE;
}
if (hd_new_cyl > 16383)
{
MessageBox(ghwnd,"Drive has too many cylinders (maximum is 16383)","PCem error",MB_OK);
return TRUE;
}
EndDialog(hdlg,1);
return TRUE;
case IDCANCEL:
EndDialog(hdlg,0);
return TRUE;
case IDC_EDIT1: case IDC_EDIT2: case IDC_EDIT3:
h = GetDlgItem(hdlg, IDC_EDIT1);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].spt);
h = GetDlgItem(hdlg, IDC_EDIT2);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].hpc);
h = GetDlgItem(hdlg, IDC_EDIT3);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].tracks);
h = GetDlgItem(hdlg, IDC_TEXT1);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
return TRUE;
}
break;
}
return FALSE;
}
static BOOL CALLBACK hdconf_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char s[260];
HWND h;
PcemHDC hd[4];
FILE *f;
off64_t sz;
switch (message)
{
case WM_INITDIALOG:
pause = 1;
hd[0] = hdc[0];
hd[1] = hdc[1];
hd[2] = hdc[2];
hd[3] = hdc[3];
hd_changed = 0;
h = GetDlgItem(hdlg, IDC_EDIT_C_SPT);
sprintf(s, "%i", hdc[0].spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_HPC);
sprintf(s, "%i", hdc[0].hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_CYL);
sprintf(s, "%i", hdc[0].tracks);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[0]);
h = GetDlgItem(hdlg, IDC_EDIT_D_SPT);
sprintf(s, "%i", hdc[1].spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_HPC);
sprintf(s, "%i", hdc[1].hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_CYL);
sprintf(s, "%i", hdc[1].tracks);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h= GetDlgItem(hdlg, IDC_EDIT_D_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[1]);
h = GetDlgItem(hdlg, IDC_EDIT_E_SPT);
sprintf(s, "%i", hdc[2].spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_HPC);
sprintf(s, "%i", hdc[2].hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_CYL);
sprintf(s, "%i", hdc[2].tracks);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h= GetDlgItem(hdlg, IDC_EDIT_E_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[2]);
h = GetDlgItem(hdlg, IDC_EDIT_F_SPT);
sprintf(s, "%i", hdc[3].spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_HPC);
sprintf(s, "%i", hdc[3].hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_CYL);
sprintf(s, "%i", hdc[3].tracks);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h= GetDlgItem(hdlg, IDC_EDIT_F_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)ide_fn[3]);
h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[0].tracks*(uint64_t)hd[0].hpc)*(uint64_t)hd[0].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[1].tracks*(uint64_t)hd[1].hpc)*(uint64_t)hd[1].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[2].tracks*(uint64_t)hd[2].hpc)*(uint64_t)hd[2].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd[3].tracks*(uint64_t)hd[3].hpc)*(uint64_t)hd[3].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
new_cdrom_channel = cdrom_channel;
update_hdd_cdrom(hdlg);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
if (hd_changed || cdrom_channel != new_cdrom_channel)
{
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);
sscanf(s, "%i", &hd[0].spt);
h = GetDlgItem(hdlg, IDC_EDIT_C_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_C_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].tracks);
h = GetDlgItem(hdlg, IDC_EDIT_C_FN);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[0]);
h = GetDlgItem(hdlg, IDC_EDIT_D_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[1].spt);
h = GetDlgItem(hdlg, IDC_EDIT_D_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[1].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_D_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[1].tracks);
h = GetDlgItem(hdlg, IDC_EDIT_D_FN);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[1]);
h = GetDlgItem(hdlg, IDC_EDIT_E_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[2].spt);
h = GetDlgItem(hdlg, IDC_EDIT_E_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[2].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_E_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[2].tracks);
h = GetDlgItem(hdlg, IDC_EDIT_E_FN);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[2]);
h = GetDlgItem(hdlg, IDC_EDIT_F_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[3].spt);
h = GetDlgItem(hdlg, IDC_EDIT_F_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[3].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_F_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[3].tracks);
h = GetDlgItem(hdlg, IDC_EDIT_F_FN);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)ide_fn[3]);
hdc[0] = hd[0];
hdc[1] = hd[1];
hdc[2] = hd[2];
hdc[3] = hd[3];
cdrom_channel = new_cdrom_channel;
if (has_been_inited)
{
saveconfig(NULL);
resetpchard();
}
}
}
case IDCANCEL:
EndDialog(hdlg, 0);
pause = 0;
return TRUE;
case IDC_EJECTC:
hd[0].spt = 0;
hd[0].hpc = 0;
hd[0].tracks = 0;
ide_fn[0][0] = 0;
SetDlgItemText(hdlg, IDC_EDIT_C_SPT, "0");
SetDlgItemText(hdlg, IDC_EDIT_C_HPC, "0");
SetDlgItemText(hdlg, IDC_EDIT_C_CYL, "0");
SetDlgItemText(hdlg, IDC_EDIT_C_FN, "");
hd_changed = 1;
return TRUE;
case IDC_EJECTD:
hd[1].spt = 0;
hd[1].hpc = 0;
hd[1].tracks = 0;
ide_fn[1][0] = 0;
SetDlgItemText(hdlg, IDC_EDIT_D_SPT, "0");
SetDlgItemText(hdlg, IDC_EDIT_D_HPC, "0");
SetDlgItemText(hdlg, IDC_EDIT_D_CYL, "0");
SetDlgItemText(hdlg, IDC_EDIT_D_FN, "");
hd_changed = 1;
return TRUE;
case IDC_EJECTE:
hd[2].spt = 0;
hd[2].hpc = 0;
hd[2].tracks = 0;
ide_fn[2][0] = 0;
SetDlgItemText(hdlg, IDC_EDIT_E_SPT, "0");
SetDlgItemText(hdlg, IDC_EDIT_E_HPC, "0");
SetDlgItemText(hdlg, IDC_EDIT_E_CYL, "0");
SetDlgItemText(hdlg, IDC_EDIT_E_FN, "");
hd_changed = 1;
return TRUE;
case IDC_EJECTF:
hd[3].spt = 0;
hd[3].hpc = 0;
hd[3].tracks = 0;
ide_fn[3][0] = 0;
SetDlgItemText(hdlg, IDC_EDIT_F_SPT, "0");
SetDlgItemText(hdlg, IDC_EDIT_F_HPC, "0");
SetDlgItemText(hdlg, IDC_EDIT_F_CYL, "0");
SetDlgItemText(hdlg, IDC_EDIT_F_FN, "");
hd_changed = 1;
return TRUE;
case IDC_CNEW:
if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdNewDlgMfm") : TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_C_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name);
h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
return TRUE;
case IDC_CFILE:
if (!getfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", ""))
{
f = fopen64(openfilestring, "rb");
if (!f)
{
MessageBox(ghwnd,"Can't open file for read","PCem error",MB_OK);
return TRUE;
}
fseeko64(f, -1, SEEK_END);
sz = ftello64(f) + 1;
fclose(f);
check_hd_type(sz);
if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdSizeDlgMfm") : TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_C_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_C_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
h= GetDlgItem(hdlg, IDC_TEXT_C_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
}
return TRUE;
case IDC_DNEW:
if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdNewDlgMfm") : TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_D_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name);
h= GetDlgItem(hdlg, IDC_TEXT_D_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
return TRUE;
case IDC_DFILE:
if (!getfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", ""))
{
f = fopen64(openfilestring, "rb");
if (!f)
{
MessageBox(ghwnd,"Can't open file for read","PCem error",MB_OK);
return TRUE;
}
fseeko64(f, -1, SEEK_END);
sz = ftello64(f) + 1;
fclose(f);
check_hd_type(sz);
if (DialogBox(hinstance, hdd_controller_current_is_mfm() ? TEXT("HdSizeDlgMfm") : TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_D_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_D_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
}
return TRUE;
case IDC_ENEW:
if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_E_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name);
h= GetDlgItem(hdlg, IDC_TEXT_E_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
return TRUE;
case IDC_EFILE:
if (!getfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", ""))
{
f = fopen64(openfilestring, "rb");
if (!f)
{
MessageBox(ghwnd,"Can't open file for read","PCem error",MB_OK);
return TRUE;
}
fseeko64(f, -1, SEEK_END);
sz = ftello64(f) + 1;
fclose(f);
check_hd_type(sz);
if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_E_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_E_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
}
return TRUE;
case IDC_FNEW:
if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, (DLGPROC)hdnew_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_F_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)hd_new_name);
h= GetDlgItem(hdlg, IDC_TEXT_F_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
return TRUE;
case IDC_FFILE:
if (!getfile(hdlg, "Hard disc image (*.IMG)\0*.IMG\0All files (*.*)\0*.*\0", ""))
{
f = fopen64(openfilestring, "rb");
if (!f)
{
MessageBox(ghwnd,"Can't open file for read","PCem error",MB_OK);
return TRUE;
}
fseeko64(f, -1, SEEK_END);
sz = ftello64(f) + 1;
fclose(f);
check_hd_type(sz);
if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, (DLGPROC)hdsize_dlgproc) == 1)
{
h = GetDlgItem(hdlg, IDC_EDIT_F_SPT);
sprintf(s, "%i", hd_new_spt);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_HPC);
sprintf(s, "%i", hd_new_hpc);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_CYL);
sprintf(s, "%i", hd_new_cyl);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
h = GetDlgItem(hdlg, IDC_EDIT_F_FN);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)openfilestring);
h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE);
sprintf(s, "Size : %imb", (int)(((((uint64_t)hd_new_cyl*(uint64_t)hd_new_hpc)*(uint64_t)hd_new_spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
hd_changed = 1;
}
}
return TRUE;
case IDC_EDIT_C_SPT: case IDC_EDIT_C_HPC: case IDC_EDIT_C_CYL:
h = GetDlgItem(hdlg, IDC_EDIT_C_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].spt);
h = GetDlgItem(hdlg, IDC_EDIT_C_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_C_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[0].tracks);
h = GetDlgItem(hdlg, IDC_TEXT_C_SIZE);
sprintf(s, "Size : %imb", ((((hd[0].tracks*hd[0].hpc)*hd[0].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
return TRUE;
case IDC_EDIT_D_SPT: case IDC_EDIT_D_HPC: case IDC_EDIT_D_CYL:
h = GetDlgItem(hdlg, IDC_EDIT_D_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[1].spt);
h = GetDlgItem(hdlg, IDC_EDIT_D_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[1].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_D_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[1].tracks);
h = GetDlgItem(hdlg, IDC_TEXT_D_SIZE);
sprintf(s, "Size : %imb", ((((hd[1].tracks*hd[1].hpc)*hd[1].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
return TRUE;
case IDC_EDIT_E_SPT: case IDC_EDIT_E_HPC: case IDC_EDIT_E_CYL:
h = GetDlgItem(hdlg, IDC_EDIT_E_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[2].spt);
h = GetDlgItem(hdlg, IDC_EDIT_E_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[2].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_E_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[2].tracks);
h = GetDlgItem(hdlg, IDC_TEXT_E_SIZE);
sprintf(s, "Size : %imb", ((((hd[2].tracks*hd[2].hpc)*hd[2].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
return TRUE;
case IDC_EDIT_F_SPT: case IDC_EDIT_F_HPC: case IDC_EDIT_F_CYL:
h = GetDlgItem(hdlg, IDC_EDIT_F_SPT);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[3].spt);
h = GetDlgItem(hdlg, IDC_EDIT_F_HPC);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[3].hpc);
h = GetDlgItem(hdlg, IDC_EDIT_F_CYL);
SendMessage(h, WM_GETTEXT, 255, (LPARAM)s);
sscanf(s, "%i", &hd[3].tracks);
h = GetDlgItem(hdlg, IDC_TEXT_F_SIZE);
sprintf(s, "Size : %imb", ((((hd[3].tracks*hd[3].hpc)*hd[3].spt)*512)/1024)/1024);
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
return TRUE;
case IDC_CHDD:
if (new_cdrom_channel == 0)
new_cdrom_channel = -1;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_DHDD:
if (new_cdrom_channel == 1)
new_cdrom_channel = -1;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_EHDD:
if (new_cdrom_channel == 2)
new_cdrom_channel = -1;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_FHDD:
if (new_cdrom_channel == 3)
new_cdrom_channel = -1;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_CCDROM:
new_cdrom_channel = 0;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_DCDROM:
new_cdrom_channel = 1;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_ECDROM:
new_cdrom_channel = 2;
update_hdd_cdrom(hdlg);
return TRUE;
case IDC_FCDROM:
new_cdrom_channel = 3;
update_hdd_cdrom(hdlg);
return TRUE;
}
break;
}
return FALSE;
}
void hdconf_open(HWND hwnd)
{
if (hdd_controller_current_is_mfm())
DialogBox(hinstance, TEXT("HdConfDlgMfm"), hwnd, (DLGPROC)hdconf_dlgproc);
else
DialogBox(hinstance, TEXT("HdConfDlg"), hwnd, (DLGPROC)hdconf_dlgproc);
}

View file

@ -1,275 +0,0 @@
#define DIRECTINPUT_VERSION 0x0700
#include <dinput.h>
#include <math.h>
#include <stdint.h>
extern "C" {
#include "device.h"
#include "gameport.h"
}
#include "plat-joystick.h"
#include "win.h"
extern "C" int video_fullscreen;
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void joystick_init();
extern "C" void joystick_close();
extern "C" void poll_joystick();
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
joystick_t joystick_state[MAX_JOYSTICKS];
static LPDIRECTINPUT lpdi;
static LPDIRECTINPUTDEVICE2 lpdi_joystick[2] = {NULL, NULL};
int joysticks_present = 0;
static GUID joystick_guids[MAX_JOYSTICKS];
static BOOL CALLBACK joystick_enum_callback(LPCDIDEVICEINSTANCE lpddi, LPVOID data)
{
if (joysticks_present >= MAX_JOYSTICKS)
return DIENUM_STOP;
pclog("joystick_enum_callback : found joystick %i : %s\n", joysticks_present, lpddi->tszProductName);
joystick_guids[joysticks_present++] = lpddi->guidInstance;
if (joysticks_present >= MAX_JOYSTICKS)
return DIENUM_STOP;
return DIENUM_CONTINUE;
}
BOOL CALLBACK DIEnumDeviceObjectsCallback(
LPCDIDEVICEOBJECTINSTANCE lpddoi,
LPVOID pvRef)
{
plat_joystick_t *state = (plat_joystick_t *)pvRef;
if (lpddoi->guidType == GUID_XAxis || lpddoi->guidType == GUID_YAxis || lpddoi->guidType == GUID_ZAxis ||
lpddoi->guidType == GUID_RxAxis || lpddoi->guidType == GUID_RyAxis || lpddoi->guidType == GUID_RzAxis ||
lpddoi->guidType == GUID_Slider)
{
strncpy(state->axis[state->nr_axes].name, lpddoi->tszName, sizeof(state->axis[state->nr_axes].name));
pclog("Axis %i : %s %x %x\n", state->nr_axes, state->axis[state->nr_axes].name, lpddoi->dwOfs, lpddoi->dwType);
if (lpddoi->guidType == GUID_XAxis)
state->axis[state->nr_axes].id = 0;
else if (lpddoi->guidType == GUID_YAxis)
state->axis[state->nr_axes].id = 1;
else if (lpddoi->guidType == GUID_ZAxis)
state->axis[state->nr_axes].id = 2;
else if (lpddoi->guidType == GUID_RxAxis)
state->axis[state->nr_axes].id = 3;
else if (lpddoi->guidType == GUID_RyAxis)
state->axis[state->nr_axes].id = 4;
else if (lpddoi->guidType == GUID_RzAxis)
state->axis[state->nr_axes].id = 5;
state->nr_axes++;
}
else if (lpddoi->guidType == GUID_Button)
{
strncpy(state->button[state->nr_buttons].name, lpddoi->tszName, sizeof(state->button[state->nr_buttons].name));
pclog("Button %i : %s %x %x\n", state->nr_buttons, state->button[state->nr_buttons].name, lpddoi->dwOfs, lpddoi->dwType);
state->nr_buttons++;
}
else if (lpddoi->guidType == GUID_POV)
{
strncpy(state->pov[state->nr_povs].name, lpddoi->tszName, sizeof(state->pov[state->nr_povs].name));
pclog("POV %i : %s %x %x\n", state->nr_povs, state->pov[state->nr_povs].name, lpddoi->dwOfs, lpddoi->dwType);
state->nr_povs++;
}
return DIENUM_CONTINUE;
}
void joystick_init()
{
int c;
atexit(joystick_close);
joysticks_present = 0;
if (FAILED(DirectInputCreate(hinstance, DIRECTINPUT_VERSION, &lpdi, NULL)))
fatal("joystick_init : DirectInputCreate failed\n");
if (FAILED(lpdi->EnumDevices(DIDEVTYPE_JOYSTICK, joystick_enum_callback, NULL, DIEDFL_ATTACHEDONLY)))
fatal("joystick_init : EnumDevices failed\n");
pclog("joystick_init: joysticks_present=%i\n", joysticks_present);
for (c = 0; c < joysticks_present; c++)
{
LPDIRECTINPUTDEVICE lpdi_joystick_temp = NULL;
DIPROPRANGE joy_axis_range;
DIDEVICEINSTANCE device_instance;
DIDEVCAPS devcaps;
if (FAILED(lpdi->CreateDevice(joystick_guids[c], &lpdi_joystick_temp, NULL)))
fatal("joystick_init : CreateDevice failed\n");
if (FAILED(lpdi_joystick_temp->QueryInterface(IID_IDirectInputDevice2, (void **)&lpdi_joystick[c])))
fatal("joystick_init : CreateDevice failed\n");
lpdi_joystick_temp->Release();
memset(&device_instance, 0, sizeof(device_instance));
device_instance.dwSize = sizeof(device_instance);
if (FAILED(lpdi_joystick[c]->GetDeviceInfo(&device_instance)))
fatal("joystick_init : GetDeviceInfo failed\n");
pclog("Joystick %i :\n", c);
pclog(" tszInstanceName = %s\n", device_instance.tszInstanceName);
pclog(" tszProductName = %s\n", device_instance.tszProductName);
strncpy(plat_joystick_state[c].name, device_instance.tszInstanceName, 64);
memset(&devcaps, 0, sizeof(devcaps));
devcaps.dwSize = sizeof(devcaps);
if (FAILED(lpdi_joystick[c]->GetCapabilities(&devcaps)))
fatal("joystick_init : GetCapabilities failed\n");
pclog(" Axes = %i\n", devcaps.dwAxes);
pclog(" Buttons = %i\n", devcaps.dwButtons);
pclog(" POVs = %i\n", devcaps.dwPOVs);
lpdi_joystick[c]->EnumObjects(DIEnumDeviceObjectsCallback, &plat_joystick_state[c], DIDFT_ALL);
if (FAILED(lpdi_joystick[c]->SetCooperativeLevel(ghwnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
fatal("joystick_init : SetCooperativeLevel failed\n");
if (FAILED(lpdi_joystick[c]->SetDataFormat(&c_dfDIJoystick)))
fatal("joystick_init : SetDataFormat failed\n");
joy_axis_range.lMin = -32768;
joy_axis_range.lMax = 32767;
joy_axis_range.diph.dwSize = sizeof(DIPROPRANGE);
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
joy_axis_range.diph.dwHow = DIPH_BYOFFSET;
joy_axis_range.diph.dwObj = DIJOFS_X;
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
joy_axis_range.diph.dwObj = DIJOFS_Y;
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
joy_axis_range.diph.dwObj = DIJOFS_Z;
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
joy_axis_range.diph.dwObj = DIJOFS_RX;
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
joy_axis_range.diph.dwObj = DIJOFS_RY;
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
joy_axis_range.diph.dwObj = DIJOFS_RZ;
lpdi_joystick[c]->SetProperty(DIPROP_RANGE, &joy_axis_range.diph);
if (FAILED(lpdi_joystick[c]->Acquire()))
fatal("joystick_init : Acquire failed\n");
}
}
void joystick_close()
{
if (lpdi_joystick[1])
{
lpdi_joystick[1]->Release();
lpdi_joystick[1] = NULL;
}
if (lpdi_joystick[0])
{
lpdi_joystick[0]->Release();
lpdi_joystick[0] = NULL;
}
}
static int joystick_get_axis(int joystick_nr, int mapping)
{
if (mapping & POV_X)
{
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
if (LOWORD(pov) == 0xFFFF)
return 0;
else
return sin((2*M_PI * (double)pov) / 36000.0) * 32767;
}
else if (mapping & POV_Y)
{
int pov = plat_joystick_state[joystick_nr].p[mapping & 3];
if (LOWORD(pov) == 0xFFFF)
return 0;
else
return -cos((2*M_PI * (double)pov) / 36000.0) * 32767;
}
else
return plat_joystick_state[joystick_nr].a[plat_joystick_state[joystick_nr].axis[mapping].id];
}
void joystick_poll()
{
int c, d;
for (c = 0; c < joysticks_present; c++)
{
DIJOYSTATE joystate;
int b;
if (FAILED(lpdi_joystick[c]->Poll()))
{
lpdi_joystick[c]->Acquire();
lpdi_joystick[c]->Poll();
}
if (FAILED(lpdi_joystick[c]->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&joystate)))
{
lpdi_joystick[c]->Acquire();
lpdi_joystick[c]->Poll();
lpdi_joystick[c]->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)&joystate);
}
plat_joystick_state[c].a[0] = joystate.lX;
plat_joystick_state[c].a[1] = joystate.lY;
plat_joystick_state[c].a[2] = joystate.lZ;
plat_joystick_state[c].a[3] = joystate.lRx;
plat_joystick_state[c].a[4] = joystate.lRy;
plat_joystick_state[c].a[5] = joystate.lRz;
for (b = 0; b < 16; b++)
plat_joystick_state[c].b[b] = joystate.rgbButtons[b] & 0x80;
for (b = 0; b < 4; b++)
plat_joystick_state[c].p[b] = joystate.rgdwPOV[b];
// pclog("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", c, joystick_state[c].x, joystick_state[c].y, joystick_state[c].b[0], joystick_state[c].b[1], joysticks_present);
}
for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++)
{
if (joystick_state[c].plat_joystick_nr)
{
int joystick_nr = joystick_state[c].plat_joystick_nr - 1;
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
joystick_state[c].axis[d] = joystick_get_axis(joystick_nr, joystick_state[c].axis_mapping[d]);
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
joystick_state[c].button[d] = plat_joystick_state[joystick_nr].b[joystick_state[c].button_mapping[d]];
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
{
int x, y;
double angle, magnitude;
x = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][0]);
y = joystick_get_axis(joystick_nr, joystick_state[c].pov_mapping[d][1]);
angle = (atan2((double)y, (double)x) * 360.0) / (2*M_PI);
magnitude = sqrt((double)x*(double)x + (double)y*(double)y);
if (magnitude < 16384)
joystick_state[c].pov[d] = -1;
else
joystick_state[c].pov[d] = ((int)angle + 90 + 360) % 360;
}
}
else
{
for (d = 0; d < joystick_get_axis_count(joystick_type); d++)
joystick_state[c].axis[d] = 0;
for (d = 0; d < joystick_get_button_count(joystick_type); d++)
joystick_state[c].button[d] = 0;
for (d = 0; d < joystick_get_pov_count(joystick_type); d++)
joystick_state[c].pov[d] = -1;
}
}
}

View file

@ -1,541 +0,0 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include "ibm.h"
#include "config.h"
#include "device.h"
#include "gameport.h"
#include "plat-joystick.h"
#include "resources.h"
#include "win.h"
static int joystick_nr;
static int joystick_config_type;
#define AXIS_STRINGS_MAX 3
static char *axis_strings[AXIS_STRINGS_MAX] = {"X Axis", "Y Axis", "Z Axis"};
static void rebuild_axis_button_selections(HWND hdlg)
{
int id = IDC_CONFIG_BASE + 2;
HWND h;
int joystick;
int c, d;
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
joystick = SendMessage(h, CB_GETCURSEL, 0, 0);
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
{
int sel = c;
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_RESETCONTENT, 0, 0);
if (joystick)
{
for (d = 0; d < plat_joystick_state[joystick-1].nr_axes; d++)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].axis[d].name);
if (c < AXIS_STRINGS_MAX)
{
if (!stricmp(axis_strings[c], plat_joystick_state[joystick-1].axis[d].name))
sel = d;
}
}
for (d = 0; d < plat_joystick_state[joystick-1].nr_povs; d++)
{
char s[80];
sprintf(s, "%s (X axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
}
SendMessage(h, CB_SETCURSEL, sel, 0);
EnableWindow(h, TRUE);
}
else
EnableWindow(h, FALSE);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_RESETCONTENT, 0, 0);
if (joystick)
{
for (d = 0; d < plat_joystick_state[joystick-1].nr_buttons; d++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].button[d].name);
SendMessage(h, CB_SETCURSEL, c, 0);
EnableWindow(h, TRUE);
}
else
EnableWindow(h, FALSE);
id += 2;
}
for (c = 0; c < joystick_get_pov_count(joystick_config_type)*2; c++)
{
int sel = c;
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_RESETCONTENT, 0, 0);
if (joystick)
{
for (d = 0; d < plat_joystick_state[joystick-1].nr_povs; d++)
{
char s[80];
sprintf(s, "%s (X axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
sprintf(s, "%s (Y axis)", plat_joystick_state[joystick-1].pov[d].name);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
}
for (d = 0; d < plat_joystick_state[joystick-1].nr_axes; d++)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[joystick-1].axis[d].name);
}
SendMessage(h, CB_SETCURSEL, sel, 0);
EnableWindow(h, TRUE);
}
else
EnableWindow(h, FALSE);
id += 2;
}
}
static int get_axis(HWND hdlg, int id)
{
HWND h = GetDlgItem(hdlg, id);
int axis_sel = SendMessage(h, CB_GETCURSEL, 0, 0);
int nr_axes = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr-1].nr_axes;
if (axis_sel < nr_axes)
return axis_sel;
axis_sel -= nr_axes;
if (axis_sel & 1)
return POV_Y | (axis_sel >> 1);
else
return POV_X | (axis_sel >> 1);
}
static int get_pov(HWND hdlg, int id)
{
HWND h = GetDlgItem(hdlg, id);
int axis_sel = SendMessage(h, CB_GETCURSEL, 0, 0);
int nr_povs = plat_joystick_state[joystick_state[joystick_nr].plat_joystick_nr-1].nr_povs*2;
if (axis_sel < nr_povs)
{
if (axis_sel & 1)
return POV_Y | (axis_sel >> 1);
else
return POV_X | (axis_sel >> 1);
}
return axis_sel - nr_povs;
}
static BOOL CALLBACK joystickconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
HWND h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
int c;
int id = IDC_CONFIG_BASE + 2;
int joystick = joystick_state[joystick_nr].plat_joystick_nr;
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
for (c = 0; c < joysticks_present; c++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[c].name);
SendMessage(h, CB_SETCURSEL, joystick, 0);
rebuild_axis_button_selections(hdlg);
if (joystick_state[joystick_nr].plat_joystick_nr)
{
int nr_axes = plat_joystick_state[joystick-1].nr_axes;
int nr_povs = plat_joystick_state[joystick-1].nr_povs;
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
{
int mapping = joystick_state[joystick_nr].axis_mapping[c];
h = GetDlgItem(hdlg, id);
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping, 0);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_SETCURSEL, joystick_state[joystick_nr].button_mapping[c], 0);
id += 2;
}
for (c = 0; c < joystick_get_pov_count(joystick_config_type); c++)
{
int mapping;
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][0];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
id += 2;
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][1];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
id += 2;
}
}
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_CONFIG_BASE:
if (HIWORD(wParam) == CBN_SELCHANGE)
rebuild_axis_button_selections(hdlg);
break;
case IDOK:
{
HWND h;
int c;
int id = IDC_CONFIG_BASE + 2;
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
joystick_state[joystick_nr].plat_joystick_nr = SendMessage(h, CB_GETCURSEL, 0, 0);
if (joystick_state[joystick_nr].plat_joystick_nr)
{
for (c = 0; c < joystick_get_axis_count(joystick_config_type); c++)
{
joystick_state[joystick_nr].axis_mapping[c] = get_axis(hdlg, id);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
h = GetDlgItem(hdlg, id);
joystick_state[joystick_nr].button_mapping[c] = SendMessage(h, CB_GETCURSEL, 0, 0);
id += 2;
}
for (c = 0; c < joystick_get_button_count(joystick_config_type); c++)
{
h = GetDlgItem(hdlg, id);
joystick_state[joystick_nr].pov_mapping[c][0] = get_pov(hdlg, id);
id += 2;
h = GetDlgItem(hdlg, id);
joystick_state[joystick_nr].pov_mapping[c][1] = get_pov(hdlg, id);
id += 2;
}
}
}
case IDCANCEL:
EndDialog(hdlg, 0);
return TRUE;
}
break;
}
return FALSE;
}
void joystickconfig_open(HWND hwnd, int joy_nr, int type)
{
// device_config_t *config = device->config;
uint16_t *data_block = malloc(16384);
uint16_t *data;
DLGTEMPLATE *dlg = (DLGTEMPLATE *)data_block;
DLGITEMTEMPLATE *item;
int y = 10;
int id = IDC_CONFIG_BASE;
int c;
joystick_nr = joy_nr;
joystick_config_type = type;
memset(data_block, 0, 4096);
dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU;
dlg->x = 10;
dlg->y = 10;
dlg->cx = 220;
dlg->cy = 70;
data = (uint16_t *)(dlg + 1);
*data++ = 0; /*no menu*/
*data++ = 0; /*predefined dialog box class*/
data += MultiByteToWideChar(CP_ACP, 0, "Device Configuration", -1, data, 50);
*data++ = 8; /*Point*/
data += MultiByteToWideChar(CP_ACP, 0, "MS Sans Serif", -1, data, 50);
if (((uintptr_t)data) & 2)
data++;
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item->x = 70;
item->y = y;
item->id = id++;
item->cx = 140;
item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; // combo box class
data += MultiByteToWideChar(CP_ACP, 0, "Device", -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item->x = 10;
item->y = y;
item->id = id++;
item->cx = 60;
item->cy = 15;
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; // static class
data += MultiByteToWideChar(CP_ACP, 0, "Device :", -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
y += 20;
for (c = 0; c < joystick_get_axis_count(type); c++)
{
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item->x = 70;
item->y = y;
item->id = id++;
item->cx = 140;
item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; // combo box class
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item->x = 10;
item->y = y;
item->id = id++;
item->cx = 60;
item->cy = 15;
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; // static class
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_axis_name(type, c), -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
y += 20;
}
for (c = 0; c < joystick_get_button_count(type); c++)
{
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item->x = 70;
item->y = y;
item->id = id++;
item->cx = 140;
item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; // combo box class
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item->x = 10;
item->y = y;
item->id = id++;
item->cx = 60;
item->cy = 15;
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; // static class
data += MultiByteToWideChar(CP_ACP, 0, joystick_get_button_name(type, c), -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
y += 20;
}
for (c = 0; c < joystick_get_pov_count(type)*2; c++)
{
char s[80];
/*Combo box*/
item = (DLGITEMTEMPLATE *)data;
item->x = 70;
item->y = y;
item->id = id++;
item->cx = 140;
item->cy = 150;
item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0085; // combo box class
if (c & 1)
sprintf(s, "%s (Y axis)", joystick_get_pov_name(type, c/2));
else
sprintf(s, "%s (X axis)", joystick_get_pov_name(type, c/2));
data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
/*Static text*/
item = (DLGITEMTEMPLATE *)data;
item->x = 10;
item->y = y;
item->id = id++;
item->cx = 60;
item->cy = 15;
item->style = WS_CHILD | WS_VISIBLE;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0082; // static class
data += MultiByteToWideChar(CP_ACP, 0, s, -1, data, 256);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
y += 20;
}
dlg->cdit = (id - IDC_CONFIG_BASE) + 2;
// DEFPUSHBUTTON "OK",IDOK,64,232,50,14, WS_TABSTOP
// PUSHBUTTON "Cancel",IDCANCEL,128,232,50,14, WS_TABSTOP
item = (DLGITEMTEMPLATE *)data;
item->x = 20;
item->y = y;
item->cx = 50;
item->cy = 14;
item->id = IDOK; // OK button identifier
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; // button class
data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50);
*data++ = 0; // no creation data
if (((uintptr_t)data) & 2)
data++;
item = (DLGITEMTEMPLATE *)data;
item->x = 80;
item->y = y;
item->cx = 50;
item->cy = 14;
item->id = IDCANCEL; // OK button identifier
item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON;
data = (uint16_t *)(item + 1);
*data++ = 0xFFFF;
*data++ = 0x0080; // button class
data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50);
*data++ = 0; // no creation data
dlg->cy = y + 20;
// config_device = device;
DialogBoxIndirect(hinstance, dlg, hwnd, (DLGPROC)joystickconfig_dlgproc);
free(data_block);
}

View file

@ -1,47 +0,0 @@
#define UNICODE
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#undef BITMAP
#include "plat-keyboard.h"
#include "win.h"
#include "video.h"
extern "C" int pcem_key[272];
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void keyboard_init();
extern "C" void keyboard_close();
extern "C" void keyboard_poll();
int pcem_key[272];
void keyboard_init()
{
atexit(keyboard_close);
memset(pcem_key, 0, sizeof(pcem_key));
pclog("Keyboard initialized!\n");
}
void keyboard_close()
{
}
void keyboard_poll_host()
{
int c;
for (c = 0; c < 272; c++)
pcem_key[c] = rawinputkey[c];
if ((rawinputkey[0x1D] || rawinputkey[0x9D]) &&
(rawinputkey[0x38] || rawinputkey[0xB8]) &&
(rawinputkey[0x51] || rawinputkey[0xD1]) &&
video_fullscreen)
leave_fullscreen();
}

View file

@ -1,70 +0,0 @@
#define DIRECTINPUT_VERSION 0x0700
#include <dinput.h>
#include "plat-mouse.h"
#include "win.h"
extern "C" int video_fullscreen;
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void mouse_init();
extern "C" void mouse_close();
extern "C" void mouse_poll_host();
extern "C" void mouse_get_mickeys(int *x, int *y, int *z);
static LPDIRECTINPUT lpdi;
static LPDIRECTINPUTDEVICE lpdi_mouse = NULL;
static DIMOUSESTATE mousestate;
static int mouse_x = 0, mouse_y = 0, mouse_z = 0;
int mouse_buttons = 0;
void mouse_init()
{
if (FAILED(DirectInputCreate(hinstance, DIRECTINPUT_VERSION, &lpdi, NULL)))
fatal("mouse_init : DirectInputCreate failed\n");
if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &lpdi_mouse, NULL)))
fatal("mouse_init : CreateDevice failed\n");
if (FAILED(lpdi_mouse->SetCooperativeLevel(ghwnd, DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE))))
fatal("mouse_init : SetCooperativeLevel failed\n");
if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse)))
fatal("mouse_init : SetDataFormat failed\n");
}
void mouse_close()
{
if (lpdi_mouse)
{
lpdi_mouse->Release();
lpdi_mouse = NULL;
}
}
void mouse_poll_host()
{
if (FAILED(lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate)))
{
lpdi_mouse->Acquire();
lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate);
}
mouse_buttons = 0;
if (mousestate.rgbButtons[0] & 0x80)
mouse_buttons |= 1;
if (mousestate.rgbButtons[1] & 0x80)
mouse_buttons |= 2;
if (mousestate.rgbButtons[2] & 0x80)
mouse_buttons |= 4;
mouse_x += mousestate.lX;
mouse_y += mousestate.lY;
mouse_z += mousestate.lZ/120;
if (!mousecapture && !video_fullscreen)
mouse_x = mouse_y = mouse_z = mouse_buttons = 0;
}
void mouse_get_mickeys(int *x, int *y, int *z)
{
*x = mouse_x;
*y = mouse_y;
*z = mouse_z;
mouse_x = mouse_y = mouse_z = 0;
}

View file

@ -1,213 +0,0 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include <commctrl.h>
#include <pcap.h>
#include "ibm.h"
#include "config.h"
#include "nethandler.h"
#include "resources.h"
#include "win.h"
static HINSTANCE net_hLib = 0;
static char *net_lib_name = "wpcap.dll";
static pcap_if_t *alldevs;
static char *dev_name[20];
int (*_pcap_findalldevs)(pcap_if_t **, char *);
void (*_pcap_freealldevs)(pcap_if_t *);
pcap_t *(*_pcap_open_live)(const char *, int, int, int, char *);
int (*_pcap_datalink)(pcap_t *);
void (*_pcap_close)(pcap_t *);
#define ETH_DEV_NAME_MAX 256 /* maximum device name size */
#define ETH_DEV_DESC_MAX 256 /* maximum device description size */
#define ETH_MAX_DEVICE 30 /* maximum ethernet devices */
#define ETH_PROMISC 1 /* promiscuous mode = true */
#define ETH_MAX_PACKET 1514 /* maximum ethernet packet size */
#define PCAP_READ_TIMEOUT -1
static int get_network_name(char *dev_name, char *regval)
{
if (dev_name[strlen( "\\Device\\NPF_" )] == '{')
{
char regkey[2048];
HKEY reghnd;
sprintf(regkey, "SYSTEM\\CurrentControlSet\\Control\\Network\\"
"{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", dev_name+
strlen("\\Device\\NPF_"));
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, regkey, 0, KEY_QUERY_VALUE, &reghnd) == ERROR_SUCCESS)
{
DWORD reglen = 2048;
DWORD regtype;
if (RegQueryValueExA(reghnd, "Name", NULL, &regtype, (LPBYTE)regval, &reglen) == ERROR_SUCCESS)
{
RegCloseKey (reghnd);
if ((regtype != REG_SZ) || (reglen > 2048))
return -1;
/*Name now in regval*/
return 0;
}
RegCloseKey (reghnd);
}
}
return -1;
}
static BOOL CALLBACK networkconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND h;
pcap_if_t *dev;
char errbuf[PCAP_ERRBUF_SIZE];
int type;
switch (message)
{
case WM_INITDIALOG:
h = GetDlgItem(hdlg, IDC_COMBONETTYPE);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"SLiRP");
SendMessage(h, CB_SETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBONETDEVICE);
SendMessage(h, CB_SETCURSEL, 0, 0);
EnableWindow(h, FALSE);
net_hLib = LoadLibraryA(net_lib_name);
if (net_hLib)
{
int c = 0;
int match = 0;
_pcap_findalldevs = (void *)GetProcAddress(net_hLib, "pcap_findalldevs");
_pcap_freealldevs = (void *)GetProcAddress(net_hLib, "pcap_freealldevs");
_pcap_open_live = (void *)GetProcAddress(net_hLib, "pcap_open_live");
_pcap_datalink = (void *)GetProcAddress(net_hLib, "pcap_datalink");
_pcap_close = (void *)GetProcAddress(net_hLib, "pcap_close");
if (_pcap_findalldevs(&alldevs, errbuf) != -1)
{
char *pcap_device = config_get_string(CFG_GLOBAL, NULL, "pcap_device", "nothing");
h = GetDlgItem(hdlg, IDC_COMBONETDEVICE);
for (dev = alldevs; dev; dev = dev->next)
{
pcap_t *conn = _pcap_open_live(dev->name, ETH_MAX_PACKET, ETH_PROMISC, PCAP_READ_TIMEOUT, errbuf);
int datalink;
if (conn)
{
datalink = _pcap_datalink(conn);
_pcap_close(conn);
}
if (conn && datalink == DLT_EN10MB)
{
char desc[2048];
char s[2048];
if ((dev->flags & PCAP_IF_LOOPBACK) || (!strcmp("any", dev->name)))
continue;
if (pcap_device)
{
if (!strcmp(pcap_device, dev->name))
match = c;
}
dev_name[c++] = dev->name;
if (get_network_name(dev->name, desc))
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)dev->name);
else
{
sprintf(s, "%s - %s", dev->name, desc);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
}
}
}
}
if (c)
{
h = GetDlgItem(hdlg, IDC_COMBONETTYPE);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"PCAP");
if (config_get_int(CFG_GLOBAL, NULL, "net_type", NET_SLIRP) == NET_PCAP)
{
SendMessage(h, CB_SETCURSEL, 1, 0);
h = GetDlgItem(hdlg, IDC_COMBONETDEVICE);
SendMessage(h, CB_SETCURSEL, match, 0);
EnableWindow(h, TRUE);
}
}
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
h = GetDlgItem(hdlg, IDC_COMBONETTYPE);
type = SendMessage(h, CB_GETCURSEL, 0, 0);
if (type) /*PCAP*/
{
int dev;
h = GetDlgItem(hdlg, IDC_COMBONETDEVICE);
dev = SendMessage(h, CB_GETCURSEL, 0, 0);
config_set_int(CFG_GLOBAL, NULL, "net_type", NET_PCAP);
config_set_string(CFG_GLOBAL, NULL, "pcap_device", dev_name[dev]);
}
else /*SLiRP*/
{
config_set_int(CFG_GLOBAL, NULL, "net_type", NET_SLIRP);
config_set_string(CFG_GLOBAL, NULL, "pcap_device", "nothing");
}
saveconfig_global_only();
case IDCANCEL:
EndDialog(hdlg, 0);
if (net_hLib)
{
_pcap_freealldevs(alldevs);
_pcap_findalldevs = NULL;
_pcap_freealldevs = NULL;
_pcap_open_live = NULL;
_pcap_datalink = NULL;
_pcap_close = NULL;
FreeLibrary(net_hLib);
}
return TRUE;
case IDC_COMBONETTYPE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int type;
h = GetDlgItem(hdlg, IDC_COMBONETTYPE);
type = SendMessage(h, CB_GETCURSEL, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBONETDEVICE);
if (!type)
EnableWindow(h, FALSE);
else
EnableWindow(h, TRUE);
return TRUE;
}
}
break;
}
return FALSE;
}
void networkconfig_open(HWND hwnd)
{
DialogBox(hinstance, TEXT("NetworkConfDlg"), hwnd, (DLGPROC)networkconfig_dlgproc);
}

View file

@ -1,103 +0,0 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include "ibm.h"
#include "device.h"
#include "video.h"
#include "resources.h"
#include "win.h"
#include "x86_ops.h"
#include "mem.h"
#include "codegen.h"
HWND status_hwnd;
int status_is_open = 0;
extern int sreadlnum, swritelnum, segareads, segawrites, scycles_lost;
extern uint64_t main_time;
static uint64_t status_time;
static BOOL CALLBACK status_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char device_s[4096];
switch (message)
{
case WM_INITDIALOG:
status_is_open = 1;
case WM_USER:
{
uint64_t new_time = timer_read();
uint64_t status_diff = new_time - status_time;
status_time = new_time;
sprintf(device_s,
"CPU speed : %f MIPS\n"
"FPU speed : %f MFLOPS\n\n"
/* "Cache misses (read) : %i/sec\n"
"Cache misses (write) : %i/sec\n\n"*/
"Video throughput (read) : %i bytes/sec\n"
"Video throughput (write) : %i bytes/sec\n\n"
"Effective clockspeed : %iHz\n\n"
"Timer 0 frequency : %fHz\n\n"
"CPU time : %f%% (%f%%)\n"
"New blocks : %i\nOld blocks : %i\nRecompiled speed : %f MIPS\nAverage size : %f\n"
"Flushes : %i\nEvicted : %i\nReused : %i\nRemoved : %i\nReal speed : %f MIPS"
// "\nFully recompiled ins %% : %f%%"
,mips,
flops,
/*#ifndef DYNAREC
sreadlnum,
swritelnum,
#endif*/
segareads,
segawrites,
clockrate - scycles_lost,
pit_timer0_freq(),
((double)main_time * 100.0) / status_diff,
((double)main_time * 100.0) / timer_freq
, cpu_new_blocks_latched, cpu_recomp_blocks_latched, (double)cpu_recomp_ins_latched / 1000000.0, (double)cpu_recomp_ins_latched/cpu_recomp_blocks_latched,
cpu_recomp_flushes_latched, cpu_recomp_evicted_latched,
cpu_recomp_reuse_latched, cpu_recomp_removed_latched,
((double)cpu_recomp_ins_latched / 1000000.0) / ((double)main_time / timer_freq)
// ((double)cpu_recomp_full_ins_latched / (double)cpu_recomp_ins_latched) * 100.0
// cpu_reps_latched, cpu_notreps_latched
);
main_time = 0;
/*#ifndef DYNAREC
device_add_status_info(device_s, 4096);
#endif*/
SendDlgItemMessage(hdlg, IDC_STEXT_DEVICE, WM_SETTEXT, (WPARAM)NULL, (LPARAM)device_s);
device_s[0] = 0;
device_add_status_info(device_s, 4096);
SendDlgItemMessage(hdlg, IDC_STEXT1, WM_SETTEXT, (WPARAM)NULL, (LPARAM)device_s);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
status_is_open = 0;
EndDialog(hdlg, 0);
return TRUE;
}
break;
}
return FALSE;
}
void status_open(HWND hwnd)
{
status_hwnd = CreateDialog(hinstance, TEXT("StatusDlg"), hwnd, (DLGPROC)status_dlgproc);
ShowWindow(status_hwnd, SW_SHOW);
}

View file

@ -1,49 +0,0 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "video.h"
BITMAP *screen;
void hline(BITMAP *b, int x1, int y, int x2, int col)
{
if (y < 0 || y >= buffer32->h)
return;
for (; x1 < x2; x1++)
((uint32_t *)b->line[y])[x1] = col;
}
void blit(BITMAP *src, BITMAP *dst, int x1, int y1, int x2, int y2, int xs, int ys)
{
}
void stretch_blit(BITMAP *src, BITMAP *dst, int x1, int y1, int xs1, int ys1, int x2, int y2, int xs2, int ys2)
{
}
void rectfill(BITMAP *b, int x1, int y1, int x2, int y2, uint32_t col)
{
}
void set_palette(PALETTE p)
{
}
void destroy_bitmap(BITMAP *b)
{
}
BITMAP *create_bitmap(int x, int y)
{
BITMAP *b = malloc(sizeof(BITMAP) + (y * sizeof(uint8_t *)));
int c;
b->dat = malloc(x * y * 4);
for (c = 0; c < y; c++)
{
b->line[c] = b->dat + (c * x * 4);
}
b->w = x;
b->h = y;
return b;
}

1497
src/win.c

File diff suppressed because it is too large Load diff

View file

@ -1,42 +0,0 @@
extern HINSTANCE hinstance;
extern HWND ghwnd;
extern int mousecapture;
#ifdef __cplusplus
extern "C" {
#endif
#define szClassName "PCemMainWnd"
#define szSubClassName "PCemSubWnd"
void leave_fullscreen();
#ifdef __cplusplus
}
#endif
void status_open(HWND hwnd);
extern HWND status_hwnd;
extern int status_is_open;
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);
void joystickconfig_open(HWND hwnd, int joy_nr, int type);
void networkconfig_open(HWND hwnd);
extern char openfilestring[260];
int getfile(HWND hwnd, char *f, char *fn);
int getsfile(HWND hwnd, char *f, char *fn, char *dir, char *ext);
extern int pause;
extern int has_been_inited;