don't click here

Ristar disassembly

Discussion in 'Engineering & Reverse Engineering' started by Andlabs, Jul 27, 2010.

  1. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    So yeah, seeing as if I probably won't be working extensively on it, I put a Ristar disassembly I made for the DAC samples onto the SVN. Read the readme.txt and go crazy =P

    EDIT
    Some Nemesis(?) art pointers, if anyone wants to confirm/label: http://ristar-cluster.info/php-pages/index2.html
     
  2. Hivebrain

    Hivebrain

    Administrator
    3,048
    160
    43
    53.4N, 1.5W
    Github
    Any chance of switching to asm instead of idb, or has the code not been fully disassembled?
     
  3. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    That's the thing I'm unsure of; if you search for TODO you'll see some jumps haven't been fully resolved yet; and besides I might have missed some jumps, or IDA might have accidentlly misinterpreted something as a function (happened to me with Chaotix a lot), etc. Plus with Ristar IDA accidentally marks some data (such as Nemesis data) as offsets. I want to hold off an ASM conversion until the code is analyzed fully, but yes raw split+text ASM would help.

    Also I'd prefer waiting until someone gets a command line Star compressor/decompressor working too, just so splits/builds/hacks go easier =P
     
  4. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    Code (Text):
    1. ROM:00005050; =============== S U B R O U T I N E =======================================
    2. ROM:00005050
    3. ROM:00005050; a0 = OST pointer
    4. ROM:00005050
    5. ROM:00005050 RenderSprite:                          ; CODE XREF: MainRenderSprites:loc_5010p
    6. ROM:00005050                                        ; sub_548F0:loc_54958p
    7. ROM:00005050                 btst    #0,2(a0)
    8. ROM:00005056                 bne.s   locret_5060
    9. ROM:00005058                 btst    #1,2(a0)
    10. ROM:0000505E                 beq.s   loc_5062
    11. ROM:00005060
    12. ROM:00005060 locret_5060:                           ; CODE XREF: RenderSprite+6j
    13. ROM:00005060                 rts
    14. ROM:00005062; ---------------------------------------------------------------------------
    15. ROM:00005062
    16. ROM:00005062 loc_5062:                              ; CODE XREF: RenderSprite+Ej
    17. ROM:00005062                 movea.l 8(a0),a1
    18. ROM:00005066                 moveq   #0,d0
    19. ROM:00005068                 move.b  3(a0),d0
    20. ROM:0000506C                 add.w   d0,d0
    21. ROM:0000506E                 adda.w  (a1,d0.w),a1
    22. ROM:00005072                 moveq   #0,d1
    23. ROM:00005074                 move.b  (a1)+,d1
    24. ROM:00005076                 bmi.s   locret_50D6
    25. ROM:00005078                 move.b  (a1)+,4(a0)
    26. ROM:0000507C                 move.w  $2A(a0),d2
    27. ROM:00005080                 move.w  $28(a0),d3
    28. ROM:00005084                 btst    #6,2(a0)
    29. ROM:0000508A                 bne.s   loc_50E4
    30. ROM:0000508C
    31. ROM:0000508C loc_508C:                              ; CODE XREF: RenderSprite+82j
    32. ROM:0000508C                 move.b  (a1)+,d0
    33. ROM:0000508E                 ext.w   d0
    34. ROM:00005090                 add.w   d2,d0
    35. ROM:00005092                 move.w  d0,(a2)+
    36. ROM:00005094                 move.b  (a1)+,(a2)+
    37. ROM:00005096                 move.b  d6,(a2)+
    38. ROM:00005098                 move.w  (a1)+,d0
    39. ROM:0000509A                 add.w   $E(a0),d0
    40. ROM:0000509E                 btst    #4,2(a0)
    41. ROM:000050A4                 bne.s   loc_50AA
    42. ROM:000050A6                 ori.w   #$8000,d0
    43. ROM:000050AA
    44. ROM:000050AA loc_50AA:                              ; CODE XREF: RenderSprite+54j
    45. ROM:000050AA                 move.w  d0,(a2)+
    46. ROM:000050AC                 move.b  (a1)+,d0
    47. ROM:000050AE                 tst.b   2(a0)
    48. ROM:000050B2                 bpl.s   loc_50BC
    49. ROM:000050B4                 bchg    #3,-2(a2)
    50. ROM:000050BA                 move.b  (a1),d0
    51. ROM:000050BC
    52. ROM:000050BC loc_50BC:                              ; CODE XREF: RenderSprite+62j
    53. ROM:000050BC                 addq.l  #1,a1
    54. ROM:000050BE                 ext.w   d0
    55. ROM:000050C0                 add.w   d3,d0
    56. ROM:000050C2                 andi.w  #$1FF,d0
    57. ROM:000050C6                 beq.s   loc_50D8
    58. ROM:000050C8
    59. ROM:000050C8 loc_50C8:                              ; CODE XREF: RenderSprite+8Ej
    60. ROM:000050C8                                        ; RenderSprite+92j
    61. ROM:000050C8                 move.w  d0,(a2)+
    62. ROM:000050CA                 addq.b  #1,d6
    63. ROM:000050CC                 cmpi.w  #$50,d6; 'P'
    64. ROM:000050D0                 bhi.s   locret_50D6
    65. ROM:000050D2                 dbf     d1,loc_508C
    66. ROM:000050D6
    67. ROM:000050D6 locret_50D6:                           ; CODE XREF: RenderSprite+26j
    68. ROM:000050D6                                        ; RenderSprite+80j
    69. ROM:000050D6                 rts
    70. ROM:000050D8; ---------------------------------------------------------------------------
    71. ROM:000050D8
    72. ROM:000050D8 loc_50D8:                              ; CODE XREF: RenderSprite+76j
    73. ROM:000050D8                 btst    #5,2(a0)
    74. ROM:000050DE                 bne.s   loc_50C8
    75. ROM:000050E0                 addq.w  #1,d0
    76. ROM:000050E2                 bra.s   loc_50C8
    77. ROM:000050E4; ---------------------------------------------------------------------------
    78. ROM:000050E4
    79. ROM:000050E4 loc_50E4:                              ; CODE XREF: RenderSprite+3Aj
    80. ROM:000050E4                                        ; RenderSprite+EAj
    81. ROM:000050E4                 move.b  (a1)+,d0
    82. ROM:000050E6                 ext.w   d0
    83. ROM:000050E8                 neg.w   d0
    84. ROM:000050EA                 moveq   #3,d4
    85. ROM:000050EC                 and.b   (a1),d4
    86. ROM:000050EE                 addq.b  #1,d4
    87. ROM:000050F0                 lsl.w   #3,d4
    88. ROM:000050F2                 sub.w   d4,d0
    89. ROM:000050F4                 add.w   d2,d0
    90. ROM:000050F6                 move.w  d0,(a2)+
    91. ROM:000050F8                 move.b  (a1)+,(a2)+
    92. ROM:000050FA                 move.b  d6,(a2)+
    93. ROM:000050FC                 move.w  (a1)+,d0
    94. ROM:000050FE                 add.w   $E(a0),d0
    95. ROM:00005102                 ori.w   #$1000,d0
    96. ROM:00005106                 btst    #4,2(a0)
    97. ROM:0000510C                 bne.s   loc_5112
    98. ROM:0000510E                 ori.w   #$8000,d0
    99. ROM:00005112
    100. ROM:00005112 loc_5112:                              ; CODE XREF: RenderSprite+BCj
    101. ROM:00005112                 move.w  d0,(a2)+
    102. ROM:00005114                 move.b  (a1)+,d0
    103. ROM:00005116                 tst.b   2(a0)
    104. ROM:0000511A                 bpl.s   loc_5124
    105. ROM:0000511C                 bchg    #3,-2(a2)
    106. ROM:00005122                 move.b  (a1),d0
    107. ROM:00005124
    108. ROM:00005124 loc_5124:                              ; CODE XREF: RenderSprite+CAj
    109. ROM:00005124                 addq.l  #1,a1
    110. ROM:00005126                 ext.w   d0
    111. ROM:00005128                 add.w   d3,d0
    112. ROM:0000512A                 andi.w  #$1FF,d0
    113. ROM:0000512E                 beq.s   loc_5140
    114. ROM:00005130
    115. ROM:00005130 loc_5130:                              ; CODE XREF: RenderSprite+F6j
    116. ROM:00005130                                        ; RenderSprite+FAj
    117. ROM:00005130                 move.w  d0,(a2)+
    118. ROM:00005132                 addq.b  #1,d6
    119. ROM:00005134                 cmpi.w  #$50,d6; 'P'
    120. ROM:00005138                 bhi.s   locret_513E
    121. ROM:0000513A                 dbf     d1,loc_50E4
    122. ROM:0000513E
    123. ROM:0000513E locret_513E:                           ; CODE XREF: RenderSprite+E8j
    124. ROM:0000513E                 rts
    125. ROM:00005140; ---------------------------------------------------------------------------
    126. ROM:00005140
    127. ROM:00005140 loc_5140:                              ; CODE XREF: RenderSprite+DEj
    128. ROM:00005140                 btst    #5,2(a0)
    129. ROM:00005146                 bne.s   loc_5130
    130. ROM:00005148                 addq.w  #1,d0
    131. ROM:0000514A                 bra.s   loc_5130
    132. ROM:0000514A; End of function RenderSprite
    Does anyone know if the sprite mappings read by this routine are the same format as in S1/2/3K/Crackers? I get odd results loading a mapping in all four formats in SonMapEd, and both this and the Sonic 1 code are just confusing.
     
  5. The code isn't confusing at all if you know how the Sprite Attribute Table works, and if you don't there's always genvdp.txt. Anyway, the mappings data starts off with an offset table which is identical to the one in Sonic 1. The format of each frame's mapping data is NN ?? (YY SS AAAA XX XX'). NN is the number of sprites in the frame - 1, so the bytes in brackets are repeated NN + 1 times. I have no idea what ?? is but it's moved to byte 4 of the object's status table. YY is the Y offset, SS is the sprite size, AAAA is the art tile, XX is the X offset and XX' is the X offset in case the object is X-flipped (it doesn't need to be stored separately, it can be calculated, but I'm assuming it was done for speed reasons). For comparison, Sonic 1 is NN (YY SS AAAA XX), except NN is the number of sprites in the frame instead of the number of sprites -1.

    Also, RenderSprite is an inaccurate name since a mapping frame can consist of multiple sprites. RenderMappingFrame or RenderFrame or even RenderObject would be better.