You are not logged in.
I've been messing around with hex editing the Pokemon Red ROM for fun. I have added a new house in Vermilion City by changing the map data. I hijacked one of the warps that was unnecessary (the right entrance to the SS Anne) and moved the warp on top of my new house door and pointed the warp to the first warp in my new house map.
There is a list of Map ID's defined in the ROM. I used one of the unused maps (ID 0x0B) and changed the ROM bank and header pointer to a ROM bank that is completely empty and far away from other data to make editing easier (Rom Bank 3F). My map header, scripts, and text for my new house are all together in this area. I have the house mapped out, I have my sprites in it, they can talk, etc.
The only issue I am having is that the color palette when inside the house is green instead of the Vermilion city orange. The music also resets and changes to something different. When you enter any other house in Vermilion city, the music continues seamlessly and the palette stays the same. My third problem is that the town map hanging on the wall in my new house doesn't show the player in Vermilion City.
My guess is that the music/palettes are determined by the bank number the map data is in. My other guess is that there is some table somewhere that defines color/sound/town map location for each map. I'm looking through the PokeRed disassembly repo and I'm not having much luck figuring this out.
Alright, So I've done a bit more research and played around with some things, and I'm pretty sure I know how to solve each problem, even though I haven't done it fully yet. These are assumptions about the programming that I have deduced. They are probably right, but there may still be some ignorance/error.
Palette Color: This is determined by the TYPE of map you are in. Apparently there are two different 'types' of maps. Major Cities/Outside Routes, as opposed to Dungeons/Houses/Indoor maps/etc. Here is a list of all the maps:
Any map with an ID lower than 0x25 is considered a major/key map. Any map ID that is greater or equal to 0x25 is considered a minor/indoor map.
From what I can tell, the minor maps inherit their palette color from the last major map that the player was at. I learned this by editing my custom warp from Vermilion -> Random Pewter City house. When I enter the pewter city house from Vermilion, the palette inside the house stays the same Vermilion orange. The reason my custom map turns colors is because it's index is 0x0B, which defines it as a major/key area. I'm sure there is somewhere in the game that defines color palettes for key areas. The solution to this problem is to change my custom map to use a different unused index that is greater than 0x25 so the game engine assumes my map is an indoor map instead of an outdoor map. This will make it so my new map inherits the palette from the city.
Music Issue: The music for indoor maps is not inherited. I am led to believe that there is a giant map/music table that lists which song ID is played in each map ID. To fix this issue, all I would have to do is change the unused map ID (which I am now using) to use the same song ID that Vermilion City uses.
Town Map Issue: There are tables that define how the town map is laid out, and data for how each map is represented on the town map. This shouldn't interfere with palette/music at all, this only matters if you actually care enough to fix the town map. This post has all the info you'd need to fix that: https://hax.iimarckus.org/topic/5/
I will try implementing these solutions soon and I will report back whether or not I was right in my estimation.
Alright, I figured out all of my problems. I'm posting the answers in case someone in the future trying to do the same thing comes across this.
Everything in the post above was right. As long as your custom map has a map index >= 0x25 the color of your custom map will inherit the color palette from the last known location instead of creating a new palette.
The songs that are played on each map are stored in a table starting at 0xC04D. There is one entry per every map (248 entries total). Each entry is two bytes. The first byte in each entry is the song ID, and the second byte is the bank in which the song is located.
By making my map use index 0x45 instead of 0x0B, and copying the data from the vermilion city sound entry over the 0x45 map sound entry, I have successfully finished my goal.
Last edited by mpvab (2017-10-10 00:33:31)