From 9032eaf9b50dc8f61f5b66031317aaf035ac55b8 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sun, 5 Jul 2020 23:50:11 -0500 Subject: [PATCH] fixed ca65 listing line numbers --- doc/notes.txt | 2 ++ src/machine/apple2.ts | 5 +++-- src/platform/vectrex.ts | 1 + src/worker/workermain.ts | 23 +++++++++++++++-------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index a5bde2a5..7f528ba0 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -204,6 +204,8 @@ TODO: - need Edge 79+ - no import in workers - copy to gen/ directory (allowJs is weird) +- can we debug first frame via replay? +- ca65 line numbers are not aligned with source code WEB WORKER FORMAT diff --git a/src/machine/apple2.ts b/src/machine/apple2.ts index d10a2848..5326bb84 100644 --- a/src/machine/apple2.ts +++ b/src/machine/apple2.ts @@ -2,7 +2,7 @@ import { MOS6502, MOS6502State } from "../common/cpu/MOS6502"; import { Bus, BasicScanlineMachine, xorshift32, SavesState } from "../common/devices"; import { KeyFlags } from "../common/emu"; // TODO -import { lzgmini, stringToByteArray, RGBA, printFlags } from "../common/util"; +import { hex, lzgmini, stringToByteArray, RGBA, printFlags } from "../common/util"; const cpuFrequency = 1023000; const cpuCyclesPerLine = 65; // approx: http://www.cs.columbia.edu/~sedwards/apple2fpga/ @@ -993,7 +993,7 @@ const APPLEIIGO_LZG = `TFpHAAAwAAAABYxwdy2NARUZHjRBUFBMRUlJR08gUk9NMS4wADQfNB80H const NUM_DRIVES = 2; const NUM_TRACKS = 35; - const TRACK_SIZE = 0x1a00; + const TRACK_SIZE = 0x1880; const SECTOR_SIZE = 383; const DISKII_PROM = [ @@ -1072,6 +1072,7 @@ class DiskII extends DiskIIState implements SlotDevice, SavesState "\nOffset: " + (this.track_index) + "\nMode: " + (this.read_mode ? "READ" : "WRITE") + "\nMotor: " + this.motor + + "\nData: " + (this.track_data ? hex(this.track_data[this.track_index]) : '-') + "\n"; } diff --git a/src/platform/vectrex.ts b/src/platform/vectrex.ts index 6612aea8..afc6bb6c 100644 --- a/src/platform/vectrex.ts +++ b/src/platform/vectrex.ts @@ -14,6 +14,7 @@ import { NullProbe, Probeable, ProbeAll } from "../common/devices"; // http://www.playvectrex.com/designit/chrissalo/bios.asm // https://www.6809.org.uk/asm6809/doc/asm6809.shtml // http://www.playvectrex.com/ +// http://vectrexmuseum.com/vectrexhistory.php var VECTREX_PRESETS = [ { id: 'hello.xasm', name: 'Hello World (ASM)' }, diff --git a/src/worker/workermain.ts b/src/worker/workermain.ts index d54c08f2..b7d7e530 100644 --- a/src/worker/workermain.ts +++ b/src/worker/workermain.ts @@ -843,22 +843,28 @@ function setupStdin(fs, code:string) { ); } +//TODO: this doesn't align very well /* - 000000r 1 .segment "CODE" - 000000r 1 .proc _rasterWait: near - 000000r 1 ; int main() { return mul2(2); } - 000000r 1 .dbg line, "main.c", 3 - 000014r 1 .dbg func, "main", "00", extern, "_main" - 000000r 1 A2 00 ldx #$00 +000000r 1 .segment "CODE" +000000r 1 .proc _rasterWait: near +000000r 1 ; int main() { return mul2(2); } +000000r 1 .dbg line, "main.c", 3 +000014r 1 .dbg func, "main", "00", extern, "_main" +000000r 1 A2 00 ldx #$00 +00B700 1 BOOT2: +00B700 1 A2 01 ldx #1 ;track +00B725 1 00 IBLASTDRVN: .byte 0 +00B726 1 xx xx IBSECSZ: .res 2 +00BA2F 1 2A 2B E8 2C HEX "2A2BE82C2D2E2F303132F0F133343536" */ function parseCA65Listing(code, symbols, params, dbg) { var segofs = 0; var offset = 0; var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+(\w+), "([^"]+)", (.+)/; var funcLineMatch = /"(\w+)", (\w+), "(\w+)"/; - var insnLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+([0-9A-Fr ]*)\s*(.*)/; + var insnLineMatch = /^([0-9A-F]+)([r]?)\s{1,2}(\d+)\s{1,2}([0-9A-Frx ]{11})\s+(.*)/; var lines = []; - var linenum = 4; // ca65 listing header, 5 lines + var linenum = 0; // TODO: only does .c functions, not all .s files for (var line of code.split(re_crlf)) { var dbgm = dbgLineMatch.exec(line); @@ -1034,6 +1040,7 @@ function linkLD65(step:BuildStep) { for (var fn of step.files) { if (fn.endsWith('.lst')) { var lstout = FS.readFile(fn, {encoding:'utf8'}); + lstout = lstout.split('\n\n')[1] || lstout; // remove header var asmlines = parseCA65Listing(lstout, symbolmap, params, false); var srclines = parseCA65Listing(lstout, symbolmap, params, true); putWorkFile(fn, lstout);