Actions

SCHG How-to

Add New Monitors

From Sonic Retro

Revision as of 11:47, 23 January 2014 by Bombchu link (talk | contribs) (Revamped the entire thing. it woks now.)

Let's say you want another monitor. I've given the monitor files a once-over, and found an easy way to free up 10 monitors, the 'S', the Goggles, the Blank, and 7 "invalid" monitors. 2 notes before we begin: This uses the HV build, and I will mention this later, but whenever you want to input more art through SonMapED you HAVE to open up the file Monitors under the folder _maps and add the label map_monitor: to the file before the first piece of code.

Step 1: _incObj\2E Monitor Content Power-Up.asm

Find the following code: <asm>Pow_ChkS: cmpi.b #7,d0 ; does monitor contain 'S'? bne.s Pow_ChkEnd nop

Pow_ChkEnd: rts ; 'S' and goggles monitors do nothing</asm>

Replace it with this template: <asm>Pow_ChkS: cmpi.b #7,d0 ; does monitor contain 'S'? bne.s Pow_ChkGoggles

nop ;Insert code here.

===========================================================================

Pow_ChkGoggles: ;The Goggles monitor still does nothing. cmpi.b #8,d0 ; does monitor contain goggles? bne.s Pow_ChkInvalid1

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid1: cmpi.b #9,d0 ; Is this the 1st invalid monitor? bne.s Pow_ChkInvalid2

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid2: cmpi.b #$A,d0 ; Is this the 2nd invalid monitor? bne.s Pow_ChkInvalid3

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid3: cmpi.b #$B,d0 ; Is this the 3rd invalid monitor? bne.s Pow_ChkInvalid4

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid4: cmpi.b #$C,d0 ; Is this the 4th invalid monitor? bne.s Pow_ChkInvalid5

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid5: cmpi.b #$D,d0 ; Is this the 5th invalid monitor? bne.s Pow_ChkInvalid6

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid6: cmpi.b #$E,d0 ; Is this the 6th invalid monitor? bne.s Pow_ChkInvalid7

nop ;Insert code here.

==========================================================================

Pow_ChkInvalid7: cmpi.b #$F,d0 ; Is this the 7th invalid monitor? bne.s Pow_ChkBlank

nop ;Insert code here.

==========================================================================

Pow_ChkBlank: cmpi.b #0,d0 ; Is this the blank monitor? bne.s Pow_ChkEnd

nop ;Insert code here.

==========================================================================

Pow_ChkEnd: rts

===========================================================================</asm>

Now you can use the Eggman monitor (before the rest of the monitors in the code), the 'S' monitor, the Goggles monitor, the 7 invalid monitors, and the Blank monitor. There's just a few problems: the invalid monitors have glitchy graphics, they don't flash like the other ones, AND when we destroy them it shows the "S" monitor instead of the broken one.


Step 2: _maps\Monitor.asm

Now, let's worry about fixing some mapping errors. <asm>; --------------------------------------------------------------------------------

Sprite mappings - output from SonMapEd - Sonic 1 format
--------------------------------------------------------------------------------

SME_TP0l7: map_monitor: dc.w SME_TP0l7_1A-SME_TP0l7, SME_TP0l7_20-SME_TP0l7 dc.w SME_TP0l7_2B-SME_TP0l7, SME_TP0l7_36-SME_TP0l7 dc.w SME_TP0l7_41-SME_TP0l7, SME_TP0l7_4C-SME_TP0l7 dc.w SME_TP0l7_57-SME_TP0l7, SME_TP0l7_62-SME_TP0l7 dc.w SME_TP0l7_6D-SME_TP0l7, SME_TP0l7_78-SME_TP0l7 dc.w SME_TP0l7_83-SME_TP0l7, SME_TP0l7_8E-SME_TP0l7 dc.w SME_TP0l7_99-SME_TP0l7 SME_TP0l7_1A: dc.b 1 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_20: dc.b 2 dc.b $F5, 5, 0, $10, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_2B: dc.b 2 dc.b $F5, 5, 0, $14, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_36: dc.b 2 dc.b $F5, 5, 0, $18, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_41: dc.b 2 dc.b $F5, 5, 0, $1C, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_4C: dc.b 2 dc.b $F5, 5, 0, $24, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_57: dc.b 2 dc.b $F5, 5, 0, $28, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_62: dc.b 2 dc.b $F5, 5, 0, $2C, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_6D: dc.b 2 dc.b $F5, 5, 0, $30, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_78: dc.b 2 dc.b $F5, 5, 0, $34, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_83: dc.b 2 dc.b $F5, 5, 0, $20, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_8E: dc.b 2 dc.b $F5, 5, 0, $40, $F8 dc.b $EF, $F, 0, 0, $F0 SME_TP0l7_99: dc.b 1 dc.b $FF, $D, 0, $38, $F0 even</asm>

