--- np2/macosx/np2.cpp 2003/10/28 16:44:44 1.23 +++ np2/macosx/np2.cpp 2003/11/03 10:19:43 1.27 @@ -34,15 +34,15 @@ #include "macnewdisk.h" #include "fdefine.h" #include "hid.h" +#include "midiopt.h" +#include "macalert.h" +#include "np2opening.h" +#include "toolmac.h" +#include #define USE_RESUME #define NP2OPENING - -#ifdef NP2OPENING -#include // #define OPENING_WAIT 1500 -#endif - NP2OSCFG np2oscfg = {0, 2, 0, 0, 0, 0, 1, 0}; @@ -52,7 +52,7 @@ static UINT framecnt = 0; static UINT waitcnt = 0; static UINT framemax = 1; -static BYTE scrnmode; + BYTE scrnmode; #define DRAG_THRESHOLD 5 @@ -93,21 +93,12 @@ pascal OSErr OpenAppleEventHandler(const AEKeyword key; AEDescList dlist; - if( ! AEGetParamDesc( event,keyDirectObject,typeAEList,&dlist ) ) { + if(!AEGetParamDesc(event,keyDirectObject,typeAEList,&dlist)) { AECountItems( &dlist,&ct ); for( i=1;i<=ct;i++ ) { pp=&fsc; - if( ! AEGetNthPtr( &dlist,i,typeFSS,&key,&rtype,(Ptr)pp,(long)sizeof(FSSpec),&len ) ) { - char fname[MAX_PATH]; - int ftype; - fsspec2path(&fsc, fname, MAX_PATH); - ftype = file_getftype(fname); - if ((ftype != FTYPE_D88) && (ftype != FTYPE_BETA)) { - diskdrv_sethdd(0, fname); - } - else { - diskdrv_setfdd(i-1, fname, 0); - } + if (!AEGetNthPtr( &dlist,i,typeFSS,&key,&rtype,(Ptr)pp,(long)sizeof(FSSpec),&len)) { + setDropFile(fsc, i-1); } } AEDisposeDesc( &dlist ); @@ -146,6 +137,9 @@ static void MenuBarInit(void) { InsertMenu(GetMenu(IDM_KEYBOARD), -1); InsertMenu(GetMenu(IDM_SOUND), -1); InsertMenu(GetMenu(IDM_MEMORY), -1); + SetMenuItemModifiers(GetMenuRef(IDM_FDD2), IDM_FDD2OPEN, kMenuOptionModifier); + SetMenuItemModifiers(GetMenuRef(IDM_FDD2), IDM_FDD2EJECT, kMenuOptionModifier); + SetMenuItemModifiers(GetMenuRef(IDM_SASI2), IDM_SASI2OPEN, kMenuOptionModifier); DrawMenuBar(); #else OSStatus err; @@ -198,8 +192,10 @@ static void HandleMenuChoice(long wParam break; case IDM_RESET: - pccore_cfgupdate(); - pccore_reset(); + if (ResetWarningDialogProc()) { + pccore_cfgupdate(); + pccore_reset(); + } break; case IDM_CONFIGURE: @@ -228,6 +224,7 @@ static void HandleMenuChoice(long wParam case IDM_FDD1EJECT: diskdrv_setfdd(0, NULL, 0); + toolwin_setfdd(0, NULL); break; case IDM_FDD2OPEN: @@ -236,6 +233,7 @@ static void HandleMenuChoice(long wParam case IDM_FDD2EJECT: diskdrv_setfdd(1, NULL, 0); + toolwin_setfdd(1, NULL); break; case IDM_SASI1OPEN: @@ -323,9 +321,12 @@ static void HandleMenuChoice(long wParam mouse_running(MOUSE_XOR); menu_setmouse(np2oscfg.MOUSE_SW ^ 1); sysmng_update(SYS_UPDATECFG); - toggleMenubar(); break; + case IDM_MIDIOPT: + initMidiOpt(); + break; + case IDM_MIDIPANIC: rs232c_midipanic(); mpu98ii_midipanic(); @@ -487,11 +488,9 @@ static void HandleMenuChoice(long wParam dialog_writebmp(); break; -#if 0 case IDM_S98LOGGING: - menu_sets98logging(S98_logging()); + dialog_s98(); break; -#endif case IDM_DISPCLOCK: menu_setdispclk(np2oscfg.DISPCLK ^ 1); @@ -513,6 +512,11 @@ static void HandleMenuChoice(long wParam update |= SYS_UPDATECFG; break; + case IDM_MSRAPID: + menu_setmsrapid(np2cfg.MOUSERAPID ^ 1); + update |= SYS_UPDATECFG; + break; + case IDM_I286SAVE: debugsub_status(); break; @@ -548,6 +552,7 @@ static void processwait(UINT waitcnt) { if (timing_getcount() >= waitcnt) { framecnt = 0; timing_setcount(0); + toolwin_draw((BYTE)waitcnt); if (np2oscfg.DISPCLK & 3) { if (sysmng_workclockrenewal()) { sysmng_updatecaption(3); @@ -583,58 +588,26 @@ static void flagload(const char *ext) { char path[MAX_PATH]; char buf[1024]; - int ret; + int ret, 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); + toolwin_setfdd(0, fdd_diskname(0)); + toolwin_setfdd(1, fdd_diskname(1)); } + return; } -#ifdef NP2OPENING -static void openingNP2(void) { - Rect srt, bounds; - GrafPtr port; - CFURLRef openingURL; - 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=CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("nekop2"), CFSTR("bmp"), NULL); - if (openingURL) { - if (CFURLGetFSRef(openingURL, &fsr)) { - 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); - } - } - CFRelease(openingURL); - } - SetPort(port); -} -#endif - - int main(int argc, char *argv[]) { EventRef theEvent; @@ -653,7 +626,8 @@ int main(int argc, char *argv[]) { initload(); TRACEINIT(); - + + toolwin_readini(); if (!(setupMainWindow())) { return(0); } @@ -791,6 +765,7 @@ int main(int argc, char *argv[]) { toggleFullscreen(); } + toolwin_writeini(); pccore_cfgupdate(); #if defined(USE_RESUME) @@ -821,6 +796,7 @@ int main(int argc, char *argv[]) { dosio_term(); DisposeWindow(hWndMain); + toolwin_close(); (void)argc; (void)argv; @@ -932,12 +908,18 @@ static pascal OSStatus np2windowevent(Ev np2running = FALSE; result = noErr; break; - case kEventWindowShowing: - scrndraw_redraw(); - break; case kEventWindowActivated: DisableAllMenuItems(GetMenuHandle(IDM_EDIT)); break; + case kEventWindowToolbarSwitchMode: + toolwin_open(); + break; + case kEventWindowDragStarted: + soundmng_stop(); + break; + case kEventWindowDragCompleted: + soundmng_play(); + break; } break; case kEventClassKeyboard: @@ -1002,8 +984,10 @@ static const EventTypeSpec appEventList[ static const EventTypeSpec windEventList[] = { {kEventClassWindow, kEventWindowClose}, - {kEventClassWindow, kEventWindowShowing}, {kEventClassWindow, kEventWindowActivated}, + {kEventClassWindow, kEventWindowToolbarSwitchMode}, + {kEventClassWindow, kEventWindowDragStarted}, + {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassKeyboard, kEventRawKeyDown}, {kEventClassKeyboard, kEventRawKeyUp}, {kEventClassKeyboard, kEventRawKeyRepeat}, @@ -1023,8 +1007,20 @@ static void setUpCarbonEvent(void) { InstallStandardEventHandler(GetWindowEventTarget(hWndMain)); } -bool setupMainWindow(void) { -#if defined(NP2GCC) && 0 +static bool setupMainWindow(void) { +#if defined(NP2GCC) + OSStatus err; + IBNibRef nibRef; + + err = CreateNibReference(CFSTR("np2"), &nibRef); + if (err ==noErr ) { + CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &hWndMain); + DisposeNibReference ( nibRef); + } + else { + return(false); + } + #else Rect wRect; @@ -1079,14 +1075,6 @@ static void toggleFullscreen(void) { soundmng_play(); } -void toggleMenubar(void) { - if (scrnmode & SCRNMODE_FULLSCREEN) { - if (!np2oscfg.MOUSE_SW) { - ShowMenuBar(); - } - else { - HideMenuBar(); - } - } +void recieveCommand(long param) { + HandleMenuChoice(param); } -