|
|
| version 1.3, 2004/08/03 11:02:00 | version 1.17, 2004/08/12 18:22:54 |
|---|---|
| Line 10 | Line 10 |
| #include "scrnmng.h" | #include "scrnmng.h" |
| #include "soundmng.h" | #include "soundmng.h" |
| #include "sysmng.h" | #include "sysmng.h" |
| #include "scrndraw.h" | |
| #include "ddrawbmp.h" | #include "ddrawbmp.h" |
| #include "winloc.h" | #include "winloc.h" |
| #include "dclock.h" | #include "dclock.h" |
| #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" | #if defined(SUPPORT_RESUME) || defined(SUPPORT_STATSAVE) |
| #include "fdd_ini.h" | #include "statsave.h" |
| #include "juliet.h" | #endif |
| #include "diskdrv.h" | |
| #include "debugsub.h" | #include "debugsub.h" |
| #include "scrndraw.h" | |
| #include "makescrn.h" | |
| #include "diskdrv.h" | |
| #include "fdd_ini.h" | |
| #include "x1f.h" | #include "x1f.h" |
| Line 37 static const OEMCHAR szClassName[] = OEM | Line 38 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, |
| #if defined(SUPPORT_RESUME) | |
| 0, | |
| #endif | |
| #if defined(SUPPORT_STATSAVE) | |
| 1, | |
| #endif | |
| 0, 0, 0xffffff, 0xffbf6a}; | 0, 0, 0xffffff, 0xffbf6a}; |
| OEMCHAR szProgName[] = OEMTEXT("X millennium ねこちゅ〜ん"); | OEMCHAR szProgName[] = OEMTEXT("X millennium ねこちゅ〜ん"); |
| 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 98 static void dispbmp(HINSTANCE hinst, HDC | Line 106 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 109 static void dispbmp(HINSTANCE hinst, HDC | Line 117 static void dispbmp(HINSTANCE hinst, HDC |
| // ---- | // ---- |
| LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { | #if defined(SUPPORT_RESUME) || defined(SUPPORT_STATSAVE) |
| static const OEMCHAR xmilresumeext[] = OEMTEXT(".sav"); | |
| #endif | |
| #if defined(SUPPORT_STATSAVE) | |
| static const OEMCHAR xmilflagext[] = OEMTEXT(".sv%u"); | |
| static const OEMCHAR str_statload[] = OEMTEXT("Status Load"); | |
| #endif | |
| PAINTSTRUCT ps; | #if defined(SUPPORT_RESUME) || defined(SUPPORT_STATSAVE) |
| RECT rc; | |
| HDC hdc; | |
| UINT updateflag; | |
| switch (msg) { | static const OEMCHAR str_loaderr[] = OEMTEXT("Couldn't restart"); |
| case WM_CREATE: | static const OEMCHAR str_conflict[] = OEMTEXT("Conflict!\n\n%s\nContinue?"); |
| extclass_wmcreate(hWnd); | |
| #ifndef __GNUC__ | static void getstatfilename(OEMCHAR *path, const OEMCHAR *ext, UINT size) { |
| WINNLSEnableIME(hWnd, FALSE); | |
| file_cpyname(path, modulefile, size); | |
| file_cutext(path); | |
| file_catname(path, ext, size); | |
| } | |
| static int flagsave(const OEMCHAR *ext) { | |
| OEMCHAR path[MAX_PATH]; | |
| int ret; | |
| getstatfilename(path, ext, NELEMENTS(path)); | |
| soundmng_stop(); | |
| ret = statsave_save(path); | |
| if (ret) { | |
| file_delete(path); | |
| } | |
| soundmng_play(); | |
| return(ret); | |
| } | |
| static void flagdelete(const OEMCHAR *ext) { | |
| OEMCHAR path[MAX_PATH]; | |
| getstatfilename(path, ext, NELEMENTS(path)); | |
| file_delete(path); | |
| } | |
| static int flagload(const OEMCHAR *ext, const OEMCHAR *title, BOOL force) { | |
| int ret; | |
| int id; | |
| OEMCHAR path[MAX_PATH]; | |
| OEMCHAR buf[1024]; | |
| OEMCHAR buf2[1024 + 32]; | |
| getstatfilename(path, ext, NELEMENTS(path)); | |
| winuienter(); | |
| id = IDYES; | |
| ret = statsave_check(path, buf, NELEMENTS(buf)); | |
| if (ret & (~STATFLAG_DISKCHG)) { | |
| MessageBox(hWndMain, str_loaderr, title, MB_OK | MB_ICONSTOP); | |
| id = IDNO; | |
| } | |
| else if ((!force) && (ret & STATFLAG_DISKCHG)) { | |
| OEMSPRINTF(buf2, str_conflict, buf); | |
| id = MessageBox(hWndMain, buf2, title, | |
| MB_YESNOCANCEL | MB_ICONQUESTION); | |
| } | |
| if (id == IDYES) { | |
| statsave_load(path); | |
| // toolwin_setfdd(0, fdd_diskname(0)); | |
| // toolwin_setfdd(1, fdd_diskname(1)); | |
| } | |
| sysmng_workclockreset(); | |
| sysmng_updatecaption(1); | |
| winuileave(); | |
| return(id); | |
| } | |
| #endif | #endif |
| // ---- | |
| static void xmilcmd(HWND hWnd, UINT cmd) { | |
| UINT update; | |
| OEMCHAR ext[16]; | |
| update = 0; | |
| switch(cmd) { | |
| case IDM_IPLRESET: | |
| pccore_reset(); | |
| break; | break; |
| case WM_SYSCOMMAND: | case IDM_NMIRESET: |
| updateflag = 0; | Z80_NMI(); |
| switch(wParam) { | break; |
| case IDM_SCREENCENTER: | |
| if (!scrnmng_isfullscreen()) { | |
| wincentering(hWnd); | |
| } | |
| break; | |
| case IDM_SNAPENABLE: | case IDM_CONFIG: |
| sysmenu_setwinsnap(xmiloscfg.WINSNAP ^ 1); | winuienter(); |
| updateflag = SYS_UPDATEOSCFG; | DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), |
| break; | hWnd, (DLGPROC)CfgDialogProc); |
| winuileave(); | |
| break; | |
| case IDM_BACKGROUND: | case IDM_NEWDISK: |
| sysmenu_setbackground(xmiloscfg.background ^ 1); | winuienter(); |
| updateflag = SYS_UPDATEOSCFG; | dialog_newdisk(hWnd); |
| break; | winuileave(); |
| break; | |
| case IDM_BGSOUND: | case IDM_EXIT: |
| sysmenu_setbgsound(xmiloscfg.background ^ 2); | SendMessage(hWnd, WM_CLOSE, 0, 0L); |
| updateflag = SYS_UPDATEOSCFG; | break; |
| break; | |
| default: | case IDM_FDD0OPEN: |
| return(DefWindowProc(hWnd, msg, wParam, lParam)); | winuienter(); |
| } | dialog_changefdd(hWnd, 0); |
| sysmng_update(updateflag); | winuileave(); |
| break; | break; |
| case WM_COMMAND: | case IDM_FDD0EJECT: |
| updateflag = 0; | diskdrv_setfdd(0, NULL, 0); |
| switch(LOWORD(wParam)) { | break; |
| case IDM_IPLRESET: | |
| #if 1 | |
| pccore_reset(); | |
| #else | |
| if ((!juliet_YM2151IsEnable()) && (changehz)) { | |
| changehz = 0; | |
| STREAM_TERM(); | |
| STREAM_CREATE(); | |
| } | |
| if (reset_x1(xmilcfg.ROM_TYPE, | |
| xmilcfg.SOUND_SW, xmilcfg.DIP_SW)) { | |
| PostQuitMessage(0); | |
| } | |
| #endif | |
| break; | |
| case IDM_NMIRESET: | case IDM_FDD1OPEN: |
| Z80_NMI(); | winuienter(); |
| break; | dialog_changefdd(hWnd, 1); |
| winuileave(); | |
| break; | |
| case IDM_CONFIG: | case IDM_FDD1EJECT: |
| winuienter(); | diskdrv_setfdd(1, NULL, 0); |
| DialogBox(hInst, MAKEINTRESOURCE(IDD_CONFIG), | break; |
| hWnd, (DLGPROC)CfgDialogProc); | |
| winuileave(); | |
| break; | |
| case IDM_NEWDISK: | case IDM_TURBOZ: |
| winuienter(); | menu_setiplrom(3); |
| dialog_newdisk(hWnd); | update = SYS_UPDATECFG; |
| winuileave(); | break; |
| break; | |
| case IDM_EXIT: | case IDM_TURBO: |
| SendMessage(hWnd, WM_CLOSE, 0, 0L); | menu_setiplrom(2); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_FDD0OPEN: | case IDM_X1ROM: |
| winuienter(); | menu_setiplrom(1); |
| dialog_changefdd(hWnd, 0); | update = SYS_UPDATECFG; |
| winuileave(); | break; |
| break; | |
| case IDM_FDD0EJECT: | case IDM_BOOT2D: |
| diskdrv_setfdd(0, NULL, 0); | menu_setbootmedia(0); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_FDD1OPEN: | case IDM_BOOT2HD: |
| winuienter(); | menu_setbootmedia(DIPSW_BOOTMEDIA); |
| dialog_changefdd(hWnd, 1); | update = SYS_UPDATECFG; |
| winuileave(); | break; |
| break; | |
| case IDM_FDD1EJECT: | case IDM_HIGHRES: |
| diskdrv_setfdd(1, NULL, 0); | menu_setresolute(0); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_TURBOZ: | case IDM_LOWRES: |
| xmenu_setiplrom(3); | menu_setresolute(DIPSW_RESOLUTE); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_TURBO: | case IDM_WINDOW: |
| xmenu_setiplrom(2); | scrnmng_changescreen(scrnmode & (~SCRNMODE_FULLSCREEN)); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_X1ROM: | case IDM_FULLSCREEN: |
| xmenu_setiplrom(1); | scrnmng_changescreen(scrnmode | SCRNMODE_FULLSCREEN); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_BOOT2D: | case IDM_WIDTH80: |
| xmenu_setbootmedia(0); | crtc_forcesetwidth(80); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_BOOT2HD: | case IDM_WIDTH40: |
| xmenu_setbootmedia(DIPSW_BOOTMEDIA); | crtc_forcesetwidth(40); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_HIGHRES: | case IDM_DISPSYNC: |
| xmenu_setresolute(0); | menu_setdispmode(xmilcfg.DISPSYNC ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_LOWRES: | case IDM_RASTER: |
| xmenu_setresolute(DIPSW_RESOLUTE); | menu_setraster(xmilcfg.RASTER ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_WINDOW: | case IDM_NOWAIT: |
| scrnmng_changescreen(scrnmode & (~SCRNMODE_FULLSCREEN)); | menu_setwaitflg(xmiloscfg.NOWAIT ^ 1); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_FULLSCREEN: | case IDM_AUTOFPS: |
| scrnmng_changescreen(scrnmode | SCRNMODE_FULLSCREEN); | menu_setframe(0); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_WIDTH80: | case IDM_60FPS: |
| crtc.TXT_XL = 80; | menu_setframe(1); |
| crtc.GRP_XL = 640; | update = SYS_UPDATECFG; |
| vrambank_patch(); | break; |
| scrnallflash = 1; | |
| break; | |
| case IDM_WIDTH40: | case IDM_30FPS: |
| crtc.TXT_XL = 40; | menu_setframe(2); |
| crtc.GRP_XL = 320; | update = SYS_UPDATECFG; |
| vrambank_patch(); | break; |
| scrnallflash = 1; | |
| break; | |
| case IDM_DISPSYNC: | case IDM_20FPS: |
| xmenu_setdispmode(xmilcfg.DISPSYNC ^ 1); | menu_setframe(3); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_NOWAIT: | case IDM_15FPS: |
| xmenu_setwaitflg(xmilcfg.NOWAIT ^ 1); | menu_setframe(4); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_RASTER: | case IDM_KEY: |
| xmenu_setframe(0); | menu_setkey(0); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_60FPS: | case IDM_JOY1: |
| xmenu_setframe(1); | menu_setkey(1); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_30FPS: | case IDM_JOY2: |
| xmenu_setframe(2); | menu_setkey(2); |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_20FPS: | case IDM_FMBOARD: |
| xmenu_setframe(3); | menu_setsound(xmilcfg.SOUND_SW ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_15FPS: | case IDM_JOYSTICK: |
| xmenu_setframe(4); | menu_setjoystick(xmiloscfg.JOYSTICK ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_KEY: | case IDM_MOUSE: |
| xmenu_setkey(0); | // mousemng_toggle(MOUSEPROC_SYSTEM); |
| break; | menu_setmouse(xmilcfg.MOUSE_SW ^ 1); |
| update = SYS_UPDATECFG; | |
| break; | |
| case IDM_JOY1: | case IDM_SEEKSND: |
| xmenu_setkey(1); | menu_setmotorflg(xmilcfg.MOTOR ^ 1); |
| break; | update = SYS_UPDATECFG; |
| break; | |
| case IDM_JOY2: | case IDM_BMPSAVE: |
| xmenu_setkey(2); | winuienter(); |
| break; | bmpsave(); |
| winuileave(); | |
| break; | |
| case IDM_FMBOARD: | case IDM_OPMLOG: |
| xmenu_setsound(xmilcfg.SOUND_SW ^ 1); | winuienter(); |
| updateflag = SYS_UPDATECFG; | dialog_x1f(hWnd); |
| break; | winuileave(); |
| break; | |
| case IDM_JOYSTICK: | case IDM_DISPCLOCK: |
| xmenu_setjoystick(xmiloscfg.JOYSTICK ^ 1); | menu_setdispclk(xmiloscfg.DISPCLK ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_MOUSE: | case IDM_DISPFRAME: |
| // mousemng_toggle(MOUSEPROC_SYSTEM); | menu_setdispclk(xmiloscfg.DISPCLK ^ 2); |
| xmenu_setmouse(xmilcfg.MOUSE_SW ^ 1); | update = SYS_UPDATECFG; |
| updateflag = SYS_UPDATECFG; | break; |
| break; | |
| case IDM_8MHZ: | case IDM_JOYX: |
| xmenu_setcpuspeed(xmilcfg.CPU8MHz ^ 1); | menu_setbtnmode(xmilcfg.BTN_MODE ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_SEEKSND: | case IDM_RAPID: |
| xmenu_setmotorflg(xmilcfg.MOTOR ^ 1); | menu_setbtnrapid(xmilcfg.BTN_RAPID ^ 1); |
| updateflag = SYS_UPDATECFG; | update = SYS_UPDATECFG; |
| break; | break; |
| case IDM_BMPSAVE: | case IDM_Z80SAVE: |
| winuienter(); | debugsub_status(); |
| bmpsave(); | break; |
| winuileave(); | |
| break; | |
| case IDM_OPMLOG: | case IDM_ABOUT: |
| winuienter(); | winuienter(); |
| dialog_x1f(hWnd); | DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), |
| winuileave(); | hWnd, (DLGPROC)AboutDialogProc); |
| break; | winuileave(); |
| break; | |
| case IDM_DISPCLOCK: | default: |
| xmenu_setdispclk(xmiloscfg.DISPCLK ^ 1); | #if defined(SUPPORT_STATSAVE) |
| updateflag = SYS_UPDATECFG; | if ((cmd >= IDM_FLAGSAVE) && |
| break; | (cmd < (IDM_FLAGSAVE + SUPPORT_STATSAVE))) { |
| OEMSPRINTF(ext, xmilflagext, cmd - IDM_FLAGSAVE); | |
| flagsave(ext); | |
| } | |
| else if ((cmd >= IDM_FLAGLOAD) && | |
| (cmd < (IDM_FLAGLOAD + SUPPORT_STATSAVE))) { | |
| OEMSPRINTF(ext, xmilflagext, cmd - IDM_FLAGLOAD); | |
| flagload(ext, str_statload, TRUE); | |
| } | |
| #endif | |
| break; | |
| } | |
| sysmng_update(update); | |
| } | |
| case IDM_DISPFRAME: | LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
| xmenu_setdispclk(xmiloscfg.DISPCLK ^ 2); | |
| updateflag = SYS_UPDATECFG; | |
| break; | |
| case IDM_SKIPLINE: | PAINTSTRUCT ps; |
| xmenu_setskipline(xmilcfg.SKIP_LINE ^ 1); | RECT rc; |
| updateflag = SYS_UPDATECFG; | HDC hdc; |
| break; | UINT updateflag; |
| case IDM_JOYX: | switch (msg) { |
| xmenu_setbtnmode(xmilcfg.BTN_MODE ^ 1); | case WM_CREATE: |
| updateflag = SYS_UPDATECFG; | extclass_wmcreate(hWnd); |
| break; | #ifndef __GNUC__ |
| WINNLSEnableIME(hWnd, FALSE); | |
| #endif | |
| break; | |
| case IDM_RAPID: | case WM_SYSCOMMAND: |
| xmenu_setbtnrapid(xmilcfg.BTN_RAPID ^ 1); | updateflag = 0; |
| updateflag = SYS_UPDATECFG; | switch(wParam) { |
| case IDM_SCREENCENTER: | |
| if (!scrnmng_isfullscreen()) { | |
| wincentering(hWnd); | |
| } | |
| break; | break; |
| case IDM_HALFBMP: | case IDM_SNAPENABLE: |
| winuienter(); | sysmenu_setwinsnap(xmiloscfg.WINSNAP ^ 1); |
| bmpsavehalf(); | updateflag = SYS_UPDATEOSCFG; |
| winuileave(); | |
| break; | break; |
| case IDM_Z80SAVE: | case IDM_BACKGROUND: |
| debugsub_status(); | sysmenu_setbackground(xmiloscfg.background ^ 1); |
| updateflag = SYS_UPDATEOSCFG; | |
| break; | break; |
| case IDM_ABOUT: | case IDM_BGSOUND: |
| winuienter(); | sysmenu_setbgsound(xmiloscfg.background ^ 2); |
| DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), | updateflag = SYS_UPDATEOSCFG; |
| hWnd, (DLGPROC)AboutDialogProc); | |
| winuileave(); | |
| break; | break; |
| default: | |
| return(DefWindowProc(hWnd, msg, wParam, lParam)); | |
| } | } |
| sysmng_update(updateflag); | sysmng_update(updateflag); |
| break; | break; |
| case WM_COMMAND: | |
| xmilcmd(hWnd, LOWORD(wParam)); | |
| break; | |
| 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 434 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 516 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 498 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 580 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| case WM_KEYDOWN: | case WM_KEYDOWN: |
| if (wParam == VK_F12) { | if (wParam == VK_F12) { |
| mousemng_toggle(MOUSEPROC_SYSTEM); | mousemng_toggle(MOUSEPROC_SYSTEM); |
| // xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1); | // menu_setmouse(np2oscfg.MOUSE_SW ^ 1); |
| // sysmng_update(SYS_UPDATECFG); | // sysmng_update(SYS_UPDATECFG); |
| } | } |
| else { | else { |
| Line 578 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 660 LRESULT CALLBACK WndProc(HWND hWnd, UINT |
| case WM_MBUTTONDOWN: | case WM_MBUTTONDOWN: |
| mousemng_toggle(MOUSEPROC_SYSTEM); | mousemng_toggle(MOUSEPROC_SYSTEM); |
| // xmenu_setmouse(np2oscfg.MOUSE_SW ^ 1); | // menu_setmouse(np2oscfg.MOUSE_SW ^ 1); |
| // sysmng_update(SYS_UPDATECFG); | // sysmng_update(SYS_UPDATECFG); |
| break; | break; |
| Line 629 LRESULT CALLBACK WndProc(HWND hWnd, UINT | Line 711 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 636 int WINAPI WinMain(HINSTANCE hInstance, | Line 759 int WINAPI WinMain(HINSTANCE hInstance, |
| WNDCLASS wc; | WNDCLASS wc; |
| MSG msg; | MSG msg; |
| GetModuleFileName(NULL, modulefile, sizeof(modulefile)); | |
| dosio_init(); | |
| file_setcd(modulefile); | |
| initload(); | |
| hWnd = FindWindow(szClassName, NULL); | hWnd = FindWindow(szClassName, NULL); |
| if (hWnd != NULL) { | if (hWnd != NULL) { |
| ShowWindow(hWnd, SW_RESTORE); | ShowWindow(hWnd, SW_RESTORE); |
| SetForegroundWindow(hWnd); | SetForegroundWindow(hWnd); |
| dosio_term(); | |
| return(FALSE); | return(FALSE); |
| } | } |
| file_setcd(__argv[0]); | |
| initload(); | |
| hInst = hInstance; | hInst = hInstance; |
| hPreI = hPreInst; | hPreI = hPreInst; |
| TRACEINIT(); | TRACEINIT(); |
| // keystat_initialize(); | |
| if (!hPreInst) { | if (!hPreInst) { |
| wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW; | wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW; |
| wc.lpfnWndProc = WndProc; | wc.lpfnWndProc = WndProc; |
| Line 673 int WINAPI WinMain(HINSTANCE hInstance, | Line 801 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(); |
| sysmng_updatecaption(3); | menu_setiplrom(xmilcfg.ROM_TYPE); |
| menu_setbootmedia(xmilcfg.DIP_SW); | |
| xmenu_setiplrom(xmilcfg.ROM_TYPE); | menu_setresolute(xmilcfg.DIP_SW); |
| xmenu_setsound(xmilcfg.SOUND_SW); | menu_setdispmode(xmilcfg.DISPSYNC); |
| xmenu_setskipline(xmilcfg.SKIP_LINE); | menu_setraster(xmilcfg.RASTER); |
| xmenu_setresolute(xmilcfg.DIP_SW); | menu_setwaitflg(xmiloscfg.NOWAIT); |
| xmenu_setbootmedia(xmilcfg.DIP_SW); | menu_setframe(xmiloscfg.DRAW_SKIP); |
| xmenu_setkey(0); | menu_setkey(0); |
| xmenu_setbtnrapid(xmilcfg.BTN_RAPID); | menu_setsound(xmilcfg.SOUND_SW); |
| xmenu_setbtnmode(xmilcfg.BTN_MODE); | menu_setjoystick(xmiloscfg.JOYSTICK); |
| xmenu_setcpuspeed(xmilcfg.CPU8MHz); | menu_setmouse(xmilcfg.MOUSE_SW); |
| xmenu_setwaitflg(xmilcfg.NOWAIT); | menu_setmotorflg(xmilcfg.MOTOR); |
| xmenu_setframe(xmilcfg.DRAW_SKIP); | menu_setdispclk(xmiloscfg.DISPCLK); |
| xmenu_setmotorflg(xmilcfg.MOTOR); | menu_setbtnmode(xmilcfg.BTN_MODE); |
| xmenu_setz80save(xmiloscfg.Z80SAVE); | menu_setbtnrapid(xmilcfg.BTN_RAPID); |
| xmenu_setjoystick(xmiloscfg.JOYSTICK); | |
| xmenu_setdispclk(xmiloscfg.DISPCLK); | |
| xmenu_setdispmode(xmilcfg.DISPSYNC); | |
| xmenu_setmouse(xmilcfg.MOUSE_SW); | |
| ShowWindow(hWnd, nCmdShow); | ShowWindow(hWnd, nCmdShow); |
| UpdateWindow(hWnd); | UpdateWindow(hWnd); |
| sysmenu_initialize(); | sysmenu_initialize(); |
| // xmenu_initialize(); | menu_initialize(); |
| DrawMenuBar(hWnd); | DrawMenuBar(hWnd); |
| sysmenu_setwinsnap(xmiloscfg.WINSNAP); | sysmenu_setwinsnap(xmiloscfg.WINSNAP); |
| Line 714 int WINAPI WinMain(HINSTANCE hInstance, | Line 838 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); |
| } | } |
| } | } |
| joymng_initialize(); | |
| 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); |
| } | } |
| sysmng_initialize(); | |
| joymng_initialize(); | |
| 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 744 int WINAPI WinMain(HINSTANCE hInstance, | Line 870 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); | |
| } | |
| } | } |
| } | } |
| if ((xmilcfg.NOWAIT) || (timing_getcount())) { | else if (xmiloscfg.DRAW_SKIP) { // frame skip |
| timing_setcount(0); | if (framecnt < xmiloscfg.DRAW_SKIP) { |
| joymng_sync(); | exec1frame(); |
| mousemng_sync(); | } |
| juliet2_sync(25); | else { |
| x1r_exec(); | processwait(xmiloscfg.DRAW_SKIP); |
| x1f_sync(); | } |
| } | |
| else { // auto skip | |
| if (!waitcnt) { | |
| UINT cnt; | |
| exec1frame(); | |
| cnt = timing_getcount(); | |
| if (framecnt > cnt) { | |
| 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; |
| } | } |