S
Shunsq
Guest
Hi everyone,
I'm trying to get the bone positions from the chara.one file , present in each field archive. The wiki states that the model data is lzs compressed but i can't figure out how to decompress the file.
I've read about LZS compression and wrote a program to decompress chara.one.
It is based on this:
https://www.ff7catalog.com/posts/19760/
Anyway all i obtain is garbage. Or maybe it's not looking like what i'm expecting: isn't it supposed to look like the .MCH file,with number of bones, vertices , etc... in the header?
This is how my code works:
Code: [Select]
I'm trying to get the bone positions from the chara.one file , present in each field archive. The wiki states that the model data is lzs compressed but i can't figure out how to decompress the file.
I've read about LZS compression and wrote a program to decompress chara.one.
It is based on this:
https://www.ff7catalog.com/posts/19760/
Anyway all i obtain is garbage. Or maybe it's not looking like what i'm expecting: isn't it supposed to look like the .MCH file,with number of bones, vertices , etc... in the header?
This is how my code works:
Code: [Select]
Code:
typedef struct ALONE ALONE;struct ALONE{ long long int one_offset; long int one_datasize;//appears twice long long int has_tim;//if >0xd0 then no tim_offset and directly model data offset( which is 0) long long int tim_offset;//0 if has_tim>0xd0 long long int alone_offset;//0 if has_tim>0xd0 char name[9];};//Reads the header then creates a list of ALONE structures ( one for each character of the chara.one)//I've not included the code here//---LZS Decompression---//I create a .alone file for each character "i"for(i=0; i<alone_count; i++) { sprintf(outputpath,"%s%s.alone",outdir_name,alone_list[i].name); FILE*alone=fopen(outputpath,"ab+"); fseek(inputfile,alone_list[i].one_offset,SEEK_SET); memset(outputpath,'\0',255); int ctrl_bit[8];//control byte before the compressed data char comp[2];//the two bytes of the compressed data int comp_len=0; int comp_offset=0; long int new_pos=0; long int last_pos=0; memset(ctrl_bit,0,8*sizeof(int)); memset(comp,'\0',2); while(ftell(inputfile)<alone_list[i].one_offset+alone_list[i].one_datasize) { fscanf(inputfile,"%c",&cbyte); convert_to_bits(cbyte,ctrl_bit);//Reference byte for(j=0; j<8; j++) { if(ctrl_bit[7-j]==0)//compressed data { for(k=0; k<2; k++) { fscanf(inputfile,"%c",&cbyte); comp[k]=cbyte;//read from left to right } comp_len=comp[1]%0x10+3;//minimum is 3bytes comp_offset=comp[0]+(comp[1]-comp[1]%0x10)*0x10;//if the two byte are read from left to right 0xa4 0xb1 then comp_offset=0xba4; new_pos=ftell(alone)-(ftell(alone)-18-comp_offset)%0x1000;//reference byte pos k=0; if(new_pos<0) { for(k=0;k<comp_len;k++) { fprintf(alone,"%c",NULL); } } else if(new_pos>0) { fseek(alone,new_pos,SEEK_SET); for(k=0;k<comp_len;k++) { fscanf(alone,"%c",&cbyte);//reads at comp_offset fprintf(alone,"%c",cbyte); } } } else if(ctrl_bit[7-j]==1)//literal data { cbyte=0; fscanf(inputfile,"%c",&cbyte); fprintf(alone,"%c",cbyte); } } } fclose(alone); } fclose(inputfile);
Last edited: