Metroid Learning – Player data in the cartridge

An analysis of Super Metroid’s user interface revealed that the AI would perform best when it tried to keep the values of available energy and  ammunition as high as possible at all times. To make the AI focus on these values, it needs to know them. To get to that point, the pointer addresses of these values are needed – in short: more ROM hacking.

In this blog, I will dig into the game cartrigde to find pointers that are needed for the game script.

Hex Editing

Since the information lies in the user interface, which is basically text, it makes sense to start to look for text. Text is stored in the pointer table of the ROM – in the shape of hexadecimal numbers. Thus, the act of editing text requires a hex editor.

For now, I will not go too much into this kind of editing, since it comes with many encoding issues, which are troublesome. However, I will at least try a familiar tool: HxD.

 

HxD

When I first tried to find sprite pointer addresses for the spritelist script, I stumbled over HxD as a common choice for editing anything pointer table related. In most cases, however, it is used for editing text. After opening a valid SNES ROM, it displays a pointer table on the left hand side while also showing its decoded meaning right next to it, as shown in Figure 1. Some games have texts that are ASCII encoded, which would be the best case scenario, since a keyword search would be possible. Unfortunately, a search for the keyword ‚ENERGY‘ revealed that this game is not ASCII encoded, as shown in Figure 2. (cf. [https://www.romhacking.net])

Figure 1 – Super Metroid pointer table in HxD

 

Figure 2 – HxD Energy search

 

SRAM Hacking

Save RAM, or SRAM in short, was used in nearly all Nintendo games to save progress in the cartridge prior to memory cards and hard drives. SRAM is a special segment of memory that is stored using a battery that is part of the cartridge, and enables games to save some memory from being erased when the SNES was turned off. Today, all of these batteries are most likely dead.

Why is SRAM important all of a sudden? Because it preserved game progress for Super Metroid within a block of circa 8200 bytes. Depending on the emulator, this segment of storage could be used for this task. (cf. [https://gamefaqs.gamespot.com])

The document linked in the source for SRAM hacking contains pointer addresses for player data. Due to the hardware-heavy nature of this approach I am hesitant to take these addresses for granted, though.

 

RAM Maps

As a final approach to find answers, I tried the classic way of handling questions – Google. This lead me to RAM maps, which analyze every single byte of the ROM and try to find its meaning in the game. (cf. [https://jathys.zophar.net])

This map provides every piece of information needed for the game script.

 

Sources:

[http://www.romhacking.net]
Tables and Text Editing: http://www.romhacking.net/start/#text (10.06.2019)

[https://gamefaqs.gamespot.com]
SRAM Hacking Guide by jdratlif: https://gamefaqs.gamespot.com/snes/588741-super-metroid/faqs/39409 (10.06.2019)

[https://jathys.zophar.net]
Super Metroid RAM map: https://jathys.zophar.net/supermetroid/kejardon/RAMMap.txt (10.06.2019)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

9 + 18 =