Refresh 2

This commit is contained in:
n64 committed 2019-10-05 15:08:05 -04:00
1 parent 1ef98ec785
commit 52e605f075
316 files changed
+16344 -16365

No files matched your search

+47 -44
View File
@@ -20,7 +20,7 @@
#include "goddard/renderer.h"
#include "game/profiler.h"
#define CMD_GET(type, offset) (*(type *) (offset + (u8 *) sCurrentCmd))
#define CMD_GET(type, offset) (*(type *) ((offset) + (u8 *) sCurrentCmd))
// These are equal
#define CMD_NEXT ((struct LevelCommand *) ((u8 *) sCurrentCmd + sCurrentCmd->size))
@@ -34,7 +34,7 @@ struct LevelCommand {
enum ScriptStatus { SCRIPT_RUNNING = 1, SCRIPT_PAUSED = 0, SCRIPT_PAUSED2 = -1 };
static u32 sStack[32];
static uintptr_t sStack[32];
static struct AllocOnlyPool *sLevelPool = NULL;
@@ -43,8 +43,8 @@ static u16 sDelayFrames2 = 0;
static s16 sCurrAreaIndex = -1;
static u32 *sStackTop = sStack;
static u32 *sStackBase = NULL;
static uintptr_t *sStackTop = sStack;
static uintptr_t *sStackBase = NULL;
static s16 sScriptStatus;
static s32 sRegister;
@@ -85,32 +85,33 @@ static s32 eval_script_op(s8 op, s32 arg) {
static void level_cmd_load_and_execute(void) {
main_pool_push_state();
load_segment(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8), MEMORY_POOL_LEFT);
load_segment(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 4 + sizeof(void *)), MEMORY_POOL_LEFT);
*sStackTop++ = (u32) NEXT_CMD;
*sStackTop++ = (u32) sStackBase;
*sStackTop++ = (uintptr_t) NEXT_CMD;
*sStackTop++ = (uintptr_t) sStackBase;
sStackBase = sStackTop;
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 12));
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 4 + 2 * sizeof(void *)));
}
static void level_cmd_exit_and_execute(void) {
void *targetAddr = CMD_GET(void *, 12);
void *targetAddr = CMD_GET(void *, 4 + 2 * sizeof(void *));
main_pool_pop_state();
main_pool_push_state();
load_segment(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8), MEMORY_POOL_LEFT);
load_segment(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 4 + sizeof(void *)),
MEMORY_POOL_LEFT);
sStackTop = sStackBase;
sCurrentCmd = (struct LevelCommand *) segmented_to_virtual(targetAddr);
sCurrentCmd = segmented_to_virtual(targetAddr);
}
static void level_cmd_exit(void) {
main_pool_pop_state();
sStackTop = sStackBase;
sStackBase = (u32 *) *(--sStackTop);
sStackBase = (uintptr_t *) *(--sStackTop);
sCurrentCmd = (struct LevelCommand *) *(--sStackTop);
}
@@ -137,12 +138,12 @@ static void level_cmd_sleep2(void) {
}
static void level_cmd_jump(void) {
sCurrentCmd = (struct LevelCommand *) segmented_to_virtual(CMD_GET(void *, 4));
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 4));
}
static void level_cmd_jump_and_link(void) {
*sStackTop++ = (u32) NEXT_CMD;
sCurrentCmd = (struct LevelCommand *) segmented_to_virtual(CMD_GET(void *, 4));
*sStackTop++ = (uintptr_t) NEXT_CMD;
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 4));
}
static void level_cmd_return(void) {
@@ -150,7 +151,7 @@ static void level_cmd_return(void) {
}
static void level_cmd_jump_and_link_push_arg(void) {
*sStackTop++ = (u32) NEXT_CMD;
*sStackTop++ = (uintptr_t) NEXT_CMD;
*sStackTop++ = CMD_GET(s16, 2);
sCurrentCmd = CMD_NEXT;
}
@@ -170,7 +171,7 @@ static void level_cmd_jump_repeat(void) {
}
static void level_cmd_loop_begin(void) {
*sStackTop++ = (u32) NEXT_CMD;
*sStackTop++ = (uintptr_t) NEXT_CMD;
*sStackTop++ = 0;
sCurrentCmd = CMD_NEXT;
}
@@ -186,7 +187,7 @@ static void level_cmd_loop_until(void) {
static void level_cmd_jump_if(void) {
if (eval_script_op(CMD_GET(u8, 2), CMD_GET(s32, 4)) != 0) {
sCurrentCmd = (struct LevelCommand *) segmented_to_virtual(CMD_GET(void *, 8));
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 8));
} else {
sCurrentCmd = CMD_NEXT;
}
@@ -194,8 +195,8 @@ static void level_cmd_jump_if(void) {
static void level_cmd_jump_and_link_if(void) {
if (eval_script_op(CMD_GET(u8, 2), CMD_GET(s32, 4)) != 0) {
*sStackTop++ = (u32) NEXT_CMD;
sCurrentCmd = (struct LevelCommand *) segmented_to_virtual(CMD_GET(void *, 8));
*sStackTop++ = (uintptr_t) NEXT_CMD;
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 8));
} else {
sCurrentCmd = CMD_NEXT;
}
@@ -263,27 +264,29 @@ static void level_cmd_pop_pool_state(void) {
}
static void level_cmd_load_to_fixed_address(void) {
load_to_fixed_pool_addr(CMD_GET(void *, 4), CMD_GET(void *, 8), CMD_GET(void *, 12));
load_to_fixed_pool_addr(CMD_GET(void *, 4), CMD_GET(void *, 4 + sizeof(void *)),
CMD_GET(void *, 4 + 2 * sizeof(void *)));
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_load_segment(void) {
load_segment(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8), MEMORY_POOL_LEFT);
static void level_cmd_load_raw(void) {
load_segment(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 4 + sizeof(void *)),
MEMORY_POOL_LEFT);
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_load_compressed_segment(void) {
load_segment_decompress(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8));
static void level_cmd_load_mio0(void) {
load_segment_decompress(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 4 + sizeof(void *)));
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_19(void) {
static void level_cmd_load_mario_head(void) {
// TODO: Fix these hardcoded sizes
void *addr = main_pool_alloc(0xE1000, MEMORY_POOL_LEFT);
if (addr != NULL) {
gdm_init(addr, 0xE1000);
gd_add_to_heap(gZBuffer, 0x25800);
gd_add_to_heap(gFrameBuffer0, 0x70800);
gd_add_to_heap(gZBuffer, SCREEN_WIDTH * SCREEN_HEIGHT * 2); // 0x25800
gd_add_to_heap(gFrameBuffer0, SCREEN_WIDTH * SCREEN_HEIGHT * 2 * 3); // 0x70800
gdm_setup();
gdm_maketestdl(CMD_GET(s16, 2));
} else {
@@ -292,8 +295,8 @@ static void level_cmd_19(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_1A(void) {
func_80278304(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8));
static void level_cmd_load_mio0_texture(void) {
func_80278304(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 4 + sizeof(void *)));
sCurrentCmd = CMD_NEXT;
}
@@ -368,7 +371,7 @@ static void level_cmd_end_area(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_21(void) {
static void level_cmd_load_model_from_dl(void) {
s16 val1 = CMD_GET(s16, 2) & 0x0FFF;
s16 val2 = CMD_GET(u16, 2) >> 12;
void *val3 = CMD_GET(void *, 4);
@@ -381,7 +384,7 @@ static void level_cmd_21(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_22(void) {
static void level_cmd_load_model_from_geo(void) {
s16 arg0 = CMD_GET(s16, 2);
void *arg1 = CMD_GET(void *, 4);
@@ -401,8 +404,8 @@ static void level_cmd_23(void) {
s16 model = CMD_GET(s16, 2) & 0x0FFF;
s16 arg0H = CMD_GET(u16, 2) >> 12;
void *arg1 = CMD_GET(void *, 4);
arg2.i = CMD_GET(s32, 8); // store the raw word as a union s32. this allows is to reinterpret the
// contents as a f32 without the value being converted implicitly.
// load an f32, but using an integer load instruction for some reason (hence the union)
arg2.i = CMD_GET(s32, 4 + sizeof(void *));
if (model < 256) {
// GraphNodeScale has a GraphNode at the top. This
@@ -603,7 +606,7 @@ static void level_cmd_set_rooms(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_39(void) {
static void level_cmd_set_macro_objects(void) {
if (sCurrAreaIndex != -1) {
gAreas[sCurrAreaIndex].macroObjects = segmented_to_virtual(CMD_GET(void *, 4));
}
@@ -655,7 +658,7 @@ static void level_cmd_nop(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_30(void) {
static void level_cmd_show_dialog(void) {
if (sCurrAreaIndex != -1) {
if (CMD_GET(u8, 2) < 2) {
gAreas[sCurrAreaIndex].dialog[CMD_GET(u8, 2)] = CMD_GET(u8, 3);
@@ -748,18 +751,18 @@ static void (*LevelScriptJumpTable[])(void) = {
/*14*/ level_cmd_push_pool_state,
/*15*/ level_cmd_pop_pool_state,
/*16*/ level_cmd_load_to_fixed_address,
/*17*/ level_cmd_load_segment,
/*18*/ level_cmd_load_compressed_segment,
/*19*/ level_cmd_19,
/*1A*/ level_cmd_1A,
/*17*/ level_cmd_load_raw,
/*18*/ level_cmd_load_mio0,
/*19*/ level_cmd_load_mario_head,
/*1A*/ level_cmd_load_mio0_texture,
/*1B*/ level_cmd_init_level,
/*1C*/ level_cmd_clear_level,
/*1D*/ level_cmd_alloc_level_pool,
/*1E*/ level_cmd_free_level_pool,
/*1F*/ level_cmd_begin_area,
/*20*/ level_cmd_end_area,
/*21*/ level_cmd_21,
/*22*/ level_cmd_22,
/*21*/ level_cmd_load_model_from_dl,
/*22*/ level_cmd_load_model_from_geo,
/*23*/ level_cmd_23,
/*24*/ level_cmd_place_object,
/*25*/ level_cmd_init_mario,
@@ -773,7 +776,7 @@ static void (*LevelScriptJumpTable[])(void) = {
/*2D*/ level_cmd_2D,
/*2E*/ level_cmd_set_terrain_data,
/*2F*/ level_cmd_set_rooms,
/*30*/ level_cmd_30,
/*30*/ level_cmd_show_dialog,
/*31*/ level_cmd_set_terrain_type,
/*32*/ level_cmd_nop,
/*33*/ level_cmd_set_transition,
@@ -782,7 +785,7 @@ static void (*LevelScriptJumpTable[])(void) = {
/*36*/ level_cmd_set_music,
/*37*/ level_cmd_set_menu_music,
/*38*/ level_cmd_38,
/*39*/ level_cmd_39,
/*39*/ level_cmd_set_macro_objects,
/*3A*/ level_cmd_3A,
/*3B*/ level_cmd_create_whirlpool,
/*3C*/ level_cmd_get_or_set_var,