Actions

SCHG How-to

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

From Sonic Retro

(Created page with "{{GuideBy|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 yo…")
(No difference)

Revision as of 06:31, 5 October 2011

(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:

<asm>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</asm> These are the types of monitors used in the game. Now scroll down until you see this: <asm>LABEL_4845: res 5, (hl) ret</asm> This is one of two blank monitors that are avaliable 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: <asm> ld a, :Bank07

     ld ($FFFF)
     Call New_Monitor
     ret</asm>

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: <asm>New_Monitor:

     ld a, ($D39D)
     cp $07
     ret z
     ;your code goes here</asm>

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