Created
July 5, 2019 02:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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