From 813dc2caed0366a2cb1abeae8d9131760682982c Mon Sep 17 00:00:00 2001 From: astoria-d Date: Fri, 15 Mar 2013 17:40:03 +0900 Subject: [PATCH] flag set instruction clc, cld, clv, sec, sed supported. --- emulator/6502core.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/emulator/6502core.c b/emulator/6502core.c index 9acb913..67f456e 100644 --- a/emulator/6502core.c +++ b/emulator/6502core.c @@ -788,20 +788,40 @@ int func_BVS(void) { return branch(cpu_reg.status.overflow == 1); } +/* + * Clear Carry Flag: CLC + * 0 -> C + * Flags: C = 0 + * */ int func_CLC(void) { - return FALSE; + cpu_reg.status.carry = 0; + return TRUE; } +/* + * Clear Decimal Mode: CLD + * 0 -> D + * Flags: D = 0 + * + * NOTE: Decimal mode is not implemented on NES core. + * */ int func_CLD(void) { - return FALSE; + cpu_reg.status.decimal = 0; + return TRUE; } int func_CLI(void) { return FALSE; } +/* + * Clear Overflow Flag: CLV + * 0 -> V + * Flags: V = 0 + * */ int func_CLV(void) { - return FALSE; + cpu_reg.status.overflow = 0; + return TRUE; } int func_CMP(void) { @@ -1159,11 +1179,26 @@ int func_SBC(void) { return FALSE; } +/* + * Set Carry Flag: SEC + * 1 -> C + * Flags: C = 1 + * */ int func_SEC(void) { - return FALSE; + cpu_reg.status.carry = 1; + return TRUE; } +/* + * Set Decimal Mode: SED + * 1 -> D + * Flags: D = 1 + * + * NOTE: decimal mode is not supported on NES core + * */ int func_SED(void) { + cpu_reg.status.decimal = 1; + fprintf(stderr, "decimal mode is not supported!!!\n"); return FALSE; } -- 2.11.0