1
0
mirror of https://github.com/AppleWin/AppleWin.git synced 2025-04-01 15:29:39 +00:00

Fix IRQ; fix MB special writes

This commit is contained in:
tomcw 2025-03-13 22:13:51 +00:00
parent 7ed83f5045
commit 5606ebba46
2 changed files with 31 additions and 17 deletions

@ -452,14 +452,28 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
#ifdef _DEBUG
g_nCycleIrqStart = g_nCumulativeCycles + uExecutedCycles;
#endif
_PUSH(regs.pc >> 8)
_PUSH(regs.pc & 0xFF)
EF_TO_AF
_PUSH(regs.ps & ~AF_BREAK)
regs.ps |= AF_INTERRUPT;
if (GetMainCpu() == CPU_65C02) // GH#1099
regs.ps &= ~AF_DECIMAL;
regs.pc = * (WORD*) (mem+0xFFFE);
if (GetIsMemCacheValid())
{
_PUSH(regs.pc >> 8)
_PUSH(regs.pc & 0xFF)
EF_TO_AF;
_PUSH(regs.ps & ~AF_BREAK)
regs.ps |= AF_INTERRUPT;
if (GetMainCpu() == CPU_65C02) // GH#1099
regs.ps &= ~AF_DECIMAL;
regs.pc = *(WORD*)(mem + 0xFFFE);
}
else
{
_PUSH_ALT(regs.pc >> 8)
_PUSH_ALT(regs.pc & 0xFF)
EF_TO_AF;
_PUSH_ALT(regs.ps & ~AF_BREAK)
regs.ps |= AF_INTERRUPT;
if (GetMainCpu() == CPU_65C02) // GH#1099
regs.ps &= ~AF_DECIMAL;
regs.pc = READ_WORD_ALT(0xFFFE);
}
UINT uExtraCycles = 0; // Needed for CYC(a) macro
CYC(7);
#if defined(_DEBUG) && LOG_IRQ_TAKEN_AND_RTI

@ -619,7 +619,7 @@ BYTE MockingboardCard::IOReadInternal(WORD PC, WORD nAddr, BYTE bWrite, BYTE nVa
if (!IS_APPLE2 && MemCheckINTCXROM())
{
_ASSERT(0); // Card ROM disabled, so IO_Cxxx() returns the internal ROM
return mem[nAddr];
return ReadByteFromMemory(nAddr);
}
#endif
@ -691,22 +691,22 @@ BYTE MockingboardCard::IOWriteInternal(WORD PC, WORD nAddr, BYTE bWrite, BYTE nV
#endif
// Support 6502/65C02 false-reads of 6522 (GH#52)
if ( ((mem[(PC-2)&0xffff] == 0x91) && GetMainCpu() == CPU_6502) || // sta (zp),y - 6502 only (no-PX variant only) (UTAIIe:4-23)
(mem[(PC-3)&0xffff] == 0x99) || // sta abs16,y - 6502/65C02, but for 65C02 only the no-PX variant that does the false-read (UTAIIe:4-27)
(mem[(PC-3)&0xffff] == 0x9D) ) // sta abs16,x - 6502/65C02, but for 65C02 only the no-PX variant that does the false-read (UTAIIe:4-27)
if ( ((ReadByteFromMemory((PC-2)&0xffff) == 0x91) && GetMainCpu() == CPU_6502) || // sta (zp),y - 6502 only (no-PX variant only) (UTAIIe:4-23)
(ReadByteFromMemory((PC-3)&0xffff) == 0x99) || // sta abs16,y - 6502/65C02, but for 65C02 only the no-PX variant that does the false-read (UTAIIe:4-27)
(ReadByteFromMemory((PC-3)&0xffff) == 0x9D) ) // sta abs16,x - 6502/65C02, but for 65C02 only the no-PX variant that does the false-read (UTAIIe:4-27)
{
WORD base;
WORD addr16;
if (mem[(PC-2)&0xffff] == 0x91)
if (ReadByteFromMemory((PC-2)&0xffff) == 0x91)
{
BYTE zp = mem[(PC-1)&0xffff];
base = (mem[zp] | (mem[(zp+1)&0xff]<<8));
BYTE zp = ReadByteFromMemory((PC-1)&0xffff);
base = (ReadByteFromMemory(zp) | (ReadByteFromMemory((zp+1)&0xff)<<8));
addr16 = base + regs.y;
}
else
{
base = mem[(PC-2)&0xffff] | (mem[(PC-1)&0xffff]<<8);
addr16 = base + ((mem[(PC-3)&0xffff] == 0x99) ? regs.y : regs.x);
base = ReadByteFromMemory((PC-2)&0xffff) | (ReadByteFromMemory((PC-1)&0xffff)<<8);
addr16 = base + ((ReadByteFromMemory((PC-3)&0xffff) == 0x99) ? regs.y : regs.x);
}
if (((base ^ addr16) >> 8) == 0) // Only the no-PX variant does the false read (to the same I/O SELECT page)