PS2 Berwick Saga compress/decompress and graphic question.

Started by lckhoa, August 03, 2013, 06:38:21 AM

Previous topic - Next topic

lckhoa

Hi Pro,

I would like to make an English, at least for Menu but thing's not easy as i thought.
After a week playing with Hex & SaveState i know that most of font are compress (except font for items, chars name).

Screenshot below is two windows of compress/decompress of 1 font.

One the compress windows, first 4 bytes is decompress size and next 4 bytes is compress size, next "F8" byte i don't know yet - maybe signature or something?

When compare two windows, we can see that compress data is not total hidden data of the decompress one. We can see some bytes like "14" "F802" "7C01"...

So:
- Is there any pro out there that have more experience/smarter than me know which type of compression it is or point me a hint about it?
- The decompress data looks like a BMP, TIM but it's not. I can see this font on GDD but not its true form. Is it a TIM2, TIM3 or what?



Thanks for reading.

Pokeytax

Judging by the general structure (more readable early on, mix of literals), it looks like a LZW variant.  A lot of the time, the opening "F8" might be a bitfield indicating the state of the next 8 pieces (i.e. "11111000" meaning the next 5 chunks are literal bytes and the last three are compression codes), which explains the first five bytes being verbatim, but I don't know how to square that with the literal "14" appearing eight bytes later.

Ultimately this is easiest to solve by using a debugger and watching the game unpack the data.

tryphon

Quote from: Pokeytax on August 03, 2013, 02:29:57 PMUltimately this is easiest to solve by using a debugger and watching the game unpack the data.

I'd be REALLY interested to know how to do that with a PS2  :)

lckhoa

Quote from: Pokeytax on August 03, 2013, 02:29:57 PM
Ultimately this is easiest to solve by using a debugger and watching the game unpack the data.

Thanks for your information. Cheat Engine can set break on read/write and i can see memory change bye by byte but sadly that i know nothing about ASM.
If you don't mind than...

Thanks,

Klarth

Quote from: tryphon on August 03, 2013, 06:19:07 PM
I'd be REALLY interested to know how to do that with a PS2  :)
The general technique is to locate where the compressed file is loaded into RAM, then set a read breakpoint on the compressed data (alternatively, set a write breakpoint on the decompressed data).  That will give you an idea of where the code is at.  Then you can either disassemble the surrounding code or do a code trace.  I'm not sure what the state of PS2 debuggers are and I never released my PCSX2 trace modification.

tryphon

Please release it :)

The only PCSX2 version with a debugger I found is the one on this site, and tracer crashes on my PC as sson as I launch it.

So, for the moment, either I try to figure out the compression scheme looking at both compressed and uncompressed data (which worls only for simple compression) or I look into a disassembly all references to the memory areas, which is... tiring, to say the least :)


tryphon

I must say I didn't know about that. Thanks :)

But it's not PS2 specific, is it ?

lckhoa

I think no but try it and you will see :)
You can set break point on access/write, break and trace and more...
Like i said on my previous post, i can see the decompress routine but sadly that i don't understand ASM!