--- np2/macos9/np2.cpp 2003/10/23 07:20:43 1.1 +++ np2/macos9/np2.cpp 2003/10/25 16:01:21 1.9 @@ -3,6 +3,7 @@ #include "strres.h" #include "np2.h" #include "dosio.h" +#include "commng.h" #include "scrnmng.h" #include "soundmng.h" #include "sysmng.h" @@ -10,6 +11,7 @@ #include "mackbd.h" #include "ini.h" #include "menu.h" +#include "np2open.h" #include "dialog.h" #include "memory.h" #include "pccore.h" @@ -34,11 +36,7 @@ #define USE_RESUME -#if defined(NP2GCC) - NP2OSCFG np2oscfg = {0, 2, 0, 0, 0, 0}; -#else - NP2OSCFG np2oscfg = {0, 2, 0, 0, 0}; -#endif + NP2OSCFG np2oscfg = {0, 2, 0, 0, 0, 0}; WindowPtr hWndMain; BOOL np2running; @@ -143,16 +141,18 @@ static void HandleMenuChoice(long wParam pccore_reset(); break; -#if 0 - case IDM_NEWFDD: - newdisk(); + case IDM_CONFIGURE: + ConfigDialogProc(); break; -#endif -#if 0 - case IDM_NEWHDD: - newhdddisk(); + + case IDM_NEWDISK: + dialog_newdisk(); break; -#endif + + case IDM_FONT: + dialog_font(); + break; + case IDM_EXIT: np2running = FALSE; break; @@ -246,6 +246,10 @@ static void HandleMenuChoice(long wParam update |= SYS_UPDATECFG; break; + case IDM_SCREENOPT: + dialog_scropt(); + break; + #if defined(NP2GCC) case IDM_MOUSE: mouse_running(MOUSE_XOR); @@ -254,6 +258,12 @@ static void HandleMenuChoice(long wParam break; #endif + case IDM_MIDIPANIC: + rs232c_midipanic(); + mpu98ii_midipanic(); + pc9861k_midipanic(); + break; + case IDM_KEY: menu_setkey(0); keystat_resetjoykey(); @@ -401,6 +411,10 @@ static void HandleMenuChoice(long wParam update |= SYS_UPDATECFG; break; + case IDM_BMPSAVE: + dialog_writebmp(); + break; + case IDM_DISPCLOCK: menu_setdispclk(np2oscfg.DISPCLK ^ 1); update |= SYS_UPDATECFG; @@ -445,7 +459,12 @@ static void HandleUpdateEvent(EventRecor hWnd = (WindowPtr)pevent->message; BeginUpdate(hWnd); - scrndraw_redraw(); + if (np2running) { + scrndraw_redraw(); + } + else { + np2open(); + } EndUpdate(hWnd); } @@ -456,7 +475,11 @@ static void HandleMouseDown(EventRecord switch(FindWindow(pevent->where, &hWnd)) { case inMenuBar: - HandleMenuChoice(MenuSelect(pevent->where)); + if (np2running) { + soundmng_stop(); + HandleMenuChoice(MenuSelect(pevent->where)); + soundmng_play(); + } break; case inDrag: @@ -506,9 +529,13 @@ static void eventproc(EventRecord *event case keyDown: case autoKey: - mackbd_f12down(((event->message) & keyCodeMask) >> 8); - if (event->modifiers & cmdKey) { - HandleMenuChoice(MenuKey(event->message & charCodeMask)); + if (np2running) { + mackbd_f12down(((event->message) & keyCodeMask) >> 8); + if (event->modifiers & cmdKey) { + soundmng_stop(); + HandleMenuChoice(MenuKey(event->message & charCodeMask)); + soundmng_play(); + } } break; @@ -535,8 +562,8 @@ static void eventproc(EventRecord *event static void processwait(UINT waitcnt) { if (timing_getcount() >= waitcnt) { - timing_setcount(0); framecnt = 0; + timing_setcount(0); if (np2oscfg.DISPCLK & 3) { if (sysmng_workclockrenewal()) { sysmng_updatecaption(3); @@ -560,23 +587,42 @@ static void flagsave(const char *ext) { statsave_save(path); } -static void flagload(const char *ext) { +static void flagdelete(const char *ext) { char path[MAX_PATH]; - char buf[1024]; + + getstatfilename(path, ext, sizeof(path)); + file_delete(path); +} + +static int flagload(const char *ext) { + int ret; + char path[MAX_PATH]; + char buf[1024]; + int r; + ret = IDOK; getstatfilename(path, ext, sizeof(path)); - ret = statsave_check(path, buf, sizeof(buf)); - if (ret == NP2FLAG_SUCCESS) { + r = statsave_check(path, buf, sizeof(buf)); + if (r & (~NP2FLAG_DISKCHG)) { + ResumeErrorDialogProc(); + ret = IDCANCEL; + } + else if (r & NP2FLAG_DISKCHG) { + ret = ResumeWarningDialogProc(buf); + } + if (ret == IDOK) { statsave_load(path); } + return(ret); } int main(int argc, char *argv[]) { Rect wRect; EventRecord event; + UINT t; dosio_init(); file_setcd(target); @@ -626,6 +672,15 @@ int main(int argc, char *argv[]) { return(0); } + np2open(); + t = GETTICK(); + while((GETTICK() - t) < 100) { + if (WaitNextEvent(everyEvent, &event, 0, 0)) { + eventproc(&event); + } + } + + commng_initialize(); sysmng_initialize(); mackbd_initialize(); pccore_init(); @@ -636,12 +691,12 @@ int main(int argc, char *argv[]) { mouse_running(MOUSE_ON); } #endif - scrndraw_redraw(); +// scrndraw_redraw(); pccore_reset(); -#if defined(USE_RESUME) - flagload(np2resume); -#endif + if (np2oscfg.resume) { + flagload(np2resume); + } SetEventMask(everyEvent); @@ -692,7 +747,6 @@ int main(int argc, char *argv[]) { mackbd_callback(); pccore_exec(framecnt == 0); framecnt++; - // ¥Æ¥¹¥È cnt = timing_getcount(); if (framecnt > cnt) { waitcnt = framecnt; @@ -705,12 +759,12 @@ int main(int argc, char *argv[]) { framemax++; } if (cnt >= 12) { - timing_init(); + timing_reset(); } else { timing_setcount(cnt - framecnt); } - framecnt = 0; + processwait(0); } } else { @@ -724,9 +778,12 @@ int main(int argc, char *argv[]) { pccore_cfgupdate(); -#if defined(USE_RESUME) - flagsave(np2resume); -#endif + if (np2oscfg.resume) { + flagsave(np2resume); + } + else { + flagdelete(np2resume); + } pccore_term(); S98_trash();