mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-12 18:42:14 +00:00
ca65: fixed listing parsing
This commit is contained in:
parent
9e6fc9a0e3
commit
2e2996bd73
56
presets/vcs/skeleton.cc65
Normal file
56
presets/vcs/skeleton.cc65
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Atari VCS 2600 sample C program */
|
||||||
|
/* */
|
||||||
|
/* Florent Flament (contact@florentflament.com), 2017 */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <atari2600.h>
|
||||||
|
|
||||||
|
// PAL Timings
|
||||||
|
// Roughly computed based on Stella Programmer's guide (Steve Wright)
|
||||||
|
// scanlines count per section.
|
||||||
|
#define VBLANK_TIM64 51 // 45 lines * 76 cycles/line / 64 cycles/tick
|
||||||
|
#define KERNAL_T1024 17 // 228 lines * 76 cycles/line / 1024 cycles/tick
|
||||||
|
#define OVERSCAN_TIM64 42 // 36 lines * 76 cycles/line / 64 cycles/tick
|
||||||
|
|
||||||
|
// Testing memory zones
|
||||||
|
const unsigned char rodata_v[] = "Hello!";
|
||||||
|
unsigned char data_v = 0x77;
|
||||||
|
unsigned char bss_v;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
unsigned char color = 0x79; // Stack variable
|
||||||
|
bss_v = 0x88; // Testing BSS variable
|
||||||
|
|
||||||
|
for/*ever*/(;;) {
|
||||||
|
// Vertical Sync signal
|
||||||
|
TIA.vsync = 0x02;
|
||||||
|
TIA.wsync = 0x00;
|
||||||
|
TIA.wsync = 0x00;
|
||||||
|
TIA.wsync = 0x00;
|
||||||
|
TIA.vsync = 0x00;
|
||||||
|
|
||||||
|
// Vertical Blank timer setting
|
||||||
|
RIOT.tim64t = VBLANK_TIM64;
|
||||||
|
|
||||||
|
// Doing frame computation during blank
|
||||||
|
TIA.colubk = color++; // Update color
|
||||||
|
|
||||||
|
// Wait for end of Vertical Blank
|
||||||
|
while (RIOT.timint == 0) {}
|
||||||
|
TIA.wsync = 0x00;
|
||||||
|
TIA.vblank = 0x00; // Turn on beam
|
||||||
|
|
||||||
|
// Display frame
|
||||||
|
RIOT.t1024t = KERNAL_T1024;
|
||||||
|
while (RIOT.timint == 0) {}
|
||||||
|
TIA.wsync = 0x00;
|
||||||
|
TIA.vblank = 0x02; // Turn off beam
|
||||||
|
|
||||||
|
// Overscan
|
||||||
|
RIOT.tim64t = OVERSCAN_TIM64;
|
||||||
|
while (RIOT.timint == 0) {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ import { EmscriptenModule } from "../workermain"
|
||||||
00B726 1 xx xx IBSECSZ: .res 2
|
00B726 1 xx xx IBSECSZ: .res 2
|
||||||
00BA2F 1 2A 2B E8 2C HEX "2A2BE82C2D2E2F303132F0F133343536"
|
00BA2F 1 2A 2B E8 2C HEX "2A2BE82C2D2E2F303132F0F133343536"
|
||||||
*/
|
*/
|
||||||
function parseCA65Listing(code: string, symbols, segments, params, dbg: boolean, listings?: CodeListingMap) {
|
function parseCA65Listing(asmfn: string, code: string, symbols, segments, params, dbg: boolean, listings?: CodeListingMap) {
|
||||||
var segofs = 0;
|
var segofs = 0;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+(\w+), "([^"]+)", (.+)/;
|
var dbgLineMatch = /^([0-9A-F]+)([r]?)\s+(\d+)\s+[.]dbg\s+(\w+), "([^"]+)", (.+)/;
|
||||||
|
@ -28,7 +28,7 @@ function parseCA65Listing(code: string, symbols, segments, params, dbg: boolean,
|
||||||
var origlines = [];
|
var origlines = [];
|
||||||
var lines = origlines;
|
var lines = origlines;
|
||||||
var linenum = 0;
|
var linenum = 0;
|
||||||
let curpath = '';
|
let curpath = asmfn || '';
|
||||||
// TODO: only does .c functions, not all .s files
|
// TODO: only does .c functions, not all .s files
|
||||||
for (var line of code.split(re_crlf)) {
|
for (var line of code.split(re_crlf)) {
|
||||||
var dbgm = dbgLineMatch.exec(line);
|
var dbgm = dbgLineMatch.exec(line);
|
||||||
|
@ -62,13 +62,14 @@ function parseCA65Listing(code: string, symbols, segments, params, dbg: boolean,
|
||||||
insns: null
|
insns: null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
linenum++;
|
|
||||||
var linem = insnLineMatch.exec(line);
|
var linem = insnLineMatch.exec(line);
|
||||||
var topfile = linem && linem[3] == '1';
|
var topfile = linem && linem[3] == '1';
|
||||||
|
if (topfile) linenum++;
|
||||||
if (topfile && linem[1]) {
|
if (topfile && linem[1]) {
|
||||||
var offset = parseInt(linem[1], 16);
|
var offset = parseInt(linem[1], 16);
|
||||||
var insns = linem[4].trim();
|
var insns = linem[4].trim();
|
||||||
if (insns.length) {
|
if (insns.length) {
|
||||||
|
//console.log(curpath, linenum, offset, segofs, insns);
|
||||||
if (!dbg) {
|
if (!dbg) {
|
||||||
lines.push({
|
lines.push({
|
||||||
path: curpath,
|
path: curpath,
|
||||||
|
@ -222,18 +223,18 @@ export function linkLD65(step: BuildStep): BuildStepResult {
|
||||||
var lstout = FS.readFile(fn, { encoding: 'utf8' });
|
var lstout = FS.readFile(fn, { encoding: 'utf8' });
|
||||||
lstout = lstout.split('\n\n')[1] || lstout; // remove header
|
lstout = lstout.split('\n\n')[1] || lstout; // remove header
|
||||||
putWorkFile(fn, lstout);
|
putWorkFile(fn, lstout);
|
||||||
console.log(step);
|
//const asmpath = fn.replace(/\.lst$/, '.ca65'); // TODO! could be .s
|
||||||
let isECS = step.debuginfo?.entities != null; // TODO
|
let isECS = step.debuginfo?.entities != null; // TODO
|
||||||
if (isECS) {
|
if (isECS) {
|
||||||
var asmlines = [];
|
var asmlines = [];
|
||||||
var srclines = parseCA65Listing(lstout, symbolmap, segments, params, true, listings);
|
var srclines = parseCA65Listing(fn, lstout, symbolmap, segments, params, true, listings);
|
||||||
listings[fn] = {
|
listings[fn] = {
|
||||||
lines: [],
|
lines: [],
|
||||||
text: lstout
|
text: lstout
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var asmlines = parseCA65Listing(lstout, symbolmap, segments, params, false);
|
var asmlines = parseCA65Listing(fn, lstout, symbolmap, segments, params, false);
|
||||||
var srclines = parseCA65Listing(lstout, symbolmap, segments, params, true); // TODO: listings param for ecs
|
var srclines = parseCA65Listing('', lstout, symbolmap, segments, params, true);
|
||||||
listings[fn] = {
|
listings[fn] = {
|
||||||
asmlines: srclines.length ? asmlines : null,
|
asmlines: srclines.length ? asmlines : null,
|
||||||
lines: srclines.length ? srclines : asmlines,
|
lines: srclines.length ? srclines : asmlines,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user