다마고치 선택 그림과 실제 외형 및 이름을 일치시킴
Paramix Studio / build (push) Canceled after 0s
Paramix Studio / pages (push) Canceled after 0s

This commit is contained in:
syskiller committed 2026-11-11 20:37:50 +09:00
1 parent 6ff604302e
commit fda254aa35
20 files changed
+193 -114

No files matched your search

+2 -2
View File
@@ -4424,10 +4424,10 @@ $('btnPetSave').onclick = () => {
if (!petSave) return;
const ed = petSave.edition, pet = SV.paraPet(petSave, ed), ch = {};
const lv = +$('petLevel').value; if (lv !== pet.level) ch.level = lv;
const v = $('petChar').value; if (v) { const [id, st] = v.split(':').map(Number); if (id !== pet.id || st !== pet.stage) { ch.id = id; ch.stage = st; } }
const v = $('petChar').value; if (v) { const [id, st] = v.split(':').map(Number); ch.id = id; ch.stage = st; }
for(const [key,id]of [['hunger','petHunger'],['happy','petHappy']]){const v=Number($(id).value);if(!$(id).checkValidity()){ $(id).reportValidity();return;}if(v!==pet[key])ch[key]=v;}
if($('petHealth').value==='0' && pet.sick)ch.sick=0;
if(ch.id){const def=C.charTable(state.ctx.files[0]).find(c=>c.id===ch.id);if(def)ch.koreanName=C.textGet(state.ctx.rom,def.name,'ko');}
if(ch.id)ch.ghost=C.characterGhost(state.ctx.rom,ch.id,state.ctx);
if ($('petCare').checked) ch.care = true;
if (!Object.keys(ch).length) { toast(t('petNothing')); return; }
if (petFromRom) {
+26 -1
View File
@@ -1166,6 +1166,31 @@ function charTable(dp) {
}
return [];
}
// Rebuild the current pet's native genes package from this ROM. The firmware
// caches palettes and eye sprites separately from the two character IDs.
// Native current-pet genes: nine names, two palettes, 54 five-layer frames and
// large/small eye sprites. Header-only ID changes retain the previous pet's look.
// Layout and checksum are checked against independent firmware-generated exports.
function characterGhost(rom,id,ctx=null,texts=null){
ctx=ctx||openRom(rom);texts=texts||textTablesOf(rom);const dp=ctx.files[0],table=i=>u32(dp,i*4)*2;
let rec=null;for(let o=table(11);o<table(12);o+=30)if(u16(dp,o)===id){rec=Array.from({length:15},(_,k)=>u16(dp,o+2*k));break;}
if(!rec)throw Error('Character definition is missing');
const chars=charTable(dp).filter(c=>c.id>1000&&c.id<9000),body=ctx.groups[chars.findIndex(c=>c.id===id)+1];
if(body===undefined)throw Error('Character sprites are missing');
const eye=ctx.entries[body+1],small=ctx.entries[body+4],align=n=>(n+3)&~3;
const out=new Uint8Array(0x1d34+align(eye.length)+align(small.length));
if(out.length>0x4000)throw Error('Character genes exceed the native slot');
w32(out,8,1);w16(out,12,4017);w16(out,14,id);out[16]=Math.min(15,rec[14]);
w16(out,0xfc,rec[3]);w16(out,0xfe,rec[5]);w16(out,0x100,rec[7]);w16(out,0x102,rec[8]);w16(out,0x10a,id);w32(out,0x10c,out.length);
for(let lang=0;lang<9;lang++){const t=texts.tabs[lang],index=rec[2]+1;if(!t||index>=t.n)throw Error('Native name table is missing');const start=t.offs[index]*2,end=index+1<t.n?t.offs[index+1]*2:t.b.length;let n=0;for(let i=start;i+1<end&&n<12;i+=2){const c=u16(t.b,i);if(c===0||c===0xf000)break;w16(out,18+26*lang+2*n++,c);}}
for(const[k,g]of[[0,body],[1,body+2]]){const e=ctx.entries[g],h=spriteHeader(e);out.set(e.subarray(h.palOffset,h.palOffset+32),0x140+32*k);}
const types=[0,1,15,16,17],map=[1,2,6,7,4,3,5,8,9,10,0];
for(let f=0;f<54;f++){const row=table(18)+4*(rec[1]*54+f),first=u16(dp,row),count=u16(dp,row+2);if(first===65535)continue;if(count>32)throw Error('Invalid character frame');
for(let j=0;j<count;j++){let pos=table(15)+u32(dp,table(16)+4*(first+j))*2,mask=u16(dp,pos);pos+=2;const v=[0,0,0,4096,0,64,0,0,0,0,0];for(let bit=0;bit<11;bit++)if(mask&(1<<bit)){v[map[bit]]=u16(dp,pos);pos+=2;}const ti=types.indexOf(v[10]);if(ti<0)continue;if(ti<3&&v[0])v[0]-=body;for(let k=0;k<11;k++)w16(out,0x600+(f*5+ti)*22+2*k,v[k]&65535);}
}
let at=0x1d34;for(const[k,e]of[[1,eye],[4,small]]){w32(out,0x110+8*k,at);w32(out,0x114+8*k,e.length);out.set(e,at);at+=align(e.length);}
let sum=0;for(let i=8;i<0x180;i+=4)sum=(sum+u32(out,i))>>>0;for(let i=0x600;i<out.length;i+=4)sum=(sum+u32(out,i))>>>0;w32(out,0,sum);w32(out,4,-sum>>>0);return out;
}
function fieldSets(ctx) {
const chars = charTable(ctx.files[0]).filter((c) => c.id > 1000 && c.id < 9000);
if (chars.length + 1 !== ctx.groups.length) return [];
@@ -1299,7 +1324,7 @@ function nativePetNames(out,edition,names,language){
return out;
}
root.ParamixCore = { koreanPetNames, paraLayers, faceFirst, facePoses, layersMove, EYE_V2, smaDetect, smaLoad, eyeFirst, eyeRelGet, shiftEyes, textClean, textGet, textApply, textTablesOf, TXT_ENC, DE_ENC, KO_CHARS, KO_ENC,
root.ParamixCore = { characterGhost, koreanPetNames, paraLayers, faceFirst, facePoses, layersMove, EYE_V2, smaDetect, smaLoad, eyeFirst, eyeRelGet, shiftEyes, textClean, textGet, textApply, textTablesOf, TXT_ENC, DE_ENC, KO_CHARS, KO_ENC,
fieldSets, charTable, FIELD_NAMES,
ASSET_BASE, EDITIONS, GROUP_PARTS, GROUP_SHEET_W, GROUP_SHEET_H,
arc2Parse, arc2Files, arc2Build, arc2Checksum, packSplit, packJoin, spriteHeader, spriteDecode, spriteEncode, spriteBlank, spriteTiny, spriteAlign, partOptions, launcherKeep, launcherChanges, isLauncher,
+5 -4
View File
@@ -571,13 +571,13 @@ function charCatalog(d, P, language='en', pictures=false) {
const C = typeof ParamixCore !== 'undefined' ? ParamixCore : (typeof require !== 'undefined' ? require('./core.js') : null);
if (!C) return [];
let ctx; try { ctx = C.openRom(d); } catch (e) { return []; }
const tt = textTabelle(d), out = [];
const tt = textTabelle(d), out = [], ghostTexts=pictures?C.textTablesOf(d):null;
const all=C.charTable(ctx.files[0]).filter(c=>c.id>1000&&c.id<9000);
for (const c of C.charTable(ctx.files[0])) {
if (c.id < 1001 || c.id > 4999 || c.stage < 2 || c.stage > 5) continue;
const nm = (language==='ko'||language==='de' ? C.textGet(d,c.name,language) : tt >= 0 ? zeichenkette(d,tt,c.name) : '') || ('NO. ' + c.id);
const fi = P.names.indexOf(TYPE_NAMES[c.field]);
out.push({ id: c.id, fixed: 2, pic: 0, sum: (c.stage & 255) | ((fi + 1) << 8), at: null, nativeName:C.textGet(d,c.name,language), thumbnail:pictures?portrait(C,ctx,ctx.groups[all.findIndex(v=>v.id===c.id)+1]):null, name: nm.replace(/\s+/g, ' ') });
out.push({ id: c.id, fixed: 2, pic: 0, sum: (c.stage & 255) | ((fi + 1) << 8), at: null, ghost:pictures?C.characterGhost(d,c.id,ctx,ghostTexts):null, nativeName:C.textGet(d,c.name,language), thumbnail:pictures?portrait(C,ctx,ctx.groups[all.findIndex(v=>v.id===c.id)+1]):null, name: nm.replace(/\s+/g, ' ') });
}
return out;
}
@@ -625,10 +625,11 @@ function catalogBlob(cat, korean=false, rom=null, englishPictures=false, german=
const font=korean ? nativeMenuFont(rom) : new Uint8Array(englishPictures?8:0);
if(englishPictures){w32(font,0,0x31545045);}
const encoded=cat.map(c=>korean?globalThis.ParamixKoreanMenu.encode(c.name||('항목 '+c.id),60):(german?(c.name||('NR. '+c.id)):c.name).slice(0,german?60:20));
const base=x+4+12*cat.length+font.length, tails=korean||englishPictures?26*cat.length+4*cat.length+cat.reduce((n,c)=>n+(c.thumbnail?.length||0),0)+(korean||german?encoded.reduce((n,c)=>n+c.length+1,0):0):0;
const base=x+4+12*cat.length+font.length, tails=korean||englishPictures?26*cat.length+4*cat.length+8+4*cat.length+cat.reduce((n,c)=>n+(c.ghost?.length||0),0)+cat.reduce((n,c)=>n+(c.thumbnail?.length||0),0)+(korean||german?encoded.reduce((n,c)=>n+c.length+1,0):0):0;
const b = new Uint8Array(base+tails);
const nameOffsets=[];
if(korean||englishPictures){let pos=base+30*cat.length;cat.forEach((c,i)=>{
if(korean||englishPictures){const gp=base+30*cat.length;w32(b,gp,0x314b5047);w32(b,gp+4,cat.length);let pos=gp+8+4*cat.length;cat.forEach((c,i)=>{
if(c.ghost){w32(b,gp+8+4*i,pos);b.set(c.ghost,pos);pos+=c.ghost.length;}
[...(c.nativeName||c.name)].slice(0,12).forEach((ch,j)=>w16(b,base+i*26+j*2,(german?globalThis.ParamixCore.DE_ENC:globalThis.ParamixCore.TXT_ENC)[ch]??globalThis.ParamixCore.KO_ENC[ch]??0));
if(c.thumbnail){w32(b,base+26*cat.length+i*4,pos);b.set(c.thumbnail,pos);pos+=c.thumbnail.length;}
});if(korean||german)encoded.forEach(n=>{nameOffsets.push(pos);for(const c of n)b[pos++]=c.charCodeAt(0);b[pos++]=0;});
+14 -21
View File
@@ -147,10 +147,9 @@ function paraPet(save, edition) {
return { level: p[o.level] & 15, id: u16(p, t + 4), stage: (p[t + 0x18] >> 2) & 7, hunger: p[t + 0x1C], happy: p[t + 0x1D], sick: p[t + 0x10] };
}
/**
* Changed copy of the save. ch: { level, id, stage, care } (each optional). A new character goes
* into the settings block and into the pet's own file (pages with the old character in the header).
* Changed copy of the save. A character change requires the complete native genes
* package from the ROM. Only the current pet's slot is replaced; friends are preserved.
*/
const TAMA_ANY = true;
function paraPetSet(save, edition, ch) {
const p0 = paraSettings(save), o = PET[family(edition)];
if (!p0 || !o) throw new Error('the save has no settings block');
@@ -160,25 +159,19 @@ function paraPetSet(save, edition, ch) {
if (ch.id) {
p[t + 4] = ch.id & 255; p[t + 5] = ch.id >> 8; p[t + 6] = ch.id & 255; p[t + 7] = ch.id >> 8;
if (ch.stage) p[t + 0x18] = (p[t + 0x18] & ~0x1C) | ((ch.stage & 7) << 2);
let found = 0;
if (old && old !== ch.id) for (const [a, d] of save.pages) {
if (a === SET_A || a === SET_B || d.length !== PAGE) continue;
// 1.7.2 TAMA_ANY: a bred Tama's file was not found (GitHub): small number at +8, character at +0x0C or +0x0E
if (TAMA_ANY ? (u32(d, 8) === 0 || u32(d, 8) > 255 || (u16(d, 14) !== old && u16(d, 12) !== old)) : (u32(d, 8) !== 1 || u16(d, 14) !== old)) continue;
const n = d.slice(); found++;
if (!TAMA_ANY || u16(n, 14) === old) { n[14] = ch.id & 255; n[15] = ch.id >> 8; }
if (u16(n, 12) === old) { n[12] = ch.id & 255; n[13] = ch.id >> 8; }
if (u16(n, 0x10A) === old) { n[0x10A] = ch.id & 255; n[0x10B] = ch.id >> 8; }
if(((u32(d,0)+u32(d,4))>>>0)===0){
const names=ch.koreanName;
if(names){const C=globalThis.ParamixCore; n.fill(0,18+8*26,18+9*26);[...names].slice(0,12).forEach((c,i)=>{const v=C.TXT_ENC[c]??C.KO_ENC[c];n[18+8*26+i*2]=v&255;n[19+8*26+i*2]=v>>8;});}
if(ch.stage){n[0xFC]=ch.stage;n[0xFD]=0;}
let delta=0;for(let i=8;i<0x180;i+=4)delta=(delta+u32(n,i)-u32(d,i))>>>0;
const sum=(u32(d,0)+delta)>>>0;w32(n,0,sum);w32(n,4,-sum>>>0);
}
pages.set(a, n);
const ghost=ch.ghost;
if(!(ghost instanceof Uint8Array)||ghost.length<0x1d34||ghost.length>0x4000||u32(ghost,8)!==1||u16(ghost,0x10a)!==ch.id||u32(ghost,0x10c)!==ghost.length||((u32(ghost,0)+u32(ghost,4))>>>0)!==0)throw Error('Character appearance data is missing or invalid');
let found=false;
for(const [a,d] of [...save.pages].sort((a,b)=>a[0]-b[0])){
if(a===SET_A||a===SET_B||d.length!==PAGE||u32(d,8)!==1||u16(d,12)!==4017||((u32(d,0)+u32(d,4))>>>0)!==0)continue;
const n=u32(d,0x10c);if(n<0x1d34||n>0x4000||u32(d,0x118)!==0x1d34)continue;
if(u16(d,0x10a)!==old&&u16(d,14)!==old)throw Error('Current character genes do not match this save');
for(let i=0;i<0x4000;i+=PAGE){if(a+i>=SET_A||!save.pages.has(a+i))throw Error('Current character slot is incomplete');const pg=new Uint8Array(PAGE);pg.fill(255);pg.set(ghost.subarray(i,i+PAGE));pages.set(a+i,pg);}
found=true;break;
}
if (TAMA_ANY && old && old !== ch.id && !found) throw new Error('the Tama\'s own file is not in the save, the Tama would not change');
if(!found)throw Error('Current character appearance data was not found');
p[t+0x19]=(p[t+0x19]&0xe0)|31;
}
for(const [key,off,max]of [['hunger',0x1C,6],['happy',0x1D,20],['sick',0x10,1]]){
if(ch[key]!==undefined){if(!Number.isInteger(ch[key])||ch[key]<0||ch[key]>max)throw Error('저장 데이터 값의 범위를 확인하세요.');p[t+off]=ch[key];}