Skip to content

Commit

Permalink
1.3.1: AS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kirjavascript committed Oct 29, 2023
1 parent c0aad5a commit 269d7ee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,5 +1,9 @@
# Changelog

## [1.3.1]
- Readd support for @label syntax
- Fix a bug with the even macro

## [1.3.0]
- Assembler now uses AS Macro Assembler for full macro support
- MapMacros.asm definitions added for Sonic 1 and 2
Expand Down
18 changes: 17 additions & 1 deletion app/formats/asm/index.js
Expand Up @@ -19,6 +19,22 @@ const p2binMessages = {
toolsmsg,
};

function atLabels(code) {
const labels = /^@[a-zA-Z0-9_$]+\s*:/gm;

while (true) {
const result = labels.exec(code);
if (!result) break;
const label = result[0].slice(0, -1);

if (label.startsWith('@')) {
code = code.replace(new RegExp(label, 'g'), `._at_${label.slice(1)}`);
}
}

return code;
}

export async function assemble(
code,
{ filename } = {
Expand All @@ -28,7 +44,7 @@ export async function assemble(
const aslWorker = new Worker('bundles/asl-worker.js');
const asl = Comlink.wrap(aslWorker);

const pFile = await asl.assemble(code, {
const pFile = await asl.assemble(atLabels(code), {
messages: asMessages,
filename,
});
Expand Down
1 change: 0 additions & 1 deletion app/formats/scripts/run-script.js
Expand Up @@ -334,7 +334,6 @@ export default catchFunc((file) => {
prelude: `
even macro
if (*)&1
paddingSoFar set paddingSoFar+1
dc.b 0 ;ds.b 1
endif
endm
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,5 +1,5 @@
{
"version": "1.3.0",
"version": "1.3.1",
"scripts": {
"start": "electron ./static --dev"
},
Expand Down

0 comments on commit 269d7ee

Please sign in to comment.