Diff for /np2/wince/w32/Attic/np2.cpp between versions 1.2 and 1.5

version 1.2, 2003/10/23 12:58:44 version 1.5, 2003/11/21 06:51:16
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        <time.h>  
 #include        "resource.h"  #include        "resource.h"
 #include        "strres.h"  #include        "strres.h"
 #include        "np2.h"  #include        "np2.h"
 #include        "dosio.h"  #include        "dosio.h"
 #include        "commng.h"  #include        "commng.h"
 #include        "joymng.h"  #include        "inputmng.h"
 #include        "mousemng.h"  
 #include        "scrnmng.h"  #include        "scrnmng.h"
 #include        "soundmng.h"  #include        "soundmng.h"
 #include        "sysmng.h"  #include        "sysmng.h"
   #include        "taskmng.h"
 #include        "winkbd.h"  #include        "winkbd.h"
 #include        "ini.h"  #include        "ini.h"
 #include        "memory.h"  #include        "memory.h"
Line 26 Line 25
 #include        "fddfile.h"  #include        "fddfile.h"
 #include        "font.h"  #include        "font.h"
 #include        "timing.h"  #include        "timing.h"
 #include        "debugsub.h"  #include        "statsave.h"
   #include        "vramhdl.h"
   #include        "menubase.h"
   #include        "sysmenu.h"
   
   
 static  const char      szAppCaption[] = STRLITERAL("Neko Project II");  static const TCHAR szAppCaption[] = STRLITERAL("Neko Project II (PocketPC)");
 static  const char      szClassName[] = STRLITERAL("NP2-MainWindow");  static const TCHAR szClassName[] = STRLITERAL("NP2-MainWindow");
   
   
                 NP2OSCFG        np2oscfg = {0, 2};                  NP2OSCFG        np2oscfg = {0, 2, 0, 0};
                 HWND            hWndMain;                  HWND            hWndMain;
                 HINSTANCE       hInst;                  HINSTANCE       hInst;
                 HINSTANCE       hPrev;                  HINSTANCE       hPrev;
                 char            modulefile[MAX_PATH];                  char            modulefile[MAX_PATH];
                   BOOL            sysrunning;
   
 static  UINT            framecnt;  static  UINT            framecnt;
 static  UINT            waitcnt;  static  UINT            waitcnt;
 static  UINT            framemax = 1;  static  UINT            framemax = 1;
   
   
   // ---- resume
   
   static void getstatfilename(char *path, const char *ext, int size) {
   
           file_cpyname(path, modulefile, size);
           file_cutext(path);
           file_catname(path, str_dot, size);
           file_catname(path, ext, size);
   }
   
   static int flagsave(const char *ext) {
   
           int             ret;
           char    path[MAX_PATH];
   
           getstatfilename(path, ext, sizeof(path));
           ret = statsave_save(path);
           if (ret) {
                   file_delete(path);
           }
           return(ret);
   }
   
   static void flagdelete(const char *ext) {
   
           char    path[MAX_PATH];
   
           getstatfilename(path, ext, sizeof(path));
           file_delete(path);
   }
   
   static int flagload(const char *ext, const char *title, BOOL force) {
   
           int             ret;
           int             id;
           char    path[MAX_PATH];
           char    buf[1024];
           char    buf2[1024 + 256];
   
           getstatfilename(path, ext, sizeof(path));
           id = DID_YES;
           ret = statsave_check(path, buf, sizeof(buf));
           if (ret & (~NP2FLAG_DISKCHG)) {
                   menumbox("Couldn't restart", title, MBOX_OK | MBOX_ICONSTOP);
                   id = DID_NO;
           }
           else if ((!force) && (ret & NP2FLAG_DISKCHG)) {
                   wsprintf(buf2, "Conflict!\n\n%s\nContinue?", buf);
                   id = menumbox(buf2, title, MBOX_YESNOCAN | MBOX_ICONQUESTION);
           }
           if (id == DID_YES) {
                   statsave_load(path);
           }
           return(id);
   }
   
   
 // ---- proc  // ---- proc
   
 LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {  LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
Line 58  LRESULT CALLBACK WndProc(HWND hWnd, UINT Line 118  LRESULT CALLBACK WndProc(HWND hWnd, UINT
   
                 case WM_PAINT:                  case WM_PAINT:
                         hdc = BeginPaint(hWnd, &ps);                          hdc = BeginPaint(hWnd, &ps);
                         scrndraw_redraw();                          if (!sysrunning) {
                                   scrnmng_clear(TRUE);
                           }
                           else {
                                   scrndraw_redraw();
                           }
                         EndPaint(hWnd, &ps);                          EndPaint(hWnd, &ps);
                         break;                          break;
   
                 case WM_KEYDOWN:                  case WM_KEYDOWN:
                         if (wParam == VK_F11) {                          if (wParam == VK_F11) {
                                 return(DefWindowProc(hWnd, WM_SYSKEYDOWN, VK_F10, lParam));                                  if (menuvram == NULL) {
                                           sysmenu_menuopen(0, 0, 0);
                                   }
                                   else {
                                           menubase_close();
                                   }
                           }
                           else {
                                   winkbd_keydown(wParam, lParam);
                         }                          }
                         winkeydown106(wParam, lParam);  
                         break;                          break;
   
                 case WM_KEYUP:                  case WM_KEYUP:
                         winkeyup106(wParam, lParam);                          winkbd_keyup(wParam, lParam);
                         break;                          break;
   
                 case WM_SYSKEYDOWN:                  case WM_SYSKEYDOWN:
                         winkeydown106(wParam, lParam);                          winkbd_keydown(wParam, lParam);
                         break;                          break;
   
                 case WM_SYSKEYUP:                  case WM_SYSKEYUP:
                         winkeyup106(wParam, lParam);                          winkbd_keyup(wParam, lParam);
                           break;
   
                   case WM_MOUSEMOVE:
                           if (scrnmng_mousepos(&lParam) == SUCCESS) {
                                   if (menuvram == NULL) {
                                   }
                                   else {
                                           menubase_moving(LOWORD(lParam), HIWORD(lParam), 0);
                                   }
                           }
                           break;
   
                   case WM_LBUTTONDOWN:
                           if (scrnmng_mousepos(&lParam) == SUCCESS) {
                                   if (menuvram == NULL) {
                                   }
                                   else {
                                           menubase_moving(LOWORD(lParam), HIWORD(lParam), 1);
                                   }
                           }
                           break;
   
                   case WM_LBUTTONUP:
                           if (scrnmng_mousepos(&lParam) == SUCCESS) {
                                   if (menuvram == NULL) {
                                           sysmenu_menuopen(0, LOWORD(lParam), HIWORD(lParam));
                                   }
                                   else {
                                           menubase_moving(LOWORD(lParam), HIWORD(lParam), 2);
                                   }
                           }
                         break;                          break;
   
                 case WM_ENTERSIZEMOVE:                  case WM_ENTERSIZEMOVE:
Line 90  LRESULT CALLBACK WndProc(HWND hWnd, UINT Line 193  LRESULT CALLBACK WndProc(HWND hWnd, UINT
                         break;                          break;
   
                 case WM_CLOSE:                  case WM_CLOSE:
                         DestroyWindow(hWnd);                          taskmng_exit();
                         break;                          break;
   
                 case WM_DESTROY:                  case WM_DESTROY:
                         PostQuitMessage(0);  //                      PostQuitMessage(0);
                         break;                          break;
   
                 case WM_NP2CMD:  #if defined(WAVEMNG_CBMAIN)
                         switch(LOWORD(lParam)) {                  case MM_WOM_DONE:
                                 case NP2CMD_EXIT:                          soundmng_cb(MM_WOM_DONE, (HWAVEOUT)wParam, (WAVEHDR *)lParam);
                                 case NP2CMD_EXIT2:  
                                         PostQuitMessage(0);  
                                         break;  
   
                                 case NP2CMD_RESET:  
                                         pccore_cfgupdate();  
                                         pccore_reset();  
                                         break;  
                         }  
                         break;                          break;
   #endif
   
                 default:                  default:
                         return(DefWindowProc(hWnd, msg, wParam, lParam));                          return(DefWindowProc(hWnd, msg, wParam, lParam));
Line 118  LRESULT CALLBACK WndProc(HWND hWnd, UINT Line 213  LRESULT CALLBACK WndProc(HWND hWnd, UINT
 }  }
   
   
 static void processwait(UINT waitcnt) {  #define framereset(cnt)         framecnt = 0
   
         if (timing_getcount() >= waitcnt) {  static void processwait(UINT cnt) {
   
           if (timing_getcount() >= cnt) {
                 timing_setcount(0);                  timing_setcount(0);
                 framecnt = 0;                  framereset(cnt);
         }          }
         else {          else {
                 Sleep(1);                  Sleep(1);
Line 131  static void processwait(UINT waitcnt) { Line 228  static void processwait(UINT waitcnt) {
   
   
 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
                                                                                 LPSTR lpszCmdLine, int nCmdShow) {                                                                                  LPTSTR lpszCmdLine, int nCmdShow) {
   
           HWND            hWnd;
         WNDCLASS        np2;          WNDCLASS        np2;
           int                     id;
         MSG                     msg;          MSG                     msg;
         HWND            hwndorg;  
           hWnd = FindWindow(szClassName, NULL);
           if (hWnd != NULL) {
                   ShowWindow(hWnd, SW_RESTORE);
                   SetForegroundWindow(hWnd);
                   return(FALSE);
           }
   
         GetModuleFileName(NULL, modulefile, sizeof(modulefile));          GetModuleFileName(NULL, modulefile, sizeof(modulefile));
         dosio_init();          dosio_init();
         file_setcd(modulefile);          file_setcd(modulefile);
         initload();          initload();
   
         srand((unsigned)time(NULL));  //      srand((unsigned)time(NULL));
   
         if ((hwndorg = FindWindow(szClassName, NULL)) != NULL) {  
                 ShowWindow(hwndorg, SW_RESTORE);  
                 SetForegroundWindow(hwndorg);  
                 dosio_term();  
                 return(FALSE);  
         }  
   
         hInst = hInstance;          hInst = hInstance;
         hPrev = hPreInst;          hPrev = hPreInst;
         TRACEINIT();          TRACEINIT();
   
           inputmng_init();
         keystat_reset();          keystat_reset();
   
         if (!hPreInst) {          if (!hPreInst) {
Line 172  int WINAPI WinMain(HINSTANCE hInstance,  Line 272  int WINAPI WinMain(HINSTANCE hInstance, 
                 }                  }
         }          }
   
         hWndMain = CreateWindowEx(0, szClassName, szAppCaption,          hWnd = CreateWindow(szClassName, szAppCaption,
                                                 WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |                                                  WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
                                                 WS_MINIMIZEBOX,                                                  WS_MINIMIZEBOX,
                                                 0, 0, 320, 240,                                                  0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT,
                                                 NULL, NULL, hInstance, NULL);                                                  NULL, NULL, hInstance, NULL);
           hWndMain = hWnd;
           if (hWnd == NULL) {
                   goto np2main_err1;
           }
   
         scrnmng_initialize();          scrnmng_initialize();
   
         ShowWindow(hWndMain, nCmdShow);          ShowWindow(hWnd, nCmdShow);
         UpdateWindow(hWndMain);          UpdateWindow(hWnd);
   
         if (scrnmng_create(hWndMain, 320, 240) != SUCCESS) {          if (sysmenu_create() != SUCCESS) {
                 MessageBox(hWndMain, "Couldn't create DirectDraw Object",                  DestroyWindow(hWnd);
                   goto np2main_err1;
           }
           if (scrnmng_create(hWnd, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT)
                                                                                                                                   != SUCCESS) {
                   MessageBox(hWnd, "Couldn't create DirectDraw Object",
                                                                         szAppCaption, MB_OK | MB_ICONSTOP);                                                                          szAppCaption, MB_OK | MB_ICONSTOP);
                 return(FALSE);                  DestroyWindow(hWnd);
                   goto np2main_err2;
         }          }
   
           soundmng_initialize();
         commng_initialize();          commng_initialize();
         sysmng_initialize();          sysmng_initialize();
           taskmng_initialize();
         pccore_init();          pccore_init();
         S98_init();          S98_init();
   
         scrndraw_redraw();          scrndraw_redraw();
         pccore_reset();          pccore_reset();
   
         while(1) {          if (np2oscfg.resume) {
                   id = flagload(str_sav, str_resume, FALSE);
                   if (id == DID_CANCEL) {
                           DestroyWindow(hWndMain);
                           goto np2main_err3;
                   }
           }
   
           sysrunning = TRUE;
   
           while(taskmng_isavail()) {
                 if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) {                  if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) {
                         if (!GetMessage(&msg, NULL, 0, 0)) {                          if (!GetMessage(&msg, NULL, 0, 0)) {
                                 break;                                  break;
Line 255  int WINAPI WinMain(HINSTANCE hInstance,  Line 377  int WINAPI WinMain(HINSTANCE hInstance, 
                                                 else {                                                  else {
                                                         timing_setcount(cnt - framecnt);                                                          timing_setcount(cnt - framecnt);
                                                 }                                                  }
                                                 framecnt = 0;                                                  framereset(0);
                                         }                                          }
                                 }                                  }
                                 else {                                  else {
Line 266  int WINAPI WinMain(HINSTANCE hInstance,  Line 388  int WINAPI WinMain(HINSTANCE hInstance, 
                 }                  }
         }          }
   
           sysrunning = 0;
   
           DestroyWindow(hWnd);
   
         pccore_cfgupdate();          pccore_cfgupdate();
           if (np2oscfg.resume) {
                   flagsave(str_sav);
           }
           else {
                   flagdelete(str_sav);
           }
         pccore_term();          pccore_term();
         S98_trash();          S98_trash();
           soundmng_deinitialize();
         scrnmng_destroy();          scrnmng_destroy();
           sysmenu_destroy();
   
         if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {          if (sys_updates & (SYS_UPDATECFG | SYS_UPDATEOSCFG)) {
                 initsave();                  initsave();
Line 279  int WINAPI WinMain(HINSTANCE hInstance,  Line 412  int WINAPI WinMain(HINSTANCE hInstance, 
         dosio_term();          dosio_term();
   
         return(msg.wParam);          return(msg.wParam);
   
   np2main_err3:
           pccore_term();
           S98_trash();
           soundmng_deinitialize();
           scrnmng_destroy();
   
   np2main_err2:
           sysmenu_destroy();
   
   np2main_err1:
           TRACETERM();
           dosio_term();
           return(FALSE);
 }  }
   

Removed from v.1.2  
changed lines
  Added in v.1.5


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