-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for saving SSX screen files
These files hold the display memory data for the main screen area, followed by the CLUT indices into the 128 SAM palette colours. They are static image formats intended for preservation use. Mid-display changes to VMPR or CLUT will give the wrong result for the formats above, and if detected a raster-accurate representation of the display is saved instead (512x192 palette indices). A new SaveSSX action (51) is available for key bindings. Two screenshot saving items are available on the Record menu in the Windows version.
- Loading branch information
Showing
14 changed files
with
173 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Part of SimCoupe - A SAM Coupe emulator | ||
// | ||
// SSX.cpp: SAM main screen data saving in raw formats | ||
// | ||
// These files hold the display memory data for the main screen area, | ||
// followed by the CLUT indices into the 128 SAM palette colours. | ||
// | ||
// MODE 1 = 6144 data + 768 attrs + 16 CLUT = 6928 bytes. | ||
// MODE 2 = 6144 data + 6144 attrs + 16 CLUT = 12304 bytes. | ||
// MODE 3 = 24576 data + 4 CLUT = 24580 bytes. | ||
// MODE 4 = 24576 data + 16 CLUT = 24592 bytes. | ||
// | ||
// Mid-display changes to VMPR or CLUT will give the wrong result for | ||
// the dumps above. If detected the file is written in a different format: | ||
// | ||
// 512x192 pixels, each holding palette index (0-127) = 98304 bytes. | ||
// | ||
// The extra horizontal resolution is required for MODE 3. In other modes | ||
// each native pixel is represented by a pair of thin pixels. | ||
|
||
#include "SimCoupe.h" | ||
#include "SAMIO.h" | ||
#include "Memory.h" | ||
|
||
namespace SSX | ||
{ | ||
|
||
bool Save(CScreen* screen, int main_x, int main_y) | ||
{ | ||
char szPath[MAX_PATH]{}; | ||
Util::GetUniqueFile("ssx", szPath, sizeof(szPath)); | ||
|
||
auto file = fopen(szPath, "wb"); | ||
if (!file) | ||
{ | ||
Frame::SetStatus("Failed to open %s for writing!", szPath); | ||
return false; | ||
} | ||
|
||
if (display_changed) | ||
{ | ||
for (auto y = 0; y < SCREEN_LINES; ++y) | ||
fwrite(screen->GetLine(main_y + y) + main_x, 2, SCREEN_PIXELS, file); | ||
} | ||
else | ||
{ | ||
auto vmpr_page = VMPR_PAGE; | ||
auto screen_mode = 1 + (VMPR_MODE >> VMPR_MODE_SHIFT); | ||
|
||
const void* ptr0 = PageReadPtr(vmpr_page); | ||
const void* ptr1 = nullptr; | ||
size_t size0 = 0; | ||
size_t size1 = 0; | ||
|
||
switch (screen_mode) | ||
{ | ||
case 1: | ||
ptr0 = PageReadPtr(vmpr_page); | ||
size0 = 32*192 + 32*24; | ||
break; | ||
case 2: | ||
ptr0 = PageReadPtr(vmpr_page); | ||
ptr1 = PageReadPtr(vmpr_page) + 0x2000; | ||
size0 = size1 = 32*192; | ||
break; | ||
case 3: | ||
case 4: | ||
{ | ||
vmpr_page &= ~1; | ||
ptr0 = PageReadPtr(vmpr_page); | ||
ptr1 = PageReadPtr((vmpr_page + 1) & (MEM_PAGE_SIZE - 1)); | ||
size0 = 128*128; | ||
size1 = 128*64; | ||
break; | ||
} | ||
} | ||
|
||
if (ptr0 && size0) | ||
fwrite(ptr0, 1, size0, file); | ||
if (ptr1 && size1) | ||
fwrite(ptr1, 1, size1, file); | ||
|
||
if (screen_mode == 3) | ||
{ | ||
for (int i = 0; i < 4; ++i) | ||
fputc(mode3clut[i], file); | ||
} | ||
else | ||
{ | ||
for (int i = 0; i < N_CLUT_REGS; ++i) | ||
fputc(clut[i], file); | ||
} | ||
} | ||
|
||
fclose(file); | ||
Frame::SetStatus("Saved %s", szPath); | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Part of SimCoupe - A SAM Coupe emulator | ||
// | ||
// SSX.h: SAM main screen data saving in raw formats | ||
|
||
#pragma once | ||
#include "Screen.h" | ||
|
||
namespace SSX | ||
{ | ||
bool Save(CScreen* screen, int main_x, int main_y); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters