Actions

SCHG How-to

Difference between revisions of "Create Insta-kill and High Jump Monitors"

From Sonic Retro

(Added asm tags.)
Line 3: Line 3:
 
Firstly, in the s2.code file, goto the label "robotnik_monitor". Underneath there, you should see this:
 
Firstly, in the s2.code file, goto the label "robotnik_monitor". Underneath there, you should see this:
  
[code]
+
<asm>
 
robotnik_monitor:
 
robotnik_monitor:
 
addq.w #1,(a2)
 
addq.w #1,(a2)
 
bra.w Touch_ChkHurt2
 
bra.w Touch_ChkHurt2
[/code]
+
</asm>
  
 
Change it to this:
 
Change it to this:
  
[code]
+
<asm>
 
robotnik_monitor: ;** Credits to Hayate
 
robotnik_monitor: ;** Credits to Hayate
 
addq.w    #1,(a2)
 
addq.w    #1,(a2)
Line 20: Line 20:
 
rts
 
rts
 
 
[/code]
+
</asm>
  
 
Now, making the hi-jump monitor is a little bit more harder to make. For my purposes, instead of making a new monitor subtype, we will enable the hi-jump effect everytime a Tails 1up monitor is hit. Since this monitor does not do anything in 1 player mode, it is perfect for our purposes. In order for this effect to take place, we will have to make a new flag for the timing, called "hijump_time"
 
Now, making the hi-jump monitor is a little bit more harder to make. For my purposes, instead of making a new monitor subtype, we will enable the hi-jump effect everytime a Tails 1up monitor is hit. Since this monitor does not do anything in 1 player mode, it is perfect for our purposes. In order for this effect to take place, we will have to make a new flag for the timing, called "hijump_time"
Line 26: Line 26:
 
First, we will initialize the new flag. Near the beginning of the s2.code file, you will find a list of variable initializations. Search for the following code, and add the flag, as shown:
 
First, we will initialize the new flag. Near the beginning of the s2.code file, you will find a list of variable initializations. Search for the following code, and add the flag, as shown:
  
[code]
+
<asm>
 
; conventions specific to sonic/tails (Obj01, Obj02, and ObjDB):
 
; conventions specific to sonic/tails (Obj01, Obj02, and ObjDB):
 
; note: $1F, $20, and $21 are unused and available
 
; note: $1F, $20, and $21 are unused and available
Line 50: Line 50:
 
layer = $3E ; collision plane, track switching...
 
layer = $3E ; collision plane, track switching...
 
layer_plus = $3F ; always same as layer+1 ?? used for collision somehow
 
layer_plus = $3F ; always same as layer+1 ?? used for collision somehow
[b]hijump_time = $40 ;**[/b]
+
[B]hijump_time = $40 ;**[/B]
[/code]
+
</asm>
  
 
Afterwards, goto the label "tails_1up". Underneath there, you should see this:
 
Afterwards, goto the label "tails_1up". Underneath there, you should see this:
  
[code]
+
<asm>
 
tails_1up:
 
tails_1up:
  
Line 63: Line 63:
 
move.w #$98,d0
 
move.w #$98,d0
 
jmp (PlayMusic).l ; Play extra life music
 
jmp (PlayMusic).l ; Play extra life music
[/code]
+
</asm>
  
 
Replace it with this:
 
Replace it with this:
  
[code]
+
<asm>
 
tails_1up: ;**
 
tails_1up: ;**
 
addq.w #1,(a2)
 
addq.w #1,(a2)
Line 73: Line 73:
 
move.w #$4B0,hijump_time(a1)
 
move.w #$4B0,hijump_time(a1)
 
rts
 
rts
[/code]
+
</asm>
  
 
What that will do will initialize a timer once this monitor is hit. You can modify the "move.w" value to any value you would like the timer to last. Lastly, in order to actually cause Sonic to jump higher, we need to modify some code for when Sonic jumps. Under label "Sonic_Jump", you should see the following code:
 
What that will do will initialize a timer once this monitor is hit. You can modify the "move.w" value to any value you would like the timer to last. Lastly, in order to actually cause Sonic to jump higher, we need to modify some code for when Sonic jumps. Under label "Sonic_Jump", you should see the following code:
  
[code]
+
<asm>
 
Sonic_Jump:
 
Sonic_Jump:
 
move.b (Ctrl_1_Press_Logical).w,d0
 
move.b (Ctrl_1_Press_Logical).w,d0
Line 123: Line 123:
 
bset #2,status(a0)
 
bset #2,status(a0)
 
addq.w #5,y_pos(a0)
 
addq.w #5,y_pos(a0)
[/code]
+
</asm>
  
 
Change it to this:
 
Change it to this:
  
[code]
+
<asm>
 
Sonic_Jump:
 
Sonic_Jump:
 
move.b (Ctrl_1_Press_Logical).w,d0
 
move.b (Ctrl_1_Press_Logical).w,d0
Line 177: Line 177:
 
bset #2,status(a0)
 
bset #2,status(a0)
 
addq.w #5,y_pos(a0)
 
addq.w #5,y_pos(a0)
[/code]
+
</asm>
  
 
You have now created a hi-jump monitor! You can change the value at the "move.w" after the ** to any other value to set how high sonic will jump. For any problems, please PM me.
 
You have now created a hi-jump monitor! You can change the value at the "move.w" after the ** to any other value to set how high sonic will jump. For any problems, please PM me.

Revision as of 05:06, 15 January 2011

This tutorial/how-to will show one how to make two types of monitors, which are an insta-kill ("R"), and hi-jump monitor. The former will always kill Sonic (even if he has a shield, or is invicible or super), while the latter will cause Sonic to jump extra high for a certain time period. For this guide, I will be using the 2007 Xenowhirl Sonic 2 Discode (without the extra split). Let's begin!

Firstly, in the s2.code file, goto the label "robotnik_monitor". Underneath there, you should see this:

<asm> robotnik_monitor: addq.w #1,(a2) bra.w Touch_ChkHurt2 </asm>

Change it to this:

<asm> robotnik_monitor: ;** Credits to Hayate addq.w #1,(a2) movea.l a0,a1 lea ($FFFFB000).w,a0 jsr (KillCharacter).l movea.l a1,a0 rts

</asm>

Now, making the hi-jump monitor is a little bit more harder to make. For my purposes, instead of making a new monitor subtype, we will enable the hi-jump effect everytime a Tails 1up monitor is hit. Since this monitor does not do anything in 1 player mode, it is perfect for our purposes. In order for this effect to take place, we will have to make a new flag for the timing, called "hijump_time"

First, we will initialize the new flag. Near the beginning of the s2.code file, you will find a list of variable initializations. Search for the following code, and add the flag, as shown:

<asm>

conventions specific to sonic/tails (Obj01, Obj02, and ObjDB)
note
$1F, $20, and $21 are unused and available

inertia = $14 ; and $15 ; directionless representation of speed... not updated in the air flip_angle = $27 ; angle about the x=0 axis (360 degrees = 256) (twist/tumble) air_left = $28 flip_turned = $29 ; 0 for normal, 1 to invert flipping (it's a 180 degree rotation about the axis of Sonic's spine, so he stays in the same position but looks turned around) obj_control = $2A ; 0 for normal, 1 for hanging or for resting on a flipper, $81 for going through CNZ/OOZ/MTZ tubes or stopped in CNZ cages or stoppers or flying if Tails status_secondary = $2B flips_remaining = $2C ; number of flip revolutions remaining flip_speed = $2D ; number of flip revolutions per frame / 256 move_lock = $2E ; and $2F ; horizontal control lock, counts down to 0 invulnerable_time = $30 ; and $31 ; time remaining until you stop blinking invincibility_time = $32 ; and $33 ; remaining speedshoes_time = $34 ; and $35 ; remaining next_tilt = $36 ; angle on ground in front of sprite tilt = $37 ; angle on ground stick_to_convex = $38 ; 0 for normal, 1 to make Sonic stick to convex surfaces like the rotating discs in Sonic 1 and 3 (unused in Sonic 2 but fully functional) spindash_flag = $39 ; 0 for normal, 1 for charging a spindash or forced rolling spindash_counter = $3A ; and $3B jumping = $3C interact = $3D ; RAM address of the last object Sonic stood on, minus $FFFFB000 and divided by $40 layer = $3E ; collision plane, track switching... layer_plus = $3F ; always same as layer+1 ?? used for collision somehow [B]hijump_time = $40 ;**[/B] </asm>

