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

Author Topic: Mega Man 2 (NES) TSA Properties via FCEUX Lua  (Read 1229 times)


  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Mega Man 2 (NES) TSA Properties via FCEUX Lua
« on: August 12, 2015, 11:26:35 pm »
Hi, guys! Maybe you can give me a hand here.

I'm trying to make a mini-map (current screen only, sprites + walls) for MM2 using the FCEUX Lua scripting feature. For now, I'm able to retrieve all sprite positions and types from RAM. Also, I managed to use $2006/$2007 to read the nametables and detect all current 8x8 tiles. However, reading the tiles directly does not give me air/wall information. So, after some research, I'm thinking I'd need to read TSA properties for 16x16 blocks on current screen instead of individual tiles. I could find and read this data directly from the ROM, but I'd need to know where to start reading, in order to capture only the current screen. How can I do that? Is there some pointer in RAM? Another possibility (would be prefered) would be to intercept the game while it reads from ROM to RAM. I suppose there must be some RAM address where the game receives each TSA block on screen. Where is it? I could monitor this RAM address and draw each 16x16 block on my mini-map accordingly as they "arrive", whenever it is a wall.

August 15, 2015, 04:20:36 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
I did it! :D (source included in the video description)

I had to read the ROM and use current stage ($2A) + current screen ($440) + scroll X ($1F) from RAM to figure out the exact position of current screen info. First stage is at $10 in rom, starting with solidity info. $510 stores the map layout itself. Each code in the map maps to a tile property at $10. Next level starts at $4010 , the next at $8010 and so on. Rock5easily's editor helped a lot to figure out the codes and addresses.
« Last Edit: August 15, 2015, 04:20:36 pm by rcpinto »