Mario Kart 64
Loading...
Searching...
No Matches
update.inc.c
Go to the documentation of this file.
1#include <actors.h>
2#include <code_800029B0.h>
3#include <main.h>
5
6void func_8029CF0C(struct ActorSpawnData* spawnData, struct FallingRock* rock) {
7 s32 segment = SEGMENT_NUMBER2(spawnData);
8 s32 offset = SEGMENT_OFFSET(spawnData);
9 struct ActorSpawnData* temp_v0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset);
10 Vec3s sp24 = { 60, 120, 180 };
11 temp_v0 += rock->unk_06;
12 rock->respawnTimer = sp24[rock->unk_06]; // * 2
13 rock->pos[0] = (f32) temp_v0->pos[0] * gCourseDirection;
14 rock->pos[1] = (f32) temp_v0->pos[1] + 10.0f;
15 rock->pos[2] = (f32) temp_v0->pos[2];
16 vec3f_set(rock->velocity, 0, 0, 0);
17 vec3s_set(rock->rot, 0, 0, 0);
18}
19
26void spawn_falling_rocks(struct ActorSpawnData* spawnData) {
27 s32 addr = SEGMENT_NUMBER2(spawnData);
28 s32 offset = SEGMENT_OFFSET(spawnData);
29 // Casting this to prevent warning does not work.
30 struct ActorSpawnData* temp_s0 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset);
31 struct FallingRock* temp_v1;
32 Vec3f startingPos;
33 Vec3f startingVelocity;
34 Vec3s startingRot;
35 s16 temp;
36
37 while (temp_s0->pos[0] != -0x8000) {
38 startingPos[0] = temp_s0->pos[0] * gCourseDirection;
39 startingPos[1] = temp_s0->pos[1] + 10.0f;
40 startingPos[2] = temp_s0->pos[2];
41 vec3f_set(startingVelocity, 0, 0, 0);
42 vec3s_set(startingRot, 0, 0, 0);
43 temp = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK);
44 temp_v1 = (struct FallingRock*) &gActorList[temp];
45
46 temp_v1->unk_06 = temp_s0->someId;
47 func_802AAAAC((Collision*) &temp_v1->unk30);
48 temp_s0++;
49 }
50}
51
59 Vec3f unkVec;
60 f32 pad0;
61 f32 pad1;
62
63 if (rock->respawnTimer != 0) {
64 rock->respawnTimer -= 1;
65 return;
66 }
67 if (rock->pos[1] < D_8015F8E4) {
69 }
70 rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f);
71 rock->rot[2] += (s16) ((rock->velocity[0] * 5461.0f) / 20.0f);
72 rock->velocity[1] -= 0.1;
73 if (rock->velocity[1] < (-2.0f)) {
74 rock->velocity[1] = -2.0f;
75 }
76 rock->pos[0] += rock->velocity[0];
77 rock->pos[1] += rock->velocity[1];
78 rock->pos[2] += rock->velocity[2];
79 pad1 = rock->velocity[1];
80 check_bounding_collision(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]);
81 pad0 = rock->unk30.surfaceDistance[2];
82 if (pad0 < 0.0f) {
83 unkVec[0] = -rock->unk30.orientationVector[0];
84 unkVec[1] = -rock->unk30.orientationVector[1];
85 unkVec[2] = -rock->unk30.orientationVector[2];
86 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[2];
87 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[2];
88 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[2];
89 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
90 rock->velocity[1] = -1.2f * pad1;
91 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
92 }
93 pad0 = rock->unk30.surfaceDistance[0];
94 if (pad0 < 0.0f) {
95 unkVec[1] = -rock->unk30.unk48[1];
96 if (unkVec[1] == 0.0f) {
97 rock->velocity[1] *= -1.2f;
98 return;
99 } else {
100 unkVec[0] = -rock->unk30.unk48[0];
101 unkVec[2] = -rock->unk30.unk48[2];
102 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[0];
103 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[0];
104 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[0];
105 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
106 rock->velocity[1] = -1.2f * pad1;
107 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
108 }
109 }
110 pad0 = rock->unk30.surfaceDistance[1];
111 if (pad0 < 0.0f) {
112 unkVec[1] = -rock->unk30.unk54[1];
113 if (unkVec[1] == 0.0f) {
114 rock->velocity[1] *= -1.2f;
115 } else {
116 unkVec[0] = -rock->unk30.unk54[0];
117 unkVec[2] = -rock->unk30.unk54[2];
118 rock->pos[0] += unkVec[0] * rock->unk30.surfaceDistance[1];
119 rock->pos[1] += unkVec[1] * rock->unk30.surfaceDistance[1];
120 rock->pos[2] += unkVec[2] * rock->unk30.surfaceDistance[1];
121 pad1 = rock->velocity[1];
122 adjust_pos_orthogonally(unkVec, pad0, rock->velocity, 2.0f);
123 rock->velocity[1] = -1.2f * pad1;
124 func_800C98B8(rock->pos, rock->velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F));
125 }
126 }
127}
@ ACTOR_FALLING_ROCK
Definition actor_types.h:43
s16 add_actor_to_empty_slot(Vec3f pos, Vec3s rot, Vec3f velocity, s16 actorType)
Definition actors.c:1440
struct ActorSpawnData d_course_choco_mountain_falling_rock_spawns[]
Definition course_data.c:3137
f32 D_8015F8E4
Definition code_800029B0.c:142
struct Actor gActorList[ACTOR_LIST_SIZE]
Definition code_800029B0.c:148
f32 gCourseDirection
Definition code_800029B0.c:122
u16 check_bounding_collision(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ)
Definition collision.c:1356
void adjust_pos_orthogonally(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2, UNUSED f32 unk)
Definition collision.c:607
void func_802AAAAC(Collision *collision)
Definition collision.c:28
f32 Vec3f[3]
Definition common_structs.h:6
s16 Vec3s[3]
Definition common_structs.h:11
void func_800C98B8(Vec3f position, Vec3f velocity, u32 soundBits)
Definition external.c:3027
void update_actor_falling_rocks(struct FallingRock *rock)
Updates the falling rock actor. Actor used in Choco Mountain.
Definition update.inc.c:58
void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock)
Definition update.inc.c:6
void spawn_falling_rocks(struct ActorSpawnData *spawnData)
Spawns falling rocks. Used in Choco Mountain.
Definition update.inc.c:26
#define VIRTUAL_TO_PHYSICAL2(addr)
Definition macros.h:93
uintptr_t gSegmentTable[16]
Definition main.c:131
void vec3f_set(Vec3f arg0, f32 arg1, f32 arg2, f32 arg3)
Definition math_util.c:103
void vec3s_set(Vec3s arg0, s16 arg1, s16 arg2, s16 arg3)
Definition math_util.c:109
#define SEGMENT_OFFSET(a)
Definition mbi.h:89
#define SEGMENT_NUMBER2(a)
Definition mbi.h:91
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
Definition actor_types.h:186
Vec3s pos
Definition actor_types.h:187
u16 someId
Definition actor_types.h:189
Definition common_structs.h:132
Vec3f surfaceDistance
Definition common_structs.h:140
Vec3f orientationVector
Definition common_structs.h:143
Vec3f unk54
Definition common_structs.h:142
Vec3f unk48
Definition common_structs.h:141
Definition actor_types.h:172
Collision unk30
Definition actor_types.h:183
s16 respawnTimer
Definition actor_types.h:175
Vec3s rot
Definition actor_types.h:179
s16 unk_06
Definition actor_types.h:176
Vec3f pos
Definition actor_types.h:181
Vec3f velocity
Definition actor_types.h:182
signed int s32
Definition ultratypes.h:15
signed short int s16
Definition ultratypes.h:13
float f32
Definition ultratypes.h:34