summaryrefslogtreecommitdiff
path: root/cpu.c
diff options
context:
space:
mode:
authorvin <git@vineetk.net>2024-06-10 12:50:00 +0530
committervin <git@vineetk.net>2024-06-10 14:28:07 +0530
commite07d5917a1625e207d1ba96b7e0d1e1c493040b2 (patch)
tree049c23a5bccd4849b67ec88c779de1840f544acc /cpu.c
parent23008662cea16d4ad2a3253d883a634258378d60 (diff)
implement se?() opcodes and remove extra 65c02 opcodes
Diffstat (limited to 'cpu.c')
-rw-r--r--cpu.c420
1 files changed, 3 insertions, 417 deletions
diff --git a/cpu.c b/cpu.c
index 8c88959..c0e3877 100644
--- a/cpu.c
+++ b/cpu.c
@@ -207,18 +207,6 @@ asl(uint8_t arg)
}
static void
-bbr(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
-bbs(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
bcc(uint8_t arg)
{
if (regs.status.carry == 0)
@@ -269,12 +257,6 @@ bpl(uint8_t arg)
}
static void
-bra(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
brk(void)
{
/* TODO: push regs.pc and regs.status to stack and load IRQ vector */
@@ -528,12 +510,6 @@ ply(uint8_t arg)
}
static void
-rmb(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
rol(uint8_t arg)
{
/* TODO: complete this */
@@ -567,25 +543,19 @@ sbc(uint8_t arg)
static void
sec(uint8_t arg)
{
-/* TODO: complete this */
+ regs.status.carry = 1;
}
static void
sed(uint8_t arg)
{
-/* TODO: complete this */
+ regs.status.decimal_mode = 1;
}
static void
sei(uint8_t arg)
{
-/* TODO: complete this */
-}
-
-static void
-smb(uint8_t arg)
-{
-/* TODO: complete this */
+ regs.status.interrupt_disable = 1;
}
static void
@@ -595,12 +565,6 @@ sta(uint8_t arg)
}
static void
-stp(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
stx(uint8_t arg)
{
/* TODO: complete this */
@@ -613,12 +577,6 @@ sty(uint8_t arg)
}
static void
-stz(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
tax(void)
{
regs.x = regs.a;
@@ -634,18 +592,6 @@ tay(uint8_t arg)
}
static void
-trb(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
-tsb(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
tsx(uint8_t arg)
{
/* TODO: complete this */
@@ -670,18 +616,6 @@ tya(uint8_t arg)
}
static void
-wai(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
-unp(uint8_t arg)
-{
-/* TODO: complete this */
-}
-
-static void
interpret(void)
{
uint8_t opcode;
@@ -784,70 +718,6 @@ interpret(void)
asl(opcode_arg(AM_ABS_X));
cycles += 6;
break;
- case 0x0f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x1f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x2f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x3f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x4f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x5f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x6f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x7f:
- bbr(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x8f:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0x9f:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0xaf:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0xbf:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0xcf:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0xdf:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0xef:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
- case 0xff:
- bbs(opcode_arg(AM_REL));
- cycles += 4;
- break;
case 0x90:
bcc(opcode_arg(AM_IMM));
cycles += 2;
@@ -892,10 +762,6 @@ interpret(void)
bpl(opcode_arg(AM_IMM));
cycles += 2;
break;
- case 0x80:
- bra(opcode_arg(AM_IMM));
- cycles += 3;
- break;
case 0x00:
brk();
cycles += 7;
@@ -1256,38 +1122,6 @@ interpret(void)
ply(opcode_arg(AM_ACC));
cycles += 4;
break;
- case 0x07:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x17:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x27:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x37:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x47:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x57:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x67:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x77:
- rmb(opcode_arg(AM_REL));
- cycles += 5;
- break;
case 0x2a:
rol(opcode_arg(AM_ACC));
cycles += 2;
@@ -1384,38 +1218,6 @@ interpret(void)
sei(opcode_arg(AM_ACC));
cycles += 2;
break;
- case 0x87:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0x97:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0xa7:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0xb7:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0xc7:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0xd7:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0xe7:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
- case 0xf7:
- smb(opcode_arg(AM_REL));
- cycles += 5;
- break;
case 0x85:
sta(opcode_arg(AM_ZP));
cycles += 4;
@@ -1448,10 +1250,6 @@ interpret(void)
sta(opcode_arg(AM_IND_Y));
cycles += 7;
break;
- case 0xdb:
- stp(opcode_arg(AM_ACC));
- cycles += 2;
- break;
case 0x86:
stx(opcode_arg(AM_ZP));
cycles += 4;
@@ -1476,22 +1274,6 @@ interpret(void)
sty(opcode_arg(AM_ABS));
cycles += 5;
break;
- case 0x64:
- stz(opcode_arg(AM_ZP));
- cycles += 4;
- break;
- case 0x74:
- stz(opcode_arg(AM_ZP_X));
- cycles += 5;
- break;
- case 0x9c:
- stz(opcode_arg(AM_ABS));
- cycles += 5;
- break;
- case 0x9e:
- stz(opcode_arg(AM_ABS_X));
- cycles += 6;
- break;
case 0xaa:
tax();
cycles += 2;
@@ -1500,22 +1282,6 @@ interpret(void)
tay(opcode_arg(AM_ACC));
cycles += 2;
break;
- case 0x14:
- trb(opcode_arg(AM_ZP));
- cycles += 5;
- break;
- case 0x1c:
- trb(opcode_arg(AM_ABS));
- cycles += 6;
- break;
- case 0x04:
- tsb(opcode_arg(AM_ZP));
- cycles += 5;
- break;
- case 0x0c:
- tsb(opcode_arg(AM_ABS));
- cycles += 6;
- break;
case 0xba:
tsx(opcode_arg(AM_ACC));
cycles += 2;
@@ -1532,186 +1298,6 @@ interpret(void)
tya(opcode_arg(AM_ACC));
cycles += 2;
break;
- case 0xcb:
- wai(opcode_arg(AM_ACC));
- cycles += 5;
- break;
- case 0x03:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x0b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x13:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x1b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x23:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x2b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x33:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x3b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x43:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x4b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x53:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x5b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x63:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x6b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x73:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x7b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x83:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x8b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x93:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x9b:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xa3:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xab:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xb3:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xbb:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xc3:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xd3:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xe3:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xeb:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xf3:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0xfb:
- unp(opcode_arg(AM_ACC));
- cycles += 1;
- break;
- case 0x02:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0x22:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0x42:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0x62:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0x82:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0xc2:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0xe2:
- unp(opcode_arg(AM_IMM));
- cycles += 2;
- break;
- case 0x44:
- unp(opcode_arg(AM_ZP));
- cycles += 3;
- break;
- case 0x54:
- unp(opcode_arg(AM_ZP_X));
- cycles += 4;
- break;
- case 0xd4:
- unp(opcode_arg(AM_ZP_X));
- cycles += 4;
- break;
- case 0xf4:
- unp(opcode_arg(AM_ZP_X));
- cycles += 4;
- break;
- case 0x5c:
- unp(opcode_arg(AM_ABS));
- cycles += 8;
- break;
- case 0xdc:
- unp(opcode_arg(AM_ABS_X));
- cycles += 4;
- break;
- case 0xfc:
- unp(opcode_arg(AM_ABS_X));
- cycles += 4;
- break;
default:
printf("opcode $%02X not implemented\n", opcode);
break;