From 47cabad5ec1ec2a5f70fa146edf9c3689a615cb6 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Fri, 7 Jul 2023 23:59:44 -0500 Subject: [PATCH] atari8: debug tree display list --- src/machine/atari8.ts | 45 +++++++++++++++++++++++++++++++++++++- src/machine/chips/antic.ts | 8 +++++-- src/platform/atari8.ts | 5 +++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/machine/atari8.ts b/src/machine/atari8.ts index 827fbb83..9b880c2a 100644 --- a/src/machine/atari8.ts +++ b/src/machine/atari8.ts @@ -5,7 +5,7 @@ import { AcceptsKeyInput, AcceptsPaddleInput, AcceptsROM, BasicScanlineMachine, import { KeyFlags, Keys, makeKeycodeMap, newAddressDecoder, newKeyboardHandler } from "../common/emu"; import { hex } from "../common/util"; import { BaseWASIMachine } from "../common/wasmplatform"; -import { ANTIC, MODE_SHIFT } from "./chips/antic"; +import { ANTIC, MODE_LINES, MODE_SHIFT } from "./chips/antic"; import { CONSOL, GTIA, TRIG0 } from "./chips/gtia"; import { POKEY } from "./chips/pokey"; @@ -410,6 +410,49 @@ export class Atari800 extends BasicScanlineMachine implements AcceptsPaddleInput this.irq_pokey.pot_inputs[controller] = 255 - value; } + getDebugDisplayList() { + let pc = this.antic.getDlistAddr(); + const nextInsn = () => { + let b = this.read(pc); + pc = ((pc + 1) & 0x3ff) | (pc & ~0x3ff); + return b; + } + let dlist = {}; + let y = 0; + for (let i=0; i<256 && y<240; i++) { + let pc0 = pc; + let op = nextInsn(); // get mode + let mode = op & 0xf; + let debugmsg = ""; // op=" + hex(op); + let jmp = false; + let lines; + if (mode == 0) { + lines = (((op >> 4) & 7) + 1); + debugmsg += " blank=" + lines; + } else { + lines = MODE_LINES[mode]; + debugmsg += " mode=" + hex(mode); + debugmsg += " lines=" + lines; + jmp = (op & ~0x40) == 0x01; // JMP insn? + let lms = (op & 0x40) != 0 && (op & 0xf) != 0; // LMS insn? + if (jmp && (op & 0x40)) { debugmsg += " JVB"; } + else if (jmp) debugmsg += " JMP"; + else if (lms) debugmsg += " LMS"; + if (this.antic.isPlayfieldDMAEnabled() && (jmp || lms)) { + let dlarg_lo = nextInsn(); + let dlarg_hi = nextInsn(); + debugmsg += " $" + hex(dlarg_hi) + "" + hex(dlarg_lo); + } + if (op & 0x10) { debugmsg += " HSCROL"; } + if (op & 0x20) { debugmsg += " VSCROL"; } + } + dlist["$"+hex(pc0) + " y=" + y] = debugmsg; + if (jmp) break; + y += lines; + } + return dlist; + } + } export class Atari5200 extends Atari800 { diff --git a/src/machine/chips/antic.ts b/src/machine/chips/antic.ts index 554fff79..ba677d4c 100644 --- a/src/machine/chips/antic.ts +++ b/src/machine/chips/antic.ts @@ -42,7 +42,7 @@ const ANTIC_LEFT = 17 - 4; // gtia 34, 4 cycle delay const ANTIC_RIGHT = 110 - 4; // gtia 221, 4 cycle delay const LAST_DMA_H = 105; // last DMA cycle -const MODE_LINES = [0, 0, 8, 10, 8, 16, 8, 16, 8, 4, 4, 2, 1, 2, 1, 1]; +export const MODE_LINES = [0, 0, 8, 10, 8, 16, 8, 16, 8, 4, 4, 2, 1, 2, 1, 1]; // how many bits before DMA clock repeats? const MODE_PERIOD = [0, 0, 2, 2, 2, 2, 4, 4, 8, 4, 4, 4, 4, 2, 2, 2]; const MODE_YPERIOD = [0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 0, 0, 0, 0]; @@ -199,8 +199,12 @@ export class ANTIC { } } + getDlistAddr() { + return this.regs[DLISTL] + (this.regs[DLISTH] << 8); + } + nextInsn(): number { - let pc = this.regs[DLISTL] + (this.regs[DLISTH] << 8); + let pc = this.getDlistAddr(); let b = this.read(pc); //console.log('nextInsn', hex(pc), hex(b), this.v); pc = ((pc + 1) & 0x3ff) | (pc & ~0x3ff); diff --git a/src/platform/atari8.ts b/src/platform/atari8.ts index a6b9511b..3810f5e5 100644 --- a/src/platform/atari8.ts +++ b/src/platform/atari8.ts @@ -63,6 +63,11 @@ class Atari800Platform extends Base6502MachinePlatform { return new Uint8Array(biosBinary); } else throw new Error('could not load BIOS file'); } + getDebugTree() { + let tree = super.getDebugTree(); + tree['display_list'] = this.machine.getDebugDisplayList(); + return tree; + } } class Atari5200Platform extends Atari800Platform {