Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
omo_01.inc.c
Go to the documentation of this file.
1#include "battle/battle.h"
3#include "model.h"
4
5#define NAMESPACE A(omo_01)
6
7// following part is very similar to RockingHorse.inc.c in world/area_omo,
8// but it does not match it exactly
9
10extern EvtScript N(EVS_UpdateRockingHorse);
11
12s32 N(RockingHorseModels)[] = { MODEL_uma };
13
14typedef struct RockingHorse {
15 /* 0x00 */ f32 offsetX;
16 /* 0x04 */ f32 offsetZ;
17 /* 0x08 */ f32 rockPhaseAngularVel;
18 /* 0x0C */ f32 rockPhase;
19 /* 0x10 */ s32 modelID;
20 /* 0x14 */ s32 unk_14;
21} RockingHorse; // size = 0x18
22
23API_CALLABLE(N(UpdateRockingHorse)) {
24 RockingHorse* horse;
25 Model* model;
26 f32 rotZ;
27 f32 offsetY;
28 s32 i;
29 Matrix4f mtxPivot;
30 Matrix4f mtxRotate;
31
32 if (isInitialCall) {
33 horse = heap_malloc(sizeof(*horse));
34 script->functionTempPtr[0] = horse;
35
36 for (i = 0; i == 0; i++, horse++) {
37 horse->modelID = N(RockingHorseModels)[i];
38 horse->unk_14 = ((s32*)N(EVS_UpdateRockingHorse))[i]; // WTF ???
40 horse->offsetX = 0.0f;
41 horse->offsetZ = 0.0f;
42 horse->rockPhaseAngularVel = 3.5f;
43 horse->rockPhase = 0.0f;
44 }
45 }
46
47 horse = script->functionTempPtr[0];
48 for (i = 0; i == 0; i++, horse++) {
49 horse->rockPhase += horse->rockPhaseAngularVel;
50 horse->rockPhase = clamp_angle(horse->rockPhase);
51
52 rotZ = sin_rad(horse->rockPhase * 3.14f / 180.0f) * 20.0f;
53 offsetY = SQ(rotZ) / 90.0f;
54
57 guTranslateF(mtxPivot, -horse->offsetX, 0.0f, -horse->offsetZ);
58 guRotateF(mtxRotate, rotZ, 0.0f, 0.0f, 1.0f);
59 guMtxCatF(mtxPivot, mtxRotate, model->userTransformMtx);
60 guTranslateF(mtxPivot, horse->offsetX, offsetY, horse->offsetZ);
61 guMtxCatF(model->userTransformMtx, mtxPivot, model->userTransformMtx);
62 }
63 return ApiStatus_BLOCK;
64}
65
66EvtScript N(EVS_UpdateRockingHorse) = {
67 Call(N(UpdateRockingHorse))
68 Return
69 End
70};
71
72EvtScript N(EVS_PreBattle) = {
73 Call(SetSpriteShading, SHADING_NONE)
75 Thread
76 SetF(LVar0, Float(0.0))
77 SetF(LVar1, Float(0.0))
78 Loop(0)
81 SubF(LVar0, Float(0.6))
82 SubF(LVar1, Float(7.2))
85 Wait(1)
88 Exec(N(EVS_UpdateRockingHorse))
89 Return
90 End
91};
92
93EvtScript N(EVS_PostBattle) = {
94 Return
95 End
96};
97
98Stage NAMESPACE = {
99 .texture = "omo_tex",
100 .shape = "omo_bt01_shape",
101 .hit = "omo_bt01_hit",
102 .bg = "omo_bg",
103 .preBattle = &N(EVS_PreBattle),
104 .postBattle = &N(EVS_PostBattle),
105};
f32 Matrix4f[4][4]
Bytecode EvtScript[]
#define MODEL_hari
#define guRotateF
#define guTranslateF
#define guMtxCatF
#define clamp_angle
@ MODEL_FLAG_HAS_TRANSFORM
Definition enums.h:4367
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:4369
@ CAM_BATTLE
Definition enums.h:1801
#define ApiStatus_BLOCK
Definition evt.h:116
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
f32 sin_rad(f32 x)
Definition 43F0.c:713
void * heap_malloc(s32 size)
Definition heap.c:34
#define MODEL_o367
u16 flags
Definition model.h:60
Matrix4f userTransformMtx
Definition model.h:68
Definition model.h:59
f32 rockPhaseAngularVel
Definition omo_01.inc.c:17
#define MODEL_uma
Definition omo_01_shape.h:2
ApiStatus SetSpriteShading(Evt *script, b32 isInitialCall)
ApiStatus RotateModel(Evt *script, b32 isInitialCall)
Rotates the model the given amount on the selected axis.
ApiStatus ClampAngleFloat(Evt *script, b32 isInitialCall)
ApiStatus SetCamBGColor(Evt *script, b32 isInitialCall)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define EndLoop
Marks the end of a loop.
Definition macros.h:248
#define Float(DOUBLE)
Definition macros.h:51
#define Thread
Marks the start of a thread block.
Definition macros.h:544
#define EndThread
Marks the end of a thread block.
Definition macros.h:547
#define SetF(VAR, FLOAT_VALUE)
Sets the given variable to a given value, but supports Floats.
Definition macros.h:373
#define LVar1
Definition macros.h:149
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define SQ(x)
Definition macros.h:166
#define SubF(VAR, FLOAT_VALUE)
Definition macros.h:384
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define Loop(TIMES)
Marks the beginning of a loop.
Definition macros.h:245
#define LVar0
Definition macros.h:148
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:455
#define Return
Kills the current EVT thread.
Definition macros.h:217