修正代码的bug

This commit is contained in:
root 2022-12-28 16:30:24 +08:00
parent 817f7a2b1c
commit 2894a7bcea
2 changed files with 8 additions and 3 deletions

Binary file not shown.

View File

@ -116,13 +116,18 @@ const format = roms => {
const getnametable = list => list.reduce( (r,{serial, cheat}, idx, arr) => {
const val = serial.slice(0, -1);
if( val != r[4] ){
if( r[1].length > 0 && r[2] - r[1].at(-1) > r[3] )
r[3] = r[2] - r[1].at(-1);
r[0] = concat( r[0], enc.encode(val) )
r[1] = concat( r[1], [ r[2] ] );
r[4] = val;
}
if( cheat.length > r[3] ) r[3] = cheat.length;
r[2] = r[2] + cheat.length;
if( idx+1 == arr.length ) r[1] = concat( r[1], [ r[2] ] );
if( idx+1 == arr.length ) {
if( r[2] - r[1].at(-1) > r[3] )
r[3] = r[2] - r[1].at(-1);
r[1] = concat( r[1], [ r[2] ] );
}
return r;
}, [new Uint8Array(), new Uint16Array(), 0, 0, ""] );
@ -139,7 +144,7 @@ const format = roms => {
const [sers, offs, chtc, maxl] = getnametable( valid );
const [cheats, expanded] = expandcheat( valid, 8+sers.length+offs.length*2+chtc*8 );
console.info( `name: ${sers.length} cheats: ${chtc}` );
console.info( `name: ${sers.length} cheats: ${chtc} maxl: ${maxl}` );
const serialbase = 8;
const offsetbase = serialbase + sers.length;