Skip to content

Commit fe9c1d8

Browse files
committed
s3k next
1 parent 8c9473a commit fe9c1d8

File tree

6 files changed

+187
-164
lines changed

6 files changed

+187
-164
lines changed

TODO

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ post image of project / some custom mappings, saying it's ready for testing
1010
BUFFER
1111
==
1212

13-
// mapping debugger
13+
// rawBytes()
1414
// art ffset save message / input size
1515
// copy to project
1616
// autodismiss
@@ -25,8 +25,6 @@ BUFFER
2525

2626
// formats to support
2727

28-
// fix s2 dplc
29-
// fix tails
3028
/* https://github.com/Ralakimus/sonic-cd-r11a-disassembly */
3129
/* http://info.sonicretro.org/Disassemblies */
3230
// s3k sonic

app/formats/scripts/debug.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MapLogger {
2121
};
2222
@action clear = () => this.log.replace([]);
2323
@computed get output() {
24-
return this.log.map((item, i) => item.join` `).join`\n`;
24+
return this.log.map((item) => item.join` `).join`\n`;
2525
}
2626
}
2727

@@ -39,8 +39,6 @@ export const logger = (...args) => {
3939
log.msg(...args);
4040
};
4141

42-
window.logger = log;
43-
4442
const Debug = observer(function () {
4543
return (
4644
log.enabled && (

app/formats/scripts/run-script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ function makeOffsetTable({ read, write }) {
6666
if (header === 0) {
6767
sprites.push([]); // handle zero header optimization
6868
} else {
69-
sprites.push(spritesAddr[header]);
69+
if (spritesAddr[header]) {
70+
sprites.push(spritesAddr[header]);
71+
} else {
72+
logger('error', 'no sprite at ' + header);
73+
}
7074
}
7175
});
76+
console.log(spritesAddr);
7277
});
7378
return constants.endSection;
7479
},

scripts/Sonic 3&K Object.js

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,76 @@
1-
// Flex2 mapping definition
1+
// Flex2 Mapping Definition - Sonic 3 Objects
22

33
const {
4-
label,
5-
info,
4+
mappings,
5+
dplcs,
66
offsetTable,
7-
mapping,
8-
mappingHeader,
97
write,
108
read,
11-
nybble,
129
dc,
10+
nybble,
11+
endFrame,
12+
skipFrame,
13+
signed,
1314
} = Flex2;
1415

15-
label('Sonic 3&K Objects');
16-
offsetTable(dc.w);
17-
mappingHeader(
18-
(_mappings) => read(dc.w),
19-
(mappings) => write(dc.w, mappings.length),
20-
);
21-
mappings(
22-
(mapping) => {
23-
mapping.top = read(dc.b);
24-
read(nybble);
25-
mapping.width = read(2) + 1;
26-
mapping.height = read(2) + 1;
27-
mapping.priority = read(1);
28-
mapping.palette = read(2);
29-
mapping.yflip = read(1);
30-
mapping.xflip = read(1);
31-
mapping.offset = read(1);
32-
mapping.left = read(dc.w);
33-
},
34-
(mapping) => {
35-
// top
36-
write(dc.b, mapping.top);
37-
write(nybble, 0);
38-
// size
39-
write(2, mapping.width - 1);
40-
write(2, mapping.height - 1);
41-
// 1 player
42-
write(1, mapping.priority);
43-
write(2, mapping.palette);
44-
write(1, mapping.yflip);
45-
write(1, mapping.xflip);
46-
write(11, mapping.offset);
47-
// left
48-
write(dc.w, mapping.left);
49-
},
50-
);
51-
dplcHeader(
52-
(_dplcs) => read(dc.w),
53-
(dplcs) => write(dc.w, dplcs.length - 1),
54-
);
55-
dplcs(
56-
(dplc) => {
57-
dplc.offset = read(nybble * 3);
58-
dplc.size = read(nybble);
59-
},
60-
(dplc) => {
61-
write(nybblr * 3, dplc.offset);
62-
write(nybble, dplc.size);
63-
},
64-
);
16+
mappings([
17+
offsetTable(dc.w),
18+
[
19+
() => {
20+
const quantity = read(dc.w);
21+
return quantity > 0 && (({ mapping }, frameIndex) => {
22+
mapping.top = read(dc.b, signed);
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.vflip = read(1);
29+
mapping.hflip = read(1);
30+
mapping.art = read(11);
31+
mapping.left = read(dc.w, signed);
32+
if (frameIndex === quantity - 1) return endFrame;
33+
});
34+
},
35+
({ sprite }) => {
36+
write(dc.w, sprite.length);
37+
return ({ mapping }) => {
38+
// top
39+
write(dc.b, mapping.top);
40+
write(nybble, 0);
41+
// size
42+
write(2, mapping.width - 1);
43+
write(2, mapping.height - 1);
44+
// 1 player
45+
write(1, mapping.priority);
46+
write(2, mapping.palette);
47+
write(1, mapping.vflip);
48+
write(1, mapping.hflip);
49+
write(11, mapping.offset);
50+
// left
51+
write(dc.w, mapping.left);
52+
};
53+
},
54+
],
55+
]);
56+
57+
dplcs([
58+
offsetTable(dc.w),
59+
[
60+
() => {
61+
const quantity = read(dc.w);
62+
return quantity > 0 && (({ mapping }, frameIndex) => {
63+
mapping.art = read(nybble * 3);
64+
mapping.size = read(nybble) + 1;
65+
if (frameIndex === quantity - 1) return endFrame;
66+
});
67+
},
68+
({ sprite }) => {
69+
write(dc.w, sprite.length);
70+
return ({ mapping }) => {
71+
write(nybble * 3, mapping.art);
72+
write(nybble, mapping.size - 1);
73+
};
74+
},
75+
],
76+
]);

