Skip to content

Commit 22bfea1

Browse files
committed
asm writing for mapmacos
1 parent 10585c9 commit 22bfea1

File tree

7 files changed

+123
-11
lines changed

7 files changed

+123
-11
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [unreleased]
44
- Assembler now uses AS Macro Assembler for full macro support
55
- MapMacros.asm definitions added
6+
- Custom ASM output support added
67
- Make (de)compression threaded
78
- Change DPLC limit to 255
89
- Fix issue where image data would be cached incorrectly

TODO

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212

1313

1414
macros for mappings
15-
specify mapmacros in definition
16-
format hooks for defining asm output
17-
define macro files in script??
18-
fix prelude
1915
perf
16+
autoload mapping label if blank
2017

2118
redo tile rendering
2219
remove rotsprite

app/components/file/file-object.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ export const FileObject = observer(({ obj }) => {
198198
await fs.writeFile(path, writeBIN(dplcs));
199199
} else {
200200
const label = obj.dplcs.label || 'DPLC_' + uuid().slice(0, 4);
201-
await fs.writeFile(path, writeASM(label, dplcs));
201+
const asmOutput = script.generateDPLCsASM({
202+
label,
203+
listing: dplcs,
204+
sprites: environment.sprites,
205+
});
206+
207+
await fs.writeFile(path, asmOutput);
202208
}
203209
});
204210
}
@@ -317,7 +323,7 @@ export const FileObject = observer(({ obj }) => {
317323
</div>
318324
)}
319325

320-
{script.PLCs && (
326+
{script.DPLCs && (
321327
<>
322328
<div className="menu-item" onClick={toggleDPLCs}>
323329
<Item>DPLCs Enabled</Item>

app/formats/scripts/run-script.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ paddingSoFar set paddingSoFar+1
373373
}
374374

375375
if (writeDPLCsArgs[0]) {
376-
asm.writeDPLCs = writeDPLCs[0];
376+
asm.writeDPLCs = writeDPLCsArgs[0];
377377
}
378378
}
379379

@@ -403,8 +403,19 @@ paddingSoFar set paddingSoFar+1
403403
});
404404
};
405405

406-
exports.generateDPLCsASM = function() {
406+
exports.generateDPLCsASM = function({
407+
label,
408+
sprites,
409+
listing,
410+
}) {
411+
if (!asm.writeDPLCs) {
412+
return writeASM(label, listing);
413+
}
407414

415+
return asm.writeDPLCs({
416+
label, sprites, listing,
417+
renderHex,
418+
});
408419
};
409420

410421
return exports;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.2.2",
2+
"version": "1.3.0",
33
"scripts": {
44
"start": "electron ./static --dev"
55
},

scripts/Sonic 1.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,71 @@ SonicMappingsVer := 1
7878
SonicDplcVer = 1
7979
`);
8080
importScript('MapMacros.asm');
81+
82+
writeMappings(({ label, sprites, renderHex }) => {
83+
const list = [];
84+
85+
list.push(`${label}: mappingsTable`);
86+
sprites.forEach((_, i) => {
87+
list.push(`\tmappingsTableEntry.w\t${label}_${i}`);
88+
});
89+
list.push('');
90+
91+
sprites.forEach((sprite, i) => {
92+
list.push(`${label}_${i}:\tspriteHeader`);
93+
94+
sprite.mappings.forEach(mapping => {
95+
const pieceInfo = [
96+
mapping.left,
97+
mapping.top,
98+
mapping.width,
99+
mapping.height,
100+
mapping.art,
101+
mapping.hflip,
102+
mapping.vflip,
103+
mapping.palette,
104+
mapping.priority,
105+
].map(renderHex).join(', ');
106+
107+
list.push(` spritePiece ${pieceInfo}`);
108+
});
109+
110+
list.push(`${label}_${i}_End`);
111+
list.push('');
112+
});
113+
114+
list.push('\teven');
115+
116+
return list.join('\n');
117+
});
118+
119+
writeDPLCs(({ label, sprites, renderHex }) => {
120+
const list = [];
121+
122+
list.push(`${label}: mappingsTable`);
123+
sprites.forEach((_, i) => {
124+
list.push(`\tmappingsTableEntry.w\t${label}_${i}`);
125+
});
126+
list.push('');
127+
128+
sprites.forEach((sprite, i) => {
129+
list.push(`${label}_${i}:\tdplcHeader`);
130+
131+
sprite.dplcs.forEach(dplc => {
132+
const pieceInfo = [
133+
dplc.size,
134+
dplc.art,
135+
].map(renderHex).join(', ');
136+
137+
list.push(` dplcEntry ${pieceInfo}`);
138+
});
139+
140+
list.push(`${label}_${i}_End`);
141+
list.push('');
142+
});
143+
144+
list.push('\teven');
145+
146+
return list.join('\n');
147+
});
81148
});

scripts/Sonic 2.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ dplcs([
8383
],
8484
]);
8585

86-
asm(({ addScript, importScript, writeMappings }) => {
86+
asm(({ addScript, importScript, writeMappings, writeDPLCs }) => {
8787
addScript(`
8888
SonicMappingsVer := 2
8989
SonicDplcVer = 2
@@ -95,7 +95,7 @@ SonicDplcVer = 2
9595

9696
list.push(`${label}: mappingsTable`);
9797
sprites.forEach((_, i) => {
98-
list.push(`\tmappingsTableEntry.w\tMap_Sonic_${i}`);
98+
list.push(`\tmappingsTableEntry.w\t${label}_${i}`);
9999
});
100100
list.push('');
101101

@@ -126,4 +126,34 @@ SonicDplcVer = 2
126126

127127
return list.join('\n');
128128
});
129+
130+
writeDPLCs(({ label, sprites, renderHex }) => {
131+
const list = [];
132+
133+
list.push(`${label}: mappingsTable`);
134+
sprites.forEach((_, i) => {
135+
list.push(`\tmappingsTableEntry.w\t${label}_${i}`);
136+
});
137+
list.push('');
138+
139+
sprites.forEach((sprite, i) => {
140+
list.push(`${label}_${i}:\tdplcHeader`);
141+
142+
sprite.dplcs.forEach(dplc => {
143+
const pieceInfo = [
144+
dplc.size,
145+
dplc.art,
146+
].map(renderHex).join(', ');
147+
148+
list.push(` dplcEntry ${pieceInfo}`);
149+
});
150+
151+
list.push(`${label}_${i}_End`);
152+
list.push('');
153+
});
154+
155+
list.push('\teven');
156+
157+
return list.join('\n');
158+
});
129159
});

0 commit comments

Comments
 (0)