diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 68c2237..2176e4c 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -18,8 +18,9 @@ OBJ = 386.o 808x.o acer386sx.o ali1429.o amstrad.o cdrom-ioctl.o \ vid_oti067.o vid_paradise.o vid_pc1512.o vid_pc1640.o vid_pc200.o vid_pcjr.o vid_s3.o \ vid_s3_virge.o vid_sdac_ramdac.o vid_stg_ramdac.o vid_svga.o vid_svga_render.o \ vid_tandy.o vid_tgui9440.o vid_tkd8001_ramdac.o vid_tvga.o vid_unk_ramdac.o vid_vga.o \ - vid_voodoo.o video.o wd76c10.o win.o win-d3d.o win-d3d-fs.o win-ddraw.o win-ddraw-fs.o win-joystick.o win-keyboard.o win-midi.o \ - win-mouse.o win-timer.o win-video.o x86seg.o x87.o xtide.o pc.res + vid_voodoo.o video.o wd76c10.o win.o win-config.o win-d3d.o win-d3d-fs.o win-ddraw.o \ + win-ddraw-fs.o win-hdconf.o win-joystick.o win-keyboard.o win-midi.o win-mouse.o \ + win-status.o win-video.o x86seg.o x87.o xtide.o pc.res FMOBJ = dbopl.o SIDOBJ = convolve.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 diff --git a/src/device.c b/src/device.c index 88b6ffb..f7aa3f0 100644 --- a/src/device.c +++ b/src/device.c @@ -90,7 +90,7 @@ char *device_add_status_info(char *s, int max_len) { int c; - s[0] = 0; + s += strlen(s); for (c = 0; c < 256; c++) { diff --git a/src/ibm.h b/src/ibm.h index e781afb..698d12c 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -317,6 +317,9 @@ enum ROM_MAX }; +extern int romspresent[ROM_MAX]; +extern int gfx_present[19]; + //#define ROM_IBMPCJR 5 /*Not working! ROMs are corrupt*/ #define is386 (romset>=ROM_IBMAT386) #define is386sx 0 diff --git a/src/pc.c b/src/pc.c index 9e4ed7e..9b950d6 100644 --- a/src/pc.c +++ b/src/pc.c @@ -49,7 +49,7 @@ void fullspeed(); int framecount,fps; int intcount; -int wakeups,wokeups; + int output; int atfullspeed; void loadconfig(); @@ -93,7 +93,6 @@ void fatal(const char *format, ...) } uint8_t cgastat; -int drawit=0; int pollmouse_delay = 2; void pollmouse() @@ -239,8 +238,6 @@ void initpc() pc_reset(); pit_reset(); - install_int_ex(onesec,BPS_TO_TIMER(1)); -// install_int_ex(vsyncint,BPS_TO_TIMER(60)); /* if (romset==ROM_AMI386 || romset==ROM_AMI486) */fullspeed(); mem_updatecache(); ali1429_reset(); @@ -352,7 +349,6 @@ void runpc() cycles_lost = 0; mmuflush=0; intcount=0; - wakeups=wokeups=0; intcount=pitcount=0; emu_fps = frames; frames = 0; @@ -365,16 +361,6 @@ void runpc() } done++; frame++; -/* if ((at70hz && VGA)!=oldat70hz) - { - oldat70hz=(at70hz && VGA); - if (oldat70hz) setrefresh(70); //install_int_ex(vsyncint,BPS_TO_TIMER(70)); - else setrefresh(60); //install_int_ex(vsyncint,BPS_TO_TIMER(60)); - drawit=0; - done=0; - }*/ -// printf("End of run!\n"); -// } } void fullspeed() diff --git a/src/pc.rc b/src/pc.rc index 3f0c426..37c8622 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -87,32 +87,32 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,101+12,152,50,14 LTEXT "C:",IDC_STATIC,7,6,27,10 - EDITTEXT IDC_EDITC, 7, 22, 136, 12, WS_DISABLED + EDITTEXT IDC_EDIT_C_FN, 7, 22, 136, 12, WS_DISABLED PUSHBUTTON "...",IDC_CFILE,7 + 136, 22, 16, 14 PUSHBUTTON "New",IDC_CNEW,7 + 136 + 16, 22, 24, 14 PUSHBUTTON "Eject", IDC_EJECTC, 7 + 136 + 16 + 24, 22, 24, 14 - EDITTEXT IDC_EDIT1,36,38,16,12, WS_DISABLED - EDITTEXT IDC_EDIT2,94,38,16,12, WS_DISABLED - EDITTEXT IDC_EDIT3,152,38,28,12, WS_DISABLED + EDITTEXT IDC_EDIT_C_SPT,36,38,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_C_HPC,94,38,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_C_CYL,152,38,28,12, WS_DISABLED LTEXT "Sectors:",IDC_STATIC,7,38,27,10 LTEXT "Heads:",IDC_STATIC,63,38,29,8 LTEXT "Cylinders:",IDC_STATIC,120,38,32,12 - LTEXT "", IDC_TEXT1, 7, 54, 136, 12 + LTEXT "", IDC_TEXT_C_SIZE, 7, 54, 136, 12 LTEXT "D:",IDC_STATIC,7,76,27,10 - EDITTEXT IDC_EDITD, 7, 92, 136, 12, WS_DISABLED + EDITTEXT IDC_EDIT_D_FN, 7, 92, 136, 12, WS_DISABLED PUSHBUTTON "...",IDC_DFILE,7 + 136, 92, 16, 14 PUSHBUTTON "New",IDC_DNEW,7 + 136 + 16, 92, 24, 14 PUSHBUTTON "Eject", IDC_EJECTD, 7 + 136 + 16 + 24, 92, 24, 14 - EDITTEXT IDC_EDIT4,36,108,16,12, WS_DISABLED - EDITTEXT IDC_EDIT5,94,108,16,12, WS_DISABLED - EDITTEXT IDC_EDIT6,152,108,28,12, WS_DISABLED + EDITTEXT IDC_EDIT_D_SPT,36,108,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_D_HPC,94,108,16,12, WS_DISABLED + EDITTEXT IDC_EDIT_D_CYL,152,108,28,12, WS_DISABLED LTEXT "Sectors:",IDC_STATIC,7,108,27,10 LTEXT "Heads:",IDC_STATIC,63,108,29,8 LTEXT "Cylinders:",IDC_STATIC,120,108,32,12 - LTEXT "", IDC_TEXT2, 7, 124, 136, 12 + LTEXT "", IDC_TEXT_D_SIZE, 7, 124, 136, 12 END @@ -160,13 +160,5 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "Status" FONT 8, "MS Sans Serif" BEGIN - LTEXT "1",IDC_STEXT1,16,16,180,10 - LTEXT "2",IDC_STEXT2,16,28,180,10 - LTEXT "3",IDC_STEXT3,16,40,180,10 - LTEXT "4",IDC_STEXT4,16,52,180,10 - LTEXT "5",IDC_STEXT5,16,64,180,10 - LTEXT "6",IDC_STEXT6,16,76,180,10 - LTEXT "7",IDC_STEXT7,16,88,180,10 - LTEXT "8",IDC_STEXT8,16,100,180,10 - LTEXT "9",IDC_STEXT_DEVICE,16,112,180,1000 + LTEXT "1",IDC_STEXT_DEVICE,16,16,180,1000 END diff --git a/src/resources.h b/src/resources.h index 7c43efd..5c81510 100644 --- a/src/resources.h +++ b/src/resources.h @@ -66,5 +66,16 @@ #define IDC_STEXT8 1107 #define IDC_STEXT_DEVICE 1108 +#define IDC_EDIT_C_SPT 1200 +#define IDC_EDIT_C_HPC 1201 +#define IDC_EDIT_C_CYL 1202 +#define IDC_EDIT_D_SPT 1203 +#define IDC_EDIT_D_HPC 1204 +#define IDC_EDIT_D_CYL 1205 +#define IDC_TEXT_C_SIZE 1210 +#define IDC_TEXT_D_SIZE 1211 +#define IDC_EDIT_C_FN 1220 +#define IDC_EDIT_D_FN 1221 + #define WM_RESETD3D WM_USER #define WM_LEAVEFULLSCREEN WM_USER + 1 diff --git a/src/vid_svga.c b/src/vid_svga.c index b6067e8..36034f7 100644 --- a/src/vid_svga.c +++ b/src/vid_svga.c @@ -1345,9 +1345,9 @@ int svga_add_status_info(char *s, int max_len, void *p) int cur_len = max_len; int len; - if (svga->chain4) len = snprintf(s, max_len, "SVGA chained (possibly mode 13h)\n"); - else len = snprintf(s, max_len, "SVGA unchained (possibly mode-X)\n"); - if (len < 0) return; + if (svga->chain4) strcpy(temps, "SVGA chained (possibly mode 13h)\n"); + else strcpy(temps, "SVGA unchained (possibly mode-X)\n"); + strncat(s, temps, cur_len); cur_len -= len; if (!svga->video_bpp) strcpy(temps, "SVGA in text mode\n"); diff --git a/src/win-config.c b/src/win-config.c new file mode 100644 index 0000000..25b969f --- /dev/null +++ b/src/win-config.c @@ -0,0 +1,334 @@ +#define BITMAP WINDOWS_BITMAP +#include +#include +#undef BITMAP + +#include + +#include "ibm.h" +#include "cpu.h" +#include "model.h" +#include "resources.h" +#include "sound.h" +#include "video.h" +#include "win.h" + +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 BOOL CALLBACK config_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + char temp_str[256]; + HWND h; + int c, d; + int rom, gfx, mem, fpu; + int temp_cpu, temp_cpu_m, temp_model; + int temp_GAMEBLASTER, temp_GUS, temp_SSI2001, temp_sound_card_current; +// 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); + + h = GetDlgItem(hdlg, IDC_COMBOVID); + c = d = 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)]) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s); + if (video_new_to_old(c) == gfxcard) + SendMessage(h, CB_SETCURSEL, d, 0); + + d++; + } + + c++; + } + if (models[model].fixed_gfxcard) + EnableWindow(h, FALSE); + + 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); + + h = GetDlgItem(hdlg, IDC_COMBOSND); + c = d = 0; + while (1) + { + char *s = sound_card_getname(c); + + if (!s[0]) + break; + + settings_sound_to_list[c] = d; + + if (sound_card_available(c)) + { + 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); + + 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_CHECK2); + SendMessage(h, BM_SETCHECK, slowega, 0); + + h=GetDlgItem(hdlg, IDC_CHECK4); + SendMessage(h, BM_SETCHECK, cga_comp, 0); + + h = GetDlgItem(hdlg, IDC_COMBOCHC); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"A little"); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"A bit"); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Some"); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"A lot"); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"Infinite"); + SendMessage(h, CB_SETCURSEL, cache, 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, (1 << 16) | 256); + SendMessage(h, UDM_SETPOS, 0, mem_size); + + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + h = GetDlgItem(hdlg, IDC_MEMTEXT); + SendMessage(h, WM_GETTEXT, 255, (LPARAM)temp_str); + sscanf(temp_str, "%i", &mem); + if (mem < 1 || mem > 256) + { + MessageBox(NULL, "Invalid memory size\nMemory must be between 1 and 256 MB", "PCem", MB_OK); + break; + } + + + h = GetDlgItem(hdlg, IDC_COMBO1); + temp_model = listtomodel[SendMessage(h, CB_GETCURSEL, 0, 0)]; + + 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_COMBOSND); + temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + + 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) + { + if (MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK) + { + 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; + + 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); + + h = GetDlgItem(hdlg, IDC_CHECK4); + cga_comp=SendMessage(h, BM_GETCHECK, 0, 0); + + cpu_manufacturer = temp_cpu_m; + cpu = temp_cpu; + cpu_set(); + + h = GetDlgItem(hdlg, IDC_COMBOCHC); + cache=SendMessage(h, CB_GETCURSEL, 0, 0); + mem_updatecache(); + + saveconfig(); + + speedchanged(); + + 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)]; + + /*Enable/disable gfxcard list*/ + h = GetDlgItem(hdlg, IDC_COMBOVID); + if (!models[temp_model].fixed_gfxcard) + { + char *s = video_card_getname(video_old_to_new(gfxcard)); + + EnableWindow(h, TRUE); + + c = 0; + while (1) + { + SendMessage(h, CB_GETLBTEXT, c, (LPARAM)temp_str); + if (!strcmp(temp_str, s)) + break; + c++; + } + SendMessage(h, CB_SETCURSEL, c, 0); + } + else + EnableWindow(h, FALSE); + + /*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); + } + 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); + } + break; + } + break; + } + return FALSE; +} + +void config_open(HWND hwnd) +{ + DialogBox(hinstance, TEXT("ConfigureDlg"), hwnd, config_dlgproc); +} diff --git a/src/win-hdconf.c b/src/win-hdconf.c new file mode 100644 index 0000000..30450df --- /dev/null +++ b/src/win-hdconf.c @@ -0,0 +1,493 @@ +#define BITMAP WINDOWS_BITMAP +#include +#include +#undef BITMAP + +#include "ibm.h" +#include "ide.h" +#include "resources.h" +#include "win.h" + +static int hd_changed = 0; + +static char hd_new_name[512]; +static int hd_new_spt, hd_new_hpc, hd_new_cyl; + +static BOOL CALLBACK hdnew_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + char s[260]; + HWND h; + int c; + PcemHDC hd[2]; + FILE *f; + uint8_t buf[512]; + 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); + + 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 > 128) + { + MessageBox(ghwnd, "Drive has too many heads (maximum is 128)", "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", "")) + { + 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); + 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", (((((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; +} + +BOOL CALLBACK hdsize_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + char s[260]; + HWND h; + PcemHDC hd[2]; + switch (message) + { + case WM_INITDIALOG: + 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", ((((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 > 128) + { + MessageBox(ghwnd,"Drive has too many heads (maximum is 128)","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", (((((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[2]; + FILE *f; + off64_t sz; + switch (message) + { + case WM_INITDIALOG: + pause = 1; + hd[0] = hdc[0]; + hd[1] = hdc[1]; + 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_TEXT_C_SIZE); + sprintf(s, "Size : %imb", (((((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", (((((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); + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + if (hd_changed) + { + if (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]); + + hdc[0] = hd[0]; + hdc[1] = hd[1]; + + saveconfig(); + + 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_CNEW: + if (DialogBox(hinstance, TEXT("HdNewDlg"), hdlg, 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_CYL); + 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", (((((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); + hd_new_spt = 63; + hd_new_hpc = 16; + hd_new_cyl = ((sz / 512) / 16) / 63; + + if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, 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", (((((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, TEXT("HdNewDlg"), hdlg, 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", (((((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); + hd_new_spt = 63; + hd_new_hpc = 16; + hd_new_cyl = ((sz / 512) / 16) / 63; + + if (DialogBox(hinstance, TEXT("HdSizeDlg"), hdlg, 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", (((((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; + } + break; + + } + return FALSE; +} + +void hdconf_open(HWND hwnd) +{ + DialogBox(hinstance, TEXT("HdConfDlg"), hwnd, hdconf_dlgproc); +} diff --git a/src/win-status.c b/src/win-status.c new file mode 100644 index 0000000..998726f --- /dev/null +++ b/src/win-status.c @@ -0,0 +1,66 @@ +#define BITMAP WINDOWS_BITMAP +#include +#include +#undef BITMAP + +#include "ibm.h" +#include "video.h" +#include "resources.h" +#include "win.h" + +HWND status_hwnd; +int status_is_open = 0; + +extern int sreadlnum, swritelnum, segareads, segawrites, scycles_lost; + +static BOOL CALLBACK status_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + char s[256]; + char device_s[4096]; + switch (message) + { + case WM_INITDIALOG: + status_is_open = 1; + case WM_USER: + 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\n" + "Video throughput (write) : %i bytes/sec\n\n" + "Effective clockspeed : %iHz\n\n" + "Timer 0 frequency : %fHz\n\n", + mips, + flops, + sreadlnum, + swritelnum, + segareads, + segawrites, + clockrate - (sreadlnum*memwaitstate) - (swritelnum*memwaitstate) - scycles_lost, + pit_timer0_freq() + ); + + device_add_status_info(device_s, 4096); + SendDlgItemMessage(hdlg, IDC_STEXT_DEVICE, 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, status_dlgproc); + ShowWindow(status_hwnd, SW_SHOW); +} diff --git a/src/win-timer.c b/src/win-timer.c deleted file mode 100644 index 71bfeff..0000000 --- a/src/win-timer.c +++ /dev/null @@ -1,8 +0,0 @@ -int BPS_TO_TIMER(int a) -{ - return a; -} - -void install_int_ex(void (*rout)(), int a) -{ -} diff --git a/src/win.c b/src/win.c index 9159795..41e164b 100644 --- a/src/win.c +++ b/src/win.c @@ -54,52 +54,39 @@ static struct int winsizex=640,winsizey=480; int gfx_present[19]; -int wakeups,wokeups; #undef cs CRITICAL_SECTION cs; -void waitmain(); -void vsyncint(); -int vgapresent; -int cursoron = 1; - -HANDLE soundthreadh; -HANDLE blitthreadh; HANDLE mainthreadh; -void soundthread(LPVOID param); -void endmainthread(); -void endsoundthread(); -void silencesound(); -void restoresound(); -static HANDLE frameobject; - int infocus=1; int drawits=0; -void vsyncint() -{ -// if (infocus) -// { - drawits++; - wakeups++; - SetEvent(frameobject); -// } -} int romspresent[ROM_MAX]; int quited=0; RECT oldclip; int mousecapture=0; -int drawit; + /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK subWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); HWND ghwnd; + +HINSTANCE hinstance; + +HMENU menu; + +extern int updatestatus; + +int pause=0; + static int win_doresize = 0; +static int leave_fullscreen_flag = 0; + void updatewindowsize(int x, int y) { RECT r; @@ -119,19 +106,6 @@ void releasemouse() } } -void setrefresh(int rate) -{ - return; - remove_int(vsyncint); - drawit=0; - install_int_ex(vsyncint,BPS_TO_TIMER(rate)); -/* printf("Vsyncint at %i hz\n",rate); - counter_freq.QuadPart=counter_base.QuadPart/rate;*/ -// DeleteTimerQueueTimer( &hTimer, hTimerQueue, NULL); -// CreateTimerQueueTimer( &hTimer, hTimerQueue, -// mainroutine, NULL , 100, 1000/rate, 0); -} - void startblit() { EnterCriticalSection(&cs); @@ -142,44 +116,17 @@ void endblit() LeaveCriticalSection(&cs); } -static int leave_fullscreen_flag = 0; void leave_fullscreen() { leave_fullscreen_flag = 1; } -int mainthreadon=0; - -/*static HANDLE blitobject; -void blitthread(LPVOID param) -{ - while (!quited) - { - WaitForSingleObject(blitobject,100); - if (quited) break; - doblit(); - } -} - -void wakeupblit() -{ - SetEvent(blitobject); -}*/ - -HWND statushwnd; -int statusopen=0; -extern int updatestatus; -extern int sreadlnum, swritelnum, segareads, segawrites, scycles_lost; - -int pause=0; - void mainthread(LPVOID param) { int t = 0; int frames = 0; DWORD old_time, new_time; - mainthreadon=1; // Sleep(500); drawits=0; old_time = GetTickCount(); @@ -187,8 +134,9 @@ void mainthread(LPVOID param) { if (updatestatus) { - updatestatus=0; - if (statusopen) SendMessage(statushwnd,WM_USER,0,0); + updatestatus = 0; + if (status_is_open) + SendMessage(status_hwnd, WM_USER, 0, 0); } new_time = GetTickCount(); drawits += new_time - old_time; @@ -196,7 +144,6 @@ void mainthread(LPVOID param) if (drawits > 0 && !pause) { drawits-=10; if (drawits>50) drawits=0; - wokeups++; runpc(); frames++; if (frames >= 200 && nvr_dosave) @@ -226,11 +173,8 @@ void mainthread(LPVOID param) SendMessage(ghwnd, WM_LEAVEFULLSCREEN, 0, 0); } } - mainthreadon=0; } -HMENU menu; - static void initmenu(void) { int c; @@ -252,8 +196,6 @@ static void initmenu(void) } } -HINSTANCE hinstance; - void get_executable_name(char *s, int size) { GetModuleFileName(hinstance, s, size); @@ -418,33 +360,18 @@ int WINAPI WinMain (HINSTANCE hThisInstance, loadbios(); timeBeginPeriod(1); -// soundobject=CreateEvent(NULL, FALSE, FALSE, NULL); -// soundthreadh=CreateThread(NULL,0,soundthread,NULL,NULL,NULL); - atexit(releasemouse); -// atexit(endsoundthread); - drawit=0; + // QueryPerformanceFrequency(&counter_base); /// QueryPerformanceCounter(&counter_posold); // counter_posold.QuadPart*=100; -InitializeCriticalSection(&cs); - frameobject=CreateEvent(NULL, FALSE, FALSE, NULL); + InitializeCriticalSection(&cs); mainthreadh=(HANDLE)_beginthread(mainthread,0,NULL); -// atexit(endmainthread); -// soundthreadh=(HANDLE)_beginthread(soundthread,0,NULL); -// atexit(endsoundthread); SetThreadPriority(mainthreadh, THREAD_PRIORITY_HIGHEST); -// blitobject=CreateEvent(NULL, FALSE, FALSE, NULL); -// blitthreadh=(HANDLE)_beginthread(blitthread,0,NULL); - -// SetThreadPriority(soundthreadh, THREAD_PRIORITY_HIGHEST); - - drawit=0; - install_int_ex(vsyncint,BPS_TO_TIMER(100)); - + updatewindowsize(640, 480); QueryPerformanceFrequency(&qpc_freq); @@ -497,7 +424,6 @@ InitializeCriticalSection(&cs); // pclog("Sleep 1000\n"); Sleep(200); // pclog("TerminateThread\n"); - TerminateThread(blitthreadh,0); TerminateThread(mainthreadh,0); // pclog("Quited? %i\n",quited); // pclog("Closepc\n"); @@ -507,7 +433,6 @@ InitializeCriticalSection(&cs); vid_apis[video_fullscreen][vid_api].close(); timeEndPeriod(1); -// endsoundthread(); // dumpregs(); if (mousecapture) { @@ -603,846 +528,7 @@ int getsfile(HWND hwnd, char *f, char *fn) return 1; } -extern int is486; -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]; -BOOL CALLBACK configdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - char temp_str[256]; - HWND h; - int c, d; - int rom,gfx,mem,fpu; - int temp_cpu, temp_cpu_m, temp_model; - int temp_GAMEBLASTER, temp_GUS, temp_SSI2001, temp_sound_card_current; -// pclog("Dialog msg %i %08X\n",message,message); - switch (message) - { - case WM_INITDIALOG: - pause=1; - h=GetDlgItem(hdlg,IDC_COMBO1); - for (c=0;c 256) - { - MessageBox(NULL, "Invalid memory size\nMemory must be between 1 and 256 MB", "PCem", MB_OK); - break; - } - - - h=GetDlgItem(hdlg,IDC_COMBO1); - temp_model = listtomodel[SendMessage(h,CB_GETCURSEL,0,0)]; - - 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; - pclog("newcpu - %i %i %i %i\n",temp_cpu_m,temp_cpu,fpu,models[temp_model].cpu[temp_cpu_m].cpus[temp_cpu].cpu_type); - - 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_COMBOSND); - temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; - - 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) - { - if (MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK) - { - 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; - - 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); - - h=GetDlgItem(hdlg,IDC_CHECK4); - cga_comp=SendMessage(h,BM_GETCHECK,0,0); - - cpu_manufacturer = temp_cpu_m; - cpu = temp_cpu; - cpu_set(); - - h=GetDlgItem(hdlg,IDC_COMBOCHC); - cache=SendMessage(h,CB_GETCURSEL,0,0); - mem_updatecache(); - - saveconfig(); - - speedchanged(); -// if (romset>2) cpuspeed=1; -// setpitclock(clocks[AT?1:0][cpuspeed][0]); -// if (cpuspeed) setpitclock(8000000.0); -// else setpitclock(4772728.0); - - 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)]; - - /*Enable/disable gfxcard list*/ - h = GetDlgItem(hdlg, IDC_COMBOVID); - if (!models[temp_model].fixed_gfxcard) - { - char *s = video_card_getname(video_old_to_new(gfxcard)); - - EnableWindow(h, TRUE); - - c = 0; - while (1) - { - SendMessage(h, CB_GETLBTEXT, c, (LPARAM)temp_str); - if (!strcmp(temp_str, s)) - break; - c++; - } - SendMessage(h, CB_SETCURSEL, c, 0); - } - else - EnableWindow(h, FALSE); - - /*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); - } - 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); - } - break; - } - break; - - } - return FALSE; -} -static char hd_new_name[512]; -static int hd_new_spt, hd_new_hpc, hd_new_cyl; - -BOOL CALLBACK hdnewdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - char s[260]; - HWND h; - int c; - PcemHDC hd[2]; - FILE *f; - uint8_t buf[512]; - 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); - - 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 > 128) - { - MessageBox(ghwnd,"Drive has too many heads (maximum is 128)","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", "")) - { - 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); - 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",(((((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; -} - -BOOL CALLBACK hdsizedlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - char s[260]; - HWND h; - PcemHDC hd[2]; - switch (message) - { - case WM_INITDIALOG: - 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", ((((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 > 128) - { - MessageBox(ghwnd,"Drive has too many heads (maximum is 128)","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",(((((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 int hd_changed = 0; -BOOL CALLBACK hdconfdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - char s[260]; - HWND h; - PcemHDC hd[2]; - FILE *f; - off64_t sz; - switch (message) - { - case WM_INITDIALOG: - pause=1; - hd[0]=hdc[0]; - hd[1]=hdc[1]; - hd_changed = 0; - - h=GetDlgItem(hdlg,IDC_EDIT1); - sprintf(s,"%i",hdc[0].spt); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT2); - sprintf(s,"%i",hdc[0].hpc); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT3); - sprintf(s,"%i",hdc[0].tracks); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDITC); - SendMessage(h,WM_SETTEXT,0,(LPARAM)ide_fn[0]); - - h=GetDlgItem(hdlg,IDC_EDIT4); - sprintf(s,"%i",hdc[1].spt); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT5); - sprintf(s,"%i",hdc[1].hpc); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT6); - sprintf(s,"%i",hdc[1].tracks); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDITD); - SendMessage(h,WM_SETTEXT,0,(LPARAM)ide_fn[1]); - - h=GetDlgItem(hdlg,IDC_TEXT1); - sprintf(s,"Size : %imb",(((((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_TEXT2); - sprintf(s,"Size : %imb",(((((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); - return TRUE; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - if (hd_changed) - { - if (MessageBox(NULL,"This will reset PCem!\nOkay to continue?","PCem",MB_OKCANCEL)==IDOK) - { - 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_EDITC); - SendMessage(h,WM_GETTEXT,511,(LPARAM)ide_fn[0]); - - h=GetDlgItem(hdlg,IDC_EDIT4); - SendMessage(h,WM_GETTEXT,255,(LPARAM)s); - sscanf(s,"%i",&hd[1].spt); - h=GetDlgItem(hdlg,IDC_EDIT5); - SendMessage(h,WM_GETTEXT,255,(LPARAM)s); - sscanf(s,"%i",&hd[1].hpc); - h=GetDlgItem(hdlg,IDC_EDIT6); - SendMessage(h,WM_GETTEXT,255,(LPARAM)s); - sscanf(s,"%i",&hd[1].tracks); - h=GetDlgItem(hdlg,IDC_EDITD); - SendMessage(h,WM_GETTEXT,511,(LPARAM)ide_fn[1]); - - hdc[0] = hd[0]; - hdc[1] = hd[1]; - - saveconfig(); - - 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_EDIT1, "0"); - SetDlgItemText(hdlg, IDC_EDIT2, "0"); - SetDlgItemText(hdlg, IDC_EDIT3, "0"); - SetDlgItemText(hdlg, IDC_EDITC, ""); - 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_EDIT4, "0"); - SetDlgItemText(hdlg, IDC_EDIT5, "0"); - SetDlgItemText(hdlg, IDC_EDIT6, "0"); - SetDlgItemText(hdlg, IDC_EDITD, ""); - hd_changed = 1; - return TRUE; - - case IDC_CNEW: - if (DialogBox(hinstance,TEXT("HdNewDlg"),hdlg,hdnewdlgproc) == 1) - { - 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_EDITC); - SendMessage(h,WM_SETTEXT,0,(LPARAM)hd_new_name); - - h=GetDlgItem(hdlg,IDC_TEXT1); - sprintf(s,"Size : %imb",(((((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); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - if (DialogBox(hinstance,TEXT("HdSizeDlg"),hdlg,hdsizedlgproc) == 1) - { - 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_EDITC); - SendMessage(h,WM_SETTEXT,0,(LPARAM)openfilestring); - - h=GetDlgItem(hdlg,IDC_TEXT1); - sprintf(s,"Size : %imb",(((((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,TEXT("HdNewDlg"),hdlg,hdnewdlgproc) == 1) - { - h=GetDlgItem(hdlg,IDC_EDIT4); - sprintf(s,"%i",hd_new_spt); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT5); - sprintf(s,"%i",hd_new_hpc); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT6); - sprintf(s,"%i",hd_new_cyl); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDITD); - SendMessage(h,WM_SETTEXT,0,(LPARAM)hd_new_name); - - h=GetDlgItem(hdlg,IDC_TEXT2); - sprintf(s,"Size : %imb",(((((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); - hd_new_spt = 63; - hd_new_hpc = 16; - hd_new_cyl = ((sz / 512) / 16) / 63; - - if (DialogBox(hinstance,TEXT("HdSizeDlg"),hdlg,hdsizedlgproc) == 1) - { - h=GetDlgItem(hdlg,IDC_EDIT4); - sprintf(s,"%i",hd_new_spt); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT5); - sprintf(s,"%i",hd_new_hpc); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDIT6); - sprintf(s,"%i",hd_new_cyl); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - h=GetDlgItem(hdlg,IDC_EDITD); - SendMessage(h,WM_SETTEXT,0,(LPARAM)openfilestring); - - h=GetDlgItem(hdlg,IDC_TEXT2); - sprintf(s,"Size : %imb",(((((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_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",((((hd[0].tracks*hd[0].hpc)*hd[0].spt)*512)/1024)/1024); - SendMessage(h,WM_SETTEXT,0,(LPARAM)s); - return TRUE; - - case IDC_EDIT4: case IDC_EDIT5: case IDC_EDIT6: - h=GetDlgItem(hdlg,IDC_EDIT4); - SendMessage(h,WM_GETTEXT,255,(LPARAM)s); - sscanf(s,"%i",&hd[1].spt); - h=GetDlgItem(hdlg,IDC_EDIT5); - SendMessage(h,WM_GETTEXT,255,(LPARAM)s); - sscanf(s,"%i",&hd[1].hpc); - h=GetDlgItem(hdlg,IDC_EDIT6); - SendMessage(h,WM_GETTEXT,255,(LPARAM)s); - sscanf(s,"%i",&hd[1].tracks); - - h=GetDlgItem(hdlg,IDC_TEXT2); - 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; - } - break; - - } - return FALSE; -} - -BOOL CALLBACK statusdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - int egasp; - char s[256]; - char device_s[4096]; - switch (message) - { - case WM_INITDIALOG: - statusopen=1; - case WM_USER: - sprintf(s,"CPU speed : %f MIPS",mips); - SendDlgItemMessage(hdlg,IDC_STEXT1,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - sprintf(s,"FPU speed : %f MFLOPS",flops); - SendDlgItemMessage(hdlg,IDC_STEXT2,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - sprintf(s,"Cache misses (read) : %i/sec",sreadlnum); - SendDlgItemMessage(hdlg,IDC_STEXT3,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - sprintf(s,"Cache misses (write) : %i/sec",swritelnum); - SendDlgItemMessage(hdlg,IDC_STEXT4,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - sprintf(s,"Video throughput (read) : %i bytes/sec",segareads); - SendDlgItemMessage(hdlg,IDC_STEXT5,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - sprintf(s,"Video throughput (write) : %i bytes/sec",segawrites); - SendDlgItemMessage(hdlg,IDC_STEXT6,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - egasp=(slowega)?egacycles:egacycles2; - sprintf(s,"Effective clockspeed : %iHz",clockrate-(sreadlnum*memwaitstate)-(swritelnum*memwaitstate)- scycles_lost); -// pclog("%i : %i %i %i %i : %i %i\n",clockrate,sreadlnum*memwaitstate,swritelnum*memwaitstate,segareads*egasp,segawrites*egasp,segawrites,egasp); - SendDlgItemMessage(hdlg,IDC_STEXT7,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - sprintf(s,"Timer 0 frequency : %fHz",pit_timer0_freq()); - SendDlgItemMessage(hdlg,IDC_STEXT8,WM_SETTEXT,(WPARAM)NULL,(LPARAM)s); - device_s[0] = 0; - device_add_status_info(device_s, 4096); - SendDlgItemMessage(hdlg,IDC_STEXT_DEVICE,WM_SETTEXT,(WPARAM)NULL,(LPARAM)device_s); - return TRUE; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - statusopen=0; - EndDialog(hdlg,0); - return TRUE; - } - break; - } - return FALSE; -} HHOOK hKeyboardHook; @@ -1486,14 +572,12 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM Sleep(100); resetpc(); pause=0; - drawit=1; break; case IDM_FILE_HRESET: pause=1; Sleep(100); resetpchard(); pause=0; - drawit=1; break; case IDM_FILE_EXIT: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ @@ -1525,14 +609,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM saveconfig(); break; case IDM_HDCONF: - DialogBox(hinstance,TEXT("HdConfDlg"),hwnd,hdconfdlgproc); + hdconf_open(hwnd); break; case IDM_CONFIG: - DialogBox(hinstance,TEXT("ConfigureDlg"),hwnd,configdlgproc); + config_open(hwnd); break; case IDM_STATUS: - statushwnd=CreateDialog(hinstance,TEXT("StatusDlg"),hwnd,statusdlgproc); - ShowWindow(statushwnd,SW_SHOW); + status_open(hwnd); break; case IDM_VID_RESIZE: @@ -1648,10 +731,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_SETFOCUS: infocus=1; - drawit=0; // QueryPerformanceCounter(&counter_posold); -// ResetEvent(frameobject); -// restoresound(); // pclog("Set focus!\n"); break; case WM_KILLFOCUS: @@ -1662,7 +742,6 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM ShowCursor(TRUE); mousecapture=0; } -// silencesound(); // pclog("Lost focus!\n"); break; diff --git a/src/win.h b/src/win.h index fe69f01..3cfc43f 100644 --- a/src/win.h +++ b/src/win.h @@ -14,3 +14,19 @@ 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); + +extern char openfilestring[260]; + +int getfile(HWND hwnd, char *f, char *fn); +int getsfile(HWND hwnd, char *f, char *fn); + +extern int pause;