scripts/Sonic 3&K Player.js

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flex2 Mapping Definition - Sonic 3
1+
// Flex2 Mapping Definition - Sonic 3 Player
22

33
const {
44
mappings,
@@ -16,59 +16,61 @@ const {
1616
mappings([
1717
offsetTable(dc.w),
1818
[
19-
({ mapping, ref }, i) => {
20-
if (i === 0) {
21-
ref.quantity = read(dc.w);
22-
if (ref.quantity === 0) return skipFrame;
23-
}
24-
mapping.top = read(dc.b, signed);
25-
read(nybble);
26-
mapping.width = read(2) + 1;
27-
mapping.height = read(2) + 1;
28-
mapping.priority = read(1);
29-
mapping.palette = read(2);
30-
mapping.vflip = read(1);
31-
mapping.hflip = read(1);
32-
mapping.art = read(11);
33-
mapping.left = read(dc.w, signed);
34-
if (i === ref.quantity - 1) return endFrame;
19+
() => {
20+
const quantity = read(dc.w);
21+
return quantity > 0 && (({ mapping }, frameIndex) => {
22+
mapping.top = read(dc.b, signed);
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.vflip = read(1);
29+
mapping.hflip = read(1);
30+
mapping.art = read(11);
31+
mapping.left = read(dc.w, signed);
32+
if (frameIndex === quantity - 1) return endFrame;
33+
});
3534
},
36-
({ mapping, sprite }, i) => {
37-
if (i === 0) write(dc.w, sprite.length);
38-
// top
39-
write(dc.b, mapping.top);
40-
write(nybble, 0);
41-
// size
42-
write(2, mapping.width - 1);
43-
write(2, mapping.height - 1);
44-
// 1 player
45-
write(1, mapping.priority);
46-
write(2, mapping.palette);
47-
write(1, mapping.vflip);
48-
write(1, mapping.hflip);
49-
write(11, mapping.offset);
50-
// left
51-
write(dc.w, mapping.left);
35+
({ sprite }) => {
36+
write(dc.w, sprite.length);
37+
return ({ mapping }) => {
38+
// top
39+
write(dc.b, mapping.top);
40+
write(nybble, 0);
41+
// size
42+
write(2, mapping.width - 1);
43+
write(2, mapping.height - 1);
44+
// 1 player
45+
write(1, mapping.priority);
46+
write(2, mapping.palette);
47+
write(1, mapping.vflip);
48+
write(1, mapping.hflip);
49+
write(11, mapping.art);
50+
// left
51+
write(dc.w, mapping.left);
52+
};
5253
},
5354
],
5455
]);
5556

5657
dplcs([
5758
offsetTable(dc.w),
5859
[
59-
({ mapping, ref }, i) => {
60-
if (i === 0) {
61-
ref.quantity = read(dc.w);
62-
if (ref.quantity === 0) return skipFrame;
63-
}
64-
mapping.size = read(nybble) + 1;
65-
mapping.art = read(nybble * 3);
66-
if (i === ref.quantity - 1) return endFrame;
60+
() => {
61+
const quantity = read(dc.w);
62+
return quantity > 0 && (({ mapping }, frameIndex) => {
63+
mapping.size = read(nybble) + 1;
64+
mapping.art = read(nybble * 3);
65+
if (frameIndex === quantity - 1) return endFrame;
66+
});
6767
},
68-
({ mapping, sprite }, i) => {
69-
if (i === 0) write(dc.w, sprite.length);
70-
write(nybble, mapping.size);
71-
write(nybblr * 3, mapping.art);
68+
({ sprite }) => {
69+
write(dc.w, sprite.length);
70+
return ({ mapping }) => {
71+
write(nybble, mapping.size - 1);
72+
write(nybble * 3, mapping.art);
73+
};
7274
},
7375
],
7476
]);

0 commit comments

Comments
 (0)