Skip to content

Commit 44271fe

Browse files
committed
added acme assembler
vcslib: increased # of lines in kernel
1 parent f6452a7 commit 44271fe

File tree

12 files changed

+166
-4
lines changed

12 files changed

+166
-4
lines changed

presets/c64/basicheader.acme

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
* = $0801
3+
!word Start
4+
!byte $00,$00,$9e
5+
!text "2066"
6+
!byte $00,$00,$00
7+
* = $0812

presets/c64/skeleton.acme

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
!src "basicheader.acme"
3+
4+
Start:
5+
jsr $e544 ; clear screen
6+
ldy #0
7+
Loop:
8+
lda Message,y ; load message byte
9+
beq EOM ; 0 = end of string
10+
sta $400+41,y ; store to screen
11+
iny
12+
bne Loop ; next character
13+
EOM:
14+
jmp EOM ; infinite loop
15+
16+
Message:
17+
!scr "hello world!", 0
18+

presets/vcs/vcslib/vcslib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ extern void tinyfont48_build(byte* dest, const char str[12]);
161161
#define OVERSCAN_TIM64 _TIM64(_CYCLES(36))
162162
#else
163163
#define VBLANK_TIM64 _TIM64(_CYCLES(37))
164-
#define KERNAL_TIM64 _TIM64(_CYCLES(194))
165-
#define OVERSCAN_TIM64 _TIM64(_CYCLES(32))
164+
#define KERNAL_TIM64 _TIM64(_CYCLES(198))
165+
#define OVERSCAN_TIM64 _TIM64(_CYCLES(28))
166166
#endif
167167

168168
#define JOY_UP(plyr) (!(RIOT.swcha & ((plyr) ? 0x1 : ~MOVE_UP)))

src/common/baseplatform.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,9 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
888888
const {x,y} = this.machine.getRasterCanvasPosition();
889889
if (x >= 0 || y >= 0) {
890890
const ctx = this.video.getContext();
891-
drawCrosshair(ctx, x, y, 1);
891+
if (ctx) {
892+
drawCrosshair(ctx, x, y, 1);
893+
}
892894
}
893895
}
894896
}

src/ide/project.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ export class CodeProject {
217217
while (m = re6.exec(text)) {
218218
this.pushAllFiles(files, m[2]);
219219
}
220+
// for acme
221+
let re7 = /^[!]src\s+"(.+?)"/gmi;
222+
while (m = re7.exec(text)) {
223+
this.pushAllFiles(files, m[1]);
224+
}
220225
}
221226
return files;
222227
}

src/ide/ui.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const TOOL_TO_SOURCE_STYLE = {
129129
'remote:llvm-mos': 'text/x-csrc',
130130
}
131131

