-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathnametablepatch.js
26 lines (21 loc) · 924 Bytes
/
nametablepatch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const lookup = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-.\'>!^()############qweadzxc############################################################################################################################################################################################### ';
const convert = (patch, pos) => {
const lines = patch.trim().split('\n');
return lines.map((line, i) => {
const tiles = [...line].map(ch => lookup.indexOf(ch));
const addr = pos + (i * 0x20);
const ending = lines.length - 1 != i ? 0xFE : 0xFD;
return [addr >> 8, addr & 0xFF, ...tiles, ending];
});
};
const print = bytes => bytes.map(line => ' .byte ' + line.map(d => '$' + d.toString(16).padStart(2,'0').toUpperCase()).join`,`).join`\n`;
// nametable patches
console.log(print(convert(`
qwwwwwwe
aSLOT d
a d
zxxxxxxc
`, 0x22F7)));
console.log(print(convert(`
a d
`, 0x20A2)));