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

Author Topic: Gba Text Space  (Read 1773 times)

Sup_vic

  • Jr. Member
  • **
  • Posts: 22
    • View Profile
Gba Text Space
« on: October 23, 2015, 11:33:24 am »
First of all, I know this is probably really easy, since every single translation ever uses this, but I had a hard time finding content about this, made I didn't use good tags.

Example: If I open a rom in a hex editor and eventually find some texts I can change them, of course, but I can only use the same space that was before. I need a some noob explaining on how to "enlarge" this space so I don't have to change "sonic" for another five letter word, for example.

note: I read something about pointers but I couldn't understand it on my own.
note2: gba rom hacking is basically pokemon for google. LOL

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Gba Text Space
« Reply #1 on: October 23, 2015, 01:38:43 pm »
It depends on the game. In general, the game stores the size of the text "somewhere", since it too needs to know. The problem is just figuring out where the game stores the length.

FAST6191

  • Hero Member
  • *****
  • Posts: 2848
    • View Profile
Re: Gba Text Space
« Reply #2 on: October 23, 2015, 03:34:20 pm »
Yeah you want to read about pointers. henke37 is right but in the vast majority of cases GBA games do it the same way so you will have a bit of an easier time than someone picking up an older console or the DS, though the DS has a lot going for it as well. The older consoles will often have to fiddle with mappers, pages, windows and such like for most games, nothing especially traumatic but harder than the GBA has it.

As henke37 said computers tend to want to know where things start and end as reading things is resource consuming (and you only have a little 16 megahertz ARM7 with a couple of hundred kilobytes of RAM to play with on the GBA). To do this the vast majority of games will use pointers, small pieces of hex that quite literally point the way where the text is. There are many variations on this, especially on the DS and especially the PC where things are more software defined, but the GBA has the whole cart visible in normal memory at all points and is very quick and easy to read/access.

The GBA cart is visible in several places in memory ( http://problemkaputt.de/gbatek.htm#gbamemorymap has them) but most things will tend to opt for the 08000000-09FFFFFF section, or more likely just 08000000 through 08FFFFFF as most games are less than 16 megabytes.
The GBA has no extra headers, banks or fun things so 08123456 as a pointer is 00123456 in the ROM. To that end if you search either for the address of the text section (but with a 08 and also accounting for endianness if you hex editor is not going to do it automatically) or search for 08 and find a lot of results all mainly 4 bytes apart then you likely have your pointers.

If you need extra space then you either
1) Redo that pointer to add space and redo all the subsequent pointers that you have just put out of line from where it would have been.
2) Find some blank space in the ROM. Remember that thing above where I said most games are 16 megabytes or less? That is good as you have the whole 09000000 through 09FFFFFF range to play in for most games. I would try to use things in the 08?????? range first but if you have to go over then you have to go over.
The only real downside to using this is you may run into trouble with some flash carts that mainly use a 16 megabyte RAM section and if you want the full 32 it is marginally more annoying.

If I sound like I am pushing you towards 2) I kind of am but 1) is a perfectly valid thing to do, especially if you are intending to release a hack to the public (chuck it at the end if you are doing some internal testing or something but for the final release if you can change the game as little as possible then best to do so, especially if you want to allow others to make hacks of your hack or stack with other hacks that might really need the space.

Theoretically a game could dump the text into normal memory (which you leave the pointers in the 02000000-0203FFFF range) or do some calculations or something fun, again like the DS or the PC, but not many games will do this for text.