Skip to content

Instantly share code, notes, and snippets.

@kion-dgl
Created July 5, 2019 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kion-dgl/ec4f22d8c496c20ea723069c9803d7f8 to your computer and use it in GitHub Desktop.
Save kion-dgl/ec4f22d8c496c20ea723069c9803d7f8 to your computer and use it in GitHub Desktop.
A short script that takes an xpdata struct as an argument and attempts to read the fixed float vec3 format for sega saturn
"use strict";
const fs = require("fs");
const fp = fs.readFileSync("hwram.bin");
const xpdata = {
offset: 0x056424,
vlist_offset: 0x60561cc,
vlist_count: 0x000010,
plist_offset: 0x605628c,
plist_count: 0x000009,
attr_offset: 0x6056394,
vntbl: 0x60562d4
};
let ofs = 0x561cc;
for(let i = 0; i < 0x000010; i++) {
let axis = ["x", "y", "z"];
let vec = {};
axis.forEach(key => {
let num = fp.readInt16BE(ofs + 0);
let dec = fp.readUInt16BE(ofs + 2) / 0xffff;
let a = num.toString();
let b = dec.toFixed(3).split(".").pop();
ofs += 4;
vec[key] = a + "." + b;
});
console.log(vec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment