본체 한글 목록과 아이템 수량 선택
This commit is contained in:
1 parent
b1f7f64142
commit
7d6381f4a4
14 files changed
+2864
-2814
No files matched your search
+51
-50
@@ -1,50 +1,51 @@
|
||||
const fs=require('fs'),assert=require('assert/strict'),path=require('path');
|
||||
const C=require('../src/core.js'),F=require('../src/feld.js'),E=require('../src/emu.js'),S=require('../src/saves.js');require('../src/menu-font-ko.js');
|
||||
const read=p=>new Uint8Array(fs.readFileSync(p)),rom=read(process.argv[2]),ctx=C.openRom(rom),defs=C.charTable(ctx.files[0]);
|
||||
const u32=(b,o)=>new DataView(b.buffer,b.byteOffset,b.byteLength).getUint32(o,true);
|
||||
const ghost=0xDEE000, original=rom.slice(), petId=new DataView(rom.buffer).getUint16(ghost+0x10a,true),def=defs.find(c=>c.id===petId);
|
||||
assert.equal(C.textGet(rom,1,'ko'),'정보');assert.equal(C.textGet(rom,14,'ko'),'육지');
|
||||
assert.equal(C.KO_CHARS.length,2350);
|
||||
assert.throws(()=>C.textClean('힣','ko'),/지원/);
|
||||
const edits=new Map([[14,'한글나라'],[def.name,'한글이']]),out=C.textApply(rom,edits,'ko');
|
||||
assert.equal(C.textGet(out,14,'ko'),'한글나라');assert.equal(C.textGet(out,def.name,'ko'),'한글이');
|
||||
assert.equal(C.textGet(out,14,'en'),C.textGet(rom,14,'en'));
|
||||
assert.deepEqual(rom,original);
|
||||
assert.equal((u32(out,ghost)+u32(out,ghost+4))>>>0,0);
|
||||
let delta=0;for(let i=8;i<0x180;i+=4)delta=(delta+u32(out,ghost+i)-u32(rom,ghost+i))>>>0;
|
||||
assert.equal(u32(out,ghost),(u32(rom,ghost)+delta)>>>0);
|
||||
const decodeName=b=>{let s='';for(let i=0;i<26;i+=2){const k=b[i]|b[i+1]<<8;if(!k)break;s+=C.KO_CHARS[k-481]||'?';}return s;};
|
||||
assert.equal(decodeName(out.subarray(ghost+226,ghost+252)),'한글이');
|
||||
const save={pages:S.paraFromImage(rom,ctx.editionId),edition:ctx.editionId};
|
||||
const newer=S.paraPetSet(save,ctx.editionId,{happy:20,hunger:6});
|
||||
assert.equal(S.paraPet(newer,ctx.editionId).happy,20);
|
||||
assert.throws(()=>S.paraPetSet(save,ctx.editionId,{happy:21}),/범위/);
|
||||
const live=rom.slice();for(const[a,d]of newer.pages)live.set(d,a);
|
||||
async function main(){
|
||||
const changed=new Set([ghost]),base=async()=>({image:live,notes:[],kept:1,protectedSectors:[ghost]});
|
||||
const merged=await S.keepEdits(base,ctx.editionId,new Map([[petId,'한글이']]),{hunger:5},petId)(null,out,changed);
|
||||
const p=S.paraPet({pages:S.paraFromImage(merged.image,ctx.editionId)},ctx.editionId);
|
||||
assert.equal(p.happy,20);assert.equal(p.hunger,5);assert.equal(decodeName(merged.image.subarray(ghost+226,ghost+252)),'한글이');
|
||||
assert(!merged.protectedSectors.includes(ghost));assert(changed.has(ghost));
|
||||
await assert.rejects(()=>S.keepEdits(base,ctx.editionId,null,{hunger:5},9999)(null,out,changed),/다릅니다/);
|
||||
const chars=F.characters(out,'ko'),items=F.itemCatalog(out,'ko');
|
||||
assert(chars.length>60);assert(chars.every(c=>/[가-힣]/.test(c.name)));
|
||||
assert(items.filter(c=>/[가-힣]/.test(c.name)).length>=264);
|
||||
assert.equal(items.find(c=>c.id===7059).name,'GASHAPON'); // Official Korean table uses the brand in Latin letters.
|
||||
const emb={feld:read(path.join(__dirname,'../feld/feld-ko.bin')),stub:read(path.join(__dirname,'../feld/stub_feld_tpl.bin'))};
|
||||
const built=F.feldApply(out,{fields:true,bag:true,tama:true,saves:true},null,emb,E);
|
||||
const image=built.rom||built,info=F.feldFind(image,emb.stub);assert(info);assert(Buffer.from(image.subarray(info.off,info.off+0x8000)).includes(Buffer.from('ITOSM_KO_MENU_V1')));
|
||||
const cat=info.catOff,n=u32(image,cat+4),font=cat+12+40*n;assert.equal(u32(image,font),0x31464f4b);
|
||||
assert.equal(u32(image,font+4),2527);
|
||||
const names=font+8+13*2527;let portraits=0;
|
||||
for(let i=0;i<n;i++)if(u32(image,names+26*n+4*i))portraits++;
|
||||
assert(portraits>=60,'Character pictures missing: '+portraits);
|
||||
const stripped=F.feldStrip(image,emb,E);assert(stripped.subarray(cat,cat+4096).every(b=>b===255));
|
||||
assert.deepEqual(stripped.subarray(0xD49000),out.subarray(0xD49000),'Menu removal changed device saves');
|
||||
const rebuilt=F.feldApply(stripped,{fields:true,bag:true,tama:true,saves:true},null,emb,E);assert.deepEqual(rebuilt,image,'Menu rebuild round trip');
|
||||
const fieldsOnly=F.feldApply(out,{fields:true},null,emb,E),fo=F.feldFind(fieldsOnly,emb.stub);
|
||||
assert(F.feldStrip(fieldsOnly,emb,E).subarray(fo.catOff,fo.catOff+4096).every(b=>b===255),'Font-only catalog removal');
|
||||
if(process.argv[3]){fs.writeFileSync(process.argv[3],image);fs.writeFileSync(process.argv[3]+'.json',JSON.stringify(info));}
|
||||
console.log(JSON.stringify({passed:true,characters:chars.length,items:items.length,portraits,menuBytes:emb.feld.length,keptLatestHappiness:p.happy,physicalDevice:false}));
|
||||
}
|
||||
main().catch(e=>{console.error(e);process.exit(1);});
|
||||
const fs=require('fs'),assert=require('assert/strict'),path=require('path');
|
||||
const C=require('../src/core.js'),F=require('../src/feld.js'),E=require('../src/emu.js'),S=require('../src/saves.js');require('../src/menu-font-ko.js');
|
||||
const read=p=>new Uint8Array(fs.readFileSync(p)),rom=read(process.argv[2]),ctx=C.openRom(rom),defs=C.charTable(ctx.files[0]);
|
||||
const u32=(b,o)=>new DataView(b.buffer,b.byteOffset,b.byteLength).getUint32(o,true);
|
||||
const ghost=0xDEE000, original=rom.slice(), petId=new DataView(rom.buffer).getUint16(ghost+0x10a,true),def=defs.find(c=>c.id===petId);
|
||||
assert.equal(C.textGet(rom,1,'ko'),'정보');assert.equal(C.textGet(rom,14,'ko'),'육지');
|
||||
assert.equal(C.KO_CHARS.length,2350);
|
||||
assert.throws(()=>C.textClean('힣','ko'),/지원/);
|
||||
const edits=new Map([[14,'한글나라'],[def.name,'한글이']]),out=C.textApply(rom,edits,'ko');
|
||||
assert.equal(C.textGet(out,14,'ko'),'한글나라');assert.equal(C.textGet(out,def.name,'ko'),'한글이');
|
||||
assert.equal(C.textGet(out,14,'en'),C.textGet(rom,14,'en'));
|
||||
assert.deepEqual(rom,original);
|
||||
assert.equal((u32(out,ghost)+u32(out,ghost+4))>>>0,0);
|
||||
let delta=0;for(let i=8;i<0x180;i+=4)delta=(delta+u32(out,ghost+i)-u32(rom,ghost+i))>>>0;
|
||||
assert.equal(u32(out,ghost),(u32(rom,ghost)+delta)>>>0);
|
||||
const decodeName=b=>{let s='';for(let i=0;i<26;i+=2){const k=b[i]|b[i+1]<<8;if(!k)break;s+=C.KO_CHARS[k-481]||'?';}return s;};
|
||||
assert.equal(decodeName(out.subarray(ghost+226,ghost+252)),'한글이');
|
||||
const save={pages:S.paraFromImage(rom,ctx.editionId),edition:ctx.editionId};
|
||||
const newer=S.paraPetSet(save,ctx.editionId,{happy:20,hunger:6});
|
||||
assert.equal(S.paraPet(newer,ctx.editionId).happy,20);
|
||||
assert.throws(()=>S.paraPetSet(save,ctx.editionId,{happy:21}),/범위/);
|
||||
const live=rom.slice();for(const[a,d]of newer.pages)live.set(d,a);
|
||||
async function main(){
|
||||
const changed=new Set([ghost]),base=async()=>({image:live,notes:[],kept:1,protectedSectors:[ghost]});
|
||||
const merged=await S.keepEdits(base,ctx.editionId,new Map([[petId,'한글이']]),{hunger:5},petId)(null,out,changed);
|
||||
const p=S.paraPet({pages:S.paraFromImage(merged.image,ctx.editionId)},ctx.editionId);
|
||||
assert.equal(p.happy,20);assert.equal(p.hunger,5);assert.equal(decodeName(merged.image.subarray(ghost+226,ghost+252)),'한글이');
|
||||
assert(!merged.protectedSectors.includes(ghost));assert(changed.has(ghost));
|
||||
await assert.rejects(()=>S.keepEdits(base,ctx.editionId,null,{hunger:5},9999)(null,out,changed),/다릅니다/);
|
||||
const chars=F.characters(out,'ko'),items=F.itemCatalog(out,'ko');
|
||||
assert(chars.length>60);assert(chars.every(c=>/[가-힣]/.test(c.name)));
|
||||
assert(items.filter(c=>/[가-힣]/.test(c.name)).length>=264);
|
||||
assert.equal(items.find(c=>c.id===7059).name,'GASHAPON'); // Official Korean table uses the brand in Latin letters.
|
||||
const emb={feld:read(path.join(__dirname,'../feld/feld-ko.bin')),stub:read(path.join(__dirname,'../feld/stub_feld_tpl.bin'))};
|
||||
const built=F.feldApply(out,{fields:true,bag:true,tama:true,saves:true},null,emb,E);
|
||||
const image=built.rom||built,info=F.feldFind(image,emb.stub);assert(info);assert(Buffer.from(image.subarray(info.off,info.off+0x8000)).includes(Buffer.from('ITOSM_KO_MENU_V1')));
|
||||
const cat=info.catOff,n=u32(image,cat+4),font=cat+12+40*n;assert.equal(u32(image,font),0x31464f4b);
|
||||
const glyphCount=globalThis.ParamixKoreanMenu.fixed.length+C.KO_CHARS.length;
|
||||
assert.equal(u32(image,font+4),glyphCount);
|
||||
const names=font+8+13*glyphCount;let portraits=0;
|
||||
for(let i=0;i<n;i++)if(u32(image,names+26*n+4*i))portraits++;
|
||||
assert(portraits>=60,'Character pictures missing: '+portraits);
|
||||
const stripped=F.feldStrip(image,emb,E);assert(stripped.subarray(cat,cat+4096).every(b=>b===255));
|
||||
assert.deepEqual(stripped.subarray(0xD49000),out.subarray(0xD49000),'Menu removal changed device saves');
|
||||
const rebuilt=F.feldApply(stripped,{fields:true,bag:true,tama:true,saves:true},null,emb,E);assert.deepEqual(rebuilt,image,'Menu rebuild round trip');
|
||||
const fieldsOnly=F.feldApply(out,{fields:true},null,emb,E),fo=F.feldFind(fieldsOnly,emb.stub);
|
||||
assert(F.feldStrip(fieldsOnly,emb,E).subarray(fo.catOff,fo.catOff+4096).every(b=>b===255),'Font-only catalog removal');
|
||||
if(process.argv[3]){fs.writeFileSync(process.argv[3],image);fs.writeFileSync(process.argv[3]+'.json',JSON.stringify(info));}
|
||||
console.log(JSON.stringify({passed:true,characters:chars.length,items:items.length,portraits,menuBytes:emb.feld.length,keptLatestHappiness:p.happy,physicalDevice:false}));
|
||||
}
|
||||
main().catch(e=>{console.error(e);process.exit(1);});
|
||||
Reference in new issue
Block a user