Added support for Apple II/II+ 2K video ROMs (fixes #205)

This commit is contained in:
tomcw 2018-11-19 22:15:04 +00:00
parent 6bf7299225
commit af899fa90a
4 changed files with 57 additions and 9 deletions

View File

@ -1289,14 +1289,14 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
if ((g_hCustomRomF8 == INVALID_HANDLE_VALUE) || (GetFileSize(g_hCustomRomF8, NULL) != 0x800)) if ((g_hCustomRomF8 == INVALID_HANDLE_VALUE) || (GetFileSize(g_hCustomRomF8, NULL) != 0x800))
g_bCustomRomF8Failed = true; g_bCustomRomF8Failed = true;
} }
else if (strcmp(lpCmdLine, "-videorom") == 0) // Use 4K,8K or 16K video ROM for Enhanced //e else if (strcmp(lpCmdLine, "-videorom") == 0) // Use 2K (for II/II+). Use 4K,8K or 16K video ROM (for Enhanced //e)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
if (!ReadVideoRomFile(lpCmdLine)) if (!ReadVideoRomFile(lpCmdLine))
{ {
std::string msg = "Failed to load video rom (not found or not exactly 4/8/16KiB)"; std::string msg = "Failed to load video rom (not found or not exactly 2/4/8/16KiB)";
LogFileOutput("%s", msg.c_str()); LogFileOutput("%s", msg.c_str());
MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK);
} }

View File

@ -154,11 +154,11 @@ void userVideoRom4K(csbits_t csbits, const BYTE* pVideoRom)
} }
} }
void userVideoRom(void) void userVideoRomForIIe(void)
{ {
const BYTE* pVideoRom; const BYTE* pVideoRom;
UINT size = GetVideoRom(pVideoRom); // 4K or 8K UINT size = GetVideoRom(pVideoRom); // 2K or 4K or 8K
if (!size) if (size < kVideoRomSize4K)
return; return;
if (size == kVideoRomSize4K) if (size == kVideoRomSize4K)
@ -173,6 +173,50 @@ void userVideoRom(void)
//------------------------------------- //-------------------------------------
void userVideoRom2K(csbits_t csbits, const BYTE* pVideoRom)
{
int RA = 0; // rom address
for (int i=0; i<256; i++, RA+=8)
{
for (int y=0; y<8; y++)
{
BYTE d=0;
BYTE n = pVideoRom[RA+y];
// UTAII:8-30 "Bit 7 of your EPROM fonts will control flashing in the lower 1024 bytes of the EPROM"
// UTAII:8-31 "If you leave O7 (EPROM Output7) reset in these patterns, the resulting characters will be inversions..."
if (!(n & 0x80) && RA < 1024)
n = n ^ 0x7f;
n &= 0x7f;
// UTAII:8-30 "TEXT ROM pattern is ... reversed"
for (BYTE j=0; j<7; j++)
{
if (n & 1)
d |= 1;
d <<= 1;
n >>= 1;
}
d >>= 1; // Undo the last left shift
csbits[0][i][y] = d;
}
}
}
void userVideoRomForIIPlus(void)
{
const BYTE* pVideoRom;
UINT size = GetVideoRom(pVideoRom); // 2K or 4K or 8K
if (size != kVideoRomSize2K)
return;
userVideoRom2K(&csbits_a2[0], pVideoRom);
}
//-------------------------------------
void make_csbits(void) void make_csbits(void)
{ {
get_csbits(&csbits_enhanced2e[0], TEXT("CHARSET40"), 0); // Enhanced //e: Alt char set off get_csbits(&csbits_enhanced2e[0], TEXT("CHARSET40"), 0); // Enhanced //e: Alt char set off
@ -188,7 +232,10 @@ void make_csbits(void)
memcpy(&csbits_2e[1][64], &csbits_2e[0][64], 32*8); memcpy(&csbits_2e[1][64], &csbits_2e[0][64], 32*8);
// Try to use any user-provided video ROM for Enhanced //e // Try to use any user-provided video ROM for Enhanced //e
userVideoRom(); userVideoRomForIIe();
// Try to use any user-provided video ROM for II/II+
userVideoRomForIIPlus();
} }
csbits_t GetEnhanced2e_csbits(void) csbits_t GetEnhanced2e_csbits(void)

View File

@ -1160,7 +1160,7 @@ bool ReadVideoRomFile(const char* pRomFile)
return false; return false;
const ULONG size = GetFileSize(h, NULL); const ULONG size = GetFileSize(h, NULL);
if (size == kVideoRomSize4K || size == kVideoRomSize8K || size == kVideoRomSize16K) if (size == kVideoRomSize2K || size == kVideoRomSize4K || size == kVideoRomSize8K || size == kVideoRomSize16K)
{ {
DWORD bytesRead; DWORD bytesRead;
if (ReadFile(h, g_videoRom, size, &bytesRead, NULL) && bytesRead == size) if (ReadFile(h, g_videoRom, size, &bytesRead, NULL) && bytesRead == size)
@ -1197,7 +1197,7 @@ void SetVideoRomRockerSwitch(bool state)
bool IsVideoRom4K(void) bool IsVideoRom4K(void)
{ {
return g_videoRomSize == 0 || g_videoRomSize == kVideoRomSize4K; return g_videoRomSize <= kVideoRomSize4K;
} }
//=========================================================================== //===========================================================================

View File

@ -200,7 +200,8 @@ void Video_SetBitmapHeader( WinBmpHeader_t *pBmp, int nWidth, int nHeight, int n
BYTE VideoSetMode(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles); BYTE VideoSetMode(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles);
const UINT kVideoRomSize4K = 4*1024; const UINT kVideoRomSize2K = 1024*2;
const UINT kVideoRomSize4K = kVideoRomSize2K*2;
bool ReadVideoRomFile(const char* pRomFile); bool ReadVideoRomFile(const char* pRomFile);
UINT GetVideoRom(const BYTE*& pVideoRom); UINT GetVideoRom(const BYTE*& pVideoRom);
bool GetVideoRomRockerSwitch(void); bool GetVideoRomRockerSwitch(void);