Add collection and mission editing with automatic menu language
This commit is contained in:
1 parent
7d6381f4a4
commit
50db173a69
11 files changed
+233
-12
No files matched your search
@@ -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);
|
||||
Reference in new issue
Block a user