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.

Generation I Glitch Discussion

Editing the ROM, how would I make a custom textbox? - Page 1

Editing the ROM, how would I make a custom textbox?

Posted by: 0ErrorYT
Date: 2018-04-26 21:47:51
I'm trying to make something where when RST 38 is executed, the game jumps to a custom message saying something like "Pokemon has encountered a critical error. The game will be shut down to protect your save file." Then a safe game crash. Mostly to help me with ASM and coding in general, but I don't even know where to start, so I need help. I'm hoping to try and patch glitches in The game just for shits and giggles and experience with ASM. Any help is appreciated!

Also, do the contents of 0038 ram address matter?

Re: Editing the ROM, how would I make a custom textbox?

Posted by: ISSOtm
Date: 2018-04-27 00:10:47
You should use pokered instead. Change all the RST vectors to NOPs, except 0038, which you should repoint to the blank space after the interrupt vectors (0061~0068, not sure) and put the func there.

There is no RAM address 0038. 0038 is in ROM.

Re: Editing the ROM, how would I make a custom textbox?

Posted by: 0ErrorYT
Date: 2018-04-27 21:40:25
I got the RST vectors changed, I got the text written, I just don't know the function. It wouldnt be a jp right?

Re: Editing the ROM, how would I make a custom textbox?

Posted by: ISSOtm
Date: 2018-04-28 07:51:03
What function?

Re: Editing the ROM, how would I make a custom textbox?

Posted by: 0ErrorYT
Date: 2018-04-28 11:53:26
Never mind, I just changed a textbox instead, how do I jump to it? I can't use jp because the textbox is at 094B08

Re: Editing the ROM, how would I make a custom textbox?

Posted by: ISSOtm
Date: 2018-04-28 16:12:20
What text box did you change? And what do you mean? You can't jump to a textbox.

Re: Editing the ROM, how would I make a custom textbox?

Posted by: 0ErrorYT
Date: 2018-04-28 16:50:02
I believe it was the one talking to mom before getting a Pokemon. How do I get to it then?

Re: Editing the ROM, how would I make a custom textbox?

Posted by: Torchickens
Date: 2018-04-28 18:09:26
Text is stored using a text code byte at the beginning of the text. While I don't know all of them examples are 00 (normal text), 08 (execute code) and the preset text boxes described here.

You can terminate your code with a 57 byte, and other control characters are documented on The Big HEX List

Without the disassembly (which I haven't used before to compile a ROM), then to locate the Mom text, try opening a hex editor (I normally use the freeware software HxD) and searching for "8C 8E 8C 9C 7F 52" (because that's the start of "MOM: RED" where 8C-7F are the characters up to ":" and 52 is the player's name.

As expected, you can find the text after the 00 text code; specifically the start of it is at 94B6D. Hence you can write anything you want here as long as it fits. Change 8C to 80 and it would say "AOM: RED (…) and so on.

If you want longer text and don't mind using a tool, you may be able to do it easiest with PokeText, although I'm unsure if it has any bugs or drawbacks or anything.

If you don't mind not editing the ROM to do it, then at D36C/D36D in RAM you will find the location pointer of the map's pointer table. Sounds complex but basically let's say you make this at 80DA (beginning of stored Pokémon). This would mean the first text pointer is at DA80, so at DA80 a value of say 00DB would be the beginning of the first text box's text code and contents. Then by writing your text there (at DB00) you can give Mom the custom text you want. For example, 00 80 81 82 57 (57 is the generic terminator here) would make her say "ABC[END]"

[img]https://i.imgur.com/1XDewZj.png[/img]

Say however anyway you wanted to make longer text for her permanently in the ROM. When you enter D36C is set to 6B 41. This means pointer 416B, but we still don't know the offset only the pointer which falls in the region of banked ROM (4000-7FFF). However, you can set a breakpoint on BGB emulator to 416B on read (go to the debugger by right clicking, then choose access breakpoints, then type in 416B and add it with "on read" checked, then talk to Mom).

After you've done that, go to 416B and you can find it's in bank 12. So our pointer is really 12:416B. Another way to find the bank (in hexadecimal) is to consult this list.

So what you'd need to do in short is to find a way of making the game load something other than 416B in bank 12 (although I'm unsure of further details however you can probably find how to do it browsing the disassembly).

Bank 12's offset for HxD is 0x12*0x4000=48000 and ends at 4BFFF. 4A390 is in bank 12 and appears to be the start of free data (all 00), so you could edit that. By converting it to a three byte pointer either by hand or by using a calculator, you get 12:6390.

So you would change the 416B write to a 9063 write, then at 9063 have a custom text pointer and at the pointer have your desired text (so for instance at 4A390 you could place 9065 and at 4A392 the text beginning with 00 and ending with 57 etc.

ISSOtm may be able to help if you want to generate a custom ROM from the disassembly instead.

Hope this helps and let me know if you have any questions. :)