Diff for /np2/macos9/np2.cpp between versions 1.4 and 1.11

version 1.4, 2003/10/23 15:57:16 version 1.11, 2003/11/09 21:57:04
Line 3 Line 3
 #include        "strres.h"  #include        "strres.h"
 #include        "np2.h"  #include        "np2.h"
 #include        "dosio.h"  #include        "dosio.h"
   #include        "commng.h"
   #include        "mousemng.h"
 #include        "scrnmng.h"  #include        "scrnmng.h"
 #include        "soundmng.h"  #include        "soundmng.h"
 #include        "sysmng.h"  #include        "sysmng.h"
Line 10 Line 12
 #include        "mackbd.h"  #include        "mackbd.h"
 #include        "ini.h"  #include        "ini.h"
 #include        "menu.h"  #include        "menu.h"
   #include        "np2open.h"
 #include        "dialog.h"  #include        "dialog.h"
 #include        "memory.h"  #include        "memory.h"
 #include        "pccore.h"  #include        "pccore.h"
Line 27 Line 30
 #include        "fddfile.h"  #include        "fddfile.h"
 #include        "statsave.h"  #include        "statsave.h"
   
 #if defined(NP2GCC)  
 #include        "mousemng.h"  
 #endif  
   
 #define USE_RESUME  #define USE_RESUME
   
   
                 NP2OSCFG        np2oscfg = {0, 2, 0, 0,  0, 0};                  NP2OSCFG        np2oscfg = {0, 2, 0, 0,  0, 0, 0};
   
                 WindowPtr       hWndMain;                  WindowPtr       hWndMain;
                 BOOL            np2running;                  BOOL            np2running;
Line 115  static void MenuBarInit(void) { Line 115  static void MenuBarInit(void) {
         InsertMenu(GetMenu(IDM_KEYBOARD), -1);          InsertMenu(GetMenu(IDM_KEYBOARD), -1);
         InsertMenu(GetMenu(IDM_SOUND), -1);          InsertMenu(GetMenu(IDM_SOUND), -1);
         InsertMenu(GetMenu(IDM_MEMORY), -1);          InsertMenu(GetMenu(IDM_MEMORY), -1);
           SetMenuItemModifiers(GetMenuHandle(IDM_FDD2), LoWord(IDM_FDD2OPEN),
                                                                                                                   kMenuOptionModifier);
           SetMenuItemModifiers(GetMenuHandle(IDM_FDD2), LoWord(IDM_FDD2EJECT),
                                                                                                                   kMenuOptionModifier);
           SetMenuItemModifiers(GetMenuHandle(IDM_SASI2), LoWord(IDM_SASI2OPEN),
                                                                                                                   kMenuOptionModifier);
   #if TARGET_API_MAC_CARBON
           DisableMenuItem(GetMenuHandle(IDM_DEVICE), LoWord(IDM_MOUSE));
           DisableMenuItem(GetMenuHandle(IDM_KEYBOARD), LoWord(IDM_F12MOUSE));
   #endif
         DrawMenuBar();          DrawMenuBar();
 }  }
   