Afterwards, goto the label "tails_1up". Underneath there, you should see this:

<asm> tails_1up:

addq.w #1,($FFFFFEF6).w addq.b #1,(Life_count_2P).w addq.b #1,(Update_HUD_lives_2P).w move.w #$98,d0 jmp (PlayMusic).l ; Play extra life music </asm>

Replace it with this:

<asm> tails_1up: ;** addq.w #1,(a2) bset #3,status_secondary(a1) move.w #$4B0,hijump_time(a1) rts </asm>

What that will do will initialize a timer once this monitor is hit. You can modify the "move.w" value to any value you would like the timer to last. Lastly, in order to actually cause Sonic to jump higher, we need to modify some code for when Sonic jumps. Under label "Sonic_Jump", you should see the following code:

<asm> Sonic_Jump: move.b (Ctrl_1_Press_Logical).w,d0 andi.b #$70,d0 ; is A, B or C pressed? beq.w return_1AAE6 ; if not, return moveq #0,d0 move.b angle(a0),d0 addi.b #$80,d0 bsr.w CalcRoomOverHead cmpi.w #6,d1 ; does Sonic have enough room to jump? blt.w return_1AAE6 ; if not, branch move.w #$680,d2 tst.b (Super_Sonic_flag).w beq.s + move.w #$800,d2 ; set higher jump speed if super + btst #6,status(a0) ; Test if underwater beq.s + move.w #$380,d2 ; set lower jump speed if under + moveq #0,d0 move.b angle(a0),d0 subi.b #$40,d0 jsr (CalcSine).l muls.w d2,d1 asr.l #8,d1 add.w d1,x_vel(a0) ; make Sonic jump (in X... this adds nothing on level ground) muls.w d2,d0 asr.l #8,d0 add.w d0,y_vel(a0) ; make Sonic jump (in Y) bset #1,status(a0) bclr #5,status(a0) addq.l #4,sp move.b #1,jumping(a0) clr.b stick_to_convex(a0) move.w #$A0,d0 jsr (PlaySound).l ; play jumping sound move.b #$13,y_radius(a0) move.b #9,x_radius(a0) btst #2,status(a0) bne.s Sonic_RollJump move.b #$E,y_radius(a0) move.b #7,x_radius(a0) move.b #2,anim(a0) ; use "jumping" animation bset #2,status(a0) addq.w #5,y_pos(a0) </asm>

Change it to this:

<asm> Sonic_Jump: move.b (Ctrl_1_Press_Logical).w,d0 andi.b #$70,d0 ; is A, B or C pressed? beq.w return_1AAE6 ; if not, return moveq #0,d0 move.b angle(a0),d0 addi.b #$80,d0 bsr.w CalcRoomOverHead cmpi.w #6,d1 ; does Sonic have enough room to jump? blt.w return_1AAE6 ; if not, branch move.w #$680,d2 ;*** tst.b (Super_Sonic_flag).w ;*** beq.s + ;*** move.w #$800,d2 ; set higher jump speed if super + btst #6,status(a0) ; Test if underwater beq.s + move.w #$380,d2 ; set lower jump speed if under + btst #3,status_secondary(a0);**test if high jump monitor was hit beq.s + ;** move.w #$1000,d2 ;sethigher jump speed if hit + moveq #0,d0 move.b angle(a0),d0 subi.b #$40,d0 jsr (CalcSine).l muls.w d2,d1 asr.l #8,d1 add.w d1,x_vel(a0) ; make Sonic jump (in X... this adds nothing on level ground) muls.w d2,d0 asr.l #8,d0 add.w d0,y_vel(a0) ; make Sonic jump (in Y) bset #1,status(a0) bclr #5,status(a0) addq.l #4,sp move.b #1,jumping(a0) clr.b stick_to_convex(a0) move.w #$A0,d0 jsr (PlaySound).l ; play jumping sound move.b #$13,y_radius(a0) move.b #9,x_radius(a0) btst #2,status(a0) bne.s Sonic_RollJump move.b #$E,y_radius(a0) move.b #7,x_radius(a0) move.b #2,anim(a0) ; use "jumping" animation bset #2,status(a0) addq.w #5,y_pos(a0) </asm>

You have now created a hi-jump monitor! You can change the value at the "move.w" after the ** to any other value to set how high sonic will jump. For any problems, please PM me.