mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 22:04:10 +08:00
idxtable和cmdtable的location算错了
This commit is contained in:
parent
2894a7bcea
commit
9e00fb294c
Binary file not shown.
@ -195,10 +195,11 @@ const assembleCheat = (list, dup, hole) => {
|
||||
|
||||
const pack = (entlist, strlist, idxlist, cmdlist, xvalue) => {
|
||||
const align = (n, base) => base * Math.floor( (n+base-1) / base );
|
||||
const strbase = 2 + entlist.length * 4 * 3;
|
||||
const idxbase = strbase + strlist.length;
|
||||
const cmdbase = idxbase + idxlist.length * 2;
|
||||
const size = cmdbase + cmdlist.length*4;
|
||||
const entrysize = entlist[0].buffer.byteLength;
|
||||
const strbase = 2 + entlist.length * entrysize;
|
||||
const idxbase = strbase + strlist.buffer.byteLength;
|
||||
const cmdbase = idxbase + idxlist.buffer.byteLength;
|
||||
const size = cmdbase + cmdlist.buffer.byteLength;;
|
||||
let result = new ArrayBuffer( align(size, 32) );
|
||||
|
||||
// entry count
|
||||
@ -207,7 +208,7 @@ const pack = (entlist, strlist, idxlist, cmdlist, xvalue) => {
|
||||
|
||||
// entry data
|
||||
entlist.forEach( (entry,index) => {
|
||||
let offset = 2 + index*4*3;
|
||||
let offset = 2 + index*entrysize;
|
||||
view.setUint32( offset, entry[0], true );
|
||||
view.setUint32( offset+4, entry[1] + (entry[0] > 0xffff ? cmdbase : idxbase), true );
|
||||
view.setUint32( offset+8, entry[2], true );
|
||||
@ -218,11 +219,11 @@ const pack = (entlist, strlist, idxlist, cmdlist, xvalue) => {
|
||||
strings.set( strlist, 0 );
|
||||
|
||||
// indexes table
|
||||
let indexes = new Uint8Array( result, idxbase, idxlist.length*2 );
|
||||
let indexes = new Uint8Array( result, idxbase, idxlist.buffer.byteLength );
|
||||
indexes.set( new Uint8Array(idxlist.buffer), 0 );
|
||||
|
||||
// instruction table
|
||||
let commands = new Uint8Array( result, cmdbase, cmdlist.length*4 );
|
||||
let commands = new Uint8Array( result, cmdbase, cmdlist.buffer.byteLength );
|
||||
commands.set( new Uint8Array(cmdlist.buffer), 0 );
|
||||
|
||||
return { id: xvalue, bin: new Uint8Array( result ) };
|
||||
@ -288,19 +289,19 @@ const lade = (list, info, order) => {
|
||||
if( list.length == 0 ) return 0;
|
||||
|
||||
if( strtable.length > 0xffff ) throw new RangeError(`string table is too big.`);
|
||||
let ret = idxtable.length;
|
||||
let nt = new Uint16Array( ret + list.length );
|
||||
let ret = idxtable.buffer.byteLength;
|
||||
let nt = new Uint16Array( idxtable.length + list.length );
|
||||
nt.set( idxtable, 0 );
|
||||
nt.set( list, ret );
|
||||
nt.set( list, idxtable.length );
|
||||
idxtable = nt;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const addCommand = list => {
|
||||
let ret = cmdtable.length;
|
||||
let nt = new Uint32Array( ret + list.length );
|
||||
let ret = cmdtable.buffer.byteLength;
|
||||
let nt = new Uint32Array( cmdtable.length + list.length );
|
||||
nt.set( cmdtable, 0 );
|
||||
nt.set( list, ret );
|
||||
nt.set( list, cmdtable.length );
|
||||
cmdtable = nt;
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user