From c50e619bef9ecd2266ee904b87c6401cb0572660 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Thu, 3 Apr 2025 10:29:58 +0300 Subject: fix stuff --- instructions/BRK.ts | 37 +++++++++++++++---------------------- instructions/CLC.ts | 2 +- instructions/DEC.ts | 6 ++++++ instructions/INX.ts | 2 +- instructions/INY.ts | 2 +- instructions/ROL.ts | 1 + instructions/ROR.ts | 1 + 7 files changed, 26 insertions(+), 25 deletions(-) (limited to 'instructions') diff --git a/instructions/BRK.ts b/instructions/BRK.ts index 419eeef..6a2f4e1 100644 --- a/instructions/BRK.ts +++ b/instructions/BRK.ts @@ -1,25 +1,18 @@ import type The65c02 from "../65c02.ts"; -export default function (this: The65c02, mode: string) { - switch (mode) { - case 'implied': - this.io.interruptRequest.HI() - //TODO: push shit onto stack - this.push(this.programCounter.num() & 0x00FF) - this.push(this.programCounter.num() & 0xFF00) - this.push(this.status.num()) - this.io.data.set(this.programCounter.num() & 0x00FF) - this.io.address.set(0xFFFF) - this.write() - this.io.data.set(this.programCounter.num() & 0xFF00) - this.io.address.set(0xFFFE) - this.write() - this.BRK = true - this.programCounter.increment(); - this.programCounter.increment(); - break; - - default: - throw 'wha'; - } +export default function (this: The65c02) { + this.io.interruptRequest.HI() + //TODO: push shit onto stack + this.push(this.programCounter.num() & 0x00FF) + this.push(this.programCounter.num() & 0xFF00) + this.push(this.status.num()) + this.io.data.set(this.programCounter.num() & 0x00FF) + this.io.address.set(0xFFFF) + this.write() + this.io.data.set(this.programCounter.num() & 0xFF00) + this.io.address.set(0xFFFE) + this.write() + this.BRK = true + this.programCounter.increment(); + this.programCounter.increment(); } \ No newline at end of file diff --git a/instructions/CLC.ts b/instructions/CLC.ts index d14b2f4..f909d85 100644 --- a/instructions/CLC.ts +++ b/instructions/CLC.ts @@ -2,7 +2,7 @@ import type The65c02 from "../65c02.ts"; export default function (this: The65c02, mode: string) { switch (mode) { - case 'implied': + case 'implicit': this.carry = false; this.programCounter.increment(); break; diff --git a/instructions/DEC.ts b/instructions/DEC.ts index 2f9d7a9..19f40f9 100644 --- a/instructions/DEC.ts +++ b/instructions/DEC.ts @@ -1,6 +1,12 @@ import type The65c02 from "../65c02.ts"; export default function (this: The65c02, mode: string) { + if (mode == 'implicit') { + this.flagZN(this.regA.num() - 1) + this.regA.decrement(); + this.programCounter.increment() + return; + } const addr = this.getAddr(mode); this.io.address.set(addr); this.read(); diff --git a/instructions/INX.ts b/instructions/INX.ts index 9c1cc1b..9a947e1 100644 --- a/instructions/INX.ts +++ b/instructions/INX.ts @@ -2,7 +2,7 @@ import type The65c02 from "../65c02.ts"; export default function (this: The65c02, mode: string) { switch (mode) { - case 'implied': + case 'implicit': this.regX.increment() this.negative = this.regX.bit(7); this.zero = this.regX.num() == 0; diff --git a/instructions/INY.ts b/instructions/INY.ts index 566c6d4..7e8784d 100644 --- a/instructions/INY.ts +++ b/instructions/INY.ts @@ -2,7 +2,7 @@ import type The65c02 from "../65c02.ts"; export default function (this: The65c02, mode: string) { switch (mode) { - case 'implied': + case 'implicit': this.regY.increment() this.negative = this.regY.bit(7); this.zero = this.regY.num() == 0; diff --git a/instructions/ROL.ts b/instructions/ROL.ts index c76ef8b..bd1e810 100644 --- a/instructions/ROL.ts +++ b/instructions/ROL.ts @@ -7,6 +7,7 @@ export default function (this: The65c02, mode: string) { this.negative = (result & 256) != 0 this.carry = (mem & 256) != 0 this.regA.set(result & 0xFF); + this.programCounter.increment() } else { const addr = this.getAddr(mode) this.io.address.set(addr); diff --git a/instructions/ROR.ts b/instructions/ROR.ts index 7226604..60226c9 100644 --- a/instructions/ROR.ts +++ b/instructions/ROR.ts @@ -7,6 +7,7 @@ export default function (this: The65c02, mode: string) { this.negative = (result & 256) != 0 this.carry = (mem & 256) != 0 this.regA.set(result & 0xFF); + this.programCounter.increment() } else { const addr = this.getAddr(mode) this.io.address.set(addr); -- cgit 1.4.1-2-gfad0