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

Author Topic: Cant find smb3 palette  (Read 6595 times)

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Cant find smb3 palette
« on: September 21, 2015, 12:40:18 am »
Im trying to find a palette for mario 3 but i cant seem to find it. When leaf mario gets hit he goes into a poof animation, one of which is a white circle. Drawing on the tile reveals that it is using the colors red white and black. PPU viewer on fecux shows only one likely candidate for being the palette, yet even using replace all with a hex editor does not have an effect on it. Anyone know why, what am i missing here?

here's a picture of it
http://i.imgur.com/Bx8KAY5.png
 

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Cant find smb3 palette
« Reply #1 on: September 21, 2015, 02:20:16 am »
$36D27-9 in-ROM seems to be those three palette ID#'s. (The "transparency" entry isn't included.)

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #2 on: September 21, 2015, 02:35:09 am »
Are you sure? that changes other things like the white on the mushrooms, turtles and pipe plant things but has no effect on the poof.

September 21, 2015, 02:39:48 am - (Auto Merged - Double Posts are not allowed before 7 days.)
ok n/m you were right and i could have sworn i tried that one along with all the otheres.. must have been a problem with my emulator not updating the new edited rom and was still using the old one... thanks man!

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Cant find smb3 palette
« Reply #3 on: September 21, 2015, 07:01:48 am »
You do realize that SMB3 has a full disassembly, right? Naturally, it includes the locations of the palettes.

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #4 on: September 21, 2015, 12:16:41 pm »
Im aware and I have it, however asm along with rom hacking is kinda new to me so navigating the folder structure and reading the .asm files is a pain to find anything useful to me. Ill get around too tearing it apart sooner or later but for now i dont care to find them by hand. Unless you  can tell me exactly where to look in the disassembly.

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Cant find smb3 palette
« Reply #5 on: September 21, 2015, 01:04:40 pm »
I'd do a search for something like "palette", there can't be that many hits.

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #6 on: September 21, 2015, 08:18:12 pm »
I was able to find the palettes in the disassembly(prg027.asm)and its exactly what I needed! Also the transparent color is listed along with the other three, the problem is who ever coded the ppu viewer for fceux says the color is $00 when its really $FF. That explains all the youtube tutorials that use this method of finding palettes having to take out the 00 to find them. Just figured id post this to let who ever is reading that little bit of info lol.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #7 on: September 21, 2015, 08:57:18 pm »
the problem is who ever coded the ppu viewer for fceux says the color is $00 when its really $FF.

Ehhhh

FCEUX isn't fully to blame here.  The "transparent" colors in the PPU have extremely strange mirroring behavior and are very confusing.

FCEUX probably doesn't display them "properly" in that it likely hides $xxx4, $xxx8, and $xxxC and just displays $xxx0 for all of them -- which is "inaccurate" in a sense -- but if it were to display them properly it would be even more confusing because that's not how the graphics are seen in-game.  FCEUX really has no way to "win" in this scenario -- and the way it does it is probably the most intuitive for most people.


Also, $FF wouldn't be a valid color, as colors would be in the range of $00-3F.  $FF would just be a mirror of $3F, which would be black.  But even $3F is seldom used, as $0F is typically used for black.  Are you sure the $FF is part of the palette?

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #8 on: September 21, 2015, 09:24:55 pm »
Not entirely sure but when matching the colors being used by the levels (bg and sprites) to thos in the prg027.asm anytime $FF is used in the .asm... FCEUX shows it as $00.

September 21, 2015, 09:35:57 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
and i know its not a valid color its just how the transparent is represented in the hex of the rom... but now im having a problem with world 1 fort sprite colors.... fceux is making it hard for real lol
« Last Edit: September 21, 2015, 09:35:57 pm by Hypnotic_rabbit »

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #9 on: September 21, 2015, 09:41:05 pm »
Not entirely sure but when matching the colors being used by the levels (bg and sprites) to thos in the prg027.asm anytime $FF is used in the .asm... FCEUX shows it as $00.

Is there a link to this disassembly?  I didn't see it in the docs section, and googling turned up a page that described it, but didn't actually have a download link to it.

Anyway -- the game might not actually be using those FFs.  They might be padding.

