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

Author Topic: I can't change a pointer that... isn't a pointer?  (Read 1020 times)

MegaParadise

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
I can't change a pointer that... isn't a pointer?
« on: November 24, 2020, 08:38:50 am »
Ok, this is really weird. Im translating a game called Yugioh Gx - Duel Academy, for the GBA console. This game has groups of text string separated with "00" bytes, wich are displayed as "." in the tables. Double "00", aka ".." represent the whole group of groups of text string, wich correspond to a pointer. For instance: "..Title.King of Games.Prince of Games.Elite duelist.Honored Duelist.Shwed Duelist.." So, everything from the T of "title" to the last "00" of the string is in the same group, so, when you get the pointer (take the offset from the "T" of title since it starts there) you get 58 C8 46, and then add 09 (this game works with bytes ending in 09 instead of 08). Righ, all is perfect in the papers BUT, when i try to repoint the pointer or even just modify it with random bytes NOTHING happens. Its so weird, its like it isn't a pointer when it clearly is. Btw, its clear that is a pointer because it is in a section of the rom wich has a lot of other pointers with the same pattern (3 pairs of bytes and 09). I was thinking that MAYBE there was multiple pointers for the same group, but the ROM just find one pointer with the offset of the string, so i dont have idea whats going on. I'll attach a screenshot so you can see the pointer section that im talking about.
PD: Sorry if my english is not on point, i dont use it a lot.

IMAGE: https://postimg.cc/8JFm1h0j

Iredc

  • Jr. Member
  • **
  • Posts: 34
    • View Profile
    • FMA visual novels' translations
Re: I can't change a pointer that... isn't a pointer?
« Reply #1 on: November 26, 2020, 06:54:29 am »
I have only experience with one GBA game, but it's my understanding that pointers ending in 09 are for expanded ROMs. So, 58 C8 46 09 would point to offset 0x0146C858, instead of offset 0x0046C858.

Have you checked if there are relative pointers before the text block? In the game I worked with, general pointers ending in 08 only pointed to the whole text block. Then, inside that block, there were relative pointers that led to individual strings.

FAST6191

  • Hero Member
  • *****
  • Posts: 3023
    • View Profile
Re: I can't change a pointer that... isn't a pointer?
« Reply #2 on: November 26, 2020, 09:55:50 am »
Re 08 vs 09 in pointers.

The GBA ROM is visible in memory in a few different locations, said locations corresponding to different waitstates for reading (less important stuff then being able to be kicked to lower priority). It is also on exceptionally fast memory so

However the vast majority of GBA games use the 08000000 through 09FFFFFF region.

Traditionally GBA games are 32 megabytes or less (some video ones and some flash carts can exceed this but we will skip that for now, or you can read the video stuff https://mgba.io/2015/10/20/dumping-the-undumped/ ). This differs to some older devices that had to do tricky things to fit more data in directly accessible memory.

However as ROM was reasonably expensive during the GBA era then the vast vast majority of games are 16 megabytes or less. If you go for pointer level addressing (and the GBA CPU, ROM and everything else does on the GBA) that is between 000000 and FFFFFF to cover the whole area.
This then leads to a popular shorthand that GBA pointers start with 08. In practice it is more like you add 08000000 to the address in the ROM to find the pointer. If you go above 16 megabytes you then end up in the 01000000 through 01FFFFFF range. Add 08000000 to that and you end up with 09000000 through 09FFFFFF or collectively 08000000 through 09FFFFFF for the entire ROM. That is not even a complete workup if you do count the later waitstate stuff, though in practice it will probably still work as most things don't have timings issues.

Not everything will use a direct pointer like that, sometimes things get copied to memory first (including program code), sometimes it will point to the start of a section and then add values to get to the final destination (think first paragraph, second line, third word in normal human pointers, or in the case of games start of the section, here are values to either get to the first, second, third... sentences say, or maybe you get a start and it adds values each time (this 500 to start, add 10 to get to the second, add an additional 15 to get to the third...). This is pointer maths, offset pointers and relative pointers, some of which are less common on the GBA than they are on the DS where would not bet against any appearing in any random game you plucked out to have a look at but I still have GBA examples. You might have even found another such example.
There is also fixed length (common in menus -- no need for the game to play with pointers if it is just new line every 10 bytes or whatever the devs picked) and parsed wherein the game will automatically detect end of line/section and start a new one (just like your PC does when typing and probably what the web browser you are reading this on is doing). Parsed is generally viewed as a waste of resources by programmers (it is not like the game text changes after you burn the ROM) so it is seldom done beyond maybe auto new line, however that you can do with a simple counter as you are fetching data or maybe animating text being written on screen rather than having to check for control bytes.

Random 00 in the middle of data can also be a sign of compression -- some types of LZ will have a control character to say "no compression here" and then have something else when you actually have compression. Though if it is not a fixed distance apart then probably not.