VideoReinitialize(): remove default arg & refactor out common code (PR #911)

This commit is contained in:
Andrea 2021-01-13 22:02:48 +00:00 committed by GitHub
parent 6cffb30330
commit 816e22524f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 39 deletions

View File

@ -312,15 +312,8 @@ void CPageConfig::DlgOK(HWND hWnd)
if (bVideoReinit)
{
GetVideo().Config_Save_Video();
win32Frame.FrameRefreshStatus(DRAW_TITLE);
GetVideo().VideoReinitialize();
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
{
win32Frame.VideoRedrawScreen();
}
win32Frame.ApplyVideoModeChange();
}
//

View File

@ -2117,7 +2117,7 @@ void NTSC_VideoInit( uint8_t* pFramebuffer ) // wsVideoInit
g_pFuncUpdateTextScreen = updateScreenText40;
g_pFuncUpdateGraphicsScreen = updateScreenText40;
GetVideo().VideoReinitialize(); // Setup g_pFunc_ntsc*Pixel()
GetVideo().VideoReinitialize(true); // Setup g_pFunc_ntsc*Pixel()
bgra_t baseColors[kNumBaseColors];
GenerateBaseColors(&baseColors);

View File

@ -287,7 +287,7 @@ static void ParseUnitApple2(YamlLoadHelper& yamlLoadHelper, UINT version)
MemLoadSnapshot(yamlLoadHelper, version);
// g_Apple2Type may've changed: so redraw frame (title, buttons, leds, etc)
GetVideo().VideoReinitialize(); // g_CharsetType changed
GetVideo().VideoReinitialize(true); // g_CharsetType changed
GetFrame().FrameUpdateApple2Type(); // Calls VideoRedrawScreen() before the aux mem has been loaded (so if DHGR is enabled, then aux mem will be zeros at this stage)
}

View File

@ -126,7 +126,7 @@ UINT Video::GetFrameBufferHeight(void)
//===========================================================================
void Video::VideoReinitialize(bool bInitVideoScannerAddress /*= true*/)
void Video::VideoReinitialize(bool bInitVideoScannerAddress)
{
NTSC_VideoReinitialize( g_dwCyclesThisFrame, bInitVideoScannerAddress );
NTSC_VideoInitAppleType();

View File

@ -211,7 +211,7 @@ public:
COLORREF GetMonochromeRGB(void) { return g_nMonochromeRGB; }
void SetMonochromeRGB(COLORREF colorRef) { g_nMonochromeRGB = colorRef; }
void VideoReinitialize(bool bInitVideoScannerAddress = true);
void VideoReinitialize(bool bInitVideoScannerAddress);
void VideoResetState(void);
void VideoRefreshBuffer(uint32_t uRedrawWholeScreenVideoMode, bool bRedrawWholeScreen);

View File

@ -9,6 +9,7 @@
#include "Log.h"
#include "Memory.h"
#include "CardManager.h"
#include "Debugger/Debug.h"
#include "../resource/resource.h"
// Win32Frame methods are implemented in AppleWin, WinFrame and WinVideo.
@ -306,12 +307,7 @@ void Win32Frame::ChooseMonochromeColor(void)
if (ChooseColor(&cc))
{
video.SetMonochromeRGB(cc.rgbResult);
video.VideoReinitialize();
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
{
VideoRedrawScreen();
}
video.Config_Save_Video();
ApplyVideoModeChange();
}
}
@ -514,6 +510,29 @@ void Win32Frame::DDUninit(void)
#undef SAFE_RELEASE
void Win32Frame::ApplyVideoModeChange(void)
{
Video& video = GetVideo();
video.Config_Save_Video();
video.VideoReinitialize(false);
if (g_nAppMode != MODE_LOGO)
{
if (g_nAppMode == MODE_DEBUG)
{
UINT debugVideoMode;
if (DebugGetVideoMode(&debugVideoMode))
VideoRefreshScreen(debugVideoMode, true);
else
VideoPresentScreen();
}
else
{
VideoPresentScreen();
}
}
}
Win32Frame& Win32Frame::GetWin32Frame()
{
FrameBase& frameBase = GetFrame();

View File

@ -44,6 +44,7 @@ public:
void ChooseMonochromeColor(void);
UINT Get3DBorderWidth(void);
UINT Get3DBorderHeight(void);
void ApplyVideoModeChange(void);
LRESULT WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
private:

View File

@ -1113,7 +1113,7 @@ LRESULT Win32Frame::WndProc(
}
case WM_DISPLAYCHANGE:
GetVideo().VideoReinitialize();
GetVideo().VideoReinitialize(false);
break;
case WM_DROPFILES:
@ -1223,26 +1223,7 @@ LRESULT Win32Frame::WndProc(
// TODO: Clean up code:FrameRefreshStatus(DRAW_TITLE) DrawStatusArea((HDC)0,DRAW_TITLE)
DrawStatusArea( (HDC)0, DRAW_TITLE );
GetVideo().VideoReinitialize(false);
if (g_nAppMode != MODE_LOGO)
{
if (g_nAppMode == MODE_DEBUG)
{
UINT debugVideoMode;
if ( DebugGetVideoMode(&debugVideoMode) )
VideoRefreshScreen(debugVideoMode, true);
else
VideoPresentScreen();
}
else
{
VideoPresentScreen();
}
}
GetVideo().Config_Save_Video();
ApplyVideoModeChange();
}
else if (wparam == VK_F10)
{