Refresh 2

This commit is contained in:
n64
2019-10-05 15:08:05 -04:00
parent 1ef98ec785
commit 52e605f075
316 changed files with 16346 additions and 16367 deletions
+54 -54
View File
@@ -16,8 +16,8 @@
static u16 gRandomSeed16;
// unused
static void func_80383B70(u32 segptr) {
gBehCommand = segmented_to_virtual((void *) segptr);
static void func_80383B70(void *segptr) {
gBehCommand = segmented_to_virtual(segptr);
gCurrentObject->stackIndex = 0;
}
@@ -72,13 +72,13 @@ void func_80383D68(struct Object *object) {
object->header.gfx.angle[2] = object->oFaceAngleRoll & 0xFFFF;
}
static void cur_object_stack_push(u32 value) {
static void cur_object_stack_push(uintptr_t value) {
gCurrentObject->stack[gCurrentObject->stackIndex] = value;
gCurrentObject->stackIndex++;
}
static u32 cur_object_stack_pop(void) {
u32 value;
static uintptr_t cur_object_stack_pop(void) {
uintptr_t value;
gCurrentObject->stackIndex--;
value = gCurrentObject->stack[gCurrentObject->stackIndex];
return value;
@@ -117,7 +117,7 @@ static s32 beh_cmd_graph_node(void) {
}
static s32 beh_cmd_obj_load_chill(void) {
u32 model = gBehCommand[1];
u32 model = (u32) gBehCommand[1];
void *arg1 = (void *) gBehCommand[2];
struct Object *object = spawn_object_at_origin(gCurrentObject, 0, model, arg1);
@@ -129,7 +129,7 @@ static s32 beh_cmd_obj_load_chill(void) {
}
static s32 beh_cmd_obj_spawn(void) {
u32 model = gBehCommand[1];
u32 model = (u32) gBehCommand[1];
void *arg1 = (void *) gBehCommand[2];
struct Object *object = spawn_object_at_origin(gCurrentObject, 0, model, arg1);
@@ -144,7 +144,7 @@ static s32 beh_cmd_obj_spawn(void) {
static s32 beh_cmd_obj_load_chill_param(void) {
u32 behParam = (s16)(gBehCommand[0] & 0xFFFF);
u32 model = gBehCommand[1];
u32 model = (u32) gBehCommand[1];
void *arg2 = (void *) gBehCommand[2];
struct Object *object = spawn_object_at_origin(gCurrentObject, 0, model, arg2);
@@ -172,23 +172,23 @@ static s32 beh_cmd_break2(void) {
}
static s32 beh_cmd_call(void) {
u32 *jumpAddress;
uintptr_t *jumpAddress;
gBehCommand++;
cur_object_stack_push((u32)(gBehCommand + 1));
jumpAddress = (u32 *) segmented_to_virtual((void *) gBehCommand[0]);
cur_object_stack_push((uintptr_t)(gBehCommand + 1));
jumpAddress = segmented_to_virtual((void *) gBehCommand[0]);
gBehCommand = jumpAddress;
return BEH_CONTINUE;
}
static s32 beh_cmd_return(void) {
gBehCommand = (u32 *) cur_object_stack_pop();
gBehCommand = (uintptr_t *) cur_object_stack_pop();
return BEH_CONTINUE;
}
static s32 beh_cmd_delay(void) {
s16 arg0 = gBehCommand[0] & 0xFFFF;
s16 arg0 = (s16)(gBehCommand[0] & 0xFFFF);
if (gCurrentObject->unk1F4 < arg0 - 1) {
gCurrentObject->unk1F4++;
@@ -201,7 +201,7 @@ static s32 beh_cmd_delay(void) {
}
static s32 beh_cmd_delay_var(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 arg0 = cur_object_get_int(objectOffset);
if (gCurrentObject->unk1F4 < (arg0 - 1)) {
@@ -216,7 +216,7 @@ static s32 beh_cmd_delay_var(void) {
static s32 beh_cmd_goto(void) {
gBehCommand++;
gBehCommand = (u32 *) segmented_to_virtual((void *) gBehCommand[0]);
gBehCommand = segmented_to_virtual((void *) gBehCommand[0]);
return BEH_CONTINUE;
}
@@ -224,7 +224,7 @@ static s32 beh_cmd_goto(void) {
static s32 Behavior26(void) {
s32 value = (u8)(gBehCommand[0] >> 16) & 0xFF;
cur_object_stack_push((u32)(gBehCommand + 1));
cur_object_stack_push((uintptr_t)(gBehCommand + 1));
cur_object_stack_push(value);
gBehCommand++;
@@ -235,7 +235,7 @@ static s32 Behavior26(void) {
static s32 beh_cmd_begin_repeat(void) {
s32 count = (s16)(gBehCommand[0] & 0xFFFF);
cur_object_stack_push((u32)(gBehCommand + 1));
cur_object_stack_push((uintptr_t)(gBehCommand + 1));
cur_object_stack_push(count);
gBehCommand++;
@@ -244,12 +244,12 @@ static s32 beh_cmd_begin_repeat(void) {
}
static s32 beh_cmd_end_repeat(void) {
u32 count = cur_object_stack_pop();
u32 count = (u32) cur_object_stack_pop();
count--;
if (count != 0) {
gBehCommand = (u32 *) cur_object_stack_pop();
cur_object_stack_push((u32) gBehCommand);
gBehCommand = (uintptr_t *) cur_object_stack_pop();
cur_object_stack_push((uintptr_t) gBehCommand);
cur_object_stack_push(count);
} else {
cur_object_stack_pop();
@@ -260,12 +260,12 @@ static s32 beh_cmd_end_repeat(void) {
}
static s32 beh_cmd_end_repeat_nobreak(void) {
u32 count = cur_object_stack_pop();
u32 count = (u32) cur_object_stack_pop();
count--;
if (count != 0) {
gBehCommand = (u32 *) cur_object_stack_pop();
cur_object_stack_push((u32) gBehCommand);
gBehCommand = (uintptr_t *) cur_object_stack_pop();
cur_object_stack_push((uintptr_t) gBehCommand);
cur_object_stack_push(count);
} else {
cur_object_stack_pop();
@@ -276,15 +276,15 @@ static s32 beh_cmd_end_repeat_nobreak(void) {
}
static s32 beh_cmd_begin_loop(void) {
cur_object_stack_push((u32)(gBehCommand + 1));
cur_object_stack_push((uintptr_t)(gBehCommand + 1));
gBehCommand++;
return BEH_CONTINUE;
}
static s32 beh_cmd_end_loop(void) {
gBehCommand = (u32 *) cur_object_stack_pop();
cur_object_stack_push((u32) gBehCommand);
gBehCommand = (uintptr_t *) cur_object_stack_pop();
cur_object_stack_push((uintptr_t) gBehCommand);
return BEH_BREAK;
}
@@ -301,7 +301,7 @@ static s32 beh_cmd_callnative(void) {
}
static s32 beh_cmd_obj_set_float(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
f32 value = (s16)(gBehCommand[0] & 0xFFFF);
cur_object_set_float(objectOffset, value);
@@ -311,8 +311,8 @@ static s32 beh_cmd_obj_set_float(void) {
}
static s32 beh_cmd_obj_set_int(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
s16 value = gBehCommand[0] & 0xFFFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s16 value = (s16)(gBehCommand[0] & 0xFFFF);
cur_object_set_int(objectOffset, value);
@@ -322,7 +322,7 @@ static s32 beh_cmd_obj_set_int(void) {
// unused
static s32 Behavior36(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
u32 value = (s16)(gBehCommand[1] & 0xFFFF);
cur_object_set_int(objectOffset, value);
@@ -332,7 +332,7 @@ static s32 Behavior36(void) {
}
static s32 beh_cmd_obj_set_float_rand(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
f32 min = (s16)(gBehCommand[0] & 0xFFFF);
f32 max = (s16)(gBehCommand[1] >> 16);
@@ -343,7 +343,7 @@ static s32 beh_cmd_obj_set_float_rand(void) {
}
static s32 beh_cmd_obj_set_int_rand(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 min = (s16)(gBehCommand[0] & 0xFFFF);
s32 max = (s16)(gBehCommand[1] >> 16);
@@ -354,7 +354,7 @@ static s32 beh_cmd_obj_set_int_rand(void) {
}
static s32 beh_cmd_obj_set_int_rand_rshift(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 min = (s16)(gBehCommand[0] & 0xFFFF);
s32 rshift = (s16)(gBehCommand[1] >> 16);
@@ -365,7 +365,7 @@ static s32 beh_cmd_obj_set_int_rand_rshift(void) {
}
static s32 beh_cmd_obj_add_float_rand(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
f32 min = (s16)(gBehCommand[0] & 0xFFFF);
f32 max = (s16)(gBehCommand[1] >> 16);
@@ -378,7 +378,7 @@ static s32 beh_cmd_obj_add_float_rand(void) {
// unused
static s32 beh_cmd_obj_add_int_rand_rshift(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 min = (s16)(gBehCommand[0] & 0xFFFF);
s32 rshift = (s16)(gBehCommand[1] >> 16);
s32 rnd = RandomU16();
@@ -390,7 +390,7 @@ static s32 beh_cmd_obj_add_int_rand_rshift(void) {
}
static s32 beh_cmd_obj_add_float(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
f32 value = (s16)(gBehCommand[0] & 0xFFFF);
cur_object_add_float(objectOffset, value);
@@ -400,7 +400,7 @@ static s32 beh_cmd_obj_add_float(void) {
}
static s32 beh_cmd_obj_add_int(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s16 value = gBehCommand[0] & 0xFFFF;
cur_object_add_int(objectOffset, value);
@@ -410,7 +410,7 @@ static s32 beh_cmd_obj_add_int(void) {
}
static s32 beh_cmd_obj_or_int(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 value = (s16)(gBehCommand[0] & 0xFFFF);
value &= 0xFFFF;
@@ -422,7 +422,7 @@ static s32 beh_cmd_obj_or_int(void) {
// unused
static s32 beh_cmd_obj_bit_clear_int(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 value = (s16)(gBehCommand[0] & 0xFFFF);
value = (value & 0xFFFF) ^ 0xFFFF;
@@ -433,7 +433,7 @@ static s32 beh_cmd_obj_bit_clear_int(void) {
}
static s32 beh_cmd_obj_set_int32(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
cur_object_set_int(objectOffset, gBehCommand[1]);
@@ -443,7 +443,7 @@ static s32 beh_cmd_obj_set_int32(void) {
static s32 beh_cmd_obj_animate(void) {
s32 animIndex = (u8)((gBehCommand[0] >> 16) & 0xFF);
u32 *animations = gCurrentObject->oAnimations;
struct Animation **animations = gCurrentObject->oAnimations;
geo_obj_init_animation((struct GraphNodeObject *) gCurrentObject, &animations[animIndex]);
@@ -517,8 +517,8 @@ static s32 beh_cmd_obj_sum_int(void) {
}
static s32 beh_cmd_set_hitbox(void) {
s16 colSphereX = gBehCommand[1] >> 16;
s16 colSphereY = gBehCommand[1] & 0xFFFF;
s16 colSphereX = (s16)(gBehCommand[1] >> 16);
s16 colSphereY = (s16)(gBehCommand[1] & 0xFFFF);
gCurrentObject->hitboxRadius = colSphereX;
gCurrentObject->hitboxHeight = colSphereY;
@@ -528,8 +528,8 @@ static s32 beh_cmd_set_hitbox(void) {
}
static s32 beh_cmd_obj_set_float2(void) {
s16 arg0 = gBehCommand[1] >> 16;
s16 arg1 = gBehCommand[1] & 0xFFFF;
s16 arg0 = (s16)(gBehCommand[1] >> 16);
s16 arg1 = (s16)(gBehCommand[1] & 0xFFFF);
gCurrentObject->hurtboxRadius = arg0;
gCurrentObject->hurtboxHeight = arg1;
@@ -539,9 +539,9 @@ static s32 beh_cmd_obj_set_float2(void) {
}
static s32 beh_cmd_collision_sphere(void) {
s16 colSphereX = gBehCommand[1] >> 16;
s16 colSphereY = gBehCommand[1] & 0xFFFF;
s16 unknown = gBehCommand[2] >> 16;
s16 colSphereX = (s16)(gBehCommand[1] >> 16);
s16 colSphereY = (s16)(gBehCommand[1] & 0xFFFF);
s16 unknown = (s16)(gBehCommand[2] >> 16);
gCurrentObject->hitboxRadius = colSphereX;
gCurrentObject->hitboxHeight = colSphereY;
@@ -576,7 +576,7 @@ static s32 beh_cmd_begin(void) {
}
static void Unknown8038556C(s32 lastIndex) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
u32 table[16];
s32 i;
@@ -604,7 +604,7 @@ static s32 beh_cmd_obj_set_pos(void) {
}
static s32 beh_cmd_interact_type(void) {
gCurrentObject->oInteractType = gBehCommand[1];
gCurrentObject->oInteractType = (u32) gBehCommand[1];
gBehCommand += 2;
return BEH_CONTINUE;
@@ -612,14 +612,14 @@ static s32 beh_cmd_interact_type(void) {
// unused
static s32 Behavior31(void) {
gCurrentObject->oInteractionSubtype = gBehCommand[1];
gCurrentObject->oInteractionSubtype = (u32) gBehCommand[1];
gBehCommand += 2;
return BEH_CONTINUE;
}
static s32 beh_cmd_scale(void) {
UNUSED u8 sp1f = (gBehCommand[0] >> 16) & 0xFF;
UNUSED u8 sp1f = (u8)((gBehCommand[0] >> 16) & 0xFF);
s16 sp1c = gBehCommand[0] & 0xFFFF;
obj_scale((f32) sp1c / 100.0f);
@@ -647,7 +647,7 @@ static s32 beh_cmd_obj_set_gravity(void) {
}
static s32 beh_cmd_obj_bit_clear_int32(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s32 flags = gBehCommand[1];
flags = flags ^ 0xFFFFFFFF;
@@ -666,7 +666,7 @@ static s32 beh_cmd_spawn_addr(void) {
}
static s32 beh_cmd_text_anim_rate(void) {
u8 objectOffset = (gBehCommand[0] >> 16) & 0xFF;
u8 objectOffset = (u8)((gBehCommand[0] >> 16) & 0xFF);
s16 arg1 = (gBehCommand[0] & 0xFFFF);
if ((gGlobalTimer % arg1) == 0) {
+29 -30
View File
@@ -91,7 +91,7 @@ UNUSED s32 D_8038BCA8;
struct GraphNode **gGeoViews;
u16 gGeoNumViews; // length of gGeoViews array
u32 gGeoLayoutStack[16];
uintptr_t gGeoLayoutStack[16];
struct GraphNode *gCurGraphNodeList[32];
s16 gCurGraphNodeIndex;
s16 gGeoLayoutStackIndex; // similar to SP register in MIPS
@@ -107,10 +107,10 @@ u32 unused_8038B894[3] = { 0 };
cmd+0x04: void *branchTarget
*/
void geo_layout_cmd_branch_and_link(void) {
gGeoLayoutStack[gGeoLayoutStackIndex++] = (u32) &gGeoLayoutCommand[8];
gGeoLayoutStack[gGeoLayoutStackIndex++] = (uintptr_t) (gGeoLayoutCommand + 4 + sizeof(void *));
gGeoLayoutStack[gGeoLayoutStackIndex++] = (gCurGraphNodeIndex << 16) + gGeoLayoutReturnIndex;
gGeoLayoutReturnIndex = gGeoLayoutStackIndex;
gGeoLayoutCommand = (u8 *) segmented_to_virtual((void *) cur_geo_cmd_s32(0x04));
gGeoLayoutCommand = segmented_to_virtual(cur_geo_cmd_ptr(0x04));
}
// 0x01: Terminate geo layout
@@ -127,10 +127,10 @@ void geo_layout_cmd_end(void) {
*/
void geo_layout_cmd_branch(void) {
if (cur_geo_cmd_u8(0x01) == 1) {
gGeoLayoutStack[gGeoLayoutStackIndex++] = (u32) &gGeoLayoutCommand[8];
gGeoLayoutStack[gGeoLayoutStackIndex++] = (uintptr_t) (gGeoLayoutCommand + 4 + sizeof(void *));
}
gGeoLayoutCommand = (u8 *) segmented_to_virtual((void *) cur_geo_cmd_s32(0x04));
gGeoLayoutCommand = segmented_to_virtual(cur_geo_cmd_ptr(0x04));
}
// 0x03: Return from branch
@@ -216,8 +216,7 @@ void geo_layout_cmd_node_root(void) {
graphNode = init_graph_node_root(gGraphNodePool, NULL, 0, x, y, width, height);
// TODO: check type
gGeoViews =
(struct GraphNode **) alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(void *));
gGeoViews = alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(struct GraphNode *));
graphNode->views = gGeoViews;
graphNode->numViews = gGeoNumViews;
@@ -263,8 +262,8 @@ void geo_layout_cmd_node_perspective(void) {
if (cur_geo_cmd_u8(0x01) != 0) {
// optional asm function
frustumFunc = (GraphNodeFunc) cur_geo_cmd_s32(0x08);
gGeoLayoutCommand += 0x04;
frustumFunc = (GraphNodeFunc) cur_geo_cmd_ptr(0x08);
gGeoLayoutCommand += sizeof(void *);
}
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, (f32) fov, near, far, frustumFunc, 0);
@@ -340,12 +339,12 @@ void geo_layout_cmd_node_switch_case(void) {
init_graph_node_switch_case(gGraphNodePool, NULL,
cur_geo_cmd_s16(0x02), // case which is initially selected
0,
(GraphNodeFunc) cur_geo_cmd_s32(0x04), // case update function
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // case update function
0);
register_scene_graph_node(&graphNode->fnNode.node);
gGeoLayoutCommand += 0x08;
gGeoLayoutCommand += 0x04 + sizeof(void *);
}
/*
@@ -369,13 +368,13 @@ void geo_layout_cmd_node_camera(void) {
cmdPos = read_vec3s_to_vec3f(toPos, cmdPos);
graphNode = init_graph_node_camera(gGraphNodePool, NULL, fromPos, toPos,
(GraphNodeFunc) cur_geo_cmd_s32(0x10), cur_geo_cmd_s16(0x02));
(GraphNodeFunc) cur_geo_cmd_ptr(0x10), cur_geo_cmd_s16(0x02));
register_scene_graph_node(&graphNode->fnNode.node);
gGeoViews[0] = &graphNode->fnNode.node;
gGeoLayoutCommand += 0x14;
gGeoLayoutCommand += 0x10 + sizeof(void *);
}
/*
@@ -446,7 +445,7 @@ void geo_layout_cmd_node_translation_rotation(void) {
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2;
cmdPos += sizeof(void*) / 2;
}
graphNode = init_graph_node_translation_rotation(gGraphNodePool, NULL, drawingLayer, displayList,
@@ -481,7 +480,7 @@ void geo_layout_cmd_node_translation(void) {
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2;
cmdPos += sizeof(void*) / 2;
}
graphNode =
@@ -517,7 +516,7 @@ void geo_layout_cmd_node_rotation(void) {
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2;
cmdPos += sizeof(void*) / 2;
}
graphNode = init_graph_node_rotation(gGraphNodePool, NULL, drawingLayer, displayList, sp2c);
@@ -544,9 +543,9 @@ void geo_layout_cmd_node_scale(void) {
void *displayList = NULL;
if (params & 0x80) {
displayList = (void *) cur_geo_cmd_s32(0x08);
displayList = cur_geo_cmd_ptr(0x08);
drawingLayer = params & 0x0F;
gGeoLayoutCommand += 0x04;
gGeoLayoutCommand += sizeof(void *);
}
graphNode = init_graph_node_scale(gGraphNodePool, NULL, drawingLayer, displayList, scale);
@@ -573,7 +572,7 @@ void geo_layout_cmd_node_animated_part(void) {
struct GraphNodeAnimatedPart *graphNode;
Vec3s translation;
s32 drawingLayer = cur_geo_cmd_u8(0x01);
void *displayList = (void *) cur_geo_cmd_s32(0x08);
void *displayList = cur_geo_cmd_ptr(0x08);
s16 *cmdPos = (s16 *) gGeoLayoutCommand;
read_vec3s(translation, &cmdPos[1]);
@@ -583,7 +582,7 @@ void geo_layout_cmd_node_animated_part(void) {
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand += 0x0C;
gGeoLayoutCommand += 0x08 + sizeof(void *);
}
/*
@@ -609,7 +608,7 @@ void geo_layout_cmd_node_billboard(void) {
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2;
cmdPos += sizeof(void*) / 2;
}
graphNode = init_graph_node_billboard(gGraphNodePool, NULL, drawingLayer, displayList, translation);
@@ -627,13 +626,13 @@ void geo_layout_cmd_node_billboard(void) {
void geo_layout_cmd_node_display_list(void) {
struct GraphNodeDisplayList *graphNode;
s32 drawingLayer = cur_geo_cmd_u8(0x01);
void *displayList = (void *) cur_geo_cmd_s32(0x04);
void *displayList = cur_geo_cmd_ptr(0x04);
graphNode = init_graph_node_display_list(gGraphNodePool, NULL, drawingLayer, displayList);
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand += 0x08;
gGeoLayoutCommand += 0x04 + sizeof(void *);
}
/*
@@ -675,12 +674,12 @@ void geo_layout_cmd_node_generated(void) {
struct GraphNodeGenerated *graphNode;
graphNode = init_graph_node_generated(gGraphNodePool, NULL,
(GraphNodeFunc) cur_geo_cmd_s32(0x04), // asm function
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function
cur_geo_cmd_s16(0x02)); // parameter
register_scene_graph_node(&graphNode->fnNode.node);
gGeoLayoutCommand += 0x08;
gGeoLayoutCommand += 0x04 + sizeof(void *);
}
/*
@@ -694,12 +693,12 @@ void geo_layout_cmd_node_background(void) {
graphNode = init_graph_node_background(
gGraphNodePool, NULL,
cur_geo_cmd_s16(0x02), // background ID, or RGBA5551 color if asm function is null
(GraphNodeFunc) cur_geo_cmd_s32(0x04), // asm function
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function
0);
register_scene_graph_node(&graphNode->fnNode.node);
gGeoLayoutCommand += 0x08;
gGeoLayoutCommand += 0x04 + sizeof(void *);
}
// 0x1A: No operation
@@ -749,11 +748,11 @@ void geo_layout_cmd_node_held_obj(void) {
read_vec3s(offset, (s16 *) &gGeoLayoutCommand[0x02]);
graphNode = init_graph_node_held_object(
gGraphNodePool, NULL, 0, offset, (GraphNodeFunc) cur_geo_cmd_s32(0x08), cur_geo_cmd_u8(0x01));
gGraphNodePool, NULL, NULL, offset, (GraphNodeFunc) cur_geo_cmd_ptr(0x08), cur_geo_cmd_u8(0x01));
register_scene_graph_node(&graphNode->fnNode.node);
gGeoLayoutCommand += 0x0C;
gGeoLayoutCommand += 0x08 + sizeof(void *);
}
/*
@@ -781,7 +780,7 @@ struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr) {
gGeoLayoutStackIndex = 2;
gGeoLayoutReturnIndex = 2; // stack index is often copied here?
gGeoLayoutCommand = (u8 *) segmented_to_virtual(segptr);
gGeoLayoutCommand = segmented_to_virtual(segptr);
gGraphNodePool = pool;
+4 -1
View File
@@ -19,12 +19,15 @@
#define cur_geo_cmd_u32(offset) \
(*(u32 *) &gGeoLayoutCommand[offset])
#define cur_geo_cmd_ptr(offset) \
(*(void **) &gGeoLayoutCommand[offset])
extern struct AllocOnlyPool *gGraphNodePool;
extern struct GraphNode *gCurRootGraphNode;
extern UNUSED s32 D_8038BCA8;
extern struct GraphNode **gGeoViews;
extern u16 gGeoNumViews;
extern u32 gGeoLayoutStack[];
extern uintptr_t gGeoLayoutStack[];
extern struct GraphNode *gCurGraphNodeList[];
extern s16 gCurGraphNodeIndex;
extern s16 gGeoLayoutStackIndex;
+10 -9
View File
@@ -497,7 +497,8 @@ struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *poo
*/
struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *pool,
struct GraphNodeHeldObject *graphNode,
s32 objNode, Vec3s translation,
struct GraphNodeObject *objNode,
Vec3s translation,
GraphNodeFunc nodeFunc, s32 unused) {
if (pool != NULL) {
graphNode = alloc_only_pool_alloc(pool, sizeof(struct GraphNodeHeldObject));
@@ -506,7 +507,7 @@ struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *po
if (graphNode != NULL) {
init_scene_graph_node_links(&graphNode->fnNode.node, GRAPH_NODE_TYPE_HELD_OBJ);
vec3s_copy(graphNode->translation, translation);
graphNode->objNode = (struct GraphNodeObject *) objNode; // assumed type
graphNode->objNode = objNode;
graphNode->fnNode.func = nodeFunc;
graphNode->unused = unused;
@@ -732,13 +733,13 @@ void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo
/**
* Initialize the animation of an object node
*/
void geo_obj_init_animation(struct GraphNodeObject *graphNode, void *sp34) {
void **animSegmented = segmented_to_virtual(sp34);
struct Animation *anim = segmented_to_virtual(animSegmented[0]);
void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr) {
struct Animation **animSegmented = segmented_to_virtual(animPtrAddr);
struct Animation *anim = segmented_to_virtual(*animSegmented);
if (graphNode->unk38.curAnim != anim) {
graphNode->unk38.curAnim = anim;
graphNode->unk38.animFrame = (anim->unk04) + ((anim->flags & ANIM_FLAG_FORWARD) ? 1 : -1);
graphNode->unk38.animFrame = anim->unk04 + ((anim->flags & ANIM_FLAG_FORWARD) ? 1 : -1);
graphNode->unk38.animAccel = 0;
graphNode->unk38.animYTrans = 0;
}
@@ -747,9 +748,9 @@ void geo_obj_init_animation(struct GraphNodeObject *graphNode, void *sp34) {
/**
* Initialize the animation of an object node
*/
void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, void *sp34, u32 animAccel) {
void **animSegmented = segmented_to_virtual(sp34);
struct Animation *anim = segmented_to_virtual(animSegmented[0]);
void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr, u32 animAccel) {
struct Animation **animSegmented = segmented_to_virtual(animPtrAddr);
struct Animation *anim = segmented_to_virtual(*animSegmented);
if (graphNode->unk38.curAnim != anim) {
graphNode->unk38.curAnim = anim;
+7 -6
View File
@@ -181,8 +181,9 @@ struct GraphNodeSwitchCase
/*0x1E*/ s16 selectedCase;
};
/** GraphNode that specifies the location and aim of the camera.
* When the roll is 0, the up vector is (0, 1, 0).
/**
* GraphNode that specifies the location and aim of the camera.
* When the roll is 0, the up vector is (0, 1, 0).
*/
struct GraphNodeCamera
{
@@ -386,7 +387,7 @@ struct GraphNodeObject *init_graph_node_object(struct AllocOnlyPool *pool, struc
struct GraphNode *sp20, Vec3f pos, Vec3s angle, Vec3f scale);
struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *sp1c,
s16 sp22);
struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart * graphNode,
struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart *graphNode,
s32 drawingLayer, void *displayList, Vec3s relativePos);
struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool,
struct GraphNodeBillboard *graphNode, s32 drawingLayer, void *displayList, Vec3s sp28);
@@ -401,7 +402,7 @@ struct GraphNodeGenerated *init_graph_node_generated(struct AllocOnlyPool *pool,
struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *pool, struct GraphNodeBackground *sp1c,
u16 sp22, GraphNodeFunc sp24, s32 sp28);
struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *pool, struct GraphNodeHeldObject *sp1c,
s32 sp20, Vec3s sp24, GraphNodeFunc sp28, s32 sp2c);
struct GraphNodeObject *objNode, Vec3s translation, GraphNodeFunc nodeFunc, s32 unused);
struct GraphNode *geo_add_child(struct GraphNode *, struct GraphNode *);
struct GraphNode *geo_remove_child(struct GraphNode *);
@@ -413,8 +414,8 @@ void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 sp1c);
void geo_reset_object_node(struct GraphNodeObject *sp20);
void geo_obj_init(struct GraphNodeObject *sp18, void *sp1c, Vec3f sp20, Vec3s sp24);
void geo_obj_init_spawninfo(struct GraphNodeObject *sp18, struct SpawnInfo *sp1c);
void geo_obj_init_animation(struct GraphNodeObject *, void *);
void geo_obj_init_animation_accel(struct GraphNodeObject *sp30, void *sp34, u32 sp38);
void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr);
void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr, u32 animAccel);
s32 retrieve_animation_index(s32 a0, u16 **a1);
+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,
+1 -1
View File
@@ -522,7 +522,7 @@ void alloc_surface_pools(void) {
sSurfacePool = main_pool_alloc(sSurfacePoolSize * sizeof(struct Surface), MEMORY_POOL_LEFT);
gCCMEnteredSlide = 0;
func_802DA4DC();
reset_red_coins_collected();
}
/**