Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,20 @@
}
}

$('#submitBASIC').click(function(event){
$('#submitBASIC').click(async function(event){
event.preventDefault(); // Prevents the default action of the anchor tag
parseBASIC();
await parseBASIC();
});

$('#submitBASICAndRun').click(function (event) {
$('#submitBASICAndRun').click(async function (event) {
event.preventDefault(); // Prevents the default action of the anchor tag
parseBASIC();
runBASIC();
await parseBASIC();
await runBASIC();
});

$('#runBASIC').click(function (event) {
$('#runBASIC').click(async function (event) {
event.preventDefault(); // Prevents the default action of the anchor tag
runBASIC();
await runBASIC();
});

async function runBASIC() {
Expand Down Expand Up @@ -355,7 +355,7 @@
['{rght}', 0x1d],
['{clr}', 0x93],
['{clear}', 0x93],
['{home}', 0x13],
['{home}', 0x13],

['{blk}', 0x90],
['{wht}', 0x05],
Expand All @@ -372,9 +372,23 @@
['{mgry}', 0x98],
['{lgrn}', 0x99],
['{lblu}', 0x9a],
['{lgry}', 0x9b]

['{lgry}', 0x9b],

// additional entries found in COMPUTES!'s Gazette
['{rvs}', 0x12],
['{space}', 0x20],
['{spaces}', 0x20],
['{gry1}', 0x97],
['{gry2}', 0x98],
['{gry3}', 0x9b],
['{f1}', 0x85],
['{f2}', 0x86],
['{f3}', 0x87],
['{f4}', 0x88],
['{f5}', 0x89],
['{f6}', 0x8a],
['{f7}', 0x8b],
['{f8}', 0x8c],
];

function asciiToPetscii(o) {
Expand All @@ -396,6 +410,8 @@
}

function scan(s, tokenize = true) {
s = expandCounts(s);

if (tokenize) {
for (let i = 0; i < TOKENS.length; i++) {
let [token, value] = TOKENS[i];
Expand All @@ -416,6 +432,14 @@
return [asciiToPetscii(s.charCodeAt(0)), s.substring(1)];
}

// Expand patterns like {3 spaces} → {spaces}{spaces}{spaces}
function expandCounts(input) {
return input.replace(/\{(\d+)\s+([^}]+)\}/g, (_, count, word) => {
count = Number(count);
return Array(count).fill(`{${word}}`).join('');
});
}

function scanLineNumber(s) {
s = s.trimStart();
let acc = [];
Expand Down