Diff for /np2/win9x/scrnmng.cpp between versions 1.23 and 1.27

version 1.23, 2007/01/08 01:16:59 version 1.27, 2011/03/07 09:54:11
Line 1 Line 1
 #include        "compiler.h"  /**
 #include        <ddraw.h>   * @file        scrnmng.cpp
    * @brief       Screen Manager (DirectDraw2)
    *
    * @author      $Author$
    * @date        $Date$
    */
   
   #include "compiler.h"
   #include <ddraw.h>
 #ifndef __GNUC__  #ifndef __GNUC__
 #include        <winnls32.h>  #include <winnls32.h>
 #endif  #endif
 #include        "resource.h"  #include "resource.h"
 #include        "np2.h"  #include "np2.h"
 #include        "winloc.h"  #include "winloc.h"
 #include        "mousemng.h"  #include "mousemng.h"
 #include        "scrnmng.h"  #include "scrnmng.h"
 #include        "sysmng.h"  #include "sysmng.h"
 #include        "menu.h"  #include "menu.h"
 #include        "np2class.h"  #include "np2class.h"
 #include        "pccore.h"  #include "pccore.h"
 #include        "scrndraw.h"  #include "scrndraw.h"
 #include        "palettes.h"  #include "palettes.h"
   
 #if defined(SUPPORT_DCLOCK)  #if defined(SUPPORT_DCLOCK)
 #include        "dclock.h"  #include "dclock.h"
 #endif  #endif
   
   #if !defined(__GNUC__)
   #pragma comment(lib, "ddraw.lib")
   #pragma comment(lib, "dxguid.lib")
   #endif  // !defined(__GNUC__)
   
 extern WINLOCEX np2_winlocexallwin(HWND base);  extern WINLOCEX np2_winlocexallwin(HWND base);
   
   
Line 236  static void renewalclientsize(BOOL winlo Line 249  static void renewalclientsize(BOOL winlo
   
                 wlex = NULL;                  wlex = NULL;
                 if (winloc) {                  if (winloc) {
                         wlex = np2_winlocexallwin(hWndMain);                          wlex = np2_winlocexallwin(g_hWndMain);
                 }                  }
                 winlocex_setholdwnd(wlex, hWndMain);                  winlocex_setholdwnd(wlex, g_hWndMain);
                 setwindowsize(hWndMain, scrnwidth, scrnheight);                  setwindowsize(g_hWndMain, scrnwidth, scrnheight);
                 winlocex_move(wlex);                  winlocex_move(wlex);
                 winlocex_destroy(wlex);                  winlocex_destroy(wlex);
         }          }
