+  RHDN Forum Archive
|-+  Romhacking
| |-+  General Romhacking
| | |-+  NES Palette Hacking - Switching A Sprite To A Different Palette Set
Pages: [1]
Author Topic: NES Palette Hacking - Switching A Sprite To A Different Palette Set  (Read 265 times)
Jedi QuestMaster
Guest
« on: April 11, 2007, 08:27:15 am »

Let's say I'm trying to change the colors of a sprite; but I want to switch the sprite to a different 4-color palette available without actually changing the colors of the palettes themselves.

I couldn't find this in any docs; how would I do this?
Nightcrawler
Guest
« Reply #1 on: April 11, 2007, 08:36:16 am »

It's a bit tricky on the NES. You'll need to edit the attribute table in PPU memory.

http://www.romhacking.net/docs/nesgfx.zip

That document pretty much explains what's going on.

It's probably easier to change the colors of the palette, but I understand of course how that can have unwanted side effects.
Disch
Guest
« Reply #2 on: April 11, 2007, 11:24:58 am »

Sprites do not use the attribute table -- that's just for the BG.

Each sprite has its own choice of which palette it uses.  It's determined by the low two attribute bits for the sprite in OAM.  Games typically have a copy of "Shadow" OAM that gets copied to the actual OAM on the $02xx page (although some games put it at the $07xx page -- it should be easy enough to tell which page it is just by looking at a memory viewer -- most of the page will look like "Fx XX XX XX Fx XX XX XX").  Every 3rd byte in a set of 4 ($0202, $0206, $020A, etc)  is the attribute byte for each sprite.  Changing which palette the sprite uses is as simple as changing that byte.

HOWEVER!  It's not that easy -- as sprites generally get jumbled around in OAM in order to constantly fluctuate their priorities (so that when more than 8 are on a scanline -- they flicker to make all of them partially visible -- rather than having some totally invisible). You'll have to find out how the game draws the desired sprite to Shadow OAM and change its palette before it does so.  Games all do this their own way and might store the palette used as some sprite attribute in a way that's easy to edit once you find it.


This is one of those things that gets really hard to find through tracing... because Shadow OAM is so jumbled up and crazy.  You might be better off with a broader approach like corruption or something.
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC