Welcome Guest ( Log In | Register ) Rules · Search

5 Pages V   1 2 3 > »   
Reply to this topicStart new topic
Sonic 1 Jumpdash
The most used Jumpdash on the Internet
Selbi
post Sunday 22nd March 2009, 7:48 pm
Post #1


Keep on rockin'

* * * * * * * 

Group: Projects Supervisor
Posts: 1,152
Joined: 20th July 2008
From: Lueneburg, Germany
Member No.: 469
Points: 45




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. wink.gif


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

This post has been edited by Selbi: Friday 5th March 2010, 9:56 pm


--------------------
This post may contain Bad Grammar. That's because I'm not very well at english. I'm apologizing if you don't understand me.
And for fucks sake, don't copy this message into your signature!



SSRG IRC Status:
Go to the top of the page
 
+Quote Post
DalekSam
post Sunday 22nd March 2009, 8:29 pm
Post #2


Gee, this pose makes me look ol' school...

* * * * 

Group: Member
Posts: 423
Joined: 24th February 2008
From: Belfast
Member No.: 317
Points: 10




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


--------------------
Go to the top of the page
 
+Quote Post
SonicVaan
post Sunday 22nd March 2009, 9:09 pm
Post #3


* * * * 

Group: Member
Posts: 347
Joined: 12th September 2008
From: Germany, Cologne
Member No.: 542
Points: 2




