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

Author Topic: Extending name space in NES game?  (Read 1590 times)

duiz

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Extending name space in NES game?
« on: January 30, 2019, 05:04:36 pm »
So I did a quick and dirty name translation hack for the bootleg Famicom fighting game World Heroes 2 Pro for my friend (my first release! yay!)

http://www.romhacking.net/translations/4212/

Now I have never done any romhacking or have any sort of coding experience whatsoever so this was a process of just simply debugging the hex code and figuring out the name scheme and character table and then switch the letters. Not pretty or impressive I know. However I wonder if there is a way to fit more characters into the names as many have to be abbreviated to fit the predetermined character length.

In the code, the name appears twice, one I guess is a trigger I guess and the other for the display.

For example, looking at Ryu

R=1B Y=22 U=1E

In the code, it appears like this

Code: [Select]
22 03 1B 22 1E 05 17 0B 1B 13 19 07 0D 12 1E 18
---------------------
FF 1B 22 1E FF FF 17 0B 1B 13 19 0D 12 1E 18 AC

sics

  • Full Member
  • ***
  • Posts: 221
  • Contact me!
    • View Profile
    • Deviantart: Terwilf
Re: Extending name space in NES game?
« Reply #1 on: February 09, 2019, 08:13:47 am »
 Perhaps you can achieve more if you understand how these names work:

 1. Before the first list you can find the pointers that point to each name of the first player or the player on the left:
     E1 D9 / E5 D9 / EB D9 / F3 D9 / F9 D9 / FE D9 / 05 DA / CE D9 / DC D9 / 0A DA / D4 D9 / 0F DA

 2. The first list of names works by setting the number of letters used by each followed by the name:
Code: [Select]
N° / B  L  O  O  D
 05 / 0C 16 19 19 0E
    / M  A  I 
 07 / 17 0B 13 FF FF FF FF
    / A  N  D  Y
 04 / 0B 18 0E 22
    / R  Y  U
 03 / 1B 22 1E
    / M  A  R  I  O
 05 / 17 0B 1B 13 19
    / C  H  U  N  -  L  I
 07 / 0D 12 1E 18 AC 16 13
    / S  O  N  I  C
 05 / 1C 19 18 13 0D
    / L  E  O
 04 / 16 0F 19 AD
    / H  A  G  G  A  R
 06 / 12 0B 11 11 0B 1B
    / K  O  P  A
 04 / 15 19 1A 0B
    / G  O  K  U
 04 / 11 19 15 1E
    / M  .  B  .
 04 / 17 AD 0C AD

 3. In the same way, the list of the names of the left or of the second player stores its pointers directly above it:
     6D DA / 74 DA / 7B DA / 82 DA / 89 DA / 90 DA / 97 DA / 9E DA / 66 DA / A5 DA / 5F DA / AC DA

 4. On the other hand this list has a different behavior, this time stores each name using 7 letters regardless of the length of the name, this is done in this way to be able to correctly align the names of the right side:
Code: [Select]
M A I X X X X
X X X A N D Y
X X X X R Y U
X X M A R I O
C H U N - L I
X X S O N I C
X X X L E O .
X H A G G A R
X X X K O P A
X X B L O O D
X X X G O K U
U X X M . B .

 ■ The most advisable thing that occurs to me is to try to write as many names as I can in the current space and then identify some unused area to write the rest.
 ■ The limit of 7 characters will not let you write names like LAURENCE, if you want to solve this the first step will be to replace the value 07 by 08 in the address 3da4f.
 ■ Usually nobody understands with words the way to calculate the pointer so I leave a comparative list between the Offset and the pointers of the first list of names:
Code: [Select]
╔═════════╦═══════╗
║ Offset. ║Pointer║
╠══╦══════╬═══════╣
║03║d9 de ║ CE D9 ║
║03║d9 e4 ║ D4 D9 ║
║03║d9 ec ║ DC D9 ║
║03║d9 f1 ║ E1 D9 ║
║03║d9 f5 ║ E5 D9 ║
║03║d9 fb ║ EB D9 ║
║03║da 03 ║ F3 D9 ║
║03║da 09 ║ F9 D9 ║
║03║da 0e ║ FE D9 ║
║03║da 15 ║ 05 DA ║
║03║da 1a ║ 0A DA ║
║03║da 1f ║ 0F DA ║
╚══╩══════╩═══════╝

 5. As you will see the 03 is deleted, the remaining figure is subtracted 10 (what occupies the header) and then both numbers are flipped.

 I hope this quick tutorial is useful for you to meet your goals :thumbsup:

