Good sir, good point. Ok then, TUTORIAL TIME! First off then, if you haven't already done so... please go pick up the following:
A Sonic & Knuckles Split Disassembly, and
SonMapEd. NOW if you don't know how to use SonMapEd, I suggest you take a quick look at
THIS, and
THIS, before proceeding. I'll still walk you through how to do everything though, so don't worry. It is REALLY EASY!
Right then. Take a look at your disassembly. Now if you work with the Sonic 1/2 disassemblies, this will look... different. This is because the file layout is not based on WHAT the files are, rather... the context in which they are used. Personally I prefer the former... and will be organizing it that way in my Sonic 3 REV C disassembly when I work on that. ANYWAY, Open the "General" folder. This will contain mappings, palettes, art, etc. for all of the characters, enemies, etc. outside of the main 1P levels.
(The zones can be found in the "Levels" folder below "General" for future reference.)
IMPORTANT: Before doing anything else, Go to "Settings > Game Format" in the SonMapEd menu. Select Sonic 3 & Knuckles. Be sure to change this each time you work with a different base game, as each games files are handled differently (Most notably mappings... and PLC's, I think though I could be wrong). Ok, proceed...
Now, we want Knuckles' mappings. They are found in
"General" >
"Sprites" >
"Knuckles" > "Map - Knuckles.asm". Now, you can open it if you want, but in its unlabeled messy state, chances are, you may not know what to do with it. SO, let's have SonMapEd do it for us. Open SonMapEd, and... provided you read the SonMapEd tutorial I linked above... you know how to at least open the files. So go load Knuckles art (Load Uncompressed Art) (
Knuckles > Art > Knuckles.bin), his palette (Load Primary/Full Palette) (
Knuckles > Palettes > Main.bin) - OPTIONAL, BUT BETTER TO JUST DO THIS, his mappings (
Knuckles > Map - Knuckles.bin) AND finally, the DPLC's (Knuckles >
Knuckles pattern load cues.asm)
Notice the sprite counter at the very top of the window? This will tell you what number your sprite is. You can have it in decimal numbers, or hex like mine. I'll give you the numbers in both, for this tutorial. Press the
[ and
] keys to scroll through the sprites, and go to sprite
213/251 (
D5/FB) Now, to fix this error, we want to fix the positioning of the sprite. To shift the sprite up, down, left, or right, hold
SHIFT and hit the respective arrow key. This will shift the sprite by 1 pixel. NOT holding shift with the arrow keys will shift the sprite 8 pixels. We don't need to do that here, since the sprite is only off-center by 1 pixel. So for this sprite, and the one directly after that, shift them over 1 pixel to the left. Now, go ahead and save the mappings file. Rename the old one
"Map - Knuckles OLD", and don't overwrite it, as we are going to look at what we did.
Now build (Build Scripts > buildS3Complete.bat) and run, and voila. Fixed! Now, for education's sake... lets look at what we ACTUALLY did. Open up both of your Map - Knuckles.asm files and compare them with each other. They will be difficult to look through and compare, as SonMapEd's output is a bit different in appearance compared to the original disassembly file. Here is, generally speaking, what the mappings of the first file looks like:
SME_pwc2r_1F8:
dc.b 0, 4
dc.b $EC, 8, 0, 0, $FF, $F3
dc.b $F4, $E, 0, 3, $FF, $F3
dc.b $FC, 2, 0, $F, $FF, $EB
dc.b $C, 4, 0, $12, 0, 3
This page explains what all of these numbers mean, and so will I. The first two numbers are the number of pieces (clusters of tiles put together) that make the sprite. In SonMapEd, press the
; or
' keys to scroll through sprite pieces. Afterwards, you have lines of hex that are in this format
YY SS VV VV XX XX. I'll explain each one in detail.
- YY - (Y Position) The relative signed top edge position of the sprite from the center of the object. So look at the 1st byte of the 1st piece. $EC is -20. The top of the piece is 20 pixels above the center of the sprite.
- SS - (Shape/Size) is the size of the sprite, in tiles minus one. The upper four bits are ignored, the next two bits control the width and the lowest two bits control the height. Thus sprites can be of any size from 1x1 tile to 4x4 tiles. For example, $01 is a 1x2 sprite, $02 is a 1x3 sprite, $04 is a 2x1 sprite, and so on. NOW you know why we are using sprite PIECES! Anyway, the first piece here says 8, which is 1000 in binary. So that means it is 3x1 (bits 10 is 2, bits 00 is 0. Add #1 to both of these).
- VV - (VDP/V-Ram read/settings) This word will be added to the object's VRAM offset and then used as the pattern index for that sprite. Like all SEGA Genesis VDP pattern indices, it is a bitmask of the form PCCY XAAA AAAA AAAA. P is the priority flag, CC is the palette line to use, X and Y indicate that the sprite should be flipped horizontally and vertically respectively and AAA AAAA AAAA is the actual tile index, I.e. the VRAM offset of the pattern divided by $20. Both being at zero, that means that priority=false, it uses palette line 1, the tile is not flipped, and the piece starts with using the first tile.
- XX - (X Position) This is the relative signed left edge position of the sprite from the center of the object. So... just like with the YY byte, this is just converted to decimal. This time, though, it is 2 bytes. So what have we got? $FF F3. This is -13 in decimal. We now know that it is 13 pixels to the left of the center of the sprite. Using the XX and YY coordinates, we can locate the center of the sprite, BTW. Just thought I'd mention that.
Now, let's find out where we made a change. In the OLD file, search for:
word_14BA3E:. In the new one, search for:
SME_pwc2r_1168:. Not much more for me to say here. I think you get the idea.
TheInvisibleSun, on 07 February 2013 - 03:23 AM, said:
Tiddles, on 07 February 2013 - 01:37 AM, said:
As far as the relabelling goes, does this mean you're looking through the labels with loc_xxxxx type names and figuring out what they do to give them a sensible name? Would be interesting to see a sample section with some better labels and comments! This sort of thing tends to be extremely helpful, natch.
This. It certainly helped me to understand a lot about how to work with Sonic 1 (which still has some areas that are still unnamed/unconverted by the way, namely Final Zone and it's relevant functions and routines, for example).
That is EXACTLY what I am doing. Also making comments, and will give the variables and whatnot the same name as what my Sonic 1/2 disassemblies have. It'll be difficult and time consuming though...
EDIT: I'm working (albeit at a very slow, holiday speed) on cooking up a sample with Sonic 3's Sonic object code... Learned something, I did. Sonic and 2P Sonic are different objects, as we all know... but they actually share much of the same routines! Only the init and control routines are different... Hmm... I'll post the asm for Sonic when its ready. It'll come in its own smaller asm file that you can copy/paste into your Sonic 3 disassembly's asm.
This post has been edited by KingofHarts: 10 February 2013 - 03:03 AM