romhack.h 1.34 KB
#ifndef __ROMHACK_H__
#define __ROMHACK_H__

#include <list>
#include <hash_map.h>
using namespace std;

typedef unsigned char u8;
typedef unsigned long u32;
typedef signed long s32;

typedef enum {
    R_MIPS_26,
    R_MIPS_LO16,
    R_MIPS_HI16,
} reltype_t;

typedef struct {
    char *symbol;
    u32 hi;
    u32 lo;
    u8 found;
    u32 size;
} sym_t;

typedef struct {
    u32 index;
    u32 hi_offset;
    u32 lo_offset;
    reltype_t type;
    sym_t *sym;
    u32 text;
} rel_t;

typedef struct {
    char *symbol;
    u32 num_ops;
    u32 first_op;
    u32 first_mask;
    u32 crc;
    u32 partial_crc;
    list<u32> offsets;
    list<rel_t*> relocs;
    u8  ambiguous;
} sig_t;

struct eqstr
{
    bool operator()(const char* s1, const char* s2) const {
        return strcmp(s1, s2) == 0;
    }
};

typedef hash_map<char *, sig_t *, hash<char *>, eqstr> sigmap_t;
typedef hash_map<char *, sym_t *, hash<char *>, eqstr> symmap_t;

typedef struct {
    char *symbol;
    u32 offset;
} override_t;

typedef struct {
    u32 src;
    u32 dst;
} dynamic_t;

typedef struct {
    u32 data[20];
} vimode_t;

void make_crc_table();
extern u32 crc32(u32 crc, u8* buf, u32 len);

extern int do_pal;

void scan_rom(u8* rom, u32 rom_len, sigmap_t &sigs);
void patch_vitbl(u8*rom, u32 rom_len);

void read_library(char *, symmap_t &, sigmap_t &);

#endif /* __ROMHACK_H__ */