Allow switching between 3 SMP cores at compile-time.

This commit is contained in:
Brandon Wright 2011-10-18 13:10:06 -05:00
parent 70159fd939
commit 13c55b9260
12 changed files with 6126 additions and 1114 deletions

View File

@ -59,12 +59,25 @@ void SMP::op_step() {
#define op_writestack(data) op_write(0x0100 | regs.sp--, data) #define op_writestack(data) op_write(0x0100 | regs.sp--, data)
#if defined(CYCLE_ACCURATE) #if defined(CYCLE_ACCURATE)
#if defined(PSEUDO_CYCLE)
if(opcode_cycle == 0) if(opcode_cycle == 0)
opcode_number = op_readpc(); opcode_number = op_readpc();
// opcode_cycle++;
switch(opcode_number) { switch(opcode_number) {
#include "core/oppseudo_misc.cpp"
#include "core/oppseudo_mov.cpp"
#include "core/oppseudo_pc.cpp"
#include "core/oppseudo_read.cpp"
#include "core/oppseudo_rmw.cpp"
}
#else
if(opcode_cycle == 0) {
opcode_number = op_readpc();
opcode_cycle++;
} else switch(opcode_number) {
#include "core/opcycle_misc.cpp" #include "core/opcycle_misc.cpp"
#include "core/opcycle_mov.cpp" #include "core/opcycle_mov.cpp"
#include "core/opcycle_pc.cpp" #include "core/opcycle_pc.cpp"
@ -72,6 +85,7 @@ void SMP::op_step() {
#include "core/opcycle_rmw.cpp" #include "core/opcycle_rmw.cpp"
} }
#endif // defined(PSEUDO_CYCLE)
#else #else
unsigned opcode = op_readpc(); unsigned opcode = op_readpc();
@ -98,8 +112,7 @@ void SMP::op_step() {
dsp.clock += cycle_count_table[opcode]; dsp.clock += cycle_count_table[opcode];
#endif #endif
#endif // defined(CYCLE_ACCURATE)
#endif
} }
const unsigned SMP::cycle_count_table[256] = { const unsigned SMP::cycle_count_table[256] = {

View File

@ -1,30 +1,70 @@
case 0x00: { case 0x00: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xef: { case 0xef: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
regs.pc--; regs.pc--;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xff: { case 0xff: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
regs.pc--; regs.pc--;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x9f: { case 0x9f: {
op_io(4); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_io();
break;
case 4:
op_io();
regs.a = (regs.a >> 4) | (regs.a << 4); regs.a = (regs.a >> 4) | (regs.a << 4);
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xdf: { case 0xdf: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
if(regs.p.c || (regs.a) > 0x99) { if(regs.p.c || (regs.a) > 0x99) {
regs.a += 0x60; regs.a += 0x60;
regs.p.c = 1; regs.p.c = 1;
@ -34,11 +74,19 @@ case 0xdf: {
} }
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xbe: { case 0xbe: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
if(!regs.p.c || (regs.a) > 0x99) { if(!regs.p.c || (regs.a) > 0x99) {
regs.a -= 0x60; regs.a -= 0x60;
regs.p.c = 0; regs.p.c = 0;
@ -48,247 +96,581 @@ case 0xbe: {
} }
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x60: { case 0x60: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.p.c = 0; regs.p.c = 0;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x20: { case 0x20: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.p.p = 0; regs.p.p = 0;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x80: { case 0x80: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.p.c = 1; regs.p.c = 1;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x40: { case 0x40: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.p.p = 1; regs.p.p = 1;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xe0: { case 0xe0: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.p.v = 0; regs.p.v = 0;
regs.p.h = 0; regs.p.h = 0;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xed: { case 0xed: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
regs.p.c = !regs.p.c; regs.p.c = !regs.p.c;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xa0: { case 0xa0: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
regs.p.i = 1; regs.p.i = 1;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xc0: { case 0xc0: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
regs.p.i = 0; regs.p.i = 0;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x02: { case 0x02: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x01; rd |= 0x01;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x12: { case 0x12: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x01; rd &= ~0x01;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x22: { case 0x22: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x02; rd |= 0x02;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x32: { case 0x32: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x02; rd &= ~0x02;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x42: { case 0x42: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x04; rd |= 0x04;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x52: { case 0x52: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x04; rd &= ~0x04;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x62: { case 0x62: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x08; rd |= 0x08;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x72: { case 0x72: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x08; rd &= ~0x08;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x82: { case 0x82: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x10; rd |= 0x10;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x92: { case 0x92: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x10; rd &= ~0x10;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xa2: { case 0xa2: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x20; rd |= 0x20;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xb2: { case 0xb2: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x20; rd &= ~0x20;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xc2: { case 0xc2: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x40; rd |= 0x40;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xd2: { case 0xd2: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x40; rd &= ~0x40;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xe2: { case 0xe2: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd |= 0x80; rd |= 0x80;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xf2: { case 0xf2: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd &= ~0x80; rd &= ~0x80;
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x2d: { case 0x2d: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_writestack(regs.a); op_writestack(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x4d: { case 0x4d: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_writestack(regs.x); op_writestack(regs.x);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x6d: { case 0x6d: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_writestack(regs.y); op_writestack(regs.y);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x0d: { case 0x0d: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_writestack(regs.p); op_writestack(regs.p);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xae: { case 0xae: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
regs.a = op_readstack(); regs.a = op_readstack();
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xce: { case 0xce: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
regs.x = op_readstack(); regs.x = op_readstack();
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xee: { case 0xee: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
regs.y = op_readstack(); regs.y = op_readstack();
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x8e: { case 0x8e: {
op_io(2); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
regs.p = op_readstack(); regs.p = op_readstack();
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xcf: { case 0xcf: {
op_io(8); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_io();
break;
case 4:
op_io();
break;
case 5:
op_io();
break;
case 6:
op_io();
break;
case 7:
op_io();
break;
case 8:
op_io();
ya = regs.y * regs.a; ya = regs.y * regs.a;
regs.a = ya; regs.a = ya;
regs.y = ya >> 8; regs.y = ya >> 8;
//result is set based on y (high-byte) only //result is set based on y (high-byte) only
regs.p.n = !!(regs.y & 0x80); regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0); regs.p.z = (regs.y == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x9e: { case 0x9e: {
op_io(11); switch(opcode_cycle++) {
case 1:
op_io();
break;
case 2:
op_io();
break;
case 3:
op_io();
break;
case 4:
op_io();
break;
case 5:
op_io();
break;
case 6:
op_io();
break;
case 7:
op_io();
break;
case 8:
op_io();
break;
case 9:
op_io();
break;
case 10:
op_io();
break;
case 11:
op_io();
ya = regs.ya; ya = regs.ya;
//overflow set if quotient >= 256 //overflow set if quotient >= 256
regs.p.v = !!(regs.y >= regs.x); regs.p.v = !!(regs.y >= regs.x);
@ -306,6 +688,9 @@ case 0x9e: {
//result is set based on a (quotient) only //result is set based on a (quotient) only
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }

View File

@ -1,72 +1,117 @@
case 0x7d: { case 0x7d: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = regs.x; regs.a = regs.x;
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xdd: { case 0xdd: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = regs.y; regs.a = regs.y;
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x5d: { case 0x5d: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.x = regs.a; regs.x = regs.a;
regs.p.n = !!(regs.x & 0x80); regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0); regs.p.z = (regs.x == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xfd: { case 0xfd: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.y = regs.a; regs.y = regs.a;
regs.p.n = !!(regs.y & 0x80); regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0); regs.p.z = (regs.y == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x9d: { case 0x9d: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.x = regs.sp; regs.x = regs.sp;
regs.p.n = !!(regs.x & 0x80); regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0); regs.p.z = (regs.x == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xbd: { case 0xbd: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.sp = regs.x; regs.sp = regs.x;
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xe8: { case 0xe8: {
switch(opcode_cycle++) {
case 1:
regs.a = op_readpc(); regs.a = op_readpc();
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xcd: { case 0xcd: {
switch(opcode_cycle++) {
case 1:
regs.x = op_readpc(); regs.x = op_readpc();
regs.p.n = !!(regs.x & 0x80); regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0); regs.p.z = (regs.x == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x8d: { case 0x8d: {
switch(opcode_cycle++) {
case 1:
regs.y = op_readpc(); regs.y = op_readpc();
regs.p.n = !!(regs.y & 0x80); regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0); regs.p.z = (regs.y == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xe6: { case 0xe6: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
op_io(); op_io();
break; break;
@ -81,12 +126,14 @@ case 0xe6: {
} }
case 0xbf: { case 0xbf: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
op_io(); op_io();
break; break;
case 2: case 2:
regs.a = op_readdp(regs.x++); regs.a = op_readdp(regs.x++);
break;
case 3:
op_io(); op_io();
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
@ -97,7 +144,7 @@ case 0xbf: {
} }
case 0xe4: { case 0xe4: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
@ -112,7 +159,7 @@ case 0xe4: {
} }
case 0xf8: { case 0xf8: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
@ -127,7 +174,7 @@ case 0xf8: {
} }
case 0xeb: { case 0xeb: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
@ -142,12 +189,14 @@ case 0xeb: {
} }
case 0xf4: { case 0xf4: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
op_io();
break; break;
case 2: case 2:
op_io();
break;
case 3:
regs.a = op_readdp(sp + regs.x); regs.a = op_readdp(sp + regs.x);
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
@ -158,12 +207,14 @@ case 0xf4: {
} }
case 0xf9: { case 0xf9: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
op_io();
break; break;
case 2: case 2:
op_io();
break;
case 3:
regs.x = op_readdp(sp + regs.y); regs.x = op_readdp(sp + regs.y);
regs.p.n = !!(regs.x & 0x80); regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0); regs.p.z = (regs.x == 0);
@ -174,12 +225,14 @@ case 0xf9: {
} }
case 0xfb: { case 0xfb: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
op_io();
break; break;
case 2: case 2:
op_io();
break;
case 3:
regs.y = op_readdp(sp + regs.x); regs.y = op_readdp(sp + regs.x);
regs.p.n = !!(regs.y & 0x80); regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0); regs.p.z = (regs.y == 0);
@ -190,7 +243,7 @@ case 0xfb: {
} }
case 0xe5: { case 0xe5: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
@ -208,12 +261,14 @@ case 0xe5: {
} }
case 0xe9: { case 0xe9: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
sp |= op_readpc() << 8;
break; break;
case 2: case 2:
sp |= op_readpc() << 8;
break;
case 3:
regs.x = op_readaddr(sp); regs.x = op_readaddr(sp);
regs.p.n = !!(regs.x & 0x80); regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0); regs.p.z = (regs.x == 0);
@ -224,12 +279,14 @@ case 0xe9: {
} }
case 0xec: { case 0xec: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
sp |= op_readpc() << 8;
break; break;
case 2: case 2:
sp |= op_readpc() << 8;
break;
case 3:
regs.y = op_readaddr(sp); regs.y = op_readaddr(sp);
regs.p.n = !!(regs.y & 0x80); regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0); regs.p.z = (regs.y == 0);
@ -240,13 +297,17 @@ case 0xec: {
} }
case 0xf5: { case 0xf5: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
sp |= op_readpc() << 8;
op_io();
break; break;
case 2: case 2:
sp |= op_readpc() << 8;
break;
case 3:
op_io();
break;
case 4:
regs.a = op_readaddr(sp + regs.x); regs.a = op_readaddr(sp + regs.x);
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
@ -257,13 +318,17 @@ case 0xf5: {
} }
case 0xf6: { case 0xf6: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
sp |= op_readpc() << 8;
op_io();
break; break;
case 2: case 2:
sp |= op_readpc() << 8;
break;
case 3:
op_io();
break;
case 4:
regs.a = op_readaddr(sp + regs.y); regs.a = op_readaddr(sp + regs.y);
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
@ -274,18 +339,20 @@ case 0xf6: {
} }
case 0xe7: { case 0xe7: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc() + regs.x; dp = op_readpc() + regs.x;
op_io();
break; break;
case 2: case 2:
sp = op_readdp(dp); op_io();
break; break;
case 3: case 3:
sp |= op_readdp(dp + 1) << 8; sp = op_readdp(dp);
break; break;
case 4: case 4:
sp |= op_readdp(dp + 1) << 8;
break;
case 5:
regs.a = op_readaddr(sp); regs.a = op_readaddr(sp);
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
@ -296,18 +363,20 @@ case 0xe7: {
} }
case 0xf7: { case 0xf7: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
op_io();
break; break;
case 2: case 2:
sp = op_readdp(dp); op_io();
break; break;
case 3: case 3:
sp |= op_readdp(dp + 1) << 8; sp = op_readdp(dp);
break; break;
case 4: case 4:
sp |= op_readdp(dp + 1) << 8;
break;
case 5:
regs.a = op_readaddr(sp + regs.y); regs.a = op_readaddr(sp + regs.y);
regs.p.n = !!(regs.a & 0x80); regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0); regs.p.z = (regs.a == 0);
@ -318,7 +387,7 @@ case 0xf7: {
} }
case 0xfa: { case 0xfa: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
@ -337,15 +406,17 @@ case 0xfa: {
} }
case 0x8f: { case 0x8f: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
rd = op_readpc(); rd = op_readpc();
dp = op_readpc();
break; break;
case 2: case 2:
op_readdp(dp); dp = op_readpc();
break; break;
case 3: case 3:
op_readdp(dp);
break;
case 4:
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -354,7 +425,7 @@ case 0x8f: {
} }
case 0xc6: { case 0xc6: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
op_io(); op_io();
break; break;
@ -370,10 +441,14 @@ case 0xc6: {
} }
case 0xaf: { case 0xaf: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
op_io(2); op_io();
break;
case 2: case 2:
op_io();
break;
case 3:
op_writedp(regs.x++, regs.a); op_writedp(regs.x++, regs.a);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -382,7 +457,7 @@ case 0xaf: {
} }
case 0xc4: { case 0xc4: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -398,7 +473,7 @@ case 0xc4: {
} }
case 0xd8: { case 0xd8: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -414,7 +489,7 @@ case 0xd8: {
} }
case 0xcb: { case 0xcb: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -430,16 +505,18 @@ case 0xcb: {
} }
case 0xd4: { case 0xd4: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
dp += regs.x; dp += regs.x;
break; break;
case 2: case 3:
op_readdp(dp); op_readdp(dp);
break; break;
case 3: case 4:
op_writedp(dp, regs.a); op_writedp(dp, regs.a);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -448,16 +525,18 @@ case 0xd4: {
} }
case 0xd9: { case 0xd9: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
dp += regs.y; dp += regs.y;
break; break;
case 2: case 3:
op_readdp(dp); op_readdp(dp);
break; break;
case 3: case 4:
op_writedp(dp, regs.x); op_writedp(dp, regs.x);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -466,16 +545,18 @@ case 0xd9: {
} }
case 0xdb: { case 0xdb: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
dp += regs.x; dp += regs.x;
break; break;
case 2: case 3:
op_readdp(dp); op_readdp(dp);
break; break;
case 3: case 4:
op_writedp(dp, regs.y); op_writedp(dp, regs.y);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -484,7 +565,7 @@ case 0xdb: {
} }
case 0xc5: { case 0xc5: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -503,7 +584,7 @@ case 0xc5: {
} }
case 0xc9: { case 0xc9: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -522,7 +603,7 @@ case 0xc9: {
} }
case 0xcc: { case 0xcc: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -541,17 +622,21 @@ case 0xcc: {
} }
case 0xd5: { case 0xd5: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
op_io(); op_io();
dp += regs.x; dp += regs.x;
break; break;
case 2: case 4:
op_readaddr(dp); op_readaddr(dp);
break; break;
case 3: case 5:
op_writeaddr(dp, regs.a); op_writeaddr(dp, regs.a);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -560,17 +645,21 @@ case 0xd5: {
} }
case 0xd6: { case 0xd6: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
op_io(); op_io();
dp += regs.y; dp += regs.y;
break; break;
case 2: case 4:
op_readaddr(dp); op_readaddr(dp);
break; break;
case 3: case 5:
op_writeaddr(dp, regs.a); op_writeaddr(dp, regs.a);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -579,22 +668,24 @@ case 0xd6: {
} }
case 0xc7: { case 0xc7: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break;
case 2:
op_io(); op_io();
sp += regs.x; sp += regs.x;
break; break;
case 2: case 3:
dp = op_readdp(sp); dp = op_readdp(sp);
break; break;
case 3: case 4:
dp |= op_readdp(sp + 1) << 8; dp |= op_readdp(sp + 1) << 8;
break; break;
case 4: case 5:
op_readaddr(dp); op_readaddr(dp);
break; break;
case 5: case 6:
op_writeaddr(dp, regs.a); op_writeaddr(dp, regs.a);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -603,7 +694,7 @@ case 0xc7: {
} }
case 0xd7: { case 0xd7: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
@ -612,13 +703,15 @@ case 0xd7: {
break; break;
case 3: case 3:
dp |= op_readdp(sp + 1) << 8; dp |= op_readdp(sp + 1) << 8;
break;
case 4:
op_io(); op_io();
dp += regs.y; dp += regs.y;
break; break;
case 4: case 5:
op_readaddr(dp); op_readaddr(dp);
break; break;
case 5: case 6:
op_writeaddr(dp, regs.a); op_writeaddr(dp, regs.a);
opcode_cycle = 0; opcode_cycle = 0;
break; break;
@ -627,15 +720,17 @@ case 0xd7: {
} }
case 0xba: { case 0xba: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
break; break;
case 2: case 2:
regs.a = op_readdp(sp); regs.a = op_readdp(sp);
op_io();
break; break;
case 3: case 3:
op_io();
break;
case 4:
regs.y = op_readdp(sp + 1); regs.y = op_readdp(sp + 1);
regs.p.n = !!(regs.ya & 0x8000); regs.p.n = !!(regs.ya & 0x8000);
regs.p.z = (regs.ya == 0); regs.p.z = (regs.ya == 0);
@ -646,7 +741,7 @@ case 0xba: {
} }
case 0xda: { case 0xda: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
break; break;
@ -665,12 +760,14 @@ case 0xda: {
} }
case 0xaa: { case 0xaa: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
sp = op_readpc(); sp = op_readpc();
sp |= op_readpc() << 8;
break; break;
case 2: case 2:
sp |= op_readpc() << 8;
break;
case 3:
bit = sp >> 13; bit = sp >> 13;
sp &= 0x1fff; sp &= 0x1fff;
rd = op_readaddr(sp); rd = op_readaddr(sp);
@ -682,20 +779,24 @@ case 0xaa: {
} }
case 0xca: { case 0xca: {
switch(++opcode_cycle) { switch(opcode_cycle++) {
case 1: case 1:
dp = op_readpc(); dp = op_readpc();
dp |= op_readpc() << 8;
break; break;
case 2: case 2:
dp |= op_readpc() << 8;
break;
case 3:
bit = dp >> 13; bit = dp >> 13;
dp &= 0x1fff; dp &= 0x1fff;
rd = op_readaddr(dp); rd = op_readaddr(dp);
if(regs.p.c)rd |= (1 << bit); if(regs.p.c)rd |= (1 << bit);
else rd &= ~(1 << bit); else rd &= ~(1 << bit);
break;
case 4:
op_io(); op_io();
break; break;
case 3: case 5:
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0; opcode_cycle = 0;
break; break;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,262 +1,550 @@
case 0xbc: { case 0xbc: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = op_inc(regs.a); regs.a = op_inc(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x3d: { case 0x3d: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.x = op_inc(regs.x); regs.x = op_inc(regs.x);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xfc: { case 0xfc: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.y = op_inc(regs.y); regs.y = op_inc(regs.y);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x9c: { case 0x9c: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = op_dec(regs.a); regs.a = op_dec(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x1d: { case 0x1d: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.x = op_dec(regs.x); regs.x = op_dec(regs.x);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xdc: { case 0xdc: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.y = op_dec(regs.y); regs.y = op_dec(regs.y);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x1c: { case 0x1c: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = op_asl(regs.a); regs.a = op_asl(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x5c: { case 0x5c: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = op_lsr(regs.a); regs.a = op_lsr(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x3c: { case 0x3c: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = op_rol(regs.a); regs.a = op_rol(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x7c: { case 0x7c: {
switch(opcode_cycle++) {
case 1:
op_io(); op_io();
regs.a = op_ror(regs.a); regs.a = op_ror(regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xab: { case 0xab: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd = op_inc(rd); rd = op_inc(rd);
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x8b: { case 0x8b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd = op_dec(rd); rd = op_dec(rd);
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x0b: { case 0x0b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd = op_asl(rd); rd = op_asl(rd);
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x4b: { case 0x4b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd = op_lsr(rd); rd = op_lsr(rd);
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x2b: { case 0x2b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd = op_rol(rd); rd = op_rol(rd);
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x6b: { case 0x6b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
break;
case 3:
rd = op_ror(rd); rd = op_ror(rd);
op_writedp(dp, rd); op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xbb: { case 0xbb: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
break;
case 3:
rd = op_readdp(dp + regs.x); rd = op_readdp(dp + regs.x);
break;
case 4:
rd = op_inc(rd); rd = op_inc(rd);
op_writedp(dp + regs.x, rd); op_writedp(dp + regs.x, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x9b: { case 0x9b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
break;
case 3:
rd = op_readdp(dp + regs.x); rd = op_readdp(dp + regs.x);
break;
case 4:
rd = op_dec(rd); rd = op_dec(rd);
op_writedp(dp + regs.x, rd); op_writedp(dp + regs.x, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x1b: { case 0x1b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
break;
case 3:
rd = op_readdp(dp + regs.x); rd = op_readdp(dp + regs.x);
break;
case 4:
rd = op_asl(rd); rd = op_asl(rd);
op_writedp(dp + regs.x, rd); op_writedp(dp + regs.x, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x5b: { case 0x5b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
break;
case 3:
rd = op_readdp(dp + regs.x); rd = op_readdp(dp + regs.x);
break;
case 4:
rd = op_lsr(rd); rd = op_lsr(rd);
op_writedp(dp + regs.x, rd); op_writedp(dp + regs.x, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x3b: { case 0x3b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
break;
case 3:
rd = op_readdp(dp + regs.x); rd = op_readdp(dp + regs.x);
break;
case 4:
rd = op_rol(rd); rd = op_rol(rd);
op_writedp(dp + regs.x, rd); op_writedp(dp + regs.x, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x7b: { case 0x7b: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
op_io(); op_io();
break;
case 3:
rd = op_readdp(dp + regs.x); rd = op_readdp(dp + regs.x);
break;
case 4:
rd = op_ror(rd); rd = op_ror(rd);
op_writedp(dp + regs.x, rd); op_writedp(dp + regs.x, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0xac: { case 0xac: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
break;
case 4:
rd = op_inc(rd); rd = op_inc(rd);
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x8c: { case 0x8c: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
break;
case 4:
rd = op_dec(rd); rd = op_dec(rd);
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x0c: { case 0x0c: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
break;
case 4:
rd = op_asl(rd); rd = op_asl(rd);
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x4c: { case 0x4c: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
break;
case 4:
rd = op_lsr(rd); rd = op_lsr(rd);
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x2c: { case 0x2c: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
break;
case 4:
rd = op_rol(rd); rd = op_rol(rd);
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x6c: { case 0x6c: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
break;
case 4:
rd = op_ror(rd); rd = op_ror(rd);
op_writeaddr(dp, rd); op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x0e: { case 0x0e: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
regs.p.n = !!((regs.a - rd) & 0x80); regs.p.n = !!((regs.a - rd) & 0x80);
regs.p.z = ((regs.a - rd) == 0); regs.p.z = ((regs.a - rd) == 0);
break;
case 4:
op_readaddr(dp); op_readaddr(dp);
break;
case 5:
op_writeaddr(dp, rd | regs.a); op_writeaddr(dp, rd | regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x4e: { case 0x4e: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8; dp |= op_readpc() << 8;
break;
case 3:
rd = op_readaddr(dp); rd = op_readaddr(dp);
regs.p.n = !!((regs.a - rd) & 0x80); regs.p.n = !!((regs.a - rd) & 0x80);
regs.p.z = ((regs.a - rd) == 0); regs.p.z = ((regs.a - rd) == 0);
break;
case 4:
op_readaddr(dp); op_readaddr(dp);
break;
case 5:
op_writeaddr(dp, rd &~ regs.a); op_writeaddr(dp, rd &~ regs.a);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x3a: { case 0x3a: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
rd++; rd++;
break;
case 3:
op_writedp(dp++, rd); op_writedp(dp++, rd);
break;
case 4:
rd += op_readdp(dp) << 8; rd += op_readdp(dp) << 8;
break;
case 5:
op_writedp(dp, rd >> 8); op_writedp(dp, rd >> 8);
regs.p.n = !!(rd & 0x8000); regs.p.n = !!(rd & 0x8000);
regs.p.z = (rd == 0); regs.p.z = (rd == 0);
opcode_cycle = 0;
break;
}
break; break;
} }
case 0x1a: { case 0x1a: {
switch(opcode_cycle++) {
case 1:
dp = op_readpc(); dp = op_readpc();
break;
case 2:
rd = op_readdp(dp); rd = op_readdp(dp);
rd--; rd--;
break;
case 3:
op_writedp(dp++, rd); op_writedp(dp++, rd);
break;
case 4:
rd += op_readdp(dp) << 8; rd += op_readdp(dp) << 8;
break;
case 5:
op_writedp(dp, rd >> 8); op_writedp(dp, rd >> 8);
regs.p.n = !!(rd & 0x8000); regs.p.n = !!(rd & 0x8000);
regs.p.z = (rd == 0); regs.p.z = (rd == 0);
opcode_cycle = 0;
break;
}
break; break;
} }

View File

@ -0,0 +1,311 @@
case 0x00: {
op_io();
break;
}
case 0xef: {
op_io(2);
regs.pc--;
break;
}
case 0xff: {
op_io(2);
regs.pc--;
break;
}
case 0x9f: {
op_io(4);
regs.a = (regs.a >> 4) | (regs.a << 4);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}
case 0xdf: {
op_io(2);
if(regs.p.c || (regs.a) > 0x99) {
regs.a += 0x60;
regs.p.c = 1;
}
if(regs.p.h || (regs.a & 15) > 0x09) {
regs.a += 0x06;
}
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}
case 0xbe: {
op_io(2);
if(!regs.p.c || (regs.a) > 0x99) {
regs.a -= 0x60;
regs.p.c = 0;
}
if(!regs.p.h || (regs.a & 15) > 0x09) {
regs.a -= 0x06;
}
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}
case 0x60: {
op_io();
regs.p.c = 0;
break;
}
case 0x20: {
op_io();
regs.p.p = 0;
break;
}
case 0x80: {
op_io();
regs.p.c = 1;
break;
}
case 0x40: {
op_io();
regs.p.p = 1;
break;
}
case 0xe0: {
op_io();
regs.p.v = 0;
regs.p.h = 0;
break;
}
case 0xed: {
op_io(2);
regs.p.c = !regs.p.c;
break;
}
case 0xa0: {
op_io(2);
regs.p.i = 1;
break;
}
case 0xc0: {
op_io(2);
regs.p.i = 0;
break;
}
case 0x02: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x01;
op_writedp(dp, rd);
break;
}
case 0x12: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x01;
op_writedp(dp, rd);
break;
}
case 0x22: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x02;
op_writedp(dp, rd);
break;
}
case 0x32: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x02;
op_writedp(dp, rd);
break;
}
case 0x42: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x04;
op_writedp(dp, rd);
break;
}
case 0x52: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x04;
op_writedp(dp, rd);
break;
}
case 0x62: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x08;
op_writedp(dp, rd);
break;
}
case 0x72: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x08;
op_writedp(dp, rd);
break;
}
case 0x82: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x10;
op_writedp(dp, rd);
break;
}
case 0x92: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x10;
op_writedp(dp, rd);
break;
}
case 0xa2: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x20;
op_writedp(dp, rd);
break;
}
case 0xb2: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x20;
op_writedp(dp, rd);
break;
}
case 0xc2: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x40;
op_writedp(dp, rd);
break;
}
case 0xd2: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x40;
op_writedp(dp, rd);
break;
}
case 0xe2: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= 0x80;
op_writedp(dp, rd);
break;
}
case 0xf2: {
dp = op_readpc();
rd = op_readdp(dp);
rd &= ~0x80;
op_writedp(dp, rd);
break;
}
case 0x2d: {
op_io(2);
op_writestack(regs.a);
break;
}
case 0x4d: {
op_io(2);
op_writestack(regs.x);
break;
}
case 0x6d: {
op_io(2);
op_writestack(regs.y);
break;
}
case 0x0d: {
op_io(2);
op_writestack(regs.p);
break;
}
case 0xae: {
op_io(2);
regs.a = op_readstack();
break;
}
case 0xce: {
op_io(2);
regs.x = op_readstack();
break;
}
case 0xee: {
op_io(2);
regs.y = op_readstack();
break;
}
case 0x8e: {
op_io(2);
regs.p = op_readstack();
break;
}
case 0xcf: {
op_io(8);
ya = regs.y * regs.a;
regs.a = ya;
regs.y = ya >> 8;
//result is set based on y (high-byte) only
regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0);
break;
}
case 0x9e: {
op_io(11);
ya = regs.ya;
//overflow set if quotient >= 256
regs.p.v = !!(regs.y >= regs.x);
regs.p.h = !!((regs.y & 15) >= (regs.x & 15));
if(regs.y < (regs.x << 1)) {
//if quotient is <= 511 (will fit into 9-bit result)
regs.a = ya / regs.x;
regs.y = ya % regs.x;
} else {
//otherwise, the quotient won't fit into regs.p.v + regs.a
//this emulates the odd behavior of the S-SMP in this case
regs.a = 255 - (ya - (regs.x << 9)) / (256 - regs.x);
regs.y = regs.x + (ya - (regs.x << 9)) % (256 - regs.x);
}
//result is set based on a (quotient) only
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}

View File

@ -0,0 +1,705 @@
case 0x7d: {
op_io();
regs.a = regs.x;
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}
case 0xdd: {
op_io();
regs.a = regs.y;
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}
case 0x5d: {
op_io();
regs.x = regs.a;
regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0);
break;
}
case 0xfd: {
op_io();
regs.y = regs.a;
regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0);
break;
}
case 0x9d: {
op_io();
regs.x = regs.sp;
regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0);
break;
}
case 0xbd: {
op_io();
regs.sp = regs.x;
break;
}
case 0xe8: {
regs.a = op_readpc();
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
break;
}
case 0xcd: {
regs.x = op_readpc();
regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0);
break;
}
case 0x8d: {
regs.y = op_readpc();
regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0);
break;
}
case 0xe6: {
switch(++opcode_cycle) {
case 1:
op_io();
break;
case 2:
regs.a = op_readdp(regs.x);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xbf: {
switch(++opcode_cycle) {
case 1:
op_io();
break;
case 2:
regs.a = op_readdp(regs.x++);
op_io();
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xe4: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
regs.a = op_readdp(sp);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xf8: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
regs.x = op_readdp(sp);
regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xeb: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
regs.y = op_readdp(sp);
regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xf4: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
op_io();
break;
case 2:
regs.a = op_readdp(sp + regs.x);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xf9: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
op_io();
break;
case 2:
regs.x = op_readdp(sp + regs.y);
regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xfb: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
op_io();
break;
case 2:
regs.y = op_readdp(sp + regs.x);
regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xe5: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
sp |= op_readpc() << 8;
break;
case 3:
regs.a = op_readaddr(sp);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xe9: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
sp |= op_readpc() << 8;
break;
case 2:
regs.x = op_readaddr(sp);
regs.p.n = !!(regs.x & 0x80);
regs.p.z = (regs.x == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xec: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
sp |= op_readpc() << 8;
break;
case 2:
regs.y = op_readaddr(sp);
regs.p.n = !!(regs.y & 0x80);
regs.p.z = (regs.y == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xf5: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
sp |= op_readpc() << 8;
op_io();
break;
case 2:
regs.a = op_readaddr(sp + regs.x);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xf6: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
sp |= op_readpc() << 8;
op_io();
break;
case 2:
regs.a = op_readaddr(sp + regs.y);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xe7: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc() + regs.x;
op_io();
break;
case 2:
sp = op_readdp(dp);
break;
case 3:
sp |= op_readdp(dp + 1) << 8;
break;
case 4:
regs.a = op_readaddr(sp);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xf7: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
op_io();
break;
case 2:
sp = op_readdp(dp);
break;
case 3:
sp |= op_readdp(dp + 1) << 8;
break;
case 4:
regs.a = op_readaddr(sp + regs.y);
regs.p.n = !!(regs.a & 0x80);
regs.p.z = (regs.a == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xfa: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
rd = op_readdp(sp);
break;
case 3:
dp = op_readpc();
break;
case 4:
op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break;
}
case 0x8f: {
switch(++opcode_cycle) {
case 1:
rd = op_readpc();
dp = op_readpc();
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, rd);
opcode_cycle = 0;
break;
}
break;
}
case 0xc6: {
switch(++opcode_cycle) {
case 1:
op_io();
break;
case 2:
op_readdp(regs.x);
break;
case 3:
op_writedp(regs.x, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xaf: {
switch(++opcode_cycle) {
case 1:
op_io(2);
case 2:
op_writedp(regs.x++, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xc4: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xd8: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.x);
opcode_cycle = 0;
break;
}
break;
}
case 0xcb: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.y);
opcode_cycle = 0;
break;
}
break;
}
case 0xd4: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
op_io();
dp += regs.x;
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xd9: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
op_io();
dp += regs.y;
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.x);
opcode_cycle = 0;
break;
}
break;
}
case 0xdb: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
op_io();
dp += regs.x;
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.y);
opcode_cycle = 0;
break;
}
break;
}
case 0xc5: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8;
break;
case 3:
op_readaddr(dp);
break;
case 4:
op_writeaddr(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xc9: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8;
break;
case 3:
op_readaddr(dp);
break;
case 4:
op_writeaddr(dp, regs.x);
opcode_cycle = 0;
break;
}
break;
}
case 0xcc: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
dp |= op_readpc() << 8;
break;
case 3:
op_readaddr(dp);
break;
case 4:
op_writeaddr(dp, regs.y);
opcode_cycle = 0;
break;
}
break;
}
case 0xd5: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
dp += regs.x;
break;
case 2:
op_readaddr(dp);
break;
case 3:
op_writeaddr(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xd6: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
dp += regs.y;
break;
case 2:
op_readaddr(dp);
break;
case 3:
op_writeaddr(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xc7: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
op_io();
sp += regs.x;
break;
case 2:
dp = op_readdp(sp);
break;
case 3:
dp |= op_readdp(sp + 1) << 8;
break;
case 4:
op_readaddr(dp);
break;
case 5:
op_writeaddr(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xd7: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
dp = op_readdp(sp);
break;
case 3:
dp |= op_readdp(sp + 1) << 8;
op_io();
dp += regs.y;
break;
case 4:
op_readaddr(dp);
break;
case 5:
op_writeaddr(dp, regs.a);
opcode_cycle = 0;
break;
}
break;
}
case 0xba: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
break;
case 2:
regs.a = op_readdp(sp);
op_io();
break;
case 3:
regs.y = op_readdp(sp + 1);
regs.p.n = !!(regs.ya & 0x8000);
regs.p.z = (regs.ya == 0);
opcode_cycle = 0;
break;
}
break;
}
case 0xda: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
break;
case 2:
op_readdp(dp);
break;
case 3:
op_writedp(dp, regs.a);
break;
case 4:
op_writedp(dp + 1, regs.y);
opcode_cycle = 0;
break;
}
break;
}
case 0xaa: {
switch(++opcode_cycle) {
case 1:
sp = op_readpc();
sp |= op_readpc() << 8;
break;
case 2:
bit = sp >> 13;
sp &= 0x1fff;
rd = op_readaddr(sp);
regs.p.c = !!(rd & (1 << bit));
opcode_cycle = 0;
break;
}
break;
}
case 0xca: {
switch(++opcode_cycle) {
case 1:
dp = op_readpc();
dp |= op_readpc() << 8;
break;
case 2:
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
if(regs.p.c)rd |= (1 << bit);
else rd &= ~(1 << bit);
op_io();
break;
case 3:
op_writeaddr(dp, rd);
opcode_cycle = 0;
break;
}
break;
}

View File

@ -0,0 +1,536 @@
case 0x2f: {
rd = op_readpc();
if(0){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xf0: {
rd = op_readpc();
if(!regs.p.z){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xd0: {
rd = op_readpc();
if(regs.p.z){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xb0: {
rd = op_readpc();
if(!regs.p.c){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x90: {
rd = op_readpc();
if(regs.p.c){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x70: {
rd = op_readpc();
if(!regs.p.v){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x50: {
rd = op_readpc();
if(regs.p.v){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x30: {
rd = op_readpc();
if(!regs.p.n){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x10: {
rd = op_readpc();
if(regs.p.n){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x03: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x01) != 0x01){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x13: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x01) == 0x01){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x23: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x02) != 0x02){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x33: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x02) == 0x02){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x43: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x04) != 0x04){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x53: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x04) == 0x04){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x63: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x08) != 0x08){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x73: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x08) == 0x08){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x83: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x10) != 0x10){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x93: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x10) == 0x10){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xa3: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x20) != 0x20){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xb3: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x20) == 0x20){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xc3: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x40) != 0x40){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xd3: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x40) == 0x40){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xe3: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x80) != 0x80){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xf3: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if((sp & 0x80) == 0x80){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x2e: {
dp = op_readpc();
sp = op_readdp(dp);
rd = op_readpc();
op_io();
if(regs.a == sp){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xde: {
dp = op_readpc();
op_io();
sp = op_readdp(dp + regs.x);
rd = op_readpc();
op_io();
if(regs.a == sp){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x6e: {
dp = op_readpc();
wr = op_readdp(dp);
op_writedp(dp, --wr);
rd = op_readpc();
if(wr == 0x00){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0xfe: {
rd = op_readpc();
op_io();
regs.y--;
op_io();
if(regs.y == 0x00){ break; }
op_io(2);
regs.pc += (int8)rd;
break;
}
case 0x5f: {
rd = op_readpc();
rd |= op_readpc() << 8;
regs.pc = rd;
break;
}
case 0x1f: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
dp += regs.x;
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
regs.pc = rd;
break;
}
case 0x3f: {
rd = op_readpc();
rd |= op_readpc() << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x4f: {
rd = op_readpc();
op_io(2);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = 0xff00 | rd;
break;
}
case 0x01: {
dp = 0xffde - (0 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x11: {
dp = 0xffde - (1 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x21: {
dp = 0xffde - (2 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x31: {
dp = 0xffde - (3 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x41: {
dp = 0xffde - (4 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x51: {
dp = 0xffde - (5 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x61: {
dp = 0xffde - (6 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x71: {
dp = 0xffde - (7 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x81: {
dp = 0xffde - (8 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x91: {
dp = 0xffde - (9 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0xa1: {
dp = 0xffde - (10 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0xb1: {
dp = 0xffde - (11 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0xc1: {
dp = 0xffde - (12 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0xd1: {
dp = 0xffde - (13 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0xe1: {
dp = 0xffde - (14 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0xf1: {
dp = 0xffde - (15 << 1);
rd = op_readaddr(dp);
rd |= op_readaddr(dp + 1) << 8;
op_io(3);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
regs.pc = rd;
break;
}
case 0x0f: {
rd = op_readaddr(0xffde);
rd |= op_readaddr(0xffdf) << 8;
op_io(2);
op_writestack(regs.pc >> 8);
op_writestack(regs.pc);
op_writestack(regs.p);
regs.pc = rd;
regs.p.b = 1;
regs.p.i = 0;
break;
}
case 0x6f: {
rd = op_readstack();
rd |= op_readstack() << 8;
op_io(2);
regs.pc = rd;
break;
}
case 0x7f: {
regs.p = op_readstack();
rd = op_readstack();
rd |= op_readstack() << 8;
op_io(2);
regs.pc = rd;
break;
}

View File

@ -0,0 +1,744 @@
case 0x88: {
rd = op_readpc();
regs.a = op_adc(regs.a, rd);
break;
}
case 0x28: {
rd = op_readpc();
regs.a = op_and(regs.a, rd);
break;
}
case 0x68: {
rd = op_readpc();
regs.a = op_cmp(regs.a, rd);
break;
}
case 0xc8: {
rd = op_readpc();
regs.x = op_cmp(regs.x, rd);
break;
}
case 0xad: {
rd = op_readpc();
regs.y = op_cmp(regs.y, rd);
break;
}
case 0x48: {
rd = op_readpc();
regs.a = op_eor(regs.a, rd);
break;
}
case 0x08: {
rd = op_readpc();
regs.a = op_or(regs.a, rd);
break;
}
case 0xa8: {
rd = op_readpc();
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x86: {
op_io();
rd = op_readdp(regs.x);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x26: {
op_io();
rd = op_readdp(regs.x);
regs.a = op_and(regs.a, rd);
break;
}
case 0x66: {
op_io();
rd = op_readdp(regs.x);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x46: {
op_io();
rd = op_readdp(regs.x);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x06: {
op_io();
rd = op_readdp(regs.x);
regs.a = op_or(regs.a, rd);
break;
}
case 0xa6: {
op_io();
rd = op_readdp(regs.x);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x84: {
dp = op_readpc();
rd = op_readdp(dp);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x24: {
dp = op_readpc();
rd = op_readdp(dp);
regs.a = op_and(regs.a, rd);
break;
}
case 0x64: {
dp = op_readpc();
rd = op_readdp(dp);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x3e: {
dp = op_readpc();
rd = op_readdp(dp);
regs.x = op_cmp(regs.x, rd);
break;
}
case 0x7e: {
dp = op_readpc();
rd = op_readdp(dp);
regs.y = op_cmp(regs.y, rd);
break;
}
case 0x44: {
dp = op_readpc();
rd = op_readdp(dp);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x04: {
dp = op_readpc();
rd = op_readdp(dp);
regs.a = op_or(regs.a, rd);
break;
}
case 0xa4: {
dp = op_readpc();
rd = op_readdp(dp);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x94: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x34: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
regs.a = op_and(regs.a, rd);
break;
}
case 0x74: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x54: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x14: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
regs.a = op_or(regs.a, rd);
break;
}
case 0xb4: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x85: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x25: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.a = op_and(regs.a, rd);
break;
}
case 0x65: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x1e: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.x = op_cmp(regs.x, rd);
break;
}
case 0x5e: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.y = op_cmp(regs.y, rd);
break;
}
case 0x45: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x05: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.a = op_or(regs.a, rd);
break;
}
case 0xa5: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x95: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.x);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x96: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.y);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x35: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.x);
regs.a = op_and(regs.a, rd);
break;
}
case 0x36: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.y);
regs.a = op_and(regs.a, rd);
break;
}
case 0x75: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.x);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x76: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.y);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x55: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.x);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x56: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.y);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x15: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.x);
regs.a = op_or(regs.a, rd);
break;
}
case 0x16: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.y);
regs.a = op_or(regs.a, rd);
break;
}
case 0xb5: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.x);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0xb6: {
dp = op_readpc();
dp |= op_readpc() << 8;
op_io();
rd = op_readaddr(dp + regs.y);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x87: {
dp = op_readpc() + regs.x;
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x27: {
dp = op_readpc() + regs.x;
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp);
regs.a = op_and(regs.a, rd);
break;
}
case 0x67: {
dp = op_readpc() + regs.x;
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x47: {
dp = op_readpc() + regs.x;
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x07: {
dp = op_readpc() + regs.x;
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp);
regs.a = op_or(regs.a, rd);
break;
}
case 0xa7: {
dp = op_readpc() + regs.x;
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x97: {
dp = op_readpc();
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp + regs.y);
regs.a = op_adc(regs.a, rd);
break;
}
case 0x37: {
dp = op_readpc();
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp + regs.y);
regs.a = op_and(regs.a, rd);
break;
}
case 0x77: {
dp = op_readpc();
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp + regs.y);
regs.a = op_cmp(regs.a, rd);
break;
}
case 0x57: {
dp = op_readpc();
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp + regs.y);
regs.a = op_eor(regs.a, rd);
break;
}
case 0x17: {
dp = op_readpc();
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp + regs.y);
regs.a = op_or(regs.a, rd);
break;
}
case 0xb7: {
dp = op_readpc();
op_io();
sp = op_readdp(dp);
sp |= op_readdp(dp + 1) << 8;
rd = op_readaddr(sp + regs.y);
regs.a = op_sbc(regs.a, rd);
break;
}
case 0x99: {
op_io();
rd = op_readdp(regs.y);
wr = op_readdp(regs.x);
wr = op_adc(wr, rd);
(1) ? op_writedp(regs.x, wr) : op_io();
break;
}
case 0x39: {
op_io();
rd = op_readdp(regs.y);
wr = op_readdp(regs.x);
wr = op_and(wr, rd);
(1) ? op_writedp(regs.x, wr) : op_io();
break;
}
case 0x79: {
op_io();
rd = op_readdp(regs.y);
wr = op_readdp(regs.x);
wr = op_cmp(wr, rd);
(0) ? op_writedp(regs.x, wr) : op_io();
break;
}
case 0x59: {
op_io();
rd = op_readdp(regs.y);
wr = op_readdp(regs.x);
wr = op_eor(wr, rd);
(1) ? op_writedp(regs.x, wr) : op_io();
break;
}
case 0x19: {
op_io();
rd = op_readdp(regs.y);
wr = op_readdp(regs.x);
wr = op_or(wr, rd);
(1) ? op_writedp(regs.x, wr) : op_io();
break;
}
case 0xb9: {
op_io();
rd = op_readdp(regs.y);
wr = op_readdp(regs.x);
wr = op_sbc(wr, rd);
(1) ? op_writedp(regs.x, wr) : op_io();
break;
}
case 0x89: {
sp = op_readpc();
rd = op_readdp(sp);
dp = op_readpc();
wr = op_readdp(dp);
wr = op_adc(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x29: {
sp = op_readpc();
rd = op_readdp(sp);
dp = op_readpc();
wr = op_readdp(dp);
wr = op_and(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x69: {
sp = op_readpc();
rd = op_readdp(sp);
dp = op_readpc();
wr = op_readdp(dp);
wr = op_cmp(wr, rd);
(0) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x49: {
sp = op_readpc();
rd = op_readdp(sp);
dp = op_readpc();
wr = op_readdp(dp);
wr = op_eor(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x09: {
sp = op_readpc();
rd = op_readdp(sp);
dp = op_readpc();
wr = op_readdp(dp);
wr = op_or(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0xa9: {
sp = op_readpc();
rd = op_readdp(sp);
dp = op_readpc();
wr = op_readdp(dp);
wr = op_sbc(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x98: {
rd = op_readpc();
dp = op_readpc();
wr = op_readdp(dp);
wr = op_adc(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x38: {
rd = op_readpc();
dp = op_readpc();
wr = op_readdp(dp);
wr = op_and(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x78: {
rd = op_readpc();
dp = op_readpc();
wr = op_readdp(dp);
wr = op_cmp(wr, rd);
(0) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x58: {
rd = op_readpc();
dp = op_readpc();
wr = op_readdp(dp);
wr = op_eor(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x18: {
rd = op_readpc();
dp = op_readpc();
wr = op_readdp(dp);
wr = op_or(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0xb8: {
rd = op_readpc();
dp = op_readpc();
wr = op_readdp(dp);
wr = op_sbc(wr, rd);
(1) ? op_writedp(dp, wr) : op_io();
break;
}
case 0x7a: {
dp = op_readpc();
rd = op_readdp(dp);
op_io();
rd |= op_readdp(dp + 1) << 8;
regs.ya = op_addw(regs.ya, rd);
break;
}
case 0x9a: {
dp = op_readpc();
rd = op_readdp(dp);
op_io();
rd |= op_readdp(dp + 1) << 8;
regs.ya = op_subw(regs.ya, rd);
break;
}
case 0x5a: {
dp = op_readpc();
rd = op_readdp(dp);
rd |= op_readdp(dp + 1) << 8;
op_cmpw(regs.ya, rd);
break;
}
case 0x4a: {
dp = op_readpc();
dp |= op_readpc() << 8;
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
regs.p.c = regs.p.c & !!(rd & (1 << bit));
break;
}
case 0x6a: {
dp = op_readpc();
dp |= op_readpc() << 8;
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
regs.p.c = regs.p.c & !(rd & (1 << bit));
break;
}
case 0x8a: {
dp = op_readpc();
dp |= op_readpc() << 8;
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
op_io();
regs.p.c = regs.p.c ^ !!(rd & (1 << bit));
break;
}
case 0xea: {
dp = op_readpc();
dp |= op_readpc() << 8;
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
rd ^= (1 << bit);
op_writeaddr(dp, rd);
break;
}
case 0x0a: {
dp = op_readpc();
dp |= op_readpc() << 8;
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
op_io();
regs.p.c = regs.p.c | !!(rd & (1 << bit));
break;
}
case 0x2a: {
dp = op_readpc();
dp |= op_readpc() << 8;
bit = dp >> 13;
dp &= 0x1fff;
rd = op_readaddr(dp);
op_io();
regs.p.c = regs.p.c | !(rd & (1 << bit));
break;
}

View File

@ -0,0 +1,262 @@
case 0xbc: {
op_io();
regs.a = op_inc(regs.a);
break;
}
case 0x3d: {
op_io();
regs.x = op_inc(regs.x);
break;
}
case 0xfc: {
op_io();
regs.y = op_inc(regs.y);
break;
}
case 0x9c: {
op_io();
regs.a = op_dec(regs.a);
break;
}
case 0x1d: {
op_io();
regs.x = op_dec(regs.x);
break;
}
case 0xdc: {
op_io();
regs.y = op_dec(regs.y);
break;
}
case 0x1c: {
op_io();
regs.a = op_asl(regs.a);
break;
}
case 0x5c: {
op_io();
regs.a = op_lsr(regs.a);
break;
}
case 0x3c: {
op_io();
regs.a = op_rol(regs.a);
break;
}
case 0x7c: {
op_io();
regs.a = op_ror(regs.a);
break;
}
case 0xab: {
dp = op_readpc();
rd = op_readdp(dp);
rd = op_inc(rd);
op_writedp(dp, rd);
break;
}
case 0x8b: {
dp = op_readpc();
rd = op_readdp(dp);
rd = op_dec(rd);
op_writedp(dp, rd);
break;
}
case 0x0b: {
dp = op_readpc();
rd = op_readdp(dp);
rd = op_asl(rd);
op_writedp(dp, rd);
break;
}
case 0x4b: {
dp = op_readpc();
rd = op_readdp(dp);
rd = op_lsr(rd);
op_writedp(dp, rd);
break;
}
case 0x2b: {
dp = op_readpc();
rd = op_readdp(dp);
rd = op_rol(rd);
op_writedp(dp, rd);
break;
}
case 0x6b: {
dp = op_readpc();
rd = op_readdp(dp);
rd = op_ror(rd);
op_writedp(dp, rd);
break;
}
case 0xbb: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
rd = op_inc(rd);
op_writedp(dp + regs.x, rd);
break;
}
case 0x9b: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
rd = op_dec(rd);
op_writedp(dp + regs.x, rd);
break;
}
case 0x1b: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
rd = op_asl(rd);
op_writedp(dp + regs.x, rd);
break;
}
case 0x5b: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
rd = op_lsr(rd);
op_writedp(dp + regs.x, rd);
break;
}
case 0x3b: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
rd = op_rol(rd);
op_writedp(dp + regs.x, rd);
break;
}
case 0x7b: {
dp = op_readpc();
op_io();
rd = op_readdp(dp + regs.x);
rd = op_ror(rd);
op_writedp(dp + regs.x, rd);
break;
}
case 0xac: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
rd = op_inc(rd);
op_writeaddr(dp, rd);
break;
}
case 0x8c: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
rd = op_dec(rd);
op_writeaddr(dp, rd);
break;
}
case 0x0c: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
rd = op_asl(rd);
op_writeaddr(dp, rd);
break;
}
case 0x4c: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
rd = op_lsr(rd);
op_writeaddr(dp, rd);
break;
}
case 0x2c: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
rd = op_rol(rd);
op_writeaddr(dp, rd);
break;
}
case 0x6c: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
rd = op_ror(rd);
op_writeaddr(dp, rd);
break;
}
case 0x0e: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.p.n = !!((regs.a - rd) & 0x80);
regs.p.z = ((regs.a - rd) == 0);
op_readaddr(dp);
op_writeaddr(dp, rd | regs.a);
break;
}
case 0x4e: {
dp = op_readpc();
dp |= op_readpc() << 8;
rd = op_readaddr(dp);
regs.p.n = !!((regs.a - rd) & 0x80);
regs.p.z = ((regs.a - rd) == 0);
op_readaddr(dp);
op_writeaddr(dp, rd &~ regs.a);
break;
}
case 0x3a: {
dp = op_readpc();
rd = op_readdp(dp);
rd++;
op_writedp(dp++, rd);
rd += op_readdp(dp) << 8;
op_writedp(dp, rd >> 8);
regs.p.n = !!(rd & 0x8000);
regs.p.z = (rd == 0);
break;
}
case 0x1a: {
dp = op_readpc();
rd = op_readdp(dp);
rd--;
op_writedp(dp++, rd);
rd += op_readdp(dp) << 8;
op_writedp(dp, rd >> 8);
regs.p.n = !!(rd & 0x8000);
regs.p.z = (rd == 0);
break;
}

View File

@ -1,4 +1,5 @@
#define CYCLE_ACCURATE #define CYCLE_ACCURATE
#define PSEUDO_CYCLE
#include <snes/snes.hpp> #include <snes/snes.hpp>