The point is -- you shouldn't include the transparent colors when searching for palettes.

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #10 on: September 21, 2015, 10:00:20 pm »
I got the link from here in one of the threads i made.... but here is the file

https://code.google.com/p/smb3project/source/browse/trunk/SMB3/PRG/prg027.asm

they start on line 1458, also every palette iv looked into includes the FF as part of the 4 so i dunno about not using it man unless you got a good reason why not lol, i may stumble on a reason not to still tho but for now im going to trust the disassembley because it hasn't lied to me yet lol. Also when you say $xxxC a you mean $0C right? Because thats exactly where im having the problem on the world 1 fort.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #11 on: September 21, 2015, 11:33:46 pm »
I didn't see the code that actually loads those palettes, but it looks like sprite palettes use $FF for transparent colors whereas BG palettes do not.

If I were to make an educated guess... I'd say that perhaps the loading code looks for $FF specifically (though any value >= $80 is more likely) -- and if found, it will skip the color rather than draw it to avoid mirroring oddities.

also every palette iv looked into includes the FF as part of the 4

You must not have looked at any of the BG palettes that are listed immediately before the sprite palettes.  ;P    See lines 1460-1467

Quote
Also when you say $xxxC a you mean $0C right? Because thats exactly where im having the problem on the world 1 fort.

Palettes are stored in PPU memory at addresses $3F00 - $3F1F

$3F0x are BG palettes
$3F1x are sprite palettes.

$3Fx0, $3Fx4, $3Fx8, and $3FxC are the slots for "color 0", and are not actually drawn on screen, since color 0 is transparent.

Though $3Fx0 is special because it determines the backdrop color, which is drawn when both BG and sprite pixels are transparent.


But to answer your question, when I said $xxxC I was referring to $3F0C and $3F1C... the transparent color for the final palette for BG and sprites.

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #12 on: September 22, 2015, 12:06:04 am »
Oh yeah i should have been specific lol... i was talking about the sprites FF not the bg. But you got to remember im reading this data into a program.... changing it... and then putting it back... i cant be skipping things and leaving them out like i thought you were saying lol but i understand what you mean by when you are looking for them. But as for the $xxxC/$0C its all good.. just for some reason fceux gives the wrong hex value for 0C but thats ok im just using it to guide me though which palettes go with which levels anyway.... its easy to narrow down with what i get from it then test it. There are a lot more prg.asm files with the disassembly  and im sure the rest of the functions for the palettes are there somewhere, lucky for me i only need the palettes lol.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #13 on: September 22, 2015, 02:02:57 am »
just for some reason fceux gives the wrong hex value for 0C

OK I feel compelled to explain this, even though it doesn't really matter.

Feel free to ignore this post if you don't really care.


As I'm sure you know, NES graphics are 2bpp, which means that any one tile can consist of no more than 4 colors.  3 of those colors are drawn normally -- but one ("color 0") is reserved as transparent and is never actually drawn.  This allows for transparent sprites so that they don't all have to be box-shaped.  It also allows for transparent backgrounds so that sprites can appear behind the nametables.


Therefore, since only 3 colors are drawn, you only need 3 colors per palette.  However, the NES provides 4 colors because it's just easier to work with multiples of 4 than it is multiples of 3.  The result of this is there are completely worthless entries in the palette that are never actually used*.   $3Fx4, $3Fx8, and $3FxC in the palette are never rendered on screen*, even though they actually exist on the actual system.

* Technically you can get the system to draw them, but it's tricky and complicated and not useful.

$3Fx0 would be just as useless, except the NES uses it as the overall backdrop color.  So it never is rendered as part of a BG or sprite tile -- but is rendered when both BG and sprite pixels are transparent.  If you were to layer NES graphics it'd look like this:


Foreground sprite pixels    <- drawn on top
Nametable pixels            <- drawn if no foreground pixel or if that pixel is transparent
Background sprite pixels    <- drawn if NT pixel is transparent
Color $3Fx0                 <- drawn if all of the above are transparent


To make matters even more confusing, $3F00 and $3F10 are mirrored.  There is only 1 backdrop color, even though there are two entries in the palette.  So $3F00 and $3F10 are both the same palette entry.  Effectively, whichever one the game writes to last is the one that changes the backdrop color.

