Add new tiles in different acts in Sonic 2 SMS
From Sonic Retro
(Redirected from SCHG How-to:How to Add new tiles in different acts in Sonic 2 SMS)
(Original guide by Ravenfreak) Alright, say you wanted to add a new tileset to whatever act in whatever level. This is what this guide is for! As with my other guides this guide was made with the wiki disassembly in mind, not the SVN. (Plus it's down anyway atm unless you have a SVN client. :V) Before anything, make sure you download Glitch's program Aspect Edit if you haven't done so yet. If you already have the program downloaded, you'll need a fresh tileset to work with, or if you want you could work with an existing tileset. (Just remember to align tiles properly so they can be decompressed into VRAM correctly. For more info, see [smspower.org]) I suggest opening an existing one just so you know how many tiles need to be edited. I used GHZ in my example. Anyway, next we need to open the palette for whatever level we're adding the tiles for, in this case open palette_ghz.bin located in the palettes folder. This way, we can view the tileset. Now save the tileset as "Art_GHZ_Level_Tiles2.bin" and save it in "art\level\ghz". Now we have a second tileset to work with. But the game isn't aware of this new art yet. So next, we need to edit zone_tilesets.asm. Search for .db :Art_GHZ_Level_Tiles. It should look like this:
.db :Art_GHZ_Level_Tiles .dw $2000 .dw Art_GHZ_Level_Tiles .dw Tileset_GHZ
Here we have the tilesets that are to be loaded into VRAM for each act, this one here is for act 1. So say you wanted to add the new tiles to act 2. Right bellow .dw Tileset_GHZ, you'd want to change the next 4 lines to this:
.db :Art_GHZ_Level_Tiles2 .dw $2000 .dw Art_GHZ_Level_Tiles2 .dw Tileset_GHZ
This will allow the new tileset to be loaded into VRAM when act 2 loads. Save zone_tilesets.asm. Now we need to include the new tiles into the ROM itself. GHZ tileset is originally in bank 10, but if we add another .include an overflow occurs in bank 10. So we need to expand the ROM by adding another bank. This is very simple to do, open s2.asm located in the src folder. Scroll down until you see the ROM bank map. It looks like this:
.ROMBANKMAP BANKSTOTAL 31 BANKSIZE $4000 BANKS 31 .ENDRO
Change 31 to 32, for our new bank. Next open a blank text file and name it bank32.asm. I suggest saving it to the include folder, since the banks are located here. Next open banks.asm located in "src\includes". At the end of the file, add this:
.BANK 32 .ORG $0000 Bank32: .include "src\includes\bank32.asm"
This will allow the ROM to be bigger, and therefore you could add new stuff without breaking anything. xP Now if you don't already have bank32.asm open, reopen it and add this:
Art_GHZ_Level_Tiles2: ;new ghz tiles .incbin "art\level\ghz\art_ghz_level_tiles2.bin"
Now we have our new tileset! But wait, when you go to build your ROM, your confronted with a corrupted mess in GHZ2. That's because, we need to add a new mappings file as well, otherwise the game will always load garbage. Now we need to create a new mappings file. So open mappings32_ghz.bin in Aspect Edit. Next open the new tileset, as well as opening both the forground and background palettes. This will allow you to edit the mappings accordingly. Now in order for the game to load the proper mappings and not garbage, we need to export the new mappings as an asm file. Simply press the "export to assembly" button, which is located next to the "save as" button. You could name it whatever you want, I named the file "NewMappings.asm". If you still have bank32.asm open add the following lines after the tiles file.
Mappings32_GHZ2: .include "mappings\ghz\NewMappings.asm"
We're still not done yet, we need to edit the level headers to load the new mappings. This is the final step. Open level_headers.asm located in the src folder. Now search for LevelHeader_GHZ2, it should look like this:
LevelHeader_GHZ2: .db :Mappings32_GHZ .dw Mappings32_GHZ .db :Layout_GHZ2 .dw Layout_GHZ2 .dw $0100 .dw $FF00 .dw $0700 .dw $0008 .dw $0008 .dw $1F00 .dw $0110 .dw DATA_4AE5
Now simply change Mappings32_GHZ to Mappings32_GHZ2, save the file and build the ROM. And presto, the act has a completely new tileset! Special thanks to Glitch for making both the disassembly and Aspect Edit. Note: the only glitch i've noticed is the ring animation stops working, but that might just be due to the tiles I used. If that's not the case, then I dunno how to fix the glitch. :\