summary refs log tree commit diff
path: root/65c02.ts
diff options
context:
space:
mode:
authorWlodekM <[email protected]>2025-04-03 09:56:21 +0300
committerWlodekM <[email protected]>2025-04-03 09:56:21 +0300
commit0424cc4e5b5aeffd56f680f36333a4a27fc43a76 (patch)
tree797892022ad7ebb78753e56a00b541c8379a6747 /65c02.ts
parent1ee63e391385e2caa47509b36ff79299f02a97c5 (diff)
start working on some 65c02 stuff
Diffstat (limited to '65c02.ts')
-rw-r--r--65c02.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/65c02.ts b/65c02.ts
index fe17cb5..157e66c 100644
--- a/65c02.ts
+++ b/65c02.ts
@@ -190,11 +190,13 @@ export default class The65c02 {
     getZPAddr(): number {
         this.programCounter.increment()
         const zp = this.readPC().num()
+        this.programCounter.increment()
         return zp
     }
     getZPXAddr(): number {
         this.programCounter.increment()
         const zp = this.readPC().num()
+        this.programCounter.increment()
         return (this.regX.num() + zp) & 0xFF
     }
     getAbsoluteAddr(): number {
@@ -225,6 +227,7 @@ export default class The65c02 {
         const lo_abit = this.readPC().num()
         this.io.address.set((this.regX.num() + addr + 1) & 0xFF)
         const hi_abit = this.readPC().num()
+        this.programCounter.increment()
         return ((hi_abit << 8) | lo_abit)
     }
     getIndirectYAddr(): number {
@@ -234,8 +237,33 @@ export default class The65c02 {
         const lo_abit = this.readPC().num()
         this.io.address.set((addr + 1) & 0xFF)
         const hi_abit = this.readPC().num()
+        this.programCounter.increment()
         return ((hi_abit << 8) | lo_abit) + this.regY.num();
     }
+    getZPI(): number {
+        this.programCounter.increment()
+        const addr = this.readPC().num()
+        this.io.address.set((addr) & 0xFF)
+        const lo_abit = this.readPC().num()
+        this.io.address.set((addr + 1) & 0xFF)
+        const hi_abit = this.readPC().num()
+        this.programCounter.increment()
+        return ((hi_abit << 8) | lo_abit);
+    }
+    getAbsIndexedIndirect(): number {
+        this.programCounter.increment()
+        let addr = this.readPC().num()
+        this.programCounter.increment()
+        addr |= this.readPC().num() << 8;
+        addr += this.regX.num();
+        addr &= 0xFFFF
+        this.io.address.set((addr) & 0xFF)
+        const lo_abit = this.readPC().num()
+        this.io.address.set((addr + 1) & 0xFF)
+        const hi_abit = this.readPC().num()
+        this.programCounter.increment()
+        return ((hi_abit << 8) | lo_abit);
+    }
     getAddr(mode: string, allow?: string[]): number {
         if (allow && !allow.includes(mode))
             throw 'disallowed mode'
@@ -244,6 +272,10 @@ export default class The65c02 {
                 this.programCounter.increment()
                 this.programCounter.increment()
                 return this.programCounter.num() - 1
+            case 'zero-page indirect':
+                return this.getZPI()
+            case 'absolute indexed indirect':
+                return this.getAbsIndexedIndirect();
             // deno-lint-ignore no-case-declarations
             case 'relative':
                 this.programCounter.increment()