Sonic and Sega Retro Message Board: Mercury pwns Yuji Naka - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Loading News Feed...
 

Mercury pwns Yuji Naka Trigonometry, bitches!

#1 User is offline Mercury 

Posted 14 August 2010 - 04:59 AM

  • His Name Is Sonic
  • Posts: 1597
  • Joined: 13-November 08
  • Gender:Not Telling
  • Location:Location Location
  • Project:AeStHete (Sonic Time Twisted engine)
  • Wiki edits:130
A lot of people hate the Sonic 1 Special Stages. Watching YouTube playthroughs, you'll hear them profaned quite often.

I'm pretty good at beating them, myself, but I still hate them. Because I'm scientifically minded, I tried to figure out just why this is so.

Then it hit me - Sonic doesn't have a variable jump height. Unlike when he's in the normal zones, you can't just let go of the jump button to mitigate his upward velocity.

Having noticed this, it struck me that it was most likely the largest contributor to the hate for the Special Stages. Because you don't have as much control over Sonic as you've become accustomed to from playing the normal zones, it's frustrating and unfair. Trying to navigate through cramped paths winds up being an exercise in hitting every bumper and and reverse block through no fault of you own - Sonic just makes a full jump no matter what you do.

Well, it was clear - I had to remedy this. I looked in the disassembly, and lo! - there was an unused routine for reducing Sonic's jump height in the Special Stages. Of course, merely reactivating the routine would be far too simple a fix - there had to be more than that. After all, if it worked, why would it be deprecated in the first place?

It turns out the unused routine is the same as the one from Sonic's normal code. It's deprecated because, in the Special Stages, Sonic's in a rotating maze, where up isn't always up. The routine is simply impotent at any angle other than 0.

Well, Yuji Naka might be lazy, but I'm not - so I wrote a new routine that actually does work, at any angle.

This is what I did, and if you follow the steps, you can, too. This is for the SVN disassembly:

First, open "_incObj\09 Sonic in Special Stage.asm" and find the label "Obj09_InAir". Replace this line:

Syntax Highlighted Code: ASM
 
bsr.w nullsub_2
 


with this one:

Syntax Highlighted Code: ASM
 
bsr.w Obj09_JumpHeight
 


Now, find the "nullsub_2" label. This is the deprecated routine, and we need to replace it with the new one I wrote, "Obj09_JumpHeight". So replace these lines:

Syntax Highlighted Code: ASM
 
nullsub_2: ; XREF: Obj09_InAir
rts
; End of function nullsub_2
 
; ===========================================================================
; ---------------------------------------------------------------------------
; unused subroutine to limit Sonic's upward vertical speed
; ---------------------------------------------------------------------------
move.w #-$400,d1
cmp.w obVelY(a0),d1
ble.s locret_1BBB4
move.b (v_jpadhold2).w,d0
andi.b #btnABC,d0
bne.s locret_1BBB4
move.w d1,obVelY(a0)
 
locret_1BBB4:
rts
 


with these:

Syntax Highlighted Code: ASM
 
; ---------------------------------------------------------------------------
; Subroutine to limit Sonic's upward vertical speed
; ---------------------------------------------------------------------------
 
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
 
 
Obj09_JumpHeight: ; XREF: Obj09_InAir
move.b (v_jpadhold2).w,d0 ; is the jump button up?
andi.b #btnABC,d0
bne.s locret_1BBB4 ; if not, branch to return
btst #7,obStatus(a0) ; did Sonic jump or is he just falling or hit by a bumper?
beq.s locret_1BBB4 ; if not, branch to return
move.b (v_ssangle).w,d0 ; get SS angle
andi.b #$FC,d0
neg.b d0
subi.b #$40,d0
jsr (CalcSine).l
move.w obVelY(a0),d2 ; get Y speed
muls.w d2,d0 ; multiply Y speed by sin
asr.l #8,d0 ; find the new Y speed
move.w obVelX(a0),d2 ; get X speed
muls.w d2,d1 ; multiply X speed by cos
asr.l #8,d1 ; find the new X speed
add.w d0,d1 ; combine the two speeds
cmpi.w #$400,d1 ; compare the combined speed with the jump release speed
ble.s locret_1BBB4 ; if it's less, branch to return
move.b (v_ssangle).w,d0
andi.b #$FC,d0
neg.b d0
subi.b #$40,d0
jsr (CalcSine).l
muls.w #$400,d1
asr.l #8,d1
move.w d1,obVelX(a0)
muls.w #$400,d0
asr.l #8,d0
move.w d0,obVelY(a0) ; set the speed to the jump release speed
bclr #7,obStatus(a0) ; clear "Sonic has jumped" flag
 
locret_1BBB4:
rts
 


Next, go to the "Obj09_OnWall" label, and add this line directly after it:

Syntax Highlighted Code: ASM
 
bclr #7,obStatus(a0) ; clear "Sonic has jumped" flag
 


Now, go to the "Obj09_Jump" label, and after this line:

Syntax Highlighted Code: ASM
 
