--- np2/macosx/np2.cpp 2003/10/16 17:59:36 1.1.1.1 +++ np2/macosx/np2.cpp 2003/10/20 10:14:27 1.7 @@ -1,5 +1,6 @@ #include "compiler.h" #include "resource.h" +#include "strres.h" #include "np2.h" #include "dosio.h" #include "scrnmng.h" @@ -26,11 +27,18 @@ #include "fddfile.h" #include "statsave.h" +#if defined(NP2GCC) +#include "mousemng.h" +#endif #define USE_RESUME +#if defined(NP2GCC) + NP2OSCFG np2oscfg = {0, 2, 0, 0, 0, 0}; +#else NP2OSCFG np2oscfg = {0, 2, 0, 0, 0}; +#endif WindowPtr hWndMain; BOOL np2running; @@ -50,6 +58,9 @@ static BYTE scrnmode; static char target[MAX_PATH] = DEFAULTPATH; +static const char np2resume[] = "sav"; + + // ---- おまじない #if TARGET_CARBON @@ -111,13 +122,11 @@ static void MenuBarInit(void) { DrawMenuBar(); } - static void changescreen(BYTE mode) { (void)mode; } - static void HandleMenuChoice(long wParam) { UINT update; @@ -459,6 +468,14 @@ static void HandleMouseDown(EventRecord break; case inContent: +#if defined(NP2GCC) + if (controlKey & GetCurrentKeyModifiers() ) { + mouse_btn(MOUSE_RIGHTDOWN); + } + else { + mouse_btn(MOUSE_LEFTDOWN); + } +#endif break; case inGoAway: @@ -481,36 +498,73 @@ static void eventproc(EventRecord *event case keyDown: case autoKey: + mackbd_f12down(((event->message) & keyCodeMask) >> 8); if (event->modifiers & cmdKey) { - if (!mackbd_down(1, ((event->message) & keyCodeMask) >> 8)) { - HandleMenuChoice(MenuKey(event->message & charCodeMask)); - } - } - else { - mackbd_down(0, ((event->message) & keyCodeMask) >> 8); + HandleMenuChoice(MenuKey(event->message & charCodeMask)); } break; case keyUp: - mackbd_up(((event->message) & keyCodeMask) >> 8); + mackbd_f12up(((event->message) & keyCodeMask) >> 8); + break; + +#if defined(NP2GCC) + case mouseUp: + if (controlKey & GetCurrentKeyModifiers()) { + mouse_btn(MOUSE_RIGHTUP); + } + else { + mouse_btn(MOUSE_LEFTUP); + } break; +#endif } } +// ---- + static void processwait(UINT waitcnt) { if (timing_getcount() >= waitcnt) { timing_setcount(0); framecnt = 0; - if (np2oscfg.DISPCLK & 2) { + if (np2oscfg.DISPCLK & 3) { if (sysmng_workclockrenewal()) { - sysmng_updatecaption(2); + sysmng_updatecaption(3); } } } } +static void getstatfilename(char *path, const char *ext, int size) { + + file_cpyname(path, file_getcd("np2"), size); + file_catname(path, str_dot, size); + file_catname(path, ext, size); +} + +static void flagsave(const char *ext) { + + char path[MAX_PATH]; + + getstatfilename(path, ext, sizeof(path)); + statsave_save(path); +} + +static void flagload(const char *ext) { + + char path[MAX_PATH]; + char buf[1024]; + int ret; + + getstatfilename(path, ext, sizeof(path)); + ret = statsave_check(path, buf, sizeof(buf)); + if (ret == NP2FLAG_SUCCESS) { + statsave_load(path); + } +} + int main(int argc, char *argv[]) { Rect wRect; @@ -525,10 +579,13 @@ int main(int argc, char *argv[]) { initload(); + TRACEINIT(); + SetRect(&wRect, 100, 100, 100, 100); hWndMain = NewWindow(0, &wRect, "\pNeko Project II", FALSE, noGrowDocProc, (WindowPtr)-1, TRUE, 0); if (!hWndMain) { + TRACETERM(); macossub_term(); dosio_term(); return(0); @@ -554,6 +611,7 @@ int main(int argc, char *argv[]) { scrnmode = 0; if (scrnmng_create(scrnmode) != SUCCESS) { + TRACETERM(); macossub_term(); dosio_term(); DisposeWindow(hWndMain); @@ -561,14 +619,20 @@ int main(int argc, char *argv[]) { } sysmng_initialize(); + mackbd_initialize(); pccore_init(); S98_init(); +#if defined(NP2GCC) + if (np2oscfg.MOUSE_SW) { // ver0.30 + mouse_running(MOUSE_ON); + } +#endif scrndraw_redraw(); pccore_reset(); #if defined(USE_RESUME) - statsave_load(":np2.sav"); + flagload(np2resume); #endif SetEventMask(everyEvent); @@ -580,6 +644,9 @@ int main(int argc, char *argv[]) { } else { if (np2oscfg.NOWAIT) { +#if defined(NP2GCC) + mouse_callback(); +#endif mackbd_callback(); pccore_exec(framecnt == 0); if (np2oscfg.DRAW_SKIP) { // nowait frame skip @@ -597,6 +664,9 @@ int main(int argc, char *argv[]) { } else if (np2oscfg.DRAW_SKIP) { // frame skip if (framecnt < np2oscfg.DRAW_SKIP) { +#if defined(NP2GCC) + mouse_callback(); +#endif mackbd_callback(); pccore_exec(framecnt == 0); framecnt++; @@ -607,6 +677,9 @@ int main(int argc, char *argv[]) { } else { // auto skip if (!waitcnt) { +#if defined(NP2GCC) + mouse_callback(); +#endif mackbd_callback(); pccore_exec(framecnt == 0); framecnt++; @@ -635,12 +708,16 @@ int main(int argc, char *argv[]) { pccore_cfgupdate(); #if defined(USE_RESUME) - statsave_save(":np2.sav"); + flagsave(np2resume); #endif pccore_term(); S98_trash(); +#if defined(NP2GCC) + mouse_running(MOUSE_OFF); +#endif + scrnmng_destroy(); if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {