Skip to content

Commit 99b7885

Browse files
committed
saving seems to work
1 parent 74117cf commit 99b7885

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

flex2.idea

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ check version in documentation tab (move code)
2626
logo
2727
add flex.json to sonic 2 disassembly
2828
counts for commands (wrap all in doAction, remove doAction from others)
29+
real command modes
2930
search (filter)
3031
have default as logo?
3132
input type = color
@@ -34,5 +35,4 @@ lil-g/gemini
3435
====
3536

3637
object collapse state persistance
37-
when saving asm, use the object name as the label name :D
3838
create new file | newFactory={(path)=>{}}

modules/formats/dplc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export function bufferToDPLCs(buffer, format) {
2525
const dplcOffset = headerOffset + headerSize;
2626
let sprites = [];
2727

28+
// prevent crashes from incorrectly read header
29+
if (dplcQty > 0xFF) return;
30+
2831
for (let i = 0; i < dplcQty; i++) {
2932
// convert each line to a binary string to easily extract properties
3033
const binStr = readBinary(data, dplcOffset + (dplcSize * i), dplcSize);

modules/formats/mapping.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ export function bufferToMappings(buffer, format) {
2424

2525
const mappingQty = readN(data, headerOffset, headerSize);
2626
const mappingOffset = headerOffset + headerSize;
27+
2728
let sprites = [];
2829

30+
if (mappingQty > 0xFF) return; // prevent crashes
31+
2932
for (let i = 0; i < mappingQty; i++) {
3033
// convert each line to a binary string to easily extract properties
3134
const binStr = readBinary(data, mappingOffset + (mappingSize * i), mappingSize);

modules/formats/util.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export function getHeaders(data) {
2-
let a = 0x7FFF; // ???
2+
// https://github.com/sonicretro/SonLVL/blob/master/SonLVLAPI/LevelData.cs#L1466-L1481
3+
let a = 0x7FFF; // headers are twos complement
34
let headers = [];
4-
for (let i = 0; i < data.length && i != a; i += 2) {
5-
let header = readWord(data, i);
5+
for (let i = 0; i < data.length && i < a; i += 2) {
6+
let header = readWord(data, i) & 0x7FFF;
67
headers.push(header);
78
if (header < a && !(header == 0)) {
89
a = header;

0 commit comments

Comments
 (0)