diff --git a/Makefile b/Makefile index 58c2598..0b1cdbd 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ -all: decode recode +all: decode recode recode110 extractbmp makever fixbmpheader decode: recode: +recode110: +extractbmp: +makever: +fixbmpheader: diff --git a/extractbmp.c b/extractbmp.c new file mode 100644 index 0000000..e1fa1df --- /dev/null +++ b/extractbmp.c @@ -0,0 +1,104 @@ +#include +#include +#include + +int main(int argc, char *argv[]) { + FILE *fin,*fout,*iout,*fin1; + typedef struct idx_st { + int start; + int size; + int uncompressed_size; + } idx_type; + + + typedef struct header_st { + int magic; + int count; + int header_size; + int zero1; + int index_start; + int index_size; + int img_start; + int img_size; + int string_start; + int string_size; + } header_type; + + if(argc>2) { + puts("usage: extractbmp [encode]"); + exit(1); + } + int encode=0; + + if(argc==2 && !strcmp(argv[1],"encode")) + encode=1; + fin=fopen("Image.img","rb"); + header_type header; + fread(&header,4,10,fin); + + idx_type index[header.count]; + char fname[256]; + fread(index, sizeof(idx_type), header.count, fin); + printf("%d bitmaps\n", header.count); + int outpos=0; + if(encode) { + iout=fopen("Image1.img","wb"); + fwrite(&header,4,10,iout); + fwrite(index, sizeof(idx_type), header.count, iout); + outpos=sizeof(idx_type)*header.count+sizeof(header_type); + } + for(int i=0;i +#include +#include + +int main(int argc, char *argv[]) { + FILE *fin,*fout; + typedef struct __attribute__((__packed__)) bmp_st { + short sig; + int size; + int reserved; + int offset; + int dib_size; + int width; + int height; + short planes; + short bpp; + int compression; + int img_size; + int xppm; + int yppm; + int cols; + int ccnt; + } bmp_h_type; + + if(argc!=3) { + puts("error"); + exit(1); + } + + fin=fopen(argv[1],"rb"); + fout=fopen(argv[2],"wb"); + + bmp_h_type header; + fread(&header,1,sizeof(header),fin); + + char z[16]; + fread(z,1,16,fin); + + header.size-=16; + header.offset-=16; + header.dib_size-=16; + header.compression=0; + header.xppm=0; + header.yppm=0; + header.cols=0; + header.ccnt=0; + + fwrite(&header,1,sizeof(header),fout); + while(!feof(fin)) { + char c=fgetc(fin); + if(!feof(fin)) + fputc(c,fout); + } +} diff --git a/imageupdate/Image.img b/imageupdate/Image.img new file mode 100644 index 0000000..2c23fd3 Binary files /dev/null and b/imageupdate/Image.img differ diff --git a/imageupdate/PF090JPJPN.LNG b/imageupdate/PF090JPJPN.LNG new file mode 100644 index 0000000..1342b1d Binary files /dev/null and b/imageupdate/PF090JPJPN.LNG differ diff --git a/imageupdate/PF110JPJPN.LNG b/imageupdate/PF110JPJPN.LNG new file mode 100644 index 0000000..7587fcc Binary files /dev/null and b/imageupdate/PF110JPJPN.LNG differ diff --git a/imageupdate/ScriptExec.ini b/imageupdate/ScriptExec.ini new file mode 100644 index 0000000..99af9ed --- /dev/null +++ b/imageupdate/ScriptExec.ini @@ -0,0 +1,24 @@ +COLOR 48 +ECHO +ECHO Language Installer for MRZ99 by Dzo +ECHO +SLEEP 3000 +ERROR OFF +ECHO ON +COPY -c USB\Image.img USER\PRG1\APL\MENU\Image.img +COPY -c USB\Image.img USER\PRG0\APL\MENU\Image.img +COPY -c USB\PF090JPJPN.LNG USER\PRG1\APL\LANGDATA\PF090JPJPN.LNG +COPY -c USB\PF090JPJPN.LNG USER\PRG0\APL\LANGDATA\PF090JPJPN.LNG +COPY -c USB\PF110JPJPN.LNG USER\PRG1\APL\LANGDATA\PF110JPJPN.LNG +COPY -c USB\PF110JPJPN.LNG USER\PRG0\APL\LANGDATA\PF110JPJPN.LNG +COLOR 21 +ECHO +ECHO +ECHO Done +ECHO +ECHO +ECHO +SLEEP 5000 +RESET +ECHO RESET +RESET 1 diff --git a/imageupdate/TESTMODE.KEY b/imageupdate/TESTMODE.KEY new file mode 100644 index 0000000..83fa50d Binary files /dev/null and b/imageupdate/TESTMODE.KEY differ diff --git a/makever.c b/makever.c new file mode 100644 index 0000000..2361ea0 --- /dev/null +++ b/makever.c @@ -0,0 +1,96 @@ +#include +#include +#include + +typedef struct header_st { + int magic; // 0xa55a5aa5 + int len; // len of ver file + int version; + int volume; //1 + int zero1; + int a2c; //2c + int zeros[5]; + int nfiles; //1 + int dirdepth; //1 + char dirname[64]; + int filestoprocess; //1 + char filename[56]; + int file_length; + int file_crc; + int magic1; // 0xa55a5aa5 + int ver_crc; // up to and including magic1 +} header_type; + +void wscpy(char *d, char *s) { + while (*s) { + *d++=*s++; + d++; + } +} +int crc16a(unsigned char * data_p, int len) { + unsigned char x; + unsigned short crc = 0xFFFF; + + while (len--){ + x = crc >> 8 ^ *data_p++; + x ^= x>>4; + crc = (crc << 8) ^ ((unsigned short)(x << 12)) ^ ((unsigned short)(x <<5)) ^ ((unsigned short)x); + } + return crc; +} + + +unsigned short crc16(const unsigned char *data, int len) { + unsigned short crc = 0xFFFF; + int i; + if (len) do { + crc ^= *data++; + for (i=0; i<8; i++) { + if (crc & 1) crc = (crc >> 1) ^ 0x8408; + else crc >>= 1; + } + } while (--len); + return(~crc); +} + + +int main(int argc, char *argv[]) { + + header_type h; + FILE *fin,*fout; + + memset(&h, 0, sizeof(h)); + + char *dir="OPN090"; + char *datfile="NA090OPN.DAT"; + + if(argc>=2) + datfile=argv[1]; + + if(argc>=3) + dir=argv[2]; + + h.magic=0xa55a5aa5; + h.len=sizeof(h); + h.version=0x04000000; + h.volume=1; + h.a2c=0x2c; + h.nfiles=1; + h.dirdepth=1; + wscpy(h.dirname,dir); + h.filestoprocess=1; + wscpy(h.filename,datfile); + fin=fopen(datfile,"rb"); + fseek(fin, 0L, SEEK_END); + h.file_length = ftell(fin); + unsigned char *p=malloc(h.file_length); + rewind(fin); + fread(p,1,h.file_length,fin); + h.file_crc=crc16(p,h.file_length); + h.magic1=0xa55a5aa5; + h.ver_crc=crc16((unsigned char *)&h, h.len-4); + + fout=fopen("NA090OPN.VER","wb"); + fwrite(&h,1,h.len,fout); + fclose(fout); +} diff --git a/recode110.c b/recode110.c new file mode 100644 index 0000000..a49b9be --- /dev/null +++ b/recode110.c @@ -0,0 +1,98 @@ +#include +#include + +void readstring(FILE *f, char *p) { + char c; + c=fgetc(f); + if(c!='\"') + puts("ERRRRRRRR"); + while((c=fgetc(f))!='"' && !feof(f)) + *p++=c; + *p++=0; + while((c=fgetc(f))!=10 && !feof(f)); +} + + +int main(int argc,char *argv[]) { + char data[200000]; + char st[10240]; + FILE *f,*g; + int i; + unsigned *id=(unsigned *) data; + id[0]=0xa55a5aa5; + id[1]=0x01000001; + id[2]=0x39304650; + id[3]=0x45504a30; + id[4]=0; + id[5]=0; + id[6]=0;// len + id[7]=0x40; + id[8]=0;//last + id[9]=0xaaaaaa02; + id[10]=0xaaaaaaaa; + id[11]=0xaaaaaaaa; + id[12]=0xaaaaaaaa; + id[13]=0xaaaaaaaa; + id[14]=0xaaaaaaaa; + id[15]=0xaaaaaaaa; + + g=fopen("translated_110.txt","rb"); + f=fopen("PF110JPJPN.LNG","rb"); + int start=0x40; + unsigned short *idx=(unsigned short *)(data+0x40); + fseek(f,0x40,SEEK_SET); + short nstrings; + int offset=0; + int next=0; + short ch; + fread(&nstrings, 2, 1, f); + nstrings=nstrings-3; + unsigned short *strptr=idx+nstrings; + int off=0x40+(nstrings+3)*2; + int ntrans=0; + for(i=0;i65535) + printf("Error index too large %x\n",(off-0x40)/2); + int j=0; + for(j=0;st[j]!=0;j++) { + data[off++]=st[j]; + data[off++]=0; + } + data[off++]=0; + data[off++]=0; + } + idx[i]=(off-0x40)/2; + id[8]=off; + strcpy(data+off,"RG_VOICE_DATA"); + off+=strlen("RG_VOICE_DATA"); + data[off++]=0xf1; // this looks like a checksum at the end of the file but + data[off++]=0x8d; // it doesn't seem to matter if it's wrong + id[6]=off; + printf("%d strings\n",nstrings); + f=fopen("PF110JPJPN1.LNG","wb"); + fwrite(data,off,1,f); + fclose(f); +} + diff --git a/updatemrz99.zip b/updatemrz99.zip new file mode 100644 index 0000000..a61ced4 Binary files /dev/null and b/updatemrz99.zip differ