From 04662745b00e8d400665ae9040926ad45bdb437f Mon Sep 17 00:00:00 2001 From: edmccard Date: Fri, 30 Mar 2012 15:10:01 -0400 Subject: [PATCH] cumulative mode bugs --- src/d6502/cmos.d | 1 + src/d6502/cpu.d | 11 ++++++----- src/d6502/nmosundoc.d | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/d6502/cmos.d b/src/d6502/cmos.d index 03aeb58..b6cd16a 100644 --- a/src/d6502/cmos.d +++ b/src/d6502/cmos.d @@ -231,6 +231,7 @@ class Cmos(bool strict, bool cumulative) : Cpu!(strict, cumulative) peek(0xFFFF); peek(0xFFFF); peek(0xFFFF); + static if (cumulative) tick(totalCycles); } /* JMP ($$$$) */ diff --git a/src/d6502/cpu.d b/src/d6502/cpu.d index e16d3db..48cc54b 100644 --- a/src/d6502/cpu.d +++ b/src/d6502/cpu.d @@ -69,10 +69,10 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) { if (signalActive) handleSignals(); - opcodePC = programCounter; - opcode = read(programCounter++); static if (cumulative) totalCycles = 0; else finalCycle = false; + opcodePC = programCounter; + opcode = read(programCounter++); /+ TODO: call sync delegate +/ @@ -241,6 +241,7 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) /+ TODO: call stack overflow delegate +/ } + final void pushWord(ushort val) { push(val >> 8); @@ -471,8 +472,8 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) static string SimpleOpcode(string name, string opcode, string action) { string code = "peek(programCounter);\n"; - static if (cumulative) code ~= "tick(totalCycles);\n"; code ~= (action == "") ? "" : (action ~ ";"); + static if (cumulative) code ~= "tick(totalCycles);\n"; return "override void opcode" ~ opcode ~ "()\n{\n" ~ code ~ "\n}\n"; } @@ -484,9 +485,9 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) static string RegisterOpcode(string name, string opcode, string action) { string code = "peek(programCounter);\n"; + code ~= UpdateNZ(action); static if (cumulative) code ~= "tick(totalCycles);\n"; - return "override void opcode" ~ opcode ~ "()\n{\n" ~ - code ~ UpdateNZ(action) ~ "}\n"; + return "override void opcode" ~ opcode ~ "()\n{\n" ~ code ~ "}\n"; } static string BranchOpcode(string name, string opcode, string action) diff --git a/src/d6502/nmosundoc.d b/src/d6502/nmosundoc.d index 3284cb9..3cff407 100644 --- a/src/d6502/nmosundoc.d +++ b/src/d6502/nmosundoc.d @@ -68,6 +68,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) { string type = (rw == "Write") ? "true" : "false"; string modes = "[[\"" ~ name ~ "\", \"" ~ rw ~ "\"], \n"; + string index = (name[2] == 'X') ? "Y" : "X"; for (int op = 0; op < opcodes.length; ++op) { int opcode = opcodes[op]; @@ -87,7 +88,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) modes ~= "IndirectY("~ type ~ ")"; break; case 5: - modes ~= "ZeropageX()"; + modes ~= "Zeropage" ~ index ~ "()"; break; case 7: modes ~= "AbsoluteY(" ~ type ~ ")"; @@ -183,7 +184,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) "LAX", "Read", [0xA3, 0xA7, 0xAF, 0xB3, 0xB7, 0xBF])), Read("accumulator = xIndex ="))); mixin(Opcode(mixin(UndocAddress( - "SAX", "Write", [0x83, 0x87, 0x8F, 0x97])), + "SAX", "Write", [0x83, 0x87, 0x97, 0x8F])), Write("accumulator & xIndex"))); mixin(Opcode(mixin(Type1Address(