QUOTE (DalekSam @ Sunday 22nd March 2009, 9:29 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.


--------------------
MarkeyJester and Selbi are awesome. Spread the word.


Go to the top of the page
 
+Quote Post
CarrascoZX0
post Sunday 22nd March 2009, 9:15 pm
Post #4


"Which Groove, Do You Like?"

* * * * 

Group: Member
Posts: 305
Joined: 13th December 2008
From: Winnetka, California
Member No.: 598
Points: 1




QUOTE (SonicVaan @ Sunday 22nd March 2009, 2:09 pm) *
QUOTE (DalekSam @ Sunday 22nd March 2009, 9:29 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.

My thought exactly... sad.gif
Go to the top of the page
 
+Quote Post
shadowbeasts
post Sunday 22nd March 2009, 10:41 pm
Post #5


I'm Legend

* * * * 

Group: Member
Posts: 286
Joined: 5th January 2009
From: Good 'ol USA.
Member No.: 620




QUOTE (CarrascoZX0 @ Sunday 22nd March 2009, 5:15 pm) *
QUOTE (SonicVaan @ Sunday 22nd March 2009, 2:09 pm) *
QUOTE (DalekSam @ Sunday 22nd March 2009, 9:29 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.

My thought exactly... sad.gif

I'm so glad someone finally put this up.


--------------------

You can send me a friend request at any time.
Go to the top of the page
 
+Quote Post
shadowbeasts
post Monday 23rd March 2009, 12:36 am
Post #6


I'm Legend

* * * * 

Group: Member
Posts: 286
Joined: 5th January 2009
From: Good 'ol USA.
Member No.: 620




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


--------------------

You can send me a friend request at any time.
Go to the top of the page
 
+Quote Post
Hanoch
post Monday 23rd March 2009, 3:24 pm
Post #7
* * * * 

Group: Member
Posts: 263
Joined: 3rd August 2008
From: Israel
Member No.: 488
Points: 5




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


--------------------

Click on the image to get to the True Sonic 4 Topic.
Go to the top of the page
 
+Quote Post
hitaxas
post Monday 23rd March 2009, 3:56 pm
Post #8


I can has super speed?

* * * 

Group: Member
Posts: 103
Joined: 13th August 2007
Member No.: 60
Points: 2




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


--------------------

If you're awesome, click this image
to the Hitaxas really needs a car fund...please?
Go to the top of the page
 
+Quote Post
Hanoch
post Monday 23rd March 2009, 4:07 pm
Post #9
* * * * 

Group: Member
Posts: 263
Joined: 3rd August 2008
From: Israel
Member No.: 488
Points: 5




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.


--------------------

Click on the image to get to the True Sonic 4 Topic.
Go to the top of the page
 
+Quote Post
hitaxas
post Monday 23rd March 2009, 4:32 pm
Post #10


I can has super speed?

* * * 

Group: Member
Posts: 103
Joined: 13th August 2007
Member No.: 60
Points: 2




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.

This post has been edited by hitaxas: Saturday 28th March 2009, 7:15 pm


--------------------

If you're awesome, click this image
to the Hitaxas really needs a car fund...please?
Go to the top of the page
 
+Quote Post
Selbi
post Monday 23rd March 2009, 6:27 pm
Post #11


Keep on rockin'

* * * * * * * 

Group: Projects Supervisor
Posts: 1,152
Joined: 20th July 2008
From: Lueneburg, Germany
Member No.: 469
Points: 45




To all of you, read the Title! sleep.gif 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.

This post has been edited by Selbi: Monday 23rd March 2009, 8:57 pm


--------------------
This post may contain Bad Grammar. That's because I'm not very well at english. I'm apologizing if you don't understand me.
And for fucks sake, don't copy this message into your signature!



SSRG IRC Status:
Go to the top of the page
 
+Quote Post
DalekSam
post Monday 23rd March 2009, 7:15 pm
Post #12


Gee, this pose makes me look ol' school...

* * * * 

Group: Member
Posts: 423
Joined: 24th February 2008
From: Belfast
Member No.: 317
Points: 10




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)


--------------------
Go to the top of the page
 
+Quote Post
Selbi
post Monday 23rd March 2009, 9:00 pm
Post #13


Keep on rockin'

* * * * * * * 

Group: Projects Supervisor
Posts: 1,152
Joined: 20th July 2008
From: Lueneburg, Germany
Member No.: 469
Points: 45




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


--------------------
This post may contain Bad Grammar. That's because I'm not very well at english. I'm apologizing if you don't understand me.
And for fucks sake, don't copy this message into your signature!



SSRG IRC Status:
Go to the top of the page
 
+Quote Post
Tweaker
post Monday 23rd March 2009, 11:04 pm
Post #14


A thrilling mystery!

* * * * 

Group: Member
Posts: 335
Joined: 10th August 2007
From: Pinellas Park, FL
Member No.: 27




QUOTE (Selbi @ Monday 23rd March 2009, 2:27 pm) *
To all of you, read the Title! sleep.gif 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?


--------------------
Go to the top of the page
 
+Quote Post
Entia
post Tuesday 24th March 2009, 1:00 am
Post #15


FUCK

* 

Group: Member
Posts: 33
Joined: 10th August 2007
Member No.: 29




QUOTE (Tweaker @ Monday 23rd March 2009, 6:04 pm) *
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.
Go to the top of the page
 
+Quote Post
hitaxas
post Tuesday 24th March 2009, 1:38 am
Post #16


I can has super speed?

* * * 

Group: Member
Posts: 103
Joined: 13th August 2007
Member No.: 60
Points: 2




QUOTE (Selbi @ Monday 23rd March 2009, 5:00 pm) *
@hitaxas: Do you mind it when I use your underwater code in my Jumpdash (this guide)?


Sure, whatever.


--------------------

If you're awesome, click this image
to the Hitaxas really needs a car fund...please?
Go to the top of the page
 
+Quote Post
Selbi
post Tuesday 24th March 2009, 2:47 pm
Post #17


Keep on rockin'

* * * * * * * 

Group: Projects Supervisor
Posts: 1,152
Joined: 20th July 2008
From: Lueneburg, Germany
Member No.: 469
Points: 45




QUOTE (Tweaker @ Tuesday 24th March 2009, 12:04 am) *
QUOTE (Selbi @ Monday 23rd March 2009, 2:27 pm) *
To all of you, read the Title! sleep.gif 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

QUOTE (hitaxas @ Tuesday 24th March 2009, 2:38 am) *
QUOTE (Selbi @ Monday 23rd March 2009, 5:00 pm) *
@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.

This post has been edited by Selbi: Tuesday 24th March 2009, 3:51 pm


--------------------
This post may contain Bad Grammar. That's because I'm not very well at english. I'm apologizing if you don't understand me.
And for fucks sake, don't copy this message into your signature!



SSRG IRC Status:
Go to the top of the page
 
+Quote Post
Selbi
post Tuesday 24th March 2009, 8:16 pm
Post #18


Keep on rockin'

* * * * * * * 

Group: Projects Supervisor
Posts: 1,152
Joined: 20th July 2008
From: Lueneburg, Germany
Member No.: 469
Points: 45




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


--------------------
This post may contain Bad Grammar. That's because I'm not very well at english. I'm apologizing if you don't understand me.
And for fucks sake, don't copy this message into your signature!



SSRG IRC Status:
Go to the top of the page
 
+Quote Post

5 Pages V   1 2 3 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 3rd September 2010 - 4:58 am