| version 1.8, 2003/10/25 09:08:24 | version 1.16, 2003/11/14 05:26:53 | 
| Line 4 | Line 4 | 
 | #include        "np2.h" | #include        "np2.h" | 
 | #include        "dosio.h" | #include        "dosio.h" | 
 | #include        "commng.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 29 | 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 = {100, 100, 0, 2, 0, 0,  0, 0, 0}; | 
 |  |  | 
 | WindowPtr       hWndMain; | WindowPtr       hWndMain; | 
 | BOOL            np2running; | BOOL            np2running; | 
| Line 100  static void InitToolBox(void) { | Line 98  static void InitToolBox(void) { | 
 |  |  | 
 | static void MenuBarInit(void) { | static void MenuBarInit(void) { | 
 |  |  | 
| Handle          hMenu; | Handle          hdl; | 
| MenuHandle      happlemenu; | MenuHandle      hmenu; | 
 |  |  | 
| hMenu = GetNewMBar(IDM_MAINMENU); | hdl = GetNewMBar(IDM_MAINMENU); | 
| if (!hMenu) { | if (hdl == NULL) { | 
 | ExitToShell(); | ExitToShell(); | 
 | } | } | 
| SetMenuBar(hMenu); | SetMenuBar(hdl); | 
| happlemenu = GetMenuHandle(IDM_APPLE); | hmenu = GetMenuHandle(IDM_APPLE); | 
| if (happlemenu) { | if (hmenu) { | 
| AppendResMenu(happlemenu, 'DRVR'); | AppendResMenu(hmenu, 'DRVR'); | 
 | } | } | 
 | InsertMenu(GetMenu(IDM_SASI1), -1); | InsertMenu(GetMenu(IDM_SASI1), -1); | 
 | InsertMenu(GetMenu(IDM_SASI2), -1); | InsertMenu(GetMenu(IDM_SASI2), -1); | 
 | 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); | 
 |  |  | 
 |  | #if TARGET_API_MAC_CARBON | 
 |  | hmenu = GetMenuHandle(IDM_FDD2); | 
 |  | SetItemCmd(hmenu, LoWord(IDM_FDD2OPEN), 'D'); | 
 |  | SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2OPEN), kMenuOptionModifier); | 
 |  | SetItemCmd(hmenu, LoWord(IDM_FDD2EJECT), 'E'); | 
 |  | SetMenuItemModifiers(hmenu, LoWord(IDM_FDD2EJECT), kMenuOptionModifier); | 
 |  | hmenu = GetMenuHandle(IDM_SASI2); | 
 |  | SetItemCmd(hmenu, LoWord(IDM_FDD2OPEN), 'O'); | 
 |  | SetMenuItemModifiers(hmenu, LoWord(IDM_SASI2OPEN), kMenuOptionModifier); | 
 |  | #else | 
 |  | EnableItem(GetMenuHandle(IDM_DEVICE), LoWord(IDM_MOUSE)); | 
 |  | EnableItem(GetMenuHandle(IDM_KEYBOARD), LoWord(IDM_F12MOUSE)); | 
 |  | #endif | 
 | DrawMenuBar(); | DrawMenuBar(); | 
 | } | } | 
 |  |  | 
