don't click here

Sonic 4 in 1

Discussion in 'Engineering & Reverse Engineering' started by AURORA☆FIELDS, Nov 1, 2016.



    The cute one here Tech Member
    Hello! Time for a late-release of just another hack. So whats it this time? Why, it is;
    Sonic 4 in 1!

    I am guessing, many of you would remember Vladikcomper's awesome hack Sonic 3 in 1? I used to think it was something really cool, but it kind of lacked something... Another game maybe? Oh yes, it would have to be Sonic & Knuckles! It's really shame since I've not played that game too much, so it definitely felt like a big piece missing. So I had a thought, would it actually be possible to fit all the games in. As an added challenge, and because there still is not a completed Sonic 3 disassembly around, I could not exactly do a lot to it. I thought I'd rather try my best to modify the games as little as possible (With few exceptions) and make the games still co-operate in a single ROM. If you want to read more boring backstory, open the spoiler here:
    Despite what I will end this with, it was actually surprisingly easy hack to do. Even though pain in the ass in the end, I was expecting it to be nearly impossible and have a lot of issues it really didn't end up having. At first I had to work out few limitations imposed by the massive 4 bytes of RAM I could afford. There were some weird issues, like Sonic 2 having to use REV02 because if not... Well the sound driver doesn't work. Why? Who knows, but at least REV02 somehow works. But me being me, I had to take the fancy route, and add a huge nice menu on top of everything, so I ended up working on it for months, rather than few days.

    I had a great plan from the start though, and thanks to a collaboration I did with flamewing a fair bit earlier, he made this tool called gen_scaler. This tool was amazing; It could create code that would horizontally scale image of any height and width, into any height and width buffer. What this basically meant, that the code I wanted to implement for scaling the menu like you see in the final product already existed, I just had to implement it! However, there were many complications. First of all, gen_scaler was actually really buggy and did not scale correctly. I had to bug FW to fix it, but to my pleasure he made it almost perfect. Some artifacting can still be seen but its not easy to see. Then, I realized that I would need to do some complex coding just to get the vertical scaling, palette change and image rendering work in unison. It was completely impossible to even just get the vertical scaling with image rendering working and so I abandoned the idea. I told fw that I needed him to make a vertical scaler also. Then he asked the million dollar question; "Why not just use the existing gen_scaler code to also scale vertically at the same time?" It didn't even occur to me you could do it, but I tried, and in few hours I had hacked together this feature. It was legendary; It made the rendering time take ~3 frames instead of ~8 frames, it solved the entire mess of vertically scaling, AND it was really simple to implement! Even given I got the code wrong at first, it still worked well!

    So then what, I now have a nice scaler code, a basic menu framework and the games sort of work. Oh except, no they really don't. There are a lot of glitches, few crashes, and no Sonic 2 & Knuckles either. Well shit, turns out the disassembly for S2K is really terrible and outdated. A lot of the lables are just plainly wrong, and even in some cases the right routine is commented right after the wrong one. This would be fine, except I use Sonic 2's exported symbols in S2K to gain the addresses, so effectively the game is broken. Furthermore due to differences to originals, it wouldn't even boot. I spent a lot of time debugging and patching things up until I got everything working here. The other games are fairly easy, with the odd crash in Sonic 3.

    At this point, the menu, although looks rough, works mostly. Now is the time to make it all shiny and "complete". You would think this is a quick process. But we were only like 2 months in! During this time I worked on the menu, GF had been working away at the Sonic 1 and Sonic 2 image art. And I have to hand it for him, he did some amazing work given the huge limitation of max 15 colors. No more, no less. If you are less experienced artist, and have to cope with this insane limitation whilst making vibrant and good looking scene, it can be really daunting task! Even though he had hard a time with this, he did a great job imo. VAda came in help at some point too, but the main work was up to GF. This gave me the possibility to test the rendering code better and see how it would look. Later when the Sonic 2 image was added, I first noticed how bad the vertical renderer really was. However with little tweaking it was soon fixed.

    So, next it came to implenting more of the menu. The menu text I decided to generate with a variable width font generator I had made earlier for a friend. However, I needed a nice looking font. So I decided to make a tool that would convert fonts from a png file to data files for this generator. That took me quite a while to get down. I also needed a menu background, so in this process I went digging to the World Of Illusion source code, and found the required files as well as other cool stuff. Finally the menu not only looked nice, but was also functional. Somewhere around this time I implemented the Game no Kanzume sound driver, to even add music in.

    Of course I had to take the high route and add Sonic Retro and SSRG splash screens in. However, due to their complexity, and the messy nature of my implementation, actually getting them to run involved a lot of research into Sonic 3, as well as fixing a lot of oddities. However, after many days of work, I get both up and running. Of course, I still needed to entirely program the "scripts" for SR. These would actually move the sprites around and make all the effects appear. I got a heart-attack when I tested on hardware though; nothing works. After hours of banging head to a wall, I realize I need to clear PLC's. I didn't notice this because emulators clear the RAM on boot-up, unlike flash carts. Crisis avoided.

    Of course I had to add few secrets in. It took me quite a while to write up one of the secrets, while that I was also doing bugtesting and doing other interests. I can't really work if I am watching a video or talking with someone, I need to actually really focus on what I am doing, and that's why writing everything was quite slow for me. I was also running awfully thin in time, and I realized that the amount of stuff I had to do for these last 2-ish months was huge. I started working harder and harder to get at least most done. I had to also hurry GF about the art (sorry mate), and unfortunately he could not find the time to make all of them. I however, had a lot of other plans, and I started getting more and more stressed about it.

    During the last 2 months I got most of the work done, even though the game had the main skeleton done already, in the last months and weeks of development it got the polish what I always strive for. Also a lot of additional things, such as the secrets, code optimization, fixing issues (like the rendering bugs, I finally made it nearly perfect), and fixing many small issues in the game. Though, with few weeks left, I let RHS test my game on hardware, and it didn't work. I was confused because I had tested on hardware and it was fine, but apparently due to not clearing RAM correctly, the splash screens broke completely. I was pissed off about it due to the main menu and games (mostly) working! After multiple hours of pulling hair out, even after trying to fix the bugs and clear all kinds of RAM, I finally got it. The problem was the damned moveq bug in ASM68K. For those who are unaware, ASM68K would not allow you to input numbers higher than $7F to moveq, and would require 32-bit signed number to be entered. This is fine, but instead of terminating assembly, it warns you about it and puts in $61 instead! And I have warnings disabled in my hack's assembly. Epic fail. This is why I had to debug these issues I thought I fixed by clearing RAM for hours. When I was about to give up, filled the RAM with garbage, and tried on emulators, I finally was able to reproduce the issue myself. I look at the listings file, and notice that $61 in there, mocking me like an idiot. Needless to say it was a simple fix, and I was frustrated but relieved that it ended up being so easy fix to do in the end.

    So, this leaves up with the last days to submit. I was tired, broken, and about done with the hack. I had to cut down on some features, and some things I couldn't quite finish. Soon, my dearest sexiest friend djohe would complain about a few glitches in Sonic 2. He soon realized I used REV02, and told me off for it. I explained other revisions didn't work, but because Sonic Team, REV02 actually had some flipping issues and other glitches. I was able to hunt these down, fix them and move on. I was relieved that he didn't complain about anything else on Sonic 2 after that.

    Then I played through most of the games my testers didn't, and notice something strange in S3K SSZ. One of the "clouds" are all glitched up! Holy shit what do I do?! I was just about to give up, I could not care less about fixing it anymore, but my dearest sexiest friend djohe wouldn't shut up about it. So with literally only couple hours left til submissions would be supposedly closed, I look at what he found, and could not find anything wrong. Until I saw another mappings file, for the bigger "clouds". It saw something intriguing, the art tile pointed to $7C0. I realized immediately, this was loading a masked sprite! I was toying around this code earlier, because I did not understand at all what it meant, until I removed it and saw its effects. I tested this using the S&K disassembly from my hack. I went to look at the code, and who knew, I forgot to change branch back to the original one, which basically meant it will try to show any masked sprite normally, instead of hiding it. I am glad I went to fix this, because it would have been an embarrassing bug to leave in haha!

    That is roughly what the development of this hack was like. It was a huge rollercoaster of self-harm. Trying to do something like this is definitely not easy, and requires a lot of hitting your head against the wall to get through. But I am glad I did, because this has taught me a lot of lessons, and I think I can do a lot more as a result. This was one of the most frustrating projects to work on, and definitely probably the most stupid ones too. The worst part about working with 68000 is definitely debugging something that you cant really easily debug, as well as trying to do something that the 68000 really shouldn't even be able to do. This project is basically 99% of that. Fucking hate that shit, trying to make 5 different games co-operate together is basically trying to bake bread with your dick. It's not easy and it's not fun.

    So, I have decided to submit this hack as open source. Although the download version is different from what the source offers, you may understand why I can not distribute Sonic Retro splash screen code, SSRG splash screen code, few things done to me by people who are yet not willing to release their work onto public, and may want to keep it secretive (hi Vladikcomper =P). I also do not want to spoil the secrets right away; I will want you to find the secret codes yourself by any means you deem necessary. So! Without further ado, have teh download linkz!

    There's a few problems with running hacks like this; This uses some features of the Mega Drive that are pretty much nonstandard, so not all emulators or hardware will support it. I've made a list of things that I know that will be able to work with this:
    • Mega EverDrive (hw) - Full support
    • EverDrive MD (hw) - Full support (Seems like on older models it may not work)
    • Carts with no mappers - No support
    • Fusion 3.64 - Partial support
    • Regen - Works only if LargeROMSpace is set to 1.
    • Gens re-recording - No support
    • BizHawk - SRAM saving does not work (Issue #695), and has randomizer issues
    • Genesis Plus GX - May or may not work, tests done earlier seem to disagree with tests done later. Needs further testing.

    Some unfortunate bugs also exist due to the way this works. Namely, color artifacts onscreen, that would have been previously hidden. Notably happens in Sonic 3 and Sonic & Knuckles, but may occur on other games abnormally too.

    Aaand... *drumroll* Here's the credits (aka who made this even possible in the first place);
    • Natsumi - Menu program, skeleton, game fixes, variable width font, custom Sonic Retro scripts & compatibility
    • flamewing - gen_scalers (horizontal software scaler program)
    • GF ThePlayer - Main artist
    • VAdaPEGA - Helping artist (Sonic 1, Sonic 2)
    • ValleyBell - Sound driver disassembly
    • Vladikcomper - Music, SSRG splash screen
    • Marc - Music, Sonic Retro splash screen
    • MarkeyJester - Animation and misc help
    • djohe - Testing
    • RedHotSonic - Testing (And debugging (tons of it! Thanks man))
  2. At first I thought you only got Sonic 1, 2, 3, and S&K on a single ROM and was intrigued, but then I noticed you got all the Sonic & Knuckles variations in there too! All in one ROM hack! Very impressive!
  3. Shoemanbundy


    Chicago, Illinois
    selling shoes
    Wow, nice menus. Liking the graphics. Wonder what the secrets are now :)

    How long before this is pirated all over Brazil?
  4. Dr. Mecha

    Dr. Mecha

    Dallas, TX
    3d Models
    Did you just pulled off a Sonic Jam for the Genesis/MegaDrive without the Sonic World and its contents? Because that's what it look like to me.
  5. Z3N3K_


    I think the link is down :( You have another link to the hack? I really want to try it out!
  6. biggestsonicfan


    Model2wannaB Tech Member
    ALWAYS Sonic the Fighters
    Check the Sonic Hacking Contest's 2016 vault here. File is named "[SHC2016] [compo2016] 32 - Sonic 4 in 1 - By Natsumi.bin".