다마고치 선택 그림과 실제 외형 및 이름을 일치시킴
This commit is contained in:
1 parent
6ff604302e
commit
fda254aa35
20 files changed
+193
-114
No files matched your search
@@ -0,0 +1,35 @@
|
||||
/* Supply a private ROM and optionally independent native-firmware oracle exports. */
|
||||
const fs=require('fs'),path=require('path'),assert=require('assert/strict');
|
||||
const C=require('../src/core.js'),S=require('../src/saves.js'),F=require('../src/feld.js');
|
||||
const rom=new Uint8Array(fs.readFileSync(process.argv[2])),original=rom.slice(),ctx=C.openRom(rom);
|
||||
const chars=F.characters(rom),save={pages:S.paraFromImage(rom,ctx.editionId),edition:ctx.editionId};
|
||||
const dv=b=>new DataView(b.buffer,b.byteOffset,b.byteLength),u16=(b,a)=>dv(b).getUint16(a,true),u32=(b,a)=>dv(b).getUint32(a,true);
|
||||
const old=S.paraPet(save,ctx.editionId).id;
|
||||
const slot=[...save.pages].sort((a,b)=>a[0]-b[0]).find(([a,b])=>u32(b,8)===1&&u16(b,12)===4017&&u16(b,0x10a)===old&&u32(b,0x118)===0x1d34)[0];
|
||||
let compared=0;
|
||||
for(const c of chars){
|
||||
const ghost=C.characterGhost(rom,c.id,ctx),out=S.paraPetSet(save,ctx.editionId,{id:c.id,stage:c.stage,ghost});
|
||||
assert.equal(S.paraPet(out,ctx.editionId).id,c.id);assert.equal(S.paraPet(out,ctx.editionId).stage,c.stage);
|
||||
const stored=new Uint8Array(0x4000);for(let i=0;i<0x4000;i+=4096)stored.set(out.pages.get(slot+i),i);
|
||||
assert.deepEqual(stored.subarray(0,ghost.length),ghost);assert(stored.subarray(ghost.length).every(v=>v===255));
|
||||
for(const[a,b]of save.pages)if(!(a>=slot&&a<slot+0x4000)&&a!==0xefe000&&a!==0xeff000)assert.deepEqual(out.pages.get(a),b,'Unrelated save changed: '+a.toString(16));
|
||||
// Applying the same character repairs stale palettes and eye/composite data too.
|
||||
assert.deepEqual(S.paraPetSet(out,ctx.editionId,{id:c.id,stage:c.stage,ghost}).pages,out.pages);
|
||||
if(process.argv[3]){const native=fs.readFileSync(path.join(process.argv[3],c.id+'.ghost'));assert.deepEqual(Buffer.from(ghost),native,'Native firmware mismatch: '+c.id);compared++;}
|
||||
}
|
||||
// Another pet with the same ID is not the current pet's appearance cache.
|
||||
const friends=new Map(save.pages),friend=slot+0x4000;
|
||||
for(let i=0;i<0x4000;i+=4096)friends.set(friend+i,save.pages.get(slot+i).slice());
|
||||
const gem=chars.find(c=>c.id===4062),ghost=C.characterGhost(rom,gem.id,ctx);
|
||||
const changed=S.paraPetSet({...save,pages:friends},ctx.editionId,{id:gem.id,stage:gem.stage,ghost});
|
||||
for(let i=0;i<0x4000;i+=4096)assert.deepEqual(changed.pages.get(friend+i),friends.get(friend+i),'Friend data changed');
|
||||
assert.throws(()=>S.paraPetSet(save,ctx.editionId,{id:gem.id}),/appearance/);
|
||||
const def=C.charTable(ctx.files[0]).find(c=>c.id===gem.id);
|
||||
for(const[lang,name,index]of[['ko','한글이',8],['en','GEM TEST',1],['de','BÄRCHEN',3]]){
|
||||
const edited=C.textApply(rom,new Map([[def.name,name]]),lang),g=C.characterGhost(edited,gem.id),enc=lang==='ko'?{...C.TXT_ENC,...C.KO_ENC}:lang==='de'?C.DE_ENC:C.TXT_ENC;
|
||||
for(let i=0;i<name.length;i++)assert.equal(u16(g,18+26*index+2*i),enc[name[i]],lang+' native name');
|
||||
const editedLanguages=lang==='en'?[1,2,3,4,5,6]:[index];
|
||||
for(let i=0;i<9;i++)if(!editedLanguages.includes(i))assert.deepEqual(g.subarray(18+26*i,44+26*i),ghost.subarray(18+26*i,44+26*i),'Other native name changed');
|
||||
}
|
||||
assert.deepEqual(rom,original);
|
||||
console.log(JSON.stringify({passed:true,characters:chars.length,nativeFirmwareComparisons:compared,allNativeNames:true,friendsPreserved:true,sameCharacterRepair:true,deviceWritten:false}));
|
||||
Reference in new issue
Block a user