From 3e47e77a4f4402c49cbe906a35bd87731efb7862 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 10 Oct 2017 17:51:26 -0400 Subject: [PATCH] add gx decode utility --- js/util-gx.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 js/util-gx.js diff --git a/js/util-gx.js b/js/util-gx.js new file mode 100644 index 00000000..609b3be2 --- /dev/null +++ b/js/util-gx.js @@ -0,0 +1,53 @@ +class GXReader { + constructor(buffer) { + this.buf = buffer; + this.pos = 16; + this.magic = buffer.slice(0,16).toString().trim(); + + console.log({ + magic: this.magic, + bmpoff: this.u32(), + gc1off: this.u32(), + gc2off: this.u32(), + prsecs: this.u32(), + prfila: this.u32(), + unk01: this.u32(), + unk02: this.u16(), + unk03: this.u16(), + unk04: this.u16(), + unk05: this.u16(), + unk06: this.u16(), + unk07: this.u16(), + unk08: this.u16(), + unk09: this.u16(), + unk10: this.u8(), + unk11: this.u8(), + index: this.pos + }); + } + + inc(inc) { + const ret = this.pos; + this.pos += inc; + return ret; + } + + u8() { + return this.buf.readUInt8(this.inc(1)); + } + + u16() { + return this.buf.readUInt16LE(this.inc(2)); + } + + u32() { + return this.buf.readUInt32LE(this.inc(4)); + } + + string() { + + } +} + +const fs = require('fs'); +const gx = new GXReader(fs.readFileSync(process.argv[2]));