--- np2/macos9/np2.cpp 2003/10/23 12:58:44 1.3 +++ 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,6 +141,10 @@ static void HandleMenuChoice(long wParam pccore_reset(); break; + case IDM_CONFIGURE: + ConfigDialogProc(); + break; + case IDM_NEWDISK: dialog_newdisk(); break; @@ -244,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); @@ -252,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(); @@ -447,7 +459,12 @@ static void HandleUpdateEvent(EventRecor hWnd = (WindowPtr)pevent->message; BeginUpdate(hWnd); - scrndraw_redraw(); + if (np2running) { + scrndraw_redraw(); + } + else { + np2open(); + } EndUpdate(hWnd); } @@ -458,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: @@ -508,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; @@ -537,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); @@ -562,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); @@ -628,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(); @@ -638,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); @@ -711,7 +764,7 @@ int main(int argc, char *argv[]) { else { timing_setcount(cnt - framecnt); } - framecnt = 0; + processwait(0); } } else { @@ -725,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();