ZPAddr = MemReadByte (Regs.PC+1); \
Addr = MemReadZPWord (ZPAddr); \
if (PAGE_CROSS (Addr, Regs.YR)) \
+ { \
++Cycles; \
+ } \
Addr += Regs.YR; \
Regs.AC = Regs.AC op MemReadByte (Addr); \
TEST_ZF (Regs.AC); \
} \
TEST_CF (Regs.AC); \
SET_OF ((res < -128) || (res > 127)); \
- if (CPU!=CPU_6502) \
+ if (CPU != CPU_6502) \
+ { \
++Cycles; \
+ } \
} else { \
Regs.AC += rhs + GET_CF (); \
TEST_ZF (Regs.AC); \
TEST_SF (res); \
SET_CF (res <= 0xFF); \
SET_OF (((old^rhs) & (old^res) & 0x80)); \
- if (CPU!=CPU_6502) \
+ if (CPU != CPU_6502) \
+ { \
++Cycles; \
+ } \
} else { \
Regs.AC -= rhs + (!GET_CF ()); \
TEST_ZF (Regs.AC); \
unsigned char Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
SET_ZF ((Val & Regs.AC) == 0);
MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC));
Regs.PC += 2;
unsigned Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr) << 1;
+ Val = MemReadByte (ZPAddr) << 1;
MemWriteByte (ZPAddr, (unsigned char) Val);
TEST_ZF (Val & 0xFF);
TEST_SF (Val);
unsigned char Val;
Cycles = 6;
Addr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
SET_ZF ((Val & Regs.AC) == 0);
MemWriteByte (Addr, (unsigned char) (Val | Regs.AC));
Regs.PC += 3;
unsigned Val;
Cycles = 6;
Addr = MemReadWord (Regs.PC+1);
- Val = MemReadByte (Addr) << 1;
+ Val = MemReadByte (Addr) << 1;
MemWriteByte (Addr, (unsigned char) Val);
TEST_ZF (Val & 0xFF);
TEST_SF (Val);
unsigned char Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
SET_ZF ((Val & Regs.AC) == 0);
MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC));
Regs.PC += 2;
unsigned Val;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (ZPAddr) << 1;
+ Val = MemReadByte (ZPAddr) << 1;
MemWriteByte (ZPAddr, (unsigned char) Val);
TEST_ZF (Val & 0xFF);
TEST_SF (Val);
unsigned char Val;
Cycles = 6;
Addr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
SET_ZF ((Val & Regs.AC) == 0);
MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC));
Regs.PC += 3;
unsigned Val;
Cycles = 7;
Addr = MemReadWord (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (Addr) << 1;
+ Val = MemReadByte (Addr) << 1;
MemWriteByte (Addr, (unsigned char) Val);
TEST_ZF (Val & 0xFF);
TEST_SF (Val);
{
unsigned Addr;
Cycles = 6;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
Regs.PC += 2;
PUSH (PCH);
PUSH (PCL);
unsigned char Val;
Cycles = 3;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
SET_SF (Val & 0x80);
SET_OF (Val & 0x40);
SET_ZF ((Val & Regs.AC) == 0);
unsigned Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
ROL (Val);
MemWriteByte (ZPAddr, Val);
Regs.PC += 2;
unsigned char Val;
Cycles = 4;
Addr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
SET_SF (Val & 0x80);
SET_OF (Val & 0x40);
SET_ZF ((Val & Regs.AC) == 0);
unsigned Val;
Cycles = 6;
Addr = MemReadWord (Regs.PC+1);
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
ROL (Val);
MemWriteByte (Addr, Val);
Regs.PC += 3;
unsigned char Val;
Cycles = 4;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
SET_SF (Val & 0x80);
SET_OF (Val & 0x40);
SET_ZF ((Val & Regs.AC) == 0);
unsigned Val;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
ROL (Val);
MemWriteByte (ZPAddr, Val);
Regs.PC += 2;
unsigned Val;
Cycles = 7;
Addr = MemReadWord (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
ROL (Val);
MemWriteByte (Addr, Val);
Regs.PC += 2;
unsigned char Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
SET_CF (Val & 0x01);
Val >>= 1;
MemWriteByte (ZPAddr, Val);
unsigned char Val;
Cycles = 6;
Addr = MemReadWord (Regs.PC+1);
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
SET_CF (Val & 0x01);
Val >>= 1;
MemWriteByte (Addr, Val);
unsigned char Val;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
SET_CF (Val & 0x01);
Val >>= 1;
MemWriteByte (ZPAddr, Val);
unsigned char Val;
Cycles = 7;
Addr = MemReadWord (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
SET_CF (Val & 0x01);
Val >>= 1;
MemWriteByte (Addr, Val);
unsigned Addr;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
ADC (MemReadByte (Addr));
Regs.PC += 2;
}
unsigned Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
ROR (Val);
MemWriteByte (ZPAddr, Val);
Regs.PC += 2;
PC = Regs.PC;
Lo = MemReadWord (PC+1);
- if (CPU==CPU_6502)
+ if (CPU == CPU_6502)
{
/* Emulate the 6502 bug */
Cycles = 5;
unsigned Val;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (ZPAddr);
+ Val = MemReadByte (ZPAddr);
ROR (Val);
MemWriteByte (ZPAddr, Val);
Regs.PC += 2;
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
if (PAGE_CROSS (Addr, Regs.YR)) {
++Cycles;
}
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
if (PAGE_CROSS (Addr, Regs.XR)) {
++Cycles;
}
unsigned Val;
Cycles = 7;
Addr = MemReadWord (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (Addr);
+ Val = MemReadByte (Addr);
ROR (Val);
MemWriteByte (Addr, Val);
Regs.PC += 3;
unsigned Addr;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
MemWriteByte (Addr, Regs.AC);
Regs.PC += 2;
}
{
unsigned char Val;
Cycles = 2;
- Val = MemReadByte (Regs.PC+1);
+ Val = MemReadByte (Regs.PC+1);
SET_SF (Val & 0x80);
SET_OF (Val & 0x40);
SET_ZF ((Val & Regs.AC) == 0);
unsigned Addr;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadZPWord (ZPAddr) + Regs.YR;
+ Addr = MemReadZPWord (ZPAddr) + Regs.YR;
MemWriteByte (Addr, Regs.AC);
Regs.PC += 2;
}
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
MemWriteByte (Addr, Regs.AC);
Regs.PC += 2;
}
{
unsigned Addr;
Cycles = 5;
- Addr = MemReadWord (Regs.PC+1) + Regs.YR;
+ Addr = MemReadWord (Regs.PC+1) + Regs.YR;
MemWriteByte (Addr, Regs.AC);
Regs.PC += 3;
}
{
unsigned Addr;
Cycles = 5;
- Addr = MemReadWord (Regs.PC+1) + Regs.XR;
+ Addr = MemReadWord (Regs.PC+1) + Regs.XR;
MemWriteByte (Addr, Regs.AC);
Regs.PC += 3;
}
{
unsigned Addr;
Cycles = 5;
- Addr = MemReadWord (Regs.PC+1) + Regs.XR;
+ Addr = MemReadWord (Regs.PC+1) + Regs.XR;
MemWriteByte (Addr, 0);
Regs.PC += 3;
}
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
Regs.YR = MemReadByte (Addr);
TEST_ZF (Regs.YR);
TEST_SF (Regs.YR);
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
Regs.AC = MemReadByte (Addr);
TEST_ZF (Regs.AC);
TEST_SF (Regs.AC);
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
Regs.XR = MemReadByte (Addr);
TEST_ZF (Regs.XR);
TEST_SF (Regs.XR);
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
if (PAGE_CROSS (Addr, Regs.YR)) {
++Cycles;
}
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
Regs.AC = MemReadByte (Addr);
TEST_ZF (Regs.AC);
TEST_SF (Regs.AC);
unsigned Addr;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
CMP (Regs.AC, MemReadByte (Addr));
Regs.PC += 2;
}
unsigned char Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr) - 1;
+ Val = MemReadByte (ZPAddr) - 1;
MemWriteByte (ZPAddr, Val);
TEST_ZF (Val);
TEST_SF (Val);
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
CMP (Regs.YR, MemReadByte (Addr));
Regs.PC += 3;
}
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
CMP (Regs.AC, MemReadByte (Addr));
Regs.PC += 3;
}
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadWord (ZPAddr);
+ Addr = MemReadWord (ZPAddr);
if (PAGE_CROSS (Addr, Regs.YR)) {
++Cycles;
}
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadWord (ZPAddr);
+ Addr = MemReadWord (ZPAddr);
CMP (Regs.AC, MemReadByte (Addr));
Regs.PC += 2;
}
unsigned char Val;
Cycles = 7;
Addr = MemReadWord (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (Addr) - 1;
+ Val = MemReadByte (Addr) - 1;
MemWriteByte (Addr, Val);
TEST_ZF (Val);
TEST_SF (Val);
unsigned Addr;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
SBC (MemReadByte (Addr));
Regs.PC += 2;
}
unsigned char Val;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Val = MemReadByte (ZPAddr) + 1;
+ Val = MemReadByte (ZPAddr) + 1;
MemWriteByte (ZPAddr, Val);
TEST_ZF (Val);
TEST_SF (Val);
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
SBC (MemReadByte (Addr));
Regs.PC += 3;
}
unsigned char Val;
Cycles = 6;
Addr = MemReadWord (Regs.PC+1);
- Val = MemReadByte (Addr) + 1;
+ Val = MemReadByte (Addr) + 1;
MemWriteByte (Addr, Val);
TEST_ZF (Val);
TEST_SF (Val);
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
if (PAGE_CROSS (Addr, Regs.YR)) {
++Cycles;
}
unsigned Addr;
Cycles = 5;
ZPAddr = MemReadByte (Regs.PC+1);
- Addr = MemReadZPWord (ZPAddr);
+ Addr = MemReadZPWord (ZPAddr);
SBC (MemReadByte (Addr));
Regs.PC += 2;
}
unsigned char Val;
Cycles = 6;
ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (ZPAddr) + 1;
+ Val = MemReadByte (ZPAddr) + 1;
MemWriteByte (ZPAddr, Val);
TEST_ZF (Val);
TEST_SF (Val);
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
if (PAGE_CROSS (Addr, Regs.YR)) {
++Cycles;
}
{
unsigned Addr;
Cycles = 4;
- Addr = MemReadWord (Regs.PC+1);
+ Addr = MemReadWord (Regs.PC+1);
if (PAGE_CROSS (Addr, Regs.XR)) {
++Cycles;
}
unsigned char Val;
Cycles = 7;
Addr = MemReadWord (Regs.PC+1) + Regs.XR;
- Val = MemReadByte (Addr) + 1;
+ Val = MemReadByte (Addr) + 1;
MemWriteByte (Addr, Val);
TEST_ZF (Val);
TEST_SF (Val);