Change Log

 

Version 1.2

            Added the ability to choose between the original Sonic 3 alone object layouts and the modified Sonic 3 & Knuckles object layouts.

 

Version 1.1a

            Added the ability to view and export Plane B (background) layouts.
            Fixed a bug when exporting maps while Zoomed in.

 

Version 1.1

            Added the ability to use the underwater palettes.

 

What is Sonic Extractor 3&K Mix, and what does it do?

 

            Presently, it is a simple programme designed for a single purpose - to assemble and export PNG images of the Sonic 3 and Sonic & Knuckles Zone Layouts, complete with objects.

 

How do I use Sonic Extractor to make a useful image?

 

            If you'll bear with a brief explanation of the Mega Drive data format as used in Sonic 3 and Knuckles, then I will explain the steps involved in using Sonic Extractor to its fullest.  It's rather simple, really, so let's get to it.

            Mega Drive cartridges admittedly hold very little memory - Sonic 1's 8 megabit cart, for instance, could be copied onto a floppy diskette.  So how do they fit all those colourful graphics on there?  A 24-bit bitmap image of any one Zone is already enormously larger than the entire cartridge capacity, and even in PNG compression it comes close.  So they resort to breaking the image into little repeating tiles and using them over and over in clever ways to avoid people outright noticing how few elements are actually in use.

            The above is actually pretty common knowledge, but the interesting fact is that the Zones aren't simply broken into tiles in one stage, but there are several layers of complication at work.  First the Zones are cut into 128x128 pixel chunks (in Sonic 3&K, at least - other games use other sizes), which are in turn cut into 16x16 pixel chunks, which are in turn cut into 8x8 pixel chunks, which are in turn cut into 64 individual pixels with a palette index determining the colour of each.  So there is compression at every level.

           Obviously, the designers do not work backwards.  Within reason, I imagine they create the 8x8 tiles first, from their palette, then assemble them into larger 16x16 tiles (which start to look like something at this size, like entire Totem faces, or streetlamps), and then make 128x128 portions from these.  Finally, the 128x128 mappings are arranged into the level.

            So anyone hoping to recreate a Zone from the raw data in the Mega Drive ROM will need to do the assembly in these very same stages, and that's what Sonic Extractor does.  But there's a little hitch.

            In Sonic 3&K, and many other games, the 8x8 tiles are compressed using a wily method, named Nemesis by the hacking community after the one who cracked it.  Sonic Extractor could never hope to decompress the Nemesis format with any acceptable speed, and so relies on a workaround.  Mega Drive emulators already decompress the tiles into memory by sheer virtue of having loaded the Zone, and so a savestate will contain the tiles uncompressed, and ready for use by Sonic Extractor.

            Sadly, this means the user must actually supply Sonic Extractor with a Gens savestate made in the Zone they wish to map, and not a single ROM file of Sonic 3&K.  But it's a small price to pay for increased speed.  [Note : In levels with a cycling palette, it is recommended to pause the game when the palette reaches the desirable point (streetlamps are fully on, for instance), and then make the savestate.]

            Now that this is understood, the use of the programme itself will be described.

 

