Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Macros | Functions
libsm64.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libmio0.h"
#include "libsm64.h"
#include "utils.h"

Data Structures

struct  ptr_t
 

Macros

#define IN_START_ADDR   0x000D0000
 
#define OUT_START_ADDR   0x00800000
 
#define OPCODE(IBUF_)   ((IBUF_)[0] & 0xFC)
 
#define RS(IBUF_)   ( (((IBUF_)[0] & 0x3) < 3) | (((IBUF_)[1] & 0xE0) > 5) )
 
#define RT(IBUF_)   ((IBUF_)[1] & 0x1F)
 
#define MAX_PTRS   128
 
#define COMPRESSED_LENGTH   2
 

Functions

static int find_ptr (unsigned int ptr, ptr_t table[], int count)
 
static int find_mio0 (unsigned char *buf, unsigned int length, ptr_t table[])
 
static void find_pointers (unsigned char *buf, unsigned int length, ptr_t table[], int count)
 
static unsigned int la2int (unsigned char *buf, unsigned int lui, unsigned int addiu)
 
static void find_asm_pointers (unsigned char *buf, ptr_t table[], int count)
 
static void sm64_adjust_pointers (unsigned char *buf, unsigned int length, ptr_t table[], int count)
 
static void sm64_adjust_asm (unsigned char *buf, ptr_t table[], int count)
 
static void sm64_calc_checksums (unsigned char *buf, unsigned int cksum[])
 
rom_type sm64_rom_type (unsigned char *buf, unsigned int length)
 
rom_version sm64_rom_version (unsigned char *buf)
 
void sm64_decompress_mio0 (const sm64_config *config, unsigned char *in_buf, unsigned int in_length, unsigned char *out_buf)
 
void sm64_update_checksums (unsigned char *buf)
 

Macro Definition Documentation

◆ COMPRESSED_LENGTH

#define COMPRESSED_LENGTH   2

◆ IN_START_ADDR

#define IN_START_ADDR   0x000D0000

◆ MAX_PTRS

#define MAX_PTRS   128

◆ OPCODE

#define OPCODE (   IBUF_)    ((IBUF_)[0] & 0xFC)

◆ OUT_START_ADDR

#define OUT_START_ADDR   0x00800000

◆ RS

#define RS (   IBUF_)    ( (((IBUF_)[0] & 0x3) < 3) | (((IBUF_)[1] & 0xE0) > 5) )

◆ RT

#define RT (   IBUF_)    ((IBUF_)[1] & 0x1F)

Function Documentation

◆ find_asm_pointers()

static void find_asm_pointers ( unsigned char buf,
ptr_t  table[],
int  count 
)
static

◆ find_mio0()

static int find_mio0 ( unsigned char buf,
unsigned int  length,
ptr_t  table[] 
)
static

◆ find_pointers()

static void find_pointers ( unsigned char buf,
unsigned int  length,
ptr_t  table[],
int  count 
)
static

◆ find_ptr()

static int find_ptr ( unsigned int  ptr,
ptr_t  table[],
int  count 
)
static

◆ la2int()

static unsigned int la2int ( unsigned char buf,
unsigned int  lui,
unsigned int  addiu 
)
static

◆ sm64_adjust_asm()

static void sm64_adjust_asm ( unsigned char buf,
ptr_t  table[],
int  count 
)
static

◆ sm64_adjust_pointers()

static void sm64_adjust_pointers ( unsigned char buf,
unsigned int  length,
ptr_t  table[],
int  count 
)
static

◆ sm64_calc_checksums()

static void sm64_calc_checksums ( unsigned char buf,
unsigned int  cksum[] 
)
static

◆ sm64_decompress_mio0()

void sm64_decompress_mio0 ( const sm64_config config,
unsigned char in_buf,
unsigned int  in_length,
unsigned char out_buf 
)

◆ sm64_rom_type()

rom_type sm64_rom_type ( unsigned char buf,
unsigned int  length 
)

◆ sm64_rom_version()

rom_version sm64_rom_version ( unsigned char buf)

◆ sm64_update_checksums()

void sm64_update_checksums ( unsigned char buf)