diff --git a/src/d6502/base.d b/src/d6502/base.d index 389f892..e33dce2 100644 --- a/src/d6502/base.d +++ b/src/d6502/base.d @@ -146,7 +146,6 @@ class CpuBase(bool strict, bool cumulative) abstract void run(bool continuous); abstract void stop(); - static if (!cumulative) abstract bool checkFinalCycle(); abstract void resetLow(); abstract void nmiLow(bool signalLow); abstract void irqLow(bool signalLow); diff --git a/src/d6502/cmos.d b/src/d6502/cmos.d index f736676..f277ac0 100644 --- a/src/d6502/cmos.d +++ b/src/d6502/cmos.d @@ -104,20 +104,20 @@ class Cmos(bool strict, bool cumulative) : Cpu!(strict, cumulative) static string RMW(string action) { return "peek(primaryAddress);\n" ~ - "writeFinal(primaryAddress, (flag.zero_ = flag.negative_ = " ~ + "write(primaryAddress, (flag.zero_ = flag.negative_ = " ~ action ~ "(readVal = read(primaryAddress))));\n"; } static string TestModify(string action) { return "peek(primaryAddress);\n" ~ - "writeFinal(primaryAddress, " ~ + "write(primaryAddress, " ~ action ~ "(readVal = read(primaryAddress)));\n"; } static string ReadNOP() { - return "readVal = readFinal(primaryAddress);\n"; + return "readVal = read(primaryAddress);\n"; } static string ManualAddress(string name, int[] opcodes, @@ -260,7 +260,7 @@ class Cmos(bool strict, bool cumulative) : Cpu!(strict, cumulative) /* BIT #$$ */ void opcode89() { - readVal = operand1 = readFinal(programCounter++); + readVal = operand1 = read(programCounter++); flag.zero_ = accumulator & readVal; } } diff --git a/src/d6502/cpu.d b/src/d6502/cpu.d index 48cc54b..8fc084b 100644 --- a/src/d6502/cpu.d +++ b/src/d6502/cpu.d @@ -51,7 +51,6 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) void delegate()[256] opcodes; bool continueExecution; static if (cumulative) int totalCycles; - else bool finalCycle; debug(disassemble) @@ -70,7 +69,6 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) if (signalActive) handleSignals(); static if (cumulative) totalCycles = 0; - else finalCycle = false; opcodePC = programCounter; opcode = read(programCounter++); @@ -90,14 +88,6 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) continueExecution = false; } - static if (!cumulative) - { - final override bool checkFinalCycle() - { - return finalCycle; - } - } - final override void resetLow() { resetActive = signalActive = true; @@ -206,28 +196,6 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) static if (strict) memoryWrite(addr, val); } - final ubyte readFinal(ushort addr) - { - static if (cumulative) tick(++totalCycles); - else - { - finalCycle = true; - tick(); - } - return memoryRead(addr); - } - - final void writeFinal(ushort addr, ubyte val) - { - static if (cumulative) tick(++totalCycles); - else - { - finalCycle = true; - tick(); - } - memoryWrite(addr, val); - } - final ushort readWord(ushort addrLo, ushort addrHi) { ushort word = read(addrLo); @@ -596,12 +564,12 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) static string Read(string action) { - return UpdateNZ(action ~ " (readVal = readFinal(primaryAddress))"); + return UpdateNZ(action ~ " (readVal = read(primaryAddress))"); } static string Decimal(string action) { - string code = action ~ "(readVal = readFinal(primaryAddress));\n"; + string code = action ~ "(readVal = read(primaryAddress));\n"; return "if (flag.decimal) dec_" ~ code ~ "else hex_" ~ code; } @@ -609,17 +577,17 @@ class Cpu(bool strict, bool cumulative) : CpuBase!(strict, cumulative) static string Compare(string action) { return UpdateNZ("compare(" ~ action ~ - ", (readVal = readFinal(primaryAddress)))"); + ", (readVal = read(primaryAddress)))"); } static string Write(string action) { - return "writeFinal(primaryAddress, " ~ action ~ ");\n"; + return "write(primaryAddress, " ~ action ~ ");\n"; } static string BitTest() { - return "bitTest(readVal = readFinal(primaryAddress));\n"; + return "bitTest(readVal = read(primaryAddress));\n"; } mixin(SimpleOpcode("CLC", "18", "flag.carry = false")); diff --git a/src/d6502/nmosbase.d b/src/d6502/nmosbase.d index 2a2e2b9..21e9cd3 100644 --- a/src/d6502/nmosbase.d +++ b/src/d6502/nmosbase.d @@ -37,7 +37,7 @@ class NmosBase(bool strict, bool cumulative) : Cpu!(strict, cumulative) static string RMW(string action) { return "poke(primaryAddress, (readVal = read(primaryAddress)));\n" ~ - "writeFinal(primaryAddress, flag.zero_ = flag.negative_ = " ~ + "write(primaryAddress, flag.zero_ = flag.negative_ = " ~ action ~ "(readVal));\n"; } diff --git a/src/d6502/nmosundoc.d b/src/d6502/nmosundoc.d index abea573..cc85c4d 100644 --- a/src/d6502/nmosundoc.d +++ b/src/d6502/nmosundoc.d @@ -54,12 +54,12 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) val = val & hiAddr; ushort addr = (badAddress == primaryAddress) ? primaryAddress : ((val << 8) | (primaryAddress & 0xFF)); - writeFinal(addr, val); + write(addr, val); } else { ubyte hiAddr = cast(ubyte)((baseAddress >> 8) + 1); - writeFinal(primaryAddress, val & hiAddr); + write(primaryAddress, val & hiAddr); } } @@ -122,13 +122,13 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) static string ReadNOP() { - return "readVal = readFinal(primaryAddress);\n"; + return "readVal = read(primaryAddress);\n"; } static string RMW_Read(string action1, string action2) { return "poke(primaryAddress, (readVal = read(primaryAddress)));\n" ~ - "writeFinal(primaryAddress, flag.zero_ = flag.negative_ = " ~ + "write(primaryAddress, flag.zero_ = flag.negative_ = " ~ "(writeVal = " ~ action1 ~ "(readVal)));\n" ~ action2 ~ " writeVal;\n"; } @@ -136,7 +136,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) static string RMW_Compare(string action1, string action2) { return "poke(primaryAddress, (readVal = read(primaryAddress)));\n" ~ - "writeFinal(primaryAddress, " ~ + "write(primaryAddress, " ~ "(writeVal = " ~ action1 ~ "(readVal)));\n" ~ "flag.zero_ = flag.negative_ = " ~ "compare(" ~ action2 ~ ", writeVal);\n"; @@ -145,7 +145,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) static string RMW_Decimal(string action1, string action2) { return "poke(primaryAddress, (readVal = read(primaryAddress)));\n" ~ - "writeFinal(primaryAddress, flag.zero_ = flag.negative_ = " ~ + "write(primaryAddress, flag.zero_ = flag.negative_ = " ~ "(writeVal = " ~ action1 ~ "(readVal)));\n" ~ "if (flag.decimal) dec_" ~ action2 ~ "(writeVal);\n" ~ "else hex_" ~ action2 ~ "(writeVal);\n"; @@ -209,7 +209,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* ANC #$$ */ override void opcode0B() { - readVal = operand1 = readFinal(programCounter); + readVal = operand1 = read(programCounter); flag.zero_ = flag.negative_ = (accumulator = readVal); flag.carry = (flag.negative_ > 0x7F); } @@ -217,7 +217,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* ANC #$$ */ override void opcode2B() { - readVal = operand1 = readFinal(programCounter); + readVal = operand1 = read(programCounter); flag.zero_ = flag.negative_ = (accumulator = readVal); flag.carry = (flag.negative_ > 0x7F); } @@ -225,7 +225,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* ALR #$$ */ override void opcode4B() { - readVal = operand1 = readFinal(programCounter); + readVal = operand1 = read(programCounter); flag.zero_ = flag.negative_ = (accumulator = shiftRight(accumulator & readVal)); } @@ -233,7 +233,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* ARR #$$ */ override void opcode6B() { - readVal = operand1 = readFinal(programCounter); + readVal = operand1 = read(programCounter); ubyte val = readVal & accumulator; if (flag.decimal) { ubyte temp = cast(ubyte)((val >> 1) + (flag.carry ? 0x80 : 0)); @@ -263,7 +263,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) override void opcode8B() { // unstable - readVal = operand1 = readFinal(programCounter++); + readVal = operand1 = read(programCounter++); version(Atari8Bit) { @@ -316,7 +316,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* LAX #$$ */ override void opcodeAB() { - readVal = operand1 = readFinal(programCounter); + readVal = operand1 = read(programCounter); version(Commodore128) { @@ -341,7 +341,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) override void opcodeBB() { addrAbsoluteY(false); - readVal = readFinal(primaryAddress); + readVal = read(primaryAddress); flag.zero_ = flag.negative_ = (xIndex = accumulator = (stackPointer & readVal)); @@ -350,7 +350,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* SBX #$$ */ override void opcodeCB() { - readVal = operand1 = readFinal(programCounter++); + readVal = operand1 = read(programCounter++); xIndex &= accumulator; flag.zero_ = flag.negative_ = compare(xIndex, readVal); } @@ -358,7 +358,7 @@ class NmosUndoc(bool strict, bool cumulative) : NmosBase!(strict, cumulative) /* SBC #$$ */ override void opcodeEB() { - readVal = operand1 = readFinal(programCounter++); + readVal = operand1 = read(programCounter++); if (flag.decimal) dec_subWithCarry(readVal); else hex_subWithCarry(readVal); } diff --git a/src/peripheral/diskii.d b/src/peripheral/diskii.d index b55b3b2..e2d234f 100644 --- a/src/peripheral/diskii.d +++ b/src/peripheral/diskii.d @@ -105,7 +105,6 @@ class Controller : Peripheral int activeDrive; bool writeMode; bool loadRegister; - bool delegate() checkFinalCycle; ubyte dataLatch; bool isOn; StopTimer drivesOffDelay; @@ -201,7 +200,7 @@ class Controller : Peripheral ubyte Q6L() { loadRegister = false; - if (isOn && checkFinalCycle()) + if (isOn) { if (writeMode) { diff --git a/src/system/peripheral.d b/src/system/peripheral.d index 8cd7e34..2291e91 100644 --- a/src/system/peripheral.d +++ b/src/system/peripheral.d @@ -62,7 +62,6 @@ class Peripherals_II : Peripherals void install(CpuBase cpu, AddressDecoder decoder, Rom mainRom) { auto diskController = new Controller(); - diskController.checkFinalCycle = &cpu.checkFinalCycle; cards[6] = diskController; // XXX auto langCard = new LanguageCard(); @@ -82,7 +81,6 @@ class Peripherals_IIe : Peripherals void install(CpuBase cpu, AddressDecoder decoder, Rom mainRom) { auto diskController = new Controller(); - diskController.checkFinalCycle = &cpu.checkFinalCycle; cards[6] = diskController; // XXX } }