Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
audetto committed Jan 3, 2022
2 parents 89d9031 + d63e406 commit dadba55
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions source/FrameBase.cpp
Expand Up @@ -121,9 +121,9 @@ void FrameBase::Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotTy
void FrameBase::Util_MakeScreenShotFileName(TCHAR* pFinalFileName_, DWORD chars)
{
const std::string sPrefixScreenShotFileName = "AppleWin_ScreenShot";
// TODO: g_sScreenshotDir
const std::string pPrefixFileName = !g_pLastDiskImageName.empty() ? g_pLastDiskImageName : sPrefixScreenShotFileName;
StringCbPrintf(pFinalFileName_, chars, TEXT("%s_%09d.bmp"), pPrefixFileName.c_str(), g_nLastScreenShot);
const std::string folder = Video_GetScreenShotFolder();
StringCbPrintf(pFinalFileName_, chars, TEXT("%s%s_%09d.bmp"), folder.c_str(), pPrefixFileName.c_str(), g_nLastScreenShot);
}

// Returns TRUE if file exists, else FALSE
Expand Down
1 change: 1 addition & 0 deletions source/FrameBase.h
Expand Up @@ -56,6 +56,7 @@ class FrameBase
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame);
void Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename);

virtual std::string Video_GetScreenShotFolder() = 0;
void Video_TakeScreenShot(const Video::VideoScreenShot_e ScreenShotType);
void Video_SaveScreenShot(const Video::VideoScreenShot_e ScreenShotType, const TCHAR* pScreenShotFileName);
void SetDisplayPrintScreenFileName(bool state) { g_bDisplayPrintScreenFileName = state; }
Expand Down
14 changes: 12 additions & 2 deletions source/Video.cpp
Expand Up @@ -509,7 +509,7 @@ void Video::Video_SetBitmapHeader(WinBmpHeader_t *pBmp, int nWidth, int nHeight,

void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShotType)
{
WinBmpHeader_t *pBmp = &g_tBmpHeader;
WinBmpHeader_t bmp, *pBmp = &bmp;

Video_SetBitmapHeader(
pBmp,
Expand All @@ -518,8 +518,13 @@ void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
32
);

char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == (14 + 40) ];
#define EXPECTED_BMP_HEADER_SIZE (14 + 40)
#ifdef _MSC_VER
char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE];
/**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0;
#else
static_assert(sizeof( WinBmpHeader_t ) == EXPECTED_BMP_HEADER_SIZE, "BadWinBmpHeaderPackingSize");
#endif

// Write Header
fwrite( pBmp, sizeof( WinBmpHeader_t ), 1, pFile );
Expand Down Expand Up @@ -575,6 +580,11 @@ void Video::Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
pSrc += GetFrameBufferWidth();
}
}

// re-write the Header to include the file size (otherwise "file" does not recognise it)
pBmp->nSizeFile = ftell(pFile);
rewind(pFile);
fwrite( pBmp, sizeof( WinBmpHeader_t ), 1, pFile );
}

//===========================================================================
Expand Down
17 changes: 4 additions & 13 deletions source/Video.h
Expand Up @@ -82,13 +82,9 @@ enum AppleFont_e
APPLE_FONT_Y_APPLE_40COL = 512, // ][
};

#ifdef _MSC_VER
// turn of MSVC struct member padding
#pragma pack(push,1)
#define PACKED
#else
#define PACKED // TODO: FIXME: gcc/clang __attribute__
#endif

// turn on struct member padding
#pragma pack(push,1)

// TODO: Replace with WinGDI.h / RGBQUAD
struct bgra_t
Expand Down Expand Up @@ -174,10 +170,7 @@ struct WinBmpHeader4_t
uint32_t nBlueGamma ; // 0x76 0x04
};

#ifdef _MSC_VER
#pragma pack(pop)
#endif

#pragma pack(pop)
//

class Video
Expand Down Expand Up @@ -298,8 +291,6 @@ class Video
COLORREF g_nMonochromeRGB; // saved to Registry
bool m_hasVidHD;

WinBmpHeader_t g_tBmpHeader;

static const int kVDisplayableScanLines = 192; // max displayable scanlines

static const UINT kVideoRomSize8K = kVideoRomSize4K*2;
Expand Down
6 changes: 6 additions & 0 deletions source/Windows/Win32Frame.cpp
Expand Up @@ -620,3 +620,9 @@ BYTE* Win32Frame::GetResource(WORD id, LPCSTR lpType, DWORD dwExpectedSize)

return pResource;
}

std::string Win32Frame::Video_GetScreenShotFolder()
{
// save in current folder
return "";
}
2 changes: 2 additions & 0 deletions source/Windows/Win32Frame.h
Expand Up @@ -55,6 +55,8 @@ class Win32Frame : public FrameBase
virtual BYTE* GetResource(WORD id, LPCSTR lpType, DWORD expectedSize);
virtual void Restart();

virtual std::string Video_GetScreenShotFolder();

bool GetFullScreenShowSubunitStatus(void);
int GetFullScreenOffsetX(void);
int GetFullScreenOffsetY(void);
Expand Down

0 comments on commit dadba55

Please sign in to comment.