diff --git a/README.md b/README.md index b9ec0d2..f700373 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Properties of this simulator: - simulates various hardware components (bus, cpu, memory, i/o controllers) - IRQ and NMI - instruction cycle times are simulated (however the *internal* cpu behavior is not cycle-exact for simplicity reasons) -- has all 6502 and 65c02 instructions, including many of the 'illegal' 6502 instructions (goal is 100% eventually) +- simulates all 6502 and 65c02 instructions, including many of the 'illegal' 6502 instructions - correct BCD mode for adc/sbc instructions on both cpu types - passes several extensive unit test suites that verify instruction and cpu flags behavior - simple debugging machine monitor, which basic disassembler and assembler functions diff --git a/src/main/kotlin/razorvine/ksim65/Cpu6502.kt b/src/main/kotlin/razorvine/ksim65/Cpu6502.kt index 6febf5c..a1cb2f9 100644 --- a/src/main/kotlin/razorvine/ksim65/Cpu6502.kt +++ b/src/main/kotlin/razorvine/ksim65/Cpu6502.kt @@ -1416,10 +1416,11 @@ sealed class Cpu6502Core : BusComponent() { // or https://github.com/quietust/nintendulator/blob/master/src/CPU.cpp (search for LogBadOps) // or https://github.com/stardot/b-em/blob/master/src/6502.c // or https://github.com/wpmed92/MedNES/blob/master/NES/6502.cpp - // TODO: some of the instructions below may be implemented incorrectly / are not finished yet + + // NOTE: some instructions below may be unimplemented due to cpu quirkyness private fun iAhx(): Boolean { - val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read) + val addrHi = (fetchedAddress shr 8) and 0xff val value = regA and regX and (addrHi+1) write(fetchedAddress, value) return false @@ -1506,13 +1507,13 @@ sealed class Cpu6502Core : BusComponent() { } private fun iShx(): Boolean { - val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read) + val addrHi = (fetchedAddress shr 8) and 0xff write(fetchedAddress, regX and (addrHi+1)) return false } private fun iShy(): Boolean { - val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read) + val addrHi = (fetchedAddress shr 8) and 0xff write(fetchedAddress, regY and (addrHi+1)) return false } @@ -1531,7 +1532,7 @@ sealed class Cpu6502Core : BusComponent() { private fun iTas(): Boolean { regSP = regA and regX - val addrHi = 0xff // TODO get the correct byte from the instruction (=last byte read) + val addrHi = (fetchedAddress shr 8) and 0xff write(fetchedAddress, regSP and addrHi) return false } diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties index 8918bf7..47b99a8 100644 --- a/src/main/resources/version.properties +++ b/src/main/resources/version.properties @@ -1 +1 @@ -version=1.21 +version=1.22 diff --git a/src/test/kotlin/Test6502TestSuiteIllegalInstructions.kt b/src/test/kotlin/Test6502TestSuiteIllegalInstructions.kt index bad1c4b..e5caa5c 100644 --- a/src/test/kotlin/Test6502TestSuiteIllegalInstructions.kt +++ b/src/test/kotlin/Test6502TestSuiteIllegalInstructions.kt @@ -283,60 +283,56 @@ class Test6502TestSuiteIllegalInstructions: FunctionalTestsBase() { @Test @Disabled("this illegal instruction is probably not implemented correctly yet") fun testAlrb() { - runTest("alrb") // TODO fix? + runTest("alrb") } @Test @Disabled("this illegal instruction is probably not implemented correctly yet") fun testAneb() { - runTest("aneb") // TODO fix? + runTest("aneb") } @Test @Disabled("this illegal instruction is probably not implemented correctly yet") fun testArrb() { - runTest("arrb") // TODO fix? + runTest("arrb") } @Test @Disabled("this illegal instruction is probably not implemented correctly yet") fun testLxab() { - runTest("lxab") // TODO fix something? + runTest("lxab") } @Test @Disabled("this illegal instruction is probably not implemented correctly yet") fun testSbxb() { - runTest("sbxb") // TODO fix? + runTest("sbxb") } @Test - @Disabled("this illegal instruction is probably not implemented correctly yet") fun testShaay() { - runTest("shaay") // TODO fix? + runTest("shaay") } @Test - @Disabled("this illegal instruction is probably not implemented correctly yet") fun testShaiy() { - runTest("shaiy") // TODO fix? + runTest("shaiy") } @Test - @Disabled("this illegal instruction is probably not implemented correctly yet") + @Disabled("this instruction has quirky behavior that varies between machines") fun testShsay() { - runTest("shsay") // TODO fix? + runTest("shsay") } @Test - @Disabled("this illegal instruction is probably not implemented correctly yet") fun testShxay() { - runTest("shxay") // TODO fix? + runTest("shxay") } @Test - @Disabled("this illegal instruction is probably not implemented correctly yet") fun testShyax() { - runTest("shyax") // TODO fix? + runTest("shyax") } }