Sonic the Hedgehog/Subroutines

From Sonic Retro

SCHG: Sonic 1's Subroutines

At some point, you, the user on Sonic Retro has made an attempt at creating a rom hack of a Mega Drive (or Sega Genesis for you American users) Sonic game. We'll be focusing on Sonic 1's subroutines and exactly what they do.

This guide is actually focused on the GitHub disassembly. If you are using a hivebrain disassembly or something else, try to find the corresponding subroutine in question since the Hivebrain versions won't be here.

What are subroutines?

I can try to make this as simple as possible for people beginning the Sonic ROM Hacking scene. Let's say, you want to add back in the unused Robotnik monitor into Sonic 1. To do this, we would need to use subroutines to make the player get damaged and lose their rings when they break the monitor. Here's a tutorial if you actually want to do this. As stated there, when you replace that line of code that forces the monitor to do nothing with the "Spik_Hurt" routine, you are actually directing it to a subroutine. The "Spik_Hurt" routine is the routine that goes into play when Sonic makes contact with spikes. Knocking him back and causing him to get damaged (or nothing if invincible). When you branch the monitor to be broken to trigger the spikes routine, you're making the monitor be forced to hurt Sonic when it was originally going to do nothing! I tried to sum it up as best as possible.

Import routines into code

The exact same way they imported the spikes routine into the unused Robotnik montior can apply to any other monitor. Like the ring monitor. Change the line of code that tells the game to give Sonic 10 rings to hurting Sonic. Simple as that! Though, it doesn't apply to anything. Especially in places where Sonic isn't loaded in. You can't just put the code to hurt Sonic after the player presses the start button on the title screen. That also doesn't mean that the game will wait for Sonic to spawn in and then hurt the player.

If you would like to hack Sonic 1, view the tutorials below!

SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)

Written by XPointZPoint