| Line 250  static void HandleMenuChoice(long wParam | Line 262  static void HandleMenuChoice(long wParam | 
 | dialog_scropt(); | dialog_scropt(); | 
 | break; | break; | 
 |  |  | 
| #if defined(NP2GCC) | case IDM_MOUSE: | 
| case IDM_MOUSE: | mousemng_toggle(MOUSEPROC_SYSTEM); | 
| mouse_running(MOUSE_XOR); | menu_setmouse(np2oscfg.MOUSE_SW ^ 1); | 
| menu_setmouse(np2oscfg.MOUSE_SW ^ 1); | update |= SYS_UPDATECFG; | 
| sysmng_update(SYS_UPDATECFG); | break; | 
|  |  | 
|  | case IDM_MIDIPANIC: | 
|  | rs232c_midipanic(); | 
|  | mpu98ii_midipanic(); | 
|  | pc9861k_midipanic(); | 
 | break; | break; | 
 | #endif |  | 
 |  |  | 
 | case IDM_KEY: | case IDM_KEY: | 
 | menu_setkey(0); | menu_setkey(0); | 
| Line 380  static void HandleMenuChoice(long wParam | Line 396  static void HandleMenuChoice(long wParam | 
 | update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; | 
 | break; | break; | 
 |  |  | 
 |  | case IDM_AMD98: | 
 |  | menu_setsound(0x80); | 
 |  | update |= SYS_UPDATECFG; | 
 |  | break; | 
 |  |  | 
 | case IDM_SEEKSND: | case IDM_SEEKSND: | 
 | menu_setmotorflg(np2cfg.MOTOR ^ 1); | menu_setmotorflg(np2cfg.MOTOR ^ 1); | 
 | update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; | 
| Line 471  static void HandleMouseDown(EventRecord | Line 492  static void HandleMouseDown(EventRecord | 
 | case inMenuBar: | case inMenuBar: | 
 | if (np2running) { | if (np2running) { | 
 | soundmng_stop(); | soundmng_stop(); | 
 |  | mousemng_disable(MOUSEPROC_MACUI); | 
 | HandleMenuChoice(MenuSelect(pevent->where)); | HandleMenuChoice(MenuSelect(pevent->where)); | 
 |  | mousemng_enable(MOUSEPROC_MACUI); | 
 |  | soundmng_play(); | 
 | } | } | 
 | break; | break; | 
 |  |  | 
| Line 492  static void HandleMouseDown(EventRecord | Line 516  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 511  static void HandleMouseDown(EventRecord | Line 529  static void HandleMouseDown(EventRecord | 
 |  |  | 
 | static void eventproc(EventRecord *event) { | static void eventproc(EventRecord *event) { | 
 |  |  | 
 |  | int             keycode; | 
 |  |  | 
 |  | keycode = (event->message & keyCodeMask) >> 8; | 
 | switch(event->what) { | switch(event->what) { | 
 | case mouseDown: | case mouseDown: | 
 | HandleMouseDown(event); | HandleMouseDown(event); | 
| Line 522  static void eventproc(EventRecord *event | Line 543  static void eventproc(EventRecord *event | 
 |  |  | 
 | case keyDown: | case keyDown: | 
 | case autoKey: | case autoKey: | 
| if (np2running) { | if (!np2running) { | 
| mackbd_f12down(((event->message) & keyCodeMask) >> 8); | break; | 
| if (event->modifiers & cmdKey) { | } | 
| HandleMenuChoice(MenuKey(event->message & charCodeMask)); | #if !TARGET_API_MAC_CARBON | 
| } | if ((keycode == 0x6f) && (np2oscfg.F12COPY == 0)) { | 
|  | HandleMenuChoice(IDM_MOUSE); | 
|  | break; | 
|  | } | 
|  | #endif | 
|  | if (event->modifiers & cmdKey) { | 
|  | soundmng_stop(); | 
|  | mousemng_disable(MOUSEPROC_MACUI); | 
|  | HandleMenuChoice(MenuKey(event->message & charCodeMask)); | 
|  | mousemng_enable(MOUSEPROC_MACUI); | 
|  | soundmng_play(); | 
|  | } | 
|  | else { | 
|  | mackbd_keydown(keycode); | 
 | } | } | 
 | break; | break; | 
 |  |  | 
 | case keyUp: | case keyUp: | 
| mackbd_f12up(((event->message) & keyCodeMask) >> 8); | mackbd_keyup(keycode); | 
 | break; | break; | 
 |  |  | 
| #if defined(NP2GCC) | case mouseUp: | 
| case mouseUp: | mousemng_buttonevent(MOUSEMNG_LEFTUP); | 
| if (controlKey & GetCurrentKeyModifiers()) { | mousemng_buttonevent(MOUSEMNG_RIGHTUP); | 
| mouse_btn(MOUSE_RIGHTUP); | break; | 
| } |  | 
| else { | case activateEvt: | 
| mouse_btn(MOUSE_LEFTUP); | mackbd_activate((event->modifiers & activeFlag)?TRUE:FALSE); | 
| } |  | 
 | 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 614  int main(int argc, char *argv[]) { | Line 651  int main(int argc, char *argv[]) { | 
 | Rect            wRect; | Rect            wRect; | 
 | EventRecord     event; | EventRecord     event; | 
 | UINT            t; | UINT            t; | 
 |  | GrafPtr         saveport; | 
 |  | Point           pt; | 
 |  |  | 
 | dosio_init(); | dosio_init(); | 
 | file_setcd(target); | file_setcd(target); | 
| Line 626  int main(int argc, char *argv[]) { | Line 665  int main(int argc, char *argv[]) { | 
 |  |  | 
 | TRACEINIT(); | TRACEINIT(); | 
 |  |  | 
| SetRect(&wRect, 100, 100, 100, 100); | SetRect(&wRect, np2oscfg.posx, np2oscfg.posy, 100, 100); | 
 | 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); | 
 | if (!hWndMain) { | if (!hWndMain) { | 
| Line 677  int main(int argc, char *argv[]) { | Line 716  int main(int argc, char *argv[]) { | 
 | 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(); | 
 |  |  | 
| Line 698  int main(int argc, char *argv[]) { | Line 736  int main(int argc, char *argv[]) { | 
 | } | } | 
 | else { | else { | 
 | if (np2oscfg.NOWAIT) { | if (np2oscfg.NOWAIT) { | 
 | #if defined(NP2GCC) |  | 
 | mouse_callback(); |  | 
 | #endif |  | 
 | soundmng_play(); |  | 
 | 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 719  int main(int argc, char *argv[]) { | Line 754  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 |  | 
 | soundmng_play(); |  | 
 | mackbd_callback(); | mackbd_callback(); | 
 |  | mousemng_callback(); | 
 | pccore_exec(framecnt == 0); | pccore_exec(framecnt == 0); | 
 | framecnt++; | framecnt++; | 
 | } | } | 
| Line 734  int main(int argc, char *argv[]) { | Line 766  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 |  | 
 | soundmng_play(); |  | 
 | mackbd_callback(); | mackbd_callback(); | 
 |  | mousemng_callback(); | 
 | pccore_exec(framecnt == 0); | pccore_exec(framecnt == 0); | 
 | framecnt++; | framecnt++; | 
 | cnt = timing_getcount(); | cnt = timing_getcount(); | 
| Line 758  int main(int argc, char *argv[]) { | Line 787  int main(int argc, char *argv[]) { | 
 | else { | else { | 
 | timing_setcount(cnt - framecnt); | timing_setcount(cnt - framecnt); | 
 | } | } | 
| framecnt = 0; | framereset(); | 
 | } | } | 
 | } | } | 
 | else { | else { | 
| Line 768  int main(int argc, char *argv[]) { | Line 797  int main(int argc, char *argv[]) { | 
 | } | } | 
 | } | } | 
 | } | } | 
 |  |  | 
 |  | GetPort(&saveport); | 
 |  | #if TARGET_API_MAC_CARBON | 
 |  | SetPortWindowPort(hWndMain); | 
 |  | #else | 
 |  | SetPort(hWndMain); | 
 |  | #endif | 
 |  | pt.h = 0; | 
 |  | pt.v = 0; | 
 |  | LocalToGlobal(&pt); | 
 |  | SetPort(saveport); | 
 |  | if ((np2oscfg.posx != pt.h) || (np2oscfg.posy != pt.v)) { | 
 |  | np2oscfg.posx = pt.h; | 
 |  | np2oscfg.posy = pt.v; | 
 |  | sysmng_update(SYS_UPDATEOSCFG); | 
 |  | } | 
 |  |  | 
 | np2running = FALSE; | np2running = FALSE; | 
 |  |  | 
 | pccore_cfgupdate(); | pccore_cfgupdate(); | 
| Line 782  int main(int argc, char *argv[]) { | Line 828  int main(int argc, char *argv[]) { | 
 | pccore_term(); | pccore_term(); | 
 | S98_trash(); | S98_trash(); | 
 |  |  | 
| #if defined(NP2GCC) | mousemng_disable(MOUSEPROC_SYSTEM); | 
| mouse_running(MOUSE_OFF); |  | 
| #endif |  | 
 |  |  | 
 | scrnmng_destroy(); | scrnmng_destroy(); | 
 |  |  |