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

Author Topic: Editing the Eye Whites in Super Mario Bros. 2  (Read 2359 times)

Cam

  • Newbie
  • *
  • Posts: 2
    • View Profile
Editing the Eye Whites in Super Mario Bros. 2
« on: June 16, 2014, 10:16:43 pm »
Hi everyone. Apologies in advance if I'm posting this in the wrong forum. I'm new, but questions are more important than introductions in my case.

Me and a friend are hacking Super Mario Bros. 2. In the game, the whites of the characters' eyes are overlayed (underlayed?) the main sprite, as a workaround for the three color rule on NES. We've edited the graphics of the main characters and have run into a bit of a fuzzy pickle. The whites themselves seem to be 16 pixels tall, 8 pixels wide, and just large enough to work for the original characters they were intended to be used with. Now the problem at hand is that me and my friend are incapable of changing the whites to use beyond the 8x16 tiles that they normally use. Otherwise, we'd expand the eyes to a full 16x16.

I filled in the entirety of the tiles for Mario's eyes with white (a full 16x16) to experiment, leaving me with this-

Showing the 8x16 restrictions set. I've poked around with a hex editor and came up with nothing. I'm not sure how I'll be able to extend the eyes to fit the new characters, ideally by duplicating the same white tile twice to fill the eyes.

I checked the datacrystal page on the eye addresses and the point for Mario's eyes leads me back to D5 in the ROM-

Which is the highlighted location right here, already edited to fit the new character. According to datacrystal, Luigi's eyes point to D9, which is accurately his eye graphic location right beside Mario's at D5, so I must be in the right place.

Does anyone have any idea how I could go about fixing this problem by possibly expanding this sprite size?

EDIT: Also, as a side note, it seems like the one pixel bob that characters make as they run (all characters sans Peach, at least) is done through code. Is there any way I could also apply that bob code to Peach as well?

Mattrizzle

  • Jr. Member
  • **
  • Posts: 43
    • View Profile
Re: Editing the Eye Whites in Super Mario Bros. 2
« Reply #1 on: June 17, 2014, 06:10:26 am »
I don't know the answer to your first question, but I answered the second one for someone else here.

Vanya

  • Hero Member
  • *****
  • Posts: 1487
    • View Profile
Re: Editing the Eye Whites in Super Mario Bros. 2
« Reply #2 on: June 17, 2014, 06:48:50 am »
I think the better solution for you instead of doubling the size of the whites into 16x16 there by adding an extra sprite.
(more sprites = more potential sprite tearing)
What you want to do is find the code that writes the sprite properties to the OAM and shift the whites sprite over a couple of pixels relative to the character's other sprites.
Assuming I'm remembering correctly how this all works that should be all you need to do to get your desired effect.

Here's the wiki entry for the PPU OAM: http://wiki.nesdev.com/w/index.php/PPU_OAM
« Last Edit: June 17, 2014, 06:54:28 am by Vanya »

Cam

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Editing the Eye Whites in Super Mario Bros. 2
« Reply #3 on: June 17, 2014, 02:36:26 pm »
Thank you so much for the help, I'm so glad the bumpy run works now with that hex edit!

As far as editing the position of the eyes, how would I go about doing that? Where would I even start? Would I have to edit something based on the sprite positions listed here or would I just fiddle around with the whites again through the addresses listed here? I'm really sorry, I'm not exactly experienced with this kinda stuff. I've done some stuff in the past but nothing super complicated. Although I guess this isn't super complicated either. Thank you SO much for helping me though, I can't stress that enough. I thought I'd never figure this stuff out.

RadioShadow

  • Sr. Member
  • ****
  • Posts: 333
  • Holding the Mega Drive controller
    • View Profile
Re: Editing the Eye Whites in Super Mario Bros. 2
« Reply #4 on: June 18, 2014, 06:11:54 am »
It's actually really simple.  When I get home, I'll post the information.

The game is programed to allow one of the 8 x 16 (two tiles) in the PPU to be be placed behind the player.

O = Behind Tiles
X = Front Tiles

XO
XO
XX
XX

For when the players shrink:
XO
XO
XX

The good news is, for each character, you can decide which tiles to load.

The only thing I could not figure out was adjusting the height of the items they pick up.

Vanya

  • Hero Member
  • *****
  • Posts: 1487
    • View Profile
Re: Editing the Eye Whites in Super Mario Bros. 2
« Reply #5 on: June 18, 2014, 06:20:57 am »
Thank you so much for the help, I'm so glad the bumpy run works now with that hex edit!

As far as editing the position of the eyes, how would I go about doing that? Where would I even start? Would I have to edit something based on the sprite positions listed here or would I just fiddle around with the whites again through the addresses listed here? I'm really sorry, I'm not exactly experienced with this kinda stuff. I've done some stuff in the past but nothing super complicated. Although I guess this isn't super complicated either. Thank you SO much for helping me though, I can't stress that enough. I thought I'd never figure this stuff out.

The first thing you'd need to do is open the game up in FCEUX and look at the PPU memory in the hex editor and go to the address of the OAM.
Look at the sprite data that is loaded in there and usung the info in the link I posted try to figure out what is what. You an manually edit the info to help find what you're looking for.
Make note of the values for the whites sprite and try to find it in the ROM by a direct search. If you're lucky it's stored verbatim in the game.
Then you just have to adjust the values to your liking.
If it's not stored verbatim, then you'll have set a write break to the address in OAM that belongs to the whites sprite and track down the code that writes to OAM and adjust it as needed.