Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Emulation & ROM Hacking

Hacking tutorial - Page 1

Hacking tutorial

Posted by: WithLightsOut
Date: 2008-02-27 15:31:21
I'm new to hacking (never done it).

What is a good way to get started? i.e. tools, games, ect…

Thanks

Re: help please?

Posted by: Bent`
Date: 2008-02-28 00:30:34
For starters, you need a ROM. If you're starting out, I heartily recommend Pokemon Gold, as it has nice clean programming (unlike Red, Blue, and Yellow), and has a fair amount of tools for it (unlike Crystal). If you want to do GBA games, you certainly can, but the ROMs are much more complex and they also fall under the "too many tools" syndrome – some things are best done with a hex editor.


So, a hex editor should be your next requirement. Translhextion is a solid choice; it has its bad points, but you shouldn't have any major problems with it.

And, of course, an emulator. VisualBoyAdvance should be fine for our purposes.



Open Pokemon Gold in your hex editor. On the leftmost side, you'll see a list of numbers going "00000000, 00000010, 00000020," and so on. This is the offset, or file position. When somebody says "Such-and-such data is located at offset 18AC42," this means to scroll to that offset. (You can also get to a specific offset by hitting Ctrl+G and typing in "x18AC42" or whatever the offset is.)

In the middle you'll see rows of two-digit hexadecimal numbers. These are the bytes that make up our file. When we edit these, it'll change what happens in the game. Each byte has a value that can go from 00 to FF (the hexadecimal equivalent of 0 to 255).

On the right is the ASCII representation of each byte. ASCII is a method of storing text where one byte equals one letter – 41 is 'A', 42 is 'B', 43 is 'C', and so on.


Now, let's start with something simple: editing text. This would be easy if Pokemon games used the ASCII standard to store their text – but they don't! Instead of the above, Pokemon Gold makes 80 'A', 81 'B', and so on. So what to do?

ROM hackers came up with the solution to this some time ago. It's called "Thingy tables." A Thingy table is a text file that tells the hex editor what byte represents what letter. To make the Thingy table for Gold, open Windows Notepad and copy the following text into a new file:
7F=
80=A
81=B
82=C
83=D
84=E
85=F
86=G
87=H
88=I
89=J
8A=K
8B=L
8C=M
8D=N
8E=O
8F=P
90=Q
91=R
92=S
93=T
94=U
95=V
96=W
97=X
98=Y
99=Z
A0=a
A1=b
A2=c
A3=d
A4=e
A5=f
A6=g
A7=h
A8=i
A9=j
AA=k
AB=l
AC=m
AD=n
AE=o
AF=p
B0=q
B1=r
B2=s
B3=t
B4=u
B5=v
B6=w
B7=x
B8=y
B9=z
F6=0
F7=1
F8=2
F9=3
FA=4
FB=5
FC=6
FD=7
FE=8
FF=9

Then save it as "gold.tbl". Be sure to include the quotation marks when you save!


I've purposely left this table incomplete. When you're hacking and you find out that another byte represents a character, add it to your table!


Now, you should have your table file, gold.tbl. To use it in Translhextion, go to Script > Open Thingy Table, open the table, and then click the box that says "Thingy View Active."

Not everything in this ROM is text, of course. To find some, go to offset 195624. This is Oak's speech at the beginning of the game. Don't change the 00; this is a special control code that means "Print text until you reach a 57." Starting with the next byte, replace with this:

93 A7 A8 B2 7F A8 B2 7F A0 7F A7 A0 A2 AA E7 4F 93 A4 B2 B3 A8 AD A6 E8 E8 E8 57

"This is a hack! Testing…"

Save your ROM, and try it out!
[img]http://i262.photobucket.com/albums/ii89/iimarckus/withlightsout.png[/img]

That's how you edit text. Experiment, and you'll be able to do more on your own!


The next thing most people want to do is rearrange the maps. There are multiple tools to do this; I recommend MegaMap. (You may need some extra files to get MegaMap to ron, such as zerolib.dll or MSCOMCT2.OCX.) It has some quirks: mainly that it's only partially translated (from German). However, it's a great editor, and IMO better than Goldmap.

Re: help please?

Posted by: WithLightsOut
Date: 2008-02-28 18:35:51
Thanks for the help!


I can't find 195624 though

Re: help please?

Posted by: Bent`
Date: 2008-02-28 20:50:34

On the leftmost side, you'll see a list of numbers going "00000000, 00000010, 00000020," and so on. This is the offset, or file position. When somebody says "Such-and-such data is located at offset 18AC42," this means to scroll to that offset. (You can also get to a specific offset by hitting Ctrl+G and typing in "x18AC42" or whatever the offset is.)

So hit Ctrl+G and type "x195624". 195624 will be the fifth byte on the row marked "195620".

Re: help please?

Posted by: WithLightsOut
Date: 2008-02-29 16:06:07
I did what you said but when it got to where Professor Oak talks, it just started the game over. What did i do wrong? :???:

Re: help please?

Posted by: Bent`
Date: 2008-02-29 17:29:25
Sounds like you overwrote the 00 that starts the text. Don't do that; only replace the bytes after it.

Re: help please?

Posted by: WithLightsOut
Date: 2008-02-29 21:12:02
Yep that was it but now another problem (I think) XD

When I copied in the line you said "
93 A7 A8 B2 7F A8 B2 7F A0 7F A7 A0 A2 AA E7 4F 93 A4 B2 B3 A8 AD A6 E8 E8 E8 57" he said colors and letters lol

Re: help please?

Posted by: Bent`
Date: 2008-02-29 21:34:11
I don't get that result when I try. Could you post a screenshot of what you're getting?

