Skip to content

Commit 830e42b

Browse files
committed
example scripts for sonic 1 and sonic 2
1 parent f11bc48 commit 830e42b

9 files changed

Lines changed: 244 additions & 241 deletions

File tree

TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ animation editor
88
==
99
BUGS
1010
show/hide collapse config state
11+
says open project when choosing mappings
1112
pink surrounding tiles sometimes breaks
1213
flex2_test/logo.png import is broken (alpha - works with exported flex file)
1314
tile deletes when drawing (unmap pieces / shortcuts in drawing mode)

app/formats/lang/docs.txt

Lines changed: 0 additions & 58 deletions
This file was deleted.

app/formats/lang/output.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/formats/lang/parse.js

Lines changed: 0 additions & 161 deletions
This file was deleted.

app/formats/scripts/index.js

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
1-
// arbitrary code warning
1+
// padding / fill
2+
// optimizations(false);
3+
// loadASM();
24

3-
info();
4-
offsetTable(dc.b);
5-
mappingHeader(() => byte(Symbol('length')))
6-
mapping((sprite, i) => [
7-
byte(sprite.top),
8-
nybble(0),
9-
bits(2, sprite.width - 1),
10-
bits(2, sprite.height - 1),
11-
bits(1, sprite.priority),
12-
bits(2, sprite.palette),
13-
bits(1, sprite.yflip),
14-
bits(1, sprite.xflip),
15-
bits(11, sprite.offset),
16-
word(sprite.left),
17-
]);
5+
// ASM & BIN read / write
186

7+
// purple warning: arbitrary code - warning before yes
8+
// derive UI from script - make dplcs still optional
9+
// assert everything on sprite is correcr
10+
// can read offset table
1911
// need an external scrtipts folder copied to the root on bundle
12+
// new Function('Flex2', script)({ read, write });
13+
// when write is a value of bigger than max safe int
14+
//
15+
// read a byte at a time always
16+
//
17+
// cystom screen
18+
//
19+
// ; sonic 1 mapping
20+
// (offset-table dc.b)
21+
// (mapping TTTTTTTT 0000 WW HH P CC Y X AAAAAAAAAAA LLLLLLLL)
22+
23+
// ; sonic 2 mapping
24+
25+
// ; sonic 1 dplc
26+
// (offset-table db.b)
27+
// (dplc-header LLLL)
28+
// (dplc NNNN AAAA AAAA AAAA)
29+
30+
// ; sonic 2/3&k dplc
31+
// (offset-table dc.w)
32+
// (dplc-header LLLLLLLL)
33+
// (dplc NNNN AAAA AAAA AAAA)
34+
35+
// ; sonic 2/3&k non-player dplc
36+
// (offset-table dc.w)
37+
// (dplc-header (sub #1 LLLL))
38+
// (dplc AAAA AAAA AAAA NNNN)
39+
//
40+
// TODO
41+
// kid chameleon
42+
// crackers
43+
// chaotix
44+
// github issues
45+
//
46+
// example: HUD graphics
47+
// s2 special stages

app/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,3 @@ document.addEventListener('drop', (e) => {
2323
e.preventDefault();
2424
return false;
2525
}, false);
26-
27-
console.log('todo: remove');
28-
require('#formats/scripts/index.js');

scripts/sonic1.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Flex2 mapping definition - sonic 1 object sprites
2+
3+
const {
4+
info,
5+
offsetTable,
6+
mapping,
7+
mappingHeader,
8+
write,
9+
read,
10+
nybble,
11+
dc,
12+
} = Flex2;
13+
14+
info();
15+
offsetTable(dc.b);
16+
mappingHeader(
17+
(_mappings) => read(dc.b),
18+
(mappings) => write(dc.b, mappings.length),
19+
);
20+
mappings(
21+
(mapping) => {
22+
mapping.top = read(dc.b);
23+
read(nybble);
24+
mapping.width = read(2) + 1;
25+
mapping.height = read(2) + 1;
26+
mapping.priority = read(1);
27+
mapping.palette = read(2);
28+
mapping.yflip = read(1);
29+
mapping.xflip = read(1);
30+
mapping.offset = read(11);
31+
mapping.left = read(dc.w);
32+
},
33+
(mapping) => {
34+
write(dc.b, mapping.top);
35+
write(nybble, 0);
36+
write(2, mapping.width - 1);
37+
write(2, mapping.height - 1);
38+
write(1, mapping.priority);
39+
write(2, mapping.palette);
40+
write(1, mapping.yflip);
41+
write(1, mapping.xflip);
42+
write(11, mapping.offset);
43+
write(dc.w, mapping.left);
44+
},
45+
);
46+
dplcHeader(
47+
(_dplcs) => read(dc.b),
48+
(dplcs) => write(dc.b, dplcs.length),
49+
);
50+
dplcs(
51+
(dplc) => {
52+
dplc.size = read(nybble);
53+
dplc.offset = read(nybble * 3);
54+
},
55+
(dplc) => {
56+
write(nybble, dplc.size);
57+
write(nybblr * 3, dplc.offset);
58+
},
59+
);

0 commit comments

Comments
 (0)