ASM to Sega Genesis Platform

All about assembly programming in the Sega Genesis console.


    How to make Sonic ''Float''

    Share
    avatar
    Green Snake

    Mensagens : 2094
    Data de inscrição : 2012-04-07
    Localização : I do not even know
    Current Project : nope

    How to make Sonic ''Float''

    Post  Green Snake on Sat Apr 07, 2012 1:53 pm

    Hello, This is guide how to make sonic ''float'' on air when up is pressed

    This is made to hivebrain 2005 dissassembly, so if you have another one, you may have trouble with this


    First, find Obj01_mdnormal
    you should see something like this:

    Code:

                    bsr.w   Sonic_Jump
          bsr.w   Sonic_SlopeResist
          bsr.w   Sonic_Move
          bsr.w   Sonic_Roll
          bsr.w   Sonic_LevelBound
          jsr   SpeedToPos
          bsr.w   Sonic_AnglePos
          bsr.w   Sonic_SlopeRepel
          rts
                   

    this is your normal command line for md_normal.

    Add
    Code:
     bsr.w  Sonic_Float
    at end\start\where you want to put it

    now find obj01_mdjump2

    you should find this
    Code:

                    bsr.w   Sonic_JumpHeight
          bsr.w   Sonic_ChgJumpDir
          bsr.w   Sonic_LevelBound
          jsr   ObjectFall
          btst   #6,$22(a0)   ; is Sonic underwater?
          beq.s   loc_12EA6   ; if no, branch
          subi.w   #$28,$12(a0)

    loc_12EA6:
          bsr.w   Sonic_JumpAngle
          bsr.w   Sonic_Floor
          rts

    add this code before bsr.w Sonic_JumpHeight
    Code:

    bsr.w  Sonic_float

    find ; End of function Sonic_JumpHeight

    After it, add this:

    Code:

    ; ---------------------------------------------------------------------------
    ; Subroutine to Float Sonic by pressing A button
    ; ---------------------------------------------------------------------------

    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||

    Sonic_float:         ; XREF: Obj01_MdNormal
                btst    #iUp,(Joypad|Held).w   ; is A button held?
           beq.s  Float_rts       ; if not, branch
           cmpi.b   #2,$1C(a1)   ; is Sonic rolling?
              beq.s   float_rts   ; if not, branch
              move.w   $12(a0),d0   ; load Y-velocity
              move.w   #$0,$12(a0)   ; decrease Y-velocity
              addi.w   #$20,$12(a0)   ; decrease Y-velocity   
    Float_rts:
                    rts


    Now its ready, compile it, and tell me if there is some problems

    modify ''iUp'' to change button to press
    btst #iUp,(Joypad|Held).w ; is A button held?

    For sound, put this before float_rts:

    Code:

                    move.w   #$XX,d0         ; play Float sound
          jsr   (PlaySound_Special).l  ;

    Edit ''XX'' to what you want to get effect
    avatar
    Green Snake

    Mensagens : 2094
    Data de inscrição : 2012-04-07
    Localização : I do not even know
    Current Project : nope

    Re: How to make Sonic ''Float''

    Post  Green Snake on Sat Apr 07, 2012 11:13 pm

    Sorry, forgot to say:
    This guide makes your attitude decrease

    I will tell you why:
    Code:
    move.w  $12(a0),d0  ; load Y-velocity
    move.w  #$0,$12(a0)  ; decrease Y-velocity
    addi.w  #$20,$12(a0)  ; decrease Y-velocity

    These three lines loads sonics y-velocity, like you can see, then there is ''decrese'' after move.w command.
    It should be ''delete Y-velocity'' for being more precise. Next decrease means that it will make Sonic go down
    Like you see ''Addi.w'', it means add to Y-velocity, If I would put it like this:
    Code:
    addi.w  #-$20,$12(a0)  ; decrease Y-velocity
    Now Sonic would go up as long as button is held. If you don't want to Sonic go up\down, you can delete this line.
    Or you can modify it to other number.

    you may see these lines:
    Code:
    Subroutine to Float Sonic by pressing A button
    btst    #iUp,(Joypad|Held).w  ; is A button held?
    Sorry about them, Forgot to fix them...

      Current date/time is Tue Sep 26, 2017 6:53 am