Diff for /np2/macos9/np2.cpp between versions 1.21 and 1.38

version 1.21, 2003/12/05 14:13:01 version 1.38, 2004/08/16 09:15:07
Line 20 Line 20
 #include        "pc9861k.h"  #include        "pc9861k.h"
 #include        "mpu98ii.h"  #include        "mpu98ii.h"
 #include        "timing.h"  #include        "timing.h"
   #include        "keystat.h"
 #include        "debugsub.h"  #include        "debugsub.h"
 #include        "bios.h"  #include        "bios.h"
 #include        "scrndraw.h"  #include        "scrndraw.h"
Line 28 Line 29
 #include        "s98.h"  #include        "s98.h"
 #include        "diskdrv.h"  #include        "diskdrv.h"
 #include        "fddfile.h"  #include        "fddfile.h"
 #include        "statsave.h"  
   
   
 #define USE_RESUME                  NP2OSCFG        np2oscfg = {100, 100,
                                                                   0, 0, 0, 0,
                                                                   0, 0,
                 NP2OSCFG        np2oscfg = {100, 100, 0, 2, 0, 0,  0, 0, 0, 0};  #if defined(SUPPORT_RESUME)
                                                                   0,
   #endif
   #if defined(SUPPORT_STATSAVE)
                                                                   0,
   #endif
                                                                   0, 0};
   
                 WindowPtr       hWndMain;                  WindowPtr       hWndMain;
                 BOOL            np2running;                  BOOL            np2running;
Line 53  static BYTE  scrnmode; Line 59  static BYTE  scrnmode;
 #endif  #endif
 static  char    target[MAX_PATH] = DEFAULTPATH;  static  char    target[MAX_PATH] = DEFAULTPATH;
   
   #if !defined(SUPPORT_PC9821)
   static const char np2app[] = "np2";
   #else
   static const char np2app[] = "np21";
   #endif
   
   
   // ----
   
   #if defined(SUPPORT_RESUME)
   static const char np2resumeext[] = ".sav";
   #endif
   #if defined(SUPPORT_STATSAVE)
   static const char np2flagext[] = ".sv%u";
   #endif
   
   #if defined(SUPPORT_RESUME) || defined(SUPPORT_STATSAVE)
   static void getstatfilename(char *path, const char *ext, UINT size) {
   
           file_cpyname(path, file_getcd(np2app), 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 flagdelete(const char *ext) {
   
           char    path[MAX_PATH];
   
           getstatfilename(path, ext, sizeof(path));
           file_delete(path);
   }
   
 static const char np2resume[] = "sav";  static int flagload(const char *ext, BOOL force) {
   
           char    path[MAX_PATH];
           char    buf[1024];
           int             r;
           int             ret;
   
           getstatfilename(path, ext, sizeof(path));
           r = statsave_check(path, buf, sizeof(buf));
           if (r & (~STATFLAG_DISKCHG)) {
                   ResumeErrorDialogProc();
                   ret = IDCANCEL;
           }
           else if ((!force) && (r & STATFLAG_DISKCHG)) {
                   ret = ResumeWarningDialogProc(buf);
           }
           else {
                   ret = IDOK;
           }
           if (ret == IDOK) {
                   statsave_load(path);
           }
           return(ret);
   }
   #endif
   
   
 // ---- おまじない  // ---- おまじない
Line 110  static void MenuBarInit(void) { Line 178  static void MenuBarInit(void) {
         if (hmenu) {          if (hmenu) {
                 AppendResMenu(hmenu, 'DRVR');                  AppendResMenu(hmenu, 'DRVR');
         }          }
   #if !defined(SUPPORT_SCSI)
           hmenu = GetMenuHandle(IDM_HARDDISK);
           if (hmenu) {
                   DeleteMenuItem(hmenu, 7);
                   DeleteMenuItem(hmenu, 6);
                   DeleteMenuItem(hmenu, 5);
                   DeleteMenuItem(hmenu, 4);
                   DeleteMenuItem(hmenu, 3);
           }
   #endif
           if (!np2oscfg.I286SAVE) {
                   hmenu = GetMenuHandle(IDM_OTHER);
                   if (hmenu) {
                           DeleteMenuItem(hmenu, 9);
                   }
           }
         InsertMenu(GetMenu(IDM_SASI1), -1);          InsertMenu(GetMenu(IDM_SASI1), -1);
         InsertMenu(GetMenu(IDM_SASI2), -1);          InsertMenu(GetMenu(IDM_SASI2), -1);
   #if defined(SUPPORT_SCSI)
           InsertMenu(GetMenu(IDM_SCSI0), -1);
           InsertMenu(GetMenu(IDM_SCSI1), -1);
           InsertMenu(GetMenu(IDM_SCSI2), -1);
           InsertMenu(GetMenu(IDM_SCSI3), -1);
   #endif
         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);
Line 119  static void MenuBarInit(void) { Line 209  static void MenuBarInit(void) {
 #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
         hmenu = GetMenuHandle(IDM_FDD2);          hmenu = GetMenuHandle(IDM_FDD2);
         SetItemCmd(hmenu, LoWord(IDM_FDD2OPEN), 'D');          SetItemCmd(hmenu, LoWord(IDM_FDD2OPEN), 'D');
         SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2OPEN), kMenuOptionModifier);          SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2OPEN), kMenuShiftModifier);
         SetItemCmd(hmenu, LoWord(IDM_FDD2EJECT), 'E');          SetItemCmd(hmenu, LoWord(IDM_FDD2EJECT), 'E');
         SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2EJECT), kMenuOptionModifier);          SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2EJECT), kMenuShiftModifier);
         hmenu = GetMenuHandle(IDM_SASI2);          hmenu = GetMenuHandle(IDM_SASI2);
         SetItemCmd(hmenu, LoWord(IDM_SASI2OPEN), 'O');          SetItemCmd(hmenu, LoWord(IDM_SASI2OPEN), 'O');
         SetMenuItemModifiers(hmenu, LoWord(IDM_SASI2OPEN), kMenuOptionModifier);          SetMenuItemModifiers(hmenu, LoWord(IDM_SASI2OPEN), kMenuShiftModifier);
 #else  #else
         EnableItem(GetMenuHandle(IDM_DEVICE), LoWord(IDM_MOUSE));          EnableItem(GetMenuHandle(IDM_DEVICE), LoWord(IDM_MOUSE));
         EnableItem(GetMenuHandle(IDM_KEYBOARD), LoWord(IDM_F12MOUSE));          EnableItem(GetMenuHandle(IDM_KEYBOARD), LoWord(IDM_F12MOUSE));
 #endif  #endif
   
           if (!(np2cfg.fddequip & 1)) {
                   DeleteMenu(IDM_FDD1);
           }
           if (!(np2cfg.fddequip & 2)) {
                   DeleteMenu(IDM_FDD2);
           }
           if (!(np2cfg.fddequip & 4)) {
                   DeleteMenu(IDM_FDD3);
           }
           if (!(np2cfg.fddequip & 8)) {
                   DeleteMenu(IDM_FDD4);
           }
   
   #if defined(SUPPORT_STATSAVE)
           if (!np2oscfg.statsave) {
   #endif
                   DeleteMenu(IDM_STATSAVE);
   #if defined(SUPPORT_STATSAVE)
           }
   #endif
   
         DrawMenuBar();          DrawMenuBar();
 }  }
   
Line 141  static void HandleMenuChoice(long wParam Line 253  static void HandleMenuChoice(long wParam
   
         UINT    update;          UINT    update;
         Str255  applname;          Str255  applname;
   #if defined(SUPPORT_STATSAVE)
           UINT    num;
           char    ext[16];
   #endif
   
         update = 0;          update = 0;
         switch(wParam) {          switch(wParam) {
Line 185  static void HandleMenuChoice(long wParam Line 301  static void HandleMenuChoice(long wParam
                         diskdrv_setfdd(1, NULL, 0);                          diskdrv_setfdd(1, NULL, 0);
                         break;                          break;
   
                   case IDM_FDD3OPEN:
                           dialog_changefdd(2);
                           break;
   
                   case IDM_FDD3EJECT:
                           diskdrv_setfdd(2, NULL, 0);
                           break;
   
                   case IDM_FDD4OPEN:
                           dialog_changefdd(3);
                           break;
   
                   case IDM_FDD4EJECT:
                           diskdrv_setfdd(3, NULL, 0);
                           break;
   
                 case IDM_SASI1OPEN:                  case IDM_SASI1OPEN:
                         dialog_changehdd(0);                          dialog_changehdd(0x00);
                         break;                          break;
   
                 case IDM_SASI1REMOVE:                  case IDM_SASI1REMOVE:
                         diskdrv_sethdd(0, NULL);                          diskdrv_sethdd(0x00, NULL);
                         break;                          break;
   
                 case IDM_SASI2OPEN:                  case IDM_SASI2OPEN:
                         dialog_changehdd(1);                          dialog_changehdd(0x01);
                         break;                          break;
   
                 case IDM_SASI2REMOVE:                  case IDM_SASI2REMOVE:
                         diskdrv_sethdd(1, NULL);                          diskdrv_sethdd(0x01, NULL);
                           break;
   
                   case IDM_SCSI0OPEN:
                           dialog_changehdd(0x20);
                           break;
   
                   case IDM_SCSI0REMOVE:
                           diskdrv_sethdd(0x20, NULL);
                           break;
   
                   case IDM_SCSI1OPEN:
                           dialog_changehdd(0x21);
                           break;
   
                   case IDM_SCSI1REMOVE:
                           diskdrv_sethdd(0x21, NULL);
                           break;
   
                   case IDM_SCSI2OPEN:
                           dialog_changehdd(0x22);
                           break;
   
                   case IDM_SCSI2REMOVE:
                           diskdrv_sethdd(0x22, NULL);
                           break;
   
                   case IDM_SCSI3OPEN:
                           dialog_changehdd(0x23);
                           break;
   
                   case IDM_SCSI3REMOVE:
                           diskdrv_sethdd(0x23, NULL);
                         break;                          break;
   
                 case IDM_ROLNORMAL:                  case IDM_ROLNORMAL:
Line 268  static void HandleMenuChoice(long wParam Line 432  static void HandleMenuChoice(long wParam
                         update |= SYS_UPDATECFG;                          update |= SYS_UPDATECFG;
                         break;                          break;
   
                   case IDM_MIDIOPT:
                           MPU98DialogProc();
                           break;
   
                 case IDM_MIDIPANIC:                  case IDM_MIDIPANIC:
                         rs232c_midipanic();                          rs232c_midipanic();
                         mpu98ii_midipanic();                          mpu98ii_midipanic();
Line 334  static void HandleMenuChoice(long wParam Line 502  static void HandleMenuChoice(long wParam
                         update |= SYS_UPDATEOSCFG;                          update |= SYS_UPDATEOSCFG;
                         break;                          break;
   
                   case IDM_F11USER:
                           menu_setf11key(4);
                           mackbd_resetf11();
                           update |= SYS_UPDATEOSCFG;
                           break;
   
                 case IDM_F12MOUSE:                  case IDM_F12MOUSE:
                         menu_setf12key(0);                          menu_setf12key(0);
                         mackbd_resetf12();                          mackbd_resetf12();
Line 352  static void HandleMenuChoice(long wParam Line 526  static void HandleMenuChoice(long wParam
                         update |= SYS_UPDATEOSCFG;                          update |= SYS_UPDATEOSCFG;
                         break;                          break;
   
                   case IDM_F12USER:
                           menu_setf12key(4);
                           mackbd_resetf12();
                           update |= SYS_UPDATEOSCFG;
                           break;
   
                 case IDM_BEEPOFF:                  case IDM_BEEPOFF:
                         menu_setbeepvol(0);                          menu_setbeepvol(0);
                         beep_setvol(0);                          beep_setvol(0);
Line 426  static void HandleMenuChoice(long wParam Line 606  static void HandleMenuChoice(long wParam
                         update |= SYS_UPDATECFG;                          update |= SYS_UPDATECFG;
                         break;                          break;
   
                   case IDM_JASTSND:
                           menu_setjastsnd(np2oscfg.jastsnd ^ 1);
                           update |= SYS_UPDATEOSCFG;
                           break;
   
                 case IDM_SEEKSND:                  case IDM_SEEKSND:
                         menu_setmotorflg(np2cfg.MOTOR ^ 1);                          menu_setmotorflg(np2cfg.MOTOR ^ 1);
                         update |= SYS_UPDATECFG;                          update |= SYS_UPDATECFG;
Line 451  static void HandleMenuChoice(long wParam Line 636  static void HandleMenuChoice(long wParam
                         update |= SYS_UPDATECFG;                          update |= SYS_UPDATECFG;
                         break;                          break;
   
                   case IDM_MEM116:
                           menu_setextmem(11);
                           update |= SYS_UPDATECFG;
                           break;
   
                   case IDM_MEM136:
                           menu_setextmem(13);
                           update |= SYS_UPDATECFG;
                           break;
   
                 case IDM_BMPSAVE:                  case IDM_BMPSAVE:
                         dialog_writebmp();                          dialog_writebmp();
                         break;                          break;
   
                   case IDM_CALENDAR:
                           CalendarDialogProc();
                           break;
   
                 case IDM_DISPCLOCK:                  case IDM_DISPCLOCK:
                         menu_setdispclk(np2oscfg.DISPCLK ^ 1);                          menu_setdispclk(np2oscfg.DISPCLK ^ 1);
                         update |= SYS_UPDATECFG;                          update |= SYS_UPDATECFG;
Line 487  static void HandleMenuChoice(long wParam Line 686  static void HandleMenuChoice(long wParam
                                 (void)OpenDeskAcc(applname);                                  (void)OpenDeskAcc(applname);
 #endif  #endif
                         }                          }
   #if defined(SUPPORT_STATSAVE)
                           else if (HiWord(wParam) == IDM_STATSAVE) {
                                   num = LoWord(wParam);
                                   if ((num >= 1) && (num < (1 + 10))) {
                                           SPRINTF(ext, np2flagext, num - 1);
                                           flagsave(ext);
                                   }
                                   else if ((num >= 12) && (num < (12 + 10))) {
                                           SPRINTF(ext, np2flagext, num - 12);
                                           flagload(ext, TRUE);
                                   }
                           }
   #endif
                         break;                          break;
         }          }
         sysmng_update(update);          sysmng_update(update);
Line 634  static void processwait(UINT waitcnt) { Line 846  static void processwait(UINT waitcnt) {
         }          }
 }  }
   
 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 flagdelete(const char *ext) {  
   
         char    path[MAX_PATH];  
   
         getstatfilename(path, ext, sizeof(path));  
         file_delete(path);  
 }  
   
 static int flagload(const char *ext) {  
   
         int             ret;  
         char    path[MAX_PATH];  
         char    buf[1024];  
         int             r;  
   
         ret = IDOK;  
         getstatfilename(path, ext, sizeof(path));  
         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);  
         }  
         return(ret);  
 }  
   
 int main(int argc, char *argv[]) {  int main(int argc, char *argv[]) {
   
         Rect            wRect;          Rect            wRect;
Line 693  int main(int argc, char *argv[]) { Line 859  int main(int argc, char *argv[]) {
   
         InitToolBox();          InitToolBox();
         macossub_init();          macossub_init();
         MenuBarInit();  
   
         initload();          initload();
   
           MenuBarInit();
   
         TRACEINIT();          TRACEINIT();
   
           keystat_initialize();
   
         SetRect(&wRect, np2oscfg.posx, np2oscfg.posy, 100, 100);          SetRect(&wRect, np2oscfg.posx, np2oscfg.posy, 100, 100);
   #if !defined(SUPPORT_PC9821)
         hWndMain = NewWindow(0, &wRect, "\pNeko Project II", FALSE,          hWndMain = NewWindow(0, &wRect, "\pNeko Project II", FALSE,
                                                                 noGrowDocProc, (WindowPtr)-1, TRUE, 0);                                                                  noGrowDocProc, (WindowPtr)-1, TRUE, 0);
   #else
           hWndMain = NewWindow(0, &wRect, "\pNeko Project 21", FALSE,
                                                                   noGrowDocProc, (WindowPtr)-1, TRUE, 0);
   #endif
         if (!hWndMain) {          if (!hWndMain) {
                 TRACETERM();                  TRACETERM();
                 macossub_term();                  macossub_term();
Line 722  int main(int argc, char *argv[]) { Line 895  int main(int argc, char *argv[]) {
         menu_setf12key(np2oscfg.F12KEY);          menu_setf12key(np2oscfg.F12KEY);
         menu_setbeepvol(np2cfg.BEEP_VOL);          menu_setbeepvol(np2cfg.BEEP_VOL);
         menu_setsound(np2cfg.SOUND_SW);          menu_setsound(np2cfg.SOUND_SW);
           menu_setjastsnd(np2oscfg.jastsnd);
         menu_setmotorflg(np2cfg.MOTOR);          menu_setmotorflg(np2cfg.MOTOR);
         menu_setextmem(np2cfg.EXTMEM);          menu_setextmem(np2cfg.EXTMEM);
         menu_setdispclk(np2oscfg.DISPCLK);          menu_setdispclk(np2oscfg.DISPCLK);
Line 758  int main(int argc, char *argv[]) { Line 932  int main(int argc, char *argv[]) {
 //      scrndraw_redraw();  //      scrndraw_redraw();
         pccore_reset();          pccore_reset();
   
   #if defined(SUPPORT_RESUME)
         if (np2oscfg.resume) {          if (np2oscfg.resume) {
                 flagload(np2resume);                  flagload(np2resumeext, FALSE);
         }          }
   #endif
   
         SetEventMask(everyEvent);          SetEventMask(everyEvent);
   
Line 853  int main(int argc, char *argv[]) { Line 1029  int main(int argc, char *argv[]) {
   
         pccore_cfgupdate();          pccore_cfgupdate();
   
   #if defined(SUPPORT_RESUME)
         if (np2oscfg.resume) {          if (np2oscfg.resume) {
                 flagsave(np2resume);                  flagsave(np2resumeext);
         }          }
         else {          else {
                 flagdelete(np2resume);                  flagdelete(np2resumeext);
         }          }
   #endif
   
         pccore_term();          pccore_term();
         S98_trash();          S98_trash();

Removed from v.1.21  
changed lines
  Added in v.1.38


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