bset #1,obStatus(a0)
 


add this one:

Syntax Highlighted Code: ASM
 
bset #7,obStatus(a0) ; set "Sonic has jumped" flag
 


Finally, go to the "Obj09_ChkBumper" label, and after this line:

Syntax Highlighted Code: ASM
 
bset #1,obStatus(a0)
 


add this one:

Syntax Highlighted Code: ASM
 
bclr #7,obStatus(a0) ; clear "Sonic has jumped" flag
 


Et voilà! Basically, what it does is it combines the X and Y speed using cos and sin to find how fast he's moving upward at the current angle. It compares this combined speed with the jump release speed ($400) and if it's greater, then it uses similar code to the normal jump to make Sonic move at $400 in the current angle. Simple.

When my friend (who's always been bad at the Sonic 1 Special Stages by her own admission, and hasn't played them in years) tested it out, she got the Chaos Emerald on her first try!

Yuji Naka has had to put up with a lot of shit in his time (not least of which the schoolyard bullies who taunted him in his youth for having a name that sounds for all the world like "huge knocker"), and now it's my turn to rub it in his face:

PWN, Yuji Naka!


The false bravado in this post is for humorous purposes only. I actually admire Yuji Naka a lot, and I'm sure he could improve my code greatly after but a brief glance at it.


So, let me know what you think of this, or if you find any bugs.

Here's the built rom with the fix applied.

#2 User is offline theocas 

Posted 14 August 2010 - 05:43 AM

  • Battery not included. Each set sold separately. Assembly required.
  • Posts: 343
  • Joined: 10-February 10
  • Gender:Male
  • Location:Austin, TX
  • Project:Mega CD PCM Sound Driver
  • Wiki edits:50
Wow, this is pretty nice! I tried it on 3 special stages and I got them all on my first try. Since I used the Hivebrain disasm, I just copied over the required Constants and Variables from the SVN disasm. I'm lazy.
And my special stages rotated way faster and the Up buttons are pure mayhem. Usually Sonic would just get stuck in mid-air, but this fixed it. Thanks for the fix!

#3 User is offline DalekSam 

Posted 14 August 2010 - 06:04 AM

  • woop woop yo ass too fat
  • Posts: 1752
  • Joined: 19-February 08
  • Gender:Male
  • Location:Northern Ireland, Belfast
  • Project:nothing
  • Wiki edits:165
Mercury for Super Tech Member, pl0x

This has made a stitch in my side no-more—I'm pretty sure some of the S1 special stage flack might dissapear now, if this was a commercial ROM. =P

#4 User is offline Namo 

Posted 14 August 2010 - 06:07 AM

  • take a screenshot of your heart
  • Posts: 2739
  • Joined: 02-August 09
  • Gender:Male
  • Project:dynamicite.org
Not bad work here. This certainly makes them more bearable. smile.png

#5 User is offline Dark Sonic 

Posted 14 August 2010 - 07:16 AM

  • Dark Blonic
  • Posts: 6336
  • Joined: 21-April 06
  • Gender:Male
  • Project:People really need to get their facts straight
  • Wiki edits:10
Not too shabby sir. Unfortunately I still hate the Sonic 1 special stages, but you at least made them easier... except that god damn 3rd stage D:

#6 User is offline Tweaker 

Posted 14 August 2010 - 07:31 AM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male
Interesting! I was always under the impression that the original behavior was intentional; it's pretty neat to know that there was code left over suggesting that it was supposed to work this way. Excellent find!

#7 User is offline FeliciaVal 

Posted 14 August 2010 - 11:25 AM

  • Posts: 689
  • Joined: 04-March 10
  • Gender:Female
  • Location:Spain
ooh thank you very much for this smile.png too bad I'm still using the Hivebrain dissassembly and I'm not sure how to make it work there

#8 User is offline FraGag 

Posted 14 August 2010 - 01:54 PM

  • Posts: 630
  • Joined: 09-January 08
  • Gender:Male
  • Location:Québec, Canada
  • Project:an assembler
  • Wiki edits:6
I just noticed it when trying to get all rings in the special stages in S1@SAGE 2010 (which I did :P) and it just amplified my frustration. Now I just have to remember to actually hold the jump button down to do a full-height jump. :P Nicely done!

#9 User is offline Mad Echidna 

Posted 14 August 2010 - 01:58 PM

  • Gone
  • Posts: 5203
  • Joined: 13-January 03
  • Gender:Male
  • Wiki edits:4
I propose this become a standard addition to all sonic hacks, as the 8 bit style egg prison has been :P

#10 User is offline MarkeyJester 

Posted 14 August 2010 - 02:57 PM

  • A word in your shell-like, pal
  • Posts: 1296
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
A very interesting find, nice research!

Of course, one thing I am still wondering is why Sonic moves directly up when jumping from slanted walls, not to say I want it more difficult, I just figured that Sonic's physics being very close to reality, that it would be considered or expected the jumping on a slant, will fource the character in the directional face of that slant.

#11 User is offline theocas 

