/** Compare the structure of a TP5-made file against one we authored. */ import { readFileSync } from 'node:fs'; function dump(buf, label) { const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength); const ptrs = []; for (let i = 0x200; ; i += 4) { const v = dv.getUint32(i, true); if (v === 0xffffffff) break; ptrs.push(v); } const hx = (a, b) => Buffer.from(buf.subarray(a, b)).toString('hex').replace(/(..)/g, '$1 ').trim(); console.log(`=== ${label} (${buf.length} bytes, ${ptrs.length} destinations)`); console.log(` 0x30..0x48 : ${hx(0x30, 0x48)}`); console.log(` 0x80..0xa0 : ${hx(0x80, 0xa0)}`); console.log(` 0xa0..0xb0 : ${hx(0xa0, 0xb0)}`); for (let r = 0; r < 2 && r < ptrs.length; r++) { const q = ptrs[r]; console.log(` rec${r} name : ${JSON.stringify(String.fromCharCode(...buf.subarray(q, q + 0x10)))}`); console.log(` rec${r} line : ${JSON.stringify(String.fromCharCode(...buf.subarray(q + 0x10, q + 0x20)))}`); console.log(` rec${r} third : ${JSON.stringify(String.fromCharCode(...buf.subarray(q + 0x20, q + 0x30)))}`); console.log(` rec${r} tail : ${hx(q + 0x30, q + 0x60)}`); console.log(` rec${r} tail2 : ${hx(q + 0x60, q + 0x80)}`); } } const a = new Uint8Array(readFileSync(new URL('../samples/EXPRESS 1.td5', import.meta.url))); const b = new Uint8Array(readFileSync(new URL('./authored.td5', import.meta.url))); dump(a, 'TP5 original — works on the controller'); console.log(); dump(b, 'DestoGod, built from scratch');