Line 244  static void HandleMenuChoice(long wParam Line 254  static void HandleMenuChoice(long wParam
                         update |= SYS_UPDATECFG;                          update |= SYS_UPDATECFG;
                         break;                          break;
   
 #if defined(NP2GCC)                  case IDM_SCREENOPT:
                           dialog_scropt();
                           break;
   
         case IDM_MOUSE:          case IDM_MOUSE:
             mouse_running(MOUSE_XOR);                          mousemng_toggle(MOUSEPROC_SYSTEM);
             menu_setmouse(np2oscfg.MOUSE_SW ^ 1);              menu_setmouse(np2oscfg.MOUSE_SW ^ 1);
             sysmng_update(SYS_UPDATECFG);              sysmng_update(SYS_UPDATECFG);
                         break;                          break;
 #endif  
                   case IDM_MIDIPANIC:
                           rs232c_midipanic();
                           mpu98ii_midipanic();
                           pc9861k_midipanic();
                           break;
   
                 case IDM_KEY:                  case IDM_KEY:
                         menu_setkey(0);                          menu_setkey(0);
Line 447  static void HandleUpdateEvent(EventRecor Line 465  static void HandleUpdateEvent(EventRecor
   
         hWnd = (WindowPtr)pevent->message;          hWnd = (WindowPtr)pevent->message;
         BeginUpdate(hWnd);          BeginUpdate(hWnd);
         scrndraw_redraw();          if (np2running) {
                   scrndraw_redraw();
           }
           else {
                   np2open();
           }
         EndUpdate(hWnd);          EndUpdate(hWnd);
 }  }
   
Line 458  static void HandleMouseDown(EventRecord  Line 481  static void HandleMouseDown(EventRecord 
   
         switch(FindWindow(pevent->where, &hWnd)) {          switch(FindWindow(pevent->where, &hWnd)) {
                 case inMenuBar:                  case inMenuBar:
                         HandleMenuChoice(MenuSelect(pevent->where));                          if (np2running) {
                                   soundmng_stop();
                                   HandleMenuChoice(MenuSelect(pevent->where));
                                   soundmng_play();
                           }
                         break;                          break;
   
                 case inDrag:                  case inDrag:
Line 478  static void HandleMouseDown(EventRecord  Line 505  static void HandleMouseDown(EventRecord 
                         break;                          break;
   
                 case inContent:                  case inContent:
 #if defined(NP2GCC)                          mousemng_buttonevent((pevent->modifiers & (1 << 12))
             if (controlKey & GetCurrentKeyModifiers() ) {                                                                          ?MOUSEMNG_RIGHTDOWN:MOUSEMNG_LEFTDOWN);
                 mouse_btn(MOUSE_RIGHTDOWN);  
             }  
             else {  
                 mouse_btn(MOUSE_LEFTDOWN);  
             }  
 #endif  
                         break;                          break;
   
                 case inGoAway:                  case inGoAway:
Line 508  static void eventproc(EventRecord *event Line 529  static void eventproc(EventRecord *event
   
                 case keyDown:                  case keyDown:
                 case autoKey:                  case autoKey:
                         mackbd_f12down(((event->message) & keyCodeMask) >> 8);                          if (np2running) {
                         if (event->modifiers & cmdKey) {                                  mackbd_f12down(((event->message) & keyCodeMask) >> 8);
                                 HandleMenuChoice(MenuKey(event->message & charCodeMask));                                  if (event->modifiers & cmdKey) {
                                           soundmng_stop();
                                           HandleMenuChoice(MenuKey(event->message & charCodeMask));
                                           soundmng_play();
                                   }
                         }                          }
                         break;                          break;
   
Line 518  static void eventproc(EventRecord *event Line 543  static void eventproc(EventRecord *event
                         mackbd_f12up(((event->message) & keyCodeMask) >> 8);                          mackbd_f12up(((event->message) & keyCodeMask) >> 8);
                         break;                          break;
   
 #if defined(NP2GCC)                  case mouseUp:
         case mouseUp:                          mousemng_buttonevent(MOUSEMNG_LEFTUP);
             if (controlKey & GetCurrentKeyModifiers()) {                          mousemng_buttonevent(MOUSEMNG_RIGHTUP);
                 mouse_btn(MOUSE_RIGHTUP);  
             }  
             else {  
                 mouse_btn(MOUSE_LEFTUP);  
             }  
                         break;                          break;
 #endif  
         }          }
 }  }
   
   
 // ----  // ----
   
   static void framereset(void) {
   
           framecnt = 0;
           if (np2oscfg.DISPCLK & 3) {
                   if (sysmng_workclockrenewal()) {
                           sysmng_updatecaption(3);
                   }
           }
   }
   
 static void processwait(UINT waitcnt) {  static void processwait(UINT waitcnt) {
   
         if (timing_getcount() >= waitcnt) {          if (timing_getcount() >= waitcnt) {
                 timing_setcount(0);                  timing_setcount(0);
                 framecnt = 0;                  framereset();
                 if (np2oscfg.DISPCLK & 3) {  
                         if (sysmng_workclockrenewal()) {  
                                 sysmng_updatecaption(3);  
                         }  
                 }  
         }          }
 }  }
   
Line 562  static void flagsave(const char *ext) { Line 586  static void flagsave(const char *ext) {
         statsave_save(path);          statsave_save(path);
 }  }
   
 static void flagload(const char *ext) {  static void flagdelete(const char *ext) {
   
         char    path[MAX_PATH];          char    path[MAX_PATH];
         char    buf[1024];  
           getstatfilename(path, ext, sizeof(path));
           file_delete(path);
   }
   
   static int flagload(const char *ext) {
   
         int             ret;          int             ret;
           char    path[MAX_PATH];
           char    buf[1024];
           int             r;
   
           ret = IDOK;
         getstatfilename(path, ext, sizeof(path));          getstatfilename(path, ext, sizeof(path));
         ret = statsave_check(path, buf, sizeof(buf));          r = statsave_check(path, buf, sizeof(buf));
         if (ret == NP2FLAG_SUCCESS) {          if (r & (~NP2FLAG_DISKCHG)) {
                   ResumeErrorDialogProc();
                   ret = IDCANCEL;
           }
           else if (r & NP2FLAG_DISKCHG) {
                   ret = ResumeWarningDialogProc(buf);
           }
           if (ret == IDOK) {
                 statsave_load(path);                  statsave_load(path);
         }          }
           return(ret);
 }  }
   
 int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
   
         Rect            wRect;          Rect            wRect;
         EventRecord     event;          EventRecord     event;
           UINT            t;
   
         dosio_init();          dosio_init();
         file_setcd(target);          file_setcd(target);
Line 628  int main(int argc, char *argv[]) { Line 671  int main(int argc, char *argv[]) {
                 return(0);                  return(0);
         }          }
   
           np2open();
           t = GETTICK();
           while((GETTICK() - t) < 100) {
                   if (WaitNextEvent(everyEvent, &event, 0, 0)) {
                           eventproc(&event);
                   }
           }
   
           commng_initialize();
         sysmng_initialize();          sysmng_initialize();
         mackbd_initialize();          mackbd_initialize();
         pccore_init();          pccore_init();
         S98_init();          S98_init();
   
 #if defined(NP2GCC)          mousemng_initialize();
         if (np2oscfg.MOUSE_SW) {                                                                                // ver0.30          if (np2oscfg.MOUSE_SW) {                                                                                // ver0.30
                 mouse_running(MOUSE_ON);                  mousemng_enable(MOUSEPROC_SYSTEM);
         }          }
 #endif  //      scrndraw_redraw();
         scrndraw_redraw();  
         pccore_reset();          pccore_reset();
   
         if (np2oscfg.resume) {          if (np2oscfg.resume) {
Line 654  int main(int argc, char *argv[]) { Line 705  int main(int argc, char *argv[]) {
                 }                  }
                 else {                  else {
                         if (np2oscfg.NOWAIT) {                          if (np2oscfg.NOWAIT) {
 #if defined(NP2GCC)  
                                 mouse_callback();  
 #endif  
                                 mackbd_callback();                                  mackbd_callback();
                                   mousemng_callback();
                                 pccore_exec(framecnt == 0);                                  pccore_exec(framecnt == 0);
                                 if (np2oscfg.DRAW_SKIP) {                       // nowait frame skip                                  if (np2oscfg.DRAW_SKIP) {                       // nowait frame skip
                                         framecnt++;                                          framecnt++;
Line 674  int main(int argc, char *argv[]) { Line 723  int main(int argc, char *argv[]) {
                         }                          }
                         else if (np2oscfg.DRAW_SKIP) {                  // frame skip                          else if (np2oscfg.DRAW_SKIP) {                  // frame skip
                                 if (framecnt < np2oscfg.DRAW_SKIP) {                                  if (framecnt < np2oscfg.DRAW_SKIP) {
 #if defined(NP2GCC)  
                     mouse_callback();  
 #endif  
                                         mackbd_callback();                                          mackbd_callback();
                       mousemng_callback();
                                         pccore_exec(framecnt == 0);                                          pccore_exec(framecnt == 0);
                                         framecnt++;                                          framecnt++;
                                 }                                  }
Line 688  int main(int argc, char *argv[]) { Line 735  int main(int argc, char *argv[]) {
                         else {                                                          // auto skip                          else {                                                          // auto skip
                                 if (!waitcnt) {                                  if (!waitcnt) {
                                         UINT cnt;                                          UINT cnt;
 #if defined(NP2GCC)  
                     mouse_callback();  
 #endif  
                                         mackbd_callback();                                          mackbd_callback();
                       mousemng_callback();
                                         pccore_exec(framecnt == 0);                                          pccore_exec(framecnt == 0);
                                         framecnt++;                                          framecnt++;
                                         cnt = timing_getcount();                                          cnt = timing_getcount();
Line 711  int main(int argc, char *argv[]) { Line 756  int main(int argc, char *argv[]) {
                                                 else {                                                  else {
                                                         timing_setcount(cnt - framecnt);                                                          timing_setcount(cnt - framecnt);
                                                 }                                                  }
                                                 framecnt = 0;                                                  framereset();
                                         }                                          }
                                 }                                  }
                                 else {                                  else {
Line 728  int main(int argc, char *argv[]) { Line 773  int main(int argc, char *argv[]) {
         if (np2oscfg.resume) {          if (np2oscfg.resume) {
                 flagsave(np2resume);                  flagsave(np2resume);
         }          }
           else {
                   flagdelete(np2resume);
           }
   
         pccore_term();          pccore_term();
         S98_trash();          S98_trash();
   
 #if defined(NP2GCC)          mousemng_disable(MOUSEPROC_SYSTEM);
         mouse_running(MOUSE_OFF);  
 #endif  
   
         scrnmng_destroy();          scrnmng_destroy();
   

Removed from v.1.4  
changed lines
  Added in v.1.11


RetroPC.NET-CVS <cvs@retropc.net>