don't click here

Spindash questions

Discussion in 'Engineering & Reverse Engineering' started by Quickman, Dec 18, 2006.

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

    Quickman

    be attitude for gains Tech Member
    5,604
    19
    18
    :x
    omg porjcet
    So I drag'n'dropped the spindash code from the Nick Arcade Prototype (which, by the way, is unashamedly incomplete - there's a nop to indicate where further code was being implemented) and it worked straight off (all I did was comment it to make sure I understood what it was doing). However, I have some questions. First the code. (Feel free to use and abuse, since nothing here is actually mine.)

    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; Subroutine to allow Sonic to spindash
    3. ; ---------------------------------------------------------------------------
    4.  
    5. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    6.  
    7. Sonic_Spindash:
    8.         tst.b   $39(a0) ; are we charging a spindash?
    9.         bne.s   Sonic_Spindashing; if so, go to the spindash charge code
    10.         cmpi.b  #8,$1C(a0); are we using animation 8 (ducking)?
    11.         bne.s   Sonic_NoSpindash; if not, don't do anything
    12.         move.b  ($FFFFF603).w,d0; check currently held buttons
    13.         andi.b  #$70,d0 ; are A, B or C pressed?
    14.         beq.w   Sonic_NoSpindash; if not, don't do anything
    15.         move.b  #9,$1C(a0); start using animation 9 (spindash, actually warp 1)
    16.         move.w  #$BE,d0
    17.         jsr (PlaySound_Special).l; play sound BE (spin sound)
    18.         addq.l  #4,sp
    19.         move.b  #1,$39(a0); set spindash charge flag
    20.  
    21. Sonic_NoSpindash:
    22.         rts
    23. ; ===========================================================================
    24.  
    25. Sonic_Spindashing:
    26.         move.b  ($FFFFF602).w,d0
    27.         btst    #1,d0   ; has down been released yet?
    28.         bne.s   Sonic_ChargeSpindash; if not, go to charging code
    29.         move.b  #$E,$16(a0); set height/2 to $E
    30.         move.b  #7,$17(a0); set width/2 to $7
    31.         move.b  #2,$1C(a0); use animation 2 (rolling)
    32.         addq.w  #5,$C(a0); add 5 to upper byte of playfield Y coordinate (?)
    33.         move.b  #0,$39(a0); unset spindash charge flag
    34.         move.w  #$2000,($FFFFEED0).w; *
    35.         move.w  #$800,$14(a0); set Sonic's speed to $800
    36.         btst    #0,$22(a0); which way are we facing?
    37.         beq.s   loc_103D4; if we're facing left, don't do anything
    38.         neg.w   $14(a0) ; set speed in other direction if we're facing right
    39.  
    40. loc_103D4:
    41.         bset    #2,$22(a0); set roll flag
    42.         rts
    43. ; ===========================================================================
    44.  
    45. Sonic_ChargeSpindash:
    46.         move.b  ($FFFFF603).w,d0
    47.         andi.b  #$70,d0 ; are A, B or C pressed?
    48.         beq.w   Sonic_SkipCharging; if not, don't do anything
    49.         nop     ; charging code is missing
    50.  
    51. Sonic_SkipCharging:
    52.         addq.l  #4,sp
    53.         rts
    54. ; End of function Sonic_Spindash
    Questions:
    1) What is the purpose of the adding five to the playfield Y coordinate on line 32?
    2) What is the purpose of moving $2000 into ($FFFFEED0).w on line 34? Does this have any bearing on question 3?
    3) Why does the camera lock vertically when spindashing past the point at which the dynamic level resizing kicks in?
     
  2. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    1) may be a problem with the animation that requires moving the object to correct.

    $EED0 is very close to the screen stack, so I would assume that that write does lock the screen. However, I don't know much about the screen stuff, other than that they seem to have called it a stack.

    To check what it does, try patching the relevant instructions with NOP and see what happens.
     
  3. Tweaker

    Tweaker

    Banned
    12,387
    3
    0
    Why does everybody keep using the nick arcade spindash? Use S2F, ffs.
     
  4. Quickman

    Quickman

    be attitude for gains Tech Member
    5,604
    19
    18
    :x
    omg porjcet
    I have already tried that - it has no obvious effect. $EED0 is unreferenced elsewhere in the ROM.

    I used the Nick Arcade spindash for its incompletion - what I plan on doing is far easier if I'm working with this unashamedly incomplete code compared to the complete code in S2F.
     
  5. Stealth

    Stealth

    Tech Member
    594
    31
    28
    Sonic Mania, HCGE, Sonic Megamix, SonED2, [...]
    1) The spinning frames are drawn at a different offset than the standing and spindashing ones (the height is different). The offset is to correct for the height difference and keep Sonic on the ground
    2) FFFFEED0 isn't used in Sonic 1, so it shouldn't be affecting anything else. Sonic 2 is using it as a timer for the spindash, The screen scrolling code is supposed to test it and subtract $100 if it's nonzero, keeping the screen frozen horizontally until it becomes zero. After that, the next two bytes are used as an index into the "recorded positions" array to pick up Sonic's last few positions and use them to give the effect of the screen "catching up"
    3) I don't see anything here that should be affecting the screen boundary positioning
     
  6. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    Heh, clever. I thought it was just used to calculate the character's speed, given the way that it rapidly counts down after reving.
     
  7. Quickman

    Quickman

    be attitude for gains Tech Member
    5,604
    19
    18
    :x
    omg porjcet
    Ninja update:

    I've done some more testing; it's not actually locking the Y position, but the Y position isn't changing fast enough and it can't keep up with Sonic's movement.

    I'm going to assume this is a preventable problem since spindash was implemented correctly in Sonic 2, complete with pipes to run through; what do I need to do?
     
  8. Quickman

    Quickman

    be attitude for gains Tech Member
    5,604
    19
    18
    :x
    omg porjcet
    Ninja doublepost.

    Stealth helped me realise where the problem is - the code for ducking is still being run, so the camera is being shifted down, which causes problems. Adding a delay identical to the one implemented in Sonic 2 final fixed the problem. (Now I know why they implemented that. :P)

    Spindashing after that delay still causes problems at the moment, but I can deal with that fairly easily.
     
  9. SMTP

    SMTP

    Tech Member
    that's what I told you to do on IRC a couple days ago.. =P
     
Thread Status:
Not open for further replies.