don't click here

Weird reaction when Sonic goes down slopes

Discussion in 'Engineering & Reverse Engineering' started by Dark Sonic, Oct 28, 2007.

Thread Status:
Not open for further replies.
  1. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    I'm trying to start hacking a little. I've made multiple hacking attempts this before (all failed), but I'm going to start out simple and build up, eventually making this into something creative. But I'm just starting with some basics. First thing I'm doing is adding Sonic 2 sprites to Sonic 1, since I prefer them over the Sonic 1 sprites.

    [​IMG]
    The problem right now involves Sonic and slopes and transitioning into running. While transitioning into running, about 1 out of every 10 times, he'll go into a rolling animation for 2 frames or so and then run normally.

    The second problem involves, like I said slopes. Sonic doesn't go down slopes well. I've managed to fix most sprite situations, but as that screen above suggests, something's not right. Sometimes a random sprite will pop up, like croching or rolling or ducking. At one point the game also froze sometimes, but I seem to have fixed the code enough so that doesn't happen.

    Also, the Sega Sound's kinda messed up. Any help there would be nice to
     
  2. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    The Static noise usually appears when you have added spindash. There is a fix for it : here
     
  3. Hayate

    Hayate

    Tech Member
    Uhh... here is the fix. Don't click Hitaxas' link, it has that fucking annoying Blinkx ad scheme on it.

    That's not really a good idea for a first thing to do. Porting Sonic sprites also means you have to port the mappings, animation states and DPLCs that go with them, and then you have to change the code that sets the animation states because each game has different indexes for this. This is exactly why you're getting the problem with weird sprites showing up, and I had the exact same problem for a while when I added Sonic 3 sprites to my hack.
     
  4. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    I have acctually ported the mappings and the DPLCs, and the animation states I've been editing so that they acctually work. Must not have worked completely though for like I said running on slopes is wierd. Thanks though.

    Where would the animation states be by the way and how would I go about changing them?
     
  5. Hayate

    Hayate

    Tech Member
    look in _anim/
     
  6. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    Oh those? Never mind then I know where they are for I've been editing them this whole time (Thought you were talking about something else). When I think about it probably not the best idea to start out with, but I wanted to do something creative. I did manage to successfully port the Sonic art from the Sonic 2 title screen though (Took forever for me to figure out how to make it look like Sonic wasn't repetively punching the logo =P)

    EDIT: Alright, I know when exactly the problem happens and I have an idea why, but I don't know what to do to fix it (I'll keep trying). Sonic's sprites only fuck up while transitioning from walking to running and when they do only certain sprites are put in place instead of the proper animation (rolling, ducking, spindashing, and pushing). These sprite animations are all very close by to the running sprites in the animation file. Something is messing up the first two to four sprites, but what?

    EDIT 2: To see for yourself what's wrong download the ROM here. I have to note though that the ROM is kinda buggy. This is only to show what's wrong, not a release of any kind. Don't go around saying "LOL the spindash sprite is a sideways Sonic running animation." Yes it is, and that will be fixed in time. Palettes kinda messed up too.
     
  7. StephenUK

    StephenUK

    Liquor in the front, poker in the rear Tech Member
    1,678
    0
    16
    Manchester, UK
    Quackshot Disassembly
    Sonic in S1 is hardcoded to use 6 walking frames in his main animation routine. Sonic in Sonic 2 is hardcoded to use 8 frames for walking. I'm guessing this is where your problem lies, as when I ported S1 sprites to S2, I had a similar problem.
     
  8. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    That's what I was thinking myself. Although why would it add frames at the beginning?
     
  9. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    Open up all S1 sonics in SonMapEd, then do the same for S2. Compare them and make the S2 the same as S1 counts. Example (and I mean example, I don't do S1):

    Change to:

    I hope you understand, I would throw pictures to help understand better, but at work at the moment.
     
  10. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    Hmm, matching the frames didn't seem to work.

    Here's the code I'm working with. Maybe someone can point out what I'm doing wrong (I know I'm not using those address things to address the frames, but using the number of the frame seems to work all the same... I think)

    Code (Text):
    1. SonAni_Walk:    dc.b $FF, 28, 29, 30, 31, 32, 33, 34, 35, $FF, 0
    2. SonAni_Run: dc.b $FF, 12, 13, 14, 15, $FF, 0
    3. SonAni_Roll:    dc.b $FE, 60, 61, 62, 63, 64,   $FF
    4. SonAni_Roll2:   dc.b $FE, 60, 61, 62, 63, 64, 62,   $FF
     
  11. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    In that case, make sure it's like this:

    Etc...
     
  12. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    Ya they do match up (The frames do). It's odd as problems usually only occur during the transition from walking to running and 8 out of 10 times it's some kind of rolling sprite.
     
  13. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    It's definately pointing to your mappings and cues etc? Was SonmapED set to Sonic1 game?

    Otherwise, I do not know.
     
  14. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    The issue is that angled sprites are called by adding the number of frames there are in the animation (in this case, six), to the current frame out of six that Sonic is currently on. The sprites are then lined up in such an order that adding six to each frame number would lead to the same frame of walking at another angle.

    Now, since Sonic 2 has 8 walking frames, compared to having 6 of them, you want to make sure the animation routine will add the correct amount of frames (8). Sonic_Animate is the routine you want to look at. Look at how the math works, and you'll figure out what you need to change.
     
  15. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    Ugh. I have been looking in there as you said. But I just have been trying to change everything and have come up with no luck whatsoever. I know you're right it's just that my knowledge of hacking is minimal. Sorry bout this guys but helps still needed D:

    I have a feeling that what must be changed is somewhere in here:
    Code (Text):
    1. SAnim_WalkRun:          ; XREF: SAnim_Do
    2.         subq.b  #1,$1E(a0); subtract 1 from frame   duration
    3.         bpl.s   SAnim_Delay; if time remains, branch
    4.         addq.b  #1,d0   ; is animation walking/running?
    5.         bne.w   SAnim_RollJump; if not, branch
    6.         moveq   #0,d1
    7.         move.b  $26(a0),d0; controls angle Sonic runs at
    8.         move.b  $22(a0),d2; controls direction Sonic can turn to
    9.         andi.b  #1,d2   ; is Sonic mirrored horizontally?
    10.         bne.s   loc_13A70; if yes, branch
    11.         not.b   d0  ; reverse angle
    Or perhaps here:
    Code (Text):
    1. Sonic_Animate:          ; XREF: Obj01_Control; et al
    2.         lea (SonicAniData).l,a1
    3.         moveq   #0,d0      
    4.         move.b  $1C(a0),d0
    5.         cmp.b   $1D(a0),d0; is animation set to restart?
    6.         beq.s   SAnim_Do; if not, branch
    7.         move.b  d0,$1D(a0); set to "no restart"
    8.         move.b  #0,$1B(a0); reset   animation
    9.         move.b  #0,$1E(a0); reset   frame duration
    10.  
    11. SAnim_Do:
    12.         add.w   d0,d0
    13.         adda.w  (a1,d0.w),a1; jump to appropriate animation script
    14.         move.b  (a1),d0
    15.         bmi.s   SAnim_WalkRun; if animation is walk/run/roll/jump, branch
    16.         move.b  $22(a0),d1
    17.         andi.b  #1,d1
    18.         andi.b  #$FC,1(a0)
    19.         or.b    d1,1(a0)
    20.         subq.b  #1,$1E(a0); subtract 1 from frame   duration
    21.         bpl.s   SAnim_Delay; if time remains, branch
    22.         move.b  d0,$1E(a0); load frame duration
    Correct me if I'm wrong
     
  16. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    I don't think so, but this little bit here "bne.s loc_13A70; if yes, branch", bne means branch if not equal. So, if Sonic is mirrored, it won't branch unless it was beq.s. It should either be (changes made in CAPS):

    Code (Text):
    1. SAnim_WalkRun:      ; XREF: SAnim_Do
    2.         andi.b  #1,d2; is Sonic mirrored horizontally?
    3.         BEQ.s   loc_13A70; if yes, branch
    or
    Code (Text):
    1. SAnim_WalkRun:      ; XREF: SAnim_Do
    2.         andi.b  #1,d2; is Sonic mirrored horizontally?
    3.         bne.s   loc_13A70; if NOT, branch
    I don't know what it should do as I don't hack Sonic one, just thought I'd point thaterror out =P
     
  17. Puto

    Puto

    Shin'ichi Kudō, detective. Tech Member
    2,013
    0
    16
    Portugal, Oeiras
    Part of Team Megamix, but haven't done any actual work in ages.
    Not really. When used with an "and", a bne actually branches if not zero, meaning in this case that it'll branch if the last bit of d0 is 1 (the mirror bit, I guess).
     
  18. Hayate

    Hayate

    Tech Member
    bne branches if zero is clear.
    After you change the destination register, zero will only be set if the destination register ends up at zero.

    So andi.b #1,d2 will set the zero flag if bit 0 of d2 is clear, and vice versa.
    Then, bne will branch if the zero flag is clear, I.e. if bit 0 of d2 is set.

    So, the original code was right.

    I'd personally use a btst, though, unless the wiping of the other bits was actually used later on, but I can't see a reason to do that...
     
  19. Dark Sonic

    Dark Sonic

    Member
    14,631
    1,611
    93
    Working on my art!
    Hmm, what is a btst and how would you go about using it? Would it help with my problem?
    Oh and RHS I tried your idea. What that did was it mirrored the proper angle on the slope. So when Sonic was, say going around a loop. it looked like he was running on his head.
     
  20. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    Brilliant, now make Tails do the same. =P
     
Thread Status:
Not open for further replies.