SM64 Decompilation Project!
Users browsing this thread: 1 Guest(s)

SM64 Decompilation Project!

This project aims to recreate the C source code from which SM64 was (most likely) compiled. Because this would be VERY tedious with only one person working, I wanted to ask for help! Here is what I have so far:

main.c:
Code:
​#include <stdint.h>
#include "includes.h"

void MainFunc()
{
    osInitialize();
    // Dummy routine was here
}

void main() // EntryPoint
{
    // Initialize some memory region?
    uint32_t base = 0x8033A580;
    for(uint32_t i=0; i<0x2CEE0; i+=8)
    {
        *(uint32_t*)(base+i) = 0;
        *(uint32_t*)(base+i+4) = 0;
    }
    // Jump to our actual "Main" function
    MainFunc();
}

along with other smaller code files, such as os.c, os.h and includes.h (which will include all the .h files). Inline assembly may be used, but only sparsely and only when necessary (such as reading coprocessor 0 status).

[EDIT]​ GitHub repository: https://github.com/Yoshimaster96/SM64-C-Source/tree/master

[EDIT 2]​ Quitting the project in favor of decompiling Super Monkey Ball. See you soon, when I can present something!
(This post was last modified: 23-07-2016, 12:22 AM by Yoshimaster96.)

Having trouble with SMB, so I decided to come back to this project. GitHub has been updated.

I really like the idea of this project. I had a similar idea of replacing some of the more interesting routines (such as behaviors and interactions) with C code to make them more easily customizable. I haven't spent too much time with it though since I've mostly been focused on decoding the remaining parts of the ROM for n64split.

I think it will take a lot of work to manually decompile to C. I've done a lot of the level scripts, some geo layout functions, and some cutscene code. I'm attaching what I have done to this post. Sometimes even the simplest routines take me an hour to decompile correctly though, so I worry about the scope of this project. I cannot allocate time for your decompilation project at present, but if there are any questions you have or anything I could add to n64split to make it easier on you, feel free to ask Smile

You may also be interested in a lot of the disassembly and decompilation work that Celler Dweller did years ago that Skelux has archived on his site: https://sites.google.com/site/supermario64starroad/home/sm64-documents/cellar-dweller

Finally, there are some automated tools to help decompile or get insight into the code. If you aren't scared of command line tools, radare2 is a really nice open source framework for reverse engineering and supports MIPS. For decompilation, REC (Reverse Engineering Compiler) or RecDec (Retargetable Decompiler) are tools I've used in the past. Outputs are less than ideal though.


Attached Files
Size: 9.07 KB / Downloads: 145 .zip   sm64_decompiled_c.zip


(03-10-2016, 12:12 AM)queueRAM Wrote: I really like the idea of this project. I had a similar idea of replacing some of the more interesting routines (such as behaviors and interactions) with C code to make them more easily customizable. I haven't spent too much time with it though since I've mostly been focused on decoding the remaining parts of the ROM for n64split.

I think it will take a lot of work to manually decompile to C. I've done a lot of the level scripts, some geo layout functions, and some cutscene code. I'm attaching what I have done to this post. Sometimes even the simplest routines take me an hour to decompile correctly though, so I worry about the scope of this project. I cannot allocate time for your decompilation project at present, but if there are any questions you have or anything I could add to n64split to make it easier on you, feel free to ask Smile

You may also be interested in a lot of the disassembly and decompilation work that Celler Dweller did years ago that Skelux has archived on his site: https://sites.google.com/site/supermario64starroad/home/sm64-documents/cellar-dweller

Finally, there are some automated tools to help decompile or get insight into the code. If you aren't scared of command line tools, radare2 is a really nice open source framework for reverse engineering and supports MIPS. For decompilation, REC (Reverse Engineering Compiler) or RecDec (Retargetable Decompiler) are tools I've used in the past. Outputs are less than ideal though.

Never said it'd be easy, and thanks for the resources BTW! Anyways, yeah, it'll take a while, and I'm using the ASM I got from your n64split as the base.

Maybe move this to Projects?

[EDIT]​ Thanks.
BTW I'm stuck at a particular point:
​http://pastebin.com/7bjhBDrE
(This post was last modified: 08-10-2016, 12:51 PM by Yoshimaster96.)

SM64 Decompilation Project!
Users browsing this thread: 1 Guest(s)