The PokéCommunity Forums Fan Games ROM Hacking Research & Development
Development Dynamic Overworld Palettes

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!

Reply
 
Thread Tools
  #1    
Old December 11th, 2015 (2:45 PM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73

Dynamic Overworld Palettes




Anyone who has ever inserted new overworld sprites has probably realized that the existing palette system is pretty inflexible and inextensible regarding new, custom palettes. In fact, the game simply loads a predefined list of palettes which all the NPCs share. Only palette slots 0 and 0xA are loaded dynamically when a respective NPC enters the screen. However, the palette in slot 0 is already taken by a few sprites, such as the warp arrow or the emotion bubbles, so it's not recommendable to edit it. It's quite apparent that dealing with overworld palettes is a pain under these circumstances, so I decided to write a new, dynamic palette system.

How it works


With this patch applied, the four bits in the NPC structure which usually determine what palette slot to use are ignored. Instead, the game uses a reference counting system that keeps track of what palettes are loaded and how many OBJs access them. When a sprite shows up on the screen, its palette is automatically loaded into a free palette slot if it hasn't been already. When all sprites using a certain palette have been deleted, the palette slot is available again for other palettes.

It's also worth mentioning that this doesn't only affect NPCs, I've basically tried to include any sprite that ever appears in the overworld. OBJs that show up in menus or the like will not be affected. While I've done much testing and I'm pretty sure that I've incorporated all overworld sprites there are, I can't rule out the possibility that I overlooked one. So if you find a sprite with a wrong palette, I'd greatly appreciate a short feedback so I can fix it.

Additional fixes


Aside from significantly easier palette handling, the patch also fixes some minor bugs of the vanilla game. These are:
  • When changing the weather from sandstorm or cloud reflections to another type, the game doesn't load the new palette, so rain and other weather styles end up looking really weird.
  • Some sprites are not grayscale during the flashback, such as sandstorm, cloud reflections or block animaitons during fog weather.
  • Speaking of fog, only weather type 'Steady mist' makes block animations brighter so they fit the brightness of the fog, the other fog types don't.
As a further bonus, I've made reflection palettes fully dynamic too, which means the game automatically creates them based on the NPC palette.

The patch


You can download the patch here. I've put the source code on Github.

The data will be written to 0xF00000, in order to make it compatible with as many ROMs as possible. Should your ROM already have other data at that offset, you can download the source, specify another offset in the linker script and then insert it using the Python script. For further info, see the ReadMe file.

This patch only works with FireRed 1.0!

Special thanks to knizz for his FireRed IDB and Touched for publishing his Mega Evolution source, which I could learn a few things from.
Reply With Quote

Relevant Advertising!

  #2    
Old December 12th, 2015 (9:56 PM).
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 22
Gender: Male
Posts: 794
This is a fantastic hack! Kudos to you!

Overworlds were honestly one of the things I hated most about making my hack. JPAN's hack although helpful didn't really take into account the palette slots leading to custom palettes having distorted colours, which I'm sure you realised too.
__________________
Reply With Quote
  #3    
Old December 13th, 2015 (2:55 AM).
Spherical Ice's Avatar
Spherical Ice Spherical Ice is online now
 
Join Date: Nov 2007
Location: Bristol, UK
Age: 19
Posts: 4,966
This is amazing!

I've submitted a small bug I noticed to the Issue Tracker on github, hope it helps!
__________________
Reply With Quote
  #4    
Old December 13th, 2015 (7:21 AM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73
Quote:
Originally Posted by MrDollSteak View Post
This is a fantastic hack! Kudos to you!

Overworlds were honestly one of the things I hated most about making my hack. JPAN's hack although helpful didn't really take into account the palette slots leading to custom palettes having distorted colours, which I'm sure you realised too.
Thanks!

You're right, JPAN's patch doesn't really help with palette slots, the only thing it does in terms of overworld palettes is it repoints the table so you can add more of them. You'd still be forced to put your custom palettes into slot 0 or A, or to load them separately in a level script or so. This should no longer be a problem!

Quote:
Originally Posted by Spherical Ice View Post
This is amazing!

I've submitted a small bug I noticed to the Issue Tracker on github, hope it helps!
Thanks!

Strangely enough, I just tried to reproduce this issue on a clean ROM, but it stayed dark there. It may be something specific to Gaia, a particular hook or something. I'll try to find out what's causing it, thanks for reporting!
Reply With Quote
  #5    
Old December 13th, 2015 (10:11 AM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73
My suspicion turned out to be true. The hack was actually colliding with daniilS' snowflakes routine that keeps the screen from darkening. I've updated the file Insert.py accordingly, it should work now!

To stop the snowflakes weather from darkening the screen when returning to the map, just delete this line.
Reply With Quote
  #6    
Old December 14th, 2015 (8:51 PM).
esperance's Avatar
esperance esperance is offline
PokéCommunity Daily Staff
 
Join Date: Mar 2010
Location: Ohio
Age: 19
Gender: Male
Nature: Relaxed
Posts: 3,701
This is really great! A wonderful hack.

It might be worth mentioning that while the Insert.py script will work with Python 2.7 it won't work with Python 3 (the way print works was changed in Python 3). Fortunately it's a simple modification to make.
__________________
mod github pair
Reply With Quote
  #7    
Old December 15th, 2015 (3:58 AM).
urzzz urzzz is offline
 
Join Date: May 2006
Gender:
Nature: Naughty
Posts: 17
I've wanted something like this for so long. Brilliant!

One issue I ran into was that thunderstorms were causing OW palettes to glitch out when wandering from map to map (Just for reference, I'm running a dynamic weather system using JPANs hacked fire red engine along with his walking script special) I don't know if this is a limitation of this hack? or a bug from the weather refreshing/changing from one to another or anything else? Just thought it would be worth mentioning.
Reply With Quote
  #8    
Old December 15th, 2015 (11:34 AM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73
Quote:
Originally Posted by Hopeless Masquerade View Post
This is really great! A wonderful hack.

It might be worth mentioning that while the Insert.py script will work with Python 2.7 it won't work with Python 3 (the way print works was changed in Python 3). Fortunately it's a simple modification to make.
Ohhh, I wasn't aware of this. Thanks for telling, I'll change it. Luckily it's indeed an easy fix haha.

Quote:
Originally Posted by urzzz View Post
I've wanted something like this for so long. Brilliant!

One issue I ran into was that thunderstorms were causing OW palettes to glitch out when wandering from map to map (Just for reference, I'm running a dynamic weather system using JPANs hacked fire red engine along with his walking script special) I don't know if this is a limitation of this hack? or a bug from the weather refreshing/changing from one to another or anything else? Just thought it would be worth mentioning.
Hm... Thunderstroms should definitely work with this hack. I'll look into JPAN's walking scripts and see if they have anything to do with it. Thanks for your notice though!

Anyways, I'm glad to see that you guys enjoy this project!
Reply With Quote
  #9    
Old December 15th, 2015 (4:03 PM).
~Ruki!'s Avatar
~Ruki! ~Ruki! is offline
100tifiko
 
Join Date: Feb 2014
Location: Guatemala City
Gender: Female
Nature: Brave
Posts: 252
A-W-E-S-O-M-E!!!
But my question is, Can I put in the same map up to 16 overworlds with a different pallete?
__________________
[center]
Reply With Quote
  #10    
Old December 15th, 2015 (4:38 PM).
BlackWhiteRobin's Avatar
BlackWhiteRobin BlackWhiteRobin is offline
 
Join Date: Sep 2012
Age: 19
Gender: Male
Nature: Quirky
Posts: 509
Uhm... I have a question about this. Since the palettes are now dynamic, can I put more palettes for the overworlds (I think the current has 15 or so)? If so, how? Do I manually put the offset for a specific sprite's palette?

P.S. This is a great discovery! Thank you for this! ^U^
__________________

Reply With Quote
  #11    
Old December 16th, 2015 (3:21 AM).
urzzz urzzz is offline
 
Join Date: May 2006
Gender:
Nature: Naughty
Posts: 17
Quote:
Originally Posted by Navenatox View Post
Ohhh, I wasn't aware of this. Thanks for telling, I'll change it. Luckily it's indeed an easy fix haha.


Hm... Thunderstroms should definitely work with this hack. I'll look into JPAN's walking scripts and see if they have anything to do with it. Thanks for your notice though!

Anyways, I'm glad to see that you guys enjoy this project!
Just a quick update on this. I was wrong. The thunderstorm isn't causing the issue, it seems to be a green script tile linked to a trainer battle. The aftermath of that event seems to be causing the issue for me. I'll have a good look at the script and mess around with a few things on a clean ROM to see if I can reproduce the issue in certain circumstances. Just don't start going on a wild goose chase with the thunderstorm and JPAN walking script specials. It's looking more and more likely to be human error on my part.
Reply With Quote
  #12    
Old December 16th, 2015 (12:30 PM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73
Quote:
Originally Posted by ~Ruki! View Post
A-W-E-S-O-M-E!!!
But my question is, Can I put in the same map up to 16 overworlds with a different pallete?
Yes, you can! Technically you can have even more than 16 overworlds with different palettes in one map, as long as you don't have more than 16 visible on the screen. But bear in mind that this also includes all other palettes, like tall grass, sandy footprints, reflections, the weather, and so on.

Quote:
Originally Posted by BlackWhiteRobin View Post
Uhm... I have a question about this. Since the palettes are now dynamic, can I put more palettes for the overworlds (I think the current has 15 or so)? If so, how? Do I manually put the offset for a specific sprite's palette?

P.S. This is a great discovery! Thank you for this! ^U^
You can repoint the NPC palette table at 0x3A5158 (or 0x1A2400 if you're using JPAN's patch) and add as many palettes as you wish. Each entry in that table consists of 8 bytes: 4 bytes for the pointer to the palette, 2 bytes for the palette number and 2 filler bytes. The palette number can be any value from 0 to 0xFFFF except 0x11FF, because this would indicate the end of the table. This palette number is the one that you'll need to specify in the data structure of your NPC.

Quote:
Originally Posted by urzzz View Post
Just a quick update on this. I was wrong. The thunderstorm isn't causing the issue, it seems to be a green script tile linked to a trainer battle. The aftermath of that event seems to be causing the issue for me. I'll have a good look at the script and mess around with a few things on a clean ROM to see if I can reproduce the issue in certain circumstances. Just don't start going on a wild goose chase with the thunderstorm and JPAN walking script specials. It's looking more and more likely to be human error on my part.
Okay, good to know. Just let me know if you find out that it's connected with this hack in any way.
Reply With Quote
  #13    
Old December 21st, 2015 (1:07 PM).
Joexv's Avatar
Joexv Joexv is offline
WHO ARE YOU PEOPLE
 
Join Date: Oct 2012
Location: Oregon
Age: 19
Gender: Male
Nature: Sassy
Posts: 1,019
Just got a chance to use this and its freakin amazing! Thank you for helping my reflection ocd. Thank you.
__________________
I'm bored
Jesus Christ is my Savior
Bros with Percy

My Rom hacks
A New Dawn---Gentlemon
Not in Production:
Blackened Night---Holiday Hacks
Reply With Quote
  #14    
Old December 21st, 2015 (2:49 PM).
Dionen's Avatar
Dionen Dionen is offline
farfetching as always
 
Join Date: Jun 2011
Location: Brazil
Gender: Male
Nature: Quirky
Posts: 268
Oh, I can't even describe how amazing this is
Thank you!
__________________
Reply With Quote
  #15    
Old December 22nd, 2015 (6:50 PM).
Shiny Quagsire's Avatar
Shiny Quagsire Shiny Quagsire is offline
I'm Still Alive, Elsewhere
 
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 19
Gender: Male
Nature: Jolly
Posts: 698
Looks great, it always bothered me with how hacky the palette system was done, especially with respect to reflections and weather. Seems like this actually managed to improve on a lot of things without having to compromise either, which is great.
__________________



Reply With Quote
  #16    
Old January 10th, 2016 (11:57 AM).
-Lèdypion-'s Avatar
-Lèdypion- -Lèdypion- is offline
 
Join Date: Dec 2015
Posts: 27
Very usefull!
But what about other roms like emerald?
Reply With Quote
  #17    
Old January 12th, 2016 (10:40 AM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73
Quote:
Originally Posted by -Lèdypion- View Post
Very usefull!
But what about other roms like emerald?
Actually I don't plan to redo the research for other ROMs. I might do it for Emerald sometime, but that has a rather low priority for me.
Reply With Quote
  #18    
Old January 20th, 2016 (2:14 AM).
tayyab43's Avatar
tayyab43 tayyab43 is offline
The Don
 
Join Date: Jan 2016
Location: pokeporntugal
Gender: Other
Nature: Naughty
Posts: 25
This is going to sound incredibly nooby but how would i use this patch to add pallettes?
Reply With Quote
  #19    
Old January 20th, 2016 (12:12 PM).
Joexv's Avatar
Joexv Joexv is offline
WHO ARE YOU PEOPLE
 
Join Date: Oct 2012
Location: Oregon
Age: 19
Gender: Male
Nature: Sassy
Posts: 1,019
Quote:
Originally Posted by tayyab43 View Post
This is going to sound incredibly nooby but how would i use this patch to add pallettes?
This patch isnt used to add palettes you would either need to expand your palette table or use jpans engine to add more.

This patch just makes using those added palettes much easier
__________________
I'm bored
Jesus Christ is my Savior
Bros with Percy

My Rom hacks
A New Dawn---Gentlemon
Not in Production:
Blackened Night---Holiday Hacks
Reply With Quote
  #20    
Old January 23rd, 2016 (8:21 AM).
PokéMew's Avatar
PokéMew PokéMew is offline
Pokémon Fuchsia
 
Join Date: Sep 2013
Location: Refresh
Gender: Male
Nature: Modest
Posts: 490
Send a message via Skype™ to PokéMew
Quote:
Originally Posted by tayyab43 View Post
This is going to sound incredibly nooby but how would i use this patch to add pallettes?
Adding to what Joexv said, in vanilla you could have at most 2 custom palettes on screen at once. This hack allows you to have custom palettes from each of the 16 slots at once. Again like Joexv said, you can simply expand the palette table to add more palettes.
Reply With Quote
  #21    
Old March 4th, 2016 (7:26 AM).
random321 random321 is offline
 
Join Date: Jan 2016
Gender: Other
Posts: 20
Quote:
Originally Posted by random321 View Post
all my pokemon have the wrong palette at the move deleter and possibly other places too, these are standard gen 3 pokemon that haven't been altered on a fairly clean firered 1.0 rom

other than that good job, but can we get an update to fix this one
Edit: I just removed the dynamic palettes and its fixed so this was definitely the problem
Reply With Quote
  #22    
Old March 4th, 2016 (1:25 PM).
FamiliaWerneck's Avatar
FamiliaWerneck FamiliaWerneck is offline
 
Join Date: May 2015
Location: São Paulo, Brasil
Gender: Male
Posts: 271
Would this work for the PC boxes too?
'Cause you know, we can't use generation VI icons because of their palettes, which have to come out of 3 fixed palettes.
Will we be able to use the original generation VI style icons with this hack?
__________________
My Main Team:


Reply With Quote
  #23    
Old March 5th, 2016 (4:20 PM).
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 22
Gender: Male
Posts: 794
Quote:
Originally Posted by FamiliaWerneck View Post
Would this work for the PC boxes too?
'Cause you know, we can't use generation VI icons because of their palettes, which have to come out of 3 fixed palettes.
Will we be able to use the original generation VI style icons with this hack?
Sadly no, because the boxes and cursors as well as the existing 3 palettes take up all of the palettes afaik.
__________________
Reply With Quote
  #24    
Old March 6th, 2016 (2:26 AM).
Navenatox's Avatar
Navenatox Navenatox is online now
 
Join Date: Jan 2015
Location: Austria
Age: 22
Gender: Male
Nature: Timid
Posts: 73
Quote:
Originally Posted by random321 View Post
Edit: I just removed the dynamic palettes and its fixed so this was definitely the problem
Oh ****, good catch!
I'm definitely going to have a look at that and fix it as soon as I can. I was planning to clean up the code a bit anyway, so I'll probably do both things at once. Anyhow, thanks for reporting!

Quote:
Originally Posted by FamiliaWerneck View Post
Would this work for the PC boxes too?
'Cause you know, we can't use generation VI icons because of their palettes, which have to come out of 3 fixed palettes.
Will we be able to use the original generation VI style icons with this hack?
Like MrDollSteak said, that won't work unfortunately. I do actually think that some palette slots are unused in the Pokémon menu and the PC boxes, however they would only suffice for the 6 Pokémon in your party at best. Considering a box on the PC can hold up to 30 Pokémon, there's just no way to give each icon its own palette.
Reply With Quote
  #25    
Old March 9th, 2016 (11:55 AM).
FamiliaWerneck's Avatar
FamiliaWerneck FamiliaWerneck is offline
 
Join Date: May 2015
Location: São Paulo, Brasil
Gender: Male
Posts: 271
What a said, said thing. =/
__________________
My Main Team:


Reply With Quote
Reply
Quick Reply

Sponsored Links
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:42 AM.