Reversing Games with Mupen64+

Edit on Github | Updated: 04 July 2020

This post covers how to Modify the Mupen64+ emulator to make reverse engineering an N64 game a breeze!

Input Overwrite

I like to show my own interface when certain buttons are pressed, so you need to modify eventloop.c: Original:

void event_sdl_keydown(int keysym, int keymod)
{
    int slot;

My modification

void cdl_keyevents(int keysym, int keymod);

void event_sdl_keydown(int keysym, int keymod)
{
    int slot;
    cdl_keyevents(keysym, keymod);

This allows you to create your own function (in this case its called cdl_keyevents) which can handle the sdl input, here is an example:

void cdl_keyevents(int keysym, int keymod) {
    printf("event_sdl_keydown %d %d \n", keysym, keymod);
    // S key
    if (keysym == 115) {
        printf("Lets save! \n");
        main_state_save(0, NULL);
    }
    // L Key
    if (keysym == 108) {
        printf("Lets load! \n");
        main_state_load(NULL);
    }
}