132+
// TODO: move into tool class
132133
const TOOL_TO_HELPURL = {
133134
'dasm': 'https://raw.githubusercontent.com/sehugg/dasm/master/doc/dasm.txt',
134135
'cc65': 'https://cc65.github.io/doc/cc65.html',
@@ -142,6 +143,7 @@ const TOOL_TO_HELPURL = {
142143
'zmac': "https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt",
143144
'cmoc': "http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html",
144145
'remote:llvm-mos': 'https://llvm-mos.org/wiki/Welcome',
146+
'acme': 'https://raw.githubusercontent.com/sehugg/acme/main/docs/QuickRef.txt',
145147
}
146148

147149
function gaEvent(category:string, action:string, label?:string, value?:string) {
@@ -1895,6 +1897,8 @@ function _addIncludeFile() {
18951897
addFileToProject("Include", ".wiz", (s) => { return 'import "'+s+'";' });
18961898
else if (tool == 'ecs')
18971899
addFileToProject("Include", ".ecs", (s) => { return 'import "'+s+'"' });
1900+
else if (tool == 'acme')
1901+
addFileToProject("Include", ".acme", (s) => { return '!src "'+s+'"' });
18981902
else
18991903
alertError("Can't add include file to this project type (" + tool + ")");
19001904
}

src/platform/vcs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function getToolForFilename_vcs(fn: string) {
6262
if (fn.endsWith(".wiz")) return "wiz";
6363
if (fn.endsWith(".bb") || fn.endsWith(".bas")) return "bataribasic";
6464
if (fn.endsWith(".ca65")) return "ca65";
65+
if (fn.endsWith(".acme")) return "acme";
6566
//if (fn.endsWith(".inc")) return "ca65";
6667
if (fn.endsWith(".c")) return "cc65";
6768
//if (fn.endsWith(".h")) return "cc65";

src/worker/tools/acme.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import { CodeListing, CodeListingMap } from "../../common/workertypes";
2+
import { BuildStep, BuildStepResult, emglobal, execMain, fixParamsWithDefines, gatherFiles, loadNative, makeErrorMatcher, moduleInstFn, msvcErrorMatcher, populateFiles, print_fn, putWorkFile, setupFS, staleFiles } from "../workermain";
3+
import { EmscriptenModule } from "../workermain"
4+
5+
function parseACMESymbolTable(text: string) {
6+
var symbolmap = {};
7+
var lines = text.split("\n");
8+
for (var i = 0; i < lines.length; ++i) {
9+
var line = lines[i].trim();
10+
// init_text = $81b ; ?
11+
var m = line.match(/(\w+)\s*=\s*[$]([0-9a-f]+)/i);
12+
if (m) {
13+
symbolmap[m[1]] = parseInt(m[2], 16);
14+
}
15+
}
16+
return symbolmap;
17+
}
18+
19+
function parseACMEReportFile(text: string) {
20+
var listings : CodeListingMap = {};
21+
var listing : CodeListing;
22+
var lines = text.split("\n");
23+
for (var i = 0; i < lines.length; ++i) {
24+
var line = lines[i].trim();
25+
// ; ******** Source: hello.acme
26+
var m1 = line.match(/^;\s*[*]+\s*Source: (.+)$/);
27+
if (m1) {
28+
var file = m1[1];
29+
listings[file] = listing = {
30+
lines: [],
31+
};
32+
continue;
33+
}
34+
// 15 0815 201b08 jsr init_text ; write line of text
35+
var m2 = line.match(/^(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)/i);
36+
if (m2) {
37+
if (listing) {
38+
listing.lines.push({
39+
line: parseInt(m2[1]),
40+
offset: parseInt(m2[2], 16),
41+
insns: m2[3],
42+
});
43+
}
44+
}
45+
}
46+
return listings;
47+
}
48+
49+
export function assembleACME(step: BuildStep): BuildStepResult {
50+
loadNative("acme");
51+
var errors = [];
52+
gatherFiles(step, { mainFilePath: "main.acme" });
53+
var binpath = step.prefix + ".bin";
54+
var lstpath = step.prefix + ".lst";
55+
var sympath = step.prefix + ".sym";
56+
if (staleFiles(step, [binpath, lstpath])) {
57+
var binout, lstout, symout;
58+
var ACME: EmscriptenModule = emglobal.acme({
59+
instantiateWasm: moduleInstFn('acme'),
60+
noInitialRun: true,
61+
print: print_fn,
62+
printErr: msvcErrorMatcher(errors),
63+
//printErr: makeErrorMatcher(errors, /(Error|Warning) - File (.+?), line (\d+)[^:]+: (.+)/, 3, 4, step.path, 2),
64+
});
65+
var FS = ACME.FS;
66+
populateFiles(step, FS);
67+
fixParamsWithDefines(step.path, step.params);
68+
var args = ['--msvc', '--initmem', '0', '-o', binpath, '-r', lstpath, '-l', sympath, step.path];
69+
if (step.params?.acmeargs) {
70+
args.unshift.apply(args, step.params.acmeargs);
71+
} else {
72+
args.unshift.apply(args, ['-f', 'plain']);
73+
}
74+
args.unshift.apply(args, ["-D__8BITWORKSHOP__=1"]);
75+
if (step.mainfile) {
76+
args.unshift.apply(args, ["-D__MAIN__=1"]);
77+
}
78+
execMain(step, ACME, args);
79+
if (errors.length) {
80+
let listings: CodeListingMap = {};
81+
return { errors, listings };
82+
}
83+
binout = FS.readFile(binpath, { encoding: 'binary' });
84+
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
85+
symout = FS.readFile(sympath, { encoding: 'utf8' });
86+
putWorkFile(binpath, binout);
87+
putWorkFile(lstpath, lstout);
88+
putWorkFile(sympath, symout);
89+
return {
90+
output: binout,
91+
listings: parseACMEReportFile(lstout),
92+
errors: errors,
93+
symbolmap: parseACMESymbolTable(symout),
94+
};
95+
}
96+
}

src/worker/wasm/acme.js

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/worker/wasm/acme.wasm

97.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)