Posted 14 August 2010 - 03:11 PM

  • Battery not included. Each set sold separately. Assembly required.
  • Posts: 343
  • Joined: 10-February 10
  • Gender:Male
  • Location:Austin, TX
  • Project:Mega CD PCM Sound Driver
  • Wiki edits:50
QUOTE (FeliciaVal @ Aug 14 2010, 09:25 AM)
ooh thank you very much for this smile.png too bad I'm still using the Hivebrain dissassembly and I'm not sure how to make it work there

I used the Hivebrain disasm too, so I just copied these equates over from the SVN disasm (Some of them might not be used at all, I know that, but I couldn't sort it all out atm because I used more of them. I just got rid of the obvious ones.):
Syntax Highlighted Code: ASM
 
obRender: equ 1 ; bitfield for x/y flip, display mode
obGfx: equ 2 ; palette line & VRAM setting (2 bytes)
obMap: equ 4 ; mappings address (4 bytes)
obX: equ 8 ; x-axis position (2-4 bytes)
obScreenY: equ $A ; y-axis position for screen-fixed items (2 bytes)
obY: equ $C ; y-axis position (2-4 bytes)
obVelX: equ $10 ; x-axis velocity (2 bytes)
obVelY: equ $12 ; y-axis velocity (2 bytes)
obInertia: equ $14 ; potential speed (2 bytes)
obHeight: equ $16 ; height/2
obWidth: equ $17 ; width/2
obPriority: equ $18 ; sprite stack priority -- 0 is front
obActWid: equ $19 ; action width
obFrame: equ $1A ; current frame displayed
obAniFrame: equ $1B ; current frame in animation script
obAnim: equ $1C ; current animation
obNextAni: equ $1D ; next animation
obTimeFrame: equ $1E ; time to next frame
obDelayAni: equ $1F ; time to delay animation
obColType: equ $20 ; collision response type
obColProp: equ $21 ; collision extra property
obStatus: equ $22 ; orientation or mode
obRespawnNo: equ $23 ; respawn list index number
obRoutine: equ $24 ; routine number
ob2ndRout: equ $25 ; secondary routine number
 
btnB: equ %00010000 ; B ($10)
btnR: equ %00001000 ; Right ($08)
btnL: equ %00000100 ; Left ($04)
btnDn: equ %00000010 ; Down ($02)
btnUp: equ %00000001 ; Up ($01)
btnDir: equ %00001111 ; Any direction ($0F)
btnABC: equ %01110000 ; A, B or C ($70)
bitStart: equ 7
bitA: equ 6
bitC: equ 5
bitB: equ 4
bitR: equ 3
bitL: equ 2
bitDn: equ 1
bitUp: equ 0
 
v_jpadhold2: = $FFFFF602 ; joypad input - held, duplicate
v_jpadpress2: = $FFFFF603 ; joypad input - pressed, duplicate
v_jpadhold1: = $FFFFF604 ; joypad input - held
v_jpadpress1: = $FFFFF605 ; joypad input - pressed
v_ssangle: = $FFFFF780 ; Special Stage angle (2 bytes)
v_ssrotate: = $FFFFF782 ; Special Stage rotation speed (2 bytes)

This post has been edited by theocas: 14 August 2010 - 03:20 PM

#12 User is offline Aquaslash 

Posted 15 August 2010 - 03:11 AM

  • Time to walk the dinosaur!
  • Posts: 2758
  • Joined: 17-November 04
  • Gender:Male
  • Location:Hampton, VA
  • Project:The S Factor: Sonia and Silver
  • Wiki edits:1,144
QUOTE (Mad Echidna @ Aug 14 2010, 02:58 PM)
I propose this become a standard addition to all sonic hacks, as the 8 bit style egg prison has been :P

Except the ones that cut out that special stage system altogether v.png

#13 User is offline Mercury 

Posted 15 August 2010 - 05:00 AM

  • His Name Is Sonic
  • Posts: 1597
  • Joined: 13-November 08
  • Gender:Not Telling
  • Location:Location Location
  • Project:AeStHete (Sonic Time Twisted engine)
  • Wiki edits:130
QUOTE (Mad Echidna @ Aug 14 2010, 07:58 PM)
I propose this become a standard addition to all sonic hacks, as the 8 bit style egg prison has been :P

What do you mean by the "8 bit style egg prison"? Forgive my ignorance.

#14 User is offline Black Squirrel 

Posted 15 August 2010 - 06:05 AM

  • 2 warps to Neptune
  • Posts: 1885
  • Joined: 27-December 03
  • Gender:Male
  • Location:Northumberland, England
  • Project:Blog Squirrel
  • Wiki edits:20,569
For the record the behaviour is the same in Sonic & Knuckles's bonus stage as it is in regular Sonic 1.

So this was never "fixed" officially.

#15 User is offline Azu 

Posted 15 August 2010 - 09:17 AM

  • I must be stupid.
  • Posts: 1315
  • Joined: 23-February 08
  • Gender:Male
  • Location:Home
See, why couldn't S1@SAGE2010 hack have this.

  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users