/
ac_mbg.c
95 lines (77 loc) · 2.91 KB
/
ac_mbg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "ac_mbg.h"
#include "m_collision_bg.h"
#include "m_rcp.h"
#include "sys_matrix.h"
#include "m_name_table.h"
static Vtx mbg_v[] = {
#include "assets/mbg_v.inc"
};
static Gfx mbg_model[] = {
gsDPPipeSync(),
gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2),
gsDPSetCombineLERP(PRIMITIVE, 0, SHADE, 0, 0, 0, 0, 1, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED),
gsDPSetPrimColor(0, 128, 255, 255, 0, 255),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&mbg_v[0], 8, 0),
gsSP2Triangles(5, 6, 7, 0, 4, 5, 7, 0),
gsSP2Triangles(7, 6, 2, 0, 7, 2, 3, 0),
gsSP2Triangles(5, 1, 6, 0, 6, 1, 2, 0),
gsSP2Triangles(4, 0, 5, 0, 5, 0, 1, 0),
gsSP2Triangles(4, 7, 0, 0, 0, 7, 3, 0),
gsSPEndDisplayList(),
};
static void Mbg_Actor_ct(ACTOR* actorx, GAME* game);
static void Mbg_Actor_dt(ACTOR* actorx, GAME* game);
static void Mbg_Actor_draw(ACTOR* actorx, GAME* game);
static void Mbg_Actor_move(ACTOR* actorx, GAME* game);
// clang-format off
ACTOR_PROFILE Mbg_Profile = {
mAc_PROFILE_MBG,
ACTOR_PART_ITEM,
ACTOR_STATE_NONE,
ETC_MBG,
ACTOR_OBJ_BANK_KEEP,
sizeof(MBG_ACTOR),
&Mbg_Actor_ct,
&Mbg_Actor_dt,
&Mbg_Actor_move,
&Mbg_Actor_draw,
NULL
};
// clang-format on
static void Mbg_Actor_ct(ACTOR* actorx, GAME* game) {
MBG_ACTOR* mbg = (MBG_ACTOR*)actorx;
mbg->move_bg_regist_idx = 0;
mbg->original_pos = actorx->world.position;
mbg->move_counter = 0.0f;
actorx->shape_info.rotation.y = DEG2SHORT_ANGLE(60.0f); // 0x2AAA
mbg->move_bg_regist_idx = mCoBG_RegistMoveBg(&mbg->move_bg_regist, &actorx->world.position,
&actorx->last_world_position, &actorx->shape_info.rotation.y, 40.0f,
NULL, NULL, NULL, NULL, 0, mCoBG_ATTRIBUTE_STONE, 80.0f);
}
static void Mbg_Actor_dt(ACTOR* actorx, GAME* game) {
MBG_ACTOR* mbg = (MBG_ACTOR*)actorx;
mCoBG_CrossOffMoveBg(mbg->move_bg_regist_idx);
}
static void Mbg_Actor_draw(ACTOR* actorx, GAME* game) {
xyz_t pos = actorx->world.position;
s16 angle_y = actorx->shape_info.rotation.y;
GRAPH* graph = game->graph;
OPEN_DISP(graph);
_texture_z_light_fog_prim(graph);
Matrix_translate(pos.x, pos.y, pos.z, 0);
Matrix_RotateY(angle_y, 1);
gSPMatrix(NEXT_POLY_OPA_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(NEXT_POLY_OPA_DISP, mbg_model);
CLOSE_DISP(graph);
}
static void Mbg_Actor_move(ACTOR* actorx, GAME* game) {
MBG_ACTOR* mbg = (MBG_ACTOR*)actorx;
f32 x_shift = sinf_table(DEG2RAD(mbg->move_counter)) * 60.0f;
mbg->move_counter += 2.0f;
while (mbg->move_counter > 360.0f) {
mbg->move_counter -= 360.0f;
}
actorx->world.position.x = mbg->original_pos.x + x_shift;
actorx->shape_info.rotation.y += DEG2SHORT_ANGLE(0.258179f); // 0x002F
}