Sonic Illegal instructions in a loop!

Discussion in 'Discussion and Q&A Archive' started by Ashuro, Oct 30, 2014.

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! (again)!

    I've a problem in my Sonic 1 hack, when Sonic goes to his 3rd run animation (peelout form) and take a loop, the game freezes!

    When Sonic take a loop in his walking and run animation, all works, but in his peelout form (eight feet), i take illegal instructions message error.

    I don't understand, i've imported all the sprites in SonMapEd and all work fine in _anim/Sonic.asm. 

    http://image.noelshack.com/fichiers/2014/44/1414712211-sans-titre.png

    I've forget something in Sonic1.asm?
     
  2. Alex

    Alex Active Member Member

    Joined:
    Jan 6, 2008
    Messages:
    28
    Hard to say without looking at Sonic's anim file.

    On looking at the screenshot you provided I'd suggest looking at Sonic's other walking / running frames in SonMapED, check how they are organised and ensure your peelout frames are organised in a similar fashion.

    http://i.imgur.com/gVf0dz0.png?1   <-- Sample from my project, for comparison purposes

     

    This isn't what's causing the illegal instruction, but is something you'll need to look into if you want the peelout frames to appear correctly (ie, in the right order) as Sonic moves up and down angled terrain.

    Do you think you could add the code from loc_13A78 through to SAnim_RollJump (assuming you're using Hivebrain's disassembly) to your opening post and do the same with Sonic's anim file so myself and other users could try to pinpoint the issue and try to explain why this error is occurring?

    I'm positive the problem will lie within one of those two areas, but that's based on my shorthand experience with this portion of Sonic's code.

    (not exactly fluent in ASM myself)
     
    Last edited by a moderator: Oct 31, 2014
  3. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Yeah!
    Thank you!

    This is the code and the _anim/Sonic.asm :

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

    loc_13A78:

    andi.b #$FC,1(a0)

    eor.b d1,d2

    or.b d2,1(a0)

    btst #5,$22(a0)

    bne.w SAnim_Push

    lsr.b #4,d0 ; divide angle by $10

    andi.b #6,d0 ; angle must be 0, 2, 4 or 6

    move.w $14(a0),d2 ; get Sonic's speed

    bpl.s loc_13A9C

    neg.w d2

     

    loc_13A9C:

    lea (SonAni_3rdRun).l,a1

    cmpi.w #$F00,d2 ; use 3rdRun animation

    bcc.s loc_13AB4 ; if yes, branch

    lea (SonAni_Boom).l,a1

    cmpi.w #$EAA,d2 ; use Boom animation

    bcc.s loc_13AB4 ; if yes, branch

    lea (SonAni_Run).l,a1 ; use running animation

    cmpi.w #$800,d2 ; is Sonic at running speed?

    bcc.s loc_13AB4 ; if yes, branch

    lea (SonAni_Walk).l,a1 ; use walking animation

    bra.w loc_13AB4 ; branch

     

    loc_13AB4:

    add.b d0,d0

    move.b d0,d3

    neg.w d2

    addi.w #$800,d2

    bpl.s loc_13AC2

    moveq #0,d2

     

    loc_13AC2:

    lsr.w #8,d2

    move.b d2,$1E(a0) ; modify frame duration

    bsr.w SAnim_Do2

    add.b d3,$1A(a0) ; modify frame number

    rts
    ------------------------------------------------------------------


    http://image.noelshack.com/fichiers/2014/44/1414715191-sans-titre.png

    http://image.noelshack.com/fichiers/2014/44/1414715197-sans-titre2.png

    http://image.noelshack.com/fichiers/2014/44/1414715201-sans-titre3.png
     
  4. Alex

    Alex Active Member Member

    Joined:
    Jan 6, 2008
    Messages:
    28
    The only thing that sticks out to me immediately (for the sake of responding before I go to sleep) is that Sonic uses the SonAni_Boom animation before the peelout animation, which leads me to believe the issue is with SonAni_Boom and not SonAni_3rdRun.

    I'm assuming the SonAni_Boom is like a transition from the running frames to the 3rd running frames? Something that signifies Sonic is breaking the sound barrier or something along those lines? (Judging by the slight difference in speed required to trigger the 3rd running animation following the boom animation)

    Just out of interest... 

    Try replacing your loc_13A9C with the following snippet (or just simply comment out the three lines inducing the SonAni_Boom animation) and try running your game.


    loc_13A9C:
    lea (SonAni_3rdRun).l,a1
    cmpi.w #$F00,d2 ; use 3rdRun animation
    bcc.s loc_13AB4 ; if yes, branch
    ;lea (SonAni_Boom).l,a1
    ;cmpi.w #$EAA,d2 ; use Boom animation
    ;bcc.s loc_13AB4 ; if yes, branch
    lea (SonAni_Run).l,a1 ; use running animation
    cmpi.w #$800,d2 ; is Sonic at running speed?
    bcc.s loc_13AB4 ; if yes, branch
    lea (SonAni_Walk).l,a1 ; use walking animation
    bra.w loc_13AB4 ; branch

    If you still encounter the illegal instruction error after commenting those lines, then either I missed something (it is late) or the problem lies outside of the areas I'm more experienced in. 

    If however, this prevents the game from crashing, then I can only suggest the SonAni_Boom within your Sonic animation file isn't in line with what the game is expecting somehow; in which case try the following:

    Replace the following line in _anim/Sonic.asm


    SonAni_Boom: dc.b $FF, $74, $74, $75, $75, $76, $76, $77, $77, $FF

    With:


    SonAni_Boom: dc.b $FF, $74, $75, $76, $77, $FF, $FF, $FF

    Note that the above 'fix' is based on my loose assumption regarding the purpose of the SonAni_Boom animation.

    Hope this helps
     
    Last edited by a moderator: Oct 31, 2014
  5. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hi! 


    Yeah, this is it!


    I will try that and i will tell you if it's work or not!


    Thank you!!!!!
     
Thread Status:
Not open for further replies.