News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: [SOLVED] Editing DTE table  (Read 3831 times)

TakuyaMK

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
    • HTCManiaCraft
[SOLVED] Editing DTE table
« on: March 30, 2014, 02:18:31 pm »
Hi!

How can I edit a DTE value (e.g. 1C=th) to 1C=no? Can I do it without assembly knowledge?

Thanks!
« Last Edit: March 31, 2014, 04:37:47 pm by TakuyaMK »

Bregalad

  • Hero Member
  • *****
  • Posts: 2644
    • View Profile
Re: Editing DTE table
« Reply #1 on: March 30, 2014, 02:44:39 pm »
You can generally do it without assembly knowledge, although it'd definitely help.

You'll have to find where the table(s) are located in ROM. Typically there's 2 tables : The left table and the right table. In your case you'd have to replace a 't' in the left table by a 'n', and the 'h' in the right table by a 'o'.

The data could also be stored continuously, but that's less likely.

In order to locate the tables, you'll just have to know several DTE values, and find consecutive values.
For example :
1C = th
1D = el
1E = er

By searching for "tee" you can locate the left table, and by searching "hlr" you can locate the right table.

VicVergil

  • Hero Member
  • *****
  • Posts: 715
    • View Profile
Re: Editing DTE table
« Reply #2 on: March 30, 2014, 02:58:13 pm »
1C = th
1D = el
1E = er

By searching for "tee" you can locate the left table, and by searching "hlr" you can locate the right table.

Finding those stored as a continuous string isn't that uncommon.

The one in Secret of Mana was stored as, following your example, 'theler".
But that one is one of the easiest ones, and its DTE only encodes two characters, no more.
I know also the one in Zelda III and Terranigma (but that's more of a dictionnary) have a succession of words separated by a 00 byte. So does Sword of Mana, and that one is so compression-heavy I have no idea how to build a table for it.

Usually there's a word that's stored uncompressed. For example you have "King:" or "Hyrule" and many heavily used I would bet they are part of a dictionnary and hence are uncompressed. I use a relative search to find those and I usually find the DTE/dictionnary around them AND build the table with the character values.

That said I have a BIG problem with finding the compression (and I read somewhere it's indeed a DTE) used in Front Mission Gun Hazard (AG's translation). It's a challenge I still couldn't solve, and I'd be grateful for any help.

TakuyaMK

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
    • HTCManiaCraft
Re: Editing DTE table
« Reply #3 on: March 30, 2014, 03:11:15 pm »
Hi! I located the table:



Quote
You'll have to find where the table(s) are located in ROM. Typically there's 2 tables : The left table and the right table. In your case you'd have to replace a 't' in the left table by a 'n', and the 'h' in the right table by a 'o'.

Can you explain this more detailed? :-\ I don't know where the "two tables" are.

And how can I modify left table (I suppose it's '1') to 'n'? 'n' in game is B1 (B1=n), so 'no' will be B1B2, how can I change 1C to B1B2? It ocuppies twice than 1C  :-\
« Last Edit: March 30, 2014, 03:21:53 pm by TakuyaMK »

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6923
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: [Not solved yet] Editing DTE table
« Reply #4 on: March 30, 2014, 09:44:02 pm »
Simple, overwrite "th" with "no".
I've most often seen DTE tables stored as the two letters stored together (except for DTE routines I've written :D , because separating the first and second characters into separate tables is less easy to read, but allows more pairs to be used).
"My watch says 30 chickens" Google, 2018

TakuyaMK

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
    • HTCManiaCraft
Re: [Not solved yet] Editing DTE table
« Reply #5 on: March 31, 2014, 02:24:37 am »
Simple, overwrite "th" with "no".
I've most often seen DTE tables stored as the two letters stored together (except for DTE routines I've written :D , because separating the first and second characters into separate tables is less easy to read, but allows more pairs to be used).

