don't click here

ROM Graphics Editing

Discussion in 'Engineering & Reverse Engineering' started by Elusive, Oct 29, 2004.

  1. Elusive


    Sparkster the Rocket Knight Member

    by Elusive

    To avoid the problems of 56k loading times, all images are linked.

    • A ROM to hack, obviously. For this example, I will use Sonic 1.
    • The Sega Data Compressor. I use version 2.2, as I think it's the latest version. Check the 'KNOW YOUR HACKING TOOLS' topic in the E&RE archive.
    • Tile Layer Pro. Get the version that has been .bin fixed if at all possible. Also, to go with Tile Layer Pro:
    • Sonicology TPL files. For these, check out These come in INCREDIBLY useful.
    • A hex editor - I use Hex Workshop, but really you can use any. There's not much difference between them.
    First, make sure your ROM is in .bin format - to do this, right-click on it and choose 'Properties'. A screen will appear, telling you its filetype.
    ^ Also, turn off 'Hide file extension for known filetypes' in Explorer by selecting 'Folder Options...' from the 'Tools' menu - Quick Man
    If it is NOT .bin, then you'll need to convert it TO .bin format before you can hack it. To do this, check the 'KNOW YOUR HACKING TOOLS' topic again, as there are too many .smd to .bin converters out there to list here.
    Next, install all the stuff listed above. I recommend putting Tile Layer Pro and the Sega Data Compressor into seperate folders within one parent folder, probably called something like 'Hacking Tools', or something similar. Then, create a folder in 'My Documents' called 'My ROM Hacks'. This is all just to keep things tidy.
    Oh, and put the Sonicology TPL files (they should have come in a ZIP file) into the TLP folder.
    NOTE: From now on, I will refer to Tile Layer Pro and the Sega Data Compressor as TLP and TSDC respectively.

    Right, now you should be ready to begin! For this tutorial, I will change the end-of-level signpost in Sonic 1 to resemble that of Sonic 2.

    Fire up TSDC. It will look like this:

    This part is tricky to explain. Different parts of the ROM are compressed in different ways. For example, most level mappings are compressed in Kosinski format, music is compressed in Saxman format, and so on. (As a side note, these were named after the people who cracked the compression format, allowing people to modify them today.) You cannot modify compressed art with TLP - that is why we need to decompress it with TSDC. With Sonic 1, the format we will need is Nemesis compression, as the signpost is compressed in that format. So, click the 'Nemesis' button in the 'Decompress' frame. This will appear:

    If you don't know what format the piece of art is compressed in, then you'll have to search for it in all the formats. However, we are looking for the signpost, so scroll through the list looking for it (under Sonic 1, of course), then select it:

    At the top of the N-Decompressor screen, there is a textbox labelled 'Source File'. Click the button next to it. An Open dialog box will appear:
    As you can see, I've broken my own guidelines. ;)
    It helps if you select a 'clean' (that is, unmodified) ROM - as I have, in this case. Click the 'Open' button, and the location of the unmodified ROM will appear in the top textbox.

    Second to top of the N-Decompressor screen is a 'Destination File' textbox. This is the file to which TSDC will save your uncompressed data to. Click the 'Set' button next to this textbox, and a Save dialog box will appear. Type in an appropriate name:
    You MUST save it as a .DAT file. Otherwise, TSDC throws a wobbly, and won't let you save.
    ^You CAN save as anything other than a .dat / .bin file - Quick Man
    Click the 'Save' button. Like before, the location of the file will appear in the textbox:

    Still got the 'End of level signpost' thingy selected? If not, select it. You'll see a string of numbers and letters in front of the text:
    These numbers and letters are hex locations. They tell the game and TSDC where the art for that particular thing is located in the ROM. We need to tell the program this location, so enter the numbers and letters into the textbox marked 'Offset [hex]:' In this case, it is 03A53E.
    Now all you need to do is click 'Decompress'. TSDC will decompress the art from the location you entered into the Destination File you chose!
    Now you are done with TSDC, you can close it down fully. Now the really meaty work begins.

    Fire up TLP. I won't provide a screenshot, as it's big. :(

    Go to the 'File' menu, and choose 'Open...'
    In the 'Open' box that appears, MAKE SURE YOU CHOOSE 'All files (*.*)' IN THE 'Files of type:' BOX.
    Locate your destination file, and click OK:

    What you will see is a loat of garbled junk. To clear it up, go to the 'View -> Format' menu, and choose 'Genesis'. This should clear it up a bit:
    There, that's a little better. If you get an error message, close and restart TLP until it works. It's harmless, only something to do with the way TSDC decompresses stuff. I think.

    To finally clear it up, go to 'Palette -> Load'. Then, find the TPLs I asked you to get. Find the one called 'sonic1.tpl', and open it:
    This should be the result:

    Now I'm going to replace the Sonic 1 signpost with that of Sonic 2. To do this, you'll have to go through the whole process again, up to step nine, with Sonic 2. *dodges flung tomatoes* To save you the time of doing this, I did it. To cut a long story short (and avoid more images), here's the Sonic 2 signpost in TLP:
    You'll notice I loaded the Sonic 1 palette, instead of the Sonic 2 palette. I did this as I'm transferring the Sonic 2 signpost to the Sonic 1 signpost.

    You'll notice that the first two lines in both boxes line up perfectly:
    All you need to do is drag the tiles across from the Sonic 2 window to the Sonic 1 window.
    There's the top two lines done. Now, it's just a case of moving relevant parts onto their partners - for example, left-top corner onto left-top corner, left-edge-high onto left-edge-high, and so on. This rearranging is tedious, but it's got to be done. Here's the result:

    That's the artwork done, now we need to recompress it, so the game can read it again. Close down TLP, MAKING SURE TO SAVE YOUR CHANGES.
    Now, fire up TSDC again, only this time click the 'Nemesis' button under the 'Compression' frame.
    Click the button next to the textbox marked 'Source File'. In the 'Open' dialog box that appears, select the file you edited - 'Sonic 1 endoflevelsignpost' in this example.
    Then, click the buton next to the textbox marked 'Destination File'. In the 'Save' box, type a new filename to compress the data to - I've called mine 'S1 signpost'. IT MUST BE SAVED AS A .BIN FILE.
    Finally, click 'Compress':

    Close down TSDC. Open up the compressed art file in your hex editor. In a seperate window, open Sonic 1.
    Now, the game uses things called 'pointers'. As the name suggests, these 'point' to a specific location where the data can be found. As we are modifying the Sonic 1 signpost, this new data will be of a different size to the original - you can't risk overwriting the raw data as a simple cut 'n' paste. Rather, you can stick the new data at the end of the ROM, and simply tell the pointer for the signpost to look at the new location. This will safely insert your new data.
    The pointer for the signpost is located at 0001D978. Go to this location in your hex editor - in a clean Sonic 1 ROM, it should read 0003A53E. (I'm using the JUE version, the J version will be different.) Now, go to the very end of the ROM - if you look, the ROM ends at 00080000.
    This will sound confusing - go back to the signpost pointer at 0001D978, and put 00080000 instead of 0003A53E.

    Still got the compressed art file open in your hex editor? Select it all, and press CONTROL and C (to copy the data). Now go back to your Sonic 1, and paste this data at 00080000. Save, and close the editor down.

    Finally, open the new Sonic 1 ROM in your emulator of choice. Finish a level, and there you have it:

    I've tried to be as thorough as possible, whilst still keeping it simple. I hope this proves useful. If there's any errors, tell me and I'll fix it.

    -EDIT- Thanks Quick Man, fixed some information.
  2. Lostgame


    producer/turnablist. homebrew dev. cosplayer. Oldbie
    Toronto, ON
    The O.I.C.
    Cool. I've used that recompressing technique before in Crackers, but not in any other ROM.
  3. Syren


    Teesside, UK
    Damn you Elusive! :(

    Very handy. I'll be reading this more often than not. :P
  4. Quickman


    be attitude for gains Tech Member
    omg porjcet
    1. You don't HAVE to save as .dat/.bin files.
    2. Turn on showing extensions in Explorer.
    3. You can doubleclick to put the extension in the box for you.
    4. You can see in that shot a weakness in TLP - you can view and edit outside the boundary of your file. I use this occasionally for storing stuff, but be careful not to overwrite what's in another file.
  5. Kampfer


    Nice, this is the method I use too.