win9x: adds fullscreen mode

refs #94
 svn merge -r 340:342 https://amethyst.yui.ne.jp/svn-dev/x1/xmil/branches/yui/WORK_01
This commit is contained in:
yui 2015-12-30 15:03:42 +00:00
parent 64de44dd8c
commit 1edca61000
11 changed files with 373 additions and 22 deletions

View File

@ -8,8 +8,11 @@
#include "resource.h"
#include <commctrl.h>
#include <vector>
#include "misc/PropProc.h"
#include "xmil.h"
#include "scrnmng.h"
#include "sysmng.h"
#include "misc/PropProc.h"
#include "dialogs.h"
#include "pccore.h"
#include "palettes.h"
@ -53,6 +56,7 @@ BOOL ScrOptVideoPage::OnInitDialog()
return TRUE;
}
/**
* OK (IDOK ID )
*/
@ -109,6 +113,109 @@ LRESULT ScrOptVideoPage::WindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
return CPropPageProc::WindowProc(nMsg, wParam, lParam);
}
// ----
/**
* @brief Fullscreen
*/
class ScrOptFullscreenPage : public CPropPageProc
{
public:
ScrOptFullscreenPage();
virtual ~ScrOptFullscreenPage();
protected:
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
private:
CNp2ComboBox m_zoom; //!< ズーム
};
static const CBPARAM s_cpZoom[] =
{
{MAKEINTRESOURCE(IDS_ZOOM_NONE), 0},
{MAKEINTRESOURCE(IDS_ZOOM_FIXEDASPECT), 1},
{MAKEINTRESOURCE(IDS_ZOOM_ADJUSTASPECT), 2},
{MAKEINTRESOURCE(IDS_ZOOM_FULL), 3},
};
/**
*
*/
ScrOptFullscreenPage::ScrOptFullscreenPage()
: CPropPageProc(IDD_SCROPT_FULLSCREEN)
{
}
/**
*
*/
ScrOptFullscreenPage::~ScrOptFullscreenPage()
{
}
/**
* WM_INITDIALOG
* @retval TRUE
* @retval FALSE
*/
BOOL ScrOptFullscreenPage::OnInitDialog()
{
const UINT8 c = xmiloscfg.fscrnmod;
CheckDlgButton(IDC_FULLSCREEN_SAMEBPP, (c & FSCRNMOD_SAMEBPP) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(IDC_FULLSCREEN_SAMERES, (c & FSCRNMOD_SAMERES) ? BST_CHECKED : BST_UNCHECKED);
m_zoom.SubclassDlgItem(IDC_FULLSCREEN_ZOOM, this);
m_zoom.Add(s_cpZoom, _countof(s_cpZoom));
m_zoom.SetCurItemData(c & 3);
m_zoom.EnableWindow((c & FSCRNMOD_SAMERES) ? TRUE : FALSE);
return TRUE;
}
/**
* OK (IDOK ID )
*/
void ScrOptFullscreenPage::OnOK()
{
UINT8 c = 0;
if (IsDlgButtonChecked(IDC_FULLSCREEN_SAMEBPP) != BST_UNCHECKED)
{
c |= FSCRNMOD_SAMEBPP;
}
if (IsDlgButtonChecked(IDC_FULLSCREEN_SAMERES) != BST_UNCHECKED)
{
c |= FSCRNMOD_SAMERES;
}
c |= m_zoom.GetCurItemData(xmiloscfg.fscrnmod & 3);
if (xmiloscfg.fscrnmod != c)
{
xmiloscfg.fscrnmod = c;
::sysmng_update(SYS_UPDATEOSCFG);
}
}
/**
*
* @param[in] wParam
* @param[in] lParam
* @retval TRUE
*/
BOOL ScrOptFullscreenPage::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (LOWORD(wParam) == IDC_FULLSCREEN_SAMERES)
{
m_zoom.EnableWindow((IsDlgButtonChecked(IDC_FULLSCREEN_SAMERES) != BST_UNCHECKED) ? TRUE : FALSE);
return TRUE;
}
return FALSE;
}
/**
*
* @param[in] hWnd
@ -120,6 +227,9 @@ void dialog_scropt(HWND hWnd)
ScrOptVideoPage video;
hpsp.push_back(::CreatePropertySheetPage(&video.m_psp));
ScrOptFullscreenPage fullscreen;
hpsp.push_back(::CreatePropertySheetPage(&fullscreen.m_psp));
std::tstring rTitle(LoadTString(IDS_SCREENOPTION));
PROPSHEETHEADER psh;

59
win9x/dialog/dialogs.cpp Normal file
View File

@ -0,0 +1,59 @@
/**
* @file dialogs.cpp
* @brief
*/
#include "compiler.h"
#include "dialogs.h"
#include "strres.h"
void CNp2ComboBox::Add(const UINT32* lpValues, UINT nCount)
{
for (UINT i = 0; i < nCount; i++)
{
TCHAR str[16];
wsprintf(str, str_u, lpValues[i]);
InsertString(GetCount(), str);
}
}
void CNp2ComboBox::Add(PCCBPARAM pcItem, UINT nCount)
{
for (UINT i = 0; i <nCount; i++)
{
std::tstring rString(LoadTString(pcItem[i].lpcszString));
Add(rString.c_str(), pcItem[i].nItemData);
}
}
void CNp2ComboBox::Add(LPCTSTR lpString, DWORD_PTR nItemData)
{
const int nIndex = AddString(lpString);
if (nIndex >= 0)
{
SetItemData(nIndex, nItemData);
}
}
void CNp2ComboBox::SetCurItemData(UINT32 nValue)
{
const int nItems = GetCount();
for (int i = 0; i < nItems; i++)
{
if (GetItemData(i) == nValue)
{
SetCurSel(i);
break;
}
}
}
UINT32 CNp2ComboBox::GetCurItemData(UINT32 nDefault) const
{
int nIndex = GetCurSel();
if (nIndex >= 0)
{
return GetItemData(nIndex);
}
return nDefault;
}

