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

Author Topic: Editing the title screen in Super Mario Bros. 2 (USA)?  (Read 959 times)

chocobo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Editing the title screen in Super Mario Bros. 2 (USA)?
« on: October 28, 2017, 02:33:14 am »
Hi, I'm currently trying to edit the title screen in Super Mario Bros. 2 on NES. Using Bizhawk's nametable viewer for reference, I took note of the tile numbers that were used, and how they were arranged. After trying to search for them in the ROM with a hex editor, it isn't able to find the tile patterns all. Is it possible that the title screen's hex layout is compressed in the ROM, or am I taking the wrong approach to this?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6744
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Editing the title screen in Super Mario Bros. 2 (USA)?
« Reply #1 on: October 28, 2017, 12:56:54 pm »
Compression is certainly a possibility, given that title screens have lots of repeat data which makes them compression candidates.
But one other thing to check is that often NES games would store tile data (level blocks but sometimes title screens as well) in squares.
You could try searching tile numbers in a 2x2 square. (that is the first tile, the one next to it, and then the two below those)
(though I would imagine if a game is using the squares method, which I've seen called TSA or Tile-Squairoid Assembly in very old documents, it would be aligned to even and odd rows of the tilemap. To do that, you would have to count tiles, if that nametable viewer allows you to see gridlines. Though if you are counting, you would have to factor in the very top and very bottom rows which are usually omitted, either by default or always, for NTSC games in NES emulators)
"My watch says 30 chickens" Google, 2018

Psyklax

  • Hero Member
  • *****
  • Posts: 892
    • View Profile
    • Psyklax Translations
Re: Editing the title screen in Super Mario Bros. 2 (USA)?
« Reply #2 on: October 28, 2017, 03:00:41 pm »
It's helpful to get acquainted with 6502 assembly when doing hacking like this for the NES. I'd use FCEUX: Bizhawk is fine but not as specialised and easy to use.

Look at the name table for a tile, find that location in PPU memory then right-click to do a write breakpoint to see when that location is written to. When the title screen is written, the debugger will pop up to show the instruction writing to that address, usually STA (store contents of the Accumulator). If you're lucky, it'll say directly above it where that came from in the ROM (if it's an address above $8000) and you can find it in the RAM then right-click "go here in ROM".

If it comes from somewhere under $8000, it's probably gone from ROM to RAM to the PPU, which means you need to investigate further.

chocobo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Editing the title screen in Super Mario Bros. 2 (USA)?
« Reply #3 on: October 28, 2017, 03:40:01 pm »
I tried searching in blocks at first, which lead me to find a segment of the tilemap I wrote down. After investigating further (and some trial and error), it seems that the tile arrangements for the title screen actually are stored totally uncompressed; practically row-by-row (with some extra bytes in between to separate each row). The layout for the logo seems to start at offset 176D in the ROM.

Thanks for helping me look into this!

RadioShadow

  • Sr. Member
  • ****
  • Posts: 322
  • Holding the Mega Drive controller
    • View Profile
Re: Editing the title screen in Super Mario Bros. 2 (USA)?
« Reply #4 on: November 01, 2017, 04:01:45 am »
I'll post the information when I get home.

The way it works is the following:
XX YY SS DD

XX = X Position in Background
YY = Y Position in Background
SS = Number of tiles to display horizontally.
DD = Tile ID (insert the amount you set in SS).

The same for when you tell which palette set to load.

November 05, 2017, 02:10:01 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
The tiles that make up "Super Mario Bros. 2" and the copyright Nintendo are located here: 00176A – 001891
The tiles that make up the title can be found here: 02A010

This is all the space you have to tell the game what tiles to load and the attribute (what palette set the tiles should use).

I use FCEUX, which has a Name Table Viewer.  Use that to find the X / Y position where to start placing the tiles (use the top left image).  Make a note of the PPU Address, which is two bytes.  Use the PPU Viewer to see what tiles you can load.

So you have to tell the game to load each horizontal tiles.  The format is:
- PPU Address
- Number of tiles to load
- Each tile ID

So here's an example:
21AA 05 D1D2D3D4D5

You also need to tell the game which palette the tiles you can use.  I would recommend reading this: https://wiki.nesdev.com/w/index.php/PPU_attribute_tables

using that same space, you need to send byte data to 23C0.  That's the PPU RAM that controls what palette each tile can use.

- Attribute Address (always 23C0)
- Number of sections to cover
- Each palette to change.

So to make those tiles you palette set 4:
23DA 02 FFFF

Hope that helps.  It maybe worth checking the Pony Poik Panic (V1.1) I released if you want to an example in action.  http://www.romhacking.net/hacks/791/

« Last Edit: November 05, 2017, 02:10:01 pm by RadioShadow »