Assembly Error Help

Discussion in 'Discussion and Q&A Archive' started by Ashuro, May 28, 2016.

Thread Status:
Not open for further replies.
  1. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hi, i want to import the speed booster code of Sonic 2 (xeno 2007) to implement it in my s1 hack. (hivebrain 2005).

    Here is the code:

    ; ===========================================================================
    ; ----------------------------------------------------------------------------
    ; Object 8E - Speed booster
    ; ----------------------------------------------------------------------------
    Obj8E:
    moveq #0,d0
    move.b routine(a0),d0
    move.w Obj8E_Index(pc,d0.w),d1
    jmp Obj8E_Index(pc,d1.w)
    ; ===========================================================================
    Obj8E_Index:
    dc.w Obj8E_Init-Obj8E_Index; 0
    dc.w Obj8E_Main-Obj8E_Index; 2
    ; ---------------------------------------------------------------------------
    Obj8E_BoosterSpeeds:
    dc.w $1000
    dc.w $A00
    ; ===========================================================================
    Obj8E_Init:
    addq.b #2,routine(a0) ; => Obj8E_Main
    move.l #Obj8E_MapUnc_223E2,mappings(a0)
    move.w #$E39C,art_tile(a0)
    bsr.w JmpTo16_Adjust2PArtPointer
    ori.b #4,render_flags(a0)
    move.b #$20,width_pixels(a0)
    move.b #1,priority(a0)
    move.b subtype(a0),d0
    andi.w #2,d0
    move.w Obj8E_BoosterSpeeds(pc,d0.w),objoff_30(a0)

    Obj8E_Main:
    move.b ($FFFFFE05).w,d0
    andi.b #2,d0
    move.b d0,mapping_frame(a0)
    move.w x_pos(a0),d0
    move.w d0,d1
    subi.w #$10,d0
    addi.w #$10,d1
    move.w y_pos(a0),d2
    move.w d2,d3
    subi.w #$10,d2
    addi.w #$10,d3

    lea (MainCharacter).w,a1 ; a1=character
    btst #1,status(a1)
    bne.s +
    move.w x_pos(a1),d4
    cmp.w d0,d4
    bcs.w +
    cmp.w d1,d4
    bcc.w +
    move.w y_pos(a1),d4
    cmp.w d2,d4
    bcs.w +
    cmp.w d3,d4
    bcc.w +
    move.w d0,-(sp)
    bsr.w Obj8E_GiveBoost
    move.w (sp)+,d0
    +
    lea (Sidekick).w,a1 ; a1=character
    btst #1,status(a1)
    bne.s +
    move.w x_pos(a1),d4
    cmp.w d0,d4
    bcs.w +
    cmp.w d1,d4
    bcc.w +
    move.w y_pos(a1),d4
    cmp.w d2,d4
    bcs.w +
    cmp.w d3,d4
    bcc.w +
    bsr.w Obj8E_GiveBoost
    +
    bra.w JmpTo6_MarkObjGone

    ; ===========================================================================
    Obj8E_GiveBoost:
    move.w x_vel(a1),d0
    btst #0,status(a0)
    beq.s +
    neg.w d0 ; d0 = absolute value of character's x velocity
    +
    cmpi.w #$1000,d0 ; is the character already going super fast?
    bge.s Obj8E_GiveBoost_Done ; if yes, branch to not change the speed
    move.w objoff_30(a0),x_vel(a1) ; make the character go super fast
    bclr #0,status(a1) ; turn him right
    btst #0,status(a0) ; was that the correct direction?
    beq.s + ; if yes, branch
    bset #0,status(a1) ; turn him left
    neg.w x_vel(a1) ; make the boosting direction left
    +
    move.w #$F,move_lock(a1) ; don't let him turn around for a few frames
    move.w x_vel(a1),inertia(a1) ; update his inertia value
    bclr #5,status(a0)
    bclr #6,status(a0)
    bclr #5,status(a1)

    Obj8E_GiveBoost_Done:
    move.w #$BC,d0 ; speed booster
    jmp (PlaySound).l
    ------------------------------------------------------------------------------------------------------

    How can i proceed? I get billions of errors when built it.
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    List what the errors are, and we'll take a look.

    If you've found the solution, please state what it was that you did, so that others who have a similar problem and come across this thread, can work it out too.
     
    Last edited: May 28, 2016
  3. ProjectFM

    ProjectFM Optimistic and self-dependent Member

    Joined:
    Oct 4, 2014
    Messages:
    912
    Location:
    Orono, Maine
    Because the object ID is past $7F and you're using Sonic 1, you won't be able to place it in your levels (with out adding code to place it) because bit 7 of the object type values in the object placement list is used for determining if the object's state is saved. If you want to be able to use it, you need to set the ID to a lower value or change the object placement code to work like Sonic 2.
     
  4. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    You may even have an easier time looking at the spring code of Sonic 1, basing it off of that and just making it so that it isn't solid which shouldn't be too difficult.
     
  5. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    Copying and pasting is never going to work. SST constants, subroutines like Adjust2PArtPointer, hardcoded RAM addresses, heck, there's even code for Tails in there. There'd be too many errors to count. You really would be better off writing your own object or just modifying an existing S1 one.
     
    Last edited: May 28, 2016
  6. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    The solutionis that i've found a comment in the Basic Answer thread write by ProjectFM who make the same method (Obj04 instead of 8E) and he wrote that his code work, so i've made the same solution like him but problem: the object is invisible and nothing happen.
    This is what i ask to delete this thread...
    And i see so many hacks with speed booster implemented, so i won't put it in my hack...
     
Thread Status:
Not open for further replies.