mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-20 15:17:50 +00:00
CPU emu: added _POP_ALT and _PUSH_ALT macros
For SW_ALTZP=1, fixed memwrite[] to write to mem (ie. CPU read cache)
This commit is contained in:
+38
-6
@@ -391,10 +391,10 @@ static __forceinline bool NMI(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
#ifdef _DEBUG
|
||||
g_nCycleIrqStart = g_nCumulativeCycles + uExecutedCycles;
|
||||
#endif
|
||||
PUSH(regs.pc >> 8)
|
||||
PUSH(regs.pc & 0xFF)
|
||||
_PUSH(regs.pc >> 8)
|
||||
_PUSH(regs.pc & 0xFF)
|
||||
EF_TO_AF
|
||||
PUSH(regs.ps & ~AF_BREAK)
|
||||
_PUSH(regs.ps & ~AF_BREAK)
|
||||
regs.ps |= AF_INTERRUPT;
|
||||
if (GetMainCpu() == CPU_65C02) // GH#1099
|
||||
regs.ps &= ~AF_DECIMAL;
|
||||
@@ -433,10 +433,10 @@ 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)
|
||||
_PUSH(regs.pc >> 8)
|
||||
_PUSH(regs.pc & 0xFF)
|
||||
EF_TO_AF
|
||||
PUSH(regs.ps & ~AF_BREAK)
|
||||
_PUSH(regs.ps & ~AF_BREAK)
|
||||
regs.ps |= AF_INTERRUPT;
|
||||
if (GetMainCpu() == CPU_65C02) // GH#1099
|
||||
regs.ps &= ~AF_DECIMAL;
|
||||
@@ -466,17 +466,23 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
#define READ _READ_WITH_IO_F8xx
|
||||
#define WRITE(value) _WRITE_WITH_IO_F8xx(value)
|
||||
#define HEATMAP_X(address)
|
||||
#define POP _POP
|
||||
#define PUSH(value) _PUSH(value)
|
||||
|
||||
#include "CPU/cpu6502.h" // MOS 6502
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
// 6502 & no debugger & alt read/write support
|
||||
#define READ _READ_ALT
|
||||
#define WRITE(value) _WRITE_ALT(value)
|
||||
#define POP _POP_ALT
|
||||
#define PUSH(value) _PUSH_ALT(value)
|
||||
|
||||
#define Cpu6502 Cpu6502_altRW
|
||||
#include "CPU/cpu6502.h" // MOS 6502
|
||||
@@ -484,23 +490,31 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
// 65C02 & no debugger
|
||||
#define READ _READ
|
||||
#define WRITE(value) _WRITE(value)
|
||||
#define POP _POP
|
||||
#define PUSH(value) _PUSH(value)
|
||||
|
||||
#include "CPU/cpu65C02.h" // WDC 65C02
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
// 65C02 & no debugger & alt read/write support
|
||||
#define READ _READ_ALT
|
||||
#define WRITE(value) _WRITE_ALT(value)
|
||||
#define POP _POP_ALT
|
||||
#define PUSH(value) _PUSH_ALT(value)
|
||||
|
||||
#define Cpu65C02 Cpu65C02_altRW
|
||||
#include "CPU/cpu65C02.h" // WDC 65C02
|
||||
@@ -508,6 +522,8 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
#undef HEATMAP_X
|
||||
|
||||
//-----------------
|
||||
@@ -516,6 +532,8 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
#define READ Heatmap_ReadByte_With_IO_F8xx(addr, uExecutedCycles)
|
||||
#define WRITE(value) Heatmap_WriteByte_With_IO_F8xx(addr, value, uExecutedCycles);
|
||||
#define HEATMAP_X(address) Heatmap_X(address)
|
||||
#define POP _POP
|
||||
#define PUSH(value) _PUSH(value)
|
||||
|
||||
#include "CPU/cpu_heatmap.inl"
|
||||
|
||||
@@ -525,12 +543,16 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
// 6502 & debugger & alt read/write support
|
||||
#define READ _READ_ALT
|
||||
#define WRITE(value) _WRITE_ALT(value)
|
||||
#define POP _POP_ALT
|
||||
#define PUSH(value) _PUSH_ALT(value)
|
||||
|
||||
#define Cpu6502 Cpu6502_debug_altRW
|
||||
#include "CPU/cpu6502.h" // MOS 6502
|
||||
@@ -538,12 +560,16 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
// 65C02 & debugger
|
||||
#define READ Heatmap_ReadByte(addr, uExecutedCycles)
|
||||
#define WRITE(value) Heatmap_WriteByte(addr, value, uExecutedCycles);
|
||||
#define POP _POP
|
||||
#define PUSH(value) _PUSH(value)
|
||||
|
||||
#define Cpu65C02 Cpu65C02_debug
|
||||
#include "CPU/cpu65C02.h" // WDC 65C02
|
||||
@@ -551,12 +577,16 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
// 65C02 & debugger & alt read/write support
|
||||
#define READ _READ_ALT
|
||||
#define WRITE(value) _WRITE_ALT(value)
|
||||
#define POP _POP_ALT
|
||||
#define PUSH(value) _PUSH_ALT(value)
|
||||
|
||||
#define Cpu65C02 Cpu65C02_debug_altRW
|
||||
#include "CPU/cpu65C02.h" // WDC 65C02
|
||||
@@ -564,6 +594,8 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn,
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
#undef HEATMAP_X
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#undef AF_TO_EF
|
||||
#undef EF_TO_AF
|
||||
|
||||
|
||||
#define STACK_PAGE 0x01
|
||||
|
||||
#define AF_TO_EF flagc = (regs.ps & AF_CARRY); \
|
||||
flagn = (regs.ps & AF_SIGN); \
|
||||
@@ -50,10 +50,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
| AF_RESERVED | AF_BREAK;
|
||||
// CYC(a): This can be optimised, as only certain opcodes will affect uExtraCycles
|
||||
#define CYC(a) uExecutedCycles += (a)+uExtraCycles;
|
||||
#define POP (*(mem+((regs.sp >= 0x1FF) ? (regs.sp = 0x100) : ++regs.sp)))
|
||||
#define PUSH(a) *(mem+regs.sp--) = (a); \
|
||||
if (regs.sp < 0x100) \
|
||||
#define _POP (*(mem+((regs.sp >= 0x1FF) ? (regs.sp = 0x100) : ++regs.sp)))
|
||||
#define _POP_ALT ( \
|
||||
(memreadPageType[STACK_PAGE] == MEM_Normal) \
|
||||
? _POP \
|
||||
: (*(mem+TEXT_PAGE1_BEGIN+((regs.sp >= 0x1FF) ? (regs.sp = 0x100) : ++regs.sp))) /* memreadPageType[0x01] == MEM_Aux1K */ \
|
||||
)
|
||||
#define _PUSH(a) *(mem+regs.sp--) = (a); \
|
||||
if (regs.sp < 0x100) \
|
||||
regs.sp = 0x1FF;
|
||||
#define _PUSH_ALT(a) { \
|
||||
LPBYTE page = memwrite[STACK_PAGE]; \
|
||||
if (page) { \
|
||||
*(page+(regs.sp & 0xFF)) = (BYTE)(a); \
|
||||
} \
|
||||
regs.sp--; \
|
||||
if (regs.sp < 0x100) \
|
||||
regs.sp = 0x1FF; \
|
||||
}
|
||||
#define _READ ( \
|
||||
((addr & 0xF000) == 0xC000) \
|
||||
? IORead[(addr>>4) & 0xFF](regs.pc,addr,0,0,uExecutedCycles) \
|
||||
|
||||
+7
-2
@@ -1373,6 +1373,11 @@ static void UpdatePagingForAltRW(void)
|
||||
if (SW_AUXREAD || (SW_80STORE && SW_PAGE2))
|
||||
for (loop = 0x04; loop < 0x08; loop++)
|
||||
memreadPageType[loop] = MEM_Normal;
|
||||
|
||||
#if 1 // Don't need to fix IABS_NMOS / IABS_CMOS (opcode $6C) with this...
|
||||
if (SW_ALTZP)
|
||||
memcpy(mem, memaux + 0x400, 0x100);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1411,7 +1416,7 @@ static void UpdatePagingForAltRW(void)
|
||||
|
||||
for (loop = 0x00; loop < 0x02; loop++)
|
||||
if (SW_ALTZP)
|
||||
memwrite[loop] = memaux + TEXT_PAGE1_BEGIN + ((loop & 3) << 8);
|
||||
memwrite[loop] = mem + TEXT_PAGE1_BEGIN + ((loop & 3) << 8);
|
||||
|
||||
for (loop = 0x02; loop < 0xC0; loop++)
|
||||
if (SW_AUXWRITE)
|
||||
@@ -1419,7 +1424,7 @@ static void UpdatePagingForAltRW(void)
|
||||
|
||||
for (loop = 0xD0; loop < 0x100; loop++)
|
||||
if (SW_HIGHRAM && SW_ALTZP)
|
||||
memwrite[loop] = memaux + TEXT_PAGE1_BEGIN + ((loop & 3) << 8);
|
||||
memwrite[loop] = mem + TEXT_PAGE1_BEGIN + ((loop & 3) << 8);
|
||||
|
||||
if (SW_80STORE && SW_PAGE2)
|
||||
{
|
||||
|
||||
@@ -90,21 +90,29 @@ void NTSC_VideoUpdateCycles( long cycles6502 )
|
||||
#define READ _READ_WITH_IO_F8xx
|
||||
#define WRITE(a) _WRITE_WITH_IO_F8xx(a)
|
||||
#define HEATMAP_X(pc)
|
||||
#define POP _POP
|
||||
#define PUSH(a) _PUSH(a)
|
||||
|
||||
#include "../../source/CPU/cpu6502.h" // MOS 6502
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
|
||||
//-------
|
||||
|
||||
#define READ _READ
|
||||
#define WRITE(a) _WRITE(a)
|
||||
#define POP _POP
|
||||
#define PUSH(a) _PUSH(a)
|
||||
|
||||
#include "../../source/CPU/cpu65C02.h" // WDC 65C02
|
||||
|
||||
#undef READ
|
||||
#undef WRITE
|
||||
#undef POP
|
||||
#undef PUSH
|
||||
#undef HEATMAP_X
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user