dumb changes

This commit is contained in:
Connor Olding 2016-02-09 00:11:03 -08:00
parent a111b309cb
commit ec865923a5
3 changed files with 449 additions and 643 deletions

424
adis.c
View file

@ -5,74 +5,94 @@
#include <stdio.h>
#include <stdlib.h>
#include "r3400i.h"
#include "adis.h"
#include <string.h>
#include <assert.h>
typedef void (*Handler)( unsigned long int word );
#define getRS(word)\
(unsigned int)(unsigned int)((word >> 21) & 31)
#define getRT(word)\
(unsigned int)((word >> 16) & 31)
#define getRD(word)\
(unsigned int)((word >> 11) & 31)
#define getSA(word)\
(unsigned int)((word >> 6) & 31)
/*
#define getFT(word)\
(unsigned int)((word >> 16) & 31)
#define getFS(word)\
(unsigned int)((word >> 11) & 31)
#define getFD(word)\
(unsigned int)((word >> 6) & 31)
*/
#define getFT(word)\
(unsigned int)(unsigned int)((word >> 21) & 31)
#define getFS(word)\
(unsigned int)((word >> 16) & 31)
#define getFD(word)\
(unsigned int)((word >> 11) & 31)
#define getBASE(word)\
(unsigned int)((word >> 21) & 31)
#define getIMM(word)\
(unsigned short int)(word & 0xFFFF)
#define getSIMM(word)\
(signed short int)(word & 0xFFFF)
#define getOFFSET(word)\
((signed short)(word & 0xFFFF)) * 4
#define getTARGET(word)\
(unsigned int)((word & 0x3FFFFFF) << 2)
#define flip32(word)\
(unsigned int)(((word&0xFF000000)>>24)|((word&0x00FF0000)>>8)|((word&0x0000FF00)<<8)|((word&0x000000FF)<<24))
#define flip16(value)\
(unsigned short) ((value&0xFF00)>>8) | ((value&0xFF)<<8)
typedef char u8;
typedef unsigned short u16;
typedef unsigned u32;
typedef signed char s8;
typedef signed short s16;
typedef signed s32;
typedef float f32;
typedef struct {
unsigned addr;
char * name;
} function;
unsigned int pc = 0x80000000;
char dis_op[100];
char *dis_op;
int map_branches;
int branches[1000];
int *branches;
int noBranches=0;
int EndOfFunction=-1;
unsigned local_start;
unsigned local_end;
int jaltaken=0;
int html = 0;
const char * actTypes[12]={
"Unknown",
"Prop",
"Unknown",
"Bomb",
"NPC",
"Enemy",
"Prop",
"Item/Action",
"Miscellaneous",
"Boss",
"Unknown",
"Door/Chest"
};
typedef union {
u8 ubyte[1048576];
s8 sbyte[1048576];
u16 uhalf[524288];
s16 shalf[524288];
u32 uword[262144];
s32 sword[262144];
f32 sfloat[262144];
} memoryUnion;
#ifdef OOTDEBUG
int target_count = 11;
#else
int target_count = 0;
#endif
char * mapped_functions;
function functions[256] = {
#ifdef OOTDEBUG
{0x80002130, "DebugMessage" },
{0x800FB3AC, "SetTextRGBA" },
{0x800FB41C, "SetTextXY" },
{0x800FBCB4, "SetTextString" },
{0x80031F50, "ActorSpawn" },
{0x801031E0, "sqrtf" },
{0x801067E0, "absf" },
{0x80104610, "cosf" },
{0x80100290, "sinf" },
{0x80104780, "coss" },
{0x80100450, "sins" }
#endif
};
//memoryUnion memory;
char *mapped_functions;
function **functions;
unsigned gpr_regs[32]={
0, 0, 0, 0, 0x802245B0, 0x80212020, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0x80160000, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
const char * gpr_rn[32]={
@ -96,19 +116,7 @@ const char * fpr_rn[32]={
"$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31"
};
void reset_gpr_regs(void)
{
int i;
for (i=0;i<32;i++)
{
gpr_regs[i]=0;
}
gpr_regs[4] = 0x802245B0;
gpr_regs[5] = 0x80212020;
gpr_regs[29] = 0x80160000;
}
void reset_gpr_regs_soft(void) /* for jals */
void reset_gpr_regs_soft(void)
{
gpr_regs[1] = 0;
gpr_regs[2] = 0;
@ -127,7 +135,6 @@ void reset_gpr_regs_soft(void) /* for jals */
gpr_regs[15] = 0;
gpr_regs[24] = 0;
gpr_regs[25] = 0;
}
int target2label(int addr)
@ -136,7 +143,7 @@ int target2label(int addr)
addr |= 0x80000000;
for (i=0; i<target_count; i++)
{
if (functions[i].addr == addr)
if (functions[i]->addr == addr)
return i;
}
return -1;
@ -152,8 +159,8 @@ int add_function(int addr, char * name)
for (i=0; i<32;i++)name_[i]=name[i];
functions[target_count].name = name_;
functions[target_count].addr = addr|0x80000000;
functions[target_count]->name = name_;
functions[target_count]->addr = addr|0x80000000;
target_count+=1;
return target_count-1;
@ -184,9 +191,6 @@ char * branch2label(int addr)
else
{
int lbl_no = isTarget(addr);
if (html)
sprintf(label, "<a href=\"#$lbl_%i\">$lbl_%i</a>", lbl_no, lbl_no);
else
sprintf(label, "$lbl_%i", lbl_no);
}
return label;
@ -654,8 +658,8 @@ void CFC1(unsigned long word)
void MTC1(unsigned long word)
{ //04 (04)
float * value = &gpr_regs[getRT(word)];
sprintf(dis_op, "mtc1\t%s, %s\t\t\t/* %s = %f */", gpr_rn[getRT(word)], fpr_rn[getFD(word)], fpr_rn[getFD(word)], *value );
float * value = (float *) &gpr_regs[getRT(word)];
sprintf(dis_op, "mtc1\t%s, %s\t; %s = %f", gpr_rn[getRT(word)], fpr_rn[getFD(word)], fpr_rn[getFD(word)], *value );
}
void DMTC1(unsigned long word)
@ -710,10 +714,10 @@ void L(unsigned long word)
}
Handler COP1_T[32] = {
MFC1, DMFC1, CFC1, COP1_NONE, MTC1, DMTC1, CTC1, COP1_NONE,
BC, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE,
S, D, COP1_NONE, COP1_NONE, W, L, COP1_NONE, COP1_NONE,
COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE
MFC1, DMFC1, CFC1, COP1_NONE, MTC1, DMTC1, CTC1, COP1_NONE,
BC, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE,
S, D, COP1_NONE, COP1_NONE, W, L, COP1_NONE, COP1_NONE,
COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE, COP1_NONE
};
/*
@ -863,7 +867,7 @@ void BGEZALL(unsigned long word)
Handler REGIMM_T[32] = {
BLTZ, BGEZ, BLTZL, BGEZL, NONE, NONE, NONE, NONE,
TGEI, TGEIU, TLTI, TLTIU, TEQI, NONE, TNEI, NONE,
BLTZAL,BGEZAL, BLTZALL,BGEZALL,NONE, NONE, NONE, NONE,
BLTZAL, BGEZAL, BLTZALL, BGEZALL, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE
};
@ -1031,8 +1035,7 @@ void AND(unsigned long word)
void OR(unsigned long word)
{ //37 (25)
gpr_regs[getRD(word)]=gpr_regs[getRS(word)] | gpr_regs[getRT(word)];
sprintf(dis_op, "or\t%s, %s, %s\t\t/*%s = %08X*/", gpr_rn[getRD(word)],gpr_rn[getRS(word)],gpr_rn[getRT(word)], gpr_rn[getRD(word)],gpr_regs[getRD(word)]);
sprintf(dis_op, "or\t%s, %s, %s\t; %s = %08X", gpr_rn[getRD(word)],gpr_rn[getRS(word)],gpr_rn[getRT(word)], gpr_rn[getRD(word)],gpr_regs[getRD(word)]);
}
void XOR(unsigned long word)
@ -1136,7 +1139,7 @@ void DSRA32(unsigned long word)
};
Handler SPECIAL_T[64] = {
SLL, NONE, SRL, SRA, SLLV, NONE, SRLV, SRAV,
JR, JALR, NONE, NONE, SYSCALL,BREAK, NONE, SYNC,
JR, JALR, NONE, NONE, SYSCALL, BREAK, NONE, SYNC,
MFHI, MTHI, MFLO, MTLO, DSLLV, NONE, DSRLV, DSRAV,
MULT, MULTU, DIV, DIVU, DMULT, DMULTU, DDIV, DDIVU,
ADD, ADDU, SUB, SUBU, AND, OR, XOR, NOR,
@ -1167,7 +1170,7 @@ void JAL(unsigned long word)
int functionno = target2label(target);
if(functionno >= 0)
{
sprintf(dis_op, "jal\t%s", functions[functionno].name);
sprintf(dis_op, "jal\t%s\t; %08X", functions[functionno]->name, target);
}
else
sprintf(dis_op, "jal\t0x%08X", target|0x80000000);
@ -1198,13 +1201,13 @@ void BGTZ(unsigned long word)
void ADDI(unsigned long word)
{ //08(08)
gpr_regs[getRT(word)] = gpr_regs[getRS(word)] + getSIMM(word);
sprintf(dis_op, "addi\t%s, %s, 0x%04X\t\t/*%s = %08X*/", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
sprintf(dis_op, "addi\t%s, %s, 0x%04X\t; %s = %08X", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
}
void ADDIU(unsigned long word)
{ //09(09)
gpr_regs[getRT(word)] = gpr_regs[getRS(word)] + getSIMM(word);
sprintf(dis_op, "addiu\t%s, %s, 0x%04X\t\t/*%s = %08X*/", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
sprintf(dis_op, "addiu\t%s, %s, 0x%04X\t; %s = %08X", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
}
void SLTI(unsigned long word)
@ -1220,25 +1223,25 @@ void SLTIU(unsigned long word)
void ANDI(unsigned long word)
{ //12(0C)
gpr_regs[getRT(word)] = gpr_regs[getRS(word)] & getIMM(word);
sprintf(dis_op, "andi\t%s, %s, 0x%04X\t\t/*%s = %08X*/", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
sprintf(dis_op, "andi\t%s, %s, 0x%04X\t; %s = %08X", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
}
void ORI(unsigned long word)
{ //13(0D)
gpr_regs[getRT(word)] = gpr_regs[getRS(word)] | getIMM(word);
sprintf(dis_op, "ori\t%s, %s, 0x%04X\t\t/*%s = %08X*/", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
sprintf(dis_op, "ori\t%s, %s, 0x%04X\t; %s = %08X", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
}
void XORI(unsigned long word)
{ //14(0E)
gpr_regs[getRT(word)] = gpr_regs[getRS(word)] ^ getIMM(word);
sprintf(dis_op, "xori\t%s, %s, 0x%04X\t\t/*%s = %08X*/", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
sprintf(dis_op, "xori\t%s, %s, 0x%04X\t; %s = %08X", gpr_rn[getRT(word)], gpr_rn[getRS(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
}
void LUI(unsigned long word)
{ //15(0F)
gpr_regs[getRT(word)] = getIMM(word)<<16;
sprintf(dis_op, "lui\t%s, 0x%04X\t\t/*%s = %08X*/", gpr_rn[getRT(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
sprintf(dis_op, "lui\t%s, 0x%04X\t; %s = %08X", gpr_rn[getRT(word)], getIMM(word), gpr_rn[getRT(word)], gpr_regs[getRT(word)]);
}
void COP0(unsigned long word)
@ -1440,7 +1443,7 @@ void SD(unsigned long word)
}
Handler MAIN_T[64] = {
SPECIAL,REGIMM,J, JAL, BEQ, BNE, BLEZ, BGTZ,
SPECIAL, REGIMM, J, JAL, BEQ, BNE, BLEZ, BGTZ,
ADDI, ADDIU, SLTI, SLTIU, ANDI, ORI, XORI, LUI,
COP0, COP1, NONE, NONE, BEQL, BNEL, BLEZL, BGTZL,
DADDI, DADDIU, LDL, LDR, NONE, NONE, NONE, NONE,
@ -1452,6 +1455,7 @@ SC, SWC1, NONE, NONE, SCD, SDC1, SDC2, SD
char * getOP(unsigned long int word)
{
//printf("%08X\n", (unsigned int) word);
MAIN_T[ word >> 26 ](word);
return dis_op;
}
@ -1462,69 +1466,42 @@ char * getOP(unsigned long int word)
int main(int argc, char * argv[])
{
int wordc=0;
int i;
char * buff;
int argcp=1;
int arge=argc-2;
char * outname;
FILE * outputf;
FILE * ROM;
int targetnum;
int ATABLE_START= OOT_DEBUG_ATABLE_START;
int NAMETABLE_ADD = 0xA771A0;
int output=0;
html = 0;
int little_endian = 0;
int anum;
int text_size, data_size, rodata_size, bss_size, rel_count;
//puts("test");
/* Well gee I hope they gave enough arguments */
if(argc < 3)
#define XBOX_HUGE (1024*1024*8)
char *tmp = calloc(1, XBOX_HUGE);
dis_op = calloc(1, XBOX_HUGE);
branches = calloc(1, XBOX_HUGE);
mapped_functions = calloc(1, XBOX_HUGE);
#define FUNCTIONS (XBOX_HUGE / sizeof(function))
functions = calloc(1, FUNCTIONS);
function *functions_data = calloc(1, FUNCTIONS);
for (i = 0; i < FUNCTIONS; i++) {
functions[i] = functions_data;
functions_data += sizeof(function);
}
/* Well gee scooby I hope they gave enough arguments */
if(argc != 2)
{
printf("invalid usage\n");
printf("usage: %s {code file} \n", argv[0]);
return EXIT_FAILURE;
}
/* Actor number*/
sscanf(argv[arge], "%i", &anum);
FILE *outputf=stdout;
/* Parse options */
while (argcp < arge)
{
if(!strcmp(argv[argcp],"o")) /* output */
{
argcp++;
output=1;
outname = argv[argcp];
}
else if(!strcmp(argv[argcp],"f")) /* format to html */
html=1;
else if(!strcmp(argv[argcp],"at")){ /* set actor table offset */
argcp++;
sscanf(argv[argcp],"%x", &ATABLE_START);
argcp++;
sscanf(argv[argcp],"%x", &NAMETABLE_ADD);
}
else
printf("Unknown/unhandled argument: %s\n", argv[argcp]);
argcp++;
}
//printf("Output: %s\n", outname);
if (output)
outputf=fopen(outname, "w");
else
outputf=stdout;
ROM = fopen(argv[arge+1],"rb");
ROM = fopen(argv[1],"rb");
if (!ROM)
{
printf("Error opening file `%s`\n",argv[arge]);
printf("Error opening file `%s`\n",argv[1]);
return EXIT_FAILURE;
}
/* Read ROM */
fseek(ROM, 0, SEEK_END);
int fend = ftell(ROM);
rewind(ROM);
@ -1532,75 +1509,21 @@ int main(int argc, char * argv[])
fread(buff, 1, fend, ROM);
fclose(ROM);
/* Interpret ROM */
actorCodeEntry (*actors)[470] = (void*)(ATABLE_START + buff);
//#define RAM_CODE 0x8001CE60 // TODO: don't hardcode
#define RAM_CODE 0x800110A0 // TODO: don't hardcode
pc=RAM_CODE;
// int text_size = 0xF5260; // TODO: don't hardcode
int text_size = 0xD206C; // TODO: don't hardcode
//int data_size = fend - text_size;
//int rodata_size = 0; // TODO?
int actorsize = (flip32((*actors)[anum].rom_end) - flip32((*actors)[anum].rom_start));
char * actor = (char*)(flip32((*actors)[anum].rom_start) + buff);
unsigned long *header_inset = (void*)(actor + actorsize - 4);
local_start = flip32((*actors)[anum].virtual_start);
local_end = flip32((*actors)[anum].virtual_end);
char * aname = (char*) ( (flip32((*actors)[anum].name)&0xFFFFFF) + NAMETABLE_ADD + buff );
actorHeader *actorHeader = (void*)(actor + actorsize - flip32(*header_inset));
actorInformation *actorInfo = (void*)(actor + (flip32((*actors)[anum].virtual_ainfo) - local_start));
text_size = flip32(actorHeader->text_size);
data_size = flip32(actorHeader->data_size);
rodata_size = flip32(actorHeader->rodata_size);
bss_size = flip32(actorHeader->bss_size);
rel_count = flip32(actorHeader->rel_count);
unsigned long (*words)[] = (void*)actor;
if (html)
fprintf(outputf, "<html>\n <head>\n <title>%s Notes</title>\n </head>\n <body>\n <pre lang=\"C\">\n#include &lt;mips.h&gt;", aname);
else
fprintf(outputf, "#include <mips.h>");
fprintf(outputf, "\n\n/*\n INFO:\n Actor %i \"%s\"\n ROM offsets 0x%08X-0x%08X\n Virtual offsets: 0x%08X-0x%08X\n .text size: 0x%08X\n .data size: 0x%08X\n .rodata size: 0x%08X\n .bss size: 0x%08X\n Initial register values used in comments:\n a0: 0x%08X\n a1: 0x%08X\n sp: 0x%08X\n Others: 0\n \n Type: %s (%02X)\n Object: %04X\n\n generated by %s\n*/\n\n\n",
anum,
aname,
flip32((*actors)[anum].rom_start),
flip32((*actors)[anum].rom_end),
local_start,
local_end,
text_size,
data_size,
rodata_size,
bss_size,
gpr_regs[4],
gpr_regs[5],
gpr_regs[29],
actTypes[actorInfo->type],
actorInfo->type,
flip16(actorInfo->object_number),
argv[0]
);
unsigned long (*words)[] = (void*)buff;
map_branches = 1;
int function_count=0;
pc=local_start;
/* Read relocations - TODO */
char tmp [32];
sprintf(tmp, "%s_Init", aname);
add_function(flip32(actorInfo->init_func), tmp);
if(actorInfo->draw_func){
sprintf(tmp, "%s_Draw", aname);
add_function(flip32(actorInfo->draw_func), tmp);
}
sprintf(tmp, "%s_Exec", aname);
if(actorInfo->code_func){
add_function(flip32(actorInfo->code_func), tmp);
sprintf(tmp, "%s_Other", aname);
}
if(actorInfo->unknown_func){
add_function(flip32(actorInfo->unknown_func), tmp);
sprintf(tmp, "%s_Func_0", aname);
}
sprintf(tmp, "code_Func_0");
add_function(pc, tmp);
function_count=1;
mapped_functions = malloc(256);
//memset(mapped_functions, 0x0, 256);
function_count++;
/* First scan - just to map out branches/jumps */
for (i=0; i<(text_size >> 2); i++)
@ -1610,37 +1533,35 @@ int main(int argc, char * argv[])
getOP( flip32((*words)[i]) );
if((*words)[i])
{
sprintf(tmp, "%s_Func_%i", aname, function_count);
if(add_function(pc, &tmp[0]))function_count++;
reset_gpr_regs();
sprintf(tmp, "code_Func_%i", function_count);
//puts(tmp);
if(add_function(pc, tmp))function_count++;
reset_gpr_regs_soft();
}
else
EndOfFunction+=4;
}
getOP( flip32((*words)[i]));
getOP(flip32((*words)[i]));
pc+=4;
}
pc = local_start;
pc=RAM_CODE;
map_branches = 0;
reset_gpr_regs();
reset_gpr_regs_soft();
//FILE * conf = fopen("conf.ld", "w");
fprintf(outputf, "\n\n/*\n");
/*
fprintf(outputf, "/\*\n");
for (i=0; i<target_count; i++)
{
fprintf(outputf, "%s = 0x%08X;\n", functions[i].name, functions[i].addr);
fprintf(outputf, "%s = 0x%08X;\n", functions[i]->name, functions[i]->addr);
}
fprintf(outputf, "*/\n\n\t.text\n\t\n\t\n");
//fclose(conf);
fprintf(outputf, "*\/\n\n\t.text\n\t\n\t\n");
*/
char currFuncName[32];
sprintf(currFuncName, "%s", functions[target2label(pc)].name);
char currFuncName[256];
sprintf(currFuncName, "code_Func_0");
fprintf(outputf, "\t.set\tnoreorder\n\t.set\tnoat\n\t.global\t%s\n\t.ent\t%s\n\n", currFuncName, currFuncName);
if (html)
fprintf(outputf, "<a href=\"#%s\" name=\"%s\">%s</a>:\t/* %08X */\n\n", currFuncName, currFuncName, currFuncName, pc);
else
fprintf(outputf, "%s:\t/* %08X */\n\n", currFuncName, pc);
//fprintf(outputf, "\t.set\tnoreorder\n\t.set\tnoat\n\t.global\t%s\n\t.ent\t%s\n\n", currFuncName, currFuncName);
fprintf(outputf, "\n%s:\t\t\t; %08X (%08X)\n", currFuncName, pc, pc - RAM_CODE);
function_count=1;
/* Second scan - fprintf()s */
@ -1654,29 +1575,26 @@ int main(int argc, char * argv[])
{
int functionno = target2label(pc);
if(functionno >= 0)
sprintf(currFuncName, "%s", functions[functionno].name);
sprintf(currFuncName, "%s", functions[functionno]->name);
else
sprintf(currFuncName, "function_%08X", pc|0x80000000);
fprintf(outputf, "\t.set\tnoreorder\n\t.set\tnoat\n\t.global\t%s\n\t.ent\t%s\n\n",currFuncName, currFuncName);
if (html)
fprintf(outputf, "<a href=\"#%s\" name=\"%s\">%s</a>:\t/* %08X */\n\n", currFuncName, currFuncName, currFuncName, pc);
else
fprintf(outputf, "%s:\t/* %08X */\n\n", currFuncName, pc);
//fprintf(outputf, "\t.set\tnoreorder\n\t.set\tnoat\n\t.global\t%s\n\t.ent\t%s\n\n",currFuncName, currFuncName);
fprintf(outputf, "\n%s:\t\t\t; %08X (%08X)\n", currFuncName, pc, pc - RAM_CODE);
function_count++;
reset_gpr_regs();
EndOfFunction = -1;
}
else
EndOfFunction+=4;
}
fprintf(outputf, "\t%s\n", getOP( flip32((*words)[i]) ));
fprintf(outputf, " \t%s\n", getOP( flip32((*words)[i]) ));
gpr_regs[0] = 0; /* Just in case anything tries to change $zero */
if (pc == EndOfFunction && !(mapped_functions[function_count]))
{
mapped_functions[function_count] = 1;
fprintf(outputf, "\n\t.end\t%s\n\t.set\tat\n\t.set\tnoreorder\n\n /* #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# */\n\n",currFuncName);
//fprintf(outputf, "\n\t.end\t%s\n\t.set\tat\n\t.set\tnoreorder\n\n",currFuncName);
//fprintf(outputf, "\n/* ~~~~~~~~~~ */\n");
}
if (jaltaken)
@ -1690,32 +1608,30 @@ int main(int argc, char * argv[])
targetnum=isTarget(pc+4);
if (targetnum>0)
if (html)
fprintf(outputf, "<a href=\"#$lbl_%i\" name=\"$lbl_%i\">$lbl_%i</a>:\n", targetnum, targetnum, targetnum);
else
fprintf(outputf, "$lbl_%i:\n", targetnum);
fprintf(outputf, "$lbl_%i:\t\t\t; %08X\n", targetnum, pc);
}
local_start = flip32((*actors)[anum].virtual_start);
fprintf(outputf, "\n/* TODO: */\n\n\n\t.data\n\n\t/*\n\tAddr: %08X\n\t\n\t",local_start+text_size);
int j;
for (i=text_size; i<text_size+data_size; i+=16)
{
for (j=i;j<i+16;j+=4)
fprintf(outputf, "%08X ", flip32((*words)[j>>2]));
fprintf(outputf, "\n\t");
}
fprintf(outputf, "\n\t*/\n\n\t.rodata\n\n\t/*\n\tAddr: %08X\n\t\n\t",local_start+text_size+rodata_size);
// fprintf(outputf, "\n\n\n\t.data\n\n\t/*\n\tAddr: %08X\n\t\n\t",text_size);
// int j;
// for (i=text_size; i<text_size+data_size; i+=16)
// {
// /*
// for (j=i;j<i+16;j+=4)
// fprintf(outputf, "%08X ", flip32((*words)[j>>2]));
// fprintf(outputf, "\n\t");
// */
// }
// if (rodata_size > 0)
// fprintf(outputf, "\n\t*/\n\n\t.rodata\n\n\t/*\n\tAddr: %08X\n\t\n\t",text_size+rodata_size);
//
// for (; i<text_size+data_size+rodata_size; i+=16)
// {
// for (j=i;j<i+16;j+=4)
// fprintf(outputf, "%08X ", flip32((*words)[j>>2]));
// fprintf(outputf, "\n\t");
// }
// fprintf(outputf, "\n\t*/\n");
for (; i<text_size+data_size+rodata_size; i+=16)
{
for (j=i;j<i+16;j+=4)
fprintf(outputf, "%08X ", flip32((*words)[j>>2]));
fprintf(outputf, "\n\t");
}
fprintf(outputf, "\n\t*/\n");
if (html)
fprintf(outputf, " </pre>\n </body>\n</html>");
fclose(outputf);
free(buff);

54
adis.h
View file

@ -1,54 +0,0 @@
/*
sinep
*/
#define OOT_DEBUG_ATABLE_START 0x00B8D440
typedef char u8;
typedef unsigned short u16;
typedef unsigned u32;
typedef signed char s8;
typedef signed short s16;
typedef signed s32;
typedef float f32;
typedef struct {
unsigned text_size;
unsigned data_size;
unsigned rodata_size;
unsigned bss_size;
unsigned rel_count;
} actorHeader;
typedef struct {
unsigned rom_start;
unsigned rom_end;
unsigned virtual_start;
unsigned virtual_end;
unsigned unknown_0;
unsigned virtual_ainfo;
unsigned name;
unsigned unknown_1;
} actorCodeEntry;
typedef struct {
unsigned short number;
unsigned char type;
unsigned char status;
unsigned long unknown_0;
unsigned short object_number;
unsigned short unknown_1;
unsigned long unknown_2;
unsigned long init_func;
unsigned long code_func;
unsigned long draw_func;
unsigned long unknown_func;
} actorInformation;
typedef struct {
unsigned addr;
char * name;
} function;

View file

@ -1,56 +0,0 @@
/*
r3400i.h
*/
typedef void (*Handler)( unsigned long int word );
#define getRS(word)\
(unsigned int)(unsigned int)((word >> 21) & 31)
#define getRT(word)\
(unsigned int)((word >> 16) & 31)
#define getRD(word)\
(unsigned int)((word >> 11) & 31)
#define getSA(word)\
(unsigned int)((word >> 6) & 31)
/*
#define getFT(word)\
(unsigned int)((word >> 16) & 31)
#define getFS(word)\
(unsigned int)((word >> 11) & 31)
#define getFD(word)\
(unsigned int)((word >> 6) & 31)
*/
#define getFT(word)\
(unsigned int)(unsigned int)((word >> 21) & 31)
#define getFS(word)\
(unsigned int)((word >> 16) & 31)
#define getFD(word)\
(unsigned int)((word >> 11) & 31)
#define getBASE(word)\
(unsigned int)((word >> 21) & 31)
#define getIMM(word)\
(unsigned short int)(word & 0xFFFF)
#define getSIMM(word)\
(signed short int)(word & 0xFFFF)
#define getOFFSET(word)\
((signed short)(word & 0xFFFF)) * 4
#define getTARGET(word)\
(unsigned int)((word & 0x3FFFFFF) << 2)
#define flip32(word)\
(unsigned int)(((word&0xFF000000)>>24)|((word&0x00FF0000)>>8)|((word&0x0000FF00)<<8)|((word&0x000000FF)<<24))
#define flip16(value)\
(unsigned short) ((value&0xFF00)>>8) | ((value&0xFF)<<8)