Line 297  static void clearoutscreen(void) { Line 310  static void clearoutscreen(void) {
         POINT   clipt;          POINT   clipt;
         RECT    target;          RECT    target;
   
         GetClientRect(hWndMain, &base);          GetClientRect(g_hWndMain, &base);
         clipt.x = 0;          clipt.x = 0;
         clipt.y = 0;          clipt.y = 0;
         ClientToScreen(hWndMain, &clipt);          ClientToScreen(g_hWndMain, &clipt);
         base.left += clipt.x;          base.left += clipt.x;
         base.top += clipt.y;          base.top += clipt.y;
         base.right += clipt.x;          base.right += clipt.x;
Line 321  const RECT *scrn; Line 334  const RECT *scrn;
         base.top = 0;          base.top = 0;
         base.right = ddraw.width;          base.right = ddraw.width;
         base.bottom = ddraw.height;          base.bottom = ddraw.height;
         if (GetWindowLong(hWndMain, NP2GWL_HMENU)) {          if (GetWindowLongPtr(g_hWndMain, NP2GWLP_HMENU)) {
                 scrn = &ddraw.scrn;                  scrn = &ddraw.scrn;
                 base.top = 0;                  base.top = 0;
         }          }
Line 340  static void paletteinit(void) { Line 353  static void paletteinit(void) {
         HDC     hdc;          HDC     hdc;
         UINT    i;          UINT    i;
   
         hdc = GetDC(hWndMain);          hdc = GetDC(g_hWndMain);
         GetSystemPaletteEntries(hdc, 0, 256, ddraw.pal);          GetSystemPaletteEntries(hdc, 0, 256, ddraw.pal);
         ReleaseDC(hWndMain, hdc);          ReleaseDC(g_hWndMain, hdc);
 #if defined(SUPPORT_DCLOCK)  #if defined(SUPPORT_DCLOCK)
         for (i=0; i<4; i++) {          for (i=0; i<4; i++) {
                 ddraw.pal[i+START_PALORG].peBlue = dclockpal.pal32[i].p.b;                  ddraw.pal[i+START_PALORG].peBlue = dclockpal.pal32[i].p.b;
Line 411  void scrnmng_initialize(void) { Line 424  void scrnmng_initialize(void) {
         scrnstat.height = 400;          scrnstat.height = 400;
         scrnstat.extend = 1;          scrnstat.extend = 1;
         scrnstat.multiple = 8;          scrnstat.multiple = 8;
         setwindowsize(hWndMain, 640, 400);          setwindowsize(g_hWndMain, 640, 400);
 }  }
   
 BRESULT scrnmng_create(UINT8 scrnmode) {  BRESULT scrnmng_create(UINT8 scrnmode) {
Line 429  BRESULT scrnmng_create(UINT8 scrnmode) { Line 442  BRESULT scrnmng_create(UINT8 scrnmode) {
         DEVMODE                 devmode;          DEVMODE                 devmode;
   
         ZeroMemory(&scrnmng, sizeof(scrnmng));          ZeroMemory(&scrnmng, sizeof(scrnmng));
         winstyle = GetWindowLong(hWndMain, GWL_STYLE);          winstyle = GetWindowLong(g_hWndMain, GWL_STYLE);
         winstyleex = GetWindowLong(hWndMain, GWL_EXSTYLE);          winstyleex = GetWindowLong(g_hWndMain, GWL_EXSTYLE);
         hmenu = GetMenu(hWndMain);          hmenu = GetMenu(g_hWndMain);
         if (scrnmode & SCRNMODE_FULLSCREEN) {          if (scrnmode & SCRNMODE_FULLSCREEN) {
                 scrnmode &= ~SCRNMODE_ROTATEMASK;                  scrnmode &= ~SCRNMODE_ROTATEMASK;
                 scrnmng.flag = SCRNFLAG_FULLSCREEN;                  scrnmng.flag = SCRNFLAG_FULLSCREEN;
Line 442  BRESULT scrnmng_create(UINT8 scrnmode) { Line 455  BRESULT scrnmng_create(UINT8 scrnmode) {
                 CheckMenuItem(hmenu, IDM_FULLSCREEN, MF_CHECKED);                  CheckMenuItem(hmenu, IDM_FULLSCREEN, MF_CHECKED);
                 ddraw.menudisp = 0;                  ddraw.menudisp = 0;
                 ddraw.menusize = GetSystemMetrics(SM_CYMENU);                  ddraw.menusize = GetSystemMetrics(SM_CYMENU);
                 np2class_enablemenu(hWndMain, FALSE);                  np2class_enablemenu(g_hWndMain, FALSE);
         }          }
         else {          else {
                 scrnmng.flag = SCRNFLAG_HAVEEXTEND;                  scrnmng.flag = SCRNFLAG_HAVEEXTEND;
Line 458  BRESULT scrnmng_create(UINT8 scrnmode) { Line 471  BRESULT scrnmng_create(UINT8 scrnmode) {
                 CheckMenuItem(hmenu, IDM_WINDOW, MF_CHECKED);                  CheckMenuItem(hmenu, IDM_WINDOW, MF_CHECKED);
                 CheckMenuItem(hmenu, IDM_FULLSCREEN, MF_UNCHECKED);                  CheckMenuItem(hmenu, IDM_FULLSCREEN, MF_UNCHECKED);
         }          }
         SetWindowLong(hWndMain, GWL_STYLE, winstyle);          SetWindowLong(g_hWndMain, GWL_STYLE, winstyle);
         SetWindowLong(hWndMain, GWL_EXSTYLE, winstyleex);          SetWindowLong(g_hWndMain, GWL_EXSTYLE, winstyleex);
   
         if (DirectDrawCreate(NULL, &ddraw.ddraw1, NULL) != DD_OK) {          if (DirectDrawCreate(NULL, &ddraw.ddraw1, NULL) != DD_OK) {
                 goto scre_err;                  goto scre_err;
Line 471  BRESULT scrnmng_create(UINT8 scrnmode) { Line 484  BRESULT scrnmng_create(UINT8 scrnmode) {
 #if defined(SUPPORT_DCLOCK)  #if defined(SUPPORT_DCLOCK)
                 dclock_init();                  dclock_init();
 #endif  #endif
                 ddraw2->SetCooperativeLevel(hWndMain,                  ddraw2->SetCooperativeLevel(g_hWndMain,
                                                                                 DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);                                                                                  DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
                 width = np2oscfg.fscrn_cx;                  width = np2oscfg.fscrn_cx;
                 height = np2oscfg.fscrn_cy;                  height = np2oscfg.fscrn_cy;
Line 502  BRESULT scrnmng_create(UINT8 scrnmode) { Line 515  BRESULT scrnmng_create(UINT8 scrnmode) {
                         goto scre_err;                          goto scre_err;
                 }                  }
                 ddraw2->CreateClipper(0, &ddraw.clipper, NULL);                  ddraw2->CreateClipper(0, &ddraw.clipper, NULL);
                 ddraw.clipper->SetHWnd(0, hWndMain);                  ddraw.clipper->SetHWnd(0, g_hWndMain);
   
                 ZeroMemory(&ddsd, sizeof(ddsd));                  ZeroMemory(&ddsd, sizeof(ddsd));
                 ddsd.dwSize = sizeof(ddsd);                  ddsd.dwSize = sizeof(ddsd);
Line 554  BRESULT scrnmng_create(UINT8 scrnmode) { Line 567  BRESULT scrnmng_create(UINT8 scrnmode) {
 #endif  #endif
         }          }
         else {          else {
                 ddraw2->SetCooperativeLevel(hWndMain, DDSCL_NORMAL);                  ddraw2->SetCooperativeLevel(g_hWndMain, DDSCL_NORMAL);
   
                 ZeroMemory(&ddsd, sizeof(ddsd));                  ZeroMemory(&ddsd, sizeof(ddsd));
                 ddsd.dwSize = sizeof(ddsd);                  ddsd.dwSize = sizeof(ddsd);
Line 565  BRESULT scrnmng_create(UINT8 scrnmode) { Line 578  BRESULT scrnmng_create(UINT8 scrnmode) {
                 }                  }
   
                 ddraw2->CreateClipper(0, &ddraw.clipper, NULL);                  ddraw2->CreateClipper(0, &ddraw.clipper, NULL);
                 ddraw.clipper->SetHWnd(0, hWndMain);                  ddraw.clipper->SetHWnd(0, g_hWndMain);
                 ddraw.primsurf->SetClipper(ddraw.clipper);                  ddraw.primsurf->SetClipper(ddraw.clipper);
   
                 ZeroMemory(&ddpf, sizeof(ddpf));                  ZeroMemory(&ddpf, sizeof(ddpf));
Line 615  BRESULT scrnmng_create(UINT8 scrnmode) { Line 628  BRESULT scrnmng_create(UINT8 scrnmode) {
         ddraw.height = height;          ddraw.height = height;
         ddraw.cliping = 0;          ddraw.cliping = 0;
         renewalclientsize(FALSE);          renewalclientsize(FALSE);
         screenupdate = 3;                                       // update!  //      screenupdate = 3;                                       // update!
         return(SUCCESS);          return(SUCCESS);
   
 scre_err:  scre_err:
Line 626  scre_err: Line 639  scre_err:
 void scrnmng_destroy(void) {  void scrnmng_destroy(void) {
   
         if (scrnmng.flag & SCRNFLAG_FULLSCREEN) {          if (scrnmng.flag & SCRNFLAG_FULLSCREEN) {
                 np2class_enablemenu(hWndMain, (!np2oscfg.wintype));                  np2class_enablemenu(g_hWndMain, (!np2oscfg.wintype));
         }          }
 #if defined(SUPPORT_DCLOCK)  #if defined(SUPPORT_DCLOCK)
         if (ddraw.clocksurf) {          if (ddraw.clocksurf) {
Line 652  void scrnmng_destroy(void) { Line 665  void scrnmng_destroy(void) {
         }          }
         if (ddraw.ddraw2) {          if (ddraw.ddraw2) {
                 if (ddraw.scrnmode & SCRNMODE_FULLSCREEN) {                  if (ddraw.scrnmode & SCRNMODE_FULLSCREEN) {
                         ddraw.ddraw2->SetCooperativeLevel(hWndMain, DDSCL_NORMAL);                          ddraw.ddraw2->SetCooperativeLevel(g_hWndMain, DDSCL_NORMAL);
                 }                  }
                 ddraw.ddraw2->Release();                  ddraw.ddraw2->Release();
                 ddraw.ddraw2 = NULL;                  ddraw.ddraw2 = NULL;
Line 689  void scrnmng_fullscrnmenu(int y) { Line 702  void scrnmng_fullscrnmenu(int y) {
                 if (ddraw.menudisp != menudisp) {                  if (ddraw.menudisp != menudisp) {
                         ddraw.menudisp = menudisp;                          ddraw.menudisp = menudisp;
                         if (menudisp == 1) {                          if (menudisp == 1) {
                                 np2class_enablemenu(hWndMain, TRUE);                                  np2class_enablemenu(g_hWndMain, TRUE);
                         }                          }
                         else {                          else {
                                 np2class_enablemenu(hWndMain, FALSE);                                  np2class_enablemenu(g_hWndMain, FALSE);
                                 clearoutfullscreen();                                  clearoutfullscreen();
                         }                          }
                 }                  }
Line 707  void scrnmng_topwinui(void) { Line 720  void scrnmng_topwinui(void) {
                         ddraw.primsurf->SetClipper(ddraw.clipper);                          ddraw.primsurf->SetClipper(ddraw.clipper);
                 }                  }
 #ifndef __GNUC__  #ifndef __GNUC__
                 WINNLSEnableIME(hWndMain, TRUE);                  WINNLSEnableIME(g_hWndMain, TRUE);
 #endif  #endif
         }          }
 }  }
Line 716  void scrnmng_clearwinui(void) { Line 729  void scrnmng_clearwinui(void) {
   
         if ((ddraw.cliping > 0) && (!(--ddraw.cliping))) {          if ((ddraw.cliping > 0) && (!(--ddraw.cliping))) {
 #ifndef __GNUC__  #ifndef __GNUC__
                 WINNLSEnableIME(hWndMain, FALSE);                  WINNLSEnableIME(g_hWndMain, FALSE);
 #endif  #endif
                 if (scrnmng.flag & SCRNFLAG_FULLSCREEN) {                  if (scrnmng.flag & SCRNFLAG_FULLSCREEN) {
                         ddraw.primsurf->SetClipper(0);                          ddraw.primsurf->SetClipper(0);
                 }                  }
         }          }
         if (scrnmng.flag & SCRNFLAG_FULLSCREEN) {          if (scrnmng.flag & SCRNFLAG_FULLSCREEN) {
                 np2class_enablemenu(hWndMain, FALSE);                  np2class_enablemenu(g_hWndMain, FALSE);
                 clearoutfullscreen();                  clearoutfullscreen();
                 ddraw.menudisp = 0;                  ddraw.menudisp = 0;
         }          }
         else {          else {
                 if (np2oscfg.wintype) {                  if (np2oscfg.wintype) {
                         np2class_enablemenu(hWndMain, FALSE);                          np2class_enablemenu(g_hWndMain, FALSE);
                         InvalidateRect(hWndMain, NULL, TRUE);                          InvalidateRect(g_hWndMain, NULL, TRUE);
                 }                  }
         }          }
         mousemng_enable(MOUSEPROC_WINUI);          mousemng_enable(MOUSEPROC_WINUI);
Line 818  void scrnmng_update(void) { Line 831  void scrnmng_update(void) {
                                 scrnmng.allflash = 0;                                  scrnmng.allflash = 0;
                                 clearoutfullscreen();                                  clearoutfullscreen();
                         }                          }
                         if (GetWindowLong(hWndMain, NP2GWL_HMENU)) {                          if (GetWindowLongPtr(g_hWndMain, NP2GWLP_HMENU)) {
                                 rect = &ddraw.rect;                                  rect = &ddraw.rect;
                                 scrn = &ddraw.scrn;                                  scrn = &ddraw.scrn;
                         }                          }
Line 842  void scrnmng_update(void) { Line 855  void scrnmng_update(void) {
                         }                          }
                         clip.x = 0;                          clip.x = 0;
                         clip.y = 0;                          clip.y = 0;
                         ClientToScreen(hWndMain, &clip);                          ClientToScreen(g_hWndMain, &clip);
                         dst.left = clip.x + ddraw.scrn.left;                          dst.left = clip.x + ddraw.scrn.left;
                         dst.top = clip.y + ddraw.scrn.top;                          dst.top = clip.y + ddraw.scrn.top;
                         dst.right = clip.x + ddraw.scrn.right;                          dst.right = clip.x + ddraw.scrn.right;
Line 897  const RECT   *scrn; Line 910  const RECT   *scrn;
         if (!dclock_disp()) {          if (!dclock_disp()) {
                 return;                  return;
         }          }
         if (GetWindowLong(hWndMain, NP2GWL_HMENU)) {          if (GetWindowLongPtr(g_hWndMain, NP2GWLP_HMENU)) {
                 scrn = &ddraw.scrn;                  scrn = &ddraw.scrn;
         }          }
         else {          else {
Line 959  void scrnmng_entersizing(void) { Line 972  void scrnmng_entersizing(void) {
         int             cx;          int             cx;
         int             cy;          int             cy;
   
         GetWindowRect(hWndMain, &rectwindow);          GetWindowRect(g_hWndMain, &rectwindow);
         GetClientRect(hWndMain, &rectclient);          GetClientRect(g_hWndMain, &rectclient);
         scrnsizing.bx = (np2oscfg.paddingx * 2) +          scrnsizing.bx = (np2oscfg.paddingx * 2) +
                                         (rectwindow.right - rectwindow.left) -                                          (rectwindow.right - rectwindow.left) -
                                         (rectclient.right - rectclient.left);                                          (rectclient.right - rectclient.left);
Line 1051  void scrnmng_exitsizing(void) { Line 1064  void scrnmng_exitsizing(void) {
   
         sysmenu_setscrnmul(scrnsizing.mul);          sysmenu_setscrnmul(scrnsizing.mul);
         scrnmng_setmultiple(scrnsizing.mul);          scrnmng_setmultiple(scrnsizing.mul);
         InvalidateRect(hWndMain, NULL, TRUE);           // ugh          InvalidateRect(g_hWndMain, NULL, TRUE);         // ugh
 }  }
   

Removed from v.1.23  
changed lines
  Added in v.1.27


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