Jump to content

  •  

Photo

Sonic 1 Jumpdash


  • This topic is locked This topic is locked
84 replies to this topic

#1 Selbi

Selbi

    Obligatory new year's avatar remake.

  • Pro User
  • 1673 posts
  • Gender:Male
  • Location:Lüneburg, Germany

Posted 22 March 2009 - 07:48 PM

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 (and it's still hosted there though. LINK) EDIT: Due spambots not anymore.

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
; ---------------------------------------------------------------------------
This is just something to make this code nicer. It's comented out, so it wouldn't make any difference, if you don't write it.

Sonic_JumpDash:
This is the main Label. Without this, we couldn't use the 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
This code tests if you are pressing ABC. You don't need to know how this is actually checking (I don't know it as well). We don't need a check for being in the Air, since this is done with Obj01_MdJump2:.

		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
This is a very important part: Without this, you could make infinite Jumpdashes in the air.

		move.w	#$BC,d0			; set jumpdash sound
jsr (PlaySound_Special).l ; play jumpdash sound
This is just to play a sound. You can replace the $BC with another sound ID to play another sound.

		bclr	#4,$22(a0)		; clear double jump flag
This clears the double jump flag, which is set when you are pressing jump in the air (I guess). I haven't ever tested if it's necesary. Maybe it's just there for taking an extra line. =P

		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)
$10(a0) is the X-velocity. In this huge block of coding, we are setting the jumpdash speed. We could reduce this to 4 lines, but we also want a different speed for being underwater and for having speed shoes. This code also checks in which direction you are looking (this is important. Otherwise you could just jumpdash to one side).

		clr.w	$12(a0)			; clear Y-velocity to move sonic directly down
$12(a0) is the Y-velocity. While jumping upwards you set this velocity, but when you are jumpdashing, you are going directly down. Without this line you would still move a bit upwards if you perform a jumpdash.

JD_End:
rts ; return
; End of function Sonic_JumpDash
With an rts every code ends. There is nothing to say.


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
; -------------------------------------------------------------------------
Again, this is just there to make this routine nicer. You don't need to write it as well.

BounceJD:
Same as above. This is necesary.

		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)
This is necesary. Otherwise this could would be always activated when destroying an enemy or a monitor.

		clr.w	$10(a0)		; clear X-velocity (stop sonic)
This stops you from moving forward. Nothing else.

		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)
Here again, we could this to 1 line (the first one), but we also want a different Y-velocity when being underwater and when having Speed shoes.

BounceJD_End:
rts ; return
; End of function BounceJD
Word.


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.

  • 0

#2 DalekSam

DalekSam

    beyta as shit

  • Pro User
  • 658 posts
  • Gender:Male
  • Location:Belfast
  • Interests:being beyta and thrash metal

Posted 22 March 2009 - 08:29 PM

I must say, your ASM is improving. Keep it up!
  • 0

#3 SonicVaan

SonicVaan

    The probably one and only cybergoth in this community. '_

  • Pro User
  • 385 posts
  • Gender:Male
  • Location:Germany, Cologne
  • Interests:ASM, Betatesting, Synthesizers and music production

Posted 22 March 2009 - 09:09 PM

I must say, your ASM is improving. Keep it up!


But somehow it makes me sad. It'll get overrated and yeah, hacks get more boring. Posted Image
  • 0

#4 CarrascoZX0

CarrascoZX0

    "Okay!"

  • Pro User
  • 357 posts
  • Gender:Male

Posted 22 March 2009 - 09:15 PM

I must say, your ASM is improving. Keep it up!


But somehow it makes me sad. It'll get overrated and yeah, hacks get more boring. Posted Image

My thought exactly... :)
  • 0

#5 shadowbeasts

shadowbeasts

    I'm Legend

  • Member
  • 284 posts
  • Gender:Male
  • Location:Good 'ol USA.
  • Interests:Playing video games, Hanging with friends, Reading

Posted 22 March 2009 - 10:41 PM

I must say, your ASM is improving. Keep it up!


But somehow it makes me sad. It'll get overrated and yeah, hacks get more boring. Posted Image

My thought exactly... :)

I'm so glad someone finally put this up.
  • 0

#6 shadowbeasts

shadowbeasts

    I'm Legend

  • Member
  • 284 posts
  • Gender:Male
  • Location:Good 'ol USA.
  • Interests:Playing video games, Hanging with friends, Reading

Posted 23 March 2009 - 12:36 AM

Sorry for the double post but does this Jumpdash guide work with the Sonic 1 (Split and Text by Hivebrain) (ASM68K) disassembly?
  • 0

#7 Hanoch

Hanoch

    5 Chaos Emeralds

  • Pro User
  • 310 posts
  • Gender:Male
  • Location:Israel

Posted 23 March 2009 - 03:24 PM

There are no things like ASM68K/SNASM68K limitions. Every guide works for every compiler.
  • 0

#8 hitaxas

hitaxas

    I can has super speed?

  • Member
  • 131 posts
  • Gender:Male

