Difference between revisions of "Text Tables"
(Wikipedia links; ASCII as editors; default text table; byte pair encoding)
|Line 70:||Line 70:|
Some games, such as
Some games, such as and a .
, RPGs, a single byte represent called Byte Pair Encoding BPE)Tree Encoding to the .
Revision as of 08:55, 23 June 2017
In simple terms, a text table is a look up for the numbers that a game uses to represent the alphabet. Specialized programs use text tables in order to make it easier to alter the text in a game.
For example, if you look at the game Excitebike, you notice that it has a text table that looks like this:
00=0 01=1 02=2 03=3 04=4 05=5 06=6 07=7 08=8 09=9 0A=A 0B=B 0C=C 0D=D 0E=E 0F=F 10=G 11=H 12=I 13=J 14=K 15=L 16=M 17=N 18=O 19=P 1A=Q 1B=R 1C=S 1D=T 1E=U 1F=V 20=W 21=X 22=Y 23=Z 26=* 3A=© 79=# f8== F9=' FA=! FB=: FC=
Computers use bytes. They can use letters only if they're encoded as bytes. A character encoding is a mapping between letters and bytes, and a text table is how this encoding is described to a hex editor. The number on the left of the text table is a byte-value, and the value on the right is the corresponding letter/number/symbol.
For example, in Excitebike, the phrase "IT'S A NEW RECORD!" appears if you get high score on a track. Text appears on the screen, but the programmers had to spell it out using the byte-value of each letter which looks like this:
12 1D F9 1C FC 0A FC 17 0E 20 FC 1B 0E 0C 18 1B 0D FA I T ' S A N E W R E C O R D !
If you open the Excitebike ROM in a hex editor, you'd find this very string of numbers at address 15DB. Changing the hex values would, in turn, change the text that's written to the screen. But that's a rather tedious process.
Thankfully, several programs have been written to make this process easier. Normally, when you look at the game's ROM data, all you see are a bunch of hexadecimal numbers, but these programs allow you to open up both the ROM and a text table at the same time in order to read and write to a ROM using the game's alphabet. See the images below for an example.
Here's what the Excitebike ROM looks like without a text table. There isn't any readable text to be found. This is because most hex editors use the built-in ASCII table unless told otherwise, and this text is not encoded in ASCII.
And here is the same data with a text table for Excitebike applied. Notice how the text is decoded, and we can read the game messages. The phrase "IT'S A NEW RECORD!" is now visible.
Some games, such as Blaster Master#Text are actually encoded in ASCII and can be viewed in a regular hex editor.
Games with a lot of text, like RPGs, have so much dialogue they have to compress their text. There are multiple ways to do this, and they require their own guides to explain. Final Fantasy, for example, uses a single byte to represent two letters (called Byte Pair Encoding or BPE). StarTropics uses a dictionary where a single byte can represent an entire word. BattleToads uses Huffman Tree Encoding to greatly compress the dialog.