30
win9x/dialog/dialogs.h Normal file
View File

@ -0,0 +1,30 @@
/**
* @file dialogs.h
* @brief
*/
#pragma once
#include "misc/DlgProc.h"
struct tagCBParam
{
LPCTSTR lpcszString;
int nItemData;
};
typedef struct tagCBParam CBPARAM;
typedef struct tagCBParam *PCBPARAM;
typedef const struct tagCBParam *PCCBPARAM;
/**
* @brief
*/
class CNp2ComboBox : public CComboBoxProc
{
public:
void Add(const UINT32* lpValues, UINT nCount);
void Add(PCCBPARAM pcItem, UINT nCount);
void Add(LPCTSTR lpString, DWORD_PTR nItemData);
void SetCurItemData(UINT32 nValue);
UINT32 GetCurItemData(UINT32 nDefault) const;
};

View File

@ -302,6 +302,7 @@ static const TCHAR s_szIniTitle[] = TEXT("Xmillennium"); //!<
enum
{
PFRO_BOOL = PFFLAG_RO + PFTYPE_BOOL,
PFRO_UINT8 = PFFLAG_RO + PFTYPE_UINT8,
PFRO_HEX32 = PFFLAG_RO + PFTYPE_HEX32
};
@ -361,6 +362,9 @@ static const PFTBL s_IniItems[] =
PFAND("clock_up", PFRO_HEX32, &xmiloscfg.clockcolor1, 0xffffff),
PFAND("clock_dn", PFRO_HEX32, &xmiloscfg.clockcolor2, 0xffffff),
#endif /* defined(SUPPORT_DCLOCK) */
PFVAL("fscrnbpp", PFRO_UINT8, &xmiloscfg.fscrnbpp),
PFVAL("fscrnmod", PFTYPE_HEX8, &xmiloscfg.fscrnmod),
};
//! .ini Šg£Žq

View File

