mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 22:04:10 +08:00
34 lines
879 B
JavaScript
34 lines
879 B
JavaScript
const {readFileSync} = require("fs");
|
|
|
|
const readf24 = c => {
|
|
if( c == 0 ) return 0;
|
|
|
|
const sign = c&(1<<23);
|
|
const e = (c>>16)&0x7f;
|
|
const r = c&0xffff;
|
|
const p = e - 0b111111;
|
|
|
|
let u = 1, t = 0x8000, k=2;
|
|
while( t > 0 ){
|
|
let x = t&r;
|
|
if( x ) u+=1/k;
|
|
t = t>>1;
|
|
k = k * 2;
|
|
}
|
|
|
|
let res = u*Math.pow(2, p);
|
|
return sign ? -res : res;
|
|
}
|
|
|
|
const text = readFileSync("temp").toString("utf-8");
|
|
const arr = text.split("\n").filter( s=>s.includes(",") )
|
|
const lines = arr.map( n => n.split(",").map(d=>parseInt(d, 16) ) );
|
|
for( let param of lines ){
|
|
let a = param[0] >> 8;
|
|
let b = (param[0]&0xff)<<16 | param[1]>>16;
|
|
let c = (param[1]&0xffff)<<8 | param[2]>>24;
|
|
let d = param[2] & 0xffffff;
|
|
// console.log( a.toString(16), b.toString(16), c.toString(16), d.toString(16) );
|
|
console.log( readf24(d), readf24(c), readf24(b), readf24(a) );
|
|
}
|