Posted 23 March 2009 - 03:56 PM

This topic fails. With some digging, people would find I posted a superior code for jumpdash a week or so ago.
  • 0

#9 Hanoch

Hanoch

    5 Chaos Emeralds

  • Pro User
  • 310 posts
  • Gender:Male
  • Location:Israel

Posted 23 March 2009 - 04:07 PM

Actually, I think the best version is mine. It just tests for double jump flag ($21, using sst rather than spending a ram byte) and if there is 1 in it, it ends. Then it will check for pressing C if I am, go to jumpdash. And then testing for double jump flag in jumpdash code (again) and then setting the x velocity, clearing the y velocity setting the flag and playing the sound. Test for left/right facing and negate the x speed. Not that difficult and doesn't take as much space as this code does. Also, put the button and flag tests at locret_134C2.
  • 0

#10 hitaxas

hitaxas

    I can has super speed?

  • Member
  • 131 posts
  • Gender:Male

Posted 23 March 2009 - 04:32 PM

Sure, but mine checks for the underwater flag, and sets the jumpdash to be slower if you are underwater, thus being more accurate.

Edit: Removed, since the OP is making some step-by-step guide.

Edited by hitaxas, 28 March 2009 - 07:15 PM.

  • 0

#11 Selbi

Selbi

    Obligatory new year's avatar remake.

  • Pro User
  • 1673 posts
  • Gender:Male
  • Location:Lüneburg, Germany

Posted 23 March 2009 - 06:27 PM

To all of you, read the Title! :D It's a Simple Jumpdash, not the super killah Jumpdash, because posting this does make hacks really boring.

EDIT: @Hitaxas: You should remove the code.

Edited by Selbi, 23 March 2009 - 08:57 PM.

  • 0

#12 DalekSam

DalekSam

    beyta as shit

  • Pro User
  • 658 posts
  • Gender:Male
  • Location:Belfast
  • Interests:being beyta and thrash metal

Posted 23 March 2009 - 07:15 PM

He also has that over at RH, and there's no problem at all.

Shadowbeasts: Acknolege temporary symbols like + and @cont can only be used in ASM68k and incbin, and even are illegal commands in AS. Instead, use binclude and align 2 (Yes I do use the AS version thank you)
  • 0

#13 Selbi

Selbi

    Obligatory new year's avatar remake.

  • Pro User
  • 1673 posts
  • Gender:Male
  • Location:Lüneburg, Germany

Posted 23 March 2009 - 09:00 PM

@hitaxas: Do you mind it when I use your underwater code in my Jumpdash (this guide)?
  • 0

#14 Tweaker

Tweaker

    5 Chaos Emeralds

  • Pro User
  • 310 posts
  • Gender:Male

Posted 23 March 2009 - 11:04 PM

To all of you, read the Title! :D It's a Simple Jumpdash, not the super killah Jumpdash, because posting this does make hacks really boring.

What? There's only one kind of jump dash--one that sends you in a direction at any given speed. How the hell can you make anything but a simple jump dash?
  • 0

#15 Entia

Entia

    FUCK

  • Member
  • 33 posts
  • Gender:Male
  • Interests:Little girls with cat ears throwing fire at each other.

Posted 24 March 2009 - 01:00 AM

What? There's only one kind of jump dash--one that sends you in a direction at any given speed. How the hell can you make anything but a simple jump dash?

Someone could make one that homes in on enemies too instead of just going forward- oh wait.
  • 0

#16 hitaxas

hitaxas

    I can has super speed?

  • Member
  • 131 posts
  • Gender:Male

Posted 24 March 2009 - 01:38 AM

@hitaxas: Do you mind it when I use your underwater code in my Jumpdash (this guide)?


Sure, whatever.
  • 0

#17 Selbi

Selbi

    Obligatory new year's avatar remake.

  • Pro User
  • 1673 posts
  • Gender:Male
  • Location:Lüneburg, Germany

Posted 24 March 2009 - 02:47 PM

To all of you, read the Title! :) It's a Simple Jumpdash, not the super killah Jumpdash, because posting this does make hacks really boring.

What? There's only one kind of jump dash--one that sends you in a direction at any given speed. How the hell can you make anything but a simple jump dash?

Partly agreed. But what I mean is, my Jumpdash has no lower speed in water, no special sounds, no homing... it's actually the oposite of Megamix' Jumpdash. =P

@hitaxas: Do you mind it when I use your underwater code in my Jumpdash (this guide)?


Sure, whatever.

Ok, done. The code is way longer now.

Edited by Selbi, 24 March 2009 - 03:51 PM.

  • 0

#18 Selbi

Selbi

    Obligatory new year's avatar remake.

  • Pro User
  • 1673 posts
  • Gender:Male
  • Location:Lüneburg, Germany

Posted 24 March 2009 - 08:16 PM

Sorry for double post, but I added a new feature: Bouncing up and jumpdashing again after destroying an enemy or a monitor.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users