Jumpdash for Sonic 1
I removed the Jumpdash from SSRG a long time ago. However, now it's back. It was hosted on Sofia for a while
If you want to read the story, click me!
========Starts here=======
Before you start read this: This code was made by me (Selbi). Everyone may use it, modify it etc. However, you ARE FORCED credit me when using it.
Ok, you want the Jumpdash, but you have absolutly no ASM skils? No problem! Here I will give you my Jumpdash code, which has been updated a lot since the first release. Please don't argue about "hacks will get boring", because I'm pissed off with such stuff. However, here it is:
1. Open your sonic1.asm and go to Obj01_MdJump2:. This is the Routine for Sonic's move methods when he is in the Air. Because we want to branch to our (not yet existing) Jumpdash code, add this line after the label:
bsr.w Sonic_JumpDash
2. Next go to Sonic_Roll:. After this Routine we have to place the Jumpdash code (don't ask why, just do it). I know it's just copy/paste, but most of you would rip off the code anyway, so I don't need a step-by-step guide only (scroll down a bit for a better explained split of that code).
The Jumpdash code was 3 times rewritten and millions of times overwritten. But if you still find something, you think I can do better (code, comments etc.) please mention it here!
Here it is:
; ---------------------------------------------------------------------------
; Subroutine to perform a Jumpdash
; ---------------------------------------------------------------------------
Sonic_JumpDash:
move.b ($FFFFF603).w,d0 ; is ABC pressed? (part 1)
andi.b #$70,d0 ; is ABC pressed? (part 2)
beq.w JD_End ; if not, branch
tst.b ($FFFFFFEB).w ; was jumpdash flag set?
bne.w JD_End ; if yes, branch
move.b #1,($FFFFFFEB).w ; if not, set jumpdash flag
move.b #$BC,d0 ; set jumpdash sound
jsr (PlaySound_Special).l ; play jumpdash sound
bclr #4,$22(a0) ; clear double jump flag
move.w #$A00,d0 ; set normal jumpdash speed
tst.b ($FFFFFE2E).w ; do you have speed shoes?
beq.s JD_ChkUW ; if not, branch
move.w #$B00,d0 ; set speed shoes jumpdash speed
JD_ChkUW:
btst #6,$22(a0) ; is Sonic underwater?
beq.s JD_ChkDirection ; if not, branch
move.w #$600,d0 ; set underwater jumpdash speed
JD_ChkDirection:
btst #0,$22(a0) ; is sonic facing left?
beq.s JD_Move ; if yes, branch
neg.w d0 ; if not, negate d0 (for jumping to the right)
JD_Move:
move.w d0,$10(a0) ; move Sonic forward with the selected speed ($10(a0) = Sonic's X-velocity)
clr.w $12(a0) ; clear Sonic's Y-velocity to move sonic directly down
JD_End:
rts ; return
; End of function Sonic_JumpDash
And here with explaination for every single code block:
; ---------------------------------------------------------------------------
; Subroutine to perform a Jumpdash
; ---------------------------------------------------------------------------
Sonic_JumpDash:
move.b ($FFFFF603).w,d0 ; is ABC pressed? (part 1)
andi.b #$70,d0 ; is ABC pressed? (part 2)
beq.w JD_End ; if not, branch
tst.b ($FFFFFFEB).w ; was jumpdash flag set?
bne.s JD_End ; if yes, branch
move.b #1,($FFFFFFEB).w ; if not, set jumpdash flag
move.w #$BC,d0 ; set jumpdash sound
jsr (PlaySound_Special).l ; play jumpdash sound
bclr #4,$22(a0) ; clear double jump flag
move.w #$A00,d0 ; set normal jumpdash speed
tst.b ($FFFFFE2E).w ; do you have speed shoes?
beq.s JD_ChkUW ; if not, branch
move.w #$B00,d0 ; set speed shoes jumpdash speed
JD_ChkUW:
btst #6,$22(a0) ; is Sonic underwater?
beq.s JD_ChkDirection ; if not, branch
move.w #$600,d0 ; set underwater jumpdash speed
JD_ChkDirection:
btst #0,$22(a0) ; is sonic facing left?
beq.s JD_Move ; if yes, branch
neg.w d0 ; if not, negate d0 (for jumping to the right)
JD_Move:
move.w d0,$10(a0) ; move sonic forward (X-velocity)
clr.w $12(a0) ; clear Y-velocity to move sonic directly down
JD_End:
rts ; return
; End of function Sonic_JumpDash
3. Ok, if you looked at the code, you've maybe sawn this flag $FFFFFFEB. To create a clearing code, we need to go to the routine Sonic_ResetOnFloor:L. This is the code when Sonic touches the ground again. Add this right after the label:
clr.b ($FFFFFFEB).w ; clear jumpdash flag
4. Step 4 is not necesary but very highly recomended: Remove the Speedcap. Just trust me. You will see why if you compare the Jumpdash with and without Speedcap.
Ok, now you should have a Jumpdash. It works fine, but it's a little bit lame. So you should add:
Some Extra features
We know, your current Jumpdash is very lame. So how about adding some extras? Here is the code for those things:
Stop Sonic, up bouncing and Jumpdashing again after destroying an enemy or a monitor.
1. Interested? Ok, then open your sonic1.asm. We need to branch to a specific code if you destroyed a monitor with the Jumpdash. So go to loc_1AF1E: and before locret_1AF2E: add this:
tst.b ($FFFFFFEB).w ; was the monitor destroyed with a jumpdash?
bne.w BounceJD ; if yes, branch
2. Now we have to do the same for Enemies. Go to loc_1AF9C: and replace it with this:
loc_1AF9C:
jsr AddPoints
move.b #$27,0(a1) ; change object to points
move.b #0,$24(a1)
tst.b ($FFFFFFEB).w ; was the enemy destroyed with a jumpdash?
bne.s JSR_BounceJD ; if yes, branch
bra.s loc_1AF9C_cont ; if not, skip
JSR_BounceJD:
jsr BounceJD ; jump to BounceJD
loc_1AF9C_cont:
tst.w $12(a0)
bmi.s loc_1AFC2
move.w $C(a0),d0
cmp.w $C(a1),d0
bcc.s loc_1AFCA
neg.w $12(a0)
rts
3. And now we need to add this BounceJD: Routine (yes, it's of course not in the ASM yet). Go to loc_1AFDA: and add this Routine before it:
; -------------------------------------------------------------------------
; Subroutine to stop Sonic, bounce him up and to give him the ability to
; Jumpdash again when he has performed a Jumpdash
; -------------------------------------------------------------------------
BounceJD:
tst.b ($FFFFFFEB).w ; was jumpdash flag set?
beq.s BounceJD_End ; if not, branch
clr.b ($FFFFFFEB).w ; if yes, clear jumpdash flag (allow Sonic to jumpdash again)
clr.w $10(a0) ; clear X-velocity (stop sonic)
move.w #-$5F0,$12(a0) ; use -$5F0 for Y-velocity (move sonic upwards)
btst #6,$22(a0) ; is sonic underwater?
beq.s BounceJD_Shoes ; if not, branch
move.w #-$320,$12(a0) ; use only -$320 for Y-velocity (move sonic upwards)
BounceJD_Shoes:
tst.b ($FFFFFE2E).w ; does sonic has speed shoes?
beq.s BounceJD_End ; if not, branch
move.w #-$620,$12(a0) ; use -$620 for Y-velocity (move sonic upwards)
BounceJD_End:
rts ; return
; End of function BounceJD
And here with descriptions (even though it's nearly working the same as the main code):
; -------------------------------------------------------------------------
; Subroutine to stop Sonic, bounce him up and to give him the ability to
; Jumpdash again when he has performed a Jumpdash
; -------------------------------------------------------------------------
BounceJD:
tst.b ($FFFFFFEB).w ; was jumpdash flag set?
beq.s BounceJD_End ; if not, branch
clr.b ($FFFFFFEB).w ; if yes, clear jumpdash flag (allow Sonic to jumpdash again)
clr.w $10(a0) ; clear X-velocity (stop sonic)
move.w #-$5F0,$12(a0) ; use -$5F0 for Y-velocity (move sonic upwards)
btst #6,$22(a0) ; is sonic underwater?
beq.s BounceJD_Shoes ; if not, branch
move.w #-$320,$12(a0) ; use only -$320 for Y-velocity (move sonic upwards)
BounceJD_Shoes:
tst.b ($FFFFFE2E).w ; does sonic has speed shoes?
beq.s BounceJD_End ; if not, branch
move.w #-$620,$12(a0) ; use -$620 for Y-velocity (move sonic upwards)
BounceJD_End:
rts ; return
; End of function BounceJD
After doing this, you should have a perfect Jumpdash.
Give credits!
Credits:
Me (Selbi) for everything (Guide, Code)
Note:
The code also works for Sonic 2! However, you will have to modify it a bit at first. But it won't be be so hard though, I guess you can do that. =P (And if not, PM me)
Version: v3.3 (Third rewritten Version of the original guide/code - Added the descriptions for the main code and the extra code - Did some epic fixcrap after 4 months - Overwritten since the release of v3.0: 4 times)
Last update: 5th March 2010
Edited by Selbi, 05 March 2010 - 09:56 PM.



This topic is locked








