Implement & link ac_museum_indoor

This commit is contained in:
Cuyler36
2025-05-01 22:22:35 -04:00
parent 27f480c12c
commit 855589902b
3 changed files with 148 additions and 2 deletions
+1 -1
View File
@@ -1024,7 +1024,7 @@ config.libs = [
Object(Matching, "actor/ac_museum.c"),
Object(Matching, "actor/ac_museum_fish.c"),
Object(Matching, "actor/ac_museum_fossil.c"),
Object(NonMatching, "actor/ac_museum_indoor.c"),
Object(Matching, "actor/ac_museum_indoor.c"),
Object(Matching, "actor/ac_museum_insect.c"),
Object(Matching, "actor/ac_museum_picture.c"),
Object(Matching, "actor/ac_my_house.c"),
+8 -1
View File
@@ -8,6 +8,14 @@
extern "C" {
#endif
typedef struct museum_indoor_actor_s MUSEUM_INDOOR_ACTOR;
struct museum_indoor_actor_s {
ACTOR actor_class;
f32 alpha;
int cull_index;
};
extern ACTOR_PROFILE Museum_Indoor_Profile;
#ifdef __cplusplus
@@ -15,4 +23,3 @@ extern ACTOR_PROFILE Museum_Indoor_Profile;
#endif
#endif
+139
View File
@@ -0,0 +1,139 @@
#include "ac_museum_indoor.h"
#include "m_name_table.h"
#include "m_scene.h"
#include "m_kankyo.h"
#include "sys_matrix.h"
#include "m_play.h"
#include "m_common_data.h"
static void Museum_Indoor_Actor_ct(ACTOR* actorx, GAME* game);
static void Museum_Indoor_Actor_draw(ACTOR* actorx, GAME* game);
static void Museum_Indoor_Actor_dt(ACTOR* actorx, GAME* game);
static void Museum_Indoor_Actor_move(ACTOR* actorx, GAME* game);
ACTOR_PROFILE Museum_Indoor_Profile = {
mAc_PROFILE_MUSEUM_INDOOR,
ACTOR_PART_CONTROL,
ACTOR_STATE_CAN_MOVE_IN_DEMO_SCENES | ACTOR_STATE_NO_DRAW_WHILE_CULLED | ACTOR_STATE_NO_MOVE_WHILE_CULLED,
EMPTY_NO,
ACTOR_OBJ_BANK_KEEP,
sizeof(MUSEUM_INDOOR_ACTOR),
Museum_Indoor_Actor_ct,
Museum_Indoor_Actor_dt,
Museum_Indoor_Actor_move,
Museum_Indoor_Actor_draw,
NULL,
};
typedef struct museum_indoor_cull_info_s {
int scene;
int type;
Gfx* cull_gfx;
} aMI_cull_info_c;
extern Gfx rom_museum4_wall_model[];
extern Gfx rom_museum5_wall_model[];
static aMI_cull_info_c aMI_museum_indoor_cull_info[] = {
{ SCENE_MUSEUM_ROOM_INSECT, 1, rom_museum4_wall_model },
{ SCENE_MUSEUM_ROOM_FISH, 0, rom_museum5_wall_model },
};
static void aMI_AlphaToON(f32* alpha_p) {
(*alpha_p) += 24.0f;
if (*alpha_p < 0.0f) {
*alpha_p = 0.0f;
} else if (*alpha_p > 255.0f) {
*alpha_p = 255.0f;
}
}
static void aMI_AlphaToOFF(f32* alpha_p) {
(*alpha_p) -= 24.0f;
if (*alpha_p < 0.0f) {
*alpha_p = 0.0f;
} else if (*alpha_p > 255.0f) {
*alpha_p = 255.0f;
}
}
static int aMI_GetThisSceneCullIndex(void) {
int i;
for (i = 0; i < ARRAY_COUNT(aMI_museum_indoor_cull_info); i++) {
if (Save_Get(scene_no) == aMI_museum_indoor_cull_info[i].scene) {
return i;
}
}
return -1;
}
static void Museum_Indoor_Actor_ct(ACTOR* actorx, GAME* game) {
MUSEUM_INDOOR_ACTOR* museum_indoor = (MUSEUM_INDOOR_ACTOR*)actorx;
museum_indoor->alpha = 255.0f;
museum_indoor->cull_index = aMI_GetThisSceneCullIndex();
}
static void Museum_Indoor_Actor_dt(ACTOR* actorx, GAME* game) {
// nothing
}
static void Museum_Indoor_Actor_draw(ACTOR* actorx, GAME* game) {
MUSEUM_INDOOR_ACTOR* museum_indoor = (MUSEUM_INDOOR_ACTOR*)actorx;
if (museum_indoor->cull_index != -1) {
Gfx* cull_gfx = aMI_museum_indoor_cull_info[museum_indoor->cull_index].cull_gfx;
u8 r;
u8 g;
u8 b;
u8 a = (int)museum_indoor->alpha;
mEnv_GetRoomPrimColor(&r, &g, &b, (GAME_PLAY*)game);
OPEN_DISP(game->graph);
Matrix_translate(0.0f, 0.0f, 0.0f, 0);
Matrix_RotateY(0, 1);
Matrix_scale(0.0625f, 0.0625f, 0.0625f, 1);
gSPMatrix(NEXT_POLY_XLU_DISP, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 0, r, g, b, a);
gSPDisplayList(NEXT_POLY_XLU_DISP, cull_gfx);
CLOSE_DISP(game->graph);
}
}
static void aMI_SetAlpha(MUSEUM_INDOOR_ACTOR* museum_indoor, GAME* game) {
int cull_idx = museum_indoor->cull_index;
if (cull_idx != -1) {
int camera_state = Camera2NormalState_get((GAME_PLAY*)game);
f32* alpha_p = &museum_indoor->alpha;
switch (aMI_museum_indoor_cull_info[cull_idx].type) {
case 0:
if (camera_state == 3 || camera_state == 7) {
aMI_AlphaToOFF(alpha_p);
} else {
aMI_AlphaToON(alpha_p);
}
break;
case 1:
if (camera_state == 1 || camera_state == 5) {
aMI_AlphaToOFF(alpha_p);
} else {
aMI_AlphaToON(alpha_p);
}
break;
}
}
}
static void Museum_Indoor_Actor_move(ACTOR* actorx, GAME* game) {
MUSEUM_INDOOR_ACTOR* museum_indoor = (MUSEUM_INDOOR_ACTOR*)actorx;
aMI_SetAlpha(museum_indoor, game);
}