Add collection and mission editing with automatic menu language
Paramix Studio / build (push) Canceled after 0s
Paramix Studio / pages (push) Canceled after 0s

This commit is contained in:
syskiller committed 2026-11-10 22:15:03 +09:00
1 parent 7d6381f4a4
commit 50db173a69
11 files changed
+233 -12

No files matched your search

+58 -5
View File
@@ -948,10 +948,10 @@ T.ko = {
"fl_noteEdKept": "기기({d})와 새 ROM({r})은 같은 펌웨어를 사용합니다. 기기의 저장 데이터와 지역({d})을 유지합니다",
"fl_noteEmu": "TamaEmu 펌웨어를 새로 선택해 초기 상태로 시작합니다. 업데이트만 하려면 기존 ROM을 열고 저장하세요",
"menuKo": "본체 A+C 메뉴를 한국어로 만들기",
"menuKoHint": "A+C 메뉴의 화면과 다마고치 및 아이템 이름을 한국어로 표시합니다."
"menuKoHint": "홈페이지가 한국어이면 한국어 메뉴를 자동 선택합니다. EN을 선택하면 영어 메뉴로 바뀝니다. 다마고치 및 아이템 이름을 한국어로 표시합니다."
};
T.en.menuKo="Korean A+C device menu";
T.en.menuKoHint="Experimental Korean device menu: PC preview and build checks only; hardware, save and restore are not yet verified. Back up your ROM and saves before applying. Original game, emulator settings and names read from your ROM remain unchanged.";
T.en.menuKoHint="The device menu follows the website language: Korean for 한국어 and English for EN.";
T.de.menuKo=T.en.menuKo;T.de.menuKoHint=T.en.menuKoHint;
/* ITOSM_KO_END */
let lang = 'de';
@@ -1142,6 +1142,8 @@ function em(x) {
return s;
}
function applyLang() {
const menuKo = lang === "ko";
if ($('menuKo').checked !== menuKo) { $('menuKo').checked = menuKo; if (state.ctx) state.feldStale = true; }
document.documentElement.lang = lang;
document.querySelectorAll('[data-t]').forEach(el => { el.textContent = t(el.dataset.t); });
document.querySelectorAll('[data-lang]').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.lang === lang)));
@@ -1231,7 +1233,8 @@ async function loadRom(file) {
{ const c = E.emuNfcGet(buf); state.emuNfc = c === null ? true : c; }
state.emuOpt = E.emuOptGet(buf) || { vol: 0, dim: 0, off: 0 };
if(!clean && lang==='ko')for(const it of F.itemCatalog(buf,'ko'))if(it.name==='GASHAPON'){state.texts.set(it.text,'가샤폰');state.textLanguage='ko';}
$('menuKo').checked = F.koreanMenu(buf) || lang==='ko';
$('menuKo').checked = lang==='ko';
state.progressChanges=null; petSave=null; $('petRow').hidden=true; $('progressStatus').textContent='';
{ const fe = F.embedded(), f = fe && F.feldFind(buf, fe.stub);
state.feld = !!(f && (f.flags & F.F_FIELDS)); state.bag = !!(f && (f.flags & F.F_BAG)); state.tama = !!(f && (f.flags & F.F_TAMA)); state.gplay = !!(f && (f.flags & F.F_GPLAY)); state.saves = true;
state.feldInit = state.feld; state.bagInit = state.bag; state.tamaInit = state.tama; state.gplayInit = state.gplay; state.savesInit = true;
@@ -3883,7 +3886,7 @@ $('btnWrite').onclick = async () => {
if(plan && !cleanNew){
const names=new Map();
if(state.texts?.size && (state.textLanguage||lang)==='ko')for(const def of C.charTable(state.ctx.files[0]))if(state.texts.has(def.name))names.set(def.id,C.textGet(c.rom,def.name,'ko'));
if(names.size || state.petChanges)plan=SV.keepEdits(plan,state.ctx.editionId,names,state.petChanges,state.petOriginalId);
if(names.size || state.petChanges || state.progressChanges)plan=SV.keepEdits(plan,state.ctx.editionId,names,state.petChanges,state.petOriginalId,state.progressChanges);
}
let img = c.rom;
if (!cleanNew && F.emuType(img) === 't7') { const ck = await dv.d.clockRead(); if (ck && (ck.ctrl & 0x80)) img = E.t7Wall(img, ck.counter, new Date()); }
@@ -4041,6 +4044,7 @@ function saveFor() { const v = $('saveFor').value; return v === 'm' || v === ''
function saveProg() { const v = $('saveFor').value; return savePrograms().find((p) => String(p.key) === v) || null; }
function renderSave() {
if (!state.ctx) return;
renderProgress();
const ps = savePrograms(), sel = $('saveFor'), cur = sel.value;
sel.innerHTML = '';
for (const p of ps) { const o = document.createElement('option'); o.value = String(p.key); o.textContent = p.name + (p.key === 'm' ? ' (' + t('progIsMain') + ')' : ''); sel.appendChild(o); }
@@ -4253,7 +4257,7 @@ $('btnPetSave').onclick = () => {
for (const [a, d] of nw.pages) if (d.length === 0x1000) r.set(d, a);
if(!state.petChanges)state.petOriginalId=pet.id;state.petChanges={...state.petChanges,...ch};
state.ctx.rom = r; state.petDirty = true; petSave = nw; petSave.edition = ed;
$('petStat').textContent = t('petRomDone'); renderPlan(); return;
$('petStat').textContent = t('petRomDone'); renderPlan(); renderProgress(); return;
}
const out = SV.paraWrite(SV.paraPetSet(petSave, ed, ch), ed);
const name = petName.replace(/\.tamasave$/i, '') + '-' + stamp() + '.tamasave';
@@ -4435,6 +4439,55 @@ function slotWrite(save, chk, i, warn) {
}
window.addEventListener('beforeunload', (e) => { if (window.TamaArchive.hasPending() || (state.ctx && state.changed.size && state.saved !== state.changed.size)) { e.preventDefault(); e.returnValue = t('leave'); } });
// Book and mission progress in the currently loaded ROM.
const progressWords={
ko:{title:'도감·미션',help:'현재 ROM의 저장 데이터를 변경합니다. 적용 후 새 ROM 저장으로 파일을 보관하세요. 미션 보상은 본체의 미션 화면에서 받을 수 있습니다.',unsupported:'이 ROM은 도감·미션 편집을 지원하지 않습니다.',search:'이름 검색',book:'다마고치 도감',mission:'미션',bookSelected:'선택한 도감 등록',bookAll:'전체 도감 등록',missionSelected:'선택한 미션 완료',missionAll:'전체 미션 완료',registered:'등록됨',done:'완료',claimed:'보상 받음',none:'적용할 항목을 선택하세요.',saved:'적용했습니다. 새 ROM 저장으로 파일을 보관하세요.'},
en:{title:'Collection and missions',help:'Changes the save in the loaded ROM. Save the new ROM after applying. Claim mission rewards on the device.',unsupported:'Collection and mission editing is not supported for this ROM.',search:'Search names',book:'Tamagotchi collection',mission:'Missions',bookSelected:'Register selected',bookAll:'Register all characters',missionSelected:'Complete selected',missionAll:'Complete all missions',registered:'Registered',done:'Complete',claimed:'Reward claimed',none:'Select an entry to apply.',saved:'Applied. Save the new ROM to keep these changes.'},
de:{title:'Sammlung und Missionen',help:'Ändert den Spielstand im geladenen ROM. Danach das neue ROM speichern. Missionsbelohnungen am Gerät abholen.',unsupported:'Sammlung und Missionen werden für dieses ROM nicht unterstützt.',search:'Namen suchen',book:'Tamagotchi-Sammlung',mission:'Missionen',bookSelected:'Auswahl registrieren',bookAll:'Alle registrieren',missionSelected:'Auswahl abschließen',missionAll:'Alle Missionen abschließen',registered:'Registriert',done:'Abgeschlossen',claimed:'Belohnung erhalten',none:'Bitte einen Eintrag auswählen.',saved:'Angewendet. Das neue ROM speichern.'}
};
function progressContext(){
if(!state.ctx)return null;
const P=window.ParamixProgress,ed=state.ctx.editionId,info=P.profile(state.ctx.rom,ed,lang);if(!info)return null;
const save={pages:SV.paraFromImage(state.ctx.rom,ed),edition:ed};return {P,info,save,data:P.read(save,info)};
}
function progressFilter(){const q=$('progressFind').value.trim().toLocaleLowerCase();document.querySelectorAll('[data-progress-name]').forEach(row=>{row.hidden=!!q&&!row.dataset.progressName.includes(q);});}
function renderProgress(){
const w=progressWords[lang]||progressWords.en;$('progressTitle').textContent=w.title;$('progressFindLabel').textContent=w.search;
let ctx;try{ctx=progressContext();}catch(e){$('progressControls').hidden=true;$('progressHelp').textContent=em(e);return;}
$('progressControls').hidden=!ctx;$('progressHelp').textContent=ctx?w.help:w.unsupported;if(!ctx)return;
for(const [kind,part,rows]of [['book','Book',ctx.data.book],['mission','Mission',ctx.data.missions]]){
$( 'progress'+part+'Title').textContent=w[kind]+' '+rows.filter(x=>x.done).length+' / '+rows.length;
$( 'progress'+part+'Selected').textContent=w[kind+'Selected'];$( 'progress'+part+'All').textContent=w[kind+'All'];
const list=$('progress'+part+'List');list.replaceChildren();
for(const row of rows){const label=document.createElement('label'),input=document.createElement('input'),span=document.createElement('span');
label.className='check';label.dataset.progressName=(row.name+' '+(row.field||'')).toLocaleLowerCase();
input.type='checkbox';input.value=String(row.id);input.checked=row.done;input.disabled=row.done;input.dataset.progressKind=kind;
span.textContent=row.name+(row.field?' · '+row.field:'')+(row.done?' · '+(kind==='book'?w.registered:row.claimed?w.claimed:w.done):'');
label.append(input,span);list.append(label);
}
$('progress'+part+'All').disabled=rows.every(x=>x.done);
}
progressFilter();
}
function applyProgress(kind,all){
const w=progressWords[lang]||progressWords.en;
try{
const ctx=progressContext();if(!ctx)throw Error(w.unsupported);const rows=kind==='book'?ctx.data.book:ctx.data.missions;
const ids=all?rows.filter(x=>!x.done).map(x=>x.id):[...document.querySelectorAll('[data-progress-kind="'+kind+'"]:checked:not(:disabled)')].map(x=>Number(x.value));
if(!ids.length){$('progressStatus').textContent=w.none;return;}
const key=kind==='book'?'book':'missions',change={[key]:ids},next=ctx.P.apply(ctx.save,ctx.info,change),rom=state.ctx.rom.slice();
for(const a of [0xefe000,0xeff000])rom.set(next.pages.get(a),a);
state.ctx.rom=rom;state.petDirty=true;state.progressChanges=state.progressChanges||{book:[],missions:[]};
state.progressChanges[key]=[...new Set([...state.progressChanges[key],...ids])];
if(petSave&&petFromRom)petSave={...petSave,pages:SV.paraFromImage(rom,ctx.info.edition)};
renderProgress();renderPlan();$('progressStatus').textContent=w.saved;
}catch(e){$('progressStatus').textContent=em(e);}
}
$('progressFind').oninput=progressFilter;
for(const [kind,part]of [['book','Book'],['mission','Mission']]){
$('progress'+part+'Selected').onclick=()=>applyProgress(kind,false);$('progress'+part+'All').onclick=()=>applyProgress(kind,true);
}
applyLang(); devRender();
window.__paramix = state; // for tests
})();
+16
View File
@@ -637,6 +637,22 @@ html:not([data-feature-consoles="on"]) [data-feature="consoles"]{display:none!im
<button class="btn small" id="btnPetClose" data-t="petClose"></button>
</div>
<p class="emustat" id="petStat"></p>
<section id="progressEditor">
<h3 class="savesec" id="progressTitle"></h3>
<p class="hint" id="progressHelp"></p>
<div id="progressControls" hidden>
<label><span id="progressFindLabel"></span> <input type="search" id="progressFind"></label>
<details open><summary id="progressBookTitle"></summary>
<div class="tools"><button class="btn small" id="progressBookSelected"></button><button class="btn small" id="progressBookAll"></button></div>
<div id="progressBookList" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px;max-height:320px;overflow:auto;padding:10px 0"></div>
</details>
<details open><summary id="progressMissionTitle"></summary>
<div class="tools"><button class="btn small" id="progressMissionSelected"></button><button class="btn small" id="progressMissionAll"></button></div>
<div id="progressMissionList" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:8px;max-height:320px;overflow:auto;padding:10px 0"></div>
</details>
</div>
<p class="emustat" id="progressStatus" role="status"></p>
</section>
</div>
<div class="pane" id="pane-feld" hidden>
<div class="tools" data-feature="standalone">
+46
View File
@@ -0,0 +1,46 @@
/* Paradise progress flags. Only audited firmware layouts are accepted.
* The Jade RAM payload starts four bytes after the settings page CRC pair.
* Book getter 0x100046d0: payload + 0x84 + field*4.
* Mission getter/setter 0x10021b08/0x10021be8: payload + 0xe8.
* Seen and reward-claimed bits are deliberately preserved.
*/
(function(root){
'use strict';
const S=root.ParamixSaves, C=root.ParamixCore;
const u16=(b,o)=>b[o]|b[o+1]<<8;
const u32=(b,o)=>(b[o]|b[o+1]<<8|b[o+2]<<16|b[o+3]<<24)>>>0;
function w32(b,o,v){for(let i=0;i<4;i++)b[o+i]=(v>>>(8*i))&255;}
function profile(rom,edition,language='ko'){
if(edition!==4||rom.length!==0x1000000)return null;
if(S.crc16arc(rom,0x1562c,0x15898)!==12062||S.crc16arc(rom,0x32ac8,0x32ca8)!==18931)return null;
const chars=new Map(root.ParamixFeld.characters(rom,language).map(x=>[x.id,x]));
const book=[],seen=new Set();
for(let g=0;g<3;g++){
const t=0x9a998+g*8,p=u32(rom,t)-0x10000000+0x11000,n=u32(rom,t+4);
if(n!==22||p<0x11000||p+2*n>0x110000)return null;
for(let i=0;i<n;i++){
const id=u16(rom,p+2*i),c=chars.get(id);if(!c||seen.has(id))return null;seen.add(id);
book.push({id,name:c.name,field:C.textGet(rom,14+g,language),offset:0x88+4*g,bit:i});
}
}
return {edition:4,book,missions:Array.from({length:22},(_,id)=>({id,name:C.textGet(rom,166+id,language)}))};
}
function settings(save){
for(const a of [0xefe000,0xeff000]){const p=save.pages.get(a);if(p&&p.length===4096&&S.settingsOk(p))return p;}
throw Error('저장 데이터를 읽을 수 없습니다.');
}
function read(save,info){
if(!info||save.edition!==info.edition)throw Error('지원하지 않는 도감·미션 저장 데이터입니다.');
const p=settings(save);
return {book:info.book.map(x=>({...x,done:!!(u32(p,x.offset)&(1<<x.bit))})),missions:info.missions.map(x=>({...x,done:!!(u32(p,0xec)&(1<<x.id)),claimed:!!(u32(p,0xf4)&(1<<x.id))}))};
}
function apply(save,info,change){
if(!info||save.edition!==info.edition)throw Error('지원하지 않는 도감·미션 저장 데이터입니다.');
const p=settings(save).slice(),books=new Map(info.book.map(x=>[x.id,x]));
for(const id of change.book||[]){const x=books.get(id);if(!x)throw Error('도감 항목이 올바르지 않습니다.');w32(p,x.offset,u32(p,x.offset)|(1<<x.bit));}
for(const id of change.missions||[]){if(!Number.isInteger(id)||id<0||id>=22)throw Error('미션 항목이 올바르지 않습니다.');w32(p,0xec,u32(p,0xec)|(1<<id));}
const crc=S.crc16arc(p,4,4096);p[0]=crc&255;p[1]=crc>>>8;p[2]=(~crc)&255;p[3]=((~crc)>>>8)&255;
const pages=new Map(save.pages);pages.set(0xefe000,p);pages.set(0xeff000,p.slice());return {...save,pages};
}
root.ParamixProgress={profile,read,apply};if(typeof module!=='undefined')module.exports=root.ParamixProgress;
})(typeof window!=='undefined'?window:globalThis);
+6 -1
View File
@@ -311,7 +311,7 @@ function t7SaveIn(img, save, base = 0xC0000) {
}
/** Merge explicit edits into the writer's freshly preserved device save. */
function keepEdits(base, edition, names, changes, expectedId) {
function keepEdits(base, edition, names, changes, expectedId, progress) {
return async function(dev, image, changed, moves) {
const result=await base(dev,image,changed,moves), before=result.image, out=before.slice();
if(changes && Object.keys(changes).length){
@@ -321,6 +321,11 @@ function keepEdits(base, edition, names, changes, expectedId) {
const next=paraPetSet(save,edition,changes);
for(const [a,d]of next.pages)if(d.length===4096)out.set(d,a);
}
if(progress){
const P=root.ParamixProgress, info=P.profile(out,edition);
const next=P.apply({pages:paraFromImage(out,edition),edition},info,progress);
for(const a of [SET_A,SET_B])out.set(next.pages.get(a),a);
}
if(names && names.size)globalThis.ParamixCore.koreanPetNames(out,edition,names);
const updated=new Set();
for(let a=0;a<out.length;a+=4096){