--- np2/macosx/np2.cpp 2003/10/24 12:35:19 1.15 +++ np2/macosx/np2.cpp 2003/10/24 20:46:13 1.17 @@ -32,6 +32,13 @@ #define USE_RESUME +#define NP2OPENING + +#ifdef NP2OPENING +#include +#define OPENING_WAIT 1500 +#endif + NP2OSCFG np2oscfg = {0, 2, 0, 0, 0, 0, 1, 0}; @@ -162,6 +169,11 @@ static void HandleMenuChoice(long wParam newhdddisk(); break; #endif + + case IDM_FONT: + dialog_font(); + break; + case IDM_EXIT: np2running = FALSE; break; @@ -593,6 +605,55 @@ static void flagload(const char *ext) { } } +#ifdef NP2OPENING +static void openingNP2(void) { + Rect srt, bounds; + GrafPtr port; + CFURLRef openingURL; + CFStringRef path; + char buffer[1024]; + FSRef fsr; + FSSpec fsc; + PicHandle pict; + GraphicsImportComponent gi; + + GetPort(&port); + SetPortWindowPort(hWndMain); + const RGBColor col = {0, 0, 0}; + SetRect(&bounds, 0, 0, 640, 400); + RGBBackColor(&col); + EraseRect(&bounds); + + openingURL=CFURLCopyAbsoluteURL(CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle())); + if (openingURL) { + path = CFURLCopyFileSystemPath(openingURL, kCFURLPOSIXPathStyle); + if (path) { + if (CFStringGetCString(path, buffer, 1024, CFStringGetSystemEncoding())) { + strcat(buffer, "/nekop2.bmp"); + FSPathMakeRef((const UInt8*)buffer, &fsr, NULL); + FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, &fsc, NULL); + if (!GetGraphicsImporterForFile(&fsc, &gi)) { + if (!GraphicsImportGetNaturalBounds(gi, &srt)) { + OffsetRect( &srt, -srt.left, -srt.top); + GraphicsImportSetBoundsRect(gi, &srt); + GraphicsImportGetAsPicture(gi, &pict); + OffsetRect(&srt, (640-srt.right)/2, (400-srt.bottom)/2); + DrawPicture(pict,&srt); + QDFlushPortBuffer(GetWindowPort(hWndMain), NULL); + KillPicture(pict); + } + CloseComponent(gi); + } + } + if (path) CFRelease(path); + } + if (openingURL) CFRelease(openingURL); + } + SetPort(port); +} +#endif + + int main(int argc, char *argv[]) { Rect wRect; @@ -601,6 +662,9 @@ int main(int argc, char *argv[]) { #endif EventRef theEvent; EventTargetRef theTarget; +#ifdef OPENING_WAIT + UINT32 tick; +#endif dosio_init(); file_setcd(target); @@ -626,6 +690,12 @@ int main(int argc, char *argv[]) { SizeWindow(hWndMain, 640, 400, TRUE); setUpCarbonEvent(); ShowWindow(hWndMain); +#ifdef NP2OPENING + openingNP2(); +#endif +#ifdef OPENING_WAIT + tick = GETTICK(); +#endif menu_setrotate(0); menu_setdispmode(np2cfg.DISPSYNC); @@ -661,6 +731,9 @@ int main(int argc, char *argv[]) { mouse_running(MOUSE_ON); } #endif +#ifdef OPENING_WAIT + while((GETTICK() - tick) < OPENING_WAIT); +#endif scrndraw_redraw(); pccore_reset(); @@ -875,7 +948,7 @@ static pascal OSStatus np2windowevent(Ev UInt32 whatHappened; OSStatus result = eventNotHandledErr; long eventClass; - + static UInt32 backup = 0; GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(window), NULL, &window); @@ -907,9 +980,9 @@ static pascal OSStatus np2windowevent(Ev break; case kEventRawKeyDown: if (modif & cmdKey) { - char para; - GetEventParameter (event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, ¶); - HandleMenuChoice(MenuKey(para)); + EventRecord eve; + ConvertEventRefToEventRecord( event,&eve ); + HandleMenuChoice(MenuEvent(&eve)); } else { mackbd_f12down(key); @@ -923,7 +996,10 @@ static pascal OSStatus np2windowevent(Ev else keystat_senddata(0x73 | 0x80); if (modif & controlKey) keystat_senddata(0x74); else keystat_senddata(0x74 | 0x80); - if (modif & alphaLock) keystat_senddata(0x71); + if ((modif & alphaLock) != (backup & alphaLock)) { + keystat_senddata(0x71); + backup = modif; + } result = noErr; break; default: @@ -960,10 +1036,10 @@ static void setUpCarbonEvent(void) { InstallStandardEventHandler(GetWindowEventTarget(hWndMain)); InstallApplicationEventHandler(NewEventHandlerUPP(np2appevent), - sizeof(appEventList)/sizeof(EventTypeSpec), + GetEventTypeCount(appEventList), appEventList, 0, NULL); InstallWindowEventHandler(hWndMain, NewEventHandlerUPP(np2windowevent), - sizeof(windEventList)/sizeof(EventTypeSpec), + GetEventTypeCount(windEventList), windEventList, 0, NULL); }