Actions

SCHG How-to

Difference between revisions of "Add a New Monitor in Sonic 2 SMS"

From Sonic Retro

m (Text replacement - "<asm>" to "<syntaxhighlight lang="asm">")
Line 43: Line 43:
 
And that's it! But of course don't forget to edit each level's object layout, otherwise you'll never be able to test your code. xP
 
And that's it! But of course don't forget to edit each level's object layout, otherwise you'll never be able to test your code. xP
  
[[Category:SCHG_How-tos|{{PAGENAME}}]]
+
{{S1Howtos}}

Revision as of 11:15, 25 August 2018

(Original guide by Ravenfreak)

So you want to add a new monitor in Sonic 2 and wanted to use one of the few unused monitors but don't know how? Well, here's how! First, open s2.asm in your editor of choice and search for "Collision_Monitor". It should look like this:

Collision_Monitor:
LABEL_47F6:		;collision with monitor
	ld      hl, $D39D
	ld      a, (hl)
	bit     0, a
	jr      nz, Collision_Monitor_Rings
	bit     1, a
	jr      nz, Collision_Monitor_Life
	bit     4, a
	jr      nz, Collision_Monitor_Continue
	bit     5, a
	jr      nz, LABEL_4845
	bit     2, a
	jr      nz, Collision_Monitor_Sneakers
	bit     3, a
	jr      nz, Collision_Monitor_Invincibility
	bit     6, a
	jr      nz, LABEL_4884
	ret

These are the types of monitors used in the game. Now scroll down until you see this:

LABEL_4845:
	res     5, (hl)
	ret

This is one of two blank monitors that are available to use, the other one is located after the invincibility monitor routine. Now at this point you might think to add your new monitor code after the res operand, but if you do this the game freezes. To get past this, you need to page in the bank that contains the monitors, bank 07. So after the res operand add this:

 ld a, :Bank07
      ld ($FFFF),a
      Call New_Monitor
      ret

You can change the "New_Monitor" label to whatever you want of course. xP Now to add the monitor code. Before adding your code, if you wanted to use the Question Mark monitor add this:

New_Monitor:
      ld a, ($D39D)
      cp $07
      ret z
      ;your code goes here

And that's it! But of course don't forget to edit each level's object layout, otherwise you'll never be able to test your code. xP

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
Miscellaneous
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)