don't click here

Hitaxas' S3K research topic

Discussion in 'Engineering & Reverse Engineering' started by Hitaxas, Feb 15, 2009.

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

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    I originally made this topic on Retrohack (PsychoSk8r's forums), but I decided to copy/paste what I had here. enjoy. :psyduck:

    So you want to hack S3K, or port an object from said game?

    You've looked all over this site AND asked for help, only to find that nobody can help you?

    You wonder why you cannot and be helped?

    Here is the answer: Sonic 3 and Knuckles is not as well documented as the other two games.

    I want to fix that. Who's with me?

    My S3K research is only possible because of Stealth's Sonic3k.asm file. So a big thanks to Stealth. :) (and Puto for his text format conversion. :) )

    1. you will need a copy of Stealth's S&K ASM file, which you can grab here: DOWNLOAD

    Then, if you can figure out how, lock-on S3 with the ASM.

    Here are the instructions from the IDA version of the Stealth disassembly:

    In order to build a rom you will need include.exe, snasm86k.exe (OR ASM68k.exe) and you must also make a build.bat file using the following text:

    OR, if you use ASM68k.exe:



    2. don't be afraid to share and ask questions in this topic.
    The sole purpose of this topic is to research S3K and compare it's equates, RAM variables and routines to Sonic 2.

    What good is this?
    It will help provide people with answers to unknown questions, as well as help you, the hacker.

    How will it help?
    Not only will we be able to further understand S3K, but it will also aid in porting objects to the other Sonic games, Such as Sonic 1 and 2.

    To start this all off, I will post my findings. All of my findings have been compared to their Sonic 2 (xenowhirl ASM) equivalents.

    Sonic 2 on the left, S3K on the right:

    Code (ASM):
    1. S2 to s3k equates:
    2.  
    3. Sonic_acceleration:         = 2 ; this seems to handle topspeed as well, i guess...
    4. Sonic_deceleration:     = 4 ?
    5. render_flags:           = 4 ?
    6. routine:            = 5
    7. width_pixels:               = 6 ;and 7 ?
    8. priority:           = 8   ; $100 is 2 in s2 and $80 is 1
    9. art_tile:           = $A
    10. mappings:           = $C
    11. x_pos:              = $10
    12. y_pos:              = $14
    13. x_vel:              = $18
    14. y_vel:              = $1A
    15. inertia:            = $1C
    16. y_radius:           = $1E AND 6?
    17. x_radius:           = $1F AND 7?
    18. anim:               = $20
    19. next_anim:          = $21
    20. mapping_frame:          = $22
    21. anim_frame:                 = $23
    22. anim_frame_duration:        = $24
    23. angle:              = $26
    24. flip_angle:             = $27
    25. collision_flags:        = $28
    26. collision_property:         = $29
    27. Status:             = $2A
    28. status_secondary:       = $2B
    29. air_left:           = $2C
    30. flip_turned:            = $2D
    31. obj_control:            = $2E
    32. ;routine_secondary:         = $2F
    33. flips_remaining:        = $30
    34. flip_speed:         = $31
    35. move_lock:          = $32
    36. invulnerable_time:      = $34
    37. invincibility_time:         = $35
    38. speedshoes_time:        = $36
    39. $38                 = $38 ; custom in s2... I use it for shield art. S3K uses it to check for player modes: 1 for tails and 2 for Knuckles
    40. Sonic_Look_delay_counter:   = $39
    41. next_tilt:          = $3A
    42. tilt:               = $3B
    43. stick_to_convex:            = $3C
    44. shield_dplc:            = $3C ; custom in s2... not sure if it will work in all hacks =/
    45. spindash_flag:          = $3D
    46. spindash_counter:       = $3E
    47. layer_plus:         = $3F
    48. Jumping:            = $40
    49. layer:              = $46
    50. layer_plus:         = $47
    51. next_object:            = $4A
    52.  
    53.  
    54.  
    55.  
    56.  
    57. RAM variables:
    58.  
    59. Ctrl_1_Held_Logical             = $FFFFF602
    60. Ctrl_1_Press_Logical        = $FFFFF603
    61. Ctrl_1_Held         = $FFFFF604
    62. Ctrl_1_Press            = $FFFFF605
    63. Sonic_Pos_Record_Index      = $FFFFEE26
    64. Sonic_Pos_Record_Buf        = $FFFFE500
    65. Sonic_Stat_Record_Buf       = $FFFFE400
    66. $FFFFB01A           = $FFFFB022
    67. $FFFFB001           = $FFFFB004
    68. $FFFFB018           = $FFFFB008
    69. $FFFFEE24           = $FFFFEE24
    70. $FFFFCD9C           = $FFFFCD9C
    71. $FFFFF602           = $FFFFF602
    72. PlaySound           = Play_Sound_2
    73. Primary_Collision       = $FFFFF7B4
    74. Secondary_Collision         = $FFFFF7B8
    75. Collision_addr          = $FFFFF796
    76. Chain_Bonus_counter         = $FFFFF7D0
    77. Camera_Min_Y_pos        = $FFFFEE18
    78. Camera_Min_X_pos        = $FFFFEE14
    79. Camera_Max_X_pos        = $FFFFEE16
    80. Debug_mode_flag         = $FFFFFFDA
    81. Ctrl_1_Press            = $FFFFF605
    82. Debug_placement_mode        = $FFFFFE08
    83. Control_Locked          = $FFFFF7CA
    84. Camera_Max_Y_pos_now        = $FFFFEE1A
    85. $FFFFEEBE           = $FFFFEE0B
    86. Update_HUD_lives        = $FFFFFE1C
    87. Update_HUD_rings                = $FFFFFE1D
    88. Life_count          = $FFFFFE12
    89. Time_Over_flag          = $FFFFFE1A
    90. Update_HUD_timer        = $FFFFFE1E
    91. Update_HUD_timer_2P         = $FFFFFEC7
    92. Ring_count          = $FFFFFE20
    93. Extra_life_flags        = $FFFFFE1B
    94. Level_Inactive_flag         = $FFFFFE02
    95. RandomNumber            = Random_Number
    96. Emerald_count           = $FFFFFFB1
    97. $FFFFFFB0           = $FFFFFFB0 ; used as Got_Emerald in s2, but in S3K, it is used to check the super emeralds
    98. MainCharacter           = $FFFFB000
    99. Object_RAM          = $FFFFB000
    100. Sidekick            = $FFFFB04A
    101. Water_flag          = $FFFFF730
    102. Super_Sonic_flag                = $FFFFFE19
    103. Ring_spill_anim_counter         = $FFFFFEB6
    104. Extra_life_flags                = $FFFFFE1B
    105. Saved_layer         = $FFFFFE3A
    106. Saved_art_tile          = $FFFFFE38
    107. Saved_x_pos         = $FFFFFE2E
    108. Saved_y_pos         = $FFFFFE30
    109. $FFFFF7C7           = $FFFFF7C8
    110. $FFFFF768           = $FFFFF768
    111. $FFFFF76A           = $FFFFF76A
    112. obj_control         = $FFFFF7C6
    113. Super_Sonic_frame_count     = $FFFFF670
    114. $FFFFCBC0           = $FFFFCBC0 ; used in S3K for hyper form after-images
    115. MoveX               = $FFFFB018
    116. MoveY               = $FFFFB01A
    117. MainCharacter+x_pos     = $FFFFB010
    118. MainCharacter+y_pos     = $FFFFB014
    119. Sidekick+x_pos          = $FFFFB05A
    120. Sidekick+y_pos          = $FFFFB05E
    121.  
    122.  
    123.  
    124. Routines:
    125.  
    126. PauseGame           = Paused_Debug_Controls
    127. Sonic_LevelBound                = Player_Check_Screen_Boundaries
    128. AnglePos            = Call_Player_AnglePos
    129. CalcSine            = GetSine
    130. CalcAngle           = GetArcTan
    131. Sonic_DoLevelCollision      = sub_11EEC
    132. ObjectMove          = MoveSprite_TestGravity2 or MoveSprite2
    133. SingleObjLoad           = Create_New_Sprite3
    134. AnimateSprite           = Animate_Sprite
    135. DisplaySprite                   = Draw_Sprite
    136. sonic_jumpheight        = sub_118BC
    137. Sonic_ChgJumpDir        = sub_1164E
    138. Obj01_UpdateSpeedOnGround   = loc_112FC
    139. Sonic_Lookup            = loc_112B0
    140. Sonic_Duck          = loc_11276
    141. Obj01_MdJump            = Sonic_Spin_Freespace
    142. Obj01_MdRoll            = Sonic_Spin_Path
    143. Sonic_Roll          = Player_Spin
    144. Sonic_Jump          = sub_117DA
    145. Player_OnFloor          = loc_1C95A or Tails_DoLevelCollision when Tails
    146. Sonic_CheckGoSuper      = loc_119D2
    147. Sonic_ResetOnFloor      = Player_TouchFloor

    Not 100% sure on some notes, 4 seems to be both Sonic_deceleration AND render_flags, but that may just be me overlooking shit.
     
  2. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    Why are optimizations enabled? =S I just use /p (asm68k) or -p (snasm68k) and that normally does it - especially if I want an exact build of what is in the asm file. Having to remember all those parameters seems stupid and hard =/

    By the way, to those using asm68k, it pretty much takes the same parameters as snasm68k but using / instead of - (some parameters change, but most are the same). I wonder if that helps =P
     
  3. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Without some optimizations, there seems to be a few graphical errors in Mushroom Hill Zone (S&K).
     
  4. Sik

    Sik

    Sik is pronounced as "seek", not as "sick". Tech Member
    6,718
    1
    0
    being an asshole =P
    Wouldn't that mean that something is wrong with the disassembly then? Remember that optimizations are doing stuff like replacing add with addq where possible and such.
     
  5. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    Could be. Since there are quite a few graphical mess ups in the game.
     
  6. Spanner

    Spanner

    The Tool Member
    The disassembly is quite picky. For example, if you replace the ASM'd art for Sonic with a binary file exported from SonMapEd, the game fucks up. Why is that happening? I add an even directive anyway and that fails.
     
  7. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    I haven't messed with adding files externally. If I were to replace the art, I'd save everything in ASM form and replace the lines in the asm file.
     
  8. Yuzu

    Yuzu

    Member
    2,548
    51
    28
    I guess the game is just sensitive about the files, or checks the checksum of the files, which would be pointless on the 68K at the same time.
     
  9. LazloPsylus

    LazloPsylus

    Buried under SSRG Somewhere Tech Member
    154
    0
    0
    Academy City
    SSRG, world domination, a billion and one research projects...
    I actually started doing some research pertaining to the spindash code in the disasm, actually. I had some notes, but they all seem to have disappeared. I'd be glad to join in and help, if it weren't for the fact that I'm already tied to another project and probably won't be freed up anytime soon. If I do find some spare time, however, I might be able to pitch in with some research.

    I was actually hoping that someone would attempt to do this. S3K has some interesting secrets nestled inside of the code and some amazing programming and none of it can really be read or used because there is little to no documentation on any of the disasm at all. It's time we start trying to remedy the issue of no documentation.

    By the way, as a note I just remembered, there is a serious issue pertaining to the combined ROM that does not allow much (if any) progress in AIZ and MHZ. I believe the issue is tied to either a music call involving Knuckles's Theme and it's transition back to the normal zone music (oddly, the probem does not appear at the end of LBZ, when Knuckles appears to slow down Sonic/Tails) or it could be an alignment issue. It only happens with the combined S3K ROM. That may be an issue that needs to be resolved in the disasm along with the research that is intended to be done.
     
  10. Skyler

    Skyler

    Neonネオン Cowgirlカウガール Site Staff
    3,287
    32
    28
    Hellafornia
    The next audtion
    I may not exactly be a hacking expert, but couldn't you try disassembling S3 and SK seperately?
     
  11. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    S3 alone, no... Since I have not seen a disassembly of plain S3.
    S&K, yes... That is what Stealth's file is actually.

    Although, my focus is on S3K.
     
  12. Ritchie Ramone

    Ritchie Ramone

    Member
    35
    0
    6
    I'm no hacker (although I do have some experience dicking around with pointless "experiments" on S2 disassemblies and I have some ASM knowledge), but I'm in full support of this. Hopefully this opens new doors in hacking this game. I know that with the proper knowledge, I myself could contribute to this (and I certainly do wish I were at a level where I could immediately join you guys and help further this research). Anyways, you guys have my full support.
     
Thread Status:
Not open for further replies.