0

Objective - Play Mario game and record the score and position, and later map it to level map png (https://nesmaps.com/maps/SuperMarioBrothers/SuperMarioBrosWorld1-1Map.html)

Method - I can get the score, however figuring the position is tricky. In FCEUX I am watching few RAM registers (explained below) to extract the mario and screen position, when playing NES Super Mario Bros.

Memory map - https://datacrystal.romhacking.net/wiki/Super_Mario_Bros.:RAM_map

Relevant registers -

0x006D  Player horizontal position in level
0x0086  Player x position on screen
0x071C  ScreenEdge X-Position, loads next screen when player past it?
0x071D  Player x position, moves screen position forward when this moves
0x0755  Player_Position For Scroll. It moves up to 0x70 (sometimes even 0x72) when player moves. When this register is frozen, NOTHING changes in the level, not even internally.

Current understanding - It looks like the level is divided into sections (section number is given by 0x006D), however I'm not able to figure out how to calculate the absolute left screen edge position and absolute mario position.

  • Mario isn't screen-based; it loads new bits of the level column-by-column, as needed. There's basically a wrap-around screen buffer, and the bit that goes off the left-hand side gets replaced with the new part of the level. I can't remember much else about how it works, though; my only advice is to mess with Mario's top speed, because that desynchronises the level loading from Mario's position and allows you to investigate that in more detail. – wizzwizz4 Jul 1 at 10:28
0

I can't give you a direct answer, but you should look into Mesen (https://www.mesen.ca/) and use the PPU viewer. The NES has 4 nametables, which are filled when not used, then read from when the screen "moves". You might be able to get an answer from this (or you might find this to become too complex as well, just as a little warning).

The relative x/y positions can easily be tracked by the sprite position (see Sprite Viewer tab).

enter image description here

| improve this answer | |
0

I logged the values of various registers while playing game and arrived at the following equations -

Absolute player position = (value at 0x006D * 256) + value at 0x0086  

Absolute left edge position = (value at 0x071A * 256) + value at 0x071C

where,

0x006D  Current screen (in which the player is currently in, increase or decrease depending on player's position)
0x0086  Player x position on screen
0x071A  Current screen (in level, always increasing)
0x071C  ScreenEdge X-Position
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.