@ -8,6 +8,7 @@
#define IDD_NEWDISK 104
#define IDD_ABOUT 105
#define IDD_SCROPT 106
#define IDD_SCROPT_FULLSCREEN 107
#define IDR_SYS 201
#define IDR_STAT 202
#define IDR_FDD0MENU 203
@ -28,6 +29,9 @@
#define IDC_MAKE2D 1008
#define IDC_MAKE2HD 1009
#define IDC_XMILVER 1010
#define IDC_FULLSCREEN_SAMEBPP 1101
#define IDC_FULLSCREEN_SAMERES 1102
#define IDC_FULLSCREEN_ZOOM 1103
#define IDS_APP_NAME 30001
#define IDS_CAPTION_KEYDISP 30101
#define IDS_CAPTION_SOFTKBD 30102
@ -47,6 +51,10 @@
#define IDS_X1FEXT 31032
#define IDS_X1FFILTER 31033
#define IDS_SCREENOPTION 31051
#define IDS_ZOOM_NONE 31052
#define IDS_ZOOM_FIXEDASPECT 31053
#define IDS_ZOOM_ADJUSTASPECT 31054
#define IDS_ZOOM_FULL 31055
#define IDM_IPLRESET 40000
#define IDM_NMIRESET 40001
#define IDM_CONFIG 40002

View File

@ -54,6 +54,8 @@ typedef struct {
int menusize;
RECT scrn;
RECT rect;
RECT scrnclip;
RECT rectclip;
PALETTEENTRY pal[256];
} DDRAW;
@ -143,10 +145,67 @@ static void renewalclientsize(BOOL winloc) {
if (ddraw.scrnmode & SCRNMODE_FULLSCREEN) {
ddraw.rect.right = width;
ddraw.rect.bottom = height;
ddraw.scrn.left = (ddraw.width - width) / 2;
ddraw.scrn.top = (ddraw.height - height) / 2;
ddraw.scrn.right = ddraw.scrn.left + width;
ddraw.scrn.bottom = ddraw.scrn.top + height;
scrnwidth = width;
scrnheight = height;
const UINT8 fscrnmod = xmiloscfg.fscrnmod & FSCRNMOD_ASPECTMASK;
switch (fscrnmod)
{
default:
case FSCRNMOD_NORESIZE:
break;
case FSCRNMOD_ASPECTFIX8:
scrnwidth = (ddraw.width << 3) / width;
scrnheight = (ddraw.height << 3) / height;
multiple = min(scrnwidth, scrnheight);
scrnwidth = (width * multiple) >> 3;
scrnheight = (height * multiple) >> 3;
break;
case FSCRNMOD_ASPECTFIX:
scrnwidth = ddraw.width;
scrnheight = (scrnwidth * height) / width;
if (scrnheight >= ddraw.height) {
scrnheight = ddraw.height;
scrnwidth = (scrnheight * width) / height;
}
break;
case FSCRNMOD_LARGE:
scrnwidth = ddraw.width;
scrnheight = ddraw.height;
break;
}
ddraw.scrn.left = (ddraw.width - scrnwidth) / 2;
ddraw.scrn.top = (ddraw.height - scrnheight) / 2;
ddraw.scrn.right = ddraw.scrn.left + scrnwidth;
ddraw.scrn.bottom = ddraw.scrn.top + scrnheight;
// メニュー表示時の描画領域
ddraw.rectclip = ddraw.rect;
ddraw.scrnclip = ddraw.scrn;
if (ddraw.scrnclip.top < ddraw.menusize) {
ddraw.scrnclip.top = ddraw.menusize;
int tmpcy = ddraw.height - ddraw.menusize;
if (scrnheight > tmpcy) {
switch(fscrnmod) {
default:
case FSCRNMOD_NORESIZE:
tmpcy = min(tmpcy, height);
ddraw.rectclip.bottom = tmpcy;
break;
case FSCRNMOD_ASPECTFIX8:
case FSCRNMOD_ASPECTFIX:
ddraw.rectclip.bottom = (tmpcy * height) / scrnheight;
break;
case FSCRNMOD_LARGE:
break;
}
}
ddraw.scrnclip.bottom = ddraw.menusize + tmpcy;
}
}
else {
multiple = 8;
@ -232,18 +291,21 @@ static void clearoutscreen(void) {
static void clearoutfullscreen(void) {
RECT base;
const RECT *scrn;
base.left = 0;
base.top = 0;
base.right = ddraw.width;
base.bottom = ddraw.height;
if (GetWindowLong(hWndMain, EXTGWL_HMENU)) {
scrn = &ddraw.scrn;
base.top = 0;
}
else {
scrn = &ddraw.scrnclip;
base.top = ddraw.menusize;
}
clearoutofrect(&ddraw.scrn, &base);
clearoutofrect(scrn, &base);
#if defined(SUPPORT_DCLOCK)
DispClock::GetInstance()->Redraw();
#endif // defined(SUPPORT_DCLOCK)
@ -336,6 +398,7 @@ BRESULT scrnmng_create(UINT8 scrnmode) {
LPDIRECTDRAW2 ddraw2;
DDSURFACEDESC ddsd;
DDPIXELFORMAT ddpf;
int width;
int height;
UINT bitcolor;
@ -373,13 +436,30 @@ BRESULT scrnmng_create(UINT8 scrnmode) {
#endif // defined(SUPPORT_DCLOCK)
ddraw2->SetCooperativeLevel(hWndMain,
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
width = SURFACE_WIDTH;
height = 480;
bitcolor = 8;
if (scrnmode & (SCRNMODE_SYSHIGHCOLOR | SCRNMODE_COREHIGHCOLOR)) {
bitcolor = 16;
bitcolor = xmiloscfg.fscrnbpp;
const UINT8 fscrnmod = xmiloscfg.fscrnmod;
if (fscrnmod & (FSCRNMOD_SAMERES | FSCRNMOD_SAMEBPP))
{
DEVMODE devmode;
if (EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &devmode))
{
if (fscrnmod & FSCRNMOD_SAMERES)
{
width = devmode.dmPelsWidth;
height = devmode.dmPelsHeight;
}
if (ddraw2->SetDisplayMode(SURFACE_WIDTH, height,
bitcolor, 0, 0) != DD_OK) {
if (fscrnmod & FSCRNMOD_SAMEBPP)
{
bitcolor = devmode.dmBitsPerPel;
}
}
}
if (bitcolor == 0) {
bitcolor = (scrnmode & (SCRNMODE_SYSHIGHCOLOR | SCRNMODE_COREHIGHCOLOR)) ? 16 : 8;
}
if (ddraw2->SetDisplayMode(width, height, bitcolor, 0, 0) != DD_OK) {
goto scre_err;
}
ddraw2->CreateClipper(0, &ddraw.clipper, NULL);
@ -405,7 +485,7 @@ BRESULT scrnmng_create(UINT8 scrnmode) {
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = SURFACE_WIDTH;
ddsd.dwHeight = height;
ddsd.dwHeight = SURFACE_HEIGHT;
if (ddraw2->CreateSurface(&ddsd, &ddraw.backsurf, NULL) != DD_OK) {
goto scre_err;
}
@ -463,6 +543,7 @@ BRESULT scrnmng_create(UINT8 scrnmode) {
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = SURFACE_WIDTH;
ddsd.dwHeight = SURFACE_HEIGHT;
width = SURFACE_WIDTH;
height = SURFACE_HEIGHT;
if (ddraw2->CreateSurface(&ddsd, &ddraw.backsurf, NULL) != DD_OK) {
@ -486,7 +567,7 @@ BRESULT scrnmng_create(UINT8 scrnmode) {
scrnmng.bpp = (UINT8)bitcolor;
scrnsurf.bpp = bitcolor;
ddraw.scrnmode = scrnmode;
ddraw.width = SURFACE_WIDTH;
ddraw.width = width;
ddraw.height = height;
ddraw.cliping = 0;
renewalclientsize(FALSE);
@ -661,6 +742,8 @@ void scrnmng_update(void) {
POINT clip;
RECT dst;
RECT *rect;
RECT *scrn;
HRESULT r;
if (scrnmng.palchanged) {
@ -673,7 +756,22 @@ void scrnmng_update(void) {
scrnmng.allflash = 0;
clearoutfullscreen();
}
dst = ddraw.scrn;
if (GetWindowLong(hWndMain, EXTGWL_HMENU)) {
rect = &ddraw.rect;
scrn = &ddraw.scrn;
}
else {
rect = &ddraw.rectclip;
scrn = &ddraw.scrnclip;
}
r = ddraw.primsurf->Blt(scrn, ddraw.backsurf, rect,
DDBLT_WAIT, NULL);
if (r == DDERR_SURFACELOST) {
ddraw.backsurf->Restore();
ddraw.primsurf->Restore();
ddraw.primsurf->Blt(scrn, ddraw.backsurf, rect,
DDBLT_WAIT, NULL);
}
}
else {
if (scrnmng.allflash) {
@ -687,7 +785,6 @@ void scrnmng_update(void) {
dst.top = clip.y + ddraw.scrn.top;
dst.right = clip.x + ddraw.scrn.right;
dst.bottom = clip.y + ddraw.scrn.bottom;
}
r = ddraw.primsurf->Blt(&dst, ddraw.backsurf, &ddraw.rect,
DDBLT_WAIT, NULL);
if (r == DDERR_SURFACELOST) {
@ -697,6 +794,7 @@ void scrnmng_update(void) {
DDBLT_WAIT, NULL);
}
}
}
}
@ -730,7 +828,7 @@ void scrnmng_dispclock(void)
DispClock::GetInstance()->Draw(scrnmng.bpp, dest.lpSurface, dest.lPitch);
ddraw.clocksurf->Unlock(NULL);
}
if (ddraw.primsurf->BltFast(640 - DCLOCK_WIDTH - 4,
if (ddraw.primsurf->BltFast(ddraw.width - DCLOCK_WIDTH - 4,
ddraw.height - DCLOCK_HEIGHT,
ddraw.clocksurf, const_cast<RECT*>(&rectclk),
DDBLTFAST_WAIT) == DDERR_SURFACELOST)

View File

@ -31,6 +31,16 @@ enum {
SCRNFLAG_ENABLE = 0x80
};
enum {
FSCRNMOD_NORESIZE = 0x00,
FSCRNMOD_ASPECTFIX8 = 0x01,
FSCRNMOD_ASPECTFIX = 0x02,
FSCRNMOD_LARGE = 0x03,
FSCRNMOD_ASPECTMASK = 0x03,
FSCRNMOD_SAMERES = 0x04,
FSCRNMOD_SAMEBPP = 0x08
};
typedef struct {
UINT8 flag;
UINT8 bpp;

View File

@ -57,6 +57,8 @@ static const OEMCHAR szClassName[] = OEMTEXT("Xmil-MainWindow");
#if defined(SUPPORT_DCLOCK)
0, 0, 0xffffff, 0xffbf6a,
#endif // defined(SUPPORT_DCLOCK)
0,
FSCRNMOD_SAMEBPP | FSCRNMOD_SAMERES | FSCRNMOD_ASPECTFIX8
};
OEMCHAR szProgName[] = OEMTEXT("X millennium ねこちゅ~ん");

View File

@ -553,6 +553,14 @@ SOURCE=.\dialog\d_sound.h
# End Source File
# Begin Source File
SOURCE=.\dialog\dialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\dialog\dialogs.h
# End Source File
# Begin Source File
SOURCE=.\DIALOG\EXTCLASS.CPP
# End Source File
# End Group

View File

@ -28,6 +28,9 @@ typedef struct {
UINT32 clockcolor1;
UINT32 clockcolor2;
#endif // defined(SUPPORT_DCLOCK)
UINT8 fscrnbpp;
UINT8 fscrnmod;
} XMILOSCFG;

View File

@ -283,6 +283,21 @@ BEGIN
RTEXT "",IDC_LIGHTSTR,144,22,20,10,SS_SUNKEN
END
IDD_SCROPT_FULLSCREEN DIALOG DISCARDABLE 0, 0, 172, 96
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FullScreen"
FONT 9, "lr oƒSƒVƒbƒN"
BEGIN
CONTROL "No change screen &colors",IDC_FULLSCREEN_SAMEBPP,"Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,8,8,156,10
CONTROL "No change screen &resolution",IDC_FULLSCREEN_SAMERES,
"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,8,24,
156,10
LTEXT "&Zoom",IDC_STATIC,8,45,22,8
COMBOBOX IDC_FULLSCREEN_ZOOM,40,42,96,80,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_GROUP | WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
@ -395,6 +410,10 @@ END
STRINGTABLE DISCARDABLE
BEGIN
IDS_SCREENOPTION "Screen option"
IDS_ZOOM_NONE "None"
IDS_ZOOM_FIXEDASPECT "Fixed aspect"
IDS_ZOOM_ADJUSTASPECT "Adjust aspect"
IDS_ZOOM_FULL "Full"
END
STRINGTABLE DISCARDABLE