int main(int argc, char **argv) { int mini = 0; int i, j; unsigned char k; unsigned short uni; FILE *of; for (i = 1;i < argc;i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'm': /* create isomini.cp only */ mini = 1; break; case 'h': /* help */ case '?': print_usage(); exit(1); break; default: print_usage(); exit(1); break; } } } for (i=0; i < MAX_TABLE_SIZE; i++) iso_table[i] = 0; if (mini) { of = fopen("isomini.cp", "wb"); if (!of) return 1; for (i=1; i<6; i++) { for (j=0; j<128; j++) { k = (unsigned char)j + 128; uni = iso_decode(&k, mini_index[i], 1); writeshort(of, uni); } } fclose(of); } else { of = fopen("iso.cp", "wb"); if (!of) return 1; for (i=1; i<9; i++) { for (j=0; j<128; j++) { k = (unsigned char)j + 128; uni = iso_decode(&k, i, 1); writeshort(of, uni); } } fclose(of); of = fopen("932.cp", "wb"); if (!of) return 1; for (i=0; i < MAX_TABLE_SIZE; i++) writeshort(of, cp932_table[i]); fclose(of); of = fopen("936.cp", "wb"); if (!of) return 1; for (i=0; i < MAX_TABLE_SIZE; i++) writeshort(of, cp936_table[i]); fclose(of); of = fopen("949.cp", "wb"); if (!of) return 1; for (i=0; i < MAX_TABLE_SIZE; i++) writeshort(of, cp949_table[i]); fclose(of); of = fopen("950.cp", "wb"); if (!of) return 1; for (i=0; i < MAX_TABLE_SIZE; i++) writeshort(of, cp950_table[i]); fclose(of); } return 0; }
void zlist_uncompress(OSTask_t *task) { int z; static int cnt=1; static int lastframe=-1; static int firsttime=1; readdata(&zdata,task->m_data_ptr,sizeof(ZData)); if((zdata.m_pic&0x7f000000)!=0 || (zdata.m_q1 &0x7f000000)!=0 || (zdata.m_q2 &0x7f000000)!=0 || (zdata.m_q3 &0x7f000000)!=0 || !zdata.m_pic || !zdata.m_q1 || !zdata.m_q2 || !zdata.m_q3) { print("zelda: JPEG-DCT (buffer %08X, quant %08X) INVALID, ignored.\n", zdata.m_pic,zdata.m_q1,zdata.m_q2,zdata.m_q3); return; } readq(q1,zdata.m_q1); readq(q2,zdata.m_q2); readq(q3,zdata.m_q3); if(firsttime) { firsttime=0; disasm_dumpucode("rspzlist.log", task->m_ucode ,task->ucode_size, task->m_ucode_data,task->ucode_data_size,0x80); logd("RSP microcode/data dumped to RSPZLIST.LOG\n"); } if(st.frames!=lastframe) { print("zelda: JPEG-DCT (buffer %08X, quant %08X %08X %08X)\n", zdata.m_pic,zdata.m_q1,zdata.m_q2,zdata.m_q3); lastframe=st.frames; } for(z=0;z<4;z++) { readshort ((int *)in ,zdata.m_pic+z*768,8*8*2*6); uncompress(); writeshort((int *)out,zdata.m_pic+z*768,16*16*2); } /* if(cnt==1) { FILE *f1; f1=fopen("bgin.dat","wb"); for(z=0;z<3072*2;z+=4) { d=mem_read32(zdata.m_pic+z); d=FLIP32(d); fwrite(&d,1,4,f1); } fclose(f1); } d1=(cnt)+(cnt<<8)+(cnt<<16)+(cnt<<24); d2=d1^-1; for(z=0;z<4;z++) { for(y=0;y<16;y++) for(x=0;x<16;x++) { if(x==0 || y==0 || x==15 || y==15) { mem_write16(zdata.m_pic+z*768+x*2+y*2*16,d1); } } } */ cnt++; }
bool outputstream::writetype <short> (short v) { return writeshort (v); }
bool outputstream::writetype <unsigned short> (unsigned short v) { return writeshort (static_cast <short> (v)); }
bool outputstream::writetext (const string& text, const bool asutf16, const bool writeutf16byteordermark) { if (asutf16) { if (writeutf16byteordermark) write ("\x0ff\x0fe", 2); string::charpointertype src (text.getcharpointer()); bool lastcharwasreturn = false; for (;;) { const beast_wchar c = src.getandadvance(); if (c == 0) break; if (c == '\n' && ! lastcharwasreturn) writeshort ((short) '\r'); lastcharwasreturn = (c == l'\r'); if (! writeshort ((short) c)) return false; } } else { const char* src = text.toutf8(); const char* t = src; for (;;) { if (*t == '\n') { if (t > src) if (! write (src, (size_t) (t - src))) return false; if (! write ("\r\n", 2)) return false; src = t + 1; } else if (*t == '\r') { if (t[1] == '\n') ++t; } else if (*t == 0) { if (t > src) if (! write (src, (size_t) (t - src))) return false; break; } ++t; } } return true; }