--- np2/macosx/np2.cpp 2003/10/22 19:57:39 1.11 +++ np2/macosx/np2.cpp 2003/10/23 21:00:24 1.14 @@ -26,20 +26,15 @@ #include "diskdrv.h" #include "fddfile.h" #include "statsave.h" - -#if defined(NP2GCC) #include "mousemng.h" -#endif #include "configure.h" +#include "screenopt.h" + #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, 1, 0}; WindowPtr hWndMain; BOOL np2running; @@ -261,6 +256,10 @@ static void HandleMenuChoice(long wParam break; #if defined(NP2GCC) + case IDM_SCREENOPT: + initScreenOpt(); + break; + case IDM_MOUSE: mouse_running(MOUSE_XOR); menu_setmouse(np2oscfg.MOUSE_SW ^ 1); @@ -453,6 +452,7 @@ static void HandleMenuChoice(long wParam HiliteMenu(0); } +#if 0 static void HandleUpdateEvent(EventRecord *pevent) { WindowPtr hWnd; @@ -462,6 +462,7 @@ static void HandleUpdateEvent(EventRecor scrndraw_redraw(); EndUpdate(hWnd); } +#endif static void HandleMouseDown(EventRecord *pevent) { @@ -660,7 +661,9 @@ int main(int argc, char *argv[]) { pccore_reset(); #if defined(USE_RESUME) - flagload(np2resume); + if (np2oscfg.resume) { + flagload(np2resume); + } #endif #if 0 @@ -728,7 +731,6 @@ int main(int argc, char *argv[]) { #endif pccore_exec(framecnt == 0); framecnt++; - // テスト cnt = timing_getcount(); if (framecnt > cnt) { waitcnt = framecnt; @@ -741,7 +743,7 @@ int main(int argc, char *argv[]) { framemax++; } if (cnt >= 12) { - timing_init(); + timing_reset(); } else { timing_setcount(cnt - framecnt); @@ -761,7 +763,9 @@ int main(int argc, char *argv[]) { pccore_cfgupdate(); #if defined(USE_RESUME) - flagsave(np2resume); + if (np2oscfg.resume) { + flagsave(np2resume); + } #endif pccore_term(); @@ -773,7 +777,7 @@ int main(int argc, char *argv[]) { scrnmng_destroy(); - if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) { + if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) { initsave(); } TRACETERM(); @@ -788,7 +792,7 @@ int main(int argc, char *argv[]) { } //以下、ごっそりIIxからマージ -static pascal OSStatus MyAppEventHandler (EventHandlerCallRef myHandlerChain, EventRef event, void* userData) +static pascal OSStatus np2appevent (EventHandlerCallRef myHandlerChain, EventRef event, void* userData) { UInt32 whatHappened; OSStatus result = eventNotHandledErr; @@ -804,10 +808,14 @@ static pascal OSStatus MyAppEventHandler if (IsDialogEvent(&eve)) return result; UInt32 modif; - EventMouseButton buttonKind; GetEventParameter (event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modif); + +#if defined(NP2GCC) + EventMouseButton buttonKind; GetEventParameter (event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &buttonKind); - BYTE ret; + + BYTE ret; +#endif switch (eventClass) { @@ -816,7 +824,9 @@ static pascal OSStatus MyAppEventHandler AEProcessAppleEvent(&eve); } break; + case kEventClassMouse: +#if defined(NP2GCC) switch (whatHappened) { case kEventMouseMoved: @@ -858,14 +868,22 @@ static pascal OSStatus MyAppEventHandler break; } } +#else + if (whatHappened == kEventMouseDown) { + HandleMouseDown(&eve); + } +#endif break; default: break; } + + (void)myHandlerChain; + (void)userData; return result; } -static pascal OSStatus MyWindowEventHandler(EventHandlerCallRef myHandler, EventRef event, void* userData) +static pascal OSStatus np2windowevent(EventHandlerCallRef myHandler, EventRef event, void* userData) { WindowRef window; UInt32 whatHappened; @@ -934,24 +952,37 @@ static pascal OSStatus MyWindowEventHand break; } + (void)myHandler; + (void)userData; return result; } -static void setUpCarbonEvent(void) -{ - InstallStandardEventHandler(GetWindowEventTarget(hWndMain)); - EventTypeSpec appEventList[] ={ { kEventClassAppleEvent, kEventAppleEvent }, - { kEventClassMouse, kEventMouseDown}, - { kEventClassMouse, kEventMouseMoved}, - { kEventClassMouse, kEventMouseUp} - }; - EventTypeSpec windEventList[] ={ { kEventClassWindow, kEventWindowClose}, - { kEventClassKeyboard, kEventRawKeyDown}, - { kEventClassKeyboard, kEventRawKeyUp}, - { kEventClassKeyboard, kEventRawKeyRepeat}, - { kEventClassKeyboard, kEventRawKeyModifiersChanged} - }; - InstallApplicationEventHandler(NewEventHandlerUPP(MyAppEventHandler), 4, appEventList, 0, NULL); - InstallWindowEventHandler(hWndMain, NewEventHandlerUPP(MyWindowEventHandler), 5, windEventList, 0, NULL); +static const EventTypeSpec appEventList[] = { + {kEventClassAppleEvent, kEventAppleEvent}, + {kEventClassMouse, kEventMouseDown}, +#if defined(NP2GCC) + {kEventClassMouse, kEventMouseMoved}, + {kEventClassMouse, kEventMouseUp}, +#endif + }; +static const EventTypeSpec windEventList[] = { + {kEventClassWindow, kEventWindowClose}, + {kEventClassKeyboard, kEventRawKeyDown}, + {kEventClassKeyboard, kEventRawKeyUp}, + {kEventClassKeyboard, kEventRawKeyRepeat}, + {kEventClassKeyboard, kEventRawKeyModifiersChanged}, + }; + + +static void setUpCarbonEvent(void) { + + InstallStandardEventHandler(GetWindowEventTarget(hWndMain)); + InstallApplicationEventHandler(NewEventHandlerUPP(np2appevent), + sizeof(appEventList)/sizeof(EventTypeSpec), + appEventList, 0, NULL); + InstallWindowEventHandler(hWndMain, NewEventHandlerUPP(np2windowevent), + sizeof(windEventList)/sizeof(EventTypeSpec), + windEventList, 0, NULL); } +