mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-10-25 14:03:18 +00:00
1. Registry functions The set of functions are changed to consistently use bool arguments. The macros are changed to inline functions to improve type checking. RegSaveValue() are overloaded with help of templates to reduce typecasting at call sites. For instance, bool value would be converted consistently instead of relying on call sites to convert bool to int values. 2. Memory functions BOOL usages were unnecessary. Mostly internal usages which can simply be bool. 3. FrameBase Some member variables are changed to bool. BOOL was used because of those Registry functions. Additional changes: - Some expressions are forced to be bool when assigning to bool variables.
148 lines
4.1 KiB
C++
148 lines
4.1 KiB
C++
#include "StdAfx.h"
|
|
|
|
#include "FrameBase.h"
|
|
#include "Interface.h"
|
|
#include "NTSC.h"
|
|
#include "StrFormat.h"
|
|
|
|
FrameBase::FrameBase()
|
|
{
|
|
g_hFrameWindow = (HWND)0;
|
|
g_bConfirmReboot = kConfirmReboot_Default;
|
|
g_bMultiMon = false; // OFF = load window position & clamp initial frame to screen, ON = use window position as is
|
|
g_bFreshReset = false;
|
|
g_hInstance = (HINSTANCE)0;
|
|
g_bDisplayPrintScreenFileName = false;
|
|
g_bShowPrintScreenWarningDialog = true;
|
|
}
|
|
|
|
FrameBase::~FrameBase()
|
|
{
|
|
|
|
}
|
|
|
|
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(uint32_t dwCyclesThisFrame, bool bInit /*=false*/)
|
|
{
|
|
if (bInit)
|
|
{
|
|
// Just entered full-speed mode
|
|
dwFullSpeedStartTime = GetTickCount();
|
|
return;
|
|
}
|
|
|
|
uint32_t dwFullSpeedDuration = GetTickCount() - dwFullSpeedStartTime;
|
|
if (dwFullSpeedDuration <= 16) // Only update after every realtime ~17ms of *continuous* full-speed
|
|
return;
|
|
|
|
dwFullSpeedStartTime += dwFullSpeedDuration;
|
|
|
|
VideoRedrawScreenAfterFullSpeed(dwCyclesThisFrame);
|
|
}
|
|
|
|
void FrameBase::VideoRedrawScreenAfterFullSpeed(uint32_t 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)
|
|
{
|
|
std::string strScreenShotFileName;
|
|
|
|
// 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!?
|
|
{
|
|
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);
|
|
g_nLastScreenShot = 0;
|
|
return;
|
|
}
|
|
|
|
strScreenShotFileName = Util_MakeScreenShotFileName();
|
|
bExists = Util_TestScreenShotFileName(strScreenShotFileName.c_str());
|
|
if (!bExists)
|
|
{
|
|
break;
|
|
}
|
|
g_nLastScreenShot++;
|
|
}
|
|
|
|
Video_SaveScreenShot(ScreenShotType, strScreenShotFileName.c_str());
|
|
g_nLastScreenShot++;
|
|
}
|
|
|
|
//===========================================================================
|
|
|
|
void FrameBase::Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotType, const char* pScreenShotFileName)
|
|
{
|
|
FILE* pFile = fopen(pScreenShotFileName, "wb");
|
|
if (pFile)
|
|
{
|
|
GetVideo().Video_MakeScreenShot(pFile, ScreenShotType);
|
|
fclose(pFile);
|
|
}
|
|
|
|
if (g_bDisplayPrintScreenFileName)
|
|
{
|
|
FrameMessageBox(pScreenShotFileName, "Screen Captured", MB_OK);
|
|
}
|
|
}
|
|
|
|
std::string FrameBase::Util_MakeScreenShotFileName() const
|
|
{
|
|
const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot";
|
|
const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName;
|
|
const std::string folder = Video_GetScreenShotFolder();
|
|
return StrFormat("%s%s_%09d.bmp", folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot);
|
|
}
|
|
|
|
// Returns TRUE if file exists, else FALSE
|
|
bool FrameBase::Util_TestScreenShotFileName(const char* 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;
|
|
}
|