Sonic 3 & K research (S&K also)

Discussion in 'Discussion and Q&A Archive' started by Hitaxas, Mar 12, 2009.

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

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    I originally made this topic on Retrohack (PsychoSk8r's forums), but I decided to copy/paste what I had here. enjoy. :)


    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 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. :p (and Puto for his text format conversion. :) )


    1. you will need a copy of Stealth's S&K ASM file, which you can grab from Sonic Retro (guys, If you don't want me to link to Retro, tell me, I can find a host): 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:



    S2 to s3k equates:

    Sonic_acceleration: = 2 ; this seems to handle topspeed as well, i guess...


    Sonic_deceleration: = 4 ?


    render_flags: = 4 ?


    routine: = 5


    width_pixels: = 6 ;and 7 ?


    priority: = 8 ; $100 is 2 in s2 and $80 is 1


    art_tile: = $A


    mappings: = $C


    x_pos: = $10


    y_pos: = $14


    x_vel: = $18


    y_vel: = $1A


    inertia: = $1C


    y_radius: = $1E AND 6?


    x_radius: = $1F AND 7?


    anim: = $20


    next_anim: = $21


    mapping_frame: = $22


    anim_frame: = $23


    anim_frame_duration: = $24


    angle: = $26


    flip_angle: = $27


    collision_flags: = $28


    collision_property: = $29


    Status: = $2A


    status_secondary: = $2B


    air_left: = $2C


    flip_turned: = $2D


    obj_control: = $2E


    ;routine_secondary: = $2F


    flips_remaining: = $30


    flip_speed: = $31


    move_lock: = $32


    invulnerable_time: = $34


    invincibility_time: = $35


    speedshoes_time: = $36


    $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


    Sonic_Look_delay_counter: = $39


    next_tilt: = $3A


    tilt: = $3B


    stick_to_convex: = $3C


    shield_dplc: = $3C ; custom in s2... not sure if it will work in all hacks =/


    spindash_flag: = $3D


    spindash_counter: = $3E


    layer_plus: = $3F


    Jumping: = $40


    layer: = $46


    layer_plus: = $47


    next_object: = $4A


    RAM variables:


    Ctrl_1_Held_Logical = $FFFFF602


    Ctrl_1_Press_Logical = $FFFFF603


    Ctrl_1_Held = $FFFFF604


    Ctrl_1_Press = $FFFFF605


    Sonic_Pos_Record_Index = $FFFFEE26


    Sonic_Pos_Record_Buf = $FFFFE500


    Sonic_Stat_Record_Buf = $FFFFE400


    $FFFFB01A = $FFFFB022


    $FFFFB001 = $FFFFB004


    $FFFFB018 = $FFFFB008


    $FFFFEE24 = $FFFFEE24


    $FFFFCD9C = $FFFFCD9C


    $FFFFF602 = $FFFFF602


    PlaySound = Play_Sound_2


    Primary_Collision = $FFFFF7B4


    Secondary_Collision = $FFFFF7B8


    Collision_addr = $FFFFF796


    Chain_Bonus_counter = $FFFFF7D0


    Camera_Min_Y_pos = $FFFFEE18


    Camera_Min_X_pos = $FFFFEE14


    Camera_Max_X_pos = $FFFFEE16


    Debug_mode_flag = $FFFFFFDA


    Ctrl_1_Press = $FFFFF605


    Debug_placement_mode = $FFFFFE08


    Control_Locked = $FFFFF7CA


    Camera_Max_Y_pos_now = $FFFFEE1A


    $FFFFEEBE = $FFFFEE0B


    Update_HUD_lives = $FFFFFE1C


    Update_HUD_rings = $FFFFFE1D


    Life_count = $FFFFFE12


    Time_Over_flag = $FFFFFE1A


    Update_HUD_timer = $FFFFFE1E


    Update_HUD_timer_2P = $FFFFFEC7


    Ring_count = $FFFFFE20


    Extra_life_flags = $FFFFFE1B


    Level_Inactive_flag = $FFFFFE02


    RandomNumber = Random_Number


    Emerald_count = $FFFFFFB1


    $FFFFFFB0 = $FFFFFFB0 ; used as Got_Emerald in s2, but in S3K, it is used to check the super emeralds


    MainCharacter = $FFFFB000


    Object_RAM = $FFFFB000


    Sidekick = $FFFFB04A


    Water_flag = $FFFFF730


    Super_Sonic_flag = $FFFFFE19


    Ring_spill_anim_counter = $FFFFFEB6


    Extra_life_flags = $FFFFFE1B


    Saved_layer = $FFFFFE3A


    Saved_art_tile = $FFFFFE38


    Saved_x_pos = $FFFFFE2E


    Saved_y_pos = $FFFFFE30


    $FFFFF7C7 = $FFFFF7C8


    $FFFFF768 = $FFFFF768


    $FFFFF76A = $FFFFF76A


    obj_control = $FFFFF7C6


    Super_Sonic_frame_count = $FFFFF670


    $FFFFCBC0 = $FFFFCBC0 ; used in S3K for hyper form after-images


    MoveX = $FFFFB018


    MoveY = $FFFFB01A


    MainCharacter+x_pos = $FFFFB010


    MainCharacter+y_pos = $FFFFB014


    Sidekick+x_pos = $FFFFB05A


    Sidekick+y_pos = $FFFFB05E


    Routines:


    PauseGame = Paused_Debug_Controls


    Sonic_LevelBound = Player_Check_Screen_Boundaries


    AnglePos = Call_Player_AnglePos


    CalcSine = GetSine


    CalcAngle = GetArcTan


    Sonic_DoLevelCollision = sub_11EEC


    ObjectMove = MoveSprite_TestGravity2 or MoveSprite2


    SingleObjLoad = Create_New_Sprite3


    AnimateSprite = Animate_Sprite


    DisplaySprite = Draw_Sprite


    sonic_jumpheight = sub_118BC


    Sonic_ChgJumpDir = sub_1164E


    Obj01_UpdateSpeedOnGround = loc_112FC


    Sonic_Lookup = loc_112B0


    Sonic_Duck = loc_11276


    Obj01_MdJump = Sonic_Spin_Freespace


    Obj01_MdRoll = Sonic_Spin_Path


    Sonic_Roll = Player_Spin


    Sonic_Jump = sub_117DA


    Player_OnFloor = loc_1C95A or Tails_DoLevelCollision when Tails


    Sonic_CheckGoSuper = loc_119D2


    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.


    click this link for information on this: link


    Enjoy, and help out if you can. :)


    EDIT: I am aware of the Sound issues, and the fact that building with SNASM68k screws with the character art.


    If anyone knows how to fix these problems, please post the information.
     
    Last edited by a moderator: Mar 13, 2009
  2. shadowbeasts

    shadowbeasts I'm Legend Member

    Joined:
    Jan 5, 2009
    Messages:
    286
    Location:
    Good 'ol USA.
    I've been trying to do the same thing in a way so This Topic I created should help. It's got everything thats in Sonic 3 that can't be accessed normally but is in the game and can probably be accessed in S3 through ASM. So I help with your research.
     
  3. SonicVaan

    SonicVaan I'm a cyberpunk with a taste for guns Member

    Joined:
    Sep 12, 2008
    Messages:
    456
    Location:
    Germany, Cologne
    Ok so I built the disassembly. But if I play the game, there's no sound after SEGA screen and Sonic looks messed up in the game.
     
  4. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I have the Sound Problems as well. :p It's like "SEEEGAAAA...*chrash-sound*" and no sound. Sonic is not looking messed up for me, but a game without sound is useless.
     
  5. Hitaxas

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    Snasm or asm8k?


    Also, I am aware of the sound issue..although, unsure on how to fix it.
     
  6. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Well, I used ASM68k to build. I guess SNASM68k is shit to build this. But I don't know why thi is happening. Maybe the file is too large... I dunno.
     
  7. Alriightyman

    Alriightyman I'm back! Member

    Joined:
    Oct 3, 2007
    Messages:
    156
    Location:
    USA
    That's because you are reading it wrong. 4 (or $04) is render flags. What you are thinking of is something that is put into register (a4) at the begining of Obj_Sonic's code, this:



    move.w #$80,4(a4)



    If you scroll up to the beginning of Obj_Sonic, you will see this:



    lea ($FFFFF760).w,a4



    Now when you move an address into a register, like (a4), putting a number in front of it like 4 adds 4 to the current address. So that above line of code,



    move.w #$80,4(a4)


    is actually the same as writing
    Code:
    		move.w	#$80,($FFFFF764).w
    

    Sorry if this doesn't make sense, I'm sick and can't think like normal.
     
    Last edited by a moderator: Mar 12, 2009
  8. snkenjoi

    snkenjoi Well-Known Member Member

    Joined:
    Sep 6, 2008
    Messages:
    59

    Stealth knows
     
  9. SonicVaan

    SonicVaan I'm a cyberpunk with a taste for guns Member

    Joined:
    Sep 12, 2008
    Messages:
    456
    Location:
    Germany, Cologne
    Okay I've made that, but now I've got a 1KB build. ;)
     
  10. Hitaxas

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    Snkenjoi, thanks for that link. ;)


    I'll have to try that out when I get home tomorrow. (I'm at my GF's, using a Wii for the internet.)
     
  11. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Yes, he really knows. I fixed it (replacing hundreds of $FF with a simple cnop ;)).


    Source Code aviable here (including ASM68k, corrupted SNASM68k, ROMPAD, INCLUDE and 2 custom build.bat files): LINK


    Complete Credits to Stealth (except for uploading the Source Code)
     
    Last edited by a moderator: Mar 16, 2009
  12. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    ...


    That guide was seriously unrequired you know.
     
  13. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I know, but it wouldn't make any differences, when I haven't added it. But actually you're right. Guide removed (download the File ;)).
     
  14. SonicVaan

    SonicVaan I'm a cyberpunk with a taste for guns Member

    Joined:
    Sep 12, 2008
    Messages:
    456
    Location:
    Germany, Cologne
    Okay, I made it. But now anything sounds crappy. My proof is on the attachment.S3K_SNAS.rar
     

    Attached Files:

  15. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I really don't know your problem. Maybe there is something wrong with your SNASM68K.EXE... As for the sprites, I had the same problem with Hitaxas build.bat. Use mine and everything should work. ;)
     
  16. Hitaxas

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    I'm not too sure what it is either, but using asm68k.exe works for me with no problems. Once I get home, I'll be uploading a small hack of S&K I put together.


    Thanks for the interest in this topic. ;)
     
  17. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Can anybody tell me what to do to get Sonic 3 & Knuckles? I don't get what in the begining stands and this doesn't help as well... hope someone can say it a bit proper. :)
     
  18. egdelous2

    egdelous2 Newcomer Member

    Joined:
    Nov 3, 2010
    Messages:
    11
    Selbi, the link is down, can you upload the link again please?
     
  19. Hanoch

    Hanoch Well-Known Member Member

    Joined:
    Aug 3, 2008
    Messages:
    312
    Location:
    Israel
    [​IMG]


    That's what Private Messages are for.
     
  20. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I deleted it a long time ago. I made my own buildtools a few months ago, but I highly recommend snkenjoi's. they are a million times better (and for some reason don't glitch up the sound even with MusicPadding being normal).


    But Hanoch is right, a one and a half years bump doesn't really push yourself into the right light.
     
Thread Status:
Not open for further replies.