Yeah I know the labels don't look pretty, but at least they work. This adds an extra monitor sprite before the breaking one. You will also need to add some new sprites through SonMapED.

So now we have one new monitor.

I want to point out a line of code near the top, the one that says "map_monitor" This links from a lot of over places throughout the ROM and if this label wasn't here it wouldn't know where you go and you would get a build error. So every time you use SonMapED REINSERT THAT LABEL!

Step 3: _anim\Monitor.asm

This is a small file so I want you to take a gander at the beginning, see the labels how the correspond to the labels in a list?

This is the animation linking. (what tells the monitors to flash) notice how "breaking" monitor only has one animation.

Also see how the Eggman monitor is listed 1, 0, 3, 3, 1, 3, 3, 2, 3, 3, and then the Sonic monitor is 1, 0, 4, 4, 1, 4, 4, 2, 4, 4, the shoes are 5, 5, 5, 5, ect.

Now right before "@breaking:" insert this coding:

<asm> @Invalid_1: dc.b 1, 0, $B, $B, 1, $B, $B, 2, $B, $B, afEnd even </asm>

now add to the pointer in the index at the top of the file.

Replace this line. <asm> dc.w @breaking-Ani_Monitor </asm> with this one <asm> dc.w @Invalid_1-Ani_Monitor, @breaking-Ani_Monitor </asm>

If you did it right, it should look like this.

<asm>; ; ---------------------------------------------------------------------------

Animation script - monitors
---------------------------------------------------------------------------

Ani_Monitor: dc.w @static-Ani_Monitor, @eggman-Ani_Monitor, @sonic-Ani_Monitor dc.w @shoes-Ani_Monitor, @shield-Ani_Monitor, @invincible-Ani_Monitor dc.w @rings-Ani_Monitor, @s-Ani_Monitor, @goggles-Ani_Monitor dc.w @Invalid_1-Ani_Monitor, @breaking-Ani_Monitor @static: dc.b 1, 0, 1, 2, afEnd even @eggman: dc.b 1, 0, 3, 3, 1, 3, 3, 2, 3, 3, afEnd even @sonic: dc.b 1, 0, 4, 4, 1, 4, 4, 2, 4, 4, afEnd even @shoes: dc.b 1, 0, 5, 5, 1, 5, 5, 2, 5, 5, afEnd even @shield: dc.b 1, 0, 6, 6, 1, 6, 6, 2, 6, 6, afEnd even @invincible: dc.b 1, 0, 7, 7, 1, 7, 7, 2, 7, 7, afEnd even @rings: dc.b 1, 0, 8, 8, 1, 8, 8, 2, 8, 8, afEnd even @s: dc.b 1, 0, 9, 9, 1, 9, 9, 2, 9, 9, afEnd even @goggles: dc.b 1, 0, $A, $A, 1, $A, $A, 2, $A, $A, afEnd even @Invalid_1: dc.b 1, 0, $B, $B, 1, $B, $B, 2, $B, $B, afEnd even @breaking: dc.b 2, 0, 1, 2, $C, afBack, 1 even</asm> And now your monitors all work right! Except they look like 'S' monitors when destroyed...


Step 4: Errors

Now open up 26 Monitor.asm under the folder _incObj Search for "move.b #9,obAnim(a0)" and replace it with "move.b #10,obAnim(a0)". Now your monitors will display the correct mappings after being destroyed. We had 9 monitors to begin with + 1 new one = 10, simple.

Now assemble the code and... oh noes! The code doesn't work and the ROM refuses to assemble.

It's because of the added code. Now Some branches are now to far away to work.

Let's fix that, open up Sub SolidObject in the _incObj folder and change

<asm>bsr.w MvSonicOnPtfm</asm> to <asm>jsr MvSonicOnPtfm</asm>


Then open up 89 Ending Sequence STH in the same folder and change <asm>bra.w DisplaySprite</asm> to <asm>jmp DisplaySprite</asm>

This happens at both line 37 and 58

And you done.


Step 5: SonED2 Projects\objdef\s1obj.lst

You now have 1 new monitor. But when you try and place them in SonED 2, you notice that all the "invalid" monitors are labeled "Invalid". How do you know which one's which? You could remember how many times you've pressed the 1 key, or or could have it tell you.Search for " Description: Monitor". Now scroll down until you see " Desc 9: Invalid". Now change that to Invalid 1, the one below to Invalid 2, etc... Now you can tell which monitor is which. Of course, if you have a function for that monitor, you can actually just type it's function, such as "Infinite Speed Shoes" or "50 Rings".

Step 6: Adding More monitors

So we added one monitor. To add more, do the same as above starting form step 3 BUT you need to pay attention to the animations script. you NEED to add 1 to the digit before "afBack" on the line with "@breaking:" and insert your monitor code BEFORE the "@breaking:" and add another label to the index. (you can only have up to three labels per line so you might need to add a new line)

Also to add the Sprites, use SonMapEd