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

Author Topic: Please help with color palette referencing in Mega Man 2!  (Read 11543 times)

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Please help with color palette referencing in Mega Man 2!
« on: June 22, 2013, 02:09:10 pm »
Greetings, programs!

While I am new to ROM hacking, I'm far enough in my project where I don't think it was a good fit for the newcomers board; instead I've got a pretty specific technical question I'd like to get some help with if anyone can.

I'm doing a straightforward hack of Mega Man 2, just reskinning Mega Man to look like my cousin Corey. So far, I've been using Tile Layer Pro, HxD hex editor, NES Palette Editor, FCEUX emulator debug tools, and on one occasion, Nesticle 0.42. I've successfully changed the Mega Man sprite's color palette throughout the entire game, as well as the color palettes for each of the weapons. The new Corey sprite has blue eyes, so I changed the face tiles so that the color previously assigned to white for Mega Man's eyes is now blue, and the Corey face sprite shows blue pupils with no surrounding white (basically, from Mega Man's black/white/skin palette to Corey's black/blue/skin palette).

Here is a mockup of the sprite, but it looks exactly like this in-game.


Also, I used the text table found on DataCrystal to edit the text in the opening sequence and in the game, but there were only tables for those two areas, and neither of them worked for the end credits. So with a little digging around, I found the table for the end credits and added it to the page a couple of nights ago. Hope it helps somebody else! http://datacrystal.romhacking.net/wiki/Mega_Man_II:TBL


Here are the issues that I'm having now:
Because I reassigned Mega Man's white to blue for Corey's eyes, other places in the game also began referencing blue where it should have been white. In most cases, it was in enemy sprites, and I was able to edit the tile so that the blue was replaced with another color in its own palette and look good enough to pass.

I ran into a bigger problem, though, when I noticed that the Dr. Wily sprites for the final battle sequence are blue, also. Most of the tiles that make him up are black/white/skin, so they apparently share the palette with Mega Man's face (black/white/skin). Since I replaced Mega Man's white with blue, Wily shows up like this:




So he's all blue instead of white, except for that one tile with his foot, which obviously references another palette to allow for the pink socks, or whatever they are, which are the way they look originally.


For the next few points, here is the original Mega Man weapon upgrade screen sprite:





The helmet is one palette (white/light blue/dark blue), the face is another (white/light skin/shadow skin), and the body is another (light blue/dark blue/gray, for the floor shadow).
I've been able to change the sprite and palettes to match the Corey sprite:





