don't click here

Sonic CD Gems Collection Linker Disassembly Dumps

Discussion in 'Engineering & Reverse Engineering' started by Devon, Jun 12, 2022.

  1. Devon

    Devon

    There's nothing left but faith Tech Member
    770
    451
    63
    Double posting, because I think it's warranted. As I said in the previous post, I found a tool called dwarf2cpp, that parses DWARF v1 data and generates C/C++ skeletons from them, basically allowing for easier analysis of variables, structures, and function prototypes and their local variables, while also setting up the folder structure of the source code. No actual code is decompiled, it just dumps those things. Should be a good resource for a possible decompilation in the future maybe?

    Download
    GitHub Repository

    Some samples of what it generated:
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    Here's a sample decompilation I did with this information (note: structure names and constant names had to be made up):
    Code (Text):
    1. void action(void) {
    2.     actwkt *pActwk;
    3.     i32 i;
    4.  
    5.     pActwk = actwk;
    6.     for (i = 0; i < ACTWK_SLOTS; ++i) {
    7.         if (pActwk->actno != 0) {
    8.             act_tbl[pActwk->actno](pActwk);
    9.         }
    10.         ++pActwk;
    11.     }
    12. }
    13.  
    14. void speedset(actwkt *pActwk) {
    15.     i32u xpos;
    16.     i32u ypos;
    17.     i16u spd;
    18.  
    19.     ypos = pActwk->yposi;
    20.     xpos = pActwk->xposi;
    21.     spd = pActwk->xspeed;
    22.     xpos.l += (spd.w << 8);
    23.  
    24.     spd = pActwk->yspeed;
    25.     if (!(pActwk->actfree[PLAYCTRL] & 8)) {
    26.         if (spd.w >= 0 ||
    27.             (!(pActwk->actfree[PLAYCTRL] & 2) ||
    28.             spd.w >= -0x800)) {
    29.             if (!(pActwk->actfree[PLAYCTRL] & 4)) {
    30.                 pActwk->yspeed.w += 0x38;
    31.             }
    32.         }
    33.     }
    34.     if (pActwk->yspeed.w >= 0) {
    35.         if (pActwk->yspeed.w >= 0x1000) {
    36.             pActwk->yspeed.w = 0x1000;
    37.         }
    38.     }
    39.     ypos.l += spd.w << 8;
    40.  
    41.     pActwk->xposi.l = xpos.l;
    42.     pActwk->yposi.l = ypos.l;
    43. }
    44.  
    45. void speedset2(actwkt *pActwk) {
    46.     i32u xpos;
    47.     i32u ypos;
    48.     i32 spd;
    49.     i32 actwkno;
    50.     i16 d1;
    51.  
    52.     xpos = pActwk->xposi;
    53.     ypos = pActwk->yposi;
    54.  
    55.     spd = pActwk->xspeed.w;
    56.     if (pActwk->cddat & 8) {
    57.         actwkno = pActwk->actfree[PLAYRIDE];
    58.         if (actwk[actwkno].actno == 0x1E) {
    59.             d1 = -0x100;
    60.             if (!(pActwk->cddat & 1)) {
    61.                 d1 = -d1;
    62.             }
    63.             spd += d1;
    64.         }
    65.     }
    66.     spd <<= 8;
    67.     xpos.l += spd;
    68.  
    69.     spd = pActwk->yspeed.w;
    70.     spd <<= 8;
    71.     ypos.l += spd;
    72.     pActwk->xposi = xpos;
    73.     pActwk->yposi = ypos;
    74. }
     
    Last edited: Sep 17, 2022
    • Like Like x 5
    • Useful Useful x 2
    • List