Step 1: Tileset

 

            When Sonic Extractor opens, there are four button in the top right-hand corner of the window - Open, Export, Layout, and Help.  The Help Button opens this very document, which can also be done by pressing F1.  Only the Open and Help Buttons can be accessed at programme start.  Should you attempt to click the Export or Layout Buttons, they will implore you to first load a savestate.

            Press Open to access the Open Savestate dialog box.  Navigate to the savestate you want to load, and open it.  A file called "Angel Island.gs" is supplied with Sonic Extractor - you can use it to practise with.

            The centre of the screen should begin filling up with 16x16 tiles, if the savestate is of a compatible Gens format (I've tested a bunch of different versions, and they all work, but I'd recommend using Gens+ 0.0.9.61, as it is the best version anyway).  If it is not compatible, Sonic Extractor will do its best to warn you, but the check for this is not completely infallible.  If you load an incompatible file that Sonic Extractor is fooled into accepting (which I imagine would be incredibly rare, as that file's initial bytes would have to represent the ASCII for "GST" as Gens savestates do), unexpected errors may occur.

            Anyway, if all goes well, the tiles will begin filling in.  While this is happening, you cannot do anything else, but I have tried to make it as speedy as possible.  You can however, at any time, press the Space Bar to cut the Tileset short.  You might want to do this if you discover that you have accidentally loaded the wrong savestate, or if the relevant tiles have already finished loading.

            You see, every Zone has a different number of tiles, and whereas the programme runs until it fills the whole Tileset canvas, if you see a couple of blank lines go by you can be confident that all of the tiles in use for the Zone are already in memory and you can stop the process early, speeding it up further (you can also stop it even earlier, before all the tiles are on the canvas, and compile the zone with those tiles missing, but that would only be good for a lark, if anything).

            Now that you have a Tileset, the four buttons in bottom right-hand corner of the screen, the Palette Buttons, will have been filled in with colours.  These are all the colours used in the Tileset.  You can edit them by clicking on them to bring up the standard Windows colour dialog.  However, the Tileset will not change to reflect your modifications unless you manually refresh it.  How do you do this?  With the Tileset Menu - just Right Click anywhere on the screen to bring it up.

            "Change Background Colour" : Allows you to pick a colour of your choice, using the standard Windows colour dialog.  Sometimes the default background colour from the Zone's own palette is just too dark for a pleasing map, and might need to be changed.

            "Default Background Colour" : Returns the background colour to the original hue from the palette (the first colour on the third Palette Button down).

            "Use Underwater Palette" : Recompiles the Tileset using the underwater palette found in the savestate.  Only Angel Island, Hydro City, Carnival Night (Act 2), Ice Cap (Act 2), and Launch Base (Act 2) have water in them.  Clicking this options also sets a flag so that the Objects in the Layout will be shown using the underwater palette, but some objects that are never below the water level in the real game will not reflect this (such as Robotnik Bosses).  Using the “Recompile Tileset” option or opening a new savestate will reset this flag, so the Objects will be shown using their normal palette.

            "Load Palette" : Allows you to open any ".tpl" palette file (the format used in the useful programme, Tile Layer Pro).  The Tileset will immediately recompile using the new palette data.

            "Save Palette" : Simply exports the palette in memory to a ".tpl" file.

            "Recompile Tileset" : Does just what it says.  Any modifications you've made to the palette using the Palette Buttons will be taken into account.

            Should you choose to use this Tileset image in another programme, or just hang it on your desktop wallpaper for its inherent chaotic beauty, you can press the Export Button and export the image to a location of your choice.  Otherwise, press the Layout Button, and it's on to Step 2 for you.

            IMPORTANT NOTE: As of version 1.2, before moving on to the Layout Page, you will be prompted to choose between the original Sonic 3 alone object layout, or the modified Sonic 3 & Knuckles object layout (only for the 6 zones common between the two games, of course).  When Sonic & Knuckles is locked on to Sonic 3, many of the objects have their positions revised. When you are met with the confirmation prompt, press “Yes” for the Sonic & Knuckles object layouts, or “No” for the unrevised Sonic 3 object layout. These object layouts can be selected irrespective of the game the savestate is from. Object layout data is NOT stored in Sonic 3 or Sonic 3 & Knuckles savestates – Sonic Extractor has the object layouts built-in. Therefore, if you load a savestate you made with Sonic 3, the object layout will still be the modified Sonic 3 & Knuckles version if you do not specify otherwise.

 

Step 2: Layout

 

            You should be immediately met with a pretty faithful reproduction of the Zone you know and love from the Mega Drive.

            By using the cursor keys, you can scroll through the Zone in 128 pixel chunks.  Press Page Up to hop to the top of the Layout, and Page Down to hop to the bottom.  Pressing Home and End will take you to the horizontal extremes of the Layout.  Press Space Bar to zoom in and back out.

            You may also use the Mouse to great effect on the Layout Page.  Hover over any object (it will be highlighted blue when your cursor encounters it) to see a readout of its location in the upper left corner.  Left-click drag an object to move it to a new location.  This might be necessary in a number of cases.  Though I have done my best to make the objects appear as faithfully as possible, some moving objects, such as Badniks, are always shown in their spawning location.  Sonic games think nothing of spawning Badniks in the air, or even embedded in the ground, and then letting their own movement code snap them to a more favourable position before Sonic comes across them.  So for someone making a map, some Badniks will almost surely need to be moved to better positions, and that is why I included the drag feature.  However, should you regret where you have moved an object, just Right Click it to bring up its menu, and select "Restore Position" - it will obligingly return to its spawning location.

            Other options on the object's Right Click menu include "Show", "Hide", "Show Type", and "Hide Type".  Show and Hide turn the individual object on and off, so that it won't be visible upon export of the Zone Map.  A shadow is left behind when you Hide the object, just so you can find it again to Show it, should you want to.  But that shadow will not be seen on the final map or screenshots.  Showing or Hiding Type does the indicated action for every object of the same type as the one you clicked - so that if you should feel it is not necessary to depict Angel Island's fires, Hydrocity's drips, or even Rings, on your final map, you can turn them all off easily.  Remember, however, that object types may not be the same, even if they look the same.  For instance, platforms may look identical, but exhibit distinct behaviour in the running game.  This is undetectable on a map, of course, but bear in mind that if you Hide Type for a platform and they all don't obediently disappear, this is probably what is happening.

            Next are "Flip Horizontal", "Flip Vertical".  These simply reverse the image for that one object from left-to-right and from top-to-bottom, respectively.  You can click "Restore Orientation" to return the object to its default appearance.

            The final option on the object's Right Click menu is "Layer".  You can choose between three layers - Back, Middle, and Front.  This is because objects don't know which layer to be on (the data is just not accessible from the savestate, I'm afraid).  For the most part, though, all objects are sandwiched in-between the low and high plane of the Zone tiles, but in some cases  you may feel like changing the layer of the object to more accurately reflect the image as seen on the Mega Drive itself.

            There is a second Right Click menu available in the Layout page, and it is accessed by Right Clicking on a blank area (i.e. not on an object).  The first four options here are "Export Zone Map as BMP", "Export Zone Map as PNG", "Save Screenshot", and "Specify ImageMagick Directory", all of which will be covered in the next section.  For now I'll describe the rest.

            "Jump To..." lets you jump to any coordinate within the Zone Map easily.

            "Go to Background" takes you the Plane B layout for the Zone.  This is the Zone's background.  This option is replaced with "Go to Foreground" if you are viewing the background already.  Keep in mind that some backgrounds are augmented by sprites in the real game, and won't show up accurately.

            "Zoom" does the same thing as hitting the space bar.

            "Toggle Layers" lets you show only the planes of Zone Tiles that you wish to, and "Toggle Objects" shows or hides all the objects at the same time, regardless of their type.  You'll want to use this when exporting the Plane B layout.

            "Change Background Colour" and "Default Background Colour" perform the same functions as on the Tileset Menu.

            "Count Rings" shows a message box with the number of Rings in the Act.

            Finally, "Return" sends you back to the Tileset page.  Be careful - pressing the Return option will cause you to lose all your changes to the Zone, as it is re-assembled each time you press the Layout tab.  There is a confirmation prompt, though, so don't worry too much about hitting it by accident.

 

Step 3: Export the Zone Map

 

            Once you have scrolled through the Zone Map (and tweaked whatever you felt was necessary), it's time to actually export the map.  But which image format are you going to want to export it in?  Sonic Extractor supports ".bmp" natively, since Game Maker can export in that format, but it sure takes up a lot of space.  With a little help from the freeware command-line image manipulation tool, ImageMagick, though, Sonic Extractor can support ".png", as well.  You just have to specify where the file "convert.exe" is stored in your Image Magick directory, so Sonic Extractor knows where to find it to make use of it.  To do this you just bring up the Right Click menu and select "Specify ImageMagick Directory".  If you don't want to install ImageMagick (though it really is a rather neat programme) you don't have to, of course, but you will be restricted to uncompressed bitmaps only.

            If you're not using ImageMagick, then, select "Export Zone Map to BMP".  Sometimes there is a need to only make an image of a partial Zone, so first you are allowed to specify the area of the Zone map you actually want to export.  This is done by way of four input boxes - starting X and Y coordinates, and ending X and Y coordinates.  As you enter each coordinate, press the "OK" button to move on to the next.  Pressing "Cancel" on any of these four input boxes will disregard all coordinate inputs, and skip straight ahead to exporting the Zone map in its entirety.

            Next, a message box will tell you the estimated disc cost, and you can cancel if you think it's too much.  If you happen to be running the programme off a partition, or a USB drive, you could run into trouble.  You'll just have to clear some space, drive hog!

            If you are using ImageMagick, select "Export Zone Map to PNG" instead.  The same Zone region input boxes will be shown, but there will be no disc cost message, since I can't predict how much the images will be compressed.  The process only exports one bitmap at a time, usually 2048x2048 (if you have specified a smaller range, or the Zone's dimensions aren't perfectly divisible by 2048, the bitmap may be smaller).  ImageMagick is used to convert each BMP chunk to PNG as it is made, unceremoniously deleting each BMP as it goes.  Because of this, the Command Prompt window will appear several times, as necessary.  The temporary bitmap can be up to 16 megabytes in size, so if you are operating on an extremely cramped drive, you might still want to make space considerations.

            Because Game Maker has a size limit of 2048x2048 on exported images, when you export the Zone map you will be left with a series of chunks, and not one whole image.  Sonic 3&K Zones are simply too large for even ImageMagick to handle, and it'll be up to you to decide how to concatenate them.  You may want to break Zones into several maps, or even discard unnecessary chunks.

            Finally, you can choose "Save Screenshot" to save a bitmap of just the current screen.

 

Notes on Sonic 3 & Knuckles

 

            Though Sonic Extractor endeavours to make mapping Sonic 3 & Knuckles as easy as I can make it, there will still be a few little things to keep in mind.  The programmers of the games were pulling out all the stops to push the Mega Drive to its limits, creating dynamic levels with cycling palettes and changing tiles.  Whole chunks of the Zones move around during play, like in Marble Garden, Hydrocity, and Flying Battery.  New tiles are loaded as you progress through the Zone, like in Angel Island.  Even palettes change halfway through the Zones, like in Hidden Palace and Mushroom Hill.  Thus, maps may have garbage, missing tiles, or tiles with the wrong palette.  But there is a solution.  Move through the Zone in Gens, taking savestates in each different area (such as in each of the seasons in Mushroom Hill Act 2, or each building interior in Launch Base).  Then you'll be able to make more than one map of each Zone and put together the correct parts of each, to make a finished map that accurately reflects the Zone as it is played (using the screenshot feature or only exporting a partial map can be useful here).  At least not all of the Zones are this tricky.

            Annoyingly, Lava Reef is missing tiles.  They aren't part of the normal Mega Drive backgrounds, but added on top as sprites.  If each one was its own object, they could have been included, just like the columns and waterfalls in other Zones.  But instead, some central object takes care of them all in some way that I don't yet understand.  But certainly Lava Reef isn't unrecognisable for the lack of these few tiles.  I'm just warning you so you won't think it's your savestate that's to blame, or some error in Sonic Extractor.

            Finally, I haven't included Special Stage support, because the Esrael Sonic Editor II has a pretty nice Sonic 3 & Knuckles Special Stage Editor.  It's the Zones that are difficult to get maps of, so that's what I concentrated on.

 

Legal Stuff

 

            This programme is made entirely by me, Mercury - the contents, though (sprites, layouts, etc) are entirely the property of Sega.  For this reason, I don't need to be given credit for any maps exported with Sonic Extractor.  However, I wouldn't take too kindly to somebody redistributing the programme as their own work, or using it to violate anyone's copyright, so please be polite.

            Keep in mind also that ImageMagick is protected by its own licences, and Sonic Extractor is coded to be compatible with ImageMagick.  Thus it might be infringing upon them, as well, if somebody tried doing something unscrupulous.

           And finally, don't try selling the programme for money or anything.  Cos that'd be stupid.

 

            If you have anything to say about the programme (bug reports, feedback, and whatnot), you can send them to us.mercurysilver@gmail.com.  Any serious bugs brought to my attention I will try to remedy in future updates, but don't expect any personal replies.  I'm simply far too busy (and misanthropic ;p).

 

            Cheers!