ASM to Sega Genesis Platform

All about assembly programming in the Sega Genesis console.

    Homing Attack - Variant 4 - Intercept Theorem Method



    Mensagens : 46
    Data de inscrição : 2011-01-09
    Current Project : Sonic Open Source Project

    Homing Attack - Variant 4 - Intercept Theorem Method

    Post  OuricoDoido on Thu Feb 10, 2011 10:17 pm

    In this method we will use the Intercept theorem to execute the Homing Attack. For more information about the Intercept theorem visit:

    This method don't use CalcAngle and CalcSine, and the effect is exactly the same.

    If you want download the compiled ROM, download here:

    To apply this, you need first apply the Homing Attack in Sonic 1.
    And implement in your code the square root subroutine.

    In HA_Move, modify this:
          jsr      (CalcAngle).l   ; calculates the angle
          jsr      (CalcSine).l   ; calculates the sine and the cosine
          muls.w  #$C,d1         ; multiply cosine by $C
          move.w  d1,$10(a0)      ; move d1 to X-velocity
          muls.w  #$C,d0         ; multiply sine by $C
          move.w  d0,$12(a0)      ; move d0 to Y-velocity
    To this:
          move.w  d1,d0   ; copy x-distance to d0
          move.w  d2,d3   ; copy y-distance to d3
          muls.w  d0,d0   ; x-distance^2
          muls.w  d3,d3   ; y-distance^2
          add.l  d3,d0   ; x^2 + y^2 = H^2
          jsr   SquareRoot   ; square root of H^2

          ; 255 = Real Speed // 12 = Sonic's Speed Constant
          muls.w   #255*12,d1   ; X*delta
          muls.w   #255*12,d2   ; Y*delta

          ; divide to fix the problem of "speed by distance" (near = slow, far = fast)
          divs.w   d0,d1      ; X'/H
          divs.w   d0,d2      ; Y'/H

          ; the gravity can make changes (+5 or -5) in Real Speed
          move.w  d1,$10(a0)      ; move d1 to X-velocity
          move.w  d2,$12(a0)      ; move d0 to Y-velocity

    Mensagens : 1595
    Data de inscrição : 2013-11-26
    Localização : Antarctic Ocean
    Current Project : Finding a better way to spend free time

    Re: Homing Attack - Variant 4 - Intercept Theorem Method

    Post  Electroball_ on Sun Dec 22, 2013 9:11 pm

    omg stoelooeneoen content

      Current date/time is Wed Jun 28, 2017 3:00 pm