Hi! But, how can I overwrite 'th' with 'no'?' th' occupies '1C',and' no' occupies 'B1B2'  :-\

Bregalad

  • Hero Member
  • *****
  • Posts: 2644
    • View Profile
Re: [Not solved yet] Editing DTE table
« Reply #6 on: March 31, 2014, 02:54:07 am »
Errr... it occupies 1C in the compressed text, right, not in the DTE table you manged to locate ?

VicVergil

  • Hero Member
  • *****
  • Posts: 715
    • View Profile
Re: [Not solved yet] Editing DTE table
« Reply #7 on: March 31, 2014, 08:44:18 am »
Your screenshot doesn't have the DTE table. And I bet this isn't text but some other data.
Try to find the "th" stored as two bytes. Replace it with two bytes for "no".

Bregalad

  • Hero Member
  • *****
  • Posts: 2644
    • View Profile
Re: [Not solved yet] Editing DTE table
« Reply #8 on: March 31, 2014, 10:04:15 am »
Quote
Try to find the "th" stored as two bytes.
This won't work as they aren't stored continuously in FF1 (which seems to be the game he's hacking). FF1, as well as many other NES games, uses different "left" and "right" tables. Which means the 't' is at the same position as the 'h', but in different tables.

So no, you didn't locate the table at all. To locate it search for a sequence of consecutive left or right letters from consecutive DTE bytes, as shown in my previous example.

Disch

  • Hero Member
  • *****
  • Posts: 2744
  • NES Junkie
    • View Profile
Re: [Not solved yet] Editing DTE table
« Reply #9 on: March 31, 2014, 02:03:08 pm »
Quote
This won't work as they aren't stored continuously in FF1 (which seems to be the game he's hacking).

Final Fantasy??!?!  Why did nobody say so?

Just FYI, most of this game has been completely disassembled.  In fact the disassembly available on this site ( http://www.romhacking.net/documents/401/ ) has ALL out-of-battle code documented and commented... except I think the "The End" drawing.


Doing a "find in files" for 'DTE' shows it's reading from 'lut_DTE1' and 'lut_DTE2'.

Doing a search for those will give you the exact offset and format of the tables.

I won't post it here for 'spoilers' in case you're more interested in finding it for yourself.

But in this case, Bregalad is right.  The data is stored in two separate tables.  Also... hint:  the tables are stored in reverse (the 2nd character is before the 1st)

TakuyaMK

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
    • HTCManiaCraft
Re: [Not solved yet] Editing DTE table
« Reply #10 on: March 31, 2014, 02:21:49 pm »
Thanks a lot for the info! I'll try it tonight. ;)

Bregalad

  • Hero Member
  • *****
  • Posts: 2644
    • View Profile
Re: [Not solved yet] Editing DTE table
« Reply #11 on: March 31, 2014, 02:48:16 pm »
Quote
Final Fantasy??!?!  Why did nobody say so?
He didn't say so but I saw it was written "FF1.tbl"

Quote
Also... hint:  the tables are stored in reverse (the 2nd character is before the 1st)
This is why the name "2nd" and "1st" are horribly choosen, and I preer to call them "Left" and "right", which is unambiguous, in CompressTools.

Also it's a bit dumb that FF1 uses DTE for compressing but without the possibility of recursivity (you can't have a DTE in a DTE).

When playing with CompressTools I noted that recursive DTE was by far the very best to compress text and any other kind of data where all 256 bytes aren't used, the recursivity makes it extremely powerful as it can also act as an implicit RLE, and as an implicit dictionary for common words.
Text can often be compressed to 30% of it's original, vs barely 60% for DTE without recursivity. Not only that but decompression is extremely trivial, and takes a dozen of 6502 instructions, and only uses the stack as memory.

TakuyaMK

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
    • HTCManiaCraft
Re: [Not solved yet] Editing DTE table
« Reply #12 on: March 31, 2014, 04:37:32 pm »
Found it! Thx a lot!