Help with Animation limit in S1

Discussion in 'Discussion and Q&A Archive' started by IWasAPerson, Jun 4, 2010.

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

    IWasAPerson Part Of This Complete Breakfast Member

    Joined:
    Aug 18, 2008
    Messages:
    22
    Hey guys, got a bit of a problem with my Sonic 1 hack.


    So far everything's worked out fine for me, including ASM, music, adding Shadow as a character, and level art. But, I recently ported Knuckles and am fixing his animations. Only problem is, any sprite above sprite $80 for Knuckles doesn't work. It just freezes on the last loaded sprite until the animation's done and then it snaps back to normal when a sprite below sprite $80 is loaded in Knuckles' animation queue.


    IIRC there was an anim limit in S1 of $80 that was taken out in Sonic 2 and 3 (correct me if I'm wrong on that). I've looked around for anything that would look like a sprite anim cap and have compared routines between sonic 1 and 2, but I haven't found anything. Do any of you know how to fix this problem?


    And btw, for the most part I am familiar with programming ASM, I know how to work animation scripts, and I've already successfully added Shadow to my hack so I don't think there's a porting problem. I'm just at a loss here :p . And if you need a video, just ask (slow dialup is slow)
     
  2. MAXXX309

    MAXXX309 Newcomer Exiled

    Joined:
    Mar 4, 2010
    Messages:
    19
    Location:
    Ukraine, Kiev
    Just replace SAnim_Do2: with this:



    Code:
    SAnim_Do2:
    
    				moveq   #0,d1
    
    				move.b  $1B(a0),d1;  load current frame number
    
    				move.b  1(a1,d1.w),d0;  read sprite number from script
    
    			  &#59;bmi.s	SAnim_End_FF;  if animation is complete, branch
    
    				cmpi.b  #$F0,d0			   &#59;++
    
    				bcc.s	SAnim_End_FF   &#59;++if animation is complete, branch
     
  3. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    The problem with sprites above $80 is not in animation routines, it's in BuildSprites routine, where the sprites are displayed. So that's not an animation limit, but mapping frames limit.


    Go to loc_D700 and you'll see:



    loc_D700:
    movea.l 4(a0),a1 ; load mappings addr


    moveq #0,d1


    btst #5,d4


    bne.s loc_D71C


    move.b $1A(a0),d1 ; get mapping frame number


    add.b d1,d1 ; double it


    adda.w (a1,d1.w),a1 ; load mappings of this frame


    move.b (a1)+,d1 ; get mapping rows count


    subq.b #1,d1


    bmi.s loc_D720



    Mapping frame number is doubled there, but byte type is used, so if d1 is $80 and more, there will be overflow and incorrect frame will be displayed. In later Sonic games this was fixed by using word instead of byte.


    So just replace that subroutine with this:



    loc_D700:
    movea.l 4(a0),a1 ; load mappings addr


    moveq #0,d1


    btst #5,d4


    bne.s loc_D71C


    move.b $1A(a0),d1 ; get mapping frame number


    add.w d1,d1 ; double it


    adda.w (a1,d1.w),a1 ; load mappings of this frame


    moveq #0,d1


    move.b (a1)+,d1 ; get mapping rows count


    subq.b #1,d1


    bmi.s loc_D720



    But if you're porting Knuckles there will be another problem, in this time with animations. To fix it do what MAXXX309 said.
     
  4. IWasAPerson

    IWasAPerson Part Of This Complete Breakfast Member

    Joined:
    Aug 18, 2008
    Messages:
    22
    Thanks, guys. The fixes worked perfectly, can't believe I didn't see it before :D . That explains why I was looking at animation routines and not finding anything...


    Thanks again, really appreciate it!
     
Thread Status:
Not open for further replies.