2020-12-24 15:08:50 +00:00
|
|
|
#include "StdAfx.h"
|
|
|
|
|
|
|
|
#include "FrameBase.h"
|
2021-01-03 16:21:24 +00:00
|
|
|
#include "Interface.h"
|
|
|
|
#include "NTSC.h"
|
2023-02-05 21:04:45 +00:00
|
|
|
#include "StrFormat.h"
|
2020-12-24 15:08:50 +00:00
|
|
|
|
|
|
|
FrameBase::FrameBase()
|
|
|
|
{
|
|
|
|
g_hFrameWindow = (HWND)0;
|
|
|
|
g_bConfirmReboot = 1; // saved PageConfig REGSAVE
|
|
|
|
g_bMultiMon = 0; // OFF = load window position & clamp initial frame to screen, ON = use window position as is
|
|
|
|
g_bFreshReset = false;
|
|
|
|
g_hInstance = (HINSTANCE)0;
|
2021-01-03 16:21:24 +00:00
|
|
|
g_bDisplayPrintScreenFileName = false;
|
|
|
|
g_bShowPrintScreenWarningDialog = true;
|
2020-12-24 15:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FrameBase::~FrameBase()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2021-01-03 16:21:24 +00:00
|
|
|
|
|
|
|
void FrameBase::VideoRefreshScreen(uint32_t uRedrawWholeScreenVideoMode, bool bRedrawWholeScreen)
|
|
|
|
{
|
|
|
|
// regenerate video buffer if needed
|
|
|
|
GetVideo().VideoRefreshBuffer(uRedrawWholeScreenVideoMode, bRedrawWholeScreen);
|
|
|
|
|
|
|
|
// actually draw it on screen
|
|
|
|
VideoPresentScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameBase::VideoRedrawScreen(void)
|
|
|
|
{
|
|
|
|
// NB. Can't rely on g_uVideoMode being non-zero (ie. so it can double up as a flag) since 'GR,PAGE1,non-mixed' mode == 0x00.
|
|
|
|
VideoRefreshScreen(GetVideo().GetVideoMode(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
void FrameBase::VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInit /*=false*/)
|
|
|
|
{
|
|
|
|
if (bInit)
|
|
|
|
{
|
|
|
|
// Just entered full-speed mode
|
|
|
|
dwFullSpeedStartTime = GetTickCount();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD dwFullSpeedDuration = GetTickCount() - dwFullSpeedStartTime;
|
|
|
|
if (dwFullSpeedDuration <= 16) // Only update after every realtime ~17ms of *continuous* full-speed
|
|
|
|
return;
|
|
|
|
|
|
|
|
dwFullSpeedStartTime += dwFullSpeedDuration;
|
|
|
|
|
|
|
|
VideoRedrawScreenAfterFullSpeed(dwCyclesThisFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameBase::VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame)
|
|
|
|
{
|
|
|
|
NTSC_VideoClockResync(dwCyclesThisFrame);
|
|
|
|
VideoRedrawScreen(); // Better (no flicker) than using: NTSC_VideoReinitialize() or VideoReinitialize()
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameBase::Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename)
|
|
|
|
{
|
|
|
|
_ASSERT(pScreenshotFilename);
|
|
|
|
if (!pScreenshotFilename)
|
|
|
|
return;
|
|
|
|
|
|
|
|
VideoRedrawScreen();
|
|
|
|
Video_SaveScreenShot(Video::SCREENSHOT_560x384, pScreenshotFilename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameBase::Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType)
|
|
|
|
{
|
2022-02-15 18:48:20 +00:00
|
|
|
std::string strScreenShotFileName;
|
2021-01-03 16:21:24 +00:00
|
|
|
|
|
|
|
// find last screenshot filename so we don't overwrite the existing user ones
|
|
|
|
bool bExists = true;
|
|
|
|
while (bExists)
|
|
|
|
{
|
|
|
|
if (g_nLastScreenShot > nMaxScreenShot) // Holy Crap! User has maxed the number of screenshots!?
|
|
|
|
{
|
2022-02-15 18:48:20 +00:00
|
|
|
std::string msg = StrFormat("You have more then %d screenshot filenames! They will no longer be saved.\n\n"
|
|
|
|
"Either move some of your screenshots or increase the maximum in video.cpp\n",
|
|
|
|
nMaxScreenShot);
|
|
|
|
FrameMessageBox(msg.c_str(), "Warning", MB_OK);
|
2021-01-03 16:21:24 +00:00
|
|
|
g_nLastScreenShot = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-15 18:48:20 +00:00
|
|
|
strScreenShotFileName = Util_MakeScreenShotFileName();
|
|
|
|
bExists = Util_TestScreenShotFileName(strScreenShotFileName.c_str());
|
2021-01-03 16:21:24 +00:00
|
|
|
if (!bExists)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_nLastScreenShot++;
|
|
|
|
}
|
|
|
|
|
2022-02-15 18:48:20 +00:00
|
|
|
Video_SaveScreenShot(ScreenShotType, strScreenShotFileName.c_str());
|
2021-01-03 16:21:24 +00:00
|
|
|
g_nLastScreenShot++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FrameBase::Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotType, const TCHAR* pScreenShotFileName)
|
|
|
|
{
|
|
|
|
FILE* pFile = fopen(pScreenShotFileName, "wb");
|
|
|
|
if (pFile)
|
|
|
|
{
|
|
|
|
GetVideo().Video_MakeScreenShot(pFile, ScreenShotType);
|
|
|
|
fclose(pFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_bDisplayPrintScreenFileName)
|
|
|
|
{
|
2021-01-19 20:37:43 +00:00
|
|
|
FrameMessageBox(pScreenShotFileName, "Screen Captured", MB_OK);
|
2021-01-03 16:21:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 18:48:20 +00:00
|
|
|
std::string FrameBase::Util_MakeScreenShotFileName() const
|
2021-01-03 16:21:24 +00:00
|
|
|
{
|
|
|
|
const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot";
|
|
|
|
const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName;
|
2022-01-03 14:41:03 +00:00
|
|
|
const std::string folder = Video_GetScreenShotFolder();
|
2022-02-15 18:48:20 +00:00
|
|
|
return StrFormat("%s%s_%09d.bmp", folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot);
|
2021-01-03 16:21:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns TRUE if file exists, else FALSE
|
|
|
|
bool FrameBase::Util_TestScreenShotFileName(const TCHAR* pFileName)
|
|
|
|
{
|
|
|
|
bool bFileExists = false;
|
|
|
|
FILE* pFile = fopen(pFileName, "rt");
|
|
|
|
if (pFile)
|
|
|
|
{
|
|
|
|
fclose(pFile);
|
|
|
|
bFileExists = true;
|
|
|
|
}
|
|
|
|
return bFileExists;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FrameBase::Video_ResetScreenshotCounter(const std::string& pImageName)
|
|
|
|
{
|
|
|
|
g_nLastScreenShot = 0;
|
|
|
|
g_pLastDiskImageName = pImageName;
|
|
|
|
}
|