idz: Push story geometry down into codecs

Sparsify the data model returned from the repository layer. Different
versions of the game can have drastically different dimensions for the
story data grid, so handling those dimensions is best done in the
encoders themselves.
This commit is contained in:
Tau
2021-02-03 23:43:40 +00:00
committed by Tau
parent 34f10d1fb9
commit 435634a9b2
7 changed files with 83 additions and 40 deletions
+12 -4
View File
@@ -37,14 +37,22 @@ export function loadProfile2(res: LoadProfileResponse) {
}
}
for (let i = 0; i < 9 && i < res.story.rows.length; i++) {
const row = res.story.rows[i];
for (let i = 0; i < 9; i++) {
const row = res.story.rows.get(i);
const rowOffset = 0x0228 + i * 0x26;
for (let j = 0; j < 9 && j < row.cells.length; j++) {
const cell = row.cells[j];
if (row === undefined) {
continue;
}
for (let j = 0; j < 9; j++) {
const cell = row.cells.get(j);
const cellOffset = rowOffset + j * 4;
if (cell === undefined) {
continue;
}
buf.writeUInt16LE(cell.a, cellOffset + 0);
buf.writeUInt16LE(cell.b, cellOffset + 2);
}
+12 -4
View File
@@ -37,14 +37,22 @@ export function loadProfile3(res: LoadProfileResponse) {
// space for story cells, and 27 rows * 19 bytes per row = 513 bytes, which
// is the max that will fit (the final byte of each row is unused).
for (let i = 0; i < 27 && i < res.story.rows.length; i++) {
const row = res.story.rows[i];
for (let i = 0; i < 27; i++) {
const row = res.story.rows.get(i);
const rowOffset = 0x0256 + i * 0x13;
for (let j = 0; j < 9 && j < row.cells.length; j++) {
const cell = row.cells[j];
if (row === undefined) {
continue;
}
for (let j = 0; j < 9; j++) {
const cell = row.cells.get(j);
const cellOffset = rowOffset + j * 2;
if (cell === undefined) {
continue;
}
buf.writeUInt8(cell.a, cellOffset + 0);
buf.writeUInt8(cell.b, cellOffset + 1);
}