don't click here

ROM Graphics Editing

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

  1. Elusive

    Elusive

    Sparkster the Rocket Knight Member
    A TOTAL BEGINNER'S GUIDE TO ROM GRAPHICS EDITING

    by Elusive

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

    YOU WILL NEED:
    • 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 http://sonicology.fateback.com/downloads/tpl/index.html. 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.
    BEFORE YOU BEGIN:
    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.

    STEP ONE
    Fire up TSDC. It will look like this:
    http://img9.exs.cx/img9/9426/image27.png

    STEP TWO
    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:
    http://img9.exs.cx/img9/2479/image28.png

    STEP THREE
    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:
    http://img9.exs.cx/img9/8382/image29.png

    STEP FOUR
    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:
    http://img9.exs.cx/img9/732/image30.png
    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.

    STEP FIVE
    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:
    http://img9.exs.cx/img9/1144/image216.jpg
    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:
    http://img9.exs.cx/img9/7534/image217.jpg

    STEP SIX
    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:
    http://img9.exs.cx/img9/270/image218.jpg
    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!
    http://img9.exs.cx/img9/3769/image219.jpg
    Now you are done with TSDC, you can close it down fully. Now the really meaty work begins.

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

    STEP EIGHT
    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:
    http://img9.exs.cx/img9/6566/image220.jpg

    STEP NINE
    http://img9.exs.cx/img9/5403/image222.jpg
    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:
    http://img9.exs.cx/img9/86/image223.jpg
    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.

    STEP TEN
    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:
    http://img9.exs.cx/img9/6966/image224.jpg
    This should be the result:
    http://img9.exs.cx/img9/3743/image225.jpg

    STEP ELEVEN
    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:
    http://img9.exs.cx/img9/3074/image226.jpg
    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.

    STEP TWELVE
    You'll notice that the first two lines in both boxes line up perfectly:
    http://img9.exs.cx/img9/2503/image227.jpg
    All you need to do is drag the tiles across from the Sonic 2 window to the Sonic 1 window.
    http://img9.exs.cx/img9/8052/image228.jpg
    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:
    http://img9.exs.cx/img9/1314/image229.jpg

    STEP THIRTEEN
    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':
    http://img9.exs.cx/img9/5008/image230.jpg

    STEP FOURTEEN
    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.

    STEP FIFTEEN
    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:
    http://img9.exs.cx/img9/3476/image231.jpg

    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

    Lostgame

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

    Syren

    Member
    4,330
    0
    0
    Teesside, UK
    Reintergration
    Damn you Elusive! :(

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

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    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

    Kampfer

    Member
    1,609
    5
    18
    Nice, this is the method I use too.