duiz

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Extending name space in NES game?
« Reply #2 on: February 09, 2019, 09:43:15 am »
Thanks so much! I... have no idea what you mean by any of this but I am gonna study it and do this to force myself to learn!

jackic

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: Extending name space in NES game?
« Reply #3 on: February 21, 2019, 01:03:05 pm »
Perhaps you can achieve more if you understand how these names work:

 1. Before the first list you can find the pointers that point to each name of the first player or the player on the left:
     E1 D9 / E5 D9 / EB D9 / F3 D9 / F9 D9 / FE D9 / 05 DA / CE D9 / DC D9 / 0A DA / D4 D9 / 0F DA

 2. The first list of names works by setting the number of letters used by each followed by the name:
Code: [Select]
N° / B  L  O  O  D
 05 / 0C 16 19 19 0E
    / M  A  I 
 07 / 17 0B 13 FF FF FF FF
    / A  N  D  Y
 04 / 0B 18 0E 22
    / R  Y  U
 03 / 1B 22 1E
    / M  A  R  I  O
 05 / 17 0B 1B 13 19
    / C  H  U  N  -  L  I
 07 / 0D 12 1E 18 AC 16 13
    / S  O  N  I  C
 05 / 1C 19 18 13 0D
    / L  E  O
 04 / 16 0F 19 AD
    / H  A  G  G  A  R
 06 / 12 0B 11 11 0B 1B
    / K  O  P  A
 04 / 15 19 1A 0B
    / G  O  K  U
 04 / 11 19 15 1E
    / M  .  B  .
 04 / 17 AD 0C AD

 3. In the same way, the list of the names of the left or of the second player stores its pointers directly above it:
     6D DA / 74 DA / 7B DA / 82 DA / 89 DA / 90 DA / 97 DA / 9E DA / 66 DA / A5 DA / 5F DA / AC DA

 4. On the other hand this list has a different behavior, this time stores each name using 7 letters regardless of the length of the name, this is done in this way to be able to correctly align the names of the right side:
Code: [Select]
M A I X X X X
X X X A N D Y
X X X X R Y U
X X M A R I O
C H U N - L I
X X S O N I C
X X X L E O .
X H A G G A R
X X X K O P A
X X B L O O D
X X X G O K U
U X X M . B .

 ■ The most advisable thing that occurs to me is to try to write as many names as I can in the current space and then identify some unused area to write the rest.
 ■ The limit of 7 characters will not let you write names like LAURENCE, if you want to solve this the first step will be to replace the value 07 by 08 in the address 3da4f.
 ■ Usually nobody understands with words the way to calculate the pointer so I leave a comparative list between the Offset and the pointers of the first list of names:
Code: [Select]
╔═════════╦═══════╗
║ Offset. ║Pointer║
╠══╦══════╬═══════╣
║03║d9 de ║ CE D9 ║
║03║d9 e4 ║ D4 D9 ║
║03║d9 ec ║ DC D9 ║
║03║d9 f1 ║ E1 D9 ║
║03║d9 f5 ║ E5 D9 ║
║03║d9 fb ║ EB D9 ║
║03║da 03 ║ F3 D9 ║
║03║da 09 ║ F9 D9 ║
║03║da 0e ║ FE D9 ║
║03║da 15 ║ 05 DA ║
║03║da 1a ║ 0A DA ║
║03║da 1f ║ 0F DA ║
╚══╩══════╩═══════╝

 5. As you will see the 03 is deleted, the remaining figure is subtracted 10 (what occupies the header) and then both numbers are flipped.

 I hope this quick tutorial is useful for you to meet your goals :thumbsup:

I read this post just for kicks but I just have to congratulate you on your very well made explanation.

Thanks.

sics

  • Full Member
  • ***
  • Posts: 221
  • Contact me!
    • View Profile
    • Deviantart: Terwilf
Re: Extending name space in NES game?
« Reply #4 on: March 09, 2019, 01:01:08 am »
Jackic
 Thank you very much, but no explanation is good if it is not useful to the person who needs it :thumbsup:

Duiz
 Do not worry, if you're not good at dancing with this rhythm, let's change the music :laugh:

 Let's put things in perspective:
 1. Our goal is for the game to put the words we want and our information is almost nil.
 2. We found 2 lists of names, but we are not sure exactly what they are for.
 3. We identify a sector that is text, but if we look closely there is also a value that is not part of the names :o

A separator perhaps?:
Code: [Select]
? = 03 < What is your function? :O
 R = 1B
 Y = 22
 U = 1E
 
 ? = 05 < What is your function?
 M = 17
 A = 0B
 R = 1B
 I = 13
 O = 19
 
 ? = 04 < Is not this a great nick? :3
 S = 1C
 I = 13
 C = 0D
 S = 1C

 This is the part where a person with common sense would explain a meticulous and well thought process, but the truth I lack that touch, in my case I would simply try changing the mysterious value for another and I would see how it affects the game.
Code: [Select]

 ? = 09 < I change it for 09 (These are Hexadecimal numbers)
 R = 1B
 Y = 22
 U = 1E

 With the following results we can establish some important data:


 ♦ The first RYU is called "RYU5MARIO", but the second RYU has not changed its name.


 ♦ MARIO does not seem to have been affected in any way.
 
 Then we know that the number affects the number of letters used in each name and that the first list only affects the first player.

 Therefore we can assume that the second list belongs to player two. This hypothesis can be easily verified, we just have to modify some name in the second list or simply write random values ​​to try to see how this affects the game and how to break is what I like... :D



 Checked!, but there remains a question to answer How does the game to know what name to use?, but since we are not the Sherlock Holmes of hacking, we go directly to the answer:

 ► The game has a list.
 ► The list contains information on the location where each name starts.
 ► The names start with a value that is equivalent to the number of letters that comprise it.
 ► These numbers tell the game how many letters to invoke to show on the screen.

 ● Well now we have enough information to get down to work:
 
 a. First we must create a new list of names taking into account all the previous concepts and respecting the space occupied by the original list:

"Number of letters" + "Name" (It is written with .TBL)
Code: [Select]
3RYU
5MARIO
7CHUN-LI
5SONIC
3LEO
6HAGGAR
6BOWSER
5BLOOD
4ANDY
4GOKU
3MAI
7M.BISON

 b. When replacing the previous list we will leave all the original pointers obsolete, so we must create a new table of pointers:
 
 b.1. For this, we simply take note of all the addresses of the numbers that are before each name:


textify_setup.exe

 b.2. If everything has gone well you should have a list equal to this:
Code: [Select]
0x03d9de
 0x03d9e2
 0x03d9e8
 0x03d9f0
 0x03d9f6
 0x03d9fa
 0x03da01
 0x03da08
 0x03da0e
 0x03da13
 0x03da18
 0x03da1c

 c. The following is to give a format that the emulator can understand, for this we must subtract 10 to each of the number of our list, since 10 is the equivalent of space that occupies the header in the rom.
 
 (The header is a group of additional data that is added to the ROMS at the beginning of the same, and since these are not a real part of the game, you have to ignore them when you want to calculate which is the real address of some data)
 
 Equally, all this is not necessary to understand it, since behind that curtain of boring information it is only about doing this:



 d. After prepared the pointers we select everything and we paste it in the correct direction that in this case is 3d9c6.

Quote from: Extra information

 As I mentioned earlier, the pointers are often above the data they point to, so a basic method, but effective enough to find them is:

 1. Make a save state on the character selection screen.

 2. Go a little higher than the block of text you are analyzing in the hexadecimal editor.

 3. Now slowly replace that data with any random value, for example 00.

 4. Every time you make a change, load the save state and start a new fight.
 
 5. Repeat this process until you see that when loading a character your name is not shown as it should be.
 
 6. When this happens, write down the address of the last data that I change.

  Reload the game (this also applies if the game crashes) and analyze all the data around the address I aim to identify each of the offsets you need.

 Note: If you want to dedicate yourself to this you must learn more complex and precise processes than the one I have just described, but in general this method is not a bad option to start... :-\


 e. Finally you will notice that the second block of names has a different format, although with this little tutorial I think you have enough information to find out the differences by your means, luck! :beer:

 PS1: Sorry for taking so long to respond, I needed time to be able to forget my previous comment so I could read it in a more objective way and identify points that could be reinforced.

 PS2: Here I leave a patch with the changes you want to make, using a "hexadecimal comparator" you can find the changes you make to be able to use them as a guide when you try to make the changes for yourself
« Last Edit: March 28, 2019, 10:59:26 pm by sics »