1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00

atari8: debug tree display list

This commit is contained in:
Steven Hugg 2023-07-07 23:59:44 -05:00
parent de12d20459
commit 47cabad5ec
3 changed files with 55 additions and 3 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -63,6 +63,11 @@ class Atari800Platform extends Base6502MachinePlatform<Atari800> {
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 {