Read sprites directly from cartridge

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
Tobnie8
Posts: 2
Joined: Sat Sep 24, 2022 5:04 am

Read sprites directly from cartridge

Post by Tobnie8 »

Hi! I'm a IT technology students and new in this forum :D Question: I'm during a project where i want to read sprite data directly from the cartridge, not running the game itself( thinking about using a atmega1284p).
I quess i can read the pattern tables directly from the character ROM chip with the pins connected to it.
But i need the OAM data to know how the tiles are connected, how many to each sprite, the palette and so on.
I'm a bit confused on where to find this data? Is it different from each game, or is there a pattern to look for? I think i have seen and read too many tutorials and got a bit confused:b
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Read sprites directly from cartridge

Post by tokumaru »

Even though the OAM requires a very specific data format, there's absolutely no standard to how sprite data is stored in the ROM prior to being converted by the game program into what eventually gets written to OAM.

Some games use a format similar to what goes in the OAM (x, y, pattern, attributes), only with x and y being relative to the base coordinates of an object, either preceded by a sprite count or followed by a terminator byte. But there's no way to tell where in the ROM this data is, in what order the bytes are stored, or whether a sprite count or terminator byte is used. Other games use more compact formats, with sprites commonly arranged in grids, with a header indicating the dimensions of the grid and other attributes.

To properly draw sprites you also need to have the correct palettes set up, and just like with OAM data, there's no way to tell which palettes will be in use when a sprite is drawn or where in the ROM that data is and in which format.

Another concern is CHR bank switching - unless we're talking about an NROM game, which only has 8KB of CHR-ROM that gets mapped permanently to the pattern tables, you have no way to know which banks will be in use when each meta sprite is used. If the game uses CHR-RAM things are even worse, because the CHR data can be buried anywhere in the ROM, possibly even compressed.

In short, there's basically no way to extract meaningful sprite data from an unknown ROM without actually running the game and actually probing the relevant sections of VRAM. However, if this is a specific ROM, you can manually reverse enginner it to learn where all the data is and the formats that everything uses.
Tobnie8
Posts: 2
Joined: Sat Sep 24, 2022 5:04 am

Re: Read sprites directly from cartridge

Post by Tobnie8 »

Alright, so it's just as problematic as I feared.
But thank you for the well explained answer, it gave me some new ideas of how to approach the problem :D
So I will probably be back with more questions 8-)
Post Reply