Fix for reading $C01x for Apple II and II+ models. (#1261)

This commit is contained in:
tomcw 2024-01-28 21:31:42 +00:00
parent 56cc779351
commit fbc22fa566
3 changed files with 36 additions and 30 deletions

View File

@ -333,6 +333,22 @@ static char ClipboardCurrChar(bool bIncPtr)
return nKey;
}
static BYTE ClipboardReadOrPeek(bool incPtr)
{
if (g_bPasteFromClipboard)
ClipboardInit();
if (g_bClipboardActive)
{
if (*lptstr == 0)
ClipboardDone();
else
return 0x80 | ClipboardCurrChar(incPtr);
}
return 0;
}
//===========================================================================
const UINT kAKDNumElements = 256/64;
@ -402,43 +418,29 @@ BYTE KeybReadData (void)
{
LogFileTimeUntilFirstKeyRead();
if (g_bPasteFromClipboard)
ClipboardInit();
if (g_bClipboardActive)
{
if(*lptstr == 0)
ClipboardDone();
else
return 0x80 | ClipboardCurrChar(false);
}
//
BYTE res = ClipboardReadOrPeek(false);
if (res)
return res;
return keycode | (keywaiting ? 0x80 : 0);
}
//===========================================================================
BYTE KeybReadFlag (void)
BYTE KeybClearStrobe(void)
{
if (g_bPasteFromClipboard)
ClipboardInit();
if (g_bClipboardActive)
{
if(*lptstr == 0)
ClipboardDone();
else
return 0x80 | ClipboardCurrChar(true);
}
//
keywaiting = 0;
if (IS_APPLE2) // Include Pravets machines too?
return keycode;
return ClipboardReadOrPeek(true);
}
BYTE KeybReadFlag (void)
{
_ASSERT(!IS_APPLE2); // And also not Pravets machines?
BYTE res = KeybClearStrobe();
if (res)
return res;
// AKD

View File

@ -17,6 +17,7 @@ void KeybQueueKeypress(WPARAM key, Keystroke_e bASCII);
void KeybToggleCapsLock ();
void KeybToggleP8ACapsLock ();
void KeybAnyKeyDown(UINT message, WPARAM wparam, bool bIsExtended);
BYTE KeybClearStrobe(void);
BYTE KeybReadData (void);
BYTE KeybReadFlag (void);
void KeybSaveSnapshot(class YamlSaveHelper& yamlSaveHelper);

View File

@ -417,7 +417,10 @@ static BYTE __stdcall IOWrite_C00x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULON
static BYTE __stdcall IORead_C01x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles)
{
if (IS_APPLE2) // Include Pravets machines too?
return KeybReadFlag();
{
KeybClearStrobe();
return IO_Null(pc, addr, bWrite, d, nExecutedCycles); // GH#1261
}
bool res = false;
switch (addr & 0xf)
@ -445,7 +448,7 @@ static BYTE __stdcall IORead_C01x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG
static BYTE __stdcall IOWrite_C01x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles)
{
return KeybReadFlag();
return KeybClearStrobe();
}
//-------------------------------------