Re: help please?

Posted by: WithLightsOut
Date: 2008-03-02 20:22:52
[IMG]http://i84.photobucket.com/albums/k15/ash-land/goldcopy.jpg[/img]

Re: help please?

Posted by: Bent`
Date: 2008-03-02 23:02:11
You need to type the bytes in the left (middle) column. You can switch between columns by pressing Tab.

[img]http://i262.photobucket.com/albums/ii89/iimarckus/good.png[/img]
[img]http://i262.photobucket.com/albums/ii89/iimarckus/bad.png[/img]

Re: help please?

Posted by: WithLightsOut
Date: 2008-03-03 18:11:03
Now I got it!

Thanks  ;D

Re: help please?

Posted by: Ratipharos
Date: 2008-04-06 20:29:22

For starters, you need a ROM. If you're starting out, I heartily recommend Pokemon Gold, as it has nice clean programming (unlike Red, Blue, and Yellow), and has a fair amount of tools for it (unlike Crystal). If you want to do GBA games, you certainly can, but the ROMs are much more complex and they also fall under the "too many tools" syndrome – some things are best done with a hex editor.


So, a hex editor should be your next requirement. Translhextion is a solid choice; it has its bad points, but you shouldn't have any major problems with it.

And, of course, an emulator. VisualBoyAdvance should be fine for our purposes.



Open Pokemon Gold in your hex editor. On the leftmost side, you'll see a list of numbers going "00000000, 00000010, 00000020," and so on. This is the offset, or file position. When somebody says "Such-and-such data is located at offset 18AC42," this means to scroll to that offset. (You can also get to a specific offset by hitting Ctrl+G and typing in "x18AC42" or whatever the offset is.)

In the middle you'll see rows of two-digit hexadecimal numbers. These are the bytes that make up our file. When we edit these, it'll change what happens in the game. Each byte has a value that can go from 00 to FF (the hexadecimal equivalent of 0 to 255).

On the right is the ASCII representation of each byte. ASCII is a method of storing text where one byte equals one letter – 41 is 'A', 42 is 'B', 43 is 'C', and so on.


Now, let's start with something simple: editing text. This would be easy if Pokemon games used the ASCII standard to store their text – but they don't! Instead of the above, Pokemon Gold makes 80 'A', 81 'B', and so on. So what to do?

ROM hackers came up with the solution to this some time ago. It's called "Thingy tables." A Thingy table is a text file that tells the hex editor what byte represents what letter. To make the Thingy table for Gold, open Windows Notepad and copy the following text into a new file:
7F=
80=A
81=B
82=C
83=D
84=E
85=F
86=G
87=H
88=I
89=J
8A=K
8B=L
8C=M
8D=N
8E=O
8F=P
90=Q
91=R
92=S
93=T
94=U
95=V
96=W
97=X
98=Y
99=Z
A0=a
A1=b
A2=c
A3=d
A4=e
A5=f
A6=g
A7=h
A8=i
A9=j
AA=k
AB=l
AC=m
AD=n
AE=o
AF=p
B0=q
B1=r
B2=s
B3=t
B4=u
B5=v
B6=w
B7=x
B8=y
B9=z
F6=0
F7=1
F8=2
F9=3
FA=4
FB=5
FC=6
FD=7
FE=8
FF=9

Then save it as "gold.tbl". Be sure to include the quotation marks when you save!


I've purposely left this table incomplete. When you're hacking and you find out that another byte represents a character, add it to your table!


Now, you should have your table file, gold.tbl. To use it in Translhextion, go to Script > Open Thingy Table, open the table, and then click the box that says "Thingy View Active."

Not everything in this ROM is text, of course. To find some, go to offset 195624. This is Oak's speech at the beginning of the game. Don't change the 00; this is a special control code that means "Print text until you reach a 57." Starting with the next byte, replace with this:

93 A7 A8 B2 7F A8 B2 7F A0 7F A7 A0 A2 AA E7 4F 93 A4 B2 B3 A8 AD A6 E8 E8 E8 57

"This is a hack! Testing…"

Save your ROM, and try it out!
[img]http://i262.photobucket.com/albums/ii89/iimarckus/withlightsout.png[/img]

That's how you edit text. Experiment, and you'll be able to do more on your own!


The next thing most people want to do is rearrange the maps. There are multiple tools to do this; I recommend MegaMap. (You may need some extra files to get MegaMap to ron, such as zerolib.dll or MSCOMCT2.OCX.) It has some quirks: mainly that it's only partially translated (from German). However, it's a great editor, and IMO better than Goldmap.

Whenever I do this, it comes out with so many # it will drive you bananas.

Re: help please?

Posted by: Bent`
Date: 2008-04-07 10:20:10

Whenever I do this, it comes out with so many # it will drive you bananas.

Whenever you do what? Could you be more specific?

Re: help please?

Posted by: Ratipharos
Date: 2008-04-07 14:49:39
Um…
When I make the Thingy Table and put it into the Hex Editor (For Gold) it comes out with a few P's and then _ and so on, (it's not understandable) and then #####################!

Re: help please?

Posted by: Bent`
Date: 2008-04-07 21:37:24
Are you using the correct ROM?

Is the "Thingy View Active" box checked?

Are you at the right offset?