다마고치 변경할 때 본체 색상도 선택하도록 추가
This commit is contained in:
1 parent
fda254aa35
commit
63fe0c8d41
35 files changed
+421
-188
No files matched your search
@@ -0,0 +1,25 @@
|
||||
const fs=require('fs'),path=require('path'),assert=require('assert/strict'),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),chars=F.characters(rom),save={pages:S.paraFromImage(rom,ctx.editionId),edition:ctx.editionId};
|
||||
const palette=C.characterColorTable(rom,ctx),u16=(b,o)=>b[o]|b[o+1]<<8;let native=0,pictures=0;
|
||||
assert.equal(palette.length,16);
|
||||
for(const c of chars){
|
||||
const plain=C.characterPortrait(rom,c.id,-1,ctx);
|
||||
const defs=C.charTable(ctx.files[0]).filter(c=>c.id>1000&&c.id<9000),g=ctx.groups[defs.findIndex(v=>v.id===c.id)+1],pose=C.faceFirst(ctx.files[0],g,g+1,g+2),eye=C.spriteDecode(ctx.entries[g+1]).subs[pose.eye.sub];
|
||||
for(let color=0;color<16;color++){
|
||||
const ghost=C.characterGhost(rom,c.id,ctx,null,color),changed=S.paraPetSet(save,ctx.editionId,{id:c.id,stage:c.stage,color,ghost});
|
||||
assert.equal(S.paraPet(changed,ctx.editionId).color,color);assert.deepEqual(S.paraAppearance(changed),ghost);
|
||||
if(process.argv[3]){assert.deepEqual(Buffer.from(ghost),fs.readFileSync(path.join(process.argv[3],c.id+'-'+color+'.ghost')),'Native firmware color mismatch: '+c.id+'/'+color);native++;}
|
||||
const picture=C.characterPortrait(rom,c.id,color,ctx);assert.deepEqual(picture.mask,plain.mask);
|
||||
// Ratchi uses a low eye-palette index too; it must not become the body color.
|
||||
if(c.id===4021){const dx=(plain.w-eye.w)/2+pose.eye.dx,dy=(plain.h-eye.h)/2+pose.eye.dy;for(let y=0;y<eye.h;y++)for(let x=0;x<eye.w;x++){const i=(y*eye.w+x)*4;if(!eye.data[i+3])continue;const k=((y+dy)*plain.w+x+dx)*4;assert.deepEqual(picture.data.subarray(k,k+4),eye.data.subarray(i,i+4),'Inherited eye palette recolored');}}
|
||||
for(let i=0;i<plain.mask.length;i++){const k=i*4,index=plain.mask[i];assert.equal(picture.data[k+3],plain.data[k+3]);if(index<8&&plain.data[k+3]){const rgb=u16(palette[color],index*2),actual=((picture.data[k]>>3)<<11)|((picture.data[k+1]>>2)<<5)|(picture.data[k+2]>>3);assert.equal(actual,rgb);}else assert.deepEqual(picture.data.subarray(k,k+4),plain.data.subarray(k,k+4),'Eye/detail pixel recolored');}
|
||||
pictures++;
|
||||
}
|
||||
}
|
||||
const pet=S.paraPet(save,ctx.editionId),old=S.paraAppearance(save);
|
||||
const yellow=S.paraPetSet(save,ctx.editionId,{color:7,ghost:C.characterGhost(rom,pet.id,ctx,null,7)}),painted=S.paraAppearance(yellow);
|
||||
assert.equal(S.paraPet(yellow,ctx.editionId).id,pet.id);assert.equal(S.paraPet(yellow,ctx.editionId).color,7);
|
||||
assert.deepEqual(painted.subarray(0x600),old.subarray(0x600),'Color-only edit changed inherited eyes or frames');
|
||||
assert.deepEqual(painted.subarray(18,0x140),old.subarray(18,0x140),'Color-only edit changed names or metadata');
|
||||
assert.throws(()=>C.characterGhost(rom,pet.id,ctx,null,16),/color/);assert.throws(()=>C.characterPortrait(rom,pet.id,-2,ctx),/color/);
|
||||
assert.deepEqual(rom,original);console.log(JSON.stringify({passed:true,characters:chars.length,colors:16,nativeComparisons:native,previewCombinations:pictures,colorOnlyPreservesEyes:true}));
|
||||
Reference in new issue
Block a user