This is probably why SMB3 uses $FF for color 0.  When it sets those palettes in the PPU, it probably skips the $FF entries so it doesn't overwrite the backdrop color by accident.  Since the game probably would want the backdrop color set by the NT palettes, not the sprite palettes.



So how does FCEUX fit in with all of this?  Well it draws the palettes incorrectly sort of.  Because it uses the backdrop color ($3F00) for all the $3Fx4, $3Fx8, and $3FxC entries in the palette, even though those entries may contain something different.

So why does it do that?  Because those colors are never visible, so showing them "properly" would be confusing for most people.  Let's imagine for a moment a game has $0F black for the backdrop color ($3F00), but puts red in $3F04 for some reason.  And let's say that red appears nowhere else in the palette.  Now, if the PPU viewer showed red in the palette, and red in the NT view, and red in the pattern table view -- that would be really confusing and misleading because you would never see red in the actual game.


Long-winded explanation over.  So yeah -- forget about the transparent color.

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #14 on: September 22, 2015, 02:25:16 am »
Nah man anything you got to say im all ears and i understand what you mean by the game/emu not caring about the transparent color but i kind of have to care about it considering im working with the actual data in the rom and having to put it back lol

September 22, 2015, 02:33:01 am - (Auto Merged - Double Posts are not allowed before 7 days.)
And what i mean by working with it is... sure the nes and emu drop the color like its nothing but my prog isnt playing the game but rather its editing it, that includes the transparent color lol
« Last Edit: September 22, 2015, 02:33:01 am by Hypnotic_rabbit »

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #15 on: September 22, 2015, 12:59:43 pm »
but i kind of have to care about it considering im working with the actual data in the rom and having to put it back lol

But if the game isn't using that byte... like if that byte is just padding and/or a flag to not write anything to the PPU, then you kind of don't have to care about it.  Editing it would be more problematic than useful.

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #16 on: September 22, 2015, 02:28:22 pm »
 Well its clearly not buffer padding or a flag its the transparent color lol, but i was kind of tired yesterday when i was trying to explain what i mean by i need to worry about it. No i dont need to edit it or change it, why would i lol? You are right there but when reading the data in and putting it back out into the Rom the strings need be nice and uniform so its just easier to keep them on it rather then cut them off when reading and put them back on when writing lol

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #17 on: September 22, 2015, 03:24:24 pm »
Well its clearly not buffer padding or a flag its the transparent color lol

I think we're miscommunicating.  Whatever

Hypnotic_rabbit

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Cant find smb3 palette
« Reply #18 on: September 22, 2015, 03:52:17 pm »
I think so too lol but i think we are on the same page for the most part anyway. You know the technical ins and outs of whats going on and I know what I need to do to make it work so i think we are good lol.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Cant find smb3 palette
« Reply #19 on: September 22, 2015, 08:39:54 pm »
So I traced the code in the game.

And FWIW, the $FF bytes are absolutely padding, and the values are completely discarded and overwritten with the backdrop color.  So the value of those bytes literally do not matter at all -- it's just padding.

Tracelog:

Code: [Select]
A:0F X:20 Y:90 S:FD P:nvUbdiZC   $B895:AD DE 7D  LDA $7DDE = #$0F
A:0F X:20 Y:90 S:FD P:nvUbdizC   $B898:8D EE 7D  STA $7DEE = #$FF
A:0F X:20 Y:90 S:FD P:nvUbdizC   $B89B:8D F2 7D  STA $7DF2 = #$FF
A:0F X:20 Y:90 S:FD P:nvUbdizC   $B89E:8D F6 7D  STA $7DF6 = #$FF
A:0F X:20 Y:90 S:FD P:nvUbdizC   $B8A1:8D FA 7D  STA $7DFA = #$FF

The palette is loaded into RAM at address $7DDE.  This palette is copied somewhere else in the $07xx page so it can be modified for fade in/out effects, but the one at $7DDE appears to be the "base" palette.

After loading the palette from ROM, the above code is run.  Notice how $7DEE, $7DF2, $7DF6, and $7DFA all contain $FF.  This is color 0 for the sprite palettes.  Notice how the game is taking the backdrop color ($7DDE) and copying it to all those other areas.  This effectively overwrites the FFs with whatever the current backdrop color is.

So in this case, FCEUX was not displaying anything incorrectly.  The game was simply not using those FF bytes because they were padding.