다마고치 변경할 때 본체 색상도 선택하도록 추가
Paramix Studio / build (push) Canceled after 0s
Paramix Studio / pages (push) Canceled after 0s

This commit is contained in:
syskiller committed 2026-11-11 21:34:16 +09:00
1 parent fda254aa35
commit 63fe0c8d41
35 files changed
+421 -188

No files matched your search

+26 -7
View File
@@ -23,9 +23,22 @@ module.exports=function(s,enc){
s=s.replace(/#define GOLD\s+[^\n]+/,'#define GOLD RGB(157,95,8)').replace(/#define ORANGE\s+[^\n]+/,'#define ORANGE RGB(160,80,12)').replace(/#define PINK\s+[^\n]+/,'#define PINK RGB(176,45,100)');
// Korean native names are also stored as the firmware's u16 glyph codes after the font.
const pos=s.indexOf('static void chr_pick(void){');
const colorNames=["기본색","빨강","분홍","보라","파랑","하늘색","민트","초록","노랑","주황","연분홍","연보라","연하늘","연두","크림","하양","회색"];
const helpers=`static u32 ko_names(void){u32 a=g_cfg.cat_off+12u+40u*g_cfg.cat_n;return rd32(a)==0x31464f4bu?a+8u+13u*rd32(a+4u):0;}
static u32 ko_le32(u32 a){const volatile u8 *p=fl(a);return (u32)p[0]|((u32)p[1]<<8)|((u32)p[2]<<16)|((u32)p[3]<<24);}
static void ko_portrait(u32 k){u32 a=ko_names();if(!a)return;u32 o=ko_le32(a+26u*g_cfg.cat_n+4u*k);if(!o)return;u32 at=g_cfg.cat_off+o,w=32,h=32,sc=2;if(ko_le32(at)==0x3154504bu){w=fl(at+4)[0];h=fl(at+6)[0];at+=8;sc=1;}if(!w||!h||w>64||h>64)return;int left=(128-(int)(w*sc))/2,top=27+(64-(int)(h*sc))/2;for(u32 y=0;y<h;y++)for(u32 x=0;x<w;x++){const volatile u8 *p=fl(at+2u*(y*w+x));u32 c=p[0]|((u32)p[1]<<8);if(c!=0xf81fu)rect(left+x*sc,top+y*sc,left+(x+1)*sc,top+(y+1)*sc,(u16)c);}}
static u32 ko_colors(void){u32 a=ko_names()+34u*g_cfg.cat_n+8u;return ko_le32(a)==0x314b5043u?a+4u:0;}
static const char *ko_color_name(void){static const char *const names[]={${colorNames.map(n=>'"'+enc(n)+'"').join(',')}};return names[g_chr_color+1];}
static void ko_portrait(u32 k){
u32 a=ko_names();if(!a)return;u32 o=ko_le32(a+26u*g_cfg.cat_n+4u*k);if(!o)return;
u32 at=g_cfg.cat_off+o,w=32,h=32,sc=2;if(ko_le32(at)==0x3154504bu){w=fl(at+4)[0];h=fl(at+6)[0];at+=8;sc=1;}
if(!w||!h||w>64||h>64)return;u32 mask=at+2u*w*h,pal=ko_colors();int colored=g_chr_color>=0&&pal&&ko_le32(mask)==0x314b534du;
int left=(128-(int)(w*sc))/2,top=27+(64-(int)(h*sc))/2;
for(u32 y=0;y<h;y++)for(u32 x=0;x<w;x++){u32 n=y*w+x;const volatile u8 *p=fl(at+2u*n);u32 c=p[0]|((u32)p[1]<<8);if(c==0xf81fu)continue;
if(colored){u32 index=(fl(mask+4u+(n>>1))[0]>>((n&1u)*4u))&15u;if(index<8u){p=fl(pal+16u*(u32)g_chr_color+2u*index);c=p[0]|((u32)p[1]<<8);}}
rect(left+x*sc,top+y*sc,left+(x+1)*sc,top+(y+1)*sc,(u16)c);
}
}
`;
s=s.slice(0,pos)+helpers+s.slice(pos);
s=s.replace('static char g_nm[24];','static char g_nm[64];');
@@ -52,12 +65,13 @@ static void ko_row(int y,int selected){rect(5,y+2,123,y+14,RGB(18,96,136));rect(
s=s.replace('fn=fname(f-1u); *col=fcol(f-1u);','fn=fname(f-1u); *col=WHITE;');
const previewStart=s.indexOf(' u32 kk=g_chr[sel]'),previewEnd=s.indexOf(' u32 to=g_cfg.tama_off;',previewStart);
if(previewStart<0||previewEnd<0)throw Error('Character preview not found');
s=s.slice(0,previewStart)+` u32 nw=0,st=0,old=t_id();int accepted=0,back=0;
s=s.slice(0,previewStart)+` u32 nw=0,st=0,old=t_id();int accepted=0,back=0,colorMode=0;
g_chr_color=g_set[g_cfg.tama_off+0x19u]&31u;if(g_chr_color>15)g_chr_color=-1;
while(!accepted&&!back){
u32 kk=g_chr[sel],o=g_cfg.cat_off+8u+28u*kk;nw=rd16(o);st=fl(o+6)[0];
char nm[64];chr_name(kk,nm);rect(0,0,128,128,BG);ko_title(nm,2);ko_portrait(kk);
ctext(93,stage_name(st),GREY,1);ctext(105,"${enc('휠 이전 다음')}",GREY,1);ctext(117,"${enc('B 변경 C 목록')}",GREY,1);show();wait_release();
for(;;){int key=input();if(key==1){int next=(int)sel+g_step;if(next<0)next=0;if(next>=(int)g_chrn)next=(int)g_chrn-1;sel=(u32)next;break;}if(key==K_OK){accepted=1;break;}if(key==K_BACK){back=1;break;}}
ctext(93,ko_color_name(),GREY,1);ctext(105,colorMode?"${enc('휠 색상 A 이동')}":"${enc('휠 이동 A 색상')}",GREY,1);ctext(117,"${enc('B 변경 C 목록')}",GREY,1);show();wait_release();
for(;;){int key=input();if(key==K_A){colorMode=!colorMode;break;}if(key==1){if(colorMode){g_chr_color+=g_step;if(g_chr_color>15)g_chr_color=-1;if(g_chr_color< -1)g_chr_color=15;break;}int next=(int)sel+g_step;if(next<0)next=0;if(next>=(int)g_chrn)next=(int)g_chrn-1;sel=(u32)next;break;}if(key==K_OK){accepted=1;break;}if(key==K_BACK){back=1;break;}}
}
if(!accepted)break;
`+s.slice(previewEnd);
@@ -91,7 +105,7 @@ static u32 count_add(u32 id,u32 owned){
`+s.slice(countEnd);
s=s.replace('count_edit(id, slot<n ? count_get(slot) : 1u, 1u)','count_add(id, slot<n ? count_get(slot) : 0u)');
s=s.replace('u32 v=count_edit(id, slot<n ? count_get(slot) : 1u);\n if(v){','u32 v=count_add(id, slot<n ? count_get(slot) : 0u);\n if(v<16u){');
s=s.replace('static u32 tama_files(u32 old, u32 nw){','static u32 ko_names(void);\nstatic u32 tama_files(u32 old, u32 nw){');
s=s.replace('static u32 tama_files(u32 old, u32 nw){','static int g_chr_color;\nstatic u32 ko_colors(void);\nstatic u32 ko_names(void);\nstatic u32 tama_files(u32 old, u32 nw){');
s=s.replace(' flash_read(a, g_page, PAGE);\n#ifdef FELD_TAMA_ANY',' flash_read(a, g_page, PAGE);\n u32 before=0;for(u32 z=8;z<0x180;z+=4)before+=*(u32*)(g_page+z);\n#ifdef FELD_TAMA_ANY');
s=s.replace(' flash_prog4k(a, g_page); n++;',` if(rd32(a)+rd32(a+4u)==0u){
int k=cat_find(nw);u32 names=ko_names();if(k>=0&&names){for(u32 j=0;j<26;j++)g_page[226u+j]=fl(names+26u*(u32)k+j)[0];g_page[0xfcu]=fl(g_cfg.cat_off+8u+28u*(u32)k+6u)[0];g_page[0xfdu]=0;}
@@ -105,6 +119,7 @@ static u32 count_add(u32 id,u32 owned){
static u32 tama_files(u32 old,u32 nw){
int k=cat_find(nw);u32 names=ko_names();if(k<0||!names)return 0;
u32 tab=names+30u*g_cfg.cat_n;if(ghost_rd32(tab)!=0x314b5047u||ghost_rd32(tab+4u)!=g_cfg.cat_n)return 0;
u32 pal=ko_colors();if(g_chr_color>=0&&!pal)return 0;
u32 rel=ghost_rd32(tab+8u+4u*(u32)k);if(!rel)return 0;u32 src=g_cfg.cat_off+rel,len=ghost_rd32(src+0x10cu);
if(len<0x1d34u||len>0x4000u||src>=g_cfg.user_start||len>g_cfg.user_start-src||ghost_rd32(src+8u)!=1u||(ghost_rd32(src+0x108u)>>16)!=nw||ghost_rd32(src)+ghost_rd32(src+4u)!=0u)return 0;
for(u32 a=g_cfg.user_start;a+0x4000u<=g_cfg.user_end&&a+0x4000u<=SET_A;a+=PAGE){
@@ -112,14 +127,18 @@ static u32 tama_files(u32 old,u32 nw){
u32 n=rd32(a+0x10cu);if(n<0x1d34u||n>0x4000u||rd32(a+0x118u)!=0x1d34u)continue;
// The first native genes slot is the current pet. Never alter later friend slots.
if(rd16(a+0x10au)!=old&&rd16(a+14u)!=old)return 0;
for(u32 off=0;off<0x4000u;off+=PAGE){for(u32 j=0;j<PAGE;j++)g_page[j]=off+j<len?fl(src+off+j)[0]:255u;flash_prog4k(a+off,g_page);}
for(u32 off=0;off<0x4000u;off+=PAGE){for(u32 j=0;j<PAGE;j++)g_page[j]=off+j<len?fl(src+off+j)[0]:255u;if(off==0&&g_chr_color>=0){
u32 before=0;for(u32 q=8;q<0x180;q+=4)before+=*(u32*)(g_page+q);
g_page[16]=(u8)g_chr_color;for(u32 q=0;q<16;q++){u8 v=fl(pal+16u*(u32)g_chr_color+q)[0];g_page[0x140+q]=v;g_page[0x160+q]=v;}
u32 sum=ghost_rd32(src)-before;for(u32 q=8;q<0x180;q+=4)sum+=*(u32*)(g_page+q);*(u32*)g_page=sum;*(u32*)(g_page+4)=0u-sum;
}flash_prog4k(a+off,g_page);}
return 1;
}
return 0;
}
`+s.slice(z);}
s=s.replace('if(old && old!=nw && !tama_files(old, nw))','if(!tama_files(old, nw))');
s=s.replace('g_set[to+0x18u]=(u8)((g_set[to+0x18u]&~0x1Cu)|((st&7u)<<2));','g_set[to+0x18u]=(u8)((g_set[to+0x18u]&~0x1Cu)|((st&7u)<<2));\n g_set[to+0x19u]=(u8)((g_set[to+0x19u]&0xe0u)|31u);');
s=s.replace('g_set[to+0x18u]=(u8)((g_set[to+0x18u]&~0x1Cu)|((st&7u)<<2));','g_set[to+0x18u]=(u8)((g_set[to+0x18u]&~0x1Cu)|((st&7u)<<2));\n g_set[to+0x19u]=(u8)((g_set[to+0x19u]&0xe0u)|(g_chr_color<0?31u:(u32)g_chr_color));');
s=s.replace('RGB(60,60,110)','RGB(205,225,169)').replace('RGB(40,40,70)','BG');
s=s.replace('if(k>=0 && fl(g_cfg.cat_off+8u+28u*(u32)k+2u)[0]==2u){ char t[64]; chr_name((u32)k,t); t[15]=0;', 'if(k>=0 && fl(g_cfg.cat_off+8u+28u*(u32)k+2u)[0]==2u){ char t[64]; chr_name((u32)k,t); int z=0;while(t[z]&&z+(ko_pair(t+z)?2:1)<=14)z+=ko_pair(t+z)?2:1;t[z]=0;');
return s;