I've also changed the weapon color palettes so that instead of two colors changing, only corey's shirt/shoes/hair (what's brown) change, and his skin tone remains the same color. Here he is after Item-3; instead of red/white, he's red/skin:





This also translates to in-game, here's an example of Heat Man's weapon. Instead of red/yellowish, he's red/skin:





Again, the issue I'm having is with color palette assignment, this time on the ending sequence. Although I've been able to change all these palettes within the game, the ending sequence seems to reference another palette I've had trouble pinpointing. So, even though it's different at the weapon upgrade screen and in-game, the end credits sprites (which I haven't completely edited to look like Corey yet) must be pulling their color information from elsewhere.


Here's you can see blue on Mega Man's face around his mouth and eyes, meaning it references the same palette as the face sprite for the weapon upgrade screen, which I changed from (light skin/skin shadow/white) to (light skin/blue/white) for Corey's blue eyes. Also, the only different tiles from the weapon upgrade screen are the shoulders up, but for some reason the Corey tiles are still referencing a blue palette instead of the brown one.





Same goes for this last helmet shot, I don't know why it's still blue:





Same goes for the weapon palettes; here's Heat Man's normal red/yellowish palette even though I've changed the in-game from yellow to a skin tone (but you can see the blue from the altered face sprite palette):






So I need help finding and changing these palettes! The method I've used so far is FCEUX's PPG Viewer, which shows the tiles and palettes being displayed in real-time as the ROM is running, finding the hex values for the color palette I want to change, searching for the string of hex values with the HxD hex editor, and then double-checking and changing them to what I want with NES Palette Editor.


Even in the case of the ending sequence palettes, where I already know what hex values Mega Man's blue palette are (0F 2C 11, in most cases), my search for that hex sequence doesn't return me anything. So I need help in finding and changing the main Mega Man palette from blue to brown, and then finding the palettes for the boss weapon colors that Mega Man cycles through during the ending sequence. As well as the color palette for that last helmet shot.


Also, if there is a way, in the case of the Dr. Wily sprite, for me to actually change the reference data for the tile. In the case of that last battle with Wily, he's sharing a palette with my Corey sprite, and the blue eyes are a must. So is there a way to redirect the Wily tiles so that they'll reference a different palette altogether?


I'm really sorry to have written a novel on my first post, guys, but this is my first time ROM hacking and I've really, really enjoyed the project! I'm hoping you will have answers and suggestions for me. And please, please, assume that I have no idea what I'm doing, explain things like I'm 5, ask me any possible question you think might lead me in the right direction. I'd like to surprise my cousin with this, so I really want to make it as complete as possible. Thanks in advance!!!

Zynk

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 902
  • WIP Roll-chan: The Wily Wars
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #1 on: June 22, 2013, 09:32:04 pm »
Heys!  :D

Maybe I could help you with those palette issues. I'm also doing a skin mod for this game. I'll give the offsets for those palettes I've gathered with my notes. But I'm not sure if these are correct b/c I'm doing also the JP version as well & their offsets differ from the US version.

ENDING PALETTE
00037A70-00037A80


As for you changing the FACE PALETTE, did you also altered the face palettes of the Robot Masters? I can imagine that it also affected their face palettes.

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #2 on: June 22, 2013, 11:15:08 pm »
Thanks! It's funny, I've been keeping notes on what I found and already had 00037A70 - 00037A80 noted as a possibility, but wasn't for sure on it. But now that you mention it and I go back and look at it, I totally believe you're right, I think it's just the same.

Also, yes, I ended up altering the face TILES on most of the Robot Masters (except Wood Man didn't seem to be affected?), so when the white in the eyes of the Robot Masters changed to blue when I altered the palette, I just filled in the white with their skin color. It doesn't make a terribly noticeable difference and seemed acceptable enough to me.


I'm going to try the ending sequence palette and get back to you. In the meantime: any thoughts on what to do about Wily??

Drakon

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • 16 Bit Gamer
Re: Please help with color palette referencing in Mega Man 2!
« Reply #3 on: June 22, 2013, 11:21:46 pm »
Instead of changing existing pallettes, why not redraw these sprites to use the according pallette values that the game already uses?

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #4 on: June 22, 2013, 11:59:12 pm »
Instead of changing existing pallettes, why not redraw these sprites to use the according pallette values that the game already uses?

Well, I really wanted to skin Mega Man to look like my cousin, which required brown hair and skin tone on the arms. Had I stuck with Mega Man's palette, he'd have had blue hair and light blue arms. Plus he really needed blue eyes to complete the resemblance. As a result, I've inadvertently changed some of the colors of other sprites, and so I'm trying to remedy that as best I can.

Drakon

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • 16 Bit Gamer
Re: Please help with color palette referencing in Mega Man 2!
« Reply #5 on: June 23, 2013, 07:25:44 am »
Well, I really wanted to skin Mega Man to look like my cousin, which required brown hair and skin tone on the arms. Had I stuck with Mega Man's palette, he'd have had blue hair and light blue arms. Plus he really needed blue eyes to complete the resemblance. As a result, I've inadvertently changed some of the colors of other sprites, and so I'm trying to remedy that as best I can.

That's a problem with romhacking is shared pallette data.  I encountered this issue many times with the street fighter 2 champion edition arcade romset.

Zynk

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 902
  • WIP Roll-chan: The Wily Wars
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #6 on: June 23, 2013, 07:46:29 am »
In the meantime: any thoughts on what to do about Wily??
Wily has 2 or 3 sprite banks in CHR. One is where Alien Wily is; the groveling Wily is with the Wily Machine. I don't know the offsets, you're on your own finding those that I mentioned.

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #7 on: June 23, 2013, 12:52:03 pm »
Wily has 2 or 3 sprite banks in CHR. One is where Alien Wily is; the groveling Wily is with the Wily Machine. I don't know the offsets, you're on your own finding those that I mentioned.

Can you clarify what you mean by "sprite banks in CHR"? The Wily in my hack is blue in the animation where he is floating and changes into the alien, after beating the alien when he's standing behind the controls, and when he grovels.

I know with a pretty fair measure of certainty that he shares this blue with the one I put in Mega Man's face palette. I can't just change his lab coat to skin tone, otherwise he's gonna look naked and really creepy -- actually, that might be hilarious. I'll have to see how it looks.

So, is there any known way to change the palette that the Wily sprite references?

Zynk

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 902
  • WIP Roll-chan: The Wily Wars
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #8 on: June 23, 2013, 10:47:48 pm »
Can you clarify what you mean by "sprite banks in CHR"? The Wily in my hack is blue in the animation where he is floating and changes into the alien, after beating the alien when he's standing behind the controls, and when he grovels.

IYou can see those in YY-CHR utility. So ALL of Wily's palette were all affected with the face palette change...?
If you don't want to giveup your cousin's blue eyes, then you'll have to stick with Krusty the Clown--I mean, Blue-haired Wily.  :P

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #9 on: June 24, 2013, 12:21:18 am »
IYou can see those in YY-CHR utility. So ALL of Wily's palette were all affected with the face palette change...?
If you don't want to giveup your cousin's blue eyes, then you'll have to stick with Krusty the Clown--I mean, Blue-haired Wily.  :P


Yeah, looks that way. I don't know what I'm going to do about his white foot, though... I'll have to see if I can find that palette and change it to blue or something, just to keep it all together.

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Please help with color palette referencing in Mega Man 2!
« Reply #10 on: June 24, 2013, 09:23:30 am »
As far as shared palettes go, you could fix that by adding a new palette in some free space of the ROM, and changing the pointer for either Megaman or Wily (whichever you want to have their own new palette) to point to the new palette.

Depending on how the code for palettes work this could be really easy or fairly difficult. If you know where the palette of interest is in ROM, I'd suggest just setting a read breakpoint on that address in FCEUX's debugger. From there you can figure out how it is calculating the address it's using to load the value from. If you're lucky it will just be loading a pointer, and hopefully you can change just the pointer to Megaman or Wily without it affecting anything else.
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #11 on: June 24, 2013, 09:39:41 am »
As far as shared palettes go, you could fix that by adding a new palette in some free space of the ROM, and changing the pointer for either Megaman or Wily (whichever you want to have their own new palette) to point to the new palette.

Depending on how the code for palettes work this could be really easy or fairly difficult. If you know where the palette of interest is in ROM, I'd suggest just setting a read breakpoint on that address in FCEUX's debugger. From there you can figure out how it is calculating the address it's using to load the value from. If you're lucky it will just be loading a pointer, and hopefully you can change just the pointer to Megaman or Wily without it affecting anything else.

Yeah, this. All this. I want to be able to do this. I may have to do it differently, though, and I'll explain why I think so, and you tell me if I'm totally wrong.

Since Wily and Mega Man are sharing a palette, if I "set a read breakpoint" (which I assume is like some sort of running check for a desired value?) for the color palette, it will register with Mega Man long before I get to Wily.

What would be more desirable is if there were a way to check for Wily's TILE data and see if I could redirect the palette to which the tile points. Do you know how tile data is represented? I'd assume it's a hex value with an offset like everything else, but I'm not sure how to find out an exact tile location and then use it in a program like debugger.

If you have any more information, please let me know. I worked on it some last night and was just about ready to tie up some loose ends and call it finished with the Wily bug, but you've just sparked a new interest in getting it remedied. So thanks!

M-Tee

  • Hero Member
  • *****
  • Posts: 595
  • One pixel at a timeā€¦
    • View Profile
    • M-Tee Retro Graphics
Re: Please help with color palette referencing in Mega Man 2!
« Reply #12 on: June 24, 2013, 09:40:36 pm »
Or you could redesign your character sprite. Blue in the eyes is definitely not essentially, and portraying glasses as solid white is pretty common.  ...or you could make a new design to replace Wily with using your new palette.

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Please help with color palette referencing in Mega Man 2!
« Reply #13 on: June 24, 2013, 10:37:34 pm »
Since Wily and Mega Man are sharing a palette, if I "set a read breakpoint" (which I assume is like some sort of running check for a desired value?) for the color palette, it will register with Mega Man long before I get to Wily.

This isn't as big a problem as you might think. You can use conditional breakpoints in FCEUX to avoid breaking in certain locations. Or you can just replace the instruction that it's breaking at with a NOP (might mess up Mega Man, but will prevent breaking).

Quote
What would be more desirable is if there were a way to check for Wily's TILE data and see if I could redirect the palette to which the tile points. Do you know how tile data is represented? I'd assume it's a hex value with an offset like everything else, but I'm not sure how to find out an exact tile location and then use it in a program like debugger.

If you have any more information, please let me know. I worked on it some last night and was just about ready to tie up some loose ends and call it finished with the Wily bug, but you've just sparked a new interest in getting it remedied. So thanks!

I actually don't have much experience with the NES, so I can't give you specific information. However, you can easily find out how all that stuff works by reading technical documents. For example: http://wiki.nesdev.com/w/index.php/PPU

From here: http://wiki.nesdev.com/w/index.php/PPU_palettes, it looks like there are 4 sprite palettes, stored from $3F11-$3F1F. It then says: "The choice of palette is in attribute 2 of each sprite (see PPU OAM)."

On the PPU OAM page, it shows how the OAM memory works. The lower 2 bits of byte 2 control what palette the sprite is. I can't actually find anything that says where the OAM memory actually is (I think the PPU might have it's own memory on the NES, as opposed to other systems where it is just part of RAM), so you'll have figure out where the memory for Wily's sprite is, and set a breakpoint on the 2nd byte of it. Then you can look at the code to see how it is setting which palette number it is using and how to change that. I do believe FCEUX has a different setting for PPU breakpoints, so I'm pretty sure this is possible.

Good luck!
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

theataraxian

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #14 on: June 25, 2013, 10:04:18 am »
This isn't as big a problem as you might think. You can use conditional breakpoints in FCEUX to avoid breaking in certain locations. Or you can just replace the instruction that it's breaking at with a NOP (might mess up Mega Man, but will prevent breaking).

I actually don't have much experience with the NES, so I can't give you specific information. However, you can easily find out how all that stuff works by reading technical documents. For example: http://wiki.nesdev.com/w/index.php/PPU

From here: http://wiki.nesdev.com/w/index.php/PPU_palettes, it looks like there are 4 sprite palettes, stored from $3F11-$3F1F. It then says: "The choice of palette is in attribute 2 of each sprite (see PPU OAM)."

On the PPU OAM page, it shows how the OAM memory works. The lower 2 bits of byte 2 control what palette the sprite is. I can't actually find anything that says where the OAM memory actually is (I think the PPU might have it's own memory on the NES, as opposed to other systems where it is just part of RAM), so you'll have figure out where the memory for Wily's sprite is, and set a breakpoint on the 2nd byte of it. Then you can look at the code to see how it is setting which palette number it is using and how to change that. I do believe FCEUX has a different setting for PPU breakpoints, so I'm pretty sure this is possible.

Good luck!

So, last night I was up late and read as much of this information as I could possibly understand. The FCEUX Hex Editor allows you to look at three separate views: NES Memory, PPU Memory, and the ROM File. When looking at the PPU Memory page, I was definitely able to see the data that's explained in your links. The NESDEV pages on the PPU seem to all be concerned with locations in PPU Memory.


What I still fail to understand, though, is how to find data within the ROM File that determines how a sprite or tile is assigned its palette. When I'm looking at the PPU Memory in hex editor, I can see the value that's already been loaded into PPU RAM, but I don't know why it's been loaded. I don't know what other information in the ROM decides that.


I'm going to keep trying, at least a little longer. Otherwise, blue Wily will be a feature in this game.  ;D

Spikeman

  • Hero Member
  • *****
  • Posts: 1063
  • *unce unce unce*
    • View Profile
    • None at the moment, check out my Last.fm page instead?
Re: Please help with color palette referencing in Mega Man 2!
« Reply #15 on: June 25, 2013, 06:12:10 pm »
What I still fail to understand, though, is how to find data within the ROM File that determines how a sprite or tile is assigned its palette. When I'm looking at the PPU Memory in hex editor, I can see the value that's already been loaded into PPU RAM, but I don't know why it's been loaded. I don't know what other information in the ROM decides that.

That's what the debugger is for! If you found the data in PPU RAM you're almost there - you just need to set a breakpoint on the value in RAM you found, and follow the code backwards to see where the value was loaded from ROM.

If you make a savestate before Wily appears and upload it for me I could guide you through the debugging process. (A patch might be helpful too!)
Open Source Hacking Projects: Guru Logic Champ, Telefang 2, (Want more? Check out my GitHub!)

Drakon

  • Sr. Member
  • ****
  • Posts: 277
    • View Profile
    • 16 Bit Gamer
Re: Please help with color palette referencing in Mega Man 2!
« Reply #16 on: June 25, 2013, 09:57:58 pm »
Basically you need to learn enough nes asm language to find where the data is loaded.  It's a pain.

NickCox01

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Please help with color palette referencing in Mega Man 2!
« Reply #17 on: December 15, 2014, 02:55:56 am »
theataraxian, I know that it was your idea on doing that for your custom Mega Man game, but I'm trying to go for that same approach, but altering the eye color to green, for you see that my eyes in real life are green! I can't get a hex editor to work on my Windows 8 laptop at all, so I tried the built in one with my FCEUX emulator, and do you wanna know of my current progress on how i did it? :|