+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Text hacking Cross of Venus (NDS)
Pages: 1 [2]
Author Topic: Text hacking Cross of Venus (NDS)  (Read 1 times)
Ryusui
Guest
« Reply #15 on: May 21, 2011, 02:30:18 pm »

Quote from: Majin3 on May 21, 2011, 10:02:43 am
Thanks, guys. I didn't understand it completely, though...
The first example (1FF8): Why is it -8? Isn't FFF-FF8=7? And by looking at the compressed file, the distance to "nce" is even 9.
The third example (0FF7): Once again, isn't it -8? But -9 is right here.
And as for the other 2, I don't get where they should be pointing at all. The second one points to B6 0F 8F (should be 00 4B 02) and the fourth one to 75 B7 1F 08 (should be 00 00 00 00).
But I think I got the rest now at least.

jjjewel, are you planning to write a (de)compressor for that "NDS games that use similar compression"?
Or I guess I could ask the writer of DSDecmp or something to implement this one...

*headdesks* Yeah, it looks like I fudged my math. Add 1 to get the actual distance.

Also, you misunderstand. It looks in the uncompressed data for the snippets, not the compressed. "nce" will be eight characters back from the output address at that time.

Let's look at that "getOnceInstance" sequence again.

get($FF)OnceInst($BA)a($F8)($1F)

When it hits the compression code, the output looks like this:

getOnceInsta

And "length 3, distance 8" tells it that the next snippet is:

getOnceInstance

Get it now?
« Last Edit: May 21, 2011, 04:36:36 pm by Ryusui »
Majin3
Guest
« Reply #16 on: May 21, 2011, 04:24:43 pm »

Hmm, not yet.
Shouldn't I subtract 1 to get the actual value?
Yes, "nce" is 8 characters back (uncompressed data) but FFF-FF8 is 7, isn't it?

And it looks in the uncompressed data? In the third example (0FF7) that would be 00 4B instead of "NN" which is back at 13.
Ryusui
Guest
« Reply #17 on: May 21, 2011, 04:36:20 pm »

Subtract, add, whichever. You understand the math better than I can explain it.

Also, I don't see your problem. The compression code in the middle of "ARIANNE" points right back to the "NN" of "ZYUUNINN".

At that point, the uncompressed data should look something like this:

ZYUUNINN($??)($??)($??)ARIA

I know that the compression code in the middle indicates a three-byte sequence, but I don't know what the actual bytes are, so they're marked in with question marks.

"Length 2, Distance 9" therefore gives us...

ZYUUNINN($??)($??)($??)ARIANNE
Majin3
Guest
« Reply #18 on: May 21, 2011, 05:12:47 pm »

Oh, I forgot I didn't upload any screenshot of that part uncompressed.
Here it is:

As you can see the distance is 13.

And the distance from getOnceInsta to nce is also 8, while FFF-FF8 gets us 7.
Either there is something wrong there or I didn't understand it yet.
Ryusui
Guest
« Reply #19 on: May 21, 2011, 05:23:43 pm »

Like I said: you have it right. Take the negative number and add (or subtract, whichever) 1. It makes sense there'd be an offset value, since a distance of 0 means it would be looking at empty space.

Note that a distance of 1 and an arbitrary length can be a valuable space-saving trick: the end result is similar to RLE, where compression codes are used to indicate long sequences of repeating bytes.
jjjewel
Guest
« Reply #20 on: May 21, 2011, 08:49:42 pm »

Quote from: Majin3 on May 21, 2011, 10:02:43 am
jjjewel, are you planning to write a (de)compressor for that "NDS games that use similar compression"?
Or I guess I could ask the writer of DSDecmp or something to implement this one...
I've been working on it but not getting very far. The recompression can be quite complicated. I may have to ask for help with the programs later too.

Anyway, if anyone interested, other NDS games that I mentioned are Nana DS (graphic compression in .R00 archive), Duel Love DS (text and graphic compression in .ptd archive), and Oshare Princess DS (text compression in mes.bin). They all use different kinds of compressions, but the concepts are pretty similar to what we're discussing here. ^_^
Ryusui
Guest
« Reply #21 on: May 22, 2011, 01:56:30 am »

Recompression isn't hard. It's just tedious.

Search the preceding data for any match between 2 bytes and $11 (17 dec) long that's less than $1000 bytes back from the current position. Once you've found the longest possible match, calculate the compression code and output it, or else output the plaintext code. Track the compression flags for each code, and once you've got a full byte, output that. (Note that you'll need to do things backwards - you have to write the compression flag byte which goes before the codes after you've calculated them.)
henke37
Guest
« Reply #22 on: May 31, 2011, 05:34:56 am »

It helps that the DS comes with built in decompression routines in the bios.

Check if you are using the variant compression that has support for variable length backreferences. It has some flag bits used to indicate how long the backreference code itself is.
Pages: 1 [2]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC