|
|
| version 1.1, 2004/08/01 05:31:31 | version 1.9, 2004/08/07 10:53:01 |
|---|---|
| Line 17 | Line 17 |
| #include "winkbd.h" | #include "winkbd.h" |
| #include "menu.h" | #include "menu.h" |
| #include "ini.h" | #include "ini.h" |
| #include "juliet.h" | |
| #include "extclass.h" | #include "extclass.h" |
| #include "dialog.h" | #include "dialog.h" |
| #include "z80core.h" | #include "z80core.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "x1_io.h" | #include "iocore.h" |
| #include "x1_crtc.h" | |
| #include "timing.h" | #include "timing.h" |
| #include "draw.h" | |
| #include "x1_fdc.h" | |
| #include "fdd_ini.h" | |
| #include "juliet.h" | |
| #include "diskdrv.h" | |
| #include "debugsub.h" | #include "debugsub.h" |
| #include "makescrn.h" | |
| #include "diskdrv.h" | |
| #include "fdd_ini.h" | |
| #include "x1f.h" | #include "x1f.h" |
| Line 38 static const OEMCHAR szClassName[] = OEM | Line 35 static const OEMCHAR szClassName[] = OEM |
| XMILOSCFG xmiloscfg = { | XMILOSCFG xmiloscfg = { |
| CW_USEDEFAULT, CW_USEDEFAULT, | CW_USEDEFAULT, CW_USEDEFAULT, |
| 1, 0, 0, | 1, 0, 0, 0, 1, |
| 0, 0, 0, | 0, 0, 0, |
| 0, 0, 0xffffff, 0xffbf6a}; | 0, 0, 0xffffff, 0xffbf6a}; |
| Line 46 static const OEMCHAR szClassName[] = OEM | Line 43 static const OEMCHAR szClassName[] = OEM |
| HWND hWndMain; | HWND hWndMain; |
| HINSTANCE hInst; | HINSTANCE hInst; |
| HINSTANCE hPreI; | HINSTANCE hPreI; |
| OEMCHAR modulefile[MAX_PATH]; | |
| OEMCHAR fddfolder[MAX_PATH]; | OEMCHAR fddfolder[MAX_PATH]; |
| OEMCHAR bmpfilefolder[MAX_PATH]; | OEMCHAR bmpfilefolder[MAX_PATH]; |
| static BYTE xmilforeground = 0; | static BRESULT xmilstopemulate = FALSE; |
| BYTE xmilopening = 1; | UINT8 xmilopening = 1; |
| static void wincentering(HWND hWnd) { | static void wincentering(HWND hWnd) { |
| Line 99 static void dispbmp(HINSTANCE hinst, HDC | Line 97 static void dispbmp(HINSTANCE hinst, HDC |
| HDC hmdc; | HDC hmdc; |
| hbmp = LoadBitmap(hinst, res); | hbmp = LoadBitmap(hinst, res); |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | GetObject(hbmp, sizeof(bmp), &bmp); |
| hmdc = CreateCompatibleDC(hdc); | hmdc = CreateCompatibleDC(hdc); |
| SelectObject(hmdc, hbmp); | SelectObject(hmdc, hbmp); |
| BitBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); | BitBlt(hdc, x, y, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); |
| Line 236 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 234 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| break; | break; |
| case IDM_BOOT2HD: | case IDM_BOOT2HD: |
| xmenu_setbootmedia(DIP_BOOTMEDIA); | xmenu_setbootmedia(DIPSW_BOOTMEDIA); |
| updateflag = SYS_UPDATECFG; | updateflag = SYS_UPDATECFG; |
| break; | break; |
| Line 246 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 244 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| break; | break; |
| case IDM_LOWRES: | case IDM_LOWRES: |
| xmenu_setresolute(DIP_RESOLUTE); | xmenu_setresolute(DIPSW_RESOLUTE); |
| updateflag = SYS_UPDATECFG; | updateflag = SYS_UPDATECFG; |
| break; | break; |
| Line 259 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 257 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| break; | break; |
| case IDM_WIDTH80: | case IDM_WIDTH80: |
| crtc.TXT_XL = 80; | crtc.s.TXT_XL = 80; |
| crtc.GRP_XL = 640; | crtc.s.GRP_XL = 640; |
| vrambank_patch(); | vrambank_patch(); |
| scrnallflash = 1; | scrnallflash = 1; |
| break; | break; |
| case IDM_WIDTH40: | case IDM_WIDTH40: |
| crtc.TXT_XL = 40; | crtc.s.TXT_XL = 40; |
| crtc.GRP_XL = 320; | crtc.s.GRP_XL = 320; |
| vrambank_patch(); | vrambank_patch(); |
| scrnallflash = 1; | scrnallflash = 1; |
| break; | break; |
| Line 277 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 275 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| break; | break; |
| case IDM_NOWAIT: | case IDM_NOWAIT: |
| xmenu_setwaitflg(xmilcfg.NOWAIT ^ 1); | xmenu_setwaitflg(xmiloscfg.NOWAIT ^ 1); |
| updateflag = SYS_UPDATECFG; | updateflag = SYS_UPDATECFG; |
| break; | break; |
| Line 403 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 401 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| case WM_ACTIVATE: | case WM_ACTIVATE: |
| if (LOWORD(wParam) != WA_INACTIVE) { | if (LOWORD(wParam) != WA_INACTIVE) { |
| xmilforeground = 0; | xmilstopemulate = FALSE; |
| scrnmng_update(); | scrnmng_update(); |
| mousemng_enable(MOUSEPROC_BG); | mousemng_enable(MOUSEPROC_BG); |
| soundmng_enable(SNDPROC_MASTER); | soundmng_enable(SNDPROC_MASTER); |
| } | } |
| else { | else { |
| xmilforeground = 1; | |
| mousemng_disable(MOUSEPROC_BG); | mousemng_disable(MOUSEPROC_BG); |
| xmilstopemulate = (xmiloscfg.background & 1)?TRUE:FALSE; | |
| if (xmiloscfg.background) { | if (xmiloscfg.background) { |
| soundmng_disable(SNDPROC_MASTER); | soundmng_disable(SNDPROC_MASTER); |
| } | } |
| Line 435 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 433 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| PatBlt(hdc, 0, 0, width, height, PATCOPY); | PatBlt(hdc, 0, 0, width, height, PATCOPY); |
| SelectObject(hdc, hbrush); | SelectObject(hdc, hbrush); |
| dispbmp(hinst, hdc, "XMILBMP", | dispbmp(hinst, hdc, OEMTEXT("XMILBMP"), |
| (width - 201) / 2, (height - 31) / 2); | (width - 201) / 2, (height - 31) / 2); |
| dispbmp(hinst, hdc, "ZILOG", | dispbmp(hinst, hdc, OEMTEXT("ZILOG"), |
| width - (101 + 8 + 41 + 8 + 68 + 1), height - 38); | width - (101 + 8 + 41 + 8 + 68 + 1), height - 38); |
| dispbmp(hinst, hdc, "TURBOZ", | dispbmp(hinst, hdc, OEMTEXT("TURBOZ"), |
| width - (101 + 8 + 68 + 1), height - 18); | width - (101 + 8 + 68 + 1), height - 18); |
| dispbmp(hinst, hdc, "OPMSOUND", | dispbmp(hinst, hdc, OEMTEXT("OPMSOUND"), |
| width - (68 + 1), height - (25 + 1)); | width - (68 + 1), height - (25 + 1)); |
| } | } |
| else { | else { |
| Line 630 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 628 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| // ---- | // ---- |
| static UINT framecnt = 0; | |
| static UINT waitcnt = 0; | |
| static UINT framemax = 1; | |
| static void framereset(UINT cnt) { | |
| framecnt = 0; | |
| scrnmng_dispclock(); | |
| // kdispwin_draw((BYTE)cnt); | |
| // skbdwin_process(); | |
| // mdbgwin_process(); | |
| // toolwin_draw((BYTE)cnt); | |
| // viewer_allreload(FALSE); | |
| if (xmiloscfg.DISPCLK & 3) { | |
| if (sysmng_workclockrenewal()) { | |
| sysmng_updatecaption(3); | |
| } | |
| } | |
| } | |
| static void processwait(UINT cnt) { | |
| if (timing_getcount() >= cnt) { | |
| timing_setcount(0); | |
| framereset(cnt); | |
| } | |
| else { | |
| Sleep(1); | |
| } | |
| soundmng_sync(); | |
| } | |
| static void exec1frame(void) { | |
| joymng_sync(); | |
| mousemng_sync(); | |
| pccore_exec(framecnt == 0); | |
| dclock_callback(); | |
| framecnt++; | |
| } | |
| int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, |
| LPSTR lpszCmdLine, int nCmdShow) { | LPSTR lpszCmdLine, int nCmdShow) { |
| Line 644 int WINAPI WinMain(HINSTANCE hInstance, | Line 683 int WINAPI WinMain(HINSTANCE hInstance, |
| return(FALSE); | return(FALSE); |
| } | } |
| file_setcd(__argv[0]); | GetModuleFileName(NULL, modulefile, sizeof(modulefile)); |
| file_setcd(modulefile); | |
| initload(); | initload(); |
| hInst = hInstance; | hInst = hInstance; |
| Line 674 int WINAPI WinMain(HINSTANCE hInstance, | Line 714 int WINAPI WinMain(HINSTANCE hInstance, |
| WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | |
| WS_MINIMIZEBOX, | WS_MINIMIZEBOX, |
| xmiloscfg.winx, xmiloscfg.winy, | xmiloscfg.winx, xmiloscfg.winy, |
| SCREEN_WIDTH, SCREEN_HEIGHT, | SURFACE_WIDTH, SURFACE_HEIGHT, |
| NULL, NULL, hInstance, NULL); | NULL, NULL, hInstance, NULL); |
| hWndMain = hWnd; | hWndMain = hWnd; |
| scrnmng_initialize(); | scrnmng_initialize(); |
| Line 690 int WINAPI WinMain(HINSTANCE hInstance, | Line 730 int WINAPI WinMain(HINSTANCE hInstance, |
| xmenu_setbtnrapid(xmilcfg.BTN_RAPID); | xmenu_setbtnrapid(xmilcfg.BTN_RAPID); |
| xmenu_setbtnmode(xmilcfg.BTN_MODE); | xmenu_setbtnmode(xmilcfg.BTN_MODE); |
| xmenu_setcpuspeed(xmilcfg.CPU8MHz); | xmenu_setcpuspeed(xmilcfg.CPU8MHz); |
| xmenu_setwaitflg(xmilcfg.NOWAIT); | xmenu_setwaitflg(xmiloscfg.NOWAIT); |
| xmenu_setframe(xmilcfg.DRAW_SKIP); | xmenu_setframe(xmiloscfg.DRAW_SKIP); |
| xmenu_setmotorflg(xmilcfg.MOTOR); | xmenu_setmotorflg(xmilcfg.MOTOR); |
| xmenu_setz80save(xmiloscfg.Z80SAVE); | xmenu_setz80save(xmiloscfg.Z80SAVE); |
| xmenu_setjoystick(xmiloscfg.JOYSTICK); | xmenu_setjoystick(xmiloscfg.JOYSTICK); |
| Line 715 int WINAPI WinMain(HINSTANCE hInstance, | Line 755 int WINAPI WinMain(HINSTANCE hInstance, |
| if (scrnmng_create(scrnmode) != SUCCESS) { | if (scrnmng_create(scrnmode) != SUCCESS) { |
| scrnmode ^= SCRNMODE_FULLSCREEN; | scrnmode ^= SCRNMODE_FULLSCREEN; |
| if (scrnmng_create(scrnmode) != SUCCESS) { | if (scrnmng_create(scrnmode) != SUCCESS) { |
| MessageBox(hWnd, "Couldn't create DirectDraw Object", | MessageBox(hWnd, OEMTEXT("Couldn't create DirectDraw Object"), |
| szProgName, MB_OK); | szProgName, MB_OK); |
| return(FALSE); | return(FALSE); |
| } | } |
| Line 725 int WINAPI WinMain(HINSTANCE hInstance, | Line 765 int WINAPI WinMain(HINSTANCE hInstance, |
| juliet_load(); | juliet_load(); |
| juliet_prepare(); | juliet_prepare(); |
| juliet2_reset(); | // juliet2_reset(); |
| if (soundmng_initialize() == SUCCESS) { | if (soundmng_initialize() == SUCCESS) { |
| soundmng_pcmload(SOUND_PCMSEEK, "fddseek.wav", 0); | soundmng_pcmload(SOUND_PCMSEEK, OEMTEXT("fddseek.wav"), 0); |
| soundmng_pcmload(SOUND_PCMSEEK1, "fddseek1.wav", 0); | soundmng_pcmload(SOUND_PCMSEEK1, OEMTEXT("fddseek1.wav"), 0); |
| soundmng_pcmvolume(SOUND_PCMSEEK, xmilcfg.MOTORVOL); | soundmng_pcmvolume(SOUND_PCMSEEK, xmilcfg.MOTORVOL); |
| soundmng_pcmvolume(SOUND_PCMSEEK1, xmilcfg.MOTORVOL); | soundmng_pcmvolume(SOUND_PCMSEEK1, xmilcfg.MOTORVOL); |
| } | } |
| Line 736 int WINAPI WinMain(HINSTANCE hInstance, | Line 776 int WINAPI WinMain(HINSTANCE hInstance, |
| pccore_initialize(); | pccore_initialize(); |
| pccore_reset(); | pccore_reset(); |
| #if !defined(UNICODE) | |
| if (__argc > 1) { | if (__argc > 1) { |
| for (int i=1; i<__argc; i++) { | for (int i=1; i<__argc; i++) { |
| if (is_d8ufile(__argv[i])) { | if (is_d8ufile(__argv[i])) { |
| Line 745 int WINAPI WinMain(HINSTANCE hInstance, | Line 786 int WINAPI WinMain(HINSTANCE hInstance, |
| } | } |
| } | } |
| } | } |
| #endif | |
| scrndraw_redraw(); | scrndraw_redraw(); |
| xmilopening = 0; | xmilopening = 0; |
| while(1) { | while(1) { |
| if (!(xmiloscfg.background & xmilforeground)) { | if (!xmilstopemulate) { |
| if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { | if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { |
| if (!GetMessage(&msg, NULL, 0, 0)) { | if (!GetMessage(&msg, NULL, 0, 0)) { |
| break; | break; |
| } | } |
| if ((msg.message != WM_SYSKEYDOWN) && | if ((msg.hwnd != hWnd) || |
| (msg.message != WM_SYSKEYUP)) { | ((msg.message != WM_SYSKEYDOWN) && |
| (msg.message != WM_SYSKEYUP))) { | |
| TranslateMessage(&msg); | TranslateMessage(&msg); |
| } | } |
| DispatchMessage(&msg); | DispatchMessage(&msg); |
| } | } |
| else { | else { |
| if (xmiloscfg.DISPCLK) { | if (xmiloscfg.NOWAIT) { |
| if (sysmng_workclockrenewal()) { | exec1frame(); |
| sysmng_updatecaption(2); | if (xmiloscfg.DRAW_SKIP) { // nowait frame skip |
| if (framecnt >= xmiloscfg.DRAW_SKIP) { | |
| processwait(0); | |
| } | |
| } | |
| else { // nowait auto skip | |
| if (timing_getcount()) { | |
| processwait(0); | |
| } | |
| } | |
| } | |
| else if (xmiloscfg.DRAW_SKIP) { // frame skip | |
| if (framecnt < xmiloscfg.DRAW_SKIP) { | |
| exec1frame(); | |
| } | |
| else { | |
| processwait(xmiloscfg.DRAW_SKIP); | |
| } | } |
| } | } |
| if ((xmilcfg.NOWAIT) || (timing_getcount())) { | else { // auto skip |
| timing_setcount(0); | if (!waitcnt) { |
| joymng_sync(); | UINT cnt; |
| mousemng_sync(); | exec1frame(); |
| juliet2_sync(25); | cnt = timing_getcount(); |
| x1r_exec(); | if (framecnt > cnt) { |
| x1f_sync(); | waitcnt = framecnt; |
| if (framemax > 1) { | |
| framemax--; | |
| } | |
| } | |
| else if (framecnt >= framemax) { | |
| if (framemax < 12) { | |
| framemax++; | |
| } | |
| if (cnt >= 12) { | |
| timing_reset(); | |
| } | |
| else { | |
| timing_setcount(cnt - framecnt); | |
| } | |
| framereset(0); | |
| } | |
| } | |
| else { | |
| processwait(waitcnt); | |
| waitcnt = framecnt; | |
| } | |
| } | } |
| soundmng_sync(); | |
| juliet2_exec(); | |
| } | } |
| } | } |
| else { | else { // background sleep |
| if (!GetMessage(&msg, NULL, 0, 0)) { | if (!GetMessage(&msg, NULL, 0, 0)) { |
| break; | break; |
| } | } |