|
|
SCHG:Nem s2ssFrom Sonic Retro
IntroductionHere are my notes on the S2 savestate files. In order to edit these files I recommend a hex utility called Hex Workshop, and I recommend getting the emulators gens and genecyst. Gens is the one I use most of the time, but genecyst has a lot of features that are extremely useful that gens dosen't have. First of all it's very important that you understand the basics. All data stored on a computer is in the form of 1's and 0's. On a CD for example, a laser hits the surface, and if the laser bounces back and hits the lens it's a 1, and if it dosen't it's a zero. Each 1 or 0 is called a bit, and a bit cannot have any other characters in it other that a 1 or a 0. Now the computer deals with bits in groups of 4. There are 16 possible combinations for a group of four 1's and 0's, so to make it simpler to deal with it as one value, rather than 4 (Eg. 0110 becomes 6). Now as there are 16 possible combinations for a group of 4 bits, this value to represent thier values must have 16 values itself, so rather than a simple 0-9, this value is 0-F (0123456789ABCDEF). This value is called a hexadecimal value (hex value fo short). Each hex value is dealt with in groups of 2, called a byte, each byte having 128 possible combinations. Now on a final output level the byte may be looked up on an ASCII table, which will convert that value into a recogniseable character (Eg. a byte value of 73 becomes a lowercase s on an english ASCII table). You will practically never touch the ASCII version of the code in hacking though. Now one important thing to realise is that as one character of hex has 16 values and a decimal (real) value only has 10, it may be nessicary to convert the numbers between them from time to time. This is done with the use of a base converter (included in hex workshop). Let's say you wanted to give Sonic 50 rings. If you enter 50 as the vaue, you will in fact end up with 80, becuase that value you are entering is actually a hex value, but if you use the base converer to convert it first, you merely enter the value of 50 into the decimal box, and it will spit out a hex value of 32, which will in fact give you 50 rings in the game. Another useful utility that you will need is a hex calculator (also included in hex workshop). A hex calculator is the same as a normal calculator, but it deals with hex values rather than decimal values. Now onto exactly what a savestate consists of. A savestate is a dump of all the ram that is allocated to the system, but that's not just main system ram, it's sound ram, CPU cache, etc. In a savestate all of this is mashed together in one file. Here's what's where in a genecyst savestate:
And here's what's where in a Kgen savestate:
All the address values listed here are based on a genecyst savestate file, so if you wish to edit one of another type you'll have to convert them yourself. Now any single value that is stored in the system ram can be altered in game by use of a pro action replay code. First of all, here's an example of a Pro action replay code: FFFE10:0800 Now, the first byte in this code is FF, and a value of FF in the first two characters indicates that the code is altering data in the system ram. The next four character after it are the actual memory location in the ram, and the last four are the two byte value to write into that memory address. The pro action replay will always alter two memory addreses at a time by the way, because the Mega Drive (Genesis) is a 16 bit system. It dosen't matter though because you will find that a value will have two bytes assigned to it anyway, or the second byte will be related. In the case of the example, the first byte being altered is the current level, and the second is the current act within that level. The actual address of these values in the savestate are 12288 and 12289. An explination of why lies in the locations of the ram data that is stored in the savestate. If you look at the above table, there are 2478 lines worth of data before the system ram in the savestate, so for any action replay code you want to convert into a file location, you will need to add 2478 to the line number, and for any line number you want to convert into a pro action replay code you will need to minus 2478. Remember that these line numbers are hex values though, so you will need to do this in a hex calculator. (NOTE: Genecyst dosen't do pro action replay codes properly, use gens instead for that function). Another thing you need to know is that each level in Sonic 2 has a value asigned to it, but this value does not correspond with each level's final position in the game. Here is a list of the level values in Sonic 2:
And here's the list for the beta:
And one last thing you need to know is the way that the Mega Drive stores all the art. All the art that is used in the game is stored in the form of 8x8 pixel blocks. These blocks do not actually store colours at all, they actually only have one hex value per pixel. That value specifies what point on the palette line the pixel will get it's colour from. The palette has 4 lines, each with 16 colurs on them. Now the colours on the palette can be changed at any point during play, and some palette colours may even automatically change colour each couple of frames to make it look like the colour is flashing. Now these 8x8 blocks are not what makes up the level directly. 4 8x8 blocks are grouped together to form a 16x16 block, and it is at this point that the palette line to use for that 16x16 block is specified. The 8x8 patterns can also have thier x, y, or x and y values reversed when placing them in a 16x16 block. Also it's at the 16x16 level that the collision definitions are specified. Now finally we get to a 128x128 block, and these are the things that the actual level info loads. It is made up of 64 16x16 blocks,and each block inside them can use a different palette line. You cannot place anything except a sprite or a 128x128 block directly into a level. Now that you know all the basics, here's my breakdown: Internal Groups
Single Variables
Pattern breakdown8x8 blocks (12478-1C477) 16x16 block mappings: (B478-CE77)
The next three values represent the pattern number to use. Specify the number that the pattern is in the list. Past the value of 800, the block number restarts back at block 0, but the block is mirrored. The block mappings use the standard method of layout, start at x0 y0 and move across x values until end of line is reached, then repeating on next y value. If a space is blank in the 16x16 mappings, it will have the values 4000 in every box. 128x128 block mappings: (2478-A477) Collision info breakdownFinal: (FA78-FD77) Based on 16x16 blocks, not 8x8 blocks. One byte per block in sequencial order. Each value creates a different responce, so a full listing will need to be compiled (FF=solid, 00=not solid). Beta: (F478-FA77) Sprite loading addresses (11BE8-11BEF)The sprite information is discarded when screen moves too far away, and information is then reloaded from rom when character reenters area. These values specify a location in the rom to load the information from. The first four bytes are the address to load the sprites from when approaching from the left. The four bytes after that is the address to load the sprite info when approaching from the right. There is also another block of 8 bytes after this one that appears to be the same, but it dosen't seem to do anything. And no, it's not where to load the sprites from when approaching from the top and bottom. By transferring these values between levels, you can do some interesting things such as fighting the Death Egg in Aquatic Ruin zone. NOTE: Altering these values to those of another level will transfer the information for the location of sprites, and the key files (definitions about movement/reactions) for the sprites, but unless the correct patterns for them are loaded into the ram, it will look like a jumbled piece of crap. Buffered sprite breakdownFinal: (D878-F477) Stored in blocks of 64 bytes (40) per sprite. The sprites are listed in the order that they appear starting from the top left and scrolling across x values, then beginning on next line. The following example uses address locations for the first sprite on the list as a referance. You will need to increase the line values on this list by 40(hex) for every sprite that comes before the one you want to modify.
Beta: (DC78-F477)
Ring placement breakdown (10C78-11277)One ring is defined by 6 bytes. The first byte has something to do with the ring's current status. 00 you can get the ring, but 01-7F you can't, and 80-FF the ring disappears completely. The second byte is to do with the animation of the sprite. 00 is animated, 01 up is the frame of the animation to display if the sprite is not animated (07 is the last frame for the ring animation). The second two bytes are the x location of the sprite, and the last two bytes are the y location of the sprite. All the rings are listed in a large group, and the end of this group is signalled by the 4 byte value FFFF FFFF. Pallette breakdownFinal: (Below water: 114F8-11577, Above water: 11F78-11FF7) Beta:(Below water: 11EF8-11F77, Above water: 11F78-11FF7) Pattern load cue (11AF8-?????)Requests are processed in the order they are listed. If you try to load multiple patterns to the same area, the last one will overwrite the first. A six byte value per request. First four bytes are the address to load the patterns from the rom (eg, 0008 30D2). The last two bytes are the address to load the patterns into in the video ram. The pattern view window in genecyst is the easiest way to determine this. Note that whenever clearing out the pattern cue you must also set 11B71 to 00, or else some crap will be written over the first few patterns in the video ram. I have yet to narrow down the exact relationship this variable has with the load cue. Master level trigger (11A78)This trigger is the main trigger that specifies the current "mode" if you will that the game is in. Changing this will make the game switch to the mode you specify once it finishes it's current process.
These values repeat every (40). Values above 28 have not been used, so you get the red screen of death. If you change this value in level the screen will fade out and the data for the thing you have selected will be loaded instead. If you specify a value betwen the values I have listed, you will get some strange results. Level design breakdown (A478-B477)Level is delt with as a grid, starting with first tile in top left and working across to the right doing one x value at a time. One byte represents one tile in one grid location. A value of 00 is the first large tile in the database, 01 is the second, etc. The maximum possible number of large tiles on the x-axis is 127 (7F). One x line is stored in the form of 127 lines for foreground tiles, then another 127 lines for background tiles per y value. That totals an increase of 0100 per line, so if level data started at 0300 (not possible), 0300-03FF would be all the data for the top row of 128x128 tiles, 0400-04FF would be all the data for the second row of 128x128 tiles, etc.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
