don't click here

Random notes

Discussion in 'Engineering & Reverse Engineering' started by Ultima, Sep 22, 2005.

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

    Ultima

    Games Publisher Tech Member
    2,398
    1
    18
    London, England
    Publishing mobile games!
    These are some random notes I made a while ago. Dunno whether they're useful to anyone or not. They're not at all guaranteed to be correct - a lot of it is untested assumption, so you may have to confirm it if you wanna use any of it. It's mainly just skeletal work I suppose. This is for Sonic 2 by the way.

    Collision Response Research.

    Code (Text):
    1. COLLISION RESPONSES
    2. ===================
    3.  
    4. Bitfield:
    5. 0000 0000
    6. TTSS SSSS
    7.  
    8. TT is definately correct.
    9. SS SSSS is questionable. It is the size, but the format I am unsure of. Look at the following data:
    10.  
    11. 0100 0111: Collision Event, 16x16 (ring)
    12. 0100 0110: Collision Event, 32x32 (monitor)
    13. 1101 1000: Starpost (o_O)
    14. 0000 1010: Octopus Badnik OOZ, Seahorse Badnik, Buzz Bomber Badnik (16x32)
    15. 0000 1001: Fish from EHZ (16x16)
    16. 0000 1001: Coconuts EHZ (16x16)
    17. 0000 1111: EHZ Boss (64x64)
    18.  
    19. S: SIZE
    20. T: 00: Enemy, 01: Collision Event, 10: Hurt, 11: Nothing?? (it is used by the starpost though)
    21.  
    22. 00: No collision
    23. 01: Enemy
    24. 08: Very Small Enemy
    25. 0F: Large Enemy
    26. 10: Large Enemy
    27. 14: Very Wide Enemy
    28. 18: Very Small Enemy (8x8?)
    29. 1C: Very Small Enemy (8x8?)
    30. 20: Tall Enemy
    31. 24: Wide Enemy
    32. 28: Very Small Enemy
    33. 2C: Tall Enemy
    34. 30: Very Small Enemy
    35. 3F: Huge Enemy (256x256? o_O)
    36. 40: Collision Event - Small (And destroy)
    37. 7F: Huge Collision Event (256x256?)
    38. 80: Hurt, Can't destroy, small
    39. C0: Nothing
    40. FF: Nothing (256x256 maybe;P)
    Mappings stuff. I've since learned that Hivebrain has a guide on Sonicology.

    Code (Text):
    1. MAPPINGS: SPRITE SIZES
    2. ======================
    3.  
    4. 00: 8x8
    5. 01: 8x16
    6. 02: 8x24
    7. 03: 8x32
    8. 04: 16x8
    9. 05: 16x16
    10. 06: 16x24
    11. 07: 16x32
    12. 08: 24x8
    13. 09: 24x16
    14. 0A: 24x24
    15. 0B: 24x32
    16. 0C: 32x8
    17. 0D: 32x16
    18. 0E: 32x24
    19. 0F: 32x32
    20.  
    21. FLAGS
    22. =====
    23.  
    24. Add to Vram:
    25.  
    26. + $0800: Horizontal Flip
    27. + $1000: Vertical Flip
    28. + $2000: Use Default Palette Line +1
    29. + $4000: Use Default Palette Line +2
    30. + $6000: Use Default Palette Line +3
    31. + $8000: Always in Foreground
    32.  
    33. To get the right address in VRAM, multiply the block number by $20 (32)
    Some very primitive object documentation. These must've been random scribblings.

    Code (Text):
    1. OBJECTS - ROUTINE 0: INIT
    2. ROUTINE 1: BEFORE COLLISION FRAME EVENT
    3. ROUTINE 2: COLLISION EVENT
    4. ROUTINE X: CUSTOM EVENT
    5.  
    6. loc_164E6: Clear an Object's SST entries (destroy the object)
    7. 164F4: Draw the object
    8. 16544: animation script
    This is to do with Sonic's animation frames.

    Code (Text):
    1. Sonic 3 SST
    2.  
    3. $16 - To do with gravity
    4. $14 - Y Location
    5. $1A - Y speed
    6. $1C - X speed
    7. $18 - X speed
    8. $10 - X location
    9. $04 - Direction?
    10. $1E - Jumping/Rolling
    11.  
    12. $22 - FRAME NUMBER TO DISPLAY
    13.  
    14. SONIC 3
    15.  
    16. $1-8, walking
    17. $9-$20 - walking (various angles)
    18. $6A-77 - running in tree trunk (twirl-run)
    19. $B1-B3 - end of level pose
    20. $9D-9F - skidding
    21. $BA - standing
    22. $BE/BD - waiting
    23. $AD/AE/AF - parts of sonic bored
    24. $D9 - last frame of sonic bored
    25. $21-24 - running
    26. $C3/C4 - looking up
    27. $9B/9C - looking down
    28. $96-9A - rolling
    29. $86-8B - charging spindash
    30. $B6-B9 - pushing
    31. $32-3B - sonic twirling
    32. $8D - Sonic hurt
    33. $90-91 - Sonic hanging on
    34. $79-7F - Sonic hanging on (various angles)
    35.  
    36. SONIC 2
    37.  
    38. $1 - standing ? ?X
    39. $2-3 start bored animation ?X
    40. $4-5 tappings foot (bored) ?X
    41. $6 - look at watch ?    X
    42. $7 - start lie down ?   X
    43. $8-9 lying down ? ?X
    44. $A - start lying down ? X
    45. $0B/0C - looking up ?   X
    46. $0D-0F (second half of walking) ?X
    47. $10-14 (first half of walking) ?X
    48. $15-2C walking - angled ?   X
    49. $2D-30 - sonic running ?    X
    50. $31-3C - running angled ?  
    51. $3D-41 - rolling ?  X
    52. $42-47 - charging spindash ?X
    53. $48-4B - pushing ?  X
    54. $4C/4D - looking down ? X
    55. $4E/4F - hurt ? ?X
    56. $50/51 - holding on (horizontal)
    57. $52/53 - holding on, vertical
    58. $54-59 - spinning in air (above fan)    X (twirling)
    59. $5A - breathe in air
    60. $5B - standing spring frame ?X (twirling)
    61. $5C - dead
    62. $5D - drowned
    63. $5E - dead (grey? o_O)
    64. $5F-6A - twirling from spring ?X (twirling)
    65. $6B/6C - hanging (used in WFZ for the metal bars you hang onto) X
    66. $6D-6F - Super Sonic Transformation
    67. $75-78 - Super Sonic Walk
    68. $D2-D5 - skidding ? X
    69. Balancing?
    VRAM blocks for the letters on the title screen...

    Code (Text):
    1. TITLE SCREEN LETTERS
    2. 68E A
    3. 68F B
    4. 690 C ? 69C O
    5. 691 D ? 69D P
    6. 692 E ? 69E Q
    7. 693 F ? 69F R
    8. 694 G ? 6A0 S
    9. 695 H ? 6A1 T
    10. 696 I ? 6A2 U
    11. 697 J ? 6A3 V
    12. 698 K ? 6A4 W
    13. 699 L ? 6A5 Y
    14. 69A M ? 6A6 Y
    15. 69B N ? 6A7 Z
    That's all I found in that folder. I thought it best to post it in case anyone has any use of it. *shrugs*

    EDIT: Oops. Found some more.

    Code (Text):
    1. LEVEL SELECT:
    2. 0000 - SPACE    001C - :    0029 - L    0036 - Y
    3. 0010 - 0    001D - .    002A - M    0037 - Z
    4. 0011 - 1    001E - A    002B - N
    5. 0012 - 2    001F - B    002C - O
    6. 0013 - 3    0020 - C    002D - P
    7. 0014 - 4    0021 - D    002E - Q
    8. 0015 - 5    0022 - E    002F - R
    9. 0016 - 6    0023 - F    0030 - S
    10. 0017 - 7    0024 - G    0031 - T
    11. 0018 - 8    0025 - H    0032 - U
    12. 0019 - 9 ?0026 - I  0033 - V
    13. 001A - *    0027 - J    0034 - W
    14. 001B - ?    0028 - K    0035 - X
    Random disassembly. It's the title screen.

    Code (Text):
    1.  ?lea   ($FFFFFB00).w,a1 ?;Move Address of Palette data into a1
    2.  ?moveq #0,d0 ? ?;init d0
    3.  ?move.w    #$3F,d1 ? ?;Move ($3F - 63) into d1
    4.  
    5. loc_3B8A: ?; CODE XREF: ROM:00003B8Cj
    6.  ?move.l    d0,(a1)+ ? ?;Moves d0 to value at address a1 and increments a1 (clears a palette colour then moves to the next)
    7.  ?dbf   d1,loc_3B8A ? ?;Loops back to loc_3B8A until it has been done d1 (63) times.
    8.  ?moveq #1,d0 ? ?;move 1 into d0
    9.  ?bsr.w sub_2712 ? ?;Branch
    10.  ?move.b    #0,($FFFFFFFA).w ?;Set Debug mode to 0
    11.  ?move.w    #0,($FFFFFFD8).w ?;2 Player mode to 0
    12.  ?move.w    #$280,($FFFFF614).w ?;Moves $280 into F614, making the number of frames to wait for demo guide to $280 frames
    13.  ?clr.w ($FFFFF604).w ?;Clear 1 Player buttons being pressed
    14.  ?move.b    #$E,($FFFFB040).w ?;Putting Flashing stars into SST as instance 2  
    15.  ?move.b    #2,($FFFFB068).w ?;Sets object subtype 2 for creating stars.
    16.  ?jsr   sub_15F9C ? ?;jump to subroutine
    17.  ?jsr   sub_16604 ? ?;jump to subroutine
    18.  ?moveq #0,d0 ? ?;init d0
    19.  ?bsr.w sub_1650 ? ?;
    20.  ?move.w    #0,($FFFFFFD4).w ?;Initilisation Cheat counter for cheats involving title screen
    21.  ?move.w    #0,($FFFFFFD6).w ?;Initilisation Cheat counter for cheats involving title screen
    22.  ?nop  
    23.  ?nop  
    24.  ?nop  
    25.  ?nop  
    26.  ?nop  
    27.  ?nop  
    28.  ?move.w    #4,($FFFFEED2).w ?;Controls how close sonic can get to the edge of the screen, before the camera moves. ?
    29.  ?move.w    #0,($FFFFE500).w ?;
    30.  ?lea   ($FFFFFF20).w,a1 ?;
    31.  ?moveq #$B,d0
    32.  
    33. loc_3BF4: ?; CODE XREF: ROM:00003BF8j
    34.  ?move.w    #-1,(a1)+
    35.  ?dbf   d0,loc_3BF4
    36.  ?move.w    #-$280,($FFFFEE00).w;Set the camera position X
    37.  ?move.w    ($FFFFF60C).w,d0   
    38.  ?ori.b #$40,d0; ?;Or on 40 and d0 (F60C)
    39.  ?move.w    d0,($C00004).l ?;move the value in d0 into the VDP register
    40.  ?bsr.w sub_23C6 ? ?
    41.  
    42. loc_3C14: ?; CODE XREF: ROM:00003C5Cj
    43.  ? ?; ROM:00003C6Cj
    44.  ?move.b    #4,($FFFFF62A).w
    45.  ?bsr.w sub_3384
    46.  ?jsr   sub_15F9C ?
    47.  ?bsr.w sub_3E98 ?;branch to unknown subroutine
    48.  ?jsr   sub_16604 ? ?;jump to unknown subroutine
    49.  ?lea   ($FFFFF804).w,a1 ?;Set a1 to point to FF804 ("PLC" for Sonic and Tails in the Title Screen)
    50.  ?moveq #0,d0 ? ?;Init d0
    51.  ?moveq #$4F,d6 ? ?;move 4F (79) into d6 to prepare for loop
    52.  
    53. loc_3C36: ?; CODE XREF: ROM:00003C44j
    54.  ?tst.w (a1) ? ?;Test if a1 is 0
    55.  ?bne.s loc_3C42 ?;branch if ?not 0
    56.  ?bchg  #2,d0 ? ?;Set Sonic and Tails Sprite Priority to 2, to stop them appearing in front of the banner
    57.  ?move.w    d0,2(a1) ?;Inserts Value into Ram Address
    58.  
    59. loc_3C42: ?; CODE XREF: ROM:00003C38j
    60.  ?addq.w    #8,a1 ? ?;Add 8 to a1
    61.  ?dbf   d6,loc_3C36 ? ?;Loops until done 4F(79)times
    62.  ?bsr.w sub_168A ? ?;Unknown Subroutine
    63.  ?bsr.w sub_3DB4 ? ?;check for miles cheat buttons
    64.  ?tst.w ($FFFFF614).w ?;Tests for demo time
    65.  ?beq.w loc_3D2E ? ?;If 0, start demo mode
    66.  ?tst.b ($FFFFB06F).w ? ? ? ? ? ? ?;Test player input
    67.  ?beq.w loc_3C14 ? ? ? ? ? ? ? ? ?;If not branch to Unknown Location
    68.  ?move.b    ($FFFFF605).w,d0 ?;put the buttons being held down into d0
    69.  ?or.b  ($FFFFF607).w,d0 ?;OR it with the 2 player buttons - so both controllers work
    70.  ?andi.b    #-$80,d0 ? ? ? ? ? ? ? ? ?;AND d0 with -$80: we're only testing for the start button
    71.  ?beq.w loc_3C14 ? ?;if the start button isn't pressed, loop back and carry on
    72.  ?move.b    #$C,($FFFFF600).w ?;go into normal game mode at the end of the frame (the stuff below will take precedence)
    73.  ?move.b    #3,($FFFFFE12).w ?;set the starting lives to 3
    74.  
    75. loc_3C7C:
    76.  ?move.b    #3,($FFFFFEC6).w ? ? ? ? ?;Set starting tails lives to 3
    77.  ?moveq #0,d0 ? ?;initilisation of variables to 0 for level start.
    78.  ?move.w    d0,($FFFFFE20).w ?;rings init
    79.  ?move.l    d0,($FFFFFE22).w ?;time counter init
    80.  ?move.l    d0,($FFFFFE26).w ?;score init
    81.  ?move.w    d0,($FFFFFED0).w ?;Tails ring counter (2 player mode, only for results screen)
    82.  ?move.l    d0,($FFFFFED2).w ?;Tails Time counter (2 player mode, only for results screen)
    83.  ?move.l    d0,($FFFFFED6).w ?;Tails Score Counter (2 Player mode, only for results screen)
    84.  ?move.b    d0,($FFFFFE18).w ?;continues
    85.  ?move.l    #$1388,($FFFFFFC0).w;set the score needed for a life for Sonic to 5000 (50000 in game)
    86.  ?move.l    #$1388,($FFFFFFC4).w;set the score needed for a life for Tails to 5000 (50000 in game)
    87.  ?move.b    #-7,d0 ? ?;set d0 to $79
    88.  ?bsr.w sub_1370 ? ?;play the sound in d0 ($79) - stops music
    89.  ?moveq #0,d0 ? ?;init d0
    90.  ?move.b    ($FFFFFF86).w,d0 ?;move the title screen selection into d0
    91.  ?bne.s loc_3CF6 ? ?;go to options if the selection is not 0
    92.  ?moveq #0,d0 ? ?;set d0 to 0 for more variable initialisation
    93.  ?move.w    d0,($FFFFFF8A).w ?;set $FF8A (unknown) to 0
    94.  ?move.w    d0,($FFFFFFD8).w ?;set $FFD8 (2 player mode) to 0
    95.  ?move.w    d0,($FFFFFE10).w ?;set the zone to 0
    96.  ?tst.b ($FFFFFFD0).w ?;check to see if level select is active
    97.  ?beq.s loc_3CE4 ? ?;if it isn't active, skip
    98.  ?btst  #6,($FFFFF604).w ?;check button A
    99.  ?beq.s loc_3CE4 ? ?;if it is not pressed, skip
    100.  ?move.b    #$28,($FFFFF600).w ?;go to the level select instead of normal game
    101.  ?rts ? ? ? ?;exit
    102. ; ???????????????????????????????????????????????????????????????????????????
    103.  
    104. loc_3CE4: ?; CODE XREF: ROM:00003CD2j ? set up some variables
    105.  ? ?; ROM:00003CDAj
    106.  ?move.w    d0,($FFFFFE16).w;Special Stage Counter ?   
    107.  ?move.w    d0,($FFFFFFB0).w;number of emeralds to 0
    108.  ?move.l    d0,($FFFFFFB2).w;Number of emeralds to draw to 0
    109.  ?move.l    d0,($FFFFFFB6).w;Number of emeralds to draw to 0
    110.  ?rts  
    111. ; ???????????????????????????????????????????????????????????????????????????
    112.  
    113. loc_3CF6: ?; CODE XREF: ROM:00003CBEj ?(2 player level select)
    114.  ?subq.b    #1,d0 ?;subtract 1 from d0 - if it was 1, it will now be 0. If it was 2, it will now be 1
    115.  ?bne.s loc_3D20 ?;if the result is not 0 (if d0 was previously not 1) go to the options menu instead. If d0 was 1 it would now be 0
    116.  ?moveq #1,d1 ?;set d1 to 1
    117.  ?move.w    d1,($FFFFFF8A).w;set $FF8A (some kind of selection option) to 1 (d1)   
    118.  ?move.w    d1,($FFFFFFD8).w;set $FFD8 (2 player mode) to 1 (d1)
    119.  ?moveq #0,d0 ? ?
    120.  ?move.w    d0,($FFFFFFB0).w;number of emeralds to 0
    121.  ?move.l    d0,($FFFFFFB2).w;Number of emeralds to draw to 0
    122.  ?move.l    d0,($FFFFFFB6).w;Number of emeralds to draw to 0
    123.  ?move.b    #$1C,($FFFFF600).w ?;go to 2 player level select screen
    124.  ?move.b    #0,($FFFFFF88).w ?;Selection on 2 player level select menu ?   
    125.  ?rts  
    126. ; ???????????????????????????????????????????????????????????????????????????
    127.  
    128. loc_3D20: ? ? ? ? ?;Options menu code
    129.  ?move.b    #$24,($FFFFF600).w;Go to options menu
    130.  ?move.b    #0,($FFFFFF8C).w ?;Box selected in options menu
    131.  ?rts  
    132. ; ???????????????????????????????????????????????????????????????????????????
    133.  
    134. loc_3D2E: ?; CODE XREF: ROM:00003C54j
    135.  ?move.b    #-7,d0 ? ?;Load sound into d0 (stop music sound)
    136.  ?bsr.w sub_1370 ? ?;Play sound in d0   (Stops music)
    137.  ?move.w    ($FFFFFFF2).w,d0 ?;Move value in FFF2 (Demo level) into d0
    138.  ?andi.w    #7,d0 ? ?;Truncates to make max number of demo levels 7
    139.  ?add.w d0,d0 ? ?;Doubles d0 for reading word addresses
    140.  ?move.w    word_3DAC(pc,d0.w),d0;Load current level values
    141.  ?move.w    d0,($FFFFFE10).w ?;Load current level and act value into RAM Address FFFFFE10
    142.  ?addq.w    #1,($FFFFFFF2).w ?;Add 1 to the current demo level
    143.  ?cmpi.w    #4,($FFFFFFF2).w ?;Compare 4 (max demo level) to current demo level
    144.  ?bcs.s loc_3D5A ? ?;If not equal, branch
    145.  ?move.w    #0,($FFFFFFF2).w ?;Sets to 0 (first demo level)
    146.  
    147. loc_3D5A: ?; CODE XREF: ROM:00003D52j
    148.  ?move.w    #1,($FFFFFFF0).w ?;Demo mode flag to 1
    149.  ?move.b    #8,($FFFFF600).w ?;Move 8 into master level trigger
    150.  ?cmpi.w    #0,($FFFFFE10).w ?;Current level and act compared to Emerald Hill
    151.  ?bne.s loc_3D74 ? ?;If not emerald hill, branch
    152.  ?move.w    #1,($FFFFFFD8).w ?;If it is Emerald Hill move 1 into 2 player mode
    153.  
    154. loc_3D74: ?; CODE XREF: ROM:00003D6Cj
    155.  ?move.b    #3,($FFFFFE12).w ?;Sonics lives init to 3
    156.  ?move.b    #3,($FFFFFEC6).w ?;Tails lives init to 3
    157.  ?moveq #0,d0 ? ?;Move 0 to d0 for variable clears
    158.  ?move.w    d0,($FFFFFE20).w ?;Rings init
    159.  ?move.l    d0,($FFFFFE22).w ?;time init
    160.  ?move.l    d0,($FFFFFE26).w ?;Score counter (HUD)init
    161.  ?move.w    d0,($FFFFFED0).w ?;Tails' rings to 0
    162.  ?move.l    d0,($FFFFFED2).w ?;Tails' time to 0
    163.  ?move.l    d0,($FFFFFED6).w ?;Tails' score to 0
    164.  ?move.l    #$1388,($FFFFFFC0).w;Score needed for lives (sonic)
    165.  ?move.l    #$1388,($FFFFFFC4).w;Score needed for lives (tails)
    166.  ?rts  
    167. ; ???????????????????????????????????????????????????????????????????????????
    168. word_3DAC: ? ? ?;demo levels and level order
    169.  ?dc.w ?0 ? ?;emerald hill
    170.  ?dc.w ?$D00 ? ?;chemical plant
    171.  ?dc.w ?$F00 ? ?;aquatic ruin
    172.  ?dc.w ?$C00 ? ?;casino night
    173.  
    174. ; ??????????????? S U B R O U T I N E ???????????????????????????????????????
    175.  
    176.  
    177. sub_3DB4: ? ? ? ?;Subroutine for the miles cheat
    178.  ?lea   (byte_3DEE).l,a0 ?;set a0 to the address of the command list (below)
    179.  ?move.w    ($FFFFFFD4).w,d0 ?;the step of the cheat that has been done
    180.  ?adda.w    d0,a0 ? ?;Adds d0 to a0 - add the current step to the command list value to read
    181.  ?move.b    ($FFFFF605).w,d0 ?;Puts current buttons being held into d0
    182.  ?andi.b    #$F,d0 ? ?;Checks for up down, left and right.
    183.  ?beq.s locret_3DEC ? ? ? ? ? ? ? ?;if none of these are pressed, exit
    184.  ?cmp.b (a0),d0 ? ?;if any of them are pressed, compare the button pressed to the command value needed (check it's the right button)
    185.  ?bne.s loc_3DE6 ? ? ? ? ? ? ? ? ?;if it's the wrong button, set to 0
    186.  ?addq.w    #1,($FFFFFFD4).w ?;if it's the right button, add 1 to the current command needed ($FFD4)
    187.  ?tst.b 1(a0) ? ?;check the first byte after a0 against 0
    188.  ?bne.s locret_3DEC ? ?;if it's not equal, exit
    189.  ?bchg  #7,($FFFFFFF8).w ?;sets $FFF8 to 0 (unsets the 7th bit) (sets miles cheat on)
    190.  ?move.b    #-$4B,d0 ? ?;puts sound effect to play into d0
    191.  ?bsr.w sub_1370 ? ?;play the sound effect number in d0
    192.  
    193. loc_3DE6: ? ? ? ?; CODE XREF: sub_3DB4+18j
    194.  ?move.w    #0,($FFFFFFD4).w ?;set $FFD4 (miles cheat current button) to 0
    195.  
    196. locret_3DEC: ? ? ?;exit
    197.  ?rts
     
  2. Hivebrain

    Hivebrain

    Administrator
    3,049
    161
    43
    53.4N, 1.5W
    Github
    There's an array for the size of collision responses somewhere, and there's a system for differentiating between enemies, power ups etc. My S1 disassembly contains some notes on it, for those who are interested in this, in the subroutine labelled "TouchResponse".
     
  3. Aurochs

    Aurochs

    Единый, могучий Советский Союз! Tech Member
    2,343
    0
    0
    Whatever catches my fancy
    You mind if I put this stuff in SHIT? (after I verify it)
     
  4. Ultima

    Ultima

    Games Publisher Tech Member
    2,398
    1
    18
    London, England
    Publishing mobile games!
    Go ahead, that's what SHIT's for =P
     
Thread Status:
Not open for further replies.