Fullscreen defaults to 32-bit. Use -fs8bit for 8-bit mode

This commit is contained in:
tomcw
2014-06-26 22:44:02 +01:00
parent 39a7fee002
commit c509349469
5 changed files with 147 additions and 50 deletions

View File

@@ -838,6 +838,10 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
bSetFullScreen = true; bSetFullScreen = true;
} }
else if (strcmp(lpCmdLine, "-fs8bit") == 0)
{
SetFullScreen32Bit(false); // Support old v1.24 fullscreen 8-bit palette mode
}
else if (strcmp(lpCmdLine, "-no-di") == 0) else if (strcmp(lpCmdLine, "-no-di") == 0)
{ {
g_bDisableDirectInput = true; g_bDisableDirectInput = true;

View File

@@ -133,6 +133,7 @@ static bool FileExists(string strFilename);
bool g_bScrollLock_FullSpeed = false; bool g_bScrollLock_FullSpeed = false;
bool g_bFreshReset = false; bool g_bFreshReset = false;
static bool g_bFullScreen32Bit = true;
// __ Prototypes __________________________________________________________________________________ // __ Prototypes __________________________________________________________________________________
static void DrawCrosshairs (int x, int y); static void DrawCrosshairs (int x, int y);
@@ -534,7 +535,7 @@ static void DrawFrameWindow ()
else if (g_nAppMode == MODE_DEBUG) else if (g_nAppMode == MODE_DEBUG)
DebugDisplay(1); DebugDisplay(1);
else else
VideoRedrawScreen(); VideoRedrawScreen(g_bIsFullScreen ? 2 : 1); // TC: 22/06/2014: Why 2 redraws in full-screen mode (32-bit only. 8-bit doesn't need this)
// DD Full-Screen Palette: BUGFIX: needs to come _after_ all drawing... // DD Full-Screen Palette: BUGFIX: needs to come _after_ all drawing...
if (g_bPaintingWindow) if (g_bPaintingWindow)
@@ -1488,6 +1489,7 @@ static void ScreenWindowResize(const bool bCtrlKey)
g_nOldViewportScale = g_nViewportScale; g_nOldViewportScale = g_nViewportScale;
FrameResizeWindow(1); // reset to 1x FrameResizeWindow(1); // reset to 1x
SetFullScreenMode(); SetFullScreenMode();
VideoRedrawScreen(1); // [TC-10/06/2014] Why isn't this working?
} }
else else
{ {
@@ -1602,6 +1604,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
g_bDebugBreakDelayCheck = true; g_bDebugBreakDelayCheck = true;
ProcessButtonClick(BTN_RUN); // Exit debugger, switch to MODE_RUNNING or MODE_STEPPING ProcessButtonClick(BTN_RUN); // Exit debugger, switch to MODE_RUNNING or MODE_STEPPING
// TC: 22/6/2014: Remove this comment now we are using 32-bits per pixel for Fullscreen?
// TODO: DD Full-Screen Palette // TODO: DD Full-Screen Palette
// exiting debugger using wrong palette, but this makes problem worse... // exiting debugger using wrong palette, but this makes problem worse...
//InvalidateRect(g_hFrameWindow,NULL,1); //InvalidateRect(g_hFrameWindow,NULL,1);
@@ -1796,6 +1799,17 @@ void CtrlReset()
//=========================================================================== //===========================================================================
bool GetFullScreen32Bit(void)
{
return g_bFullScreen32Bit;
}
void SetFullScreen32Bit(bool b32Bit)
{
g_bFullScreen32Bit = b32Bit;
}
void SetFullScreenMode () void SetFullScreenMode ()
{ {
#ifdef NO_DIRECT_X #ifdef NO_DIRECT_X
@@ -1819,7 +1833,7 @@ void SetFullScreenMode ()
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (DirectDrawCreate(NULL,&g_pDD,NULL) != DD_OK || if (DirectDrawCreate(NULL,&g_pDD,NULL) != DD_OK ||
g_pDD->SetCooperativeLevel(g_hFrameWindow,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) != DD_OK || g_pDD->SetCooperativeLevel(g_hFrameWindow,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) != DD_OK ||
g_pDD->SetDisplayMode(640,480,8) != DD_OK || g_pDD->SetDisplayMode(640,480,g_bFullScreen32Bit ? 32 : 8) != DD_OK ||
g_pDD->CreateSurface(&ddsd,&g_pDDPrimarySurface,NULL) != DD_OK) g_pDD->CreateSurface(&ddsd,&g_pDDPrimarySurface,NULL) != DD_OK)
{ {
g_pDDPrimarySurface = NULL; g_pDDPrimarySurface = NULL;
@@ -2128,9 +2142,8 @@ HDC FrameGetVideoDC (LPBYTE *pAddr_, LONG *pPitch_)
// g_pDDPrimarySurface->SetPalette(g_pDDPal); // this sets the palette for the primary surface // g_pDDPrimarySurface->SetPalette(g_pDDPal); // this sets the palette for the primary surface
// } // }
} }
*pAddr_ = (LPBYTE)surfacedesc.lpSurface+(g_nViewportCY-1)*surfacedesc.lPitch; *pAddr_ = (LPBYTE)surfacedesc.lpSurface + (g_nViewportCY-1) * surfacedesc.lPitch;
*pPitch_ = -surfacedesc.lPitch; *pPitch_ = -surfacedesc.lPitch;
return (HDC)0; return (HDC)0;
} }
else else

View File

@@ -45,6 +45,8 @@
int GetViewportScale(void); int GetViewportScale(void);
int SetViewportScale(int nNewScale); int SetViewportScale(int nNewScale);
void GetViewportCXCY(int& nViewportCX, int& nViewportCY); void GetViewportCXCY(int& nViewportCX, int& nViewportCY);
bool GetFullScreen32Bit(void);
void SetFullScreen32Bit(bool b32Bit);
LRESULT CALLBACK FrameWndProc ( LRESULT CALLBACK FrameWndProc (
HWND window, HWND window,

View File

@@ -221,7 +221,7 @@ int const kVLine0State = 0x100; // V[543210CBA] = 100000000
int const kVPresetLine = 256; // line when V state presets int const kVPresetLine = 256; // line when V state presets
int const kVSyncLines = 4; // lines per VSync duration int const kVSyncLines = 4; // lines per VSync duration
static BYTE celldirty[40][32]; static BYTE celldirty[40][32]; // NB. No longer used!
// NUM_COLOR_PALETTE // NUM_COLOR_PALETTE
static COLORREF customcolors[256]; // MONOCHROME is last custom color static COLORREF customcolors[256]; // MONOCHROME is last custom color
@@ -254,7 +254,7 @@ static WORD colormixmap[6][6][6];
int g_nAltCharSetOffset = 0; // alternate character set int g_nAltCharSetOffset = 0; // alternate character set
bool g_bVideoDisplayPage2 = 0; bool g_bVideoDisplayPage2 = 0;
bool g_VideoForceFullRedraw = 1; /*bool*/ UINT g_VideoForceFullRedraw = 1;
static LPBYTE framebufferaddr = (LPBYTE)0; static LPBYTE framebufferaddr = (LPBYTE)0;
static LONG g_nFrameBufferPitch = 0; static LONG g_nFrameBufferPitch = 0;
@@ -376,7 +376,6 @@ static bool bVideoScannerNTSC = true; // NTSC video scanning (or PAL)
void V_CreateDIBSections (); void V_CreateDIBSections ();
HBRUSH V_CreateCustomBrush (COLORREF nColor); HBRUSH V_CreateCustomBrush (COLORREF nColor);
/** Our BitBlit() / VRAM_Copy() /** Our BitBlit() / VRAM_Copy()
@param dx Dst X @param dx Dst X
@param dy Dst Y @param dy Dst Y
@@ -385,7 +384,8 @@ static bool bVideoScannerNTSC = true; // NTSC video scanning (or PAL)
@param sx Src X @param sx Src X
@param sy Src Y @param sy Src Y
// =========================================================================== */ // =========================================================================== */
void CopySource (int dx, int dy, int w, int h, int sx, int sy )
static inline void CopySource8(int dx, int dy, int w, int h, int sx, int sy)
{ {
LPBYTE pDst = g_aFrameBufferOffset[ dy ] + dx; LPBYTE pDst = g_aFrameBufferOffset[ dy ] + dx;
LPBYTE pSrc = g_aSourceStartofLine[ sy ] + sx; LPBYTE pSrc = g_aSourceStartofLine[ sy ] + sx;
@@ -398,15 +398,15 @@ void CopySource (int dx, int dy, int w, int h, int sx, int sy )
// If not multiple of 3 bytes, copy first 3 bytes, so the next copy is 4-byte aligned. // If not multiple of 3 bytes, copy first 3 bytes, so the next copy is 4-byte aligned.
while (nBytes & 3) while (nBytes & 3)
{ {
--nBytes; --nBytes;
*(pDst+nBytes) = *(pSrc+nBytes); *(pDst+nBytes) = *(pSrc+nBytes);
} }
// Copy 4 bytes at a time // Copy 4 bytes at a time
while (nBytes) while (nBytes)
{ {
nBytes -= 4; nBytes -= 4;
*(LPDWORD)(pDst+nBytes) = *(LPDWORD)(pSrc+nBytes); *(LPDWORD)(pDst+nBytes) = *(LPDWORD)(pSrc+nBytes);
} }
pDst -= g_nFrameBufferPitch; pDst -= g_nFrameBufferPitch;
@@ -414,6 +414,33 @@ void CopySource (int dx, int dy, int w, int h, int sx, int sy )
} }
} }
static void CopySource(int dx, int dy, int w, int h, int sx, int sy)
{
if (!g_bIsFullScreen || !GetFullScreen32Bit())
{
CopySource8(dx,dy,w,h,sx,sy);
return;
}
UINT32* pDst = (UINT32*) (g_aFrameBufferOffset[ dy ] + dx*sizeof(UINT32));
LPBYTE pSrc = g_aSourceStartofLine[ sy ] + sx;
int nBytes;
while (h--)
{
nBytes = w;
while (nBytes)
{
--nBytes;
const RGBQUAD& rRGB = g_pFramebufferinfo->bmiColors[ *(pSrc+nBytes) ];
const UINT32 rgb = (((UINT32)rRGB.rgbRed)<<16) | (((UINT32)rRGB.rgbGreen)<<8) | ((UINT32)rRGB.rgbBlue);
*(pDst+nBytes) = rgb;
}
pDst -= g_nFrameBufferPitch / sizeof(UINT32);
pSrc -= SRCOFFS_TOTAL;
}
}
//=========================================================================== //===========================================================================
void CreateFrameOffsetTable (LPBYTE addr, LONG pitch) void CreateFrameOffsetTable (LPBYTE addr, LONG pitch)
@@ -2674,51 +2701,84 @@ void __stdcall MixColorsVertical(int matx, int maty)
[bot2idx]; [bot2idx];
colormixbuffer[4] = (twoHalfPixel & 0xFF00) >> 8; colormixbuffer[4] = (twoHalfPixel & 0xFF00) >> 8;
colormixbuffer[5] = twoHalfPixel & 0x00FF; colormixbuffer[5] = twoHalfPixel & 0x00FF;
} }
//=========================================================================== //===========================================================================
void __stdcall CopyMixedSource (int x, int y, int sourcex, int sourcey)
static inline void __stdcall CopyMixedSource8(int x, int y, int sourcex, int sourcey)
{ {
// For tv emulation HGR Video Mode // For tv emulation HGR Video Mode
LPBYTE currsourceptr = g_aSourceStartofLine[sourcey]+sourcex; const BYTE* const currsourceptr = g_aSourceStartofLine[sourcey]+sourcex;
LPBYTE currdestptr = g_aFrameBufferOffset[y<<1] + (x<<1); BYTE* const currdestptr = g_aFrameBufferOffset[y*2] + (x*2);
LPBYTE currptr;
int matx = x; const int matx = x;
int maty = HGR_MATRIX_YOFFSET + y; const int maty = HGR_MATRIX_YOFFSET + y;
int count; const int hgrlinesabove = (y > 0) ? 1 : 0;
int bufxoffset; const int hgrlinesbelow = SW_MIXED ? ((y < 159)? 1:0) : ((y < 191)? 1:0);
int hgrlinesabove = (y > 0)? 1 : 0; const int istart = 2 - (hgrlinesabove*2);
int hgrlinesbelow = SW_MIXED ? ((y < 159)? 1:0) : ((y < 191)? 1:0); const int iend = 3 + (hgrlinesbelow*2);
int i;
int istart = 2 - (hgrlinesabove << 1);
int iend = 3 + (hgrlinesbelow << 1);
// transfer 7 pixels (i.e. the visible part of an apple hgr-byte) from row to pixelmatrix // transfer 7 pixels (i.e. the visible part of an apple hgr-byte) from row to pixelmatrix
for (count = 0, bufxoffset = 0; for (int count = 0, bufxoffset = 0; count < 7; count++, bufxoffset += 2)
count < 7; {
count++, bufxoffset += 2) { hgrpixelmatrix[matx+count][maty] = *(currsourceptr+bufxoffset);
hgrpixelmatrix[matx+count][maty] = *(currsourceptr+bufxoffset);
// color mixing between adjacent scanlines at current x position
MixColorsVertical(matx+count, maty);
// transfer up to 6 mixed (half-)pixels of current column to framebuffer // color mixing between adjacent scanlines at current x position
currptr = currdestptr+bufxoffset; MixColorsVertical(matx+count, maty);
if (hgrlinesabove)
currptr += g_nFrameBufferPitch << 1;
for (i = istart; // transfer up to 6 mixed (half-)pixels of current column to framebuffer
i <= iend; BYTE* currptr = currdestptr+bufxoffset;
currptr -= g_nFrameBufferPitch, i++) { if (hgrlinesabove)
*currptr = *(currptr+1) = colormixbuffer[i]; currptr += g_nFrameBufferPitch * 2;
for (int i = istart; i <= iend; currptr -= g_nFrameBufferPitch, i++)
{
*currptr = *(currptr+1) = colormixbuffer[i];
}
} }
}
} }
// For tv emulation HGR Video Mode
static void __stdcall CopyMixedSource(int x, int y, int sourcex, int sourcey)
{
if (!g_bIsFullScreen || !GetFullScreen32Bit())
{
CopyMixedSource8(x,y,sourcex,sourcey);
return;
}
const BYTE* const currsourceptr = g_aSourceStartofLine[sourcey]+sourcex;
UINT32* const currdestptr = (UINT32*) (g_aFrameBufferOffset[ y*2 ] + (x*2)*sizeof(UINT32));
const int matx = x;
const int maty = HGR_MATRIX_YOFFSET + y;
const int hgrlinesabove = (y > 0) ? 1 : 0;
const int hgrlinesbelow = SW_MIXED ? ((y < 159)? 1:0) : ((y < 191)? 1:0);
const int istart = 2 - (hgrlinesabove*2);
const int iend = 3 + (hgrlinesbelow*2);
// transfer 7 pixels (i.e. the visible part of an apple hgr-byte) from row to pixelmatrix
for (int count = 0, bufxoffset = 0; count < 7; count++, bufxoffset += 2)
{
hgrpixelmatrix[matx+count][maty] = *(currsourceptr+bufxoffset);
// color mixing between adjacent scanlines at current x position
MixColorsVertical(matx+count, maty);
// transfer up to 6 mixed (half-)pixels of current column to framebuffer
UINT32* currptr = currdestptr+bufxoffset;
if (hgrlinesabove)
currptr += (g_nFrameBufferPitch / sizeof(UINT32)) * 2;
for (int i = istart; i <= iend; currptr -= g_nFrameBufferPitch/sizeof(UINT32), i++)
{
RGBQUAD& rRGB = g_pFramebufferinfo->bmiColors[ colormixbuffer[i] ];
const UINT32 rgb = (((UINT32)rRGB.rgbRed)<<16) | (((UINT32)rRGB.rgbGreen)<<8) | ((UINT32)rRGB.rgbBlue);
*currptr = *(currptr+1) = rgb;
}
}
}
//=========================================================================== //===========================================================================
bool UpdateHiResCell (int x, int y, int xpixel, int ypixel, int offset) bool UpdateHiResCell (int x, int y, int xpixel, int ypixel, int offset)
@@ -3339,6 +3399,12 @@ void VideoRealizePalette(HDC dc)
} }
//=========================================================================== //===========================================================================
VideoUpdateFuncPtr_t VideoRedrawScreen (UINT n)
{
g_VideoForceFullRedraw = n;
return VideoRefreshScreen();
}
VideoUpdateFuncPtr_t VideoRedrawScreen () VideoUpdateFuncPtr_t VideoRedrawScreen ()
{ {
g_VideoForceFullRedraw = 1; g_VideoForceFullRedraw = 1;
@@ -3384,7 +3450,8 @@ VideoUpdateFuncPtr_t VideoRefreshScreen ()
bool bMixed = (SW_MIXED) ? true : false; bool bMixed = (SW_MIXED) ? true : false;
_Video_RedrawScreen( pfUpdate, bMixed ); _Video_RedrawScreen( pfUpdate, bMixed );
g_VideoForceFullRedraw = 0; //g_VideoForceFullRedraw = 0;
if (g_VideoForceFullRedraw) --g_VideoForceFullRedraw;
return pfUpdate; return pfUpdate;
} }
@@ -3442,12 +3509,22 @@ void _Video_RedrawScreen( VideoUpdateFuncPtr_t pfUpdate, bool bMixed )
// Shift-Print Screen saves only the even rows. // Shift-Print Screen saves only the even rows.
// NOTE: Keep in sync with _Video_RedrawScreen() & Video_MakeScreenShot() // NOTE: Keep in sync with _Video_RedrawScreen() & Video_MakeScreenShot()
// [TC-10/06-2014] In full-screen mode, there's noticable flicker when blanking out these alt lines.
// - Consider doing this 50% operation in CopySource() instead
for( int y = 1; y < FRAMEBUFFER_H; y += 2 ) for( int y = 1; y < FRAMEBUFFER_H; y += 2 )
{ {
unsigned char *pSrc = g_aFrameBufferOffset[y]; if (!g_bIsFullScreen || !GetFullScreen32Bit())
for( int x = 0; x < FRAMEBUFFER_W; x++ )
{ {
*pSrc++ = 0; unsigned char *pSrc = g_aFrameBufferOffset[y]; // 8-bit
for( int x = 0; x < FRAMEBUFFER_W; x++ )
*pSrc++ = 0;
}
else
{
unsigned int *pSrc = (unsigned int *) g_aFrameBufferOffset[y]; // 32-bit
for( int x = 0; x < FRAMEBUFFER_W; x++ )
*pSrc++ = 0;
} }
} }
} }

View File

@@ -97,6 +97,7 @@ void VideoDisplayLogo ();
BOOL VideoHasRefreshed (); BOOL VideoHasRefreshed ();
void VideoInitialize (); void VideoInitialize ();
void VideoRealizePalette (HDC); void VideoRealizePalette (HDC);
VideoUpdateFuncPtr_t VideoRedrawScreen (UINT);
VideoUpdateFuncPtr_t VideoRedrawScreen (); VideoUpdateFuncPtr_t VideoRedrawScreen ();
VideoUpdateFuncPtr_t VideoRefreshScreen (); VideoUpdateFuncPtr_t VideoRefreshScreen ();
void VideoReinitialize (); void VideoReinitialize ();
@@ -110,7 +111,7 @@ DWORD VideoSetSnapshot(SS_IO_Video* pSS);
extern bool g_bVideoDisplayPage2; extern bool g_bVideoDisplayPage2;
extern bool g_VideoForceFullRedraw; extern /*bool*/ UINT g_VideoForceFullRedraw;
void _Video_Dirty(); void _Video_Dirty();
void _Video_RedrawScreen( VideoUpdateFuncPtr_t update, bool bMixed = false ); void _Video_RedrawScreen( VideoUpdateFuncPtr_t update, bool bMixed = false );