From e176d806d745b3be9b684e36d972002584206dd9 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 5 Jul 2022 18:39:38 -0700 Subject: [PATCH 01/81] Add painting objects + convert vanilla paintings into objects --- README.md | 2 +- actors/common1.h | 3 + actors/common1_geo.c | 1 + actors/painting/geo.inc.c | 9 + data/behavior_data.c | 20 +- include/behavior_data.h | 2 +- include/config/config_game.h | 7 +- include/level_commands.h | 2 + include/model_ids.h | 2 + include/object_constants.h | 9 +- include/object_fields.h | 21 + include/surface_terrains.h | 20 +- include/types.h | 2 + levels/castle_inside/areas/1/geo.inc.c | 24 +- levels/castle_inside/areas/2/geo.inc.c | 28 - levels/castle_inside/areas/3/collision.inc.c | 88 -- levels/castle_inside/areas/3/geo.inc.c | 19 - levels/castle_inside/header.h | 9 +- levels/castle_inside/painting.inc.c | 724 +++++------ levels/castle_inside/script.c | 72 +- levels/hmc/areas/1/geo.inc.c | 4 - levels/hmc/areas/1/painting.inc.c | 101 +- levels/hmc/script.c | 9 +- levels/scripts.c | 1 + levels/scripts.h | 1 + levels/ttm/areas/1/geo.inc.c | 2 - levels/ttm/areas/1/painting.inc.c | 64 +- levels/ttm/script.c | 7 +- src/engine/level_script.c | 6 +- src/engine/math_util.c | 22 + src/engine/math_util.h | 5 + src/engine/surface_collision.c | 14 + src/engine/surface_collision.h | 1 + src/engine/surface_load.c | 8 +- src/game/behavior_actions.c | 1 - src/game/behavior_actions.h | 1 - src/game/behaviors/clock_arm.inc.c | 26 +- src/game/behaviors/ddd_warp.inc.c | 13 - src/game/behaviors/door.inc.c | 10 +- src/game/camera.c | 64 +- src/game/camera.h | 6 + src/game/level_update.c | 40 +- src/game/object_helpers.c | 43 +- src/game/object_list_processor.c | 2 + src/game/paintings.c | 1201 ++++++------------ src/game/paintings.h | 137 +- src/game/sound_init.c | 5 +- src/game/sound_init.h | 2 + 48 files changed, 1101 insertions(+), 1759 deletions(-) create mode 100644 actors/painting/geo.inc.c delete mode 100644 src/game/behaviors/ddd_warp.inc.c diff --git a/README.md b/README.md index c399e90168..a27cc4d689 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin - **Fazana**: PuppyLib, ucode swapping, audio load time optimisations (with Arctic), general hacker qol improvements, visual debug - **Reonu**: Starting the project/repo, widescreen, reonucam, various defines for hacker QoL - **JoshDuMan**: Decomp guy, general assistance -- **Arceveti**: Silhouette, shadow optimisation, better hanging, breath meter +- **Arceveti**: Silhouette, shadow optimizations, better hanging, breath meter, painting objects, implementation of frameperfection's rounded corners fix, naming most unknowns, various hacker QOL improvements, and various optimizations/fixes - **axollyon**: Console testing, bugfixes, idea-guying, and had a hand in silhouettes - **Wiseguy**: World scale reimplementation, silhouette, graph node optimisations, instant input patch, cake screen fix, segmented code support, and various optimizations/fixes - **Kaze**: Graph node optimisations, automatic optimal collision distance diff --git a/actors/common1.h b/actors/common1.h index 179032ca2d..bb7be165f0 100644 --- a/actors/common1.h +++ b/actors/common1.h @@ -226,6 +226,9 @@ extern const Gfx mushroom_1up_seg3_dl_0302A660[]; // number extern const GeoLayout number_geo[]; +// painting +extern const GeoLayout painting_geo[]; + // pebble extern const Gfx pebble_seg3_dl_0301CB00[]; diff --git a/actors/common1_geo.c b/actors/common1_geo.c index 7f75637ae3..2788d99aa8 100644 --- a/actors/common1_geo.c +++ b/actors/common1_geo.c @@ -18,6 +18,7 @@ #include "leaves/geo.inc.c" #include "mario_cap/geo.inc.c" #include "number/geo.inc.c" +#include "painting/geo.inc.c" #include "mushroom_1up/geo.inc.c" #include "star/geo.inc.c" #include "dirt/geo.inc.c" diff --git a/actors/painting/geo.inc.c b/actors/painting/geo.inc.c new file mode 100644 index 0000000000..02afff3ee1 --- /dev/null +++ b/actors/painting/geo.inc.c @@ -0,0 +1,9 @@ +#include "game/paintings.h" + +const GeoLayout painting_geo[] = { + GEO_CULLING_RADIUS(2000), + GEO_OPEN_NODE(), + GEO_ASM(0, geo_painting_draw), + GEO_CLOSE_NODE(), + GEO_END(), +}; diff --git a/data/behavior_data.c b/data/behavior_data.c index 946a3808ef..bfed819f35 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -8,6 +8,7 @@ #include "game/behavior_actions.h" #include "game/mario_actions_cutscene.h" #include "game/mario_misc.h" +#include "game/paintings.h" #include "game/object_helpers.h" #include "game/debug.h" #include "menu/file_select.h" @@ -2232,16 +2233,6 @@ const BehaviorScript bhvWaterLevelPillar[] = { END_LOOP(), }; -const BehaviorScript bhvDddWarp[] = { - BEGIN(OBJ_LIST_SURFACE), - OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), - SET_FLOAT(oCollisionDistance, 30000), - BEGIN_LOOP(), - CALL_NATIVE(bhv_ddd_warp_loop), - CALL_NATIVE(load_object_collision_model), - END_LOOP(), -}; - const BehaviorScript bhvMoatGrills[] = { BEGIN(OBJ_LIST_SURFACE), #ifdef UNLOCK_ALL @@ -3504,6 +3495,15 @@ const BehaviorScript bhvUnlockDoorStar[] = { END_LOOP(), }; +const BehaviorScript bhvPainting[] = { + BEGIN(OBJ_LIST_LEVEL), + OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), + CALL_NATIVE(bhv_painting_init), + BEGIN_LOOP(), + CALL_NATIVE(bhv_painting_loop), + END_LOOP(), +}; + const BehaviorScript bhvInstantActiveWarp[] = { BREAK(), }; diff --git a/include/behavior_data.h b/include/behavior_data.h index 9702f974a0..5721c5ea76 100644 --- a/include/behavior_data.h +++ b/include/behavior_data.h @@ -173,7 +173,6 @@ extern const BehaviorScript bhvBowserKeyUnlockDoor[]; extern const BehaviorScript bhvBowserKeyCourseExit[]; extern const BehaviorScript bhvInvisibleObjectsUnderBridge[]; extern const BehaviorScript bhvWaterLevelPillar[]; -extern const BehaviorScript bhvDddWarp[]; extern const BehaviorScript bhvMoatGrills[]; extern const BehaviorScript bhvClockMinuteHand[]; extern const BehaviorScript bhvClockHourHand[]; @@ -294,6 +293,7 @@ extern const BehaviorScript bhvYellowBall[]; extern const BehaviorScript bhvMario[]; extern const BehaviorScript bhvToadMessage[]; extern const BehaviorScript bhvUnlockDoorStar[]; +extern const BehaviorScript bhvPainting[]; extern const BehaviorScript bhvInstantActiveWarp[]; extern const BehaviorScript bhvAirborneWarp[]; extern const BehaviorScript bhvHardAirKnockBackWarp[]; diff --git a/include/config/config_game.h b/include/config/config_game.h index 5c9456ebf3..55cec59d10 100644 --- a/include/config/config_game.h +++ b/include/config/config_game.h @@ -4,11 +4,8 @@ * GAME SETTINGS * *****************/ -/** - * Enables some mechanics that change behavior depending on hardcoded level numbers. - * You may also need to change sLevelsWithRooms in object_helpers.c. - * TODO: separate this into separate defines, behavior params, or make these mechanics otherwise dynamic. -*/ +// Enables some mechanics that change behavior depending on hardcoded level numbers. +// TODO: separate this into separate defines, behavior params, or make these mechanics otherwise dynamic. // #define ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS // Disables lives and hides the lives counter. diff --git a/include/level_commands.h b/include/level_commands.h index 5a935f2fa1..86a621ddfa 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -114,6 +114,8 @@ enum WarpCheckpointFlags { WARP_CHECKPOINT = (1 << 7), // 0x80 }; +#define WARP_DEST_LEVEL_NUM_MASK 0x7F + enum LevelCommandCreateWhirlpoolCondition { WHIRLPOOL_COND_ALWAYS, WHIRLPOOL_COND_BOWSER2_NOT_BEATEN, diff --git a/include/model_ids.h b/include/model_ids.h index 81e92c6a11..a26c749d13 100644 --- a/include/model_ids.h +++ b/include/model_ids.h @@ -550,6 +550,8 @@ #define MODEL_SILVER_COIN_NO_SHADOW 0xE3 // silver_coin_no_shadow_geo #endif +#define MODEL_PAINTING 0xE4 + // Menu Models (overwrites Level Geometry IDs) #define MODEL_MAIN_MENU_MARIO_SAVE_BUTTON MODEL_LEVEL_GEOMETRY_03 // main_menu_geo_0001D0 #define MODEL_MAIN_MENU_RED_ERASE_BUTTON MODEL_LEVEL_GEOMETRY_04 // main_menu_geo_000290 diff --git a/include/object_constants.h b/include/object_constants.h index 5884738aac..108440b374 100644 --- a/include/object_constants.h +++ b/include/object_constants.h @@ -2064,10 +2064,11 @@ enum oActionsSnowmansBottom { #define WATER_BOMB_ACT_EXPLODE 0x3 /* TTC Painting Clock Arm */ - /* oAction */ - #define CLOCK_ARM_ACT_CHECK_DEFAULT 0x0 - #define CLOCK_ARM_ACT_MOVING 0x1 - #define CLOCK_ARM_ACT_STOP 0x2 +enum oActionsTTCPaintingClockArm { + TTC_PAINTING_CLOCK_ARM_WAIT, + TTC_PAINTING_CLOCK_ARM_ACT_MOVING, + TTC_PAINTING_CLOCK_ARM_ACT_STOPPED, +}; /* TTC rotating solid */ /* oBehParams2ndByte */ diff --git a/include/object_fields.h b/include/object_fields.h index 2ee01bcd89..1261a4da2b 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -33,6 +33,7 @@ #define OBJECT_FIELD_CHAIN_SEGMENT(index) rawData.asChainSegment[index] #define OBJECT_FIELD_OBJ(index) rawData.asObject[index] #define OBJECT_FIELD_SURFACE(index) rawData.asSurface[index] +#define OBJECT_FIELD_PAINTING(index) rawData.asPainting[index] #define OBJECT_FIELD_VPTR(index) rawData.asVoidPtr[index] #define OBJECT_FIELD_CVPTR(index) rawData.asConstVoidPtr[index] #else @@ -43,6 +44,7 @@ #define OBJECT_FIELD_CHAIN_SEGMENT(index) ptrData.asChainSegment[index] #define OBJECT_FIELD_OBJ(index) ptrData.asObject[index] #define OBJECT_FIELD_SURFACE(index) ptrData.asSurface[index] +#define OBJECT_FIELD_PAINTING(index) rawData.asPainting[index] #define OBJECT_FIELD_VPTR(index) ptrData.asVoidPtr[index] #define OBJECT_FIELD_CVPTR(index) ptrData.asConstVoidPtr[index] #endif @@ -1254,6 +1256,25 @@ #define /*0x0FC*/ oYoshiChosenHome OBJECT_FIELD_S32(0x1D) #define /*0x100*/ oYoshiTargetYaw OBJECT_FIELD_S32(0x1E) +/* Painting */ +#define /*0x0F4*/ oPaintingPtr OBJECT_FIELD_PAINTING(0x1B) +#define /*0x0F8*/ oPaintingGroup OBJECT_FIELD_S16(0x1C, 0) +#define /*0x0FA*/ oPaintingId OBJECT_FIELD_S16(0x1C, 1) +#define /*0x1AC*/ oPaintingLocalMarioPosX OBJECT_FIELD_S16(0x1D, 0) +#define /*0x1AE*/ oPaintingLocalMarioPosY OBJECT_FIELD_S16(0x1D, 1) +#define /*0x100*/ oPaintingRippleX OBJECT_FIELD_S16(0x1E, 0) +#define /*0x104*/ oPaintingRippleY OBJECT_FIELD_S16(0x1E, 1) +#define /*0x108*/ oPaintingUpdateCounter OBJECT_FIELD_S16(0x1F, 0) +#define /*0x10C*/ oLastPaintingUpdateCounter OBJECT_FIELD_S16(0x1F, 1) +#define /*0x10C*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x21, 0) +#define /*0x10E*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x21, 1) +#define /*0x110*/ oPaintingState OBJECT_FIELD_S16(0x22, 0) +#define /*0x114*/ oPaintingRippleTimer OBJECT_FIELD_S16(0x22, 1) +#define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) +#define /*0x1A8*/ oPaintingRippleDecay OBJECT_FIELD_F32(0x48) +#define /*0x1AC*/ oPaintingCurrRippleRate OBJECT_FIELD_F32(0x49) +#define /*0x1B0*/ oPaintingDispersionFactor OBJECT_FIELD_F32(0x4A) + /*Custom general defines: diff --git a/include/surface_terrains.h b/include/surface_terrains.h index 95b20aa375..ec4a49bd31 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -227,20 +227,12 @@ enum SurfaceTypes { SURFACE_TRAPDOOR, // 0x00FF // Bowser Left trapdoor, has no action defined }; -#define SURFACE_IS_NEW_WATER(cmd) (((cmd) == SURFACE_NEW_WATER) || ((cmd) == SURFACE_NEW_WATER_BOTTOM)) -#define SURFACE_IS_QUICKSAND(cmd) ((((cmd) >= SURFACE_SHALLOW_QUICKSAND) && ((cmd) <= SURFACE_MOVING_QUICKSAND)) || ((cmd) == SURFACE_INSTANT_MOVING_QUICKSAND)) -#define SURFACE_IS_NOT_HARD(cmd) (((cmd) != SURFACE_HARD) && !((cmd) >= SURFACE_HARD_SLIPPERY && ((cmd) <= SURFACE_HARD_NOT_SLIPPERY))) -#define SURFACE_IS_PAINTING_WOBBLE(cmd) (((cmd) >= SURFACE_PAINTING_WOBBLE_A6) && ((cmd) <= SURFACE_PAINTING_WOBBLE_D2)) -#define SURFACE_IS_PAINTING_WOBBLE_LEFT(cmd) ((((cmd) - SURFACE_PAINTING_WOBBLE_A6) % 3) == 0) -#define SURFACE_IS_PAINTING_WOBBLE_MIDDLE(cmd) ((((cmd) - SURFACE_PAINTING_WOBBLE_A7) % 3) == 0) -#define SURFACE_IS_PAINTING_WOBBLE_RIGHT(cmd) ((((cmd) - SURFACE_PAINTING_WOBBLE_A8) % 3) == 0) -#define SURFACE_IS_PAINTING_WARP(cmd) (((cmd) >= SURFACE_PAINTING_WARP_D3) && ((cmd) < SURFACE_WOBBLING_WARP)) // skips SURFACE_WOBBLING_WARP -#define SURFACE_IS_PAINTING_WARP_LEFT(cmd) ((((cmd) - SURFACE_PAINTING_WARP_D3 ) % 3) == 0) -#define SURFACE_IS_PAINTING_WARP_MIDDLE(cmd) ((((cmd) - SURFACE_PAINTING_WARP_D4 ) % 3) == 0) -#define SURFACE_IS_PAINTING_WARP_RIGHT(cmd) ((((cmd) - SURFACE_PAINTING_WARP_D5 ) % 3) == 0) -#define SURFACE_IS_INSTANT_WARP(cmd) (((cmd) >= SURFACE_INSTANT_WARP_1B) && ((cmd) <= SURFACE_INSTANT_WARP_1E)) -#define SURFACE_IS_WARP(cmd) (((cmd) == SURFACE_LOOK_UP_WARP) || ((cmd) == SURFACE_WOBBLING_WARP) || SURFACE_IS_PAINTING_WARP(cmd) || SURFACE_IS_INSTANT_WARP(cmd)) -#define SURFACE_IS_UNSAFE(cmd) (((cmd) == SURFACE_BURNING) || SURFACE_IS_QUICKSAND(cmd) || SURFACE_IS_WARP(cmd)) +#define SURFACE_IS_NEW_WATER(cmd) (((cmd) == SURFACE_NEW_WATER) || ((cmd) == SURFACE_NEW_WATER_BOTTOM)) +#define SURFACE_IS_QUICKSAND(cmd) ((((cmd) >= SURFACE_SHALLOW_QUICKSAND) && ((cmd) <= SURFACE_MOVING_QUICKSAND)) || ((cmd) == SURFACE_INSTANT_MOVING_QUICKSAND)) +#define SURFACE_IS_NOT_HARD(cmd) (((cmd) != SURFACE_HARD) && !((cmd) >= SURFACE_HARD_SLIPPERY && ((cmd) <= SURFACE_HARD_NOT_SLIPPERY))) +#define SURFACE_IS_INSTANT_WARP(cmd) (((cmd) >= SURFACE_INSTANT_WARP_1B) && ((cmd) <= SURFACE_INSTANT_WARP_1E)) +#define SURFACE_IS_WARP(cmd) (((cmd) == SURFACE_LOOK_UP_WARP) || SURFACE_IS_INSTANT_WARP(cmd)) +#define SURFACE_IS_UNSAFE(cmd) (((cmd) == SURFACE_BURNING) || ((cmd) == SURFACE_DEATH_PLANE) || SURFACE_IS_QUICKSAND(cmd) || SURFACE_IS_WARP(cmd)) enum SurfaceClass { SURFACE_CLASS_DEFAULT, diff --git a/include/types.h b/include/types.h index 2e0f5189a6..300cd24a55 100644 --- a/include/types.h +++ b/include/types.h @@ -315,6 +315,7 @@ struct Object { struct ChainSegment *asChainSegment[MAX_OBJECT_FIELDS]; struct Object *asObject[MAX_OBJECT_FIELDS]; struct Surface *asSurface[MAX_OBJECT_FIELDS]; + struct Painting *asPainting[MAX_OBJECT_FIELDS]; void *asVoidPtr[MAX_OBJECT_FIELDS]; const void *asConstVoidPtr[MAX_OBJECT_FIELDS]; #endif @@ -328,6 +329,7 @@ struct Object { struct ChainSegment *asChainSegment[MAX_OBJECT_FIELDS]; struct Object *asObject[MAX_OBJECT_FIELDS]; struct Surface *asSurface[MAX_OBJECT_FIELDS]; + struct Painting *asPainting[MAX_OBJECT_FIELDS]; void *asVoidPtr[MAX_OBJECT_FIELDS]; const void *asConstVoidPtr[MAX_OBJECT_FIELDS]; } ptrData; diff --git a/levels/castle_inside/areas/1/geo.inc.c b/levels/castle_inside/areas/1/geo.inc.c index 39e863ba43..5918d4de36 100644 --- a/levels/castle_inside/areas/1/geo.inc.c +++ b/levels/castle_inside/areas/1/geo.inc.c @@ -48,8 +48,6 @@ const GeoLayout castle_geo_000FD0[] = { GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07032FC0), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07033158), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(0, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -61,8 +59,6 @@ const GeoLayout castle_geo_001000[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07034D88), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07035178), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07035288), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(2, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -77,8 +73,6 @@ const GeoLayout castle_geo_001038[] = { GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07037DE8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, dl_castle_aquarium_light), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07038350), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(3, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -89,10 +83,8 @@ const GeoLayout castle_geo_001088[] = { GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0703A6C8), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_0703A808), - GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_070234C0), - GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07023520), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(1, 1), geo_painting_draw), + GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_ccm_fake_painting_1), + GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_ccm_fake_painting_2), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -172,8 +164,6 @@ const GeoLayout castle_geo_001200[] = { GEO_ASM( 0, geo_exec_inside_castle_light), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07032FC0), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07033158), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(0, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -191,8 +181,6 @@ const GeoLayout castle_geo_001260[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07034D88), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07035178), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07035288), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(2, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -213,8 +201,6 @@ const GeoLayout castle_geo_0012C8[] = { GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07037DE8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, dl_castle_aquarium_light), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07038350), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(3, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -231,10 +217,8 @@ const GeoLayout castle_geo_001348[] = { GEO_ASM( 0, geo_exec_inside_castle_light), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0703A6C8), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_0703A808), - GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_070234C0), - GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07023520), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(1, 1), geo_painting_draw), + GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_ccm_fake_painting_1), + GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_ccm_fake_painting_2), GEO_CLOSE_NODE(), GEO_RETURN(), }; diff --git a/levels/castle_inside/areas/2/geo.inc.c b/levels/castle_inside/areas/2/geo.inc.c index 2f39672fc2..43803f5856 100644 --- a/levels/castle_inside/areas/2/geo.inc.c +++ b/levels/castle_inside/areas/2/geo.inc.c @@ -14,9 +14,6 @@ const GeoLayout castle_geo_001578[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07043028), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07043B48), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07043CD8), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(8, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(10, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -28,8 +25,6 @@ const GeoLayout castle_geo_0015B8[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0704A0E8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_0704A2E0), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0704AA98), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(12, 1), geo_painting_draw), GEO_ASM( 0, geo_render_mirror_mario), GEO_CLOSE_NODE(), GEO_RETURN(), @@ -40,9 +35,6 @@ const GeoLayout castle_geo_0015F8[] = { GEO_NODE_START(), GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0704C7D8), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(9, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(13, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -55,8 +47,6 @@ const GeoLayout castle_geo_001628[] = { GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07051678), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_070519C8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07051B60), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(11, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -80,9 +70,6 @@ const GeoLayout castle_geo_001690[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07043028), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07043B48), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07043CD8), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(8, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(10, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -97,10 +84,6 @@ const GeoLayout castle_geo_0016D8[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0704A0E8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_0704A2E0), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0704AA98), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(8, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(10, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(12, 1), geo_painting_draw), GEO_ASM( 0, geo_render_mirror_mario), GEO_CLOSE_NODE(), GEO_RETURN(), @@ -114,11 +97,6 @@ const GeoLayout castle_geo_001740[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07043B48), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07043CD8), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_0704C7D8), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(8, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(9, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(10, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(13, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -134,10 +112,6 @@ const GeoLayout castle_geo_001798[] = { GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07051678), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_070519C8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07051B60), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(8, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(10, 1), geo_painting_draw), - GEO_ASM(PAINTING_ID(11, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -153,8 +127,6 @@ const GeoLayout castle_geo_001800[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_070558D0), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_070572A0), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07057F00), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(11, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; diff --git a/levels/castle_inside/areas/3/collision.inc.c b/levels/castle_inside/areas/3/collision.inc.c index a74959bc68..88f1b0711a 100644 --- a/levels/castle_inside/areas/3/collision.inc.c +++ b/levels/castle_inside/areas/3/collision.inc.c @@ -2523,91 +2523,3 @@ const Collision inside_castle_seg7_area_3_collision[] = { COL_WATER_BOX(2, 5786, -1330, 8038, 410, -1228), COL_END(), }; - -// 0x070775B4 - 0x0707768C -const Collision inside_castle_seg7_collision_ddd_warp[] = { - COL_INIT(), - COL_VERTEX_INIT(0x12), - COL_VERTEX(3866, -1074, 1587), - COL_VERTEX(3487, -1074, 1864), - COL_VERTEX(3866, -1074, 1864), - COL_VERTEX(3487, -1074, 1587), - COL_VERTEX(3487, -1074, 2135), - COL_VERTEX(3866, -1074, 2135), - COL_VERTEX(3487, -1074, 2406), - COL_VERTEX(3866, -1074, 2406), - COL_VERTEX(5939, -1074, 1587), - COL_VERTEX(5530, -1074, 1587), - COL_VERTEX(5530, -1074, 1864), - COL_VERTEX(5939, -1074, 1864), - COL_VERTEX(5530, -1074, 2135), - COL_VERTEX(5939, -1074, 2135), - COL_VERTEX(5530, -1074, 2406), - COL_VERTEX(5939, -1074, 2406), - COL_VERTEX(3456, -1074, 1587), - COL_VERTEX(3456, -1074, 2406), - COL_TRI_INIT(SURFACE_DEFAULT, 8), - COL_TRI(3, 16, 17), - COL_TRI(3, 17, 6), - COL_TRI(8, 9, 10), - COL_TRI(8, 10, 11), - COL_TRI(11, 10, 12), - COL_TRI(11, 12, 13), - COL_TRI(13, 12, 14), - COL_TRI(13, 14, 15), - COL_TRI_INIT(SURFACE_PAINTING_WARP_E8, 2), - COL_TRI(0, 1, 2), - COL_TRI(0, 3, 1), - COL_TRI_INIT(SURFACE_PAINTING_WARP_E9, 2), - COL_TRI(2, 1, 4), - COL_TRI(2, 4, 5), - COL_TRI_INIT(SURFACE_PAINTING_WARP_EA, 2), - COL_TRI(5, 6, 7), - COL_TRI(5, 4, 6), - COL_TRI_STOP(), - COL_END(), -}; - -// 0x0707768C - 0x07077764 -const Collision inside_castle_seg7_collision_ddd_warp_2[] = { - COL_INIT(), - COL_VERTEX_INIT(0x12), - COL_VERTEX(5939, -1074, 1587), - COL_VERTEX(5560, -1074, 1864), - COL_VERTEX(5939, -1074, 1864), - COL_VERTEX(5560, -1074, 1587), - COL_VERTEX(5560, -1074, 2135), - COL_VERTEX(5939, -1074, 2135), - COL_VERTEX(5560, -1074, 2406), - COL_VERTEX(5939, -1074, 2406), - COL_VERTEX(5530, -1074, 1587), - COL_VERTEX(5530, -1074, 2406), - COL_VERTEX(3866, -1074, 1864), - COL_VERTEX(3456, -1074, 2135), - COL_VERTEX(3866, -1074, 2135), - COL_VERTEX(3456, -1074, 2406), - COL_VERTEX(3866, -1074, 2406), - COL_VERTEX(3456, -1074, 1864), - COL_VERTEX(3866, -1074, 1587), - COL_VERTEX(3456, -1074, 1587), - COL_TRI_INIT(SURFACE_DEFAULT, 8), - COL_TRI(8, 9, 6), - COL_TRI(8, 6, 3), - COL_TRI(10, 11, 12), - COL_TRI(12, 13, 14), - COL_TRI(12, 11, 13), - COL_TRI(10, 15, 11), - COL_TRI(16, 15, 10), - COL_TRI(16, 17, 15), - COL_TRI_INIT(SURFACE_PAINTING_WARP_E8, 2), - COL_TRI(0, 1, 2), - COL_TRI(0, 3, 1), - COL_TRI_INIT(SURFACE_PAINTING_WARP_E9, 2), - COL_TRI(2, 4, 5), - COL_TRI(2, 1, 4), - COL_TRI_INIT(SURFACE_PAINTING_WARP_EA, 2), - COL_TRI(5, 4, 6), - COL_TRI(5, 6, 7), - COL_TRI_STOP(), - COL_END(), -}; diff --git a/levels/castle_inside/areas/3/geo.inc.c b/levels/castle_inside/areas/3/geo.inc.c index ad1fbcf691..939ce9c538 100644 --- a/levels/castle_inside/areas/3/geo.inc.c +++ b/levels/castle_inside/areas/3/geo.inc.c @@ -15,9 +15,6 @@ const GeoLayout castle_geo_001980[] = { GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_070616E8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07061C20), - GEO_ASM( 0, geo_painting_update), - GEO_ASM( PAINTING_ID(4, 1), geo_painting_draw), - GEO_ASM( PAINTING_ID(5, 1), geo_painting_draw), GEO_ASM( 0, geo_movtex_pause_control), GEO_ASM(INSIDE_CASTLE_MOVTEX_GREEN_ROOM_WATER, geo_movtex_draw_water_regions), GEO_CLOSE_NODE(), @@ -30,8 +27,6 @@ const GeoLayout castle_geo_0019C8[] = { GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07064B78), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07064D58), - GEO_ASM(0, geo_painting_update), - GEO_ASM(PAINTING_ID(6, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -54,8 +49,6 @@ const GeoLayout castle_geo_001A30[] = { GEO_NODE_START(), GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07068850), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(7, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -69,9 +62,6 @@ const GeoLayout castle_geo_001A58[] = { GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_0705E450), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_070616E8), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07061C20), - GEO_ASM( 0, geo_painting_update), - GEO_ASM( PAINTING_ID(4, 1), geo_painting_draw), - GEO_ASM( PAINTING_ID(5, 1), geo_painting_draw), GEO_ASM( 0, geo_movtex_pause_control), GEO_ASM(INSIDE_CASTLE_MOVTEX_GREEN_ROOM_WATER, geo_movtex_draw_water_regions), GEO_CLOSE_NODE(), @@ -86,8 +76,6 @@ const GeoLayout castle_geo_001AB8[] = { GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_0705E2A0), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_0705E450), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07068850), - GEO_ASM( 0, geo_painting_update), - GEO_ASM(PAINTING_ID(7, 1), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -117,9 +105,6 @@ const GeoLayout castle_geo_001B48[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07066CE0), GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07066E90), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07066FA0), - GEO_ASM( 0, geo_painting_update), - GEO_ASM( PAINTING_ID(4, 1), geo_painting_draw), - GEO_ASM( PAINTING_ID(5, 1), geo_painting_draw), GEO_ASM( 0, geo_movtex_pause_control), GEO_ASM(INSIDE_CASTLE_MOVTEX_GREEN_ROOM_WATER, geo_movtex_draw_water_regions), GEO_ASM(INSIDE_CASTLE_MOVTEX_MOAT_WATER, geo_movtex_draw_water_regions), @@ -135,10 +120,6 @@ const GeoLayout castle_geo_001BB0[] = { GEO_DISPLAY_LIST(LAYER_TRANSPARENT, inside_castle_seg7_dl_07061C20), GEO_DISPLAY_LIST(LAYER_OPAQUE, inside_castle_seg7_dl_07064B78), GEO_DISPLAY_LIST(LAYER_ALPHA, inside_castle_seg7_dl_07064D58), - GEO_ASM( 0, geo_painting_update), - GEO_ASM( PAINTING_ID(4, 1), geo_painting_draw), - GEO_ASM( PAINTING_ID(5, 1), geo_painting_draw), - GEO_ASM( PAINTING_ID(6, 1), geo_painting_draw), GEO_ASM( 0, geo_movtex_pause_control), GEO_ASM(INSIDE_CASTLE_MOVTEX_GREEN_ROOM_WATER, geo_movtex_draw_water_regions), GEO_CLOSE_NODE(), diff --git a/levels/castle_inside/header.h b/levels/castle_inside/header.h index 891fee8273..f476bcbf38 100644 --- a/levels/castle_inside/header.h +++ b/levels/castle_inside/header.h @@ -55,10 +55,8 @@ extern const GeoLayout castle_geo_001BB0[]; extern const GeoLayout castle_geo_001C10[]; // leveldata -extern const Gfx inside_castle_seg7_dl_070225D8[]; -extern const Gfx inside_castle_seg7_dl_07022610[]; -extern const Gfx inside_castle_seg7_dl_070234C0[]; -extern const Gfx inside_castle_seg7_dl_07023520[]; +extern const Gfx inside_castle_seg7_dl_ccm_fake_painting_1[]; +extern const Gfx inside_castle_seg7_dl_ccm_fake_painting_2[]; extern struct Painting bob_painting; extern struct Painting ccm_painting; extern struct Painting wf_painting; @@ -73,6 +71,7 @@ extern struct Painting ttm_painting; extern struct Painting ttc_painting; extern struct Painting sl_painting; extern struct Painting thi_huge_painting; +extern struct Painting rr_painting; extern const Gfx inside_castle_seg7_dl_bowser_1_painting[]; extern const Gfx inside_castle_seg7_dl_07028FD0[]; extern const Gfx inside_castle_seg7_dl_07029578[]; @@ -136,8 +135,6 @@ extern const Gfx inside_castle_seg7_dl_07068B10[]; extern const Collision inside_castle_seg7_area_1_collision[]; extern const Collision inside_castle_seg7_area_2_collision[]; extern const Collision inside_castle_seg7_area_3_collision[]; -extern const Collision inside_castle_seg7_collision_ddd_warp[]; -extern const Collision inside_castle_seg7_collision_ddd_warp_2[]; extern const MacroObject inside_castle_seg7_area_1_macro_objs[]; extern const MacroObject inside_castle_seg7_area_2_macro_objs[]; extern const MacroObject inside_castle_seg7_area_3_macro_objs[]; diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index d668820f14..7f155adc2e 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -1,13 +1,13 @@ #include "game/paintings.h" // 0x07021800 - 0x07021818 -static const Lights1 inside_castle_seg7_lights_07021800 = gdSPDefLights1( +static const Lights1 inside_castle_seg7_lights_painting = gdSPDefLights1( 0x50, 0x50, 0x50, 0xff, 0xff, 0xff, 0x32, 0x32, 0x32 ); // 0x07021818 - 0x07021898 -static const Vtx inside_castle_seg7_vertex_07021818[] = { +static const Vtx inside_castle_seg7_vertex_painting_textured[] = { {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 307, 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, @@ -19,7 +19,7 @@ static const Vtx inside_castle_seg7_vertex_07021818[] = { }; // 0x07021898 - 0x07021918 -static const Vtx inside_castle_seg7_vertex_07021898[] = { +static const Vtx inside_castle_seg7_vertex_painting_sl[] = { {{{ 0, 0, 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, {{{ 614, 0, 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, {{{ 614, 307, 0}, 0, { 2012, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, @@ -31,7 +31,7 @@ static const Vtx inside_castle_seg7_vertex_07021898[] = { }; // 0x07021918 - 0x07021998 -static const Vtx inside_castle_seg7_vertex_07021918[] = { +static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_1[] = { {{{ -3046, -307, -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ -2742, -307, -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ -2742, 0, -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, @@ -43,7 +43,7 @@ static const Vtx inside_castle_seg7_vertex_07021918[] = { }; // 0x07021998 - 0x07021A18 -static const Vtx inside_castle_seg7_vertex_07021998[] = { +static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_2[] = { {{{ -1866, -307, -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ -1562, -307, -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ -1562, 0, -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, @@ -55,24 +55,24 @@ static const Vtx inside_castle_seg7_vertex_07021998[] = { }; // 0x07021A18 - 0x07021A30 -static const Gfx inside_castle_seg7_dl_07021A18[] = { +static const Gfx inside_castle_seg7_sub_dl_painting_bottom[] = { gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; // 0x07021A30 - 0x07021A48 -static const Gfx inside_castle_seg7_dl_07021A30[] = { +static const Gfx inside_castle_seg7_sub_dl_painting_top[] = { gsSP2Triangles( 4, 5, 6, 0x0, 4, 6, 7, 0x0), gsSPEndDisplayList(), }; // 0x07021A48 - 0x07021AA0 -static const Gfx inside_castle_seg7_dl_07021A48[] = { +static const Gfx inside_castle_seg7_dl_painting_texture_begin[] = { gsDPPipeSync(), gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - gsSPLight(&inside_castle_seg7_lights_07021800.l, 1), - gsSPLight(&inside_castle_seg7_lights_07021800.a, 2), + gsSPLight(&inside_castle_seg7_lights_painting.l, 1), + gsSPLight(&inside_castle_seg7_lights_painting.a, 2), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), @@ -82,7 +82,7 @@ static const Gfx inside_castle_seg7_dl_07021A48[] = { }; // 0x07021AA0 - 0x07021AC0 -static const Gfx inside_castle_seg7_dl_07021AA0[] = { +static const Gfx inside_castle_seg7_dl_painting_texture_end[] = { gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPPipeSync(), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), @@ -90,7 +90,7 @@ static const Gfx inside_castle_seg7_dl_07021AA0[] = { }; // 0x07021AC0 - 0x07021AE0 -static const Gfx inside_castle_seg7_painting_dl_07021AC0[] = { +static const Gfx inside_castle_seg7_painting_dl_image_ripple[] = { gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), @@ -561,63 +561,22 @@ static const PaintingData *const inside_castle_seg7_painting_texture_maps_070225 inside_castle_seg7_painting_texture_map_top_07021FFC, }; -UNUSED static const u64 castle_inside_unused_0 = 0x0; - - -// 0x07022528 - 0x07022540 -static const Lights1 inside_castle_seg7_lights_07022528 = gdSPDefLights1( - 0x50, 0x50, 0x50, - 0xff, 0xff, 0xff, 0x32, 0x32, 0x32 -); - // 0x07022540 - 0x07022558 -// No gdSPDefLights1 macro defined because of odd different light value (0xff and 0xfa) -static const Lights1 inside_castle_seg7_lights_07022540 = { - {{ {0x40, 0x40, 0x80}, 0, {0x40, 0x40, 0x80}, 0} }, - {{{ {0x64, 0x64, 0xff}, 0, {0x64, 0x64, 0xfa}, 0, {0x28, 0x28, 0x28},0} }} -}; - -// 0x07022558 - 0x07022598 -static const Vtx inside_castle_seg7_vertex_07022558[] = { - {{{ 0, 0, 0}, 0, { -32, 990}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 0, 0}, 0, { 6100, 990}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 614, 0}, 0, { 6100, -5142}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 614, 0}, 0, { -32, -5142}, {0x00, 0x00, 0x7f, 0xff}}}, -}; +static const Lights1 inside_castle_seg7_lights_07022540 = gdSPDefLights1( + 0x40, 0x40, 0x80, + 0x64, 0x64, 0xff, 0x28, 0x28, 0x28 +); // 0x07022598 - 0x070225D8 -static const Vtx inside_castle_seg7_vertex_07022598[] = { +static const Vtx inside_castle_seg7_vertex_hmc[] = { {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 0, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; -// TODO: this is unused -// 0x070225D8 - 0x07022610 -const Gfx inside_castle_seg7_dl_070225D8[] = { - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - gsSPLight(&inside_castle_seg7_lights_07022528.l, 1), - gsSPLight(&inside_castle_seg7_lights_07022528.a, 2), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPVertex(inside_castle_seg7_vertex_07022558, 4, 0), - gsSPEndDisplayList(), -}; - -// TODO: this is unused -// 0x07022610 - 0x07022640 -const Gfx inside_castle_seg7_dl_07022610[] = { - gsSP1Triangle( 0, 1, 2, 0x0), - gsSP1Triangle( 0, 2, 3, 0x0), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - // 0x07022640 - 0x07022660 -static const Gfx inside_castle_seg7_painting_dl_07022640[] = { +static const Gfx inside_castle_seg7_painting_dl_env_map_ripple[] = { gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), @@ -1063,171 +1022,168 @@ static const PaintingData *const inside_castle_seg7_painting_env_map_texture_map inside_castle_seg7_painting_env_map_texture_map_07022660, }; -UNUSED static const u64 castle_inside_unused_1 = 0x0; - - // 0x07023050 - 0x070230B0 -static const Gfx inside_castle_seg7_painting_dl_07023050[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_bob[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700B800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700A800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x070230B0 - 0x07023110 -static const Gfx inside_castle_seg7_painting_dl_070230B0[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_ccm[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700C800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023110 - 0x07023170 -static const Gfx inside_castle_seg7_painting_dl_07023110[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_wf[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700F800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700E800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023170 - 0x070231D0 -static const Gfx inside_castle_seg7_painting_dl_07023170[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_jrb[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07011800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07010800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x070231D0 - 0x07023230 -static const Gfx inside_castle_seg7_painting_dl_070231D0[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_lll[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07012800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07013800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023230 - 0x07023290 -static const Gfx inside_castle_seg7_painting_dl_07023230[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_ssl[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07015800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07014800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023290 - 0x070232F0 -static const Gfx inside_castle_seg7_painting_dl_07023290[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_wdw[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07018800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07017800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x070232F0 - 0x07023350 -static const Gfx inside_castle_seg7_painting_dl_070232F0[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_thi[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701A800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07019800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023350 - 0x070233B0 -static const Gfx inside_castle_seg7_painting_dl_07023350[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_ttm[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701C800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701B800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x070233B0 - 0x07023410 -static const Gfx inside_castle_seg7_painting_dl_070233B0[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021818, 8, 0), +static const Gfx inside_castle_seg7_painting_dl_ttc[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701E800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701D800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023410 - 0x070234C0 -static const Gfx inside_castle_seg7_painting_dl_07023410[] = { +static const Gfx inside_castle_seg7_painting_dl_sl[] = { gsDPPipeSync(), gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), gsSPClearGeometryMode(G_LIGHTING), @@ -1236,15 +1192,15 @@ static const Gfx inside_castle_seg7_painting_dl_07023410[] = { gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPVertex(inside_castle_seg7_vertex_07021898, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_sl, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07020800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701F800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPPipeSync(), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), @@ -1253,479 +1209,411 @@ static const Gfx inside_castle_seg7_painting_dl_07023410[] = { }; // 0x070234C0 - 0x07023520 -const Gfx inside_castle_seg7_dl_070234C0[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021918, 8, 0), +const Gfx inside_castle_seg7_dl_ccm_fake_painting_1[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_ccm_fake_1, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700C800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023520 - 0x07023580 -const Gfx inside_castle_seg7_dl_07023520[] = { - gsSPDisplayList(inside_castle_seg7_dl_07021A48), - gsSPVertex(inside_castle_seg7_vertex_07021998, 8, 0), +const Gfx inside_castle_seg7_dl_ccm_fake_painting_2[] = { + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPVertex(inside_castle_seg7_vertex_painting_ccm_fake_2, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A18), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700C800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_dl_07021A30), - gsSPDisplayList(inside_castle_seg7_dl_07021AA0), + gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), + gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), gsSPEndDisplayList(), }; // 0x07023580 - 0x070235B8 -static const Gfx inside_castle_seg7_painting_dl_07023580[] = { +static const Gfx inside_castle_seg7_painting_dl_hmc[] = { gsDPPipeSync(), gsSPLight(&inside_castle_seg7_lights_07022540.l, 1), gsSPLight(&inside_castle_seg7_lights_07022540.a, 2), - gsSPVertex(inside_castle_seg7_vertex_07022598, 4, 0), + gsSPVertex(inside_castle_seg7_vertex_hmc, 4, 0), gsSP1Triangle( 0, 1, 2, 0x0), gsSP1Triangle( 0, 2, 3, 0x0), gsSPEndDisplayList(), }; // 0x070235B8 - 0x070235C0 -static const Gfx inside_castle_seg7_painting_dl_070235B8[] = { - gsSPBranchList(inside_castle_seg7_painting_dl_07023580), +static const Gfx inside_castle_seg7_painting_dl_ddd[] = { + gsSPBranchList(inside_castle_seg7_painting_dl_hmc), }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235C0[] = { - inside_castle_seg7_texture_0700B800, inside_castle_seg7_texture_0700A800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_bob[] = { + inside_castle_seg7_texture_0700B800, + inside_castle_seg7_texture_0700A800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235C8[] = { - inside_castle_seg7_texture_0700D800, inside_castle_seg7_texture_0700C800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] = { + inside_castle_seg7_texture_0700D800, + inside_castle_seg7_texture_0700C800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235D0[] = { - inside_castle_seg7_texture_0700F800, inside_castle_seg7_texture_0700E800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = { + inside_castle_seg7_texture_0700F800, + inside_castle_seg7_texture_0700E800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235D8[] = { - inside_castle_seg7_texture_07011800, inside_castle_seg7_texture_07010800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] = { + inside_castle_seg7_texture_07011800, + inside_castle_seg7_texture_07010800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235E0[] = { - inside_castle_seg7_texture_07012800, inside_castle_seg7_texture_07013800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] = { + inside_castle_seg7_texture_07012800, + inside_castle_seg7_texture_07013800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235E8[] = { - inside_castle_seg7_texture_07015800, inside_castle_seg7_texture_07014800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] = { + inside_castle_seg7_texture_07015800, + inside_castle_seg7_texture_07014800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235F0[] = { +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_hmc_env[] = { inside_castle_seg7_texture_07016800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235F4[] = { +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ddd_env[] = { inside_castle_seg7_texture_07017000, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_070235F8[] = { - inside_castle_seg7_texture_07018800, inside_castle_seg7_texture_07017800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] = { + inside_castle_seg7_texture_07018800, + inside_castle_seg7_texture_07017800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_07023600[] = { - inside_castle_seg7_texture_0701A800, inside_castle_seg7_texture_07019800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] = { + inside_castle_seg7_texture_0701A800, + inside_castle_seg7_texture_07019800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_07023608[] = { - inside_castle_seg7_texture_0701C800, inside_castle_seg7_texture_0701B800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] = { + inside_castle_seg7_texture_0701C800, + inside_castle_seg7_texture_0701B800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_07023610[] = { - inside_castle_seg7_texture_0701E800, inside_castle_seg7_texture_0701D800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] = { + inside_castle_seg7_texture_0701E800, + inside_castle_seg7_texture_0701D800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_07023618[] = { - inside_castle_seg7_texture_07020800, inside_castle_seg7_texture_0701F800, +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = { + inside_castle_seg7_texture_07020800, + inside_castle_seg7_texture_0701F800, }; // 0x07023620 - 0x07023698 -struct Painting bob_painting = { - /* id */ 0x0000, +const struct Painting bob_painting = { + /* id */ PAINTING_ID_CASTLE_BOB, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 90.0f, - /* Position */ -5222.4f, 409.6f, -153.6f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023050, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_bob, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235C0, + /* Textures */ inside_castle_seg7_painting_textures_bob, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x07023698 - 0x07023710 -struct Painting ccm_painting = { - /* id */ 0x0001, +const struct Painting ccm_painting = { + /* id */ PAINTING_ID_CASTLE_CCM, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 0.0f, - /* Position */ -2611.2f, -307.2f, -4352.0f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_070230B0, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_ccm, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235C8, + /* Textures */ inside_castle_seg7_painting_textures_ccm, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x07023710 - 0x07023788 -struct Painting wf_painting = { - /* id */ 0x0002, +const struct Painting wf_painting = { + /* id */ PAINTING_ID_CASTLE_WF, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 0.0f, - /* Position */ -51.2f, -204.8f, -4505.6f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023110, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_wf, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235D0, + /* Textures */ inside_castle_seg7_painting_textures_wf, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x07023788 - 0x07023800 -struct Painting jrb_painting = { - /* id */ 0x0003, +const struct Painting jrb_painting = { + /* id */ PAINTING_ID_CASTLE_JRB, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 270.0f, - /* Position */ 4300.8f, 409.6f, -537.6f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023170, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_jrb, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235D8, + /* Textures */ inside_castle_seg7_painting_textures_jrb, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x07023800 - 0x07023878 -struct Painting lll_painting = { - /* id */ 0x0004, +const struct Painting lll_painting = { + /* id */ PAINTING_ID_CASTLE_LLL, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 0.0f, - /* Position */ -1689.6f, -1126.4f, -3942.4f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_070231D0, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_lll, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235E0, + /* Textures */ inside_castle_seg7_painting_textures_lll, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x07023878 - 0x070238F0 -struct Painting ssl_painting = { - /* id */ 0x0005, +const struct Painting ssl_painting = { + /* id */ PAINTING_ID_CASTLE_SSL, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 180.0f, - /* Position */ -2611.2f, -1177.6f, -1075.2f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023230, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_ssl, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235E8, + /* Textures */ inside_castle_seg7_painting_textures_ssl, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x070238F0 - 0x07023968 -struct Painting hmc_painting = { - /* id */ 0x000E, +const struct Painting hmc_painting = { + /* id */ PAINTING_ID_CASTLE_HMC, /* Image Count */ 0x01, /* Texture Type */ PAINTING_ENV_MAP, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 270.0f, 0.0f, - /* Position */ 2099.2f, -1484.8f, -2278.4f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 1.0f, 0.98f, - /* Ripple Rate */ 0.0f, 0.05f, 0.05f, - /* Ripple Dispersion */ 0.0f, 15.0f, 15.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023580, + /* passive entry */ + /* Ripple Magnitude */ 10.0f, 30.0f, + /* Ripple Decay */ 1.0f, 0.98f, + /* Ripple Rate */ 0.05f, 0.05f, + /* Ripple Dispersion */ 15.0f, 15.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_hmc, /* Texture Maps */ inside_castle_seg7_painting_env_map_texture_maps_07023044, - /* Textures */ inside_castle_seg7_painting_textures_070235F0, + /* Textures */ inside_castle_seg7_painting_textures_hmc_env, /* Texture w, h */ 32, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07022640, + /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 768.0f, + /* Size */ 768.0f, 768.0f, }; // 0x07023968 - 0x070239E0 -struct Painting ddd_painting = { - /* id */ 0x0007, +const struct Painting ddd_painting = { + /* id */ PAINTING_ID_CASTLE_DDD, /* Image Count */ 0x01, /* Texture Type */ PAINTING_ENV_MAP, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 270.0f, - /* Position */ 3456.0f, -1075.2f, 1587.2f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 1.0f, 0.98f, - /* Ripple Rate */ 0.0f, 0.05f, 0.05f, - /* Ripple Dispersion */ 0.0f, 15.0f, 15.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_070235B8, + /* passive entry */ + /* Ripple Magnitude */ 10.0f, 30.0f, + /* Ripple Decay */ 1.0f, 0.98f, + /* Ripple Rate */ 0.05f, 0.05f, + /* Ripple Dispersion */ 15.0f, 15.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_ddd, /* Texture Maps */ inside_castle_seg7_painting_env_map_texture_maps_07023044, - /* Textures */ inside_castle_seg7_painting_textures_070235F4, + /* Textures */ inside_castle_seg7_painting_textures_ddd_env, /* Texture w, h */ 32, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07022640, + /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xB4, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 819.2f, + /* Size */ 819.2f, 819.2f, }; // 0x070239E0 - 0x07023A58 -struct Painting wdw_painting = { - /* id */ 0x0008, +const struct Painting wdw_painting = { + /* id */ PAINTING_ID_CASTLE_WDW, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 0.0f, - /* Position */ -966.656f, 1305.6f, -143.36f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023290, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_wdw, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_070235F8, + /* Textures */ inside_castle_seg7_painting_textures_wdw, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 614.0f, + /* Size */ 614.0f, 614.0f, }; // 0x07023A58 - 0x07023AD0 -struct Painting thi_tiny_painting = { - /* id */ 0x0009, +const struct Painting thi_tiny_painting = { + /* id */ PAINTING_ID_CASTLE_THI_TINY, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 180.0f, - /* Position */ -4598.7842f, 1354.752f, 3005.44f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_070232F0, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_thi, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_07023600, + /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 393.216f, + /* Size */ 393.216f, 393.216f, }; // 0x07023AD0 - 0x07023B48 -struct Painting ttm_painting = { - /* id */ 0x000A, +const struct Painting ttm_painting = { + /* id */ PAINTING_ID_CASTLE_TTM, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 180.0f, - /* Position */ -546.816f, 1356.8f, 3813.376f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023350, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_ttm, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_07023608, + /* Textures */ inside_castle_seg7_painting_textures_ttm, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 256.0f, + /* Size */ 256.0f, 256.0f, }; // 0x07023B48 - 0x07023BC0 -struct Painting ttc_painting = { - /* id */ 0x000B, +const struct Painting ttc_painting = { + /* id */ PAINTING_ID_CASTLE_TTC, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 180.0f, - /* Position */ 0.0f, 2713.6f, 7232.5122f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_070233B0, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_ttc, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_07023610, + /* Textures */ inside_castle_seg7_painting_textures_ttc, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 409.6f, + /* Size */ 409.6f, 409.6f, }; // 0x07023BC0 - 0x07023C38 -struct Painting sl_painting = { - /* id */ 0x000C, +const struct Painting sl_painting = { + /* id */ PAINTING_ID_CASTLE_SL, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 0.0f, - /* Position */ 3179.52f, 1408.0f, -271.36f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_07023410, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_sl, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_07023618, + /* Textures */ inside_castle_seg7_painting_textures_sl, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 716.8f, + /* Size */ 716.8f, 716.8f, }; // 0x07023C38 - 0x07023CB0 -struct Painting thi_huge_painting = { - /* id */ 0x000D, +const struct Painting thi_huge_painting = { + /* id */ PAINTING_ID_CASTLE_THI_HUGE, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 0.0f, - /* Position */ -5614.5918f, 1510.4f, -3292.16f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 40.0f, 160.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.12f, 0.07f, - /* Ripple Dispersion */ 0.0f, 80.0f, 60.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ inside_castle_seg7_painting_dl_070232F0, + /* passive entry */ + /* Ripple Magnitude */ 40.0f, 160.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.12f, 0.07f, + /* Ripple Dispersion */ 80.0f, 60.0f, + /* Normal DList */ inside_castle_seg7_painting_dl_thi, /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, - /* Textures */ inside_castle_seg7_painting_textures_07023600, + /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_07021AC0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 1638.4f, + /* Size */ 1638.4f, 1638.4f, +}; + +const struct Painting rr_painting = { + /* id */ PAINTING_ID_CASTLE_THI_HUGE, + /* Image Count */ 0x00, + /* Texture Type */ PAINTING_IMAGE, + /* passive entry */ + /* Ripple Magnitude */ 40.0f, 160.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.12f, 0.07f, + /* Ripple Dispersion */ 80.0f, 60.0f, + /* Normal DList */ NULL, + /* Texture Maps */ NULL, + /* Textures */ NULL, + /* Texture w, h */ 0, 0, + /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Alpha */ 0x00, + /* Size */ 204.8f, 204.8f, }; diff --git a/levels/castle_inside/script.c b/levels/castle_inside/script.c index 0011560302..07ef1daf34 100644 --- a/levels/castle_inside/script.c +++ b/levels/castle_inside/script.c @@ -30,18 +30,14 @@ static const LevelScript script_func_local_1[] = { WARP_NODE(/*id*/ 0x04, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x01, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x05, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x00, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x06, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x01, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x00, /*destLevel*/ LEVEL_BOB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x01, /*destLevel*/ LEVEL_BOB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x02, /*destLevel*/ LEVEL_BOB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x03, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x04, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x05, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x06, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x07, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x08, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x09, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -5222, 410, -154, /*angle*/ 0, 90, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_BOB, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -2611, -307, -4352, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_CCM, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -51, -205, -4506, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_WF, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 4300, 410, -538, /*angle*/ 0, 270, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_JRB, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_BOB, /*destLevel*/ LEVEL_BOB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_CCM, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_WF, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_JRB, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2013, 768, -2014, /*angle*/ 0, 0, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_PSS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5513, 512, -4324, /*angle*/ 0, 0, 0, /*behParam*/ 0x300B0000, /*beh*/ bhvWarp), @@ -99,25 +95,20 @@ static const LevelScript script_func_local_2[] = { OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_50_STARS, /*pos*/ -127, 2253, 4762, /*angle*/ 0, 180, 0, /*behParam*/ 0x32000000, /*beh*/ bhvStarDoor), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_70_STARS, /*pos*/ -281, 3174, 3772, /*angle*/ 0, 0, 0, /*behParam*/ 0x46000000, /*beh*/ bhvStarDoor), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_70_STARS, /*pos*/ -127, 3174, 3772, /*angle*/ 0, 180, 0, /*behParam*/ 0x46000000, /*beh*/ bhvStarDoor), - PAINTING_WARP_NODE(/*id*/ 0x18, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x19, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x1A, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x1B, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x1C, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x1D, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x1E, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x1F, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x20, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x21, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x22, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x23, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x24, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x25, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x26, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x27, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x28, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x29, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x2A, /*destLevel*/ LEVEL_RR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -967, 1306, -143, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_WDW, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -4599, 1355, 3005, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_THI_TINY, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -547, 1357, 3813, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_TTM, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 0, 2714, 7233, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_TTC, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3180, 1408, -271, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_SL, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -5615, 1510, -3292, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_THI_HUGE, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -3513, 2970, 5989, /*angle*/ 270, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_RR, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_WDW, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_THI_TINY, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_TTM, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_TTC, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_SL, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_THI_HUGE, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_RR, /*destLevel*/ LEVEL_RR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3002, 2816, 5886, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F0A0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WMOTR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -230, 4813, -3352, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F0B0000, /*beh*/ bhvWarp), @@ -167,16 +158,14 @@ static const LevelScript script_func_local_3[] = { WARP_NODE(/*id*/ 0x02, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x02, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_30_STARS, /*pos*/ 307, -1074, 2074, /*angle*/ 0, 90, 0, /*behParam*/ 0x1E000000, /*beh*/ bhvStarDoor), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_30_STARS, /*pos*/ 307, -1074, 1920, /*angle*/ 0, 270, 0, /*behParam*/ 0x1E000000, /*beh*/ bhvStarDoor), - PAINTING_WARP_NODE(/*id*/ 0x0C, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x0D, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x0E, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x0F, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x10, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x11, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x2A, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x15, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x16, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x17, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -1690, -1126, -3942, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_LLL, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -2611, -1178, -1075, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_SSL, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 2099, -1485, -2278, /*angle*/ 270, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_HMC, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3456, -1075, 1587, /*angle*/ 0, 270, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_DDD, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_LLL, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_SSL, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_HMC, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_DDD, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1280, 1997, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F180000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x18, /*destLevel*/ LEVEL_BITFS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1382, -819, -4150, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvPaintingStarCollectWarp), @@ -290,7 +279,6 @@ const LevelScript level_castle_inside_entry[] = { AREA(/*index*/ 3, castle_geo_001C10), OBJECT(/*model*/ MODEL_CASTLE_WATER_LEVEL_PILLAR, /*pos*/ 7066, -1178, -819, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvWaterLevelPillar), OBJECT(/*model*/ MODEL_CASTLE_WATER_LEVEL_PILLAR, /*pos*/ 7066, -1178, -205, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvWaterLevelPillar), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 0, 0, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvDddWarp), OBJECT(/*model*/ MODEL_MIPS, /*pos*/ -1509, -1177, -1564, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvMips), OBJECT(/*model*/ MODEL_TOAD, /*pos*/ 1787, -1381, -1957, /*angle*/ 0, 126, 0, /*behParam*/ DIALOG_082 << 24, /*beh*/ bhvToadMessage), OBJECT(/*model*/ MODEL_TOAD, /*pos*/ -4048, -1381, -1334, /*angle*/ 0, 30, 0, /*behParam*/ DIALOG_136 << 24, /*beh*/ bhvToadMessage), diff --git a/levels/hmc/areas/1/geo.inc.c b/levels/hmc/areas/1/geo.inc.c index 7c6d9b3709..d5f5d95f43 100644 --- a/levels/hmc/areas/1/geo.inc.c +++ b/levels/hmc/areas/1/geo.inc.c @@ -83,8 +83,6 @@ const GeoLayout hmc_geo_000748[] = { GEO_NODE_START(), GEO_OPEN_NODE(), GEO_DISPLAY_LIST(LAYER_OPAQUE, hmc_seg7_dl_07020FD0), - GEO_ASM(0, geo_painting_update), - GEO_ASM(PAINTING_ID(0, 0), geo_painting_draw), GEO_CLOSE_NODE(), GEO_RETURN(), }; @@ -246,8 +244,6 @@ const GeoLayout hmc_geo_000A88[] = { GEO_DISPLAY_LIST(LAYER_TRANSPARENT, hmc_seg7_dl_0701F818), GEO_DISPLAY_LIST(LAYER_OPAQUE, hmc_seg7_dl_0701FD58), GEO_DISPLAY_LIST(LAYER_OPAQUE, hmc_seg7_dl_07020FD0), - GEO_ASM( 0, geo_painting_update), - GEO_ASM( PAINTING_ID(0, 0), geo_painting_draw), GEO_ASM( 0, geo_movtex_pause_control), GEO_ASM(HMC_MOVTEX_DORRIE_POOL_WATER, geo_movtex_draw_water_regions), GEO_CLOSE_NODE(), diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index da95de8631..3be5189426 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -1,59 +1,21 @@ #include "game/paintings.h" -// 0x070241B8 - 0x070241D0 -static const Lights1 hmc_seg7_lights_070241B8 = gdSPDefLights1( - 0x50, 0x50, 0x50, - 0xff, 0xff, 0xff, 0x32, 0x32, 0x32 -); - // 0x070241D0 - 0x070241E8 -// No gdSPDefLights1 macro defined because of odd different light value (0xff and 0xfa) -static const Lights1 hmc_seg7_lights_070241D0 = { - {{ {0x40, 0x40, 0x80}, 0, {0x40, 0x40, 0x80}, 0} }, - {{{ {0x64, 0x64, 0xff}, 0, {0x64, 0x64, 0xfa}, 0, {0x28, 0x28, 0x28},0} }} -}; - -// Appears to lock 4 of the sides when shimmering and in use. Unused. -// 0x070241E8 - 0x07024228 -static const Vtx hmc_seg7_vertex_070241E8[] = { - {{{ 0, 0, 0}, 0, { -32, 990}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 0, 0}, 0, { 6100, 990}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 614, 0}, 0, { 6100, -5142}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 614, 0}, 0, { -32, -5142}, {0x00, 0x00, 0x7f, 0xff}}}, -}; +static const Lights1 hmc_seg7_lights_cotmc_pool = gdSPDefLights1( + 0x40, 0x40, 0x80, + 0x64, 0x64, 0xff, 0x28, 0x28, 0x28 +); // 0x07024228 - 0x07024268 -static const Vtx hmc_seg7_vertex_07024228[] = { +static const Vtx hmc_seg7_vertex_cotmc_pool[] = { {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 0, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; -// Unused -// 0x07024268 - 0x070242A0 -const Gfx hmc_seg7_dl_07024268[] = { - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - gsSPLight(&hmc_seg7_lights_070241B8.l, 1), - gsSPLight(&hmc_seg7_lights_070241B8.a, 2), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPVertex(hmc_seg7_vertex_070241E8, 4, 0), - gsSPEndDisplayList(), -}; - -// Unused -// 0x070242A0 - 0x070242D0 -const Gfx hmc_seg7_dl_070242A0[] = { - gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - // 0x070242D0 - 0x070242F0 -static const Gfx hmc_seg7_painting_dl_070242D0[] = { +static const Gfx hmc_seg7_painting_dl_cotmc_normal_ripple[] = { gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), @@ -61,7 +23,7 @@ static const Gfx hmc_seg7_painting_dl_070242D0[] = { }; // 0x070242F0 - 0x07024CD2 -static const PaintingData hmc_seg7_pool_texture_map_070242F0[] = { +static const PaintingData hmc_seg7_pool_texture_map_cotmc[] = { 157, // num mappings // Format: // mesh vtx ID, texture X, texture Y @@ -493,53 +455,46 @@ static const PaintingData hmc_seg7_pool_texture_map_070242F0[] = { }; // 0x07024CD4 -static const PaintingData *const hmc_seg7_painting_texture_maps_07024CD4[] = { - hmc_seg7_pool_texture_map_070242F0, +static const PaintingData *const hmc_seg7_painting_texture_maps_cotmc[] = { + hmc_seg7_pool_texture_map_cotmc, }; // 0x07024CE0 - 0x070254E0 -ALIGNED8 static const Texture hmc_seg7_texture_07024CE0[] = { +ALIGNED8 static const Texture hmc_seg7_texture_cotmc_pool_env[] = { #include "levels/hmc/7.rgba16.inc.c" }; // 0x070254E0 - 0x07025518 -static const Gfx hmc_seg7_painting_dl_070254E0[] = { +static const Gfx hmc_seg7_painting_dl_cotmc_normal[] = { gsDPPipeSync(), - gsSPLight(&hmc_seg7_lights_070241D0.l, 1), - gsSPLight(&hmc_seg7_lights_070241D0.a, 2), - gsSPVertex(hmc_seg7_vertex_07024228, 4, 0), + gsSPLight(&hmc_seg7_lights_cotmc_pool.l, 1), + gsSPLight(&hmc_seg7_lights_cotmc_pool.a, 2), + gsSPVertex(hmc_seg7_vertex_cotmc_pool, 4, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; // 0x07025518 - 0x07025594 -const Texture *const hmc_seg7_painting_textures_07025518[] = { - hmc_seg7_texture_07024CE0, +const Texture *const hmc_seg7_painting_textures_cotmc[] = { + hmc_seg7_texture_cotmc_pool_env, }; // 0x0702551C (PaintingData) -struct Painting cotmc_painting = { - /* id */ 0x000E, +const struct Painting cotmc_painting = { + /* id */ PAINTING_ID_HMC_COTMC, /* Image Count */ 0x01, /* Texture Type */ PAINTING_ENV_MAP, - /* Floor Status */ 0x00, 0x00 , 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 270.0f, 0.0f, - /* Position */ 2989.055908f, -4485.120117f, 5135.359863f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 1.0f, 0.98f, - /* Ripple Rate */ 0.0f, 0.05f, 0.05f, - /* Ripple Dispersion */ 0.0f, 15.0f, 15.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ hmc_seg7_painting_dl_070254E0, - /* Texture Maps */ hmc_seg7_painting_texture_maps_07024CD4, - /* Textures */ hmc_seg7_painting_textures_07025518, + /* passive entry */ + /* Ripple Magnitude */ 10.0f, 30.0f, + /* Ripple Decay */ 1.0f, 0.98f, + /* Ripple Rate */ 0.05f, 0.05f, + /* Ripple Dispersion */ 15.0f, 15.0f, + /* Normal DList */ hmc_seg7_painting_dl_cotmc_normal, + /* Texture Maps */ hmc_seg7_painting_texture_maps_cotmc, + /* Textures */ hmc_seg7_painting_textures_cotmc, /* Texture w, h */ 32, 32, - /* Ripple DList */ hmc_seg7_painting_dl_070242D0, + /* Ripple DList */ hmc_seg7_painting_dl_cotmc_normal_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 723.968018f, + /* Size */ 723.968018f, 723.968018f, }; diff --git a/levels/hmc/script.c b/levels/hmc/script.c index a38c1fb173..6a7ae5123a 100644 --- a/levels/hmc/script.c +++ b/levels/hmc/script.c @@ -95,10 +95,11 @@ const LevelScript level_hmc_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_HMC_RED_GRILLS, hmc_geo_000530), AREA(/*index*/ 1, hmc_geo_000B90), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7152, 3161, 7181, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3351, -4690, 4773, /*angle*/ 0, 0, 0, /*behParam*/ 0x340B0000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_COTMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 2989, -4485, 5135, /*angle*/ 270, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_HMC_COTMC, PAINTING_GROUP_HMC) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7152, 3161, 7181, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3351, -4690, 4773, /*angle*/ 0, 0, 0, /*behParam*/ 0x340B0000, /*beh*/ bhvWarp), + WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_COTMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), JUMP_LINK(script_func_local_1), diff --git a/levels/scripts.c b/levels/scripts.c index 85eb3209fb..8a0868b961 100644 --- a/levels/scripts.c +++ b/levels/scripts.c @@ -108,6 +108,7 @@ const LevelScript level_main_scripts_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_RED_COIN, red_coin_geo), LOAD_MODEL_FROM_GEO(MODEL_RED_COIN_NO_SHADOW, red_coin_no_shadow_geo), LOAD_MODEL_FROM_GEO(MODEL_NUMBER, number_geo), + LOAD_MODEL_FROM_GEO(MODEL_PAINTING, painting_geo), LOAD_MODEL_FROM_GEO(MODEL_EXPLOSION, explosion_geo), LOAD_MODEL_FROM_GEO(MODEL_DIRT_ANIMATION, dirt_animation_geo), LOAD_MODEL_FROM_GEO(MODEL_CARTOON_STAR, cartoon_star_geo), diff --git a/levels/scripts.h b/levels/scripts.h index dc0196828f..1cafd25273 100644 --- a/levels/scripts.h +++ b/levels/scripts.h @@ -3,6 +3,7 @@ #include "types.h" #include "game/puppycam2.h" +#include "game/paintings.h" // scripts extern const LevelScript level_main_scripts_entry[]; diff --git a/levels/ttm/areas/1/geo.inc.c b/levels/ttm/areas/1/geo.inc.c index 024de077b1..8e87fe75ea 100644 --- a/levels/ttm/areas/1/geo.inc.c +++ b/levels/ttm/areas/1/geo.inc.c @@ -18,8 +18,6 @@ const GeoLayout ttm_geo_000A70[] = { GEO_DISPLAY_LIST(LAYER_OPAQUE, ttm_seg7_dl_0700A120), GEO_DISPLAY_LIST(LAYER_OPAQUE, ttm_seg7_dl_0700A2E0), GEO_RENDER_OBJ(), - GEO_ASM(0, geo_painting_update), - GEO_ASM(PAINTING_ID(0, 2), geo_painting_draw), GEO_ASM(0, geo_movtex_pause_control), GEO_ASM(MOVTEX_TTM_BEGIN_WATERFALL, geo_movtex_draw_nocolor), GEO_ASM(MOVTEX_TTM_END_WATERFALL, geo_movtex_draw_nocolor), diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index 2477f6547c..b116a931ef 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -1,13 +1,13 @@ #include "game/paintings.h" // 0x070122F0 - 0x07012308 -static const Lights1 ttm_seg7_lights_070122F0 = gdSPDefLights1( +static const Lights1 ttm_seg7_lights_slide_painting = gdSPDefLights1( 0x50, 0x50, 0x50, 0xff, 0xff, 0xff, 0x32, 0x32, 0x32 ); // 0x07012308 - 0x07012388 -static const Vtx ttm_seg7_vertex_07012308[] = { +static const Vtx ttm_seg7_vertex_slide_painting[] = { {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{ 614, 307, 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, @@ -19,24 +19,24 @@ static const Vtx ttm_seg7_vertex_07012308[] = { }; // 0x07012388 - 0x070123A0 -const Gfx ttm_seg7_dl_07012388[] = { +const Gfx ttm_seg7_sub_dl_slide_painting_bottom[] = { gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; // 0x070123A0 - 0x070123B8 -const Gfx ttm_seg7_dl_070123A0[] = { +const Gfx ttm_seg7_sub_dl_slide_painting_top[] = { gsSP2Triangles( 4, 5, 6, 0x0, 4, 6, 7, 0x0), gsSPEndDisplayList(), }; // 0x070123B8 - 0x07012410 -const Gfx ttm_seg7_dl_070123B8[] = { +const Gfx ttm_seg7_sub_dl_slide_painting_normal_begin[] = { gsDPPipeSync(), gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - gsSPLight(&ttm_seg7_lights_070122F0.l, 1), - gsSPLight(&ttm_seg7_lights_070122F0.a, 2), + gsSPLight(&ttm_seg7_lights_slide_painting.l, 1), + gsSPLight(&ttm_seg7_lights_slide_painting.a, 2), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), @@ -46,7 +46,7 @@ const Gfx ttm_seg7_dl_070123B8[] = { }; // 0x07012410 - 0x07012430 -const Gfx ttm_seg7_dl_07012410[] = { +const Gfx ttm_seg7_sub_dl_slide_painting_normal_end[] = { gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPPipeSync(), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), @@ -54,7 +54,7 @@ const Gfx ttm_seg7_dl_07012410[] = { }; // 0x07012430 - 0x07012450 -static const Gfx ttm_seg7_painting_dl_07012430[] = { +static const Gfx ttm_seg7_painting_dl_slide_normal_ripple[] = { gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), @@ -529,49 +529,43 @@ UNUSED static const u64 ttm_unused_0 = 0x0; // 0x07012E98 - 0x07012EF8 -static const Gfx ttm_seg7_painting_dl_07012E98[] = { - gsSPDisplayList(ttm_seg7_dl_070123B8), - gsSPVertex(ttm_seg7_vertex_07012308, 8, 0), +static const Gfx ttm_seg7_painting_dl_slide_normal[] = { + gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_begin), + gsSPVertex(ttm_seg7_vertex_slide_painting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, ttm_seg7_texture_07004000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(ttm_seg7_dl_07012388), + gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_bottom), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, ttm_seg7_texture_07003000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(ttm_seg7_dl_070123A0), - gsSPDisplayList(ttm_seg7_dl_07012410), + gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_top), + gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_end), gsSPEndDisplayList(), }; // 0x07012EF8 - 0x07012F78 -ALIGNED8 static const Texture *const ttm_seg7_painting_textures_07012EF8[] = { - ttm_seg7_texture_07004000, ttm_seg7_texture_07003000, +ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { + ttm_seg7_texture_07004000, + ttm_seg7_texture_07003000, }; // 0x07012F00 (PaintingData) -struct Painting ttm_slide_painting = { - /* id */ 0x0000, +const struct Painting ttm_slide_painting = { + /* id */ PAINTING_ID_TTM_SLIDE, /* Image Count */ 0x02, /* Texture Type */ PAINTING_IMAGE, - /* Floor Status */ 0x00, 0x00, 0x00 /* which of the painting's nearby special floors Mario's on */, - /* Ripple Status */ 0x00, - /* Rotation */ 0.0f, 90.0f, - /* Position */ 3072.0f, 921.6f, -819.2f, - /* curr passive entry */ - /* Ripple Magnitude */ 0.0f, 20.0f, 80.0f, - /* Ripple Decay */ 1.0f, 0.9608f, 0.9524f, - /* Ripple Rate */ 0.0f, 0.24f, 0.14f, - /* Ripple Dispersion */ 0.0f, 40.0f, 30.0f, - /* Curr Ripple Timer */ 0.0f, - /* Curr Ripple x, y */ 0.0f, 0.0f, - /* Normal DList */ ttm_seg7_painting_dl_07012E98, + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + /* Normal DList */ ttm_seg7_painting_dl_slide_normal, /* Texture Maps */ ttm_seg7_painting_texture_maps_07012E88, - /* Textures */ ttm_seg7_painting_textures_07012EF8, + /* Textures */ ttm_seg7_painting_textures_slide, /* Texture w, h */ 64, 32, - /* Ripple DList */ ttm_seg7_painting_dl_07012430, + /* Ripple DList */ ttm_seg7_painting_dl_slide_normal_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, - /* Mario Below */ 0x00, 0x00, 0x00, /* Whether or not Mario is below the painting */ - /* Size */ 460.8f, + /* Size */ 460.8f, 460.8f, }; diff --git a/levels/ttm/script.c b/levels/ttm/script.c index 899aef6196..1999c93bc1 100644 --- a/levels/ttm/script.c +++ b/levels/ttm/script.c @@ -95,7 +95,7 @@ const LevelScript level_ttm_entry[] = { JUMP_LINK(script_func_global_7), LOAD_MODEL_FROM_GEO(MODEL_TTM_SLIDE_EXIT_PODIUM, ttm_geo_000DF4), LOAD_MODEL_FROM_GEO(MODEL_TTM_ROLLING_LOG, ttm_geo_000730), - LOAD_MODEL_FROM_GEO(MODEL_TTM_STAR_CAGE, ttm_geo_000710), + LOAD_MODEL_FROM_GEO(MODEL_TTM_STAR_CAGE, ttm_geo_000710), LOAD_MODEL_FROM_GEO(MODEL_TTM_BLUE_SMILEY, ttm_geo_000D14), LOAD_MODEL_FROM_GEO(MODEL_TTM_YELLOW_SMILEY, ttm_geo_000D4C), LOAD_MODEL_FROM_GEO(MODEL_TTM_STAR_SMILEY, ttm_geo_000D84), @@ -129,9 +129,8 @@ const LevelScript level_ttm_entry[] = { WARP_NODE(/*id*/ 0x14, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x14, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x15, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x16, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x16, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x15, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x00, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x01, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ 0x02, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3072, 922, -819, /*angle*/ 0, 90, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_TTM_SLIDE, PAINTING_GROUP_TTM) << 16, /*beh*/ bhvPainting), + PAINTING_WARP_NODE(/*id*/ PAINTING_ID_TTM_SLIDE, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), JUMP_LINK(script_func_local_1), diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 7e3fa0b9d5..59440b6061 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -31,7 +31,7 @@ #include "config.h" -#define NUM_PAINTINGS 45 +#define NUM_PAINTING_WARP_NODES 45 #define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd)) @@ -563,9 +563,9 @@ static void level_cmd_create_painting_warp_node(void) { if (sCurrAreaIndex != -1) { if (gAreas[sCurrAreaIndex].paintingWarpNodes == NULL) { gAreas[sCurrAreaIndex].paintingWarpNodes = - alloc_only_pool_alloc(sLevelPool, NUM_PAINTINGS * sizeof(struct WarpNode)); + alloc_only_pool_alloc(sLevelPool, NUM_PAINTING_WARP_NODES * sizeof(struct WarpNode)); - for (i = 0; i < NUM_PAINTINGS; i++) { + for (i = 0; i < NUM_PAINTING_WARP_NODES; i++) { gAreas[sCurrAreaIndex].paintingWarpNodes[i].id = 0; } } diff --git a/src/engine/math_util.c b/src/engine/math_util.c index c410e558b8..d1f2a6a7ed 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -814,6 +814,28 @@ void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, register Mat4 camMtx) { } } +/** + * Makes 'destWorldPos' the world space equivalent of 'srcLocalPos'. + */ +void vec3f_local_pos_to_world_pos(Vec3f destWorldPos, Vec3f srcLocalPos, Vec3f originPos, Vec3s rotation) { + Mat4 mtx; + + mtxf_rotate_zxy_and_translate(mtx, srcLocalPos, rotation); + linear_mtxf_mul_vec3f(mtx, destWorldPos, srcLocalPos); + vec3f_add(destWorldPos, originPos); +} + +/** + * Makes 'destLocalPos' the local space equivalent of 'srcWorldPos'. + */ +void vec3f_world_pos_to_local_pos(Vec3f destLocalPos, Vec3f srcWorldPos, Vec3f originPos, Vec3s rotation) { + Mat4 mtx; + Vec3f relativePos; + + vec3f_diff(relativePos, srcWorldPos, originPos); + mtxf_rotate_zxy_and_translate(mtx, originPos, rotation); + linear_mtxf_transpose_mul_vec3f(mtx, destLocalPos, relativePos); +} /** * Take the vector starting at 'from' pointed at 'to' an retrieve the length diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 2c131d1a6b..6de18d9ca2 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -563,6 +563,11 @@ void linear_mtxf_mul_vec3f_and_translate(Mat4 m, Vec3f dst, Vec3f v); void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx); +// Local/World pos conversions +void vec3f_local_pos_to_world_pos(Vec3f destWorldPos, Vec3f srcLocalPos, Vec3f originPos, Vec3s rotation); +void vec3f_world_pos_to_local_pos(Vec3f destLocalPos, Vec3f srcWorldPos, Vec3f originPos, Vec3s rotation); + +// Vector get/set functions void vec2f_get_lateral_dist( Vec2f from, Vec2f to, f32 *lateralDist ); void vec3f_get_lateral_dist( Vec3f from, Vec3f to, f32 *lateralDist ); void vec3f_get_lateral_dist_squared( Vec3f from, Vec3f to, f32 *lateralDist ); diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 73bb70342c..d29271f6c4 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -610,6 +610,20 @@ f32 find_room_floor(f32 x, f32 y, f32 z, struct Surface **pfloor) { return find_floor(x, y, z, pfloor); } +/** + * Get the room index at a given position. + */ +s32 get_room_at_pos(f32 x, f32 y, f32 z) { + if (gCurrentArea->surfaceRooms != NULL) { + struct Surface *floor; + find_room_floor(x, y, z, &floor); + if (floor) { + return floor->room; + } + } + return -1; +} + /** * Find the highest water floor under a given position and return the height. */ diff --git a/src/engine/surface_collision.h b/src/engine/surface_collision.h index aea42e2e20..4078163d67 100644 --- a/src/engine/surface_collision.h +++ b/src/engine/surface_collision.h @@ -55,6 +55,7 @@ ALWAYS_INLINE f32 find_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil) f32 find_floor_height(f32 x, f32 y, f32 z); f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor); f32 find_room_floor(f32 x, f32 y, f32 z, struct Surface **pfloor); +s32 get_room_at_pos(f32 x, f32 y, f32 z); s32 find_water_level_and_floor(s32 x, s32 y, s32 z, struct Surface **pfloor); s32 find_water_level(s32 x, s32 z); s32 find_poison_gas_level(s32 x, s32 z); diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 786c97f0b5..46dc4e05c3 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -576,11 +576,7 @@ void load_object_surfaces(TerrainData **data, TerrainData *vertexData) { TerrainData hasForce = surface_has_force(surfaceType); #endif - s32 flags = surf_has_no_cam_collision(surfaceType) | SURFACE_FLAG_DYNAMIC; - - // The DDD warp is initially loaded at the origin and moved to the proper - // position in paintings.c and doesn't update its room, so set it here. - RoomData room = (o->behavior == segmented_to_virtual(bhvDddWarp)) ? 5 : 0; + s32 flags = (surf_has_no_cam_collision(surfaceType) | SURFACE_FLAG_DYNAMIC); for (i = 0; i < numSurfaces; i++) { struct Surface *surface = read_surface_data(vertexData, data); @@ -600,7 +596,7 @@ void load_object_surfaces(TerrainData **data, TerrainData *vertexData) { #endif surface->flags |= flags; - surface->room = room; + surface->room = 0; add_surface(surface, TRUE); } diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index 1fd7468ed4..1279f6546c 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -174,7 +174,6 @@ void spawn_sparkle_particles(s32 n, s32 radius, s32 height, s32 r) { #include "behaviors/bowser_flame.inc.c" #include "behaviors/blue_fish.inc.c" #include "behaviors/checkerboard_platform.inc.c" -#include "behaviors/ddd_warp.inc.c" #include "behaviors/water_pillar.inc.c" #include "behaviors/moat_drainer.inc.c" #include "behaviors/bowser_key_cutscene.inc.c" diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h index 02a9d44611..cd71d36851 100644 --- a/src/game/behavior_actions.h +++ b/src/game/behavior_actions.h @@ -172,7 +172,6 @@ void bhv_bowser_key_course_exit_loop(void); void bhv_invisible_objects_under_bridge_init(void); void bhv_water_level_pillar_init(void); void bhv_water_level_pillar_loop(void); -void bhv_ddd_warp_loop(void); void bhv_moat_grills_loop(void); void bhv_rotating_clock_arm_loop(void); void bhv_ukiki_init(void); diff --git a/src/game/behaviors/clock_arm.inc.c b/src/game/behaviors/clock_arm.inc.c index f4005eced1..50e77d7ef5 100644 --- a/src/game/behaviors/clock_arm.inc.c +++ b/src/game/behaviors/clock_arm.inc.c @@ -4,30 +4,26 @@ * Main loop of the hour and minute hands of the Tick Tock Clock painting. */ void bhv_rotating_clock_arm_loop(void) { - struct Surface *marioSurface = gMarioState->floor; u16 rollAngle = o->oFaceAngleRoll; - o->oFloorHeight = gMarioState->floorHeight; // Seems to make sure Mario is on a default surface & 4 frames pass before // allowing him to change the Tick Tock Clock speed setting. // Probably a safety check for when you leave the level through the painting // to make sure the setting isn't accidentally locked in as you fly out. - if (o->oAction == 0) { - if (marioSurface->type == SURFACE_DEFAULT && o->oTimer >= 4) { - o->oAction++; + if (o->oAction == TTC_PAINTING_CLOCK_ARM_WAIT) { + if (o->oTimer >= 4) { + o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_MOVING } - } else if (o->oAction == 1) { - // If Mario is touching the Tick Tock Clock painting... - if (marioSurface != NULL - && (marioSurface->type == SURFACE_TTC_PAINTING_1 - || marioSurface->type == SURFACE_TTC_PAINTING_2 - || marioSurface->type == SURFACE_TTC_PAINTING_3)) { + } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_MOVING) { + // If Mario is entering the Tick Tock Clock painting... + if (gEnteredPainting != NULL + && gEnteredPainting->oPaintingId == PAINTING_ID_CASTLE_TTC) { // And this is the minute hand... if (cur_obj_has_behavior(bhvClockMinuteHand)) { // Set Tick Tick Clock's speed based on the angle of the hand. // The angle actually counting down from 0xFFFF to 0 so // 11 o'clock is a small value and 1 o'clock is a large value. - if (rollAngle < 0xAAA) { // > 345 degrees from 12 o'clock. + if (rollAngle < 0x0AAA) { // > 345 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_STOPPED; } else if (rollAngle < 0x6AA4) { // 210..345 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_FAST; @@ -41,7 +37,11 @@ void bhv_rotating_clock_arm_loop(void) { } // Increment the action to stop animating the hands. - o->oAction++; + o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_STOPPED + } + } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_STOPPED) { + if (gEnteredPainting == NULL) { + o->oAction = TTC_PAINTING_CLOCK_ARM_ACT_MOVING; } } diff --git a/src/game/behaviors/ddd_warp.inc.c b/src/game/behaviors/ddd_warp.inc.c deleted file mode 100644 index 95b92259c0..0000000000 --- a/src/game/behaviors/ddd_warp.inc.c +++ /dev/null @@ -1,13 +0,0 @@ -// ddd_warp.inc.c - -void bhv_ddd_warp_loop(void) { -#ifndef UNLOCK_ALL - if (gDddPaintingStatus & DDD_FLAG_BOWSERS_SUB_BEATEN) { -#endif - o->collisionData = segmented_to_virtual(inside_castle_seg7_collision_ddd_warp_2); -#ifndef UNLOCK_ALL - } else { - o->collisionData = segmented_to_virtual(inside_castle_seg7_collision_ddd_warp); - } -#endif -} diff --git a/src/game/behaviors/door.inc.c b/src/game/behaviors/door.inc.c index c75bf2386e..5683d78e16 100644 --- a/src/game/behaviors/door.inc.c +++ b/src/game/behaviors/door.inc.c @@ -93,22 +93,18 @@ void bhv_door_init(void) { f32 x = o->oPosX; f32 y = o->oPosY; f32 z = o->oPosZ; - struct Surface *floor; - find_room_floor(x, y, z, &floor); - if (floor != NULL) o->oDoorSelfRoom = floor->room; + o->oDoorSelfRoom = get_room_at_pos(x, y, z); x = o->oPosX + sins(o->oMoveAngleYaw) * 200.0f; z = o->oPosZ + coss(o->oMoveAngleYaw) * 200.0f; - find_room_floor(x, y, z, &floor); - if (floor != NULL) o->oDoorForwardRoom = floor->room; + o->oDoorForwardRoom = get_room_at_pos(x, y, z); x = o->oPosX + sins(o->oMoveAngleYaw) * -200.0f; z = o->oPosZ + coss(o->oMoveAngleYaw) * -200.0f; - find_room_floor(x, y, z, &floor); - if (floor != NULL) o->oDoorBackwardRoom = floor->room; + o->oDoorBackwardRoom = get_room_at_pos(x, y, z); if (o->oDoorSelfRoom > 0 && o->oDoorSelfRoom < 60) { gDoorAdjacentRooms[o->oDoorSelfRoom][0] = o->oDoorForwardRoom; diff --git a/src/game/camera.c b/src/game/camera.c index 21d407732c..954e143f75 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -4855,9 +4855,6 @@ u8 get_cutscene_from_mario_status(struct Camera *c) { if (sMarioCamState->cameraEvent == CAM_EVENT_CANNON) { cutscene = CUTSCENE_ENTER_CANNON; } - if (SURFACE_IS_PAINTING_WARP(sMarioGeometry.currFloorType)) { - cutscene = CUTSCENE_ENTER_PAINTING; - } switch (sMarioCamState->action) { case ACT_DEATH_EXIT: cutscene = CUTSCENE_DEATH_EXIT; @@ -6591,14 +6588,14 @@ s16 cutscene_object_without_dialog(u8 cutscene, struct Object *obj) { * @return 0 if not started, 1 if started, and -1 if finished */ s16 cutscene_object(u8 cutscene, struct Object *obj) { - s16 status = 0; + s16 status = CUTSCENE_OBJ_STATUS_NOT_STARTED; - if ((gCamera->cutscene == 0) && (sObjectCutscene == 0)) { + if ((gCamera->cutscene == CUTSCENE_NONE) && (sObjectCutscene == CUTSCENE_NONE)) { if (gRecentCutscene != cutscene) { start_object_cutscene(cutscene, obj); - status = 1; + status = CUTSCENE_OBJ_STATUS_STARTED; } else { - status = -1; + status = CUTSCENE_OBJ_STATUS_FINISHED; } } return status; @@ -9570,40 +9567,35 @@ void cutscene_double_doors_end(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; } -void cutscene_enter_painting_stub(UNUSED struct Camera *c) { -} - /** * Plays when Mario enters a painting. The camera flies up to the painting's center, then it slowly * zooms in until the star select screen appears. */ void cutscene_enter_painting(struct Camera *c) { - struct Surface *floor, *highFloor; + struct Surface *highFloor; Vec3f paintingPos, focus, focusOffset; Vec3s paintingAngle; - f32 floorHeight; + f32 floorHeight, size; - cutscene_event(cutscene_enter_painting_stub, c, 0, 0); // Zoom in set_fov_function(CAM_FOV_APP_20); sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; - if (gRipplingPainting != NULL) { - paintingAngle[0] = 0; - paintingAngle[1] = (s32)((gRipplingPainting->yaw / 360.f) * 65536.f); // convert degrees to IAU - paintingAngle[2] = 0; + struct Object *ripplingPainting = gCutsceneFocus; - focusOffset[0] = gRipplingPainting->size / 2; + if (ripplingPainting != NULL) { + vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); + + size = ((ripplingPainting->oPaintingPtr->sizeX + ripplingPainting->oPaintingPtr->sizeY) / 2.0f); + focusOffset[0] = (size * 0.5f); focusOffset[1] = focusOffset[0]; focusOffset[2] = 0; - paintingPos[0] = gRipplingPainting->posX; - paintingPos[1] = gRipplingPainting->posY; - paintingPos[2] = gRipplingPainting->posZ; + vec3f_copy(paintingPos, &ripplingPainting->oPosVec); offset_rotated(focus, paintingPos, focusOffset, paintingAngle); approach_vec3f_asymptotic(c->focus, focus, 0.1f, 0.1f, 0.1f); - focusOffset[2] = -(((gRipplingPainting->size * 1000.f) / 2) / 307.f); + focusOffset[2] = -(((size * 1000.f) / 2) / 307.f); offset_rotated(focus, paintingPos, focusOffset, paintingAngle); floorHeight = find_floor(focus[0], focus[1] + 500.f, focus[2], &highFloor) + 125.f; @@ -9616,15 +9608,12 @@ void cutscene_enter_painting(struct Camera *c) { } else { approach_vec3f_asymptotic(c->pos, focus, 0.9f, 0.9f, 0.9f); } - - find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 50.f, sMarioCamState->pos[2], &floor); - - if ((floor->type < SURFACE_PAINTING_WOBBLE_A6) || (floor->type > SURFACE_PAINTING_WARP_F9)) { - c->cutscene = 0; - gCutsceneTimer = CUTSCENE_STOP; - sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; - } + } else { + c->cutscene = CUTSCENE_NONE; + gCutsceneTimer = CUTSCENE_STOP; + sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; } + c->mode = CAMERA_MODE_CLOSE; } @@ -9644,10 +9633,12 @@ void cutscene_exit_painting_start(struct Camera *c) { vec3f_set(sCutsceneVars[2].point, 258.f, -352.f, 1189.f); vec3f_set(sCutsceneVars[1].point, 65.f, -155.f, 444.f); +#ifdef ENABLE_VANILLA_CAM_PROCESSING if (gPrevLevel == LEVEL_TTM) { sCutsceneVars[1].point[1] = 0.f; sCutsceneVars[1].point[2] = 0.f; } +#endif vec3f_copy(sCutsceneVars[0].point, sMarioCamState->pos); sCutsceneVars[0].angle[0] = 0; sCutsceneVars[0].angle[1] = sMarioCamState->faceAngle[1]; @@ -9657,7 +9648,8 @@ void cutscene_exit_painting_start(struct Camera *c) { floorHeight = find_floor(c->pos[0], c->pos[1] + 10.f, c->pos[2], &floor); if (floorHeight != FLOOR_LOWER_LIMIT) { - if (c->pos[1] < (floorHeight += 60.f)) { + floorHeight += 60.0f; + if (c->pos[1] < floorHeight) { c->pos[1] = floorHeight; } } @@ -9690,10 +9682,10 @@ void cutscene_exit_painting_move_to_floor(struct Camera *c) { Vec3f floorHeight; vec3f_copy(floorHeight, sMarioCamState->pos); - floorHeight[1] = find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 10.f, sMarioCamState->pos[2], &floor); + floorHeight[1] = find_floor(sMarioCamState->pos[0], (sMarioCamState->pos[1] + 10.0f), sMarioCamState->pos[2], &floor); if (floor != NULL) { - floorHeight[1] = floorHeight[1] + (sMarioCamState->pos[1] - floorHeight[1]) * 0.7f + 125.f; + floorHeight[1] = (floorHeight[1] + ((sMarioCamState->pos[1] - floorHeight[1]) * 0.7f) + 125.0f); approach_vec3f_asymptotic(c->focus, floorHeight, 0.2f, 0.2f, 0.2f); if (floorHeight[1] < c->pos[1]) { @@ -9706,14 +9698,16 @@ void cutscene_exit_painting_move_to_floor(struct Camera *c) { * Cutscene played when Mario leaves a painting, either due to death or collecting a star. */ void cutscene_exit_painting(struct Camera *c) { - cutscene_event(cutscene_exit_painting_start, c, 0, 0); + cutscene_event(cutscene_exit_painting_start, c, 0, 0); cutscene_event(cutscene_exit_painting_move_to_mario, c, 5, -1); cutscene_event(cutscene_exit_painting_move_to_floor, c, 5, -1); +#ifdef ENABLE_VANILLA_CAM_PROCESSING //! Hardcoded position. TTM's painting is close to an opposite wall, so just fix the pos. if (gPrevLevel == LEVEL_TTM) { - vec3f_set(c->pos, -296.f, 1261.f, 3521.f); + vec3f_set(c->pos, -296.0f, 1261.0f, 3521.0f); } +#endif update_camera_yaw(c); } diff --git a/src/game/camera.h b/src/game/camera.h index 2387260758..d6614c6651 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -353,6 +353,12 @@ enum AvoidStatus { AVOID_STATUS_WALL_COVERING_MARIO, }; +enum CutsceneObjectStatus { + CUTSCENE_OBJ_STATUS_FINISHED = -1, + CUTSCENE_OBJ_STATUS_NOT_STARTED, + CUTSCENE_OBJ_STATUS_STARTED, +}; + /** * A copy of player information that is relevant to the camera. */ diff --git a/src/game/level_update.c b/src/game/level_update.c index 6b2d27c0f3..62d3d5105a 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -31,6 +31,8 @@ #include "puppyprint.h" #include "puppylights.h" #include "level_commands.h" +#include "behavior_data.h" +#include "paintings.h" #include "config.h" @@ -620,36 +622,17 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 warpFlags) #endif } -// From Surface 0xD3 to 0xFC -#define PAINTING_WARP_INDEX_START 0x00 // Value greater than or equal to Surface 0xD3 -#define PAINTING_WARP_INDEX_FA 0x2A // THI Huge Painting index left -#define PAINTING_WARP_INDEX_END 0x2D // Value less than Surface 0xFD - -/** - * Check if Mario is above and close to a painting warp floor, and return the - * corresponding warp node. - */ -struct WarpNode *get_painting_warp_node(void) { - struct WarpNode *warpNode = NULL; - s32 paintingIndex = gMarioState->floor->type - SURFACE_PAINTING_WARP_D3; - - if (paintingIndex >= PAINTING_WARP_INDEX_START && paintingIndex < PAINTING_WARP_INDEX_END) { - if (paintingIndex < PAINTING_WARP_INDEX_FA - || gMarioState->pos[1] - gMarioState->floorHeight < 80.0f) { - warpNode = &gCurrentArea->paintingWarpNodes[paintingIndex]; - } - } - - return warpNode; -} - /** * Check is Mario has entered a painting, and if so, initiate a warp. */ void initiate_painting_warp(void) { - if (gCurrentArea->paintingWarpNodes != NULL && gMarioState->floor != NULL) { - struct WarpNode warpNode; - struct WarpNode *pWarpNode = get_painting_warp_node(); + struct WarpNode warpNode; + struct WarpNode *pWarpNode = NULL; + + if (gCurrentArea->paintingWarpNodes == NULL) { + gEnteredPainting = NULL; + } else if (gEnteredPainting != NULL) { + pWarpNode = &gCurrentArea->paintingWarpNodes[gEnteredPainting->oPaintingId]; if (pWarpNode != NULL) { if (gMarioState->action & ACT_FLAG_INTANGIBLE) { @@ -661,7 +644,7 @@ void initiate_painting_warp(void) { sWarpCheckpointActive = check_warp_checkpoint(&warpNode); } - initiate_warp(warpNode.destLevel & 0x7F, warpNode.destArea, warpNode.destNode, WARP_FLAGS_NONE); + initiate_warp((warpNode.destLevel & WARP_DEST_LEVEL_NUM_MASK), warpNode.destArea, warpNode.destNode, WARP_FLAGS_NONE); check_if_should_set_warp_checkpoint(&warpNode); play_transition_after_delay(WARP_TRANSITION_FADE_INTO_COLOR, 30, 255, 255, 255, 45); @@ -677,8 +660,11 @@ void initiate_painting_warp(void) { queue_rumble_data(80, 70); queue_rumble_decay(1); #endif + cutscene_object(CUTSCENE_ENTER_PAINTING, gEnteredPainting); } } + } else { + sPaintingEjectSoundPlayed = FALSE; } } diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index c63dd3bec3..2972fe7083 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -28,8 +28,6 @@ #include "spawn_sound.h" #include "puppylights.h" -static s8 sLevelsWithRooms[] = { LEVEL_BBH, LEVEL_CASTLE, LEVEL_HMC, -1 }; - static s32 clear_move_flag(u32 *bitSet, s32 flag); Gfx *geo_update_projectile_pos_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx) { @@ -123,8 +121,8 @@ Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node, UNUSED void } Gfx *geo_switch_area(s32 callContext, struct GraphNode *node, UNUSED void *context) { - struct Surface *floor; struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node; + RoomData room = -1; if (callContext == GEO_CONTEXT_RENDER) { if (gMarioObject == NULL) { @@ -133,21 +131,23 @@ Gfx *geo_switch_area(s32 callContext, struct GraphNode *node, UNUSED void *conte #ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS if (gCurrLevelNum == LEVEL_BBH) { // In BBH, check for a floor manually, since there is an intangible floor. In custom hacks this can be removed. - find_room_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &floor); - } else { + room = get_room_at_pos(gMarioObject->oPosX, + gMarioObject->oPosY, + gMarioObject->oPosZ); + } else if (gMarioState->floor) { // Since no intangible floors are nearby, use Mario's floor instead. - floor = gMarioState->floor; + room = gMarioState->floor->room; } + if (room != -1) { #else - floor = gMarioState->floor; + if (gMarioState->floor) { + room = gMarioState->floor->room; #endif - if (floor) { - gMarioCurrentRoom = floor->room; - s16 roomCase = floor->room - 1; - print_debug_top_down_objectinfo("areainfo %d", floor->room); + gMarioCurrentRoom = room; + print_debug_top_down_objectinfo("areainfo %d", room); - if (roomCase >= 0) { - switchCase->selectedCase = roomCase; + if (room > 0) { + switchCase->selectedCase = room - 1; } } } @@ -1881,27 +1881,16 @@ s32 is_item_in_array(s8 item, s8 *array) { } void bhv_init_room(void) { - struct Surface *floor = NULL; - if (is_item_in_array(gCurrLevelNum, sLevelsWithRooms)) { - find_room_floor(o->oPosX, o->oPosY, o->oPosZ, &floor); - - if (floor != NULL) { - o->oRoom = floor->room; - return; - } - } - o->oRoom = -1; + o->oRoom = get_room_at_pos(o->oPosX, o->oPosY, o->oPosZ); } void cur_obj_enable_rendering_if_mario_in_room(void) { if (o->oRoom != -1 && gMarioCurrentRoom != 0) { - register s32 marioInRoom = ( + if ( gMarioCurrentRoom == o->oRoom || gDoorAdjacentRooms[gMarioCurrentRoom][0] == o->oRoom || gDoorAdjacentRooms[gMarioCurrentRoom][1] == o->oRoom - ); - - if (marioInRoom) { + ) { cur_obj_enable_rendering(); o->activeFlags &= ~ACTIVE_FLAG_IN_DIFFERENT_ROOM; gNumRoomedObjectsInMarioRoom++; diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 6d20b4b7ee..f811fa3ed0 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -19,6 +19,7 @@ #include "object_list_processor.h" #include "platform_displacement.h" #include "spawn_object.h" +#include "paintings.h" #include "puppyprint.h" #include "puppylights.h" #include "profiling.h" @@ -517,6 +518,7 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { void clear_objects(void) { s32 i; + gEnteredPainting = NULL; gTHIWaterDrained = 0; gTimeStopState = 0; gMarioObject = NULL; diff --git a/src/game/paintings.c b/src/game/paintings.c index 31d78a61fb..2407bb972e 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -18,6 +18,7 @@ #include "paintings.h" #include "save_file.h" #include "segment2.h" +#include "rendering_graph_node.h" /** * @file paintings.c @@ -54,95 +55,12 @@ * Paintings that use RIPPLE_TRIGGER_CONTINUOUS try to transition to this state as soon as possible, * usually when Mario enters the room. * - * A PROXIMITY painting will automatically reset to IDLE if its ripple magnitude becomes small - * enough. + * A PROXIMITY painting will automatically reset to IDLE if its ripple magnitude becomes small enough. * * Paintings in the PAINTING_ENTERED state have been entered by Mario. - * A CONTINUOUS painting will automatically reset to RIPPLE if its ripple magnitude becomes small - * enough. + * A CONTINUOUS painting will automatically reset to RIPPLE if its ripple magnitude becomes small enough. */ -/** - * Triggers a passive ripple on the left side of the painting. - */ -#define RIPPLE_LEFT 0x20 - -/** - * Triggers a passive ripple in the middle the painting. - */ -#define RIPPLE_MIDDLE 0x10 - -/** - * Triggers a passive ripple on the right side of the painting. - */ -#define RIPPLE_RIGHT 0x8 - -/** - * Triggers an entry ripple on the left side of the painting. - */ -#define ENTER_LEFT 0x4 - -/** - * Triggers an entry ripple in the middle of the painting. - */ -#define ENTER_MIDDLE 0x2 - -/** - * Triggers an entry ripple on the right side of the painting. - */ -#define ENTER_RIGHT 0x1 - -/** - * Use the 1/4th part of the painting that is nearest to Mario's current floor. - */ -#define NEAREST_4TH 30 - -/** - * Use Mario's relative x position. - * @see painting_mario_x - */ -#define MARIO_X 40 - -/** - * Use the x center of the painting. - */ -#define MIDDLE_X 50 - -/** - * Use Mario's relative y position. - * @see painting_mario_y - */ -#define MARIO_Y 60 - -/** - * Use Mario's relative z position. - * @see painting_mario_z - */ -#define MARIO_Z 70 - -/** - * Use the y center of the painting. - */ -#define MIDDLE_Y 80 - -/** - * Does nothing to the timer. - * Why -56 instead of false? Who knows. - */ -#define DONT_RESET -56 - -/** - * Reset the timer to 0. - */ -#define RESET_TIMER 100 - -/// A copy of the type of floor Mario is standing on. -s16 gPaintingMarioFloorType; -// A copy of Mario's position -f32 gPaintingMarioXPos; -f32 gPaintingMarioYPos; -f32 gPaintingMarioZPos; - /** * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. * @@ -159,163 +77,66 @@ Vec3f *gPaintingTriNorms; /** * The painting that is currently rippling. Only one painting can be rippling at once. */ -struct Painting *gRipplingPainting; +struct Object *gRipplingPainting = NULL; /** - * Whether the DDD painting is moved forward, should being moving backwards, or has already moved backwards. + * The id of the painting Mario has entered. */ -s8 gDddPaintingStatus; +struct Object *gEnteredPainting = NULL; +// HMC painting group struct Painting *sHmcPaintings[] = { - &cotmc_painting, + /*0x0*/ &cotmc_painting, NULL, }; +// Inside Castle painting group struct Painting *sInsideCastlePaintings[] = { - &bob_painting, &ccm_painting, &wf_painting, &jrb_painting, &lll_painting, - &ssl_painting, &hmc_painting, &ddd_painting, &wdw_painting, &thi_tiny_painting, - &ttm_painting, &ttc_painting, &sl_painting, &thi_huge_painting, NULL, + /*0x0*/ &bob_painting, + /*0x1*/ &ccm_painting, + /*0x2*/ &wf_painting, + /*0x3*/ &jrb_painting, + /*0x4*/ &lll_painting, + /*0x5*/ &ssl_painting, + /*0x6*/ &hmc_painting, + /*0x7*/ &ddd_painting, + /*0x8*/ &wdw_painting, + /*0x9*/ &thi_tiny_painting, + /*0xA*/ &ttm_painting, + /*0xB*/ &ttc_painting, + /*0xC*/ &sl_painting, + /*0xD*/ &thi_huge_painting, + /*0xE*/ &rr_painting, + NULL, }; +// TTM painting group struct Painting *sTtmPaintings[] = { - &ttm_slide_painting, + /*0x0*/ &ttm_slide_painting, NULL, }; +// Array of all painting groups struct Painting **sPaintingGroups[] = { - sHmcPaintings, - sInsideCastlePaintings, - sTtmPaintings, + /*0x0*/ sHmcPaintings, + /*0x1*/ sInsideCastlePaintings, + /*0x2*/ sTtmPaintings, }; -s16 gPaintingUpdateCounter = 1; -s16 gLastPaintingUpdateCounter = 0; - -/** - * Stop paintings in paintingGroup from rippling if their id is different from *idptr. - */ -void stop_other_paintings(s16 *idptr, struct Painting *paintingGroup[]) { - s16 index; - s16 id = *idptr; - - index = 0; - while (paintingGroup[index] != NULL) { - struct Painting *painting = segmented_to_virtual(paintingGroup[index]); - - // stop all rippling except for the selected painting - if (painting->id != id) { - painting->state = 0; - } - index++; - } -} - -/** - * @return Mario's y position inside the painting (bounded). - */ -f32 painting_mario_y(struct Painting *painting) { - // Add 50 to make the ripple closer to Mario's center of mass. - f32 relY = gPaintingMarioYPos - painting->posY + 50.0f; - - if (relY < 0.0f) { - relY = 0.0f; - } else if (relY > painting->size) { - relY = painting->size; - } - return relY; -} - -/** - * @return Mario's z position inside the painting (bounded). - */ -f32 painting_mario_z(struct Painting *painting) { - f32 relZ = painting->posZ - gPaintingMarioZPos; - - if (relZ < 0.0f) { - relZ = 0.0f; - } else if (relZ > painting->size) { - relZ = painting->size; - } - return relZ; -} - /** - * @return The y origin for the ripple, based on ySource. - * For floor paintings, the z-axis is treated as y. + * Get the painting group from gCurrLevelNum. */ -f32 painting_ripple_y(struct Painting *painting, s8 ySource) { - switch (ySource) { - case MARIO_Y: - return painting_mario_y(painting); // normal wall paintings - break; - case MARIO_Z: - return painting_mario_z(painting); // floor paintings use X and Z - break; - case MIDDLE_Y: - return painting->size / 2.0; // some concentric ripples don't care about Mario - break; - } - return 0.0f; -} - -/** - * Return the quarter of the painting that is closest to the floor Mario entered. - */ -f32 painting_nearest_4th(struct Painting *painting) { - f32 firstQuarter = painting->size / 4.0; // 1/4 of the way across the painting - f32 secondQuarter = painting->size / 2.0; // 1/2 of the way across the painting - f32 thirdQuarter = painting->size * 3.0 / 4.0; // 3/4 of the way across the painting - - if (painting->floorEntered & RIPPLE_LEFT) { - return firstQuarter; - } else if (painting->floorEntered & RIPPLE_MIDDLE) { - return secondQuarter; - } else if (painting->floorEntered & RIPPLE_RIGHT) { - return thirdQuarter; - - // Same as ripple floors. - } else if (painting->floorEntered & ENTER_LEFT) { - return firstQuarter; - } else if (painting->floorEntered & ENTER_MIDDLE) { - return secondQuarter; - } else if (painting->floorEntered & ENTER_RIGHT) { - return thirdQuarter; - } - - return 0.0f; -} - -/** - * @return Mario's x position inside the painting (bounded). - */ -f32 painting_mario_x(struct Painting *painting) { - f32 relX = gPaintingMarioXPos - painting->posX; - - if (relX < 0.0f) { - relX = 0.0f; - } else if (relX > painting->size) { - relX = painting->size; - } - return relX; -} - -/** - * @return The x origin for the ripple, based on xSource. - */ -f32 painting_ripple_x(struct Painting *painting, s8 xSource) { - switch (xSource) { - case NEAREST_4TH: // normal wall paintings - return painting_nearest_4th(painting); - break; - case MARIO_X: // horizontally placed paintings use X and Z - return painting_mario_x(painting); - break; - case MIDDLE_X: // concentric rippling may not care about Mario - return painting->size / 2.0f; - break; +UNUSED s32 get_painting_group(void) { + switch (gCurrLevelNum) { + case LEVEL_HMC: + return PAINTING_GROUP_HMC; + case LEVEL_CASTLE: + return PAINTING_GROUP_INSIDE_CASTLE; + case LEVEL_TTM: + return PAINTING_GROUP_TTM; + default: + return PAINTING_GROUP_NULL; } - - return 0.0f; } /** @@ -324,250 +145,95 @@ f32 painting_ripple_x(struct Painting *painting, s8 xSource) { * @param state The state to enter * @param painting,paintingGroup identifies the painting that is changing state * @param xSource,ySource what to use for the x and y origin of the ripple - * @param resetTimer if 100, set the timer to 0 + * @param resetTimer if TRUE, set the timer to 0 */ -void painting_state(s8 state, struct Painting *painting, struct Painting *paintingGroup[], - s8 xSource, s8 ySource, s8 resetTimer) { - // make sure no other paintings are rippling - stop_other_paintings(&painting->id, paintingGroup); +void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTimer) { + struct Painting *painting = obj->oPaintingPtr; // use a different set of variables depending on the state switch (state) { case PAINTING_RIPPLE: - painting->currRippleMag = painting->passiveRippleMag; - painting->rippleDecay = painting->passiveRippleDecay; - painting->currRippleRate = painting->passiveRippleRate; - painting->dispersionFactor = painting->passiveDispersionFactor; + obj->oPaintingCurrRippleMag = painting->passiveRippleMag; + obj->oPaintingRippleDecay = painting->passiveRippleDecay; + obj->oPaintingCurrRippleRate = painting->passiveRippleRate; + obj->oPaintingDispersionFactor = painting->passiveDispersionFactor; break; case PAINTING_ENTERED: - painting->currRippleMag = painting->entryRippleMag; - painting->rippleDecay = painting->entryRippleDecay; - painting->currRippleRate = painting->entryRippleRate; - painting->dispersionFactor = painting->entryDispersionFactor; + obj->oPaintingCurrRippleMag = painting->entryRippleMag; + obj->oPaintingRippleDecay = painting->entryRippleDecay; + obj->oPaintingCurrRippleRate = painting->entryRippleRate; + obj->oPaintingDispersionFactor = painting->entryDispersionFactor; break; } - painting->state = state; - painting->rippleX = painting_ripple_x(painting, xSource); - painting->rippleY = painting_ripple_y(painting, ySource); - gPaintingMarioYEntry = gPaintingMarioYPos; - - // Because true or false would be too simple... - if (resetTimer == RESET_TIMER) { - painting->rippleTimer = 0.0f; - } - gRipplingPainting = painting; -} -/** - * Idle update function for wall paintings that use RIPPLE_TRIGGER_PROXIMITY. - */ -void wall_painting_proximity_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for Mario triggering a ripple - if (painting->floorEntered & RIPPLE_LEFT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_MIDDLE) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_RIGHT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - - // Check for Mario entering - } else if (painting->floorEntered & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } -} + obj->oPaintingState = state; -/** - * Rippling update function for wall paintings that use RIPPLE_TRIGGER_PROXIMITY. - */ -void wall_painting_proximity_rippling(struct Painting *painting, struct Painting *paintingGroup[]) { - if (painting->floorEntered & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); + // Set the ripple position + if (centerRipples) { + obj->oPaintingRippleX = (painting->sizeX * 0.5f); + obj->oPaintingRippleY = (painting->sizeY * 0.5f); + } else { + obj->oPaintingRippleX = obj->oPaintingLocalMarioPosX; + obj->oPaintingRippleY = obj->oPaintingLocalMarioPosY; } -} -/** - * Idle update function for wall paintings that use RIPPLE_TRIGGER_CONTINUOUS. - */ -void wall_painting_continuous_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for Mario triggering a ripple - if (painting->floorEntered & RIPPLE_LEFT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_MIDDLE) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_RIGHT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - - // Check for Mario entering - } else if (painting->floorEntered & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } else if (painting->floorEntered & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - } -} + // Set Mario's Y position for the WDW water level + gPaintingMarioYEntry = gMarioObject->oPosY; -/** - * Rippling update function for wall paintings that use RIPPLE_TRIGGER_CONTINUOUS. - */ -void wall_painting_continuous_rippling(struct Painting *painting, struct Painting *paintingGroup[]) { - if (painting->floorEntered & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, DONT_RESET); - } else if (painting->floorEntered & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, DONT_RESET); - } else if (painting->floorEntered & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, DONT_RESET); + if (resetTimer) { + obj->oPaintingRippleTimer = 0; } -} -/** - * Idle update function for floor paintings that use RIPPLE_TRIGGER_PROXIMITY. - * - * No floor paintings use RIPPLE_TRIGGER_PROXIMITY in the game. - */ -void floor_painting_proximity_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for Mario triggering a ripple - if (painting->floorEntered & RIPPLE_LEFT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_MIDDLE) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_RIGHT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - - // Only check for Mario entering if he jumped below the surface - } else if (painting->marioWentUnder) { - if (painting->currFloor & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->currFloor & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->currFloor & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } - } + gRipplingPainting = obj; } /** - * Rippling update function for floor paintings that use RIPPLE_TRIGGER_PROXIMITY. - * - * No floor paintings use RIPPLE_TRIGGER_PROXIMITY in the game. + * Check for Mario entering one of the special floors associated with the painting. */ -void floor_painting_proximity_rippling(struct Painting *painting, struct Painting *paintingGroup[]) { - if (painting->marioWentUnder) { - if (painting->currFloor & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->currFloor & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->currFloor & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } - } -} +void painting_update_floors(struct Object *obj) { + s8 rippleFlags = RIPPLE_FLAGS_NONE; -/** - * Idle update function for floor paintings that use RIPPLE_TRIGGER_CONTINUOUS. - * - * Both floor paintings (HMC and CotMC) are hidden behind a door, which hides the ripple's start up. - * The floor just inside the doorway is RIPPLE_LEFT, so the painting starts rippling as soon as Mario - * enters the room. - */ -void floor_painting_continuous_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for Mario triggering a ripple - if (painting->floorEntered & RIPPLE_LEFT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_MIDDLE) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - } else if (painting->floorEntered & RIPPLE_RIGHT) { - painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - - // Check for Mario entering - } else if (painting->currFloor & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->currFloor & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } else if (painting->currFloor & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - } -} + Vec3f marioWorldPos; + Vec3f marioLocalPos; + Vec3s rotation; -/** - * Rippling update function for floor paintings that use RIPPLE_TRIGGER_CONTINUOUS. - */ -void floor_painting_continuous_rippling(struct Painting *painting, struct Painting *paintingGroup[]) { - if (painting->marioWentUnder) { - if (painting->currFloor & ENTER_LEFT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, DONT_RESET); - } else if (painting->currFloor & ENTER_MIDDLE) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, DONT_RESET); - } else if (painting->currFloor & ENTER_RIGHT) { - painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, DONT_RESET); - } - } -} + // Add PAINTING_MARIO_Y_OFFSET to make the ripple closer to Mario's center of mass. + vec3f_copy_y_off(marioWorldPos, &gMarioObject->oPosVec, PAINTING_MARIO_Y_OFFSET); -/** - * Check for Mario entering one of the special floors associated with the painting. - */ -void painting_update_floors(struct Painting *painting) { - s16 paintingId = painting->id; - s8 rippleLeft = 0; - s8 rippleMiddle = 0; - s8 rippleRight = 0; - s8 enterLeft = 0; - s8 enterMiddle = 0; - s8 enterRight = 0; - - /* The area in front of every painting in the game (except HMC and CotMC, which *\ - |* act a little differently) is made up of 3 special floor triangles with special *| - |* (unique) surface types. This code checks which surface Mario is currently on *| - \* and sets a bitfield accordingly. */ - - // check if Mario's current floor is one of the special floors - if (gPaintingMarioFloorType == paintingId * 3 + SURFACE_PAINTING_WOBBLE_A6) { - rippleLeft = RIPPLE_LEFT; - } - if (gPaintingMarioFloorType == paintingId * 3 + SURFACE_PAINTING_WOBBLE_A7) { - rippleMiddle = RIPPLE_MIDDLE; - } - if (gPaintingMarioFloorType == paintingId * 3 + SURFACE_PAINTING_WOBBLE_A8) { - rippleRight = RIPPLE_RIGHT; - } - if (gPaintingMarioFloorType == paintingId * 3 + SURFACE_PAINTING_WARP_D3) { - enterLeft = ENTER_LEFT; - } - if (gPaintingMarioFloorType == paintingId * 3 + SURFACE_PAINTING_WARP_D4) { - enterMiddle = ENTER_MIDDLE; - } - if (gPaintingMarioFloorType == paintingId * 3 + SURFACE_PAINTING_WARP_D5) { - enterRight = ENTER_RIGHT; + // Get the painting's rotation. + vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); + + // Get Mario's position in the painting's local space. + vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); + + // Check if Mario is within the painting bounds laterally in local space. + if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN + && marioLocalPos[0] < (obj->oPaintingPtr->sizeX + PAINTING_EDGE_MARGIN) + && marioLocalPos[1] > -PAINTING_EDGE_MARGIN + && marioLocalPos[1] < (obj->oPaintingPtr->sizeY + PAINTING_EDGE_MARGIN)) { + // Check whether Mario is in the wobble zone. + if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH + && marioLocalPos[2] > 0.0f) { + rippleFlags |= RIPPLE_FLAG_RIPPLE; + } + // Check whether Mario is in the warp zone. + if (marioLocalPos[2] < 0.0f + && marioLocalPos[2] > -PAINTING_WARP_DEPTH) { + rippleFlags |= RIPPLE_FLAG_ENTER; + } } - painting->lastFloor = painting->currFloor; - // at most 1 of these will be nonzero; - painting->currFloor = rippleLeft + rippleMiddle + rippleRight + enterLeft + enterMiddle + enterRight; + s8 lastFlags = obj->oPaintingCurrFlags; + // at most 1 of these will be nonzero + obj->oPaintingCurrFlags = rippleFlags; - // floorEntered is true iff currFloor is true and lastFloor is false + // changedFlags is true if currFlags is true and lastFlags is false // (Mario just entered the floor on this frame) - painting->floorEntered = (painting->lastFloor ^ painting->currFloor) & painting->currFloor; - - painting->marioWasUnder = painting->marioIsUnder; - // Check if Mario has fallen below the painting (used for floor paintings) - if (gPaintingMarioYPos < painting->posY) { - painting->marioIsUnder = TRUE; - } else { - painting->marioIsUnder = FALSE; - } + obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); - // Mario "went under" if he was not under last frame, but is under now - painting->marioWentUnder = (painting->marioWasUnder ^ painting->marioIsUnder) & painting->marioIsUnder; + obj->oPaintingLocalMarioPosX = marioLocalPos[0]; + obj->oPaintingLocalMarioPosY = marioLocalPos[1]; } /** @@ -577,87 +243,38 @@ void painting_update_floors(struct Painting *painting) { * ripple's magnitude becomes small enough. */ void painting_update_ripple_state(struct Painting *painting) { - if (gPaintingUpdateCounter != gLastPaintingUpdateCounter) { - painting->currRippleMag *= painting->rippleDecay; + struct Object *obj = gCurGraphNodeObjectNode; - if (painting->rippleTimer >= ((1 << 24) - 1.0f)) { - painting->rippleTimer = 0.0f; + if (obj->oPaintingUpdateCounter != obj->oLastPaintingUpdateCounter) { + obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; + + if (obj->oPaintingRippleTimer >= (S16_MAX - 1)) { + obj->oPaintingRippleTimer = 0; } - painting->rippleTimer += 1.0f; + + obj->oPaintingRippleTimer++; } if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // if the painting is barely rippling, make it stop rippling - if (painting->currRippleMag <= 1.0f) { - painting->state = PAINTING_IDLE; + if (obj->oPaintingCurrRippleMag <= 1.0f) { + obj->oPaintingState = PAINTING_IDLE; gRipplingPainting = NULL; } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - // if the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple // If Mario goes below the surface but doesn't warp, the painting will eventually reset. - if (painting->state == PAINTING_ENTERED && painting->currRippleMag <= painting->passiveRippleMag) { - - painting->state = PAINTING_RIPPLE; - painting->currRippleMag = painting->passiveRippleMag; - painting->rippleDecay = painting->passiveRippleDecay; - painting->currRippleRate = painting->passiveRippleRate; - painting->dispersionFactor = painting->passiveDispersionFactor; + if ((obj->oPaintingState == PAINTING_ENTERED) + && (obj->oPaintingCurrRippleMag <= painting->passiveRippleMag)) { + obj->oPaintingState = PAINTING_RIPPLE; + obj->oPaintingCurrRippleMag = painting->passiveRippleMag; + obj->oPaintingRippleDecay = painting->passiveRippleDecay; + obj->oPaintingCurrRippleRate = painting->passiveRippleRate; + obj->oPaintingDispersionFactor = painting->passiveDispersionFactor; } } } -/** - * @return the ripple function at posX, posY - * note that posX and posY correspond to a point on the face of the painting, not actual axes - */ -s16 calculate_ripple_at_point(struct Painting *painting, f32 posX, f32 posY) { - /// Controls the peaks of the ripple. - f32 rippleMag = painting->currRippleMag; - /// Controls the ripple's frequency - f32 rippleRate = painting->currRippleRate; - /// Controls how fast the ripple spreads - f32 dispersionFactor = painting->dispersionFactor; - /// How far the ripple has spread - f32 rippleTimer = painting->rippleTimer; - /// x and y ripple origin - f32 rippleX = painting->rippleX; - f32 rippleY = painting->rippleY; - - f32 distanceToOrigin; - f32 rippleDistance; - - posX *= painting->size / PAINTING_SIZE; - posY *= painting->size / PAINTING_SIZE; - distanceToOrigin = sqrtf((posX - rippleX) * (posX - rippleX) + (posY - rippleY) * (posY - rippleY)); - // A larger dispersionFactor makes the ripple spread slower - rippleDistance = distanceToOrigin / dispersionFactor; - if (rippleTimer < rippleDistance) { - // if the ripple hasn't reached the point yet, make the point magnitude 0 - return 0; - } else { - // use a cosine wave to make the ripple go up and down, - // scaled by the painting's ripple magnitude - f32 rippleZ = rippleMag * cosf(rippleRate * (2 * M_PI) * (rippleTimer - rippleDistance)); - - // round it to an int and return it - return round_float(rippleZ); - } -} - -/** - * If movable, return the ripple function at (posX, posY) - * else return 0 - */ -s16 ripple_if_movable(struct Painting *painting, s16 movable, s16 posX, s16 posY) { - s16 rippleZ = 0; - - if (movable) { - rippleZ = calculate_ripple_at_point(painting, posX, posY); - } - return rippleZ; -} - /** * Allocates and generates a mesh for the rippling painting effect by modifying the passed in `mesh` * based on the painting's current ripple state. @@ -677,19 +294,62 @@ s16 ripple_if_movable(struct Painting *painting, s16 movable, s16 posX, s16 posY * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_generate_mesh(struct Painting *painting, s16 *mesh, s16 numTris) { - s16 i; +void painting_generate_mesh(struct Painting *painting, PaintingData *mesh, PaintingData numTris) { + struct Object *obj = gCurGraphNodeObjectNode; + s32 i, tri; + + gPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(struct PaintingMeshVertex))); - gPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, numTris * sizeof(struct PaintingMeshVertex)); + struct PaintingMeshVertex *paintingMesh = gPaintingMesh; - // accesses are off by 1 since the first entry is the number of vertices + /// Controls the peaks of the ripple. + f32 rippleMag = obj->oPaintingCurrRippleMag; + /// Controls the ripple's frequency. + f32 rippleRate = obj->oPaintingCurrRippleRate; + /// Controls how fast the ripple spreads. + f32 dispersionFactor = obj->oPaintingDispersionFactor; + /// How far the ripple has spread. + f32 rippleTimer = obj->oPaintingRippleTimer; + + /// X and Y ripple origin. + f32 rippleX = obj->oPaintingRippleX; + f32 rippleY = obj->oPaintingRippleY; + + f32 sizeRatioX = (painting->sizeX / PAINTING_SIZE); + f32 sizeRatioY = (painting->sizeY / PAINTING_SIZE); + + f32 dx, dy; + f32 rippleDistance; + + // Loop through all the painting vertices and calculate the ripple magnitude at each point. + // Accesses are off by 1 since the first entry is the number of vertices. for (i = 0; i < numTris; i++) { - gPaintingMesh[i].pos[0] = mesh[i * 3 + 1]; - gPaintingMesh[i].pos[1] = mesh[i * 3 + 2]; - // The "z coordinate" of each vertex in the mesh is either 1 or 0. Instead of being an - // actual coordinate, it just determines whether the vertex moves - gPaintingMesh[i].pos[2] = ripple_if_movable(painting, mesh[i * 3 + 3], - gPaintingMesh[i].pos[0], gPaintingMesh[i].pos[1]); + tri = (i * 3); + paintingMesh->pos[0] = mesh[tri + 1]; + paintingMesh->pos[1] = mesh[tri + 2]; + // The "Z coordinate" of each vertex in the mesh is either 1 or 0. Instead of being an + // actual coordinate, it just determines whether the vertex moves. + if (mesh[tri + 3]) { + // Scale and calculate the distance to the ripple origin. + dx = ((paintingMesh->pos[0] * sizeRatioX) - rippleX); + dy = ((paintingMesh->pos[1] * sizeRatioY) - rippleY); + // A larger dispersionFactor makes the ripple spread slower. + rippleDistance = sqrtf(sqr(dx) + sqr(dy)) / dispersionFactor; + + if (rippleTimer < rippleDistance) { + // If the ripple hasn't reached the point yet, make the point magnitude 0. + paintingMesh->pos[2] = 0; + } else { + // Use a cosine wave to make the ripple go up and down, + // scaled by the painting's ripple magnitude, + // round it to an int and return it. + paintingMesh->pos[2] = roundf(rippleMag * coss((s16)((rippleRate * (rippleTimer - rippleDistance)) * 0x10000))); + } + } else { + paintingMesh->pos[2] = 0; + } + + paintingMesh++; } } @@ -710,31 +370,20 @@ void painting_generate_mesh(struct Painting *painting, s16 *mesh, s16 numTris) { */ void painting_calculate_triangle_normals(PaintingData *mesh, PaintingData numVtx, PaintingData numTris) { s16 i; + Vec3s v; + Vec3f vp0, vp1, vp2; - gPaintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, numTris * sizeof(Vec3f)); + gPaintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); for (i = 0; i < numTris; i++) { - s16 tri = numVtx * 3 + i * 3 + 2; // Add 2 because of the 2 length entries preceding the list - s16 v0 = mesh[tri]; - s16 v1 = mesh[tri + 1]; - s16 v2 = mesh[tri + 2]; - - f32 x0 = gPaintingMesh[v0].pos[0]; - f32 y0 = gPaintingMesh[v0].pos[1]; - f32 z0 = gPaintingMesh[v0].pos[2]; - - f32 x1 = gPaintingMesh[v1].pos[0]; - f32 y1 = gPaintingMesh[v1].pos[1]; - f32 z1 = gPaintingMesh[v1].pos[2]; - - f32 x2 = gPaintingMesh[v2].pos[0]; - f32 y2 = gPaintingMesh[v2].pos[1]; - f32 z2 = gPaintingMesh[v2].pos[2]; + PaintingData tri = ((numVtx * 3) + (i * 3) + 2); // Add 2 because of the 2 length entries preceding the list + vec3s_copy(v, &mesh[tri]); + vec3s_to_vec3f(vp0, gPaintingMesh[v[0]].pos); + vec3s_to_vec3f(vp1, gPaintingMesh[v[1]].pos); + vec3s_to_vec3f(vp2, gPaintingMesh[v[2]].pos); // Cross product to find each triangle's normal vector - gPaintingTriNorms[i][0] = (y1 - y0) * (z2 - z1) - (z1 - z0) * (y2 - y1); - gPaintingTriNorms[i][1] = (z1 - z0) * (x2 - x1) - (x1 - x0) * (z2 - z1); - gPaintingTriNorms[i][2] = (x1 - x0) * (y2 - y1) - (y1 - y0) * (x2 - x1); + find_vector_perpendicular_to_plane(gPaintingTriNorms[i], vp0, vp1, vp2); } } @@ -742,17 +391,14 @@ void painting_calculate_triangle_normals(PaintingData *mesh, PaintingData numVtx * Rounds a floating-point component of a normal vector to an s8 by multiplying it by 127 or 128 and * rounding away from 0. */ -s8 normalize_component(f32 comp) { - s8 rounded; - - if (comp > 0.0) { - rounded = comp * 127.0 + 0.5; // round up - } else if (comp < 0.0) { - rounded = comp * 128.0 - 0.5; // round down +s32 normalize_component(f32 comp) { + if (comp > 0.0f) { + return (s8)((comp * 127.0f) + 0.5f); // round up + } else if (comp < 0.0f) { + return (s8)((comp * 128.0f) - 0.5f); // round down } else { - rounded = 0; // don't round 0 + return 0; // don't round 0 } - return rounded; } /** @@ -771,43 +417,34 @@ s8 normalize_component(f32 comp) { * The table used in game, seg2_painting_mesh_neighbor_tris, is in bin/segment2.c. */ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData numVtx) { - s16 tri; - s16 i; - s16 j; - s16 neighbors; - s16 entry = 0; + PaintingData tri; + PaintingData i, j; + PaintingData neighbors; + PaintingData entry = 0; for (i = 0; i < numVtx; i++) { - f32 nx = 0.0f; - f32 ny = 0.0f; - f32 nz = 0.0f; - f32 nlen; + Vec3f n = { 0.0f, 0.0f, 0.0f }; // The first number of each entry is the number of adjacent tris neighbors = neighborTris[entry]; for (j = 0; j < neighbors; j++) { tri = neighborTris[entry + j + 1]; - nx += gPaintingTriNorms[tri][0]; - ny += gPaintingTriNorms[tri][1]; - nz += gPaintingTriNorms[tri][2]; + vec3f_add(n, gPaintingTriNorms[tri]); } // Move to the next vertex's entry - entry += neighbors + 1; + entry += (neighbors + 1); // average the surface normals from each neighboring tri - nx /= neighbors; - ny /= neighbors; - nz /= neighbors; - nlen = sqrtf(nx * nx + ny * ny + nz * nz); - - if (nlen == 0.0f) { - gPaintingMesh[i].norm[0] = 0; - gPaintingMesh[i].norm[1] = 0; - gPaintingMesh[i].norm[2] = 0; + vec3_div_val(n, neighbors); + f32 nlen = vec3_sumsq(n); + + if (FLT_IS_NONZERO(nlen)) { + nlen = sqrtf(nlen); + gPaintingMesh[i].norm[0] = normalize_component(n[0] / nlen); + gPaintingMesh[i].norm[1] = normalize_component(n[1] / nlen); + gPaintingMesh[i].norm[2] = normalize_component(n[2] / nlen); } else { - gPaintingMesh[i].norm[0] = normalize_component(nx / nlen); - gPaintingMesh[i].norm[1] = normalize_component(ny / nlen); - gPaintingMesh[i].norm[2] = normalize_component(nz / nlen); + vec3_zero(gPaintingMesh[i].norm); } } } @@ -819,22 +456,21 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu * If the textureMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole * painting. */ -Gfx *render_painting(u8 *img, s16 tWidth, s16 tHeight, s16 *textureMap, s16 mapVerts, s16 mapTris, u8 alpha) { - s16 group; - s16 map; - s16 triGroup; - s16 mapping; - s16 meshVtx; - s16 tx; - s16 ty; +Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, PaintingData *textureMap, PaintingData mapVerts, PaintingData mapTris, Alpha alpha) { + PaintingData group; + PaintingData map; + PaintingData triGroup; + PaintingData mapping; + PaintingData meshVtx; + PaintingData tx, ty; // We can fit 15 (16 / 3) vertices in the RSP's vertex buffer. // Group triangles by 5, with one remainder group. - s16 triGroups = mapTris / 5; - s16 remGroupTris = mapTris % 5; - s16 numVtx = mapTris * 3; + PaintingData triGroups = (mapTris / 5); + PaintingData remGroupTris = (mapTris % 5); + PaintingData numVtx = (mapTris * 3); - s16 commands = triGroups * 2 + remGroupTris + 7; + PaintingData commands = ((triGroups * 2) + remGroupTris + 7); Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; @@ -843,53 +479,68 @@ Gfx *render_painting(u8 *img, s16 tWidth, s16 tHeight, s16 *textureMap, s16 mapV // Draw the groups of 5 first for (group = 0; group < triGroups; group++) { - // The triangle groups are the second part of the texture map. // Each group is a list of 15 mappings - triGroup = mapVerts * 3 + group * 15 + 2; + triGroup = ((mapVerts * 3) + (group * 15) + 2); + for (map = 0; map < 15; map++) { // The mapping is just an index into the earlier part of the textureMap // Some mappings are repeated, for example, when multiple triangles share a vertex mapping = textureMap[triGroup + map]; // The first entry is the ID of the vertex in the mesh - meshVtx = textureMap[mapping * 3 + 1]; + meshVtx = textureMap[(mapping * 3) + 1]; // The next two are the texture coordinates for that vertex - tx = textureMap[mapping * 3 + 2]; - ty = textureMap[mapping * 3 + 3]; + tx = textureMap[(mapping * 3) + 2]; + ty = textureMap[(mapping * 3) + 3]; // Map the texture and place it in the verts array - make_vertex(verts, group * 15 + map, gPaintingMesh[meshVtx].pos[0], gPaintingMesh[meshVtx].pos[1], - gPaintingMesh[meshVtx].pos[2], tx, ty, gPaintingMesh[meshVtx].norm[0], - gPaintingMesh[meshVtx].norm[1], gPaintingMesh[meshVtx].norm[2], alpha); + make_vertex(verts, ((group * 15) + map), gPaintingMesh[meshVtx].pos[0], + gPaintingMesh[meshVtx].pos[1], + gPaintingMesh[meshVtx].pos[2], + tx, ty, + gPaintingMesh[meshVtx].norm[0], + gPaintingMesh[meshVtx].norm[1], + gPaintingMesh[meshVtx].norm[2], + alpha); } // Load the vertices and draw the 5 triangles - gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + group * 15), 15, 0); + gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (group * 15)), 15, 0); gSPDisplayList(gfx++, dl_paintings_draw_ripples); } // One group left with < 5 triangles - triGroup = mapVerts * 3 + triGroups * 15 + 2; + triGroup = ((mapVerts * 3) + (triGroups * 15) + 2); + // Map the texture to the triangles - for (map = 0; map < remGroupTris * 3; map++) { + for (map = 0; map < (remGroupTris * 3); map++) { mapping = textureMap[triGroup + map]; - meshVtx = textureMap[mapping * 3 + 1]; - tx = textureMap[mapping * 3 + 2]; - ty = textureMap[mapping * 3 + 3]; - make_vertex(verts, triGroups * 15 + map, gPaintingMesh[meshVtx].pos[0], gPaintingMesh[meshVtx].pos[1], - gPaintingMesh[meshVtx].pos[2], tx, ty, gPaintingMesh[meshVtx].norm[0], - gPaintingMesh[meshVtx].norm[1], gPaintingMesh[meshVtx].norm[2], alpha); + meshVtx = textureMap[(mapping * 3) + 1]; + tx = textureMap[(mapping * 3) + 2]; + ty = textureMap[(mapping * 3) + 3]; + make_vertex(verts, ((triGroups * 15) + map), gPaintingMesh[meshVtx].pos[0], + gPaintingMesh[meshVtx].pos[1], + gPaintingMesh[meshVtx].pos[2], + tx, ty, + gPaintingMesh[meshVtx].norm[0], + gPaintingMesh[meshVtx].norm[1], + gPaintingMesh[meshVtx].norm[2], + alpha); } // Draw the triangles individually - gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + triGroups * 15), remGroupTris * 3, 0); + gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (triGroups * 15)), (remGroupTris * 3), 0); + for (group = 0; group < remGroupTris; group++) { - gSP1Triangle(gfx++, group * 3, group * 3 + 1, group * 3 + 2, 0); + gSP1Triangle(gfx++, ((group * 3) + 0), + ((group * 3) + 1), + ((group * 3) + 2), 0); } gSPEndDisplayList(gfx); + return dlist; } @@ -897,23 +548,19 @@ Gfx *render_painting(u8 *img, s16 tWidth, s16 tHeight, s16 *textureMap, s16 mapV * Orient the painting mesh for rendering. */ Gfx *painting_model_view_transform(struct Painting *painting) { - f32 sizeRatio = painting->size / PAINTING_SIZE; - Mtx *rotX = alloc_display_list(sizeof(Mtx)); - Mtx *rotY = alloc_display_list(sizeof(Mtx)); - Mtx *translate = alloc_display_list(sizeof(Mtx)); - Mtx *scale = alloc_display_list(sizeof(Mtx)); - Gfx *dlist = alloc_display_list(5 * sizeof(Gfx)); + Gfx *dlist = alloc_display_list(2 * sizeof(Gfx)); Gfx *gfx = dlist; - guTranslate(translate, painting->posX, painting->posY, painting->posZ); - guRotate(rotX, painting->pitch, 1.0f, 0.0f, 0.0f); - guRotate(rotY, painting->yaw, 0.0f, 1.0f, 0.0f); - guScale(scale, sizeRatio, sizeRatio, sizeRatio); + // Scale + Mtx *scale = alloc_display_list(sizeof(Mtx)); + guScale( + scale, + (painting->sizeX / PAINTING_SIZE), + (painting->sizeY / PAINTING_SIZE), + 1.0f + ); + gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); - gSPMatrix(gfx++, translate, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH); - gSPMatrix(gfx++, rotX, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); - gSPMatrix(gfx++, rotY, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); - gSPMatrix(gfx++, scale, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); gSPEndDisplayList(gfx); return dlist; @@ -923,9 +570,9 @@ Gfx *painting_model_view_transform(struct Painting *painting) { * Ripple a painting that has 1 or more images that need to be mapped */ Gfx *painting_ripple_image(struct Painting *painting) { + s16 i; PaintingData meshVerts; PaintingData meshTris; - PaintingData i; PaintingData *textureMap; PaintingData imageCount = painting->imageCount; PaintingData tWidth = painting->textureWidth; @@ -947,7 +594,7 @@ Gfx *painting_ripple_image(struct Painting *painting) { for (i = 0; i < imageCount; i++) { textureMap = segmented_to_virtual(textureMaps[i]); meshVerts = textureMap[0]; - meshTris = textureMap[meshVerts * 3 + 1]; + meshTris = textureMap[(meshVerts * 3) + 1]; gSPDisplayList(gfx++, render_painting(textures[i], tWidth, tHeight, textureMap, meshVerts, meshTris, painting->alpha)); } @@ -957,6 +604,7 @@ Gfx *painting_ripple_image(struct Painting *painting) { gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPDisplayList(gfx++, dl_paintings_rippling_end); gSPEndDisplayList(gfx); + return dlist; } @@ -964,13 +612,10 @@ Gfx *painting_ripple_image(struct Painting *painting) { * Ripple a painting that has 1 "environment map" texture. */ Gfx *painting_ripple_env_mapped(struct Painting *painting) { - s16 meshVerts; - s16 meshTris; - s16 *textureMap; - s16 tWidth = painting->textureWidth; - s16 tHeight = painting->textureHeight; - s16 **textureMaps = segmented_to_virtual(painting->textureMaps); - u8 **tArray = segmented_to_virtual(painting->textureArray); + PaintingData tWidth = painting->textureWidth; + PaintingData tHeight = painting->textureHeight; + PaintingData **textureMaps = segmented_to_virtual(painting->textureMaps); + Texture **tArray = segmented_to_virtual(painting->textureArray); Gfx *dlist = alloc_display_list(7 * sizeof(Gfx)); Gfx *gfx = dlist; @@ -983,9 +628,10 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting) { gSPDisplayList(gfx++, painting->rippleDisplayList); // Map the image to the mesh's vertices - textureMap = segmented_to_virtual(textureMaps[0]); - meshVerts = textureMap[0]; - meshTris = textureMap[meshVerts * 3 + 1]; + PaintingData *textureMap = segmented_to_virtual(textureMaps[0]); + PaintingData meshVerts = textureMap[0]; + PaintingData meshTris = textureMap[(meshVerts * 3) + 1]; + gSPDisplayList(gfx++, render_painting(tArray[0], tWidth, tHeight, textureMap, meshVerts, meshTris, painting->alpha)); // Update the ripple, may automatically reset the painting's state. @@ -994,6 +640,7 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting) { gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPDisplayList(gfx++, dl_paintings_env_mapped_end); gSPEndDisplayList(gfx); + return dlist; } @@ -1002,10 +649,10 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting) { * The mesh and vertex normals are regenerated and freed every frame. */ Gfx *display_painting_rippling(struct Painting *painting) { - s16 *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); - s16 *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); - s16 numVtx = mesh[0]; - s16 numTris = mesh[numVtx * 3 + 1]; + PaintingData *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); + PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); + PaintingData numVtx = mesh[0]; + PaintingData numTris = mesh[(numVtx * 3) + 1]; Gfx *dlist = NULL; // Generate the mesh and its lighting data @@ -1026,6 +673,7 @@ Gfx *display_painting_rippling(struct Painting *painting) { // The mesh data is freed every frame. mem_pool_free(gEffectsMemoryPool, gPaintingMesh); mem_pool_free(gEffectsMemoryPool, gPaintingTriNorms); + return dlist; } @@ -1039,23 +687,21 @@ Gfx *display_painting_not_rippling(struct Painting *painting) { if (dlist == NULL) { return dlist; } + gSPDisplayList(gfx++, painting_model_view_transform(painting)); gSPDisplayList(gfx++, painting->normalDisplayList); gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); + return dlist; } /** * Clear Mario-related state and clear gRipplingPainting. */ -void reset_painting(struct Painting *painting) { - painting->lastFloor = 0; - painting->currFloor = 0; - painting->floorEntered = 0; - painting->marioWasUnder = 0; - painting->marioIsUnder = 0; - painting->marioWentUnder = 0; +void reset_painting(struct Object *obj) { + obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; + obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; gRipplingPainting = NULL; @@ -1063,18 +709,18 @@ void reset_painting(struct Painting *painting) { // Make sure all variables are reset correctly. // With segmented memory the segments that contain the relevant // Painting structs are reloaded from ROM upon level load. - painting->state = PAINTING_IDLE; - painting->currRippleMag = 0.0f; - painting->rippleDecay = 1.0f; - painting->currRippleRate = 0.0f; - painting->dispersionFactor = 0.0f; - painting->rippleTimer = 0.0f; - painting->rippleX = 0.0f; - painting->rippleY = 0.0f; - if (painting == &ddd_painting) { + obj->oPaintingState = PAINTING_IDLE; + obj->oPaintingCurrRippleMag = 0.0f; + obj->oPaintingRippleDecay = 1.0f; + obj->oPaintingCurrRippleRate = 0.0f; + obj->oPaintingDispersionFactor = 0.0f; + obj->oPaintingRippleTimer = 0; + obj->oPaintingRippleX = 0; + obj->oPaintingRippleY = 0; + if (obj->oPaintingPtr == &ddd_painting) { // Move DDD painting to initial position, in case the animation // that moves the painting stops during level unload. - painting->posX = 3456.0f; + obj->oPosX = 3456.0f; } #endif } @@ -1088,188 +734,167 @@ void reset_painting(struct Painting *painting) { * * When the painting reaches backPos, a save flag is set so that the painting will spawn at backPos * whenever it loads. - * - * This function also sets gDddPaintingStatus, which controls the warp: - * 0 (0b00): set x coordinate to frontPos - * 2 (0b10): set x coordinate to backPos - * 3 (0b11): same as 2. Bit 0 is ignored */ +void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) { #ifdef UNLOCK_ALL -void move_ddd_painting(struct Painting *painting, UNUSED f32 frontPos, f32 backPos, UNUSED f32 speed) { - painting->posX = backPos; - gDddPaintingStatus = (DDD_FLAG_BOWSERS_SUB_BEATEN | DDD_FLAG_BACK); -} -#else -void move_ddd_painting(struct Painting *painting, f32 frontPos, f32 backPos, f32 speed) { - // Obtain the DDD star flags - u32 dddFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_DDD)); - // Get the other save file flags - u32 saveFileFlags = save_file_get_flags(); - // Find out whether Board Bowser's Sub was collected - u32 bowsersSubBeaten = dddFlags & BOARD_BOWSERS_SUB; - // Check whether DDD has already moved back - u32 dddBack = saveFileFlags & SAVE_FLAG_DDD_MOVED_BACK; + obj->oPosX = backPos; + return; +#endif + // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected + u32 bowsersSubBeaten = (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1); + // Get the other save file flags and check whether DDD has already moved back + u32 dddBack = (save_file_get_flags() & SAVE_FLAG_DDD_MOVED_BACK); if (!bowsersSubBeaten && !dddBack) { // If we haven't collected the star or moved the painting, put the painting at the front - painting->posX = frontPos; - gDddPaintingStatus = DDD_FLAGS_NONE; + obj->oPosX = frontPos; } else if (bowsersSubBeaten && !dddBack) { // If we've collected the star but not moved the painting back, // Each frame, move the painting by a certain speed towards the back area. - painting->posX += speed; - gDddPaintingStatus = DDD_FLAG_BOWSERS_SUB_BEATEN; - if (painting->posX >= backPos) { - painting->posX = backPos; + obj->oPosX += speed; + if (obj->oPosX >= backPos) { + obj->oPosX = backPos; // Tell the save file that we've moved DDD back. save_file_set_flags(SAVE_FLAG_DDD_MOVED_BACK); } } else if (bowsersSubBeaten && dddBack) { // If the painting has already moved back, place it in the back position. - painting->posX = backPos; - gDddPaintingStatus = (DDD_FLAG_BOWSERS_SUB_BEATEN | DDD_FLAG_BACK); + obj->oPosX = backPos; } } -#endif /** - * Set the painting's node's layer based on its alpha + * Render and update the painting whose id and group matches the values in the GraphNode's parameter. + * Use PAINTING_ID(id, group) to set the right parameter in a level's geo layout. */ -void set_painting_layer(struct GraphNodeGenerated *gen, struct Painting *painting) { - if (painting->alpha == 0xFF) { // Opaque - SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); - } else { - SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_TRANSPARENT); - } -} +Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context) { + struct GraphNodeGenerated *gen = (struct GraphNodeGenerated *) node; + struct Object *obj = gCurGraphNodeObjectNode; -/** - * Display either a normal painting or a rippling one depending on the painting's ripple status - */ -Gfx *display_painting(struct Painting *painting) { - switch (painting->state) { - case PAINTING_IDLE: - return display_painting_not_rippling(painting); - break; - default: - return display_painting_rippling(painting); - break; + if (obj == NULL) { + return NULL; } -} -/** - * Update function for wall paintings. - * Calls a different update function depending on the painting's ripple trigger and current state. - */ -void wall_painting_update(struct Painting *painting, struct Painting *paintingGroup[]) { - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - switch (painting->state) { - case PAINTING_IDLE: - wall_painting_proximity_idle(painting, paintingGroup); - break; - case PAINTING_RIPPLE: - wall_painting_proximity_rippling(painting, paintingGroup); - break; - } - } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - switch (painting->state) { - case PAINTING_IDLE: - wall_painting_continuous_idle(painting, paintingGroup); - break; - case PAINTING_RIPPLE: - wall_painting_continuous_rippling(painting, paintingGroup); - break; - } + // Failsafe for nonexistent painting groups. + if (obj->oPaintingGroup >= PAINTING_NUM_GROUPS) { + return NULL; } -} -/** - * Update function for floor paintings (HMC and CotMC) - * Calls a different update function depending on the painting's ripple trigger and current state. - * - * No floor paintings use RIPPLE_TRIGGER_PROXIMITY in the game. - */ -void floor_painting_update(struct Painting *painting, struct Painting *paintingGroup[]) { - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - switch (painting->state) { - case PAINTING_IDLE: - floor_painting_proximity_idle(painting, paintingGroup); - break; - case PAINTING_RIPPLE: - floor_painting_proximity_rippling(painting, paintingGroup); - break; - } - } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - switch (painting->state) { - case PAINTING_IDLE: - floor_painting_continuous_idle(painting, paintingGroup); - break; - case PAINTING_RIPPLE: - floor_painting_continuous_rippling(painting, paintingGroup); - break; - } - } -} - -/** - * Render and update the painting whose id and group matches the values in the GraphNode's parameter. - * Use PAINTING_ID(id, group) to set the right parameter in a level's geo layout. - */ -Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context) { - struct GraphNodeGenerated *gen = (struct GraphNodeGenerated *) node; - s32 group = (gen->parameter >> 8) & 0xFF; - s32 id = gen->parameter & 0xFF; Gfx *paintingDlist = NULL; - struct Painting **paintingGroup = sPaintingGroups[group]; - struct Painting *painting = segmented_to_virtual(paintingGroup[id]); + struct Painting *painting = obj->oPaintingPtr; + + if (painting == NULL) { + return NULL; + } if (callContext != GEO_CONTEXT_RENDER) { - reset_painting(painting); + // Reset the update counter + obj->oLastPaintingUpdateCounter = (gAreaUpdateCounter - 1); + obj->oPaintingUpdateCounter = gAreaUpdateCounter; + + reset_painting(obj); } else if (callContext == GEO_CONTEXT_RENDER) { + // Reset the update counter + obj->oLastPaintingUpdateCounter = obj->oPaintingUpdateCounter; + obj->oPaintingUpdateCounter = gAreaUpdateCounter; +#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) // Update the ddd painting before drawing - if (group == 1 && id == PAINTING_ID_DDD) { - move_ddd_painting(painting, 3456.0f, 5529.6f, 20.0f); + if (obj->oPaintingGroup == PAINTING_GROUP_INSIDE_CASTLE + && obj->oPaintingId == PAINTING_ID_CASTLE_DDD) { + move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); } +#endif - // Determine if the painting is transparent - set_painting_layer(gen, painting); + // Update the painting + painting_update_floors(obj); + + // Draw the painting + if (painting->imageCount > 0 + && painting->normalDisplayList != NULL + && painting->textureMaps != NULL + && painting->textureArray != NULL + && painting->textureWidth > 0 + && painting->textureHeight > 0 + && painting->alpha > 0) { + // Determine if the painting is opaque + if (painting->alpha == 0xFF) { + SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); + } else { + SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_TRANSPARENT); + } + + if (obj->oPaintingState == PAINTING_IDLE) { + paintingDlist = display_painting_not_rippling(painting); + } else { + paintingDlist = display_painting_rippling(painting); + } + } - // Draw before updating - paintingDlist = display_painting(painting); + if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { + // Proximity painting enter ripple + painting_state(obj, PAINTING_ENTERED, FALSE, TRUE); + } else if (obj->oPaintingState != PAINTING_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { + // Proximity painting wobble ripple + painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE); + } + } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { + // Continuous painting enter ripple + painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); + } else if (obj->oPaintingState == PAINTING_IDLE) { + // Continuous painting idle ripple + painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE); + } + } - // Update the painting - painting_update_floors(painting); - if (painting->pitch == 0x0) { - // only paintings with 0 pitch are treated as walls - wall_painting_update(painting, paintingGroup); - } else { - floor_painting_update(painting, paintingGroup); + if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { + // Mario has entered the painting. + gEnteredPainting = obj; + } else if (gEnteredPainting == obj) { + // Reset gEnteredPainting if it's this painting and this painting is not entered. + gEnteredPainting = NULL; } } + return paintingDlist; } -/** - * Update the painting system's local copy of Mario's current floor and position. - */ -Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx) { - struct Surface *surface; +void bhv_painting_init(void) { + // Get the painting group and id from the behavior params. + o->oPaintingGroup = GET_BPARAM1(o->oBehParams); + o->oPaintingId = GET_BPARAM2(o->oBehParams); - // Reset the update counter - if (callContext != GEO_CONTEXT_RENDER) { - gLastPaintingUpdateCounter = gAreaUpdateCounter - 1; - gPaintingUpdateCounter = gAreaUpdateCounter; - } else { - gLastPaintingUpdateCounter = gPaintingUpdateCounter; - gPaintingUpdateCounter = gAreaUpdateCounter; - - // Store Mario's position - find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &surface); - gPaintingMarioFloorType = surface->type; - gPaintingMarioXPos = gMarioObject->oPosX; - gPaintingMarioYPos = gMarioObject->oPosY; - gPaintingMarioZPos = gMarioObject->oPosZ; + // Failsafe for nonexistent painting groups. + if (o->oPaintingGroup >= PAINTING_NUM_GROUPS) { + return; } - return NULL; + + struct Painting **paintingGroup = sPaintingGroups[o->oPaintingGroup]; + o->oPaintingPtr = segmented_to_virtual(paintingGroup[o->oPaintingId]); + + Vec3f roomFloorCheckPos; + + // The center of the painting with a z offset since paintings are usually between floor triangles laterally. + Vec3f distPos = { + (o->oPaintingPtr->sizeX * 0.5f), + (o->oPaintingPtr->sizeY * 0.5f), + PAINTING_WOBBLE_DEPTH + }; + + // Get the painting object's rotation. + Vec3s rotation; + vec3i_to_vec3s(rotation, &o->oFaceAngleVec); + + // Set 'roomFloorCheckPos' to world space coords. + vec3f_local_pos_to_world_pos(roomFloorCheckPos, distPos, &o->oPosVec, rotation); + + // Set the object's room so that paintings only render in their room. + o->oRoom = get_room_at_pos(roomFloorCheckPos[0], + roomFloorCheckPos[1], + roomFloorCheckPos[2]); +} + +void bhv_painting_loop(void) { } diff --git a/src/game/paintings.h b/src/game/paintings.h index eaae28d899..52761caa98 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -7,33 +7,87 @@ #include "macros.h" #include "types.h" -/// Use to properly set a GraphNodeGenerated's parameter to point to the right painting -#define PAINTING_ID(id, grp) id | (grp << 8) +/// Use to properly set a GraphNodeGenerated's parameter to point to the right painting. +/// Use this for both bparam1 and bparam2 for painting objects. +#define PAINTING_ID(id, grp) (id | (grp << 8)) -/// The default painting side length +/// The default painting side length. #define PAINTING_SIZE 614.0f -#define PAINTING_ID_DDD 0x7 +/// The depth of the area in front of the painting which triggers ripples without warping. +#define PAINTING_WOBBLE_DEPTH 100.0f -#define BOARD_BOWSERS_SUB (1 << 0) +/// The depth of the area behind the painting which triggers the warp. +#define PAINTING_WARP_DEPTH PAINTING_SIZE -enum DDDPaintingFlags { - DDD_FLAGS_NONE = (0 << 0), // 0x0 - DDD_FLAG_BACK = (1 << 0), // 0x1 - DDD_FLAG_BOWSERS_SUB_BEATEN = (1 << 1), // 0x2 +/// The space around the edges in which Mario is still considered within painting bounds. +#define PAINTING_EDGE_MARGIN (PAINTING_SIZE / 2) + +/// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. +#define PAINTING_MARIO_Y_OFFSET 50.0f + +// HMC painting group +enum HMCPaintingIDs { + /*0x0*/ PAINTING_ID_HMC_COTMC, +}; + +// Inside Castle painting group +enum CastlePaintingIDs { + /*0x0*/ PAINTING_ID_CASTLE_BOB, + /*0x1*/ PAINTING_ID_CASTLE_CCM, + /*0x2*/ PAINTING_ID_CASTLE_WF, + /*0x3*/ PAINTING_ID_CASTLE_JRB, + /*0x4*/ PAINTING_ID_CASTLE_LLL, + /*0x5*/ PAINTING_ID_CASTLE_SSL, + /*0x6*/ PAINTING_ID_CASTLE_HMC, + /*0x7*/ PAINTING_ID_CASTLE_DDD, + /*0x8*/ PAINTING_ID_CASTLE_WDW, + /*0x9*/ PAINTING_ID_CASTLE_THI_TINY, + /*0xA*/ PAINTING_ID_CASTLE_TTM, + /*0xB*/ PAINTING_ID_CASTLE_TTC, + /*0xC*/ PAINTING_ID_CASTLE_SL, + /*0xD*/ PAINTING_ID_CASTLE_THI_HUGE, + /*0xE*/ PAINTING_ID_CASTLE_RR, +}; + +// TTM painting group +enum TTMPaintingIDs { + /*0x0*/ PAINTING_ID_TTM_SLIDE, +}; + +// Painting group ids +enum PaintingGroups { + PAINTING_GROUP_HMC, + PAINTING_GROUP_INSIDE_CASTLE, + PAINTING_GROUP_TTM, + PAINTING_NUM_GROUPS, + PAINTING_GROUP_NULL = -1, }; +// Painting->state enum PaintingState { PAINTING_IDLE, PAINTING_RIPPLE, - PAINTING_ENTERED + PAINTING_ENTERED, }; +// Painting->rippleTrigger enum RippleTriggers { - RIPPLE_TRIGGER_PROXIMITY = 10, - RIPPLE_TRIGGER_CONTINUOUS = 20, + RIPPLE_TRIGGER_PROXIMITY, + RIPPLE_TRIGGER_CONTINUOUS, +}; + +// Painting->lastFlags, Painting->currFlags, Painting->changedFlags +enum PaintingRippleFlags { + // Not rippling. + RIPPLE_FLAGS_NONE = (0 << 0), // 0x00 + // Triggers an entry ripple. + RIPPLE_FLAG_ENTER = (1 << 0), // 0x01 + // Triggers a passive ripple. + RIPPLE_FLAG_RIPPLE = (1 << 1), // 0x02 }; +// Painting->textureType enum PaintingType { /// Painting that uses 1 or more images as a texture PAINTING_IMAGE, @@ -42,63 +96,33 @@ enum PaintingType { }; struct Painting { - s16 id; + /// Id of the painting warp node. + PaintingData id; /// How many images should be drawn when the painting is rippling. s8 imageCount; /// Either PAINTING_IMAGE or PAINTING_ENV_MAP s8 textureType; - /// The floor Mario was on last frame - s8 lastFloor; - /// The floor Mario is currently on - s8 currFloor; - /// The floor Mario just entered - s8 floorEntered; - - /// The painting's state, see top of paintings.c - s8 state; - - /// The painting's rotation - f32 pitch; - f32 yaw; - - /// The painting's position - f32 posX; - f32 posY; - f32 posZ; - /// Controls how high the peaks of the ripple are. - f32 currRippleMag; f32 passiveRippleMag; f32 entryRippleMag; /// Multiplier that controls how fast the ripple regresses to the IDLE state. - f32 rippleDecay; f32 passiveRippleDecay; f32 entryRippleDecay; /// Controls the ripple's frequency - f32 currRippleRate; f32 passiveRippleRate; f32 entryRippleRate; - /// The rate at which the magnitude of the ripple decreases as you move farther from the central - /// point of the ripple - f32 dispersionFactor; + /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple f32 passiveDispersionFactor; f32 entryDispersionFactor; - /// How far the ripple has spread - f32 rippleTimer; - - /// The x and y origin of the ripple - f32 rippleX; - f32 rippleY; - /// Display list used when the painting is normal. const Gfx *normalDisplayList; /// Data used to map the texture to the mesh - const s16 *const *textureMaps; + const PaintingData *const *textureMaps; // Texture data const Texture *const *textureArray; @@ -107,22 +131,17 @@ struct Painting { /// Display list used when the painting is rippling. const Gfx *rippleDisplayList; + /// Controls when a passive ripple starts. RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. s8 rippleTrigger; /// The painting's transparency. Determines what layer the painting is in. Alpha alpha; - /// True if Mario was under the painting's y coordinate last frame - s8 marioWasUnder; - /// True if Mario is currently under the painting's y coordinate - s8 marioIsUnder; - /// True if Mario just went under the painting's y coordinate on this frame - s8 marioWentUnder; - /// Uniformly scales the painting to a multiple of PAINTING_SIZE. - /// By default a painting is 614.0 x 614.0 - f32 size; + /// By default a painting is 614.0f x 614.0f + f32 sizeX; + f32 sizeY; }; /** @@ -135,10 +154,12 @@ struct PaintingMeshVertex { extern struct PaintingMeshVertex *gPaintingMesh; extern Vec3f *gPaintingTriNorms; -extern struct Painting *gRipplingPainting; -extern s8 gDddPaintingStatus; +extern struct Object *gRipplingPainting; +extern struct Object *gEnteredPainting; Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); -Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx); + +void bhv_painting_init(void); +void bhv_painting_loop(void); #endif // PAINTINGS_H diff --git a/src/game/sound_init.c b/src/game/sound_init.c index ea124bdc79..d85aae7a2a 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -75,7 +75,8 @@ static u32 sMenuSoundsExtra[] = { SOUND_AIR_BLOW_FIRE, SOUND_ENV_ELEVATOR4, }; -static s8 sPaintingEjectSoundPlayed = FALSE; + +s8 sPaintingEjectSoundPlayed = FALSE; void play_menu_sounds_extra(s32 a, void *b); @@ -187,7 +188,7 @@ void play_menu_sounds(s16 soundMenuFlags) { * Called from threads: thread5_game_loop */ void play_painting_eject_sound(void) { - if (gRipplingPainting != NULL && gRipplingPainting->state == PAINTING_ENTERED) { + if (gRipplingPainting != NULL && gRipplingPainting->oPaintingState == PAINTING_ENTERED) { // ripple when Mario enters painting if (!sPaintingEjectSoundPlayed) { play_sound(SOUND_GENERAL_PAINTING_EJECT, diff --git a/src/game/sound_init.h b/src/game/sound_init.h index 26c59e8441..25ae5d6d44 100644 --- a/src/game/sound_init.h +++ b/src/game/sound_init.h @@ -23,6 +23,8 @@ enum SoundMenuMode { SOUND_MENU_MODE_HEADSET }; +extern s8 sPaintingEjectSoundPlayed; + void reset_volume(void); void raise_background_noise(s32 a); void lower_background_noise(s32 a); From 76809f51f64e648e6fe6e194ae112e5490e94b7d Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 5 Jul 2022 19:27:20 -0700 Subject: [PATCH 02/81] Fix missing floor behind DDD painting --- levels/castle_inside/areas/3/collision.inc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/levels/castle_inside/areas/3/collision.inc.c b/levels/castle_inside/areas/3/collision.inc.c index 88f1b0711a..2d3270d2f1 100644 --- a/levels/castle_inside/areas/3/collision.inc.c +++ b/levels/castle_inside/areas/3/collision.inc.c @@ -134,20 +134,20 @@ const Collision inside_castle_seg7_area_3_collision[] = { COL_VERTEX(358, -1074, 2202), COL_VERTEX(461, -1074, 2253), COL_VERTEX(410, -1074, 2253), - COL_VERTEX(3866, -1074, 2406), - COL_VERTEX(3866, -1074, 1587), - COL_VERTEX(5530, -1074, 2406), - COL_VERTEX(5530, -1074, 1587), + COL_VERTEX(3456, -1074, 2406), + COL_VERTEX(3456, -1074, 1587), + COL_VERTEX(6605, -1074, 2406), + COL_VERTEX(6605, -1074, 1587), COL_VERTEX(3456, -1074, 2406), COL_VERTEX(3456, -1074, 1587), COL_VERTEX(-3225, -1177, -1177), COL_VERTEX(-3225, -1177, -1074), COL_VERTEX(-3225, -1177, -665), COL_VERTEX(-3225, -1177, -1043), - COL_VERTEX(5530, -255, 1587), + COL_VERTEX(6605, -255, 1587), COL_VERTEX(3533, -255, 2406), COL_VERTEX(3533, -255, 1587), - COL_VERTEX(5530, -255, 2406), + COL_VERTEX(6605, -255, 2406), COL_VERTEX(3533, -1074, 2406), COL_VERTEX(3533, -1074, 1587), COL_VERTEX(3482, -1074, 1638), From 0ff4147366e550ce83ce609e221a5540dbfab7e7 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 18 Jul 2022 21:11:23 -0700 Subject: [PATCH 03/81] Rename 'sPaintingEjectSoundPlayed' to 'gPaintingEjectSoundPlayed' --- src/game/level_update.c | 2 +- src/game/sound_init.c | 8 ++++---- src/game/sound_init.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 62d3d5105a..889e0a62e2 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -664,7 +664,7 @@ void initiate_painting_warp(void) { } } } else { - sPaintingEjectSoundPlayed = FALSE; + gPaintingEjectSoundPlayed = FALSE; } } diff --git a/src/game/sound_init.c b/src/game/sound_init.c index d85aae7a2a..f728335de0 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -76,7 +76,7 @@ static u32 sMenuSoundsExtra[] = { SOUND_ENV_ELEVATOR4, }; -s8 sPaintingEjectSoundPlayed = FALSE; +s8 gPaintingEjectSoundPlayed = FALSE; void play_menu_sounds_extra(s32 a, void *b); @@ -190,13 +190,13 @@ void play_menu_sounds(s16 soundMenuFlags) { void play_painting_eject_sound(void) { if (gRipplingPainting != NULL && gRipplingPainting->oPaintingState == PAINTING_ENTERED) { // ripple when Mario enters painting - if (!sPaintingEjectSoundPlayed) { + if (!gPaintingEjectSoundPlayed) { play_sound(SOUND_GENERAL_PAINTING_EJECT, gMarioStates[0].marioObj->header.gfx.cameraToObject); } - sPaintingEjectSoundPlayed = TRUE; + gPaintingEjectSoundPlayed = TRUE; } else { - sPaintingEjectSoundPlayed = FALSE; + gPaintingEjectSoundPlayed = FALSE; } } diff --git a/src/game/sound_init.h b/src/game/sound_init.h index 25ae5d6d44..f12ecf748f 100644 --- a/src/game/sound_init.h +++ b/src/game/sound_init.h @@ -23,7 +23,7 @@ enum SoundMenuMode { SOUND_MENU_MODE_HEADSET }; -extern s8 sPaintingEjectSoundPlayed; +extern s8 gPaintingEjectSoundPlayed; void reset_volume(void); void raise_background_noise(s32 a); From 786a569ed758bb16c1a81f36bece4ec37e9b60fe Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 18 Jul 2022 21:12:09 -0700 Subject: [PATCH 04/81] Revert formatting change in 'cutscene_exit_painting' --- src/game/camera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/camera.c b/src/game/camera.c index 954e143f75..809bfde700 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9705,7 +9705,7 @@ void cutscene_exit_painting(struct Camera *c) { #ifdef ENABLE_VANILLA_CAM_PROCESSING //! Hardcoded position. TTM's painting is close to an opposite wall, so just fix the pos. if (gPrevLevel == LEVEL_TTM) { - vec3f_set(c->pos, -296.0f, 1261.0f, 3521.0f); + vec3f_set(c->pos, -296.f, 1261.f, 3521.f); } #endif From d755fb4931b3e4a201c4e3c0a1729aa448e5378a Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 18 Jul 2022 21:16:05 -0700 Subject: [PATCH 05/81] Make normalize_component return s8 instead of casting --- src/game/paintings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 2407bb972e..0a4892be6d 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -391,11 +391,11 @@ void painting_calculate_triangle_normals(PaintingData *mesh, PaintingData numVtx * Rounds a floating-point component of a normal vector to an s8 by multiplying it by 127 or 128 and * rounding away from 0. */ -s32 normalize_component(f32 comp) { +s8 normalize_component(f32 comp) { if (comp > 0.0f) { - return (s8)((comp * 127.0f) + 0.5f); // round up + return ((comp * 127.0f) + 0.5f); // round up } else if (comp < 0.0f) { - return (s8)((comp * 128.0f) - 0.5f); // round down + return ((comp * 128.0f) - 0.5f); // round down } else { return 0; // don't round 0 } From 57d7529bcef0b9fcdfa9542f73047b9f50202cde Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 9 Aug 2022 14:53:06 -0700 Subject: [PATCH 06/81] Allow paintings to use 32 vertex buffer + optimization + formatting --- bin/segment2.c | 8 + levels/castle_inside/painting.inc.c | 152 +++++++------ levels/hmc/areas/1/painting.inc.c | 3 +- levels/ttm/areas/1/painting.inc.c | 8 +- src/game/paintings.c | 336 ++++++++++++++++------------ src/game/paintings.h | 99 ++++---- 6 files changed, 333 insertions(+), 273 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 203109c73c..b9bac43b10 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2873,9 +2873,17 @@ const Gfx dl_paintings_env_mapped_end[] = { // 0x02014A30 - 0x02014A60 const Gfx dl_paintings_draw_ripples[] = { +#ifdef F3DEX_GBI_2 + gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), + gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), + gsSP2Triangles(12, 13, 14, 0x0, 15, 16, 17, 0x0), + gsSP2Triangles(18, 19, 20, 0x0, 21, 22, 23, 0x0), + gsSP2Triangles(24, 25, 26, 0x0, 27, 28, 29, 0x0), +#else gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), gsSP1Triangle( 12, 13, 14, 0x0), +#endif gsSPEndDisplayList(), }; diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index c111fe22c0..09953d99b9 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -319,7 +319,6 @@ static const PaintingData inside_castle_seg7_painting_texture_map_bottom_07021AE 73, 71, 68, }; - // 0x07021FFC - 0x07022516 static const PaintingData inside_castle_seg7_painting_texture_map_top_07021FFC[] = { 85, // num mappings @@ -548,7 +547,6 @@ static const PaintingData inside_castle_seg7_painting_texture_map_top_07021FFC[] 72, 70, 67, }; - // 0x07022518 static const PaintingData *const inside_castle_seg7_painting_texture_maps_07022518[] = { inside_castle_seg7_painting_texture_map_bottom_07021AE0, @@ -625,42 +623,42 @@ static const PaintingData inside_castle_seg7_painting_env_map_texture_map_070226 46, 4050, -1768, 47, 5070, -1768, 48, 3030, -1768, - 49, 6100, 684, - 50, 6100, 990, - 51, 5582, 990, - 52, 5582, -236, - 53, 6100, 70, - 54, 5070, 684, - 55, 5582, 378, - 56, 4560, 990, - 57, 5070, 990, - 58, 4560, -236, - 59, 5070, 70, - 60, 5070, -542, - 61, 4050, 684, - 62, 4560, 378, - 63, 3540, 990, - 64, 4050, 990, - 65, 4050, 70, - 66, 3540, -236, - 67, 4050, -542, - 68, 3030, 684, - 69, 3540, 378, - 70, 2520, 990, - 71, 3030, 990, - 72, 2520, -236, - 73, 3030, 70, - 74, 3030, -542, - 75, 6100, -542, + 49, 6100, 684, + 50, 6100, 990, + 51, 5582, 990, + 52, 5582, -236, + 53, 6100, 70, + 54, 5070, 684, + 55, 5582, 378, + 56, 4560, 990, + 57, 5070, 990, + 58, 4560, -236, + 59, 5070, 70, + 60, 5070, -542, + 61, 4050, 684, + 62, 4560, 378, + 63, 3540, 990, + 64, 4050, 990, + 65, 4050, 70, + 66, 3540, -236, + 67, 4050, -542, + 68, 3030, 684, + 69, 3540, 378, + 70, 2520, 990, + 71, 3030, 990, + 72, 2520, -236, + 73, 3030, 70, + 74, 3030, -542, + 75, 6100, -542, 76, 5582, -1462, 77, 6100, -1154, - 78, 5582, -848, + 78, 5582, -848, 79, 4560, -1462, 80, 5070, -1154, - 81, 4560, -848, + 81, 4560, -848, 82, 3540, -1462, 83, 4050, -1154, - 84, 3540, -848, + 84, 3540, -848, 85, 2520, -1462, 86, 3030, -1154, 87, 2010, -4832, @@ -695,28 +693,28 @@ static const PaintingData inside_castle_seg7_painting_env_map_texture_map_070226 116, 2010, -1768, 117, 0, -1768, 118, 478, -1462, - 119, 2010, 684, - 120, 2520, 378, - 121, 2010, 990, - 122, 1498, 990, - 123, 2010, -542, - 124, 2010, 70, - 125, 1498, -236, - 126, 988, 684, - 127, 1498, 378, - 128, 988, 990, - 129, 478, 990, - 130, 478, -236, - 131, 988, 70, - 132, 988, -542, - 133, 0, 684, - 134, 478, 378, - 135, 0, -542, - 136, 2520, -848, + 119, 2010, 684, + 120, 2520, 378, + 121, 2010, 990, + 122, 1498, 990, + 123, 2010, -542, + 124, 2010, 70, + 125, 1498, -236, + 126, 988, 684, + 127, 1498, 378, + 128, 988, 990, + 129, 478, 990, + 130, 478, -236, + 131, 988, 70, + 132, 988, -542, + 133, 0, 684, + 134, 478, 378, + 135, 0, -542, + 136, 2520, -848, 137, 2010, -1154, - 138, 1498, -848, + 138, 1498, -848, 139, 988, -1154, - 140, 478, -848, + 140, 478, -848, 141, 4050, -5142, 142, 6100, -2074, 143, 6100, -1768, @@ -731,8 +729,8 @@ static const PaintingData inside_castle_seg7_painting_env_map_texture_map_070226 152, 0, -2994, 153, 0, -2074, 154, 0, -1154, - 155, 0, 70, - 156, 0, 990, + 155, 0, 70, + 156, 0, 990, // inside_castle_seg7_painting_triangles_07022A10: 264, // num groups @@ -1004,7 +1002,6 @@ static const PaintingData inside_castle_seg7_painting_env_map_texture_map_070226 117, 154, 118, }; - // 0x07023044 - 0x07023048 static const PaintingData *const inside_castle_seg7_painting_env_map_texture_maps_07023044[] = { inside_castle_seg7_painting_env_map_texture_map_07022660, @@ -1310,7 +1307,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = // 0x07023620 - 0x07023698 const struct Painting bob_painting = { /* id */ PAINTING_ID_CASTLE_BOB, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1324,13 +1321,14 @@ const struct Painting bob_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023698 - 0x07023710 const struct Painting ccm_painting = { /* id */ PAINTING_ID_CASTLE_CCM, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1344,13 +1342,14 @@ const struct Painting ccm_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023710 - 0x07023788 const struct Painting wf_painting = { /* id */ PAINTING_ID_CASTLE_WF, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1364,13 +1363,14 @@ const struct Painting wf_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023788 - 0x07023800 const struct Painting jrb_painting = { /* id */ PAINTING_ID_CASTLE_JRB, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1384,13 +1384,14 @@ const struct Painting jrb_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023800 - 0x07023878 const struct Painting lll_painting = { /* id */ PAINTING_ID_CASTLE_LLL, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1404,13 +1405,14 @@ const struct Painting lll_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023878 - 0x070238F0 const struct Painting ssl_painting = { /* id */ PAINTING_ID_CASTLE_SSL, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1424,13 +1426,14 @@ const struct Painting ssl_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x070238F0 - 0x07023968 const struct Painting hmc_painting = { /* id */ PAINTING_ID_CASTLE_HMC, - /* Image Count */ 0x01, + /* Image Count */ 1, /* Texture Type */ PAINTING_ENV_MAP, /* passive entry */ /* Ripple Magnitude */ 10.0f, 30.0f, @@ -1444,13 +1447,14 @@ const struct Painting hmc_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 768.0f, 768.0f, }; // 0x07023968 - 0x070239E0 const struct Painting ddd_painting = { /* id */ PAINTING_ID_CASTLE_DDD, - /* Image Count */ 0x01, + /* Image Count */ 1, /* Texture Type */ PAINTING_ENV_MAP, /* passive entry */ /* Ripple Magnitude */ 10.0f, 30.0f, @@ -1464,13 +1468,14 @@ const struct Painting ddd_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xB4, + /* Unused*/ 0, /* Size */ 819.2f, 819.2f, }; // 0x070239E0 - 0x07023A58 const struct Painting wdw_painting = { /* id */ PAINTING_ID_CASTLE_WDW, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1484,13 +1489,14 @@ const struct Painting wdw_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023A58 - 0x07023AD0 const struct Painting thi_tiny_painting = { /* id */ PAINTING_ID_CASTLE_THI_TINY, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1504,13 +1510,14 @@ const struct Painting thi_tiny_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 393.216f, 393.216f, }; // 0x07023AD0 - 0x07023B48 const struct Painting ttm_painting = { /* id */ PAINTING_ID_CASTLE_TTM, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1524,13 +1531,14 @@ const struct Painting ttm_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 256.0f, 256.0f, }; // 0x07023B48 - 0x07023BC0 const struct Painting ttc_painting = { /* id */ PAINTING_ID_CASTLE_TTC, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1544,13 +1552,14 @@ const struct Painting ttc_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 409.6f, 409.6f, }; // 0x07023BC0 - 0x07023C38 const struct Painting sl_painting = { /* id */ PAINTING_ID_CASTLE_SL, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -1564,13 +1573,14 @@ const struct Painting sl_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 716.8f, 716.8f, }; // 0x07023C38 - 0x07023CB0 const struct Painting thi_huge_painting = { /* id */ PAINTING_ID_CASTLE_THI_HUGE, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 40.0f, 160.0f, @@ -1584,12 +1594,13 @@ const struct Painting thi_huge_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 1638.4f, 1638.4f, }; const struct Painting rr_painting = { /* id */ PAINTING_ID_CASTLE_THI_HUGE, - /* Image Count */ 0x00, + /* Image Count */ 0, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 40.0f, 160.0f, @@ -1603,5 +1614,6 @@ const struct Painting rr_painting = { /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0x00, + /* Unused*/ 0, /* Size */ 204.8f, 204.8f, }; diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 3693ab4616..095c140af2 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -476,7 +476,7 @@ const Texture *const hmc_seg7_painting_textures_cotmc[] = { // 0x0702551C (PaintingData) const struct Painting cotmc_painting = { /* id */ PAINTING_ID_HMC_COTMC, - /* Image Count */ 0x01, + /* Image Count */ 1, /* Texture Type */ PAINTING_ENV_MAP, /* passive entry */ /* Ripple Magnitude */ 10.0f, 30.0f, @@ -490,5 +490,6 @@ const struct Painting cotmc_painting = { /* Ripple DList */ hmc_seg7_painting_dl_cotmc_normal_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 723.968018f, 723.968018f, }; diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index 1912793d9c..bc6b6566b3 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -283,7 +283,6 @@ static const PaintingData ttm_seg7_painting_texture_map_bottom_07012450[] = { 73, 71, 68, }; - // 0x0701296C - 0x07012E84 static const PaintingData ttm_seg7_painting_top_0701296C[] = { 85, // num mappings @@ -512,16 +511,12 @@ static const PaintingData ttm_seg7_painting_top_0701296C[] = { 72, 70, 67, }; - // 0x07012E88 static const PaintingData *const ttm_seg7_painting_texture_maps_07012E88[] = { ttm_seg7_painting_texture_map_bottom_07012450, ttm_seg7_painting_top_0701296C, }; -UNUSED static const u64 ttm_unused_0 = 0x0; - - // 0x07012E98 - 0x07012EF8 static const Gfx ttm_seg7_painting_dl_slide_normal[] = { gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_begin), @@ -547,7 +542,7 @@ ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { // 0x07012F00 (PaintingData) const struct Painting ttm_slide_painting = { /* id */ PAINTING_ID_TTM_SLIDE, - /* Image Count */ 0x02, + /* Image Count */ 2, /* Texture Type */ PAINTING_IMAGE, /* passive entry */ /* Ripple Magnitude */ 20.0f, 80.0f, @@ -561,5 +556,6 @@ const struct Painting ttm_slide_painting = { /* Ripple DList */ ttm_seg7_painting_dl_slide_normal_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, + /* Unused*/ 0, /* Size */ 460.8f, 460.8f, }; diff --git a/src/game/paintings.c b/src/game/paintings.c index 0a4892be6d..b6e9bc9426 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -84,43 +84,55 @@ struct Object *gRipplingPainting = NULL; */ struct Object *gEnteredPainting = NULL; -// HMC painting group +/** + * HMC painting group + */ struct Painting *sHmcPaintings[] = { - /*0x0*/ &cotmc_painting, + /*Painting ID */ + /*PAINTING_ID_HMC_COTMC */ &cotmc_painting, NULL, }; -// Inside Castle painting group +/** + * Inside Castle painting group + */ struct Painting *sInsideCastlePaintings[] = { - /*0x0*/ &bob_painting, - /*0x1*/ &ccm_painting, - /*0x2*/ &wf_painting, - /*0x3*/ &jrb_painting, - /*0x4*/ &lll_painting, - /*0x5*/ &ssl_painting, - /*0x6*/ &hmc_painting, - /*0x7*/ &ddd_painting, - /*0x8*/ &wdw_painting, - /*0x9*/ &thi_tiny_painting, - /*0xA*/ &ttm_painting, - /*0xB*/ &ttc_painting, - /*0xC*/ &sl_painting, - /*0xD*/ &thi_huge_painting, - /*0xE*/ &rr_painting, + /*Painting ID */ + /*PAINTING_ID_CASTLE_BOB */ &bob_painting, + /*PAINTING_ID_CASTLE_CCM */ &ccm_painting, + /*PAINTING_ID_CASTLE_WF */ &wf_painting, + /*PAINTING_ID_CASTLE_JRB */ &jrb_painting, + /*PAINTING_ID_CASTLE_LLL */ &lll_painting, + /*PAINTING_ID_CASTLE_SSL */ &ssl_painting, + /*PAINTING_ID_CASTLE_HMC */ &hmc_painting, + /*PAINTING_ID_CASTLE_DDD */ &ddd_painting, + /*PAINTING_ID_CASTLE_WDW */ &wdw_painting, + /*PAINTING_ID_CASTLE_THI_TINY */ &thi_tiny_painting, + /*PAINTING_ID_CASTLE_TTM */ &ttm_painting, + /*PAINTING_ID_CASTLE_TTC */ &ttc_painting, + /*PAINTING_ID_CASTLE_SL */ &sl_painting, + /*PAINTING_ID_CASTLE_THI_HUGE */ &thi_huge_painting, + /*PAINTING_ID_CASTLE_RR */ &rr_painting, NULL, }; -// TTM painting group +/** + * TTM painting group + */ struct Painting *sTtmPaintings[] = { - /*0x0*/ &ttm_slide_painting, + /*Painting ID */ + /*PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, NULL, }; -// Array of all painting groups +/** + * Array of all painting groups + */ struct Painting **sPaintingGroups[] = { - /*0x0*/ sHmcPaintings, - /*0x1*/ sInsideCastlePaintings, - /*0x2*/ sTtmPaintings, + /*Group ID */ + /*PAINTING_GROUP_HMC */ sHmcPaintings, + /*PAINTING_GROUP_INSIDE_CASTLE */ sInsideCastlePaintings, + /*PAINTING_GROUP_TTM */ sTtmPaintings, }; /** @@ -150,7 +162,7 @@ UNUSED s32 get_painting_group(void) { void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTimer) { struct Painting *painting = obj->oPaintingPtr; - // use a different set of variables depending on the state + // Use a different set of variables depending on the state switch (state) { case PAINTING_RIPPLE: obj->oPaintingCurrRippleMag = painting->passiveRippleMag; @@ -169,7 +181,7 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTime obj->oPaintingState = state; - // Set the ripple position + // Set the ripple position. if (centerRipples) { obj->oPaintingRippleX = (painting->sizeX * 0.5f); obj->oPaintingRippleY = (painting->sizeY * 0.5f); @@ -178,7 +190,7 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTime obj->oPaintingRippleY = obj->oPaintingLocalMarioPosY; } - // Set Mario's Y position for the WDW water level + // Set Mario's Y position for the WDW water level. gPaintingMarioYEntry = gMarioObject->oPosY; if (resetTimer) { @@ -189,9 +201,9 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTime } /** - * Check for Mario entering one of the special floors associated with the painting. + * Check for Mario entering the painting. */ -void painting_update_floors(struct Object *obj) { +void painting_update_mario_pos(struct Object *obj) { s8 rippleFlags = RIPPLE_FLAGS_NONE; Vec3f marioWorldPos; @@ -225,11 +237,11 @@ void painting_update_floors(struct Object *obj) { } s8 lastFlags = obj->oPaintingCurrFlags; - // at most 1 of these will be nonzero + // At most 1 of these will be nonzero. obj->oPaintingCurrFlags = rippleFlags; // changedFlags is true if currFlags is true and lastFlags is false - // (Mario just entered the floor on this frame) + // (Mario just entered the floor on this frame). obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); obj->oPaintingLocalMarioPosX = marioLocalPos[0]; @@ -248,21 +260,22 @@ void painting_update_ripple_state(struct Painting *painting) { if (obj->oPaintingUpdateCounter != obj->oLastPaintingUpdateCounter) { obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; - if (obj->oPaintingRippleTimer >= (S16_MAX - 1)) { + // Reset the timer to 0 if it overflows. + if (obj->oPaintingRippleTimer < 0) { obj->oPaintingRippleTimer = 0; } obj->oPaintingRippleTimer++; } if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - // if the painting is barely rippling, make it stop rippling + // If the painting is barely rippling, make it stop rippling. if (obj->oPaintingCurrRippleMag <= 1.0f) { obj->oPaintingState = PAINTING_IDLE; gRipplingPainting = NULL; } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - // if the painting is doing the entry ripple but the ripples are as small as those from the - // passive ripple, make it do a passive ripple + // If the painting is doing the entry ripple but the ripples are as small as those from the + // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. if ((obj->oPaintingState == PAINTING_ENTERED) && (obj->oPaintingCurrRippleMag <= painting->passiveRippleMag)) { @@ -296,7 +309,7 @@ void painting_update_ripple_state(struct Painting *painting) { */ void painting_generate_mesh(struct Painting *painting, PaintingData *mesh, PaintingData numTris) { struct Object *obj = gCurGraphNodeObjectNode; - s32 i, tri; + PaintingData i, tri; gPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(struct PaintingMeshVertex))); @@ -311,7 +324,7 @@ void painting_generate_mesh(struct Painting *painting, PaintingData *mesh, Paint /// How far the ripple has spread. f32 rippleTimer = obj->oPaintingRippleTimer; - /// X and Y ripple origin. + /// X and Y of the ripple origin. f32 rippleX = obj->oPaintingRippleX; f32 rippleY = obj->oPaintingRippleY; @@ -369,38 +382,25 @@ void painting_generate_mesh(struct Painting *painting, PaintingData *mesh, Paint * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ void painting_calculate_triangle_normals(PaintingData *mesh, PaintingData numVtx, PaintingData numTris) { - s16 i; + PaintingData i; Vec3s v; Vec3f vp0, vp1, vp2; gPaintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); for (i = 0; i < numTris; i++) { - PaintingData tri = ((numVtx * 3) + (i * 3) + 2); // Add 2 because of the 2 length entries preceding the list + // Add 2 because of the 2 length entries preceding the list. + PaintingData tri = ((numVtx * 3) + (i * 3) + 2); vec3s_copy(v, &mesh[tri]); vec3s_to_vec3f(vp0, gPaintingMesh[v[0]].pos); vec3s_to_vec3f(vp1, gPaintingMesh[v[1]].pos); vec3s_to_vec3f(vp2, gPaintingMesh[v[2]].pos); - // Cross product to find each triangle's normal vector + // Cross product to find each triangle's normal vector. find_vector_perpendicular_to_plane(gPaintingTriNorms[i], vp0, vp1, vp2); } } -/** - * Rounds a floating-point component of a normal vector to an s8 by multiplying it by 127 or 128 and - * rounding away from 0. - */ -s8 normalize_component(f32 comp) { - if (comp > 0.0f) { - return ((comp * 127.0f) + 0.5f); // round up - } else if (comp < 0.0f) { - return ((comp * 128.0f) - 0.5f); // round down - } else { - return 0; // don't round 0 - } -} - /** * Approximates the painting mesh's vertex normals by averaging the normals of all triangles sharing a * vertex. Used for Gouraud lighting. @@ -425,7 +425,7 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu for (i = 0; i < numVtx; i++) { Vec3f n = { 0.0f, 0.0f, 0.0f }; - // The first number of each entry is the number of adjacent tris + // The first number of each entry is the number of adjacent tris. neighbors = neighborTris[entry]; for (j = 0; j < neighbors; j++) { tri = neighborTris[entry + j + 1]; @@ -434,21 +434,27 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu // Move to the next vertex's entry entry += (neighbors + 1); - // average the surface normals from each neighboring tri + // Average the surface normals from each neighboring tri. vec3_div_val(n, neighbors); f32 nlen = vec3_sumsq(n); if (FLT_IS_NONZERO(nlen)) { - nlen = sqrtf(nlen); - gPaintingMesh[i].norm[0] = normalize_component(n[0] / nlen); - gPaintingMesh[i].norm[1] = normalize_component(n[1] / nlen); - gPaintingMesh[i].norm[2] = normalize_component(n[2] / nlen); + nlen = (127.0f / sqrtf(nlen)); + vec3_prod_val(gPaintingMesh[i].norm, n, nlen); } else { vec3_zero(gPaintingMesh[i].norm); } } } +#ifdef F3DEX_GBI_2 + #define VTX_BUF_MAX 32 +#else + #define VTX_BUF_MAX 16 +#endif +#define TRI_PER_DL (VTX_BUF_MAX / 3) // 5 | 10 +#define VTX_PER_DL (TRI_PER_DL * 3) // 15 | 30 + /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, * using 'textureMap'. @@ -457,86 +463,111 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu * painting. */ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, PaintingData *textureMap, PaintingData mapVerts, PaintingData mapTris, Alpha alpha) { + struct PaintingMeshVertex *mesh = NULL; PaintingData group; + PaintingData groupIndex; PaintingData map; PaintingData triGroup; PaintingData mapping; PaintingData meshVtx; PaintingData tx, ty; - // We can fit 15 (16 / 3) vertices in the RSP's vertex buffer. - // Group triangles by 5, with one remainder group. - PaintingData triGroups = (mapTris / 5); - PaintingData remGroupTris = (mapTris % 5); + // We can fit VTX_PER_DL vertices in the RSP's vertex buffer. + // Group triangles by TRI_PER_DL, with one remainder group. + PaintingData triGroups = (mapTris / TRI_PER_DL); + PaintingData remGroupTris = (mapTris % TRI_PER_DL); PaintingData numVtx = (mapTris * 3); - PaintingData commands = ((triGroups * 2) + remGroupTris + 7); Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); + u32 commands = ( + /*gLoadBlockTexture*/ 5 + + (triGroups * ( + /*gSPVertex*/ 1 + + /*gSPDisplayList*/ 1 + )) + + /*gSPVertex*/ 1 + + (remGroupTris * ( + /*gSP1Triangle*/ 1 + )) + + /*gSPEndDisplayList*/ 1 + ); Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); - // Draw the groups of 5 first + // Draw the groups of TRI_PER_DL first. for (group = 0; group < triGroups; group++) { + // The index of the first vertex in the group. + groupIndex = (group * VTX_PER_DL); + // The triangle groups are the second part of the texture map. - // Each group is a list of 15 mappings - triGroup = ((mapVerts * 3) + (group * 15) + 2); - - for (map = 0; map < 15; map++) { - // The mapping is just an index into the earlier part of the textureMap - // Some mappings are repeated, for example, when multiple triangles share a vertex - mapping = textureMap[triGroup + map]; - - // The first entry is the ID of the vertex in the mesh - meshVtx = textureMap[(mapping * 3) + 1]; - - // The next two are the texture coordinates for that vertex - tx = textureMap[(mapping * 3) + 2]; - ty = textureMap[(mapping * 3) + 3]; - - // Map the texture and place it in the verts array - make_vertex(verts, ((group * 15) + map), gPaintingMesh[meshVtx].pos[0], - gPaintingMesh[meshVtx].pos[1], - gPaintingMesh[meshVtx].pos[2], - tx, ty, - gPaintingMesh[meshVtx].norm[0], - gPaintingMesh[meshVtx].norm[1], - gPaintingMesh[meshVtx].norm[2], - alpha); + // Each group is a list of VTX_PER_DL mappings. + triGroup = ((mapVerts * 3) + groupIndex + 2); + + // Vertices within the group + for (map = 0; map < VTX_PER_DL; map++) { + // The mapping is just an index into the earlier part of the textureMap. + // Some mappings are repeated, for example, when multiple triangles share a vertex. + mapping = (textureMap[triGroup + map] * 3); + + // The first entry is the ID of the vertex in the mesh. + meshVtx = textureMap[mapping + 1]; + // The next two are the texture coordinates for that vertex. + tx = textureMap[mapping + 2]; + ty = textureMap[mapping + 3]; + + // Get a pointer to the current mesh. + mesh = &gPaintingMesh[meshVtx]; + + // Map the texture and place it in the verts array. + make_vertex(verts, (groupIndex + map), + mesh->pos[0], + mesh->pos[1], + mesh->pos[2], + tx, ty, + mesh->norm[0], + mesh->norm[1], + mesh->norm[2], + alpha); } - // Load the vertices and draw the 5 triangles - gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (group * 15)), 15, 0); + // Load the vertices and draw the TRI_PER_DL triangles. + gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + groupIndex), VTX_PER_DL, 0); gSPDisplayList(gfx++, dl_paintings_draw_ripples); } - // One group left with < 5 triangles - triGroup = ((mapVerts * 3) + (triGroups * 15) + 2); + // One group left with < TRI_PER_DL triangles. + triGroup = ((mapVerts * 3) + (triGroups * VTX_PER_DL) + 2); - // Map the texture to the triangles + // Map the texture to the triangles. for (map = 0; map < (remGroupTris * 3); map++) { - mapping = textureMap[triGroup + map]; - meshVtx = textureMap[(mapping * 3) + 1]; - tx = textureMap[(mapping * 3) + 2]; - ty = textureMap[(mapping * 3) + 3]; - make_vertex(verts, ((triGroups * 15) + map), gPaintingMesh[meshVtx].pos[0], - gPaintingMesh[meshVtx].pos[1], - gPaintingMesh[meshVtx].pos[2], - tx, ty, - gPaintingMesh[meshVtx].norm[0], - gPaintingMesh[meshVtx].norm[1], - gPaintingMesh[meshVtx].norm[2], - alpha); + mapping = (textureMap[triGroup + map] * 3); + meshVtx = textureMap[mapping + 1]; + tx = textureMap[mapping + 2]; + ty = textureMap[mapping + 3]; + + mesh = &gPaintingMesh[meshVtx]; + make_vertex(verts, ((triGroups * VTX_PER_DL) + map), + mesh->pos[0], + mesh->pos[1], + mesh->pos[2], + tx, ty, + mesh->norm[0], + mesh->norm[1], + mesh->norm[2], + alpha); } - // Draw the triangles individually - gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (triGroups * 15)), (remGroupTris * 3), 0); + // Draw the remaining triangles individually. + gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (triGroups * VTX_PER_DL)), (remGroupTris * 3), 0); - for (group = 0; group < remGroupTris; group++) { - gSP1Triangle(gfx++, ((group * 3) + 0), - ((group * 3) + 1), - ((group * 3) + 2), 0); + for (group = 0; group < (remGroupTris * 3); group += 3) { + gSP1Triangle(gfx++, + (group + 0), + (group + 1), + (group + 2), + 0x0); } gSPEndDisplayList(gfx); @@ -544,6 +575,10 @@ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, Pa return dlist; } +#undef VTX_BUF_MAX +#undef TRI_PER_DL +#undef VTX_PER_DL + /** * Orient the painting mesh for rendering. */ @@ -570,7 +605,7 @@ Gfx *painting_model_view_transform(struct Painting *painting) { * Ripple a painting that has 1 or more images that need to be mapped */ Gfx *painting_ripple_image(struct Painting *painting) { - s16 i; + PaintingData i; PaintingData meshVerts; PaintingData meshTris; PaintingData *textureMap; @@ -590,7 +625,7 @@ Gfx *painting_ripple_image(struct Painting *painting) { gSPDisplayList(gfx++, dl_paintings_rippling_begin); gSPDisplayList(gfx++, painting->rippleDisplayList); - // Map each image to the mesh's vertices + // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { textureMap = segmented_to_virtual(textureMaps[i]); meshVerts = textureMap[0]; @@ -612,6 +647,9 @@ Gfx *painting_ripple_image(struct Painting *painting) { * Ripple a painting that has 1 "environment map" texture. */ Gfx *painting_ripple_env_mapped(struct Painting *painting) { + PaintingData meshVerts; + PaintingData meshTris; + PaintingData *textureMap; PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; PaintingData **textureMaps = segmented_to_virtual(painting->textureMaps); @@ -627,10 +665,10 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting) { gSPDisplayList(gfx++, dl_paintings_env_mapped_begin); gSPDisplayList(gfx++, painting->rippleDisplayList); - // Map the image to the mesh's vertices - PaintingData *textureMap = segmented_to_virtual(textureMaps[0]); - PaintingData meshVerts = textureMap[0]; - PaintingData meshTris = textureMap[(meshVerts * 3) + 1]; + // Map the image to the mesh's vertices. + textureMap = segmented_to_virtual(textureMaps[0]); + meshVerts = textureMap[0]; + meshTris = textureMap[(meshVerts * 3) + 1]; gSPDisplayList(gfx++, render_painting(tArray[0], tWidth, tHeight, textureMap, meshVerts, meshTris, painting->alpha)); @@ -740,13 +778,13 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) obj->oPosX = backPos; return; #endif - // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected + // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected. u32 bowsersSubBeaten = (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1); - // Get the other save file flags and check whether DDD has already moved back + // Get the other save file flags and check whether DDD has already moved back. u32 dddBack = (save_file_get_flags() & SAVE_FLAG_DDD_MOVED_BACK); if (!bowsersSubBeaten && !dddBack) { - // If we haven't collected the star or moved the painting, put the painting at the front + // If we haven't collected the star or moved the painting, put the painting at the front. obj->oPosX = frontPos; } else if (bowsersSubBeaten && !dddBack) { // If we've collected the star but not moved the painting back, @@ -788,28 +826,28 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } if (callContext != GEO_CONTEXT_RENDER) { - // Reset the update counter + // Reset the update counter. obj->oLastPaintingUpdateCounter = (gAreaUpdateCounter - 1); obj->oPaintingUpdateCounter = gAreaUpdateCounter; reset_painting(obj); } else if (callContext == GEO_CONTEXT_RENDER) { - // Reset the update counter + // Reset the update counter. obj->oLastPaintingUpdateCounter = obj->oPaintingUpdateCounter; obj->oPaintingUpdateCounter = gAreaUpdateCounter; #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) - // Update the ddd painting before drawing + // Update the ddd painting before drawing. if (obj->oPaintingGroup == PAINTING_GROUP_INSIDE_CASTLE && obj->oPaintingId == PAINTING_ID_CASTLE_DDD) { move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); } #endif - // Update the painting - painting_update_floors(obj); + // Update the painting info. + painting_update_mario_pos(obj); - // Draw the painting + // Draw the painting. if (painting->imageCount > 0 && painting->normalDisplayList != NULL && painting->textureMaps != NULL @@ -817,7 +855,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con && painting->textureWidth > 0 && painting->textureHeight > 0 && painting->alpha > 0) { - // Determine if the painting is opaque + // Determine whether the painting is opaque or transparent. if (painting->alpha == 0xFF) { SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); } else { @@ -833,18 +871,18 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - // Proximity painting enter ripple + // Proximity painting enter ripple. painting_state(obj, PAINTING_ENTERED, FALSE, TRUE); } else if (obj->oPaintingState != PAINTING_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - // Proximity painting wobble ripple + // Proximity painting wobble ripple. painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE); } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - // Continuous painting enter ripple + // Continuous painting enter ripple. painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); } else if (obj->oPaintingState == PAINTING_IDLE) { - // Continuous painting idle ripple + // Continuous painting idle ripple. painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE); } } @@ -862,38 +900,40 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } void bhv_painting_init(void) { + struct Object *obj = o; + // Get the painting group and id from the behavior params. - o->oPaintingGroup = GET_BPARAM1(o->oBehParams); - o->oPaintingId = GET_BPARAM2(o->oBehParams); + obj->oPaintingGroup = GET_BPARAM1(obj->oBehParams); + obj->oPaintingId = GET_BPARAM2(obj->oBehParams); // Failsafe for nonexistent painting groups. - if (o->oPaintingGroup >= PAINTING_NUM_GROUPS) { + if (obj->oPaintingGroup >= PAINTING_NUM_GROUPS) { return; } - struct Painting **paintingGroup = sPaintingGroups[o->oPaintingGroup]; - o->oPaintingPtr = segmented_to_virtual(paintingGroup[o->oPaintingId]); + struct Painting **paintingGroup = sPaintingGroups[obj->oPaintingGroup]; + obj->oPaintingPtr = segmented_to_virtual(paintingGroup[obj->oPaintingId]); Vec3f roomFloorCheckPos; - // The center of the painting with a z offset since paintings are usually between floor triangles laterally. + // The center of the painting, but with a z offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { - (o->oPaintingPtr->sizeX * 0.5f), - (o->oPaintingPtr->sizeY * 0.5f), - PAINTING_WOBBLE_DEPTH + (obj->oPaintingPtr->sizeX * 0.5f), + (obj->oPaintingPtr->sizeY * 0.5f), + PAINTING_WOBBLE_DEPTH // Distance in front of the painting to check for a room floor. }; // Get the painting object's rotation. Vec3s rotation; - vec3i_to_vec3s(rotation, &o->oFaceAngleVec); + vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); - // Set 'roomFloorCheckPos' to world space coords. - vec3f_local_pos_to_world_pos(roomFloorCheckPos, distPos, &o->oPosVec, rotation); + // Set 'roomFloorCheckPos' to the world space coords of 'distPos'. + vec3f_local_pos_to_world_pos(roomFloorCheckPos, distPos, &obj->oPosVec, rotation); // Set the object's room so that paintings only render in their room. - o->oRoom = get_room_at_pos(roomFloorCheckPos[0], - roomFloorCheckPos[1], - roomFloorCheckPos[2]); + obj->oRoom = get_room_at_pos(roomFloorCheckPos[0], + roomFloorCheckPos[1], + roomFloorCheckPos[2]); } void bhv_painting_loop(void) { diff --git a/src/game/paintings.h b/src/game/paintings.h index 52761caa98..05408f40a3 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -9,7 +9,7 @@ /// Use to properly set a GraphNodeGenerated's parameter to point to the right painting. /// Use this for both bparam1 and bparam2 for painting objects. -#define PAINTING_ID(id, grp) (id | (grp << 8)) +#define PAINTING_ID(id, grp) ((id) | ((grp) << 8)) /// The default painting side length. #define PAINTING_SIZE 614.0f @@ -28,38 +28,38 @@ // HMC painting group enum HMCPaintingIDs { - /*0x0*/ PAINTING_ID_HMC_COTMC, + /* 0*/ PAINTING_ID_HMC_COTMC, }; // Inside Castle painting group enum CastlePaintingIDs { - /*0x0*/ PAINTING_ID_CASTLE_BOB, - /*0x1*/ PAINTING_ID_CASTLE_CCM, - /*0x2*/ PAINTING_ID_CASTLE_WF, - /*0x3*/ PAINTING_ID_CASTLE_JRB, - /*0x4*/ PAINTING_ID_CASTLE_LLL, - /*0x5*/ PAINTING_ID_CASTLE_SSL, - /*0x6*/ PAINTING_ID_CASTLE_HMC, - /*0x7*/ PAINTING_ID_CASTLE_DDD, - /*0x8*/ PAINTING_ID_CASTLE_WDW, - /*0x9*/ PAINTING_ID_CASTLE_THI_TINY, - /*0xA*/ PAINTING_ID_CASTLE_TTM, - /*0xB*/ PAINTING_ID_CASTLE_TTC, - /*0xC*/ PAINTING_ID_CASTLE_SL, - /*0xD*/ PAINTING_ID_CASTLE_THI_HUGE, - /*0xE*/ PAINTING_ID_CASTLE_RR, + /* 0*/ PAINTING_ID_CASTLE_BOB, + /* 1*/ PAINTING_ID_CASTLE_CCM, + /* 2*/ PAINTING_ID_CASTLE_WF, + /* 3*/ PAINTING_ID_CASTLE_JRB, + /* 4*/ PAINTING_ID_CASTLE_LLL, + /* 5*/ PAINTING_ID_CASTLE_SSL, + /* 6*/ PAINTING_ID_CASTLE_HMC, + /* 7*/ PAINTING_ID_CASTLE_DDD, + /* 8*/ PAINTING_ID_CASTLE_WDW, + /* 9*/ PAINTING_ID_CASTLE_THI_TINY, + /*10*/ PAINTING_ID_CASTLE_TTM, + /*11*/ PAINTING_ID_CASTLE_TTC, + /*12*/ PAINTING_ID_CASTLE_SL, + /*13*/ PAINTING_ID_CASTLE_THI_HUGE, + /*14*/ PAINTING_ID_CASTLE_RR, }; // TTM painting group enum TTMPaintingIDs { - /*0x0*/ PAINTING_ID_TTM_SLIDE, + /* 0*/ PAINTING_ID_TTM_SLIDE, }; // Painting group ids enum PaintingGroups { - PAINTING_GROUP_HMC, - PAINTING_GROUP_INSIDE_CASTLE, - PAINTING_GROUP_TTM, + /* 0*/PAINTING_GROUP_HMC, + /* 1*/PAINTING_GROUP_INSIDE_CASTLE, + /* 2*/PAINTING_GROUP_TTM, PAINTING_NUM_GROUPS, PAINTING_GROUP_NULL = -1, }; @@ -80,11 +80,11 @@ enum RippleTriggers { // Painting->lastFlags, Painting->currFlags, Painting->changedFlags enum PaintingRippleFlags { // Not rippling. - RIPPLE_FLAGS_NONE = (0 << 0), // 0x00 + RIPPLE_FLAGS_NONE = 0x0, // Triggers an entry ripple. - RIPPLE_FLAG_ENTER = (1 << 0), // 0x01 + RIPPLE_FLAG_ENTER = BIT(0), // 0x01 // Triggers a passive ripple. - RIPPLE_FLAG_RIPPLE = (1 << 1), // 0x02 + RIPPLE_FLAG_RIPPLE = BIT(1), // 0x02 }; // Painting->textureType @@ -97,52 +97,55 @@ enum PaintingType { struct Painting { /// Id of the painting warp node. - PaintingData id; + /*0x00*/ PaintingData id; /// How many images should be drawn when the painting is rippling. - s8 imageCount; + /*0x02*/ s8 imageCount; /// Either PAINTING_IMAGE or PAINTING_ENV_MAP - s8 textureType; + /*0x03*/ s8 textureType; /// Controls how high the peaks of the ripple are. - f32 passiveRippleMag; - f32 entryRippleMag; + /*0x04*/ f32 passiveRippleMag; + /*0x08*/ f32 entryRippleMag; /// Multiplier that controls how fast the ripple regresses to the IDLE state. - f32 passiveRippleDecay; - f32 entryRippleDecay; + /*0x0C*/ f32 passiveRippleDecay; + /*0x10*/ f32 entryRippleDecay; /// Controls the ripple's frequency - f32 passiveRippleRate; - f32 entryRippleRate; + /*0x14*/ f32 passiveRippleRate; + /*0x18*/ f32 entryRippleRate; /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple - f32 passiveDispersionFactor; - f32 entryDispersionFactor; + /*0x1C*/ f32 passiveDispersionFactor; + /*0x20*/ f32 entryDispersionFactor; /// Display list used when the painting is normal. - const Gfx *normalDisplayList; + /*0x24*/ const Gfx *normalDisplayList; /// Data used to map the texture to the mesh - const PaintingData *const *textureMaps; + /*0x28*/ const PaintingData *const *textureMaps; // Texture data - const Texture *const *textureArray; - s16 textureWidth; - s16 textureHeight; + /*0x2C*/ const Texture *const *textureArray; + /*0x30*/ PaintingData textureWidth; + /*0x32*/ PaintingData textureHeight; /// Display list used when the painting is rippling. - const Gfx *rippleDisplayList; + /*0x34*/ const Gfx *rippleDisplayList; /// Controls when a passive ripple starts. RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. - s8 rippleTrigger; + /*0x38*/ s8 rippleTrigger; - /// The painting's transparency. Determines what layer the painting is in. - Alpha alpha; + /// The painting's transparency (0..255). Determines what layer the painting is in. + /*0x39*/ Alpha alpha; + + /// Struct padding. + /*0x3A*/ PaintingData unused; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. /// By default a painting is 614.0f x 614.0f - f32 sizeX; - f32 sizeY; -}; + /*0x3C*/ f32 sizeX; + /*0x40*/ f32 sizeY; +}; /*0x44*/ /** * Contains the position and normal of a vertex in the painting's generated mesh. @@ -150,7 +153,7 @@ struct Painting { struct PaintingMeshVertex { /*0x00*/ Vec3s pos; /*0x06*/ Vec3c norm; -}; +}; /*0x0C*/ extern struct PaintingMeshVertex *gPaintingMesh; extern Vec3f *gPaintingTriNorms; From e2c0fe02abbe6393d8df8ccfef97786bbeb9ed13 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 9 Aug 2022 15:44:34 -0700 Subject: [PATCH 07/81] Combine duplicate painting texture map data and move it to segment2 --- bin/segment2.c | 904 ++++++++++++++++++++++++++- levels/castle_inside/painting.inc.c | 916 +--------------------------- levels/hmc/areas/1/painting.inc.c | 438 ------------- levels/ttm/areas/1/painting.inc.c | 463 -------------- src/game/paintings.c | 11 +- src/game/paintings.h | 28 +- src/game/segment2.h | 6 +- 7 files changed, 924 insertions(+), 1842 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index b9bac43b10..75214870d2 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2889,7 +2889,7 @@ const Gfx dl_paintings_draw_ripples[] = { // 14A60: triangle mesh // 0x02014A60 -const s16 seg2_painting_triangle_mesh[] = { +const PaintingData seg2_painting_triangle_mesh[] = { 157, // numVtx // format: // 2D point (x, y), ripple (0 or 1) @@ -3326,7 +3326,7 @@ const s16 seg2_painting_triangle_mesh[] = { * num neighbors, neighbor0, neighbor1, ... * The nth entry corresponds to the nth vertex in seg2_painting_triangle_mesh */ -const s16 seg2_painting_mesh_neighbor_tris[] = { +const PaintingData seg2_painting_mesh_neighbor_tris[] = { 3, 1, 2, 3, 1, 1, 4, 1, 2, 4, 5, @@ -3485,3 +3485,903 @@ const s16 seg2_painting_mesh_neighbor_tris[] = { 3, 240, 242, 244, 1, 243, }; + +// 0x07021AE0 - 0x07021FFA +static const PaintingData seg2_painting_image_texture_map_bottom[] = { + 85, // num mappings + // Format: + // mesh vtx ID, texture X, texture Y + 49, 2016, 889, + 53, 2016, 685, + 55, 1843, 787, + 50, 2016, 992, + 51, 1843, 992, + 52, 1843, 583, + 75, 2016, 513, + 54, 1671, 889, + 59, 1671, 685, + 62, 1502, 787, + 56, 1502, 992, + 57, 1671, 992, + 58, 1502, 583, + 60, 1671, 513, + 61, 1330, 889, + 65, 1330, 685, + 63, 1162, 992, + 64, 1330, 992, + 66, 1162, 583, + 67, 1330, 513, + 69, 1162, 787, + 68, 989, 889, + 70, 821, 992, + 71, 989, 992, + 73, 989, 685, + 72, 821, 583, + 74, 989, 513, + 77, 2016, 308, + 78, 1843, 410, + 76, 1843, 204, + 81, 1502, 410, + 80, 1671, 308, + 47, 1671, 102, + 79, 1502, 204, + 46, 1330, 102, + 82, 1162, 204, + 83, 1330, 308, + 84, 1162, 410, + 86, 989, 308, + 85, 821, 204, + 48, 989, 102, + 25, 1502, 0, + 31, 1162, 0, + 19, 1843, 0, + 37, 821, 0, + 120, 821, 787, + 119, 649, 889, + 122, 481, 992, + 121, 649, 992, + 124, 649, 685, + 125, 481, 583, + 123, 649, 513, + 127, 481, 787, + 126, 308, 889, + 129, 140, 992, + 128, 308, 992, + 132, 308, 513, + 131, 308, 685, + 130, 140, 583, + 134, 140, 787, + 133, -32, 889, + 135, -32, 513, + 136, 821, 410, + 116, 649, 102, + 137, 649, 308, + 114, 481, 204, + 138, 481, 410, + 139, 308, 308, + 118, 140, 204, + 115, 308, 102, + 140, 140, 410, + 117, -32, 102, + 99, 481, 0, + 105, 140, 0, + 143, 2016, 102, + 145, 1330, 0, + 144, 1671, 0, + 142, 2016, 0, + 146, 989, 0, + 155, -32, 685, + 156, -32, 992, + 154, -32, 308, + 151, 308, 0, + 150, 649, 0, + 153, -32, 0, + + 132, // num groups + // Grouped by 5 + one remainder group, + // = 15 vertices per group + a few extra triangles + 13, 8, 5, + 0, 1, 2, + 3, 0, 4, + 4, 0, 2, + 5, 2, 1, + 1, 6, 5, + 7, 2, 8, + 5, 8, 2, + 2, 7, 4, + 7, 8, 9, + 10, 7, 9, + 11, 7, 10, + 7, 11, 4, + 12, 9, 8, + 8, 13, 12, + 21, 24, 45, + 14, 9, 15, + 12, 15, 9, + 9, 14, 10, + 16, 14, 20, + 17, 14, 16, + 14, 15, 20, + 14, 17, 10, + 15, 19, 18, + 18, 20, 15, + 19, 15, 12, + 20, 21, 16, + 18, 24, 20, + 21, 20, 24, + 22, 21, 45, + 23, 21, 22, + 21, 23, 16, + 24, 26, 25, + 25, 45, 24, + 26, 24, 18, + 6, 27, 28, + 5, 6, 28, + 29, 28, 27, + 27, 74, 29, + 29, 31, 28, + 13, 28, 31, + 28, 13, 5, + 36, 34, 35, + 12, 13, 30, + 13, 31, 30, + 31, 32, 33, + 32, 31, 29, + 33, 30, 31, + 33, 36, 30, + 30, 19, 12, + 19, 30, 36, + 18, 19, 37, + 19, 36, 37, + 34, 36, 33, + 35, 37, 36, + 37, 26, 18, + 35, 38, 37, + 26, 37, 38, + 25, 26, 62, + 26, 38, 62, + 38, 40, 39, + 39, 62, 38, + 40, 38, 35, + 41, 34, 33, + 33, 32, 41, + 42, 34, 75, + 34, 41, 75, + 35, 34, 42, + 32, 43, 76, + 41, 32, 76, + 43, 32, 29, + 29, 74, 43, + 43, 74, 77, + 46, 49, 52, + 42, 40, 35, + 39, 40, 44, + 40, 42, 78, + 44, 40, 78, + 25, 49, 45, + 45, 46, 22, + 46, 45, 49, + 47, 46, 52, + 48, 46, 47, + 46, 48, 22, + 58, 59, 57, + 49, 51, 50, + 50, 52, 49, + 51, 49, 25, + 50, 57, 52, + 52, 53, 47, + 53, 52, 57, + 53, 55, 47, + 54, 53, 59, + 55, 53, 54, + 53, 57, 59, + 56, 57, 50, + 57, 56, 58, + 58, 79, 59, + 59, 60, 54, + 60, 59, 79, + 60, 80, 54, + 61, 79, 58, + 62, 51, 25, + 39, 64, 62, + 51, 62, 64, + 50, 51, 66, + 51, 64, 66, + 63, 64, 39, + 64, 63, 65, + 65, 66, 64, + 66, 56, 50, + 56, 66, 67, + 65, 67, 66, + 58, 56, 70, + 56, 67, 70, + 67, 69, 68, + 68, 70, 67, + 69, 67, 65, + 70, 61, 58, + 68, 81, 70, + 61, 70, 81, + 71, 73, 84, + 71, 81, 68, + 72, 69, 65, + 65, 63, 72, + 68, 69, 73, + 69, 72, 82, + 73, 69, 82, + 44, 63, 39, + 63, 44, 83, + 72, 63, 83, + 73, 71, 68, +}; + +// 0x07021FFC - 0x07022516 +static const PaintingData seg2_painting_image_texture_map_top[] = { + 85, // num mappings + // Format: + // mesh vtx ID, texture X, texture Y + 0, 2016, 72, + 1, 2016, 0, + 2, 1843, 0, + 3, 1843, 174, + 4, 2016, 276, + 5, 1671, 72, + 6, 1671, 0, + 8, 989, 72, + 7, 989, 0, + 10, 821, 0, + 9, 1162, 0, + 11, 821, 174, + 12, 989, 276, + 13, 1162, 174, + 14, 1330, 72, + 15, 1502, 0, + 16, 1671, 276, + 17, 1502, 174, + 18, 1330, 276, + 19, 1843, 992, + 20, 2016, 889, + 22, 2016, 685, + 21, 1843, 583, + 23, 1843, 787, + 24, 1671, 889, + 25, 1502, 992, + 26, 1502, 583, + 27, 1671, 685, + 28, 1671, 481, + 30, 1502, 787, + 29, 1330, 889, + 31, 1162, 992, + 32, 1330, 481, + 33, 1162, 583, + 34, 1330, 685, + 35, 1162, 787, + 36, 989, 889, + 37, 821, 992, + 39, 821, 583, + 38, 989, 685, + 40, 989, 481, + 41, 2016, 481, + 42, 1843, 378, + 43, 1502, 378, + 44, 1162, 378, + 45, 821, 378, + 87, 649, 72, + 88, -32, 0, + 90, 140, 0, + 89, -32, 72, + 92, 308, 72, + 91, 140, 174, + 94, 481, 174, + 93, 649, 276, + 95, 481, 0, + 96, 308, 276, + 97, 821, 787, + 98, 649, 889, + 99, 481, 992, + 102, 649, 481, + 101, 649, 685, + 100, 481, 583, + 103, 481, 787, + 104, 308, 889, + 105, 140, 992, + 108, 308, 481, + 107, 308, 685, + 106, 140, 583, + 110, -32, 889, + 109, 140, 787, + 111, -32, 481, + 112, 481, 378, + 113, 140, 378, + 141, 1330, 0, + 142, 2016, 992, + 144, 1671, 992, + 145, 1330, 992, + 146, 989, 992, + 147, 649, 0, + 148, -32, 276, + 149, 308, 0, + 150, 649, 992, + 151, 308, 992, + 152, -32, 685, + 153, -32, 992, + + 132, // num groups + // Grouped by 5 + one remainder group, + // = 15 vertices per group + a few extra triangles + 10, 7, 13, + 0, 1, 2, + 3, 0, 2, + 4, 0, 3, + 5, 2, 6, + 2, 5, 3, + 7, 8, 9, + 8, 7, 10, + 11, 7, 9, + 12, 7, 11, + 7, 12, 13, + 13, 14, 10, + 14, 73, 10, + 5, 6, 15, + 5, 16, 3, + 16, 5, 17, + 17, 5, 15, + 14, 15, 73, + 15, 14, 17, + 18, 14, 13, + 14, 18, 17, + 19, 74, 20, + 19, 20, 23, + 28, 27, 22, + 21, 41, 22, + 22, 23, 21, + 20, 21, 23, + 23, 24, 19, + 22, 27, 23, + 24, 23, 27, + 19, 24, 75, + 25, 75, 24, + 25, 24, 29, + 24, 27, 29, + 26, 29, 27, + 27, 28, 26, + 31, 36, 77, + 26, 34, 29, + 29, 30, 25, + 30, 29, 34, + 25, 30, 76, + 31, 76, 30, + 31, 30, 35, + 30, 34, 35, + 32, 34, 26, + 33, 35, 34, + 34, 32, 33, + 35, 36, 31, + 33, 39, 35, + 36, 35, 39, + 37, 36, 56, + 36, 39, 56, + 37, 77, 36, + 28, 16, 43, + 38, 56, 39, + 39, 40, 38, + 40, 39, 33, + 22, 41, 42, + 41, 4, 42, + 3, 42, 4, + 42, 28, 22, + 28, 42, 16, + 3, 16, 42, + 26, 28, 43, + 17, 43, 16, + 43, 32, 26, + 32, 43, 18, + 17, 18, 43, + 33, 32, 44, + 32, 18, 44, + 13, 44, 18, + 13, 12, 44, + 44, 40, 33, + 40, 44, 12, + 38, 40, 45, + 40, 12, 45, + 11, 45, 12, + 9, 46, 11, + 46, 9, 78, + 47, 49, 48, + 48, 49, 51, + 49, 79, 51, + 50, 80, 48, + 51, 50, 48, + 57, 56, 60, + 46, 53, 11, + 52, 46, 54, + 53, 46, 52, + 46, 78, 54, + 54, 50, 52, + 50, 54, 80, + 50, 55, 52, + 55, 50, 51, + 38, 60, 56, + 56, 57, 37, + 58, 57, 62, + 57, 60, 62, + 58, 81, 57, + 37, 57, 81, + 59, 60, 38, + 60, 59, 61, + 61, 62, 60, + 62, 63, 58, + 63, 62, 66, + 61, 66, 62, + 63, 66, 69, + 58, 63, 82, + 64, 82, 63, + 64, 63, 69, + 45, 59, 38, + 65, 66, 61, + 66, 65, 67, + 67, 69, 66, + 68, 69, 83, + 69, 68, 64, + 67, 83, 69, + 64, 68, 84, + 70, 83, 67, + 11, 53, 45, + 59, 45, 53, + 59, 53, 71, + 61, 59, 71, + 52, 71, 53, + 52, 55, 71, + 65, 71, 55, + 71, 65, 61, + 65, 55, 72, + 67, 65, 72, + 51, 72, 55, + 70, 72, 79, + 51, 79, 72, + 72, 70, 67, +}; + +// 0x07022518 +const PaintingData *const seg2_painting_image_texture_maps[] = { + seg2_painting_image_texture_map_bottom, + seg2_painting_image_texture_map_top, +}; + +// 0x07022660 - 0x07023042 +static const PaintingData seg2_painting_env_map_texture_map[] = { + 157, // num mappings + // Format: + // mesh vtx ID, texture X, texture Y + 0, 6100, -4832, + 1, 6100, -5142, + 2, 5582, -5142, + 3, 5582, -4526, + 4, 6100, -4218, + 5, 5070, -4832, + 6, 5070, -5142, + 7, 3030, -5142, + 8, 3030, -4832, + 9, 3540, -5142, + 10, 2520, -5142, + 11, 2520, -4526, + 12, 3030, -4218, + 13, 3540, -4526, + 14, 4050, -4832, + 15, 4560, -5142, + 16, 5070, -4218, + 17, 4560, -4526, + 18, 4050, -4218, + 19, 5582, -2074, + 20, 6100, -2380, + 21, 5582, -3300, + 22, 6100, -2994, + 23, 5582, -2686, + 24, 5070, -2380, + 25, 4560, -2074, + 26, 4560, -3300, + 27, 5070, -2994, + 28, 5070, -3606, + 29, 4050, -2380, + 30, 4560, -2686, + 31, 3540, -2074, + 32, 4050, -3606, + 33, 3540, -3300, + 34, 4050, -2994, + 35, 3540, -2686, + 36, 3030, -2380, + 37, 2520, -2074, + 38, 3030, -2994, + 39, 2520, -3300, + 40, 3030, -3606, + 41, 6100, -3606, + 42, 5582, -3912, + 43, 4560, -3912, + 44, 3540, -3912, + 45, 2520, -3912, + 46, 4050, -1768, + 47, 5070, -1768, + 48, 3030, -1768, + 49, 6100, 684, + 50, 6100, 990, + 51, 5582, 990, + 52, 5582, -236, + 53, 6100, 70, + 54, 5070, 684, + 55, 5582, 378, + 56, 4560, 990, + 57, 5070, 990, + 58, 4560, -236, + 59, 5070, 70, + 60, 5070, -542, + 61, 4050, 684, + 62, 4560, 378, + 63, 3540, 990, + 64, 4050, 990, + 65, 4050, 70, + 66, 3540, -236, + 67, 4050, -542, + 68, 3030, 684, + 69, 3540, 378, + 70, 2520, 990, + 71, 3030, 990, + 72, 2520, -236, + 73, 3030, 70, + 74, 3030, -542, + 75, 6100, -542, + 76, 5582, -1462, + 77, 6100, -1154, + 78, 5582, -848, + 79, 4560, -1462, + 80, 5070, -1154, + 81, 4560, -848, + 82, 3540, -1462, + 83, 4050, -1154, + 84, 3540, -848, + 85, 2520, -1462, + 86, 3030, -1154, + 87, 2010, -4832, + 88, 0, -5142, + 89, 0, -4832, + 90, 478, -5142, + 91, 478, -4526, + 92, 988, -4832, + 93, 2010, -4218, + 94, 1498, -4526, + 95, 1498, -5142, + 96, 988, -4218, + 97, 2520, -2686, + 98, 2010, -2380, + 99, 1498, -2074, + 100, 1498, -3300, + 101, 2010, -2994, + 102, 2010, -3606, + 103, 1498, -2686, + 104, 988, -2380, + 105, 478, -2074, + 106, 478, -3300, + 107, 988, -2994, + 108, 988, -3606, + 109, 478, -2686, + 110, 0, -2380, + 111, 0, -3606, + 112, 1498, -3912, + 113, 478, -3912, + 114, 1498, -1462, + 115, 988, -1768, + 116, 2010, -1768, + 117, 0, -1768, + 118, 478, -1462, + 119, 2010, 684, + 120, 2520, 378, + 121, 2010, 990, + 122, 1498, 990, + 123, 2010, -542, + 124, 2010, 70, + 125, 1498, -236, + 126, 988, 684, + 127, 1498, 378, + 128, 988, 990, + 129, 478, 990, + 130, 478, -236, + 131, 988, 70, + 132, 988, -542, + 133, 0, 684, + 134, 478, 378, + 135, 0, -542, + 136, 2520, -848, + 137, 2010, -1154, + 138, 1498, -848, + 139, 988, -1154, + 140, 478, -848, + 141, 4050, -5142, + 142, 6100, -2074, + 143, 6100, -1768, + 144, 5070, -2074, + 145, 4050, -2074, + 146, 3030, -2074, + 147, 2010, -5142, + 148, 0, -4218, + 149, 988, -5142, + 150, 2010, -2074, + 151, 988, -2074, + 152, 0, -2994, + 153, 0, -2074, + 154, 0, -1154, + 155, 0, 70, + 156, 0, 990, + +// inside_castle_seg7_painting_triangles_07022A10: + 264, // num groups + // Grouped by 5 + one remainder group, + // = 15 vertices per group + a few extra triangles + 8, 12, 13, + 0, 1, 2, + 3, 0, 2, + 4, 0, 3, + 5, 2, 6, + 2, 5, 3, + 7, 8, 9, + 8, 7, 10, + 11, 8, 10, + 12, 8, 11, + 9, 8, 13, + 13, 14, 9, + 14, 141, 9, + 5, 6, 15, + 5, 16, 3, + 16, 5, 17, + 17, 5, 15, + 14, 15, 141, + 15, 14, 17, + 18, 14, 13, + 14, 18, 17, + 19, 142, 20, + 19, 20, 23, + 28, 27, 21, + 21, 23, 22, + 22, 41, 21, + 20, 22, 23, + 23, 24, 19, + 21, 27, 23, + 24, 23, 27, + 25, 144, 24, + 19, 24, 144, + 24, 27, 30, + 25, 24, 30, + 26, 30, 27, + 27, 28, 26, + 36, 38, 97, + 26, 34, 30, + 29, 30, 34, + 30, 29, 25, + 25, 29, 145, + 31, 145, 29, + 31, 29, 35, + 29, 34, 35, + 32, 34, 26, + 33, 35, 34, + 34, 32, 33, + 33, 38, 35, + 35, 36, 31, + 36, 35, 38, + 37, 36, 97, + 37, 146, 36, + 31, 36, 146, + 28, 16, 43, + 38, 40, 39, + 39, 97, 38, + 40, 38, 33, + 21, 41, 42, + 41, 4, 42, + 3, 42, 4, + 42, 28, 21, + 28, 42, 16, + 3, 16, 42, + 26, 28, 43, + 17, 43, 16, + 43, 32, 26, + 32, 43, 18, + 17, 18, 43, + 33, 32, 44, + 32, 18, 44, + 13, 44, 18, + 44, 40, 33, + 13, 12, 44, + 40, 44, 12, + 39, 40, 45, + 40, 12, 45, + 48, 31, 146, + 11, 45, 12, + 25, 47, 144, + 46, 25, 145, + 47, 19, 144, + 19, 143, 142, + 31, 46, 145, + 60, 59, 52, + 49, 53, 55, + 50, 49, 51, + 51, 49, 55, + 52, 55, 53, + 53, 75, 52, + 54, 55, 59, + 52, 59, 55, + 55, 54, 51, + 54, 59, 62, + 56, 54, 62, + 57, 54, 56, + 54, 57, 51, + 58, 62, 59, + 59, 60, 58, + 68, 71, 63, + 61, 62, 65, + 58, 65, 62, + 62, 61, 56, + 61, 65, 69, + 63, 61, 69, + 64, 61, 63, + 61, 64, 56, + 65, 67, 66, + 66, 69, 65, + 67, 65, 58, + 68, 69, 73, + 69, 68, 63, + 66, 73, 69, + 68, 73, 120, + 70, 68, 120, + 71, 68, 70, + 72, 120, 73, + 73, 74, 72, + 74, 73, 66, + 75, 77, 78, + 52, 75, 78, + 76, 78, 77, + 77, 143, 76, + 76, 80, 78, + 60, 78, 80, + 78, 60, 52, + 46, 83, 79, + 58, 60, 81, + 60, 80, 81, + 79, 81, 80, + 80, 47, 79, + 47, 80, 76, + 81, 67, 58, + 67, 81, 83, + 79, 83, 81, + 66, 67, 84, + 67, 83, 84, + 82, 84, 83, + 83, 46, 82, + 84, 74, 66, + 82, 86, 84, + 74, 84, 86, + 74, 86, 136, + 72, 74, 136, + 85, 136, 86, + 86, 48, 85, + 48, 86, 82, + 25, 46, 79, + 79, 47, 25, + 82, 46, 31, + 19, 47, 76, + 76, 143, 19, + 31, 48, 82, + 37, 48, 146, + 85, 48, 37, + 10, 87, 11, + 87, 10, 147, + 92, 95, 149, + 88, 89, 90, + 89, 148, 91, + 90, 89, 91, + 91, 92, 90, + 92, 149, 90, + 93, 87, 94, + 87, 93, 11, + 94, 87, 95, + 87, 147, 95, + 95, 92, 94, + 96, 92, 91, + 92, 96, 94, + 39, 101, 97, + 97, 98, 37, + 98, 97, 101, + 99, 98, 103, + 99, 150, 98, + 37, 98, 150, + 98, 101, 103, + 100, 103, 101, + 101, 102, 100, + 102, 101, 39, + 100, 107, 103, + 103, 104, 99, + 104, 103, 107, + 105, 104, 109, + 105, 151, 104, + 99, 104, 151, + 104, 107, 109, + 106, 109, 107, + 107, 108, 106, + 108, 107, 100, + 109, 110, 105, + 106, 152, 109, + 110, 109, 152, + 105, 110, 153, + 111, 152, 106, + 11, 93, 45, + 102, 45, 93, + 45, 102, 39, + 102, 93, 112, + 100, 102, 112, + 94, 112, 93, + 112, 108, 100, + 108, 112, 96, + 94, 96, 112, + 106, 108, 113, + 108, 96, 113, + 91, 113, 96, + 91, 148, 113, + 113, 111, 106, + 111, 113, 148, + 114, 116, 99, + 99, 115, 114, + 115, 99, 151, + 99, 116, 150, + 72, 124, 120, + 116, 37, 150, + 37, 116, 85, + 117, 105, 153, + 105, 115, 151, + 105, 117, 118, + 118, 115, 105, + 119, 120, 124, + 120, 119, 70, + 119, 124, 127, + 119, 121, 70, + 121, 119, 122, + 122, 119, 127, + 123, 124, 72, + 124, 123, 125, + 125, 127, 124, + 126, 127, 131, + 127, 126, 122, + 125, 131, 127, + 126, 131, 134, + 128, 126, 129, + 129, 126, 134, + 126, 128, 122, + 136, 123, 72, + 130, 134, 131, + 131, 132, 130, + 132, 131, 125, + 133, 134, 155, + 134, 133, 129, + 130, 155, 134, + 133, 156, 129, + 135, 155, 130, + 123, 136, 137, + 85, 137, 136, + 139, 115, 118, + 123, 137, 138, + 125, 123, 138, + 114, 138, 137, + 137, 116, 114, + 116, 137, 85, + 114, 139, 138, + 132, 138, 139, + 138, 132, 125, + 132, 139, 140, + 130, 132, 140, + 115, 139, 114, + 118, 140, 139, + 135, 140, 154, + 118, 154, 140, + 140, 135, 130, + 117, 154, 118, +}; + +// 0x07023044 - 0x07023048 +const PaintingData *const seg2_painting_env_map_texture_maps[] = { + seg2_painting_env_map_texture_map, +}; diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 09953d99b9..3f26906d98 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -91,467 +91,6 @@ static const Gfx inside_castle_seg7_painting_dl_image_ripple[] = { gsSPEndDisplayList(), }; -// 0x07021AE0 - 0x07021FFA -static const PaintingData inside_castle_seg7_painting_texture_map_bottom_07021AE0[] = { - 85, // num mappings - // Format: - // mesh vtx ID, texture X, texture Y - 49, 2016, 889, - 53, 2016, 685, - 55, 1843, 787, - 50, 2016, 992, - 51, 1843, 992, - 52, 1843, 583, - 75, 2016, 513, - 54, 1671, 889, - 59, 1671, 685, - 62, 1502, 787, - 56, 1502, 992, - 57, 1671, 992, - 58, 1502, 583, - 60, 1671, 513, - 61, 1330, 889, - 65, 1330, 685, - 63, 1162, 992, - 64, 1330, 992, - 66, 1162, 583, - 67, 1330, 513, - 69, 1162, 787, - 68, 989, 889, - 70, 821, 992, - 71, 989, 992, - 73, 989, 685, - 72, 821, 583, - 74, 989, 513, - 77, 2016, 308, - 78, 1843, 410, - 76, 1843, 204, - 81, 1502, 410, - 80, 1671, 308, - 47, 1671, 102, - 79, 1502, 204, - 46, 1330, 102, - 82, 1162, 204, - 83, 1330, 308, - 84, 1162, 410, - 86, 989, 308, - 85, 821, 204, - 48, 989, 102, - 25, 1502, 0, - 31, 1162, 0, - 19, 1843, 0, - 37, 821, 0, - 120, 821, 787, - 119, 649, 889, - 122, 481, 992, - 121, 649, 992, - 124, 649, 685, - 125, 481, 583, - 123, 649, 513, - 127, 481, 787, - 126, 308, 889, - 129, 140, 992, - 128, 308, 992, - 132, 308, 513, - 131, 308, 685, - 130, 140, 583, - 134, 140, 787, - 133, -32, 889, - 135, -32, 513, - 136, 821, 410, - 116, 649, 102, - 137, 649, 308, - 114, 481, 204, - 138, 481, 410, - 139, 308, 308, - 118, 140, 204, - 115, 308, 102, - 140, 140, 410, - 117, -32, 102, - 99, 481, 0, - 105, 140, 0, - 143, 2016, 102, - 145, 1330, 0, - 144, 1671, 0, - 142, 2016, 0, - 146, 989, 0, - 155, -32, 685, - 156, -32, 992, - 154, -32, 308, - 151, 308, 0, - 150, 649, 0, - 153, -32, 0, - - 132, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 13, 8, 5, - 0, 1, 2, - 3, 0, 4, - 4, 0, 2, - 5, 2, 1, - 1, 6, 5, - 7, 2, 8, - 5, 8, 2, - 2, 7, 4, - 7, 8, 9, - 10, 7, 9, - 11, 7, 10, - 7, 11, 4, - 12, 9, 8, - 8, 13, 12, - 21, 24, 45, - 14, 9, 15, - 12, 15, 9, - 9, 14, 10, - 16, 14, 20, - 17, 14, 16, - 14, 15, 20, - 14, 17, 10, - 15, 19, 18, - 18, 20, 15, - 19, 15, 12, - 20, 21, 16, - 18, 24, 20, - 21, 20, 24, - 22, 21, 45, - 23, 21, 22, - 21, 23, 16, - 24, 26, 25, - 25, 45, 24, - 26, 24, 18, - 6, 27, 28, - 5, 6, 28, - 29, 28, 27, - 27, 74, 29, - 29, 31, 28, - 13, 28, 31, - 28, 13, 5, - 36, 34, 35, - 12, 13, 30, - 13, 31, 30, - 31, 32, 33, - 32, 31, 29, - 33, 30, 31, - 33, 36, 30, - 30, 19, 12, - 19, 30, 36, - 18, 19, 37, - 19, 36, 37, - 34, 36, 33, - 35, 37, 36, - 37, 26, 18, - 35, 38, 37, - 26, 37, 38, - 25, 26, 62, - 26, 38, 62, - 38, 40, 39, - 39, 62, 38, - 40, 38, 35, - 41, 34, 33, - 33, 32, 41, - 42, 34, 75, - 34, 41, 75, - 35, 34, 42, - 32, 43, 76, - 41, 32, 76, - 43, 32, 29, - 29, 74, 43, - 43, 74, 77, - 46, 49, 52, - 42, 40, 35, - 39, 40, 44, - 40, 42, 78, - 44, 40, 78, - 25, 49, 45, - 45, 46, 22, - 46, 45, 49, - 47, 46, 52, - 48, 46, 47, - 46, 48, 22, - 58, 59, 57, - 49, 51, 50, - 50, 52, 49, - 51, 49, 25, - 50, 57, 52, - 52, 53, 47, - 53, 52, 57, - 53, 55, 47, - 54, 53, 59, - 55, 53, 54, - 53, 57, 59, - 56, 57, 50, - 57, 56, 58, - 58, 79, 59, - 59, 60, 54, - 60, 59, 79, - 60, 80, 54, - 61, 79, 58, - 62, 51, 25, - 39, 64, 62, - 51, 62, 64, - 50, 51, 66, - 51, 64, 66, - 63, 64, 39, - 64, 63, 65, - 65, 66, 64, - 66, 56, 50, - 56, 66, 67, - 65, 67, 66, - 58, 56, 70, - 56, 67, 70, - 67, 69, 68, - 68, 70, 67, - 69, 67, 65, - 70, 61, 58, - 68, 81, 70, - 61, 70, 81, - 71, 73, 84, - 71, 81, 68, - 72, 69, 65, - 65, 63, 72, - 68, 69, 73, - 69, 72, 82, - 73, 69, 82, - 44, 63, 39, - 63, 44, 83, - 72, 63, 83, - 73, 71, 68, -}; - -// 0x07021FFC - 0x07022516 -static const PaintingData inside_castle_seg7_painting_texture_map_top_07021FFC[] = { - 85, // num mappings - // Format: - // mesh vtx ID, texture X, texture Y - 0, 2016, 72, - 1, 2016, 0, - 2, 1843, 0, - 3, 1843, 174, - 4, 2016, 276, - 5, 1671, 72, - 6, 1671, 0, - 8, 989, 72, - 7, 989, 0, - 10, 821, 0, - 9, 1162, 0, - 11, 821, 174, - 12, 989, 276, - 13, 1162, 174, - 14, 1330, 72, - 15, 1502, 0, - 16, 1671, 276, - 17, 1502, 174, - 18, 1330, 276, - 19, 1843, 992, - 20, 2016, 889, - 22, 2016, 685, - 21, 1843, 583, - 23, 1843, 787, - 24, 1671, 889, - 25, 1502, 992, - 26, 1502, 583, - 27, 1671, 685, - 28, 1671, 481, - 30, 1502, 787, - 29, 1330, 889, - 31, 1162, 992, - 32, 1330, 481, - 33, 1162, 583, - 34, 1330, 685, - 35, 1162, 787, - 36, 989, 889, - 37, 821, 992, - 39, 821, 583, - 38, 989, 685, - 40, 989, 481, - 41, 2016, 481, - 42, 1843, 378, - 43, 1502, 378, - 44, 1162, 378, - 45, 821, 378, - 87, 649, 72, - 88, -32, 0, - 90, 140, 0, - 89, -32, 72, - 92, 308, 72, - 91, 140, 174, - 94, 481, 174, - 93, 649, 276, - 95, 481, 0, - 96, 308, 276, - 97, 821, 787, - 98, 649, 889, - 99, 481, 992, - 102, 649, 481, - 101, 649, 685, - 100, 481, 583, - 103, 481, 787, - 104, 308, 889, - 105, 140, 992, - 108, 308, 481, - 107, 308, 685, - 106, 140, 583, - 110, -32, 889, - 109, 140, 787, - 111, -32, 481, - 112, 481, 378, - 113, 140, 378, - 141, 1330, 0, - 142, 2016, 992, - 144, 1671, 992, - 145, 1330, 992, - 146, 989, 992, - 147, 649, 0, - 148, -32, 276, - 149, 308, 0, - 150, 649, 992, - 151, 308, 992, - 152, -32, 685, - 153, -32, 992, - - 132, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 10, 7, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 7, 8, 9, - 8, 7, 10, - 11, 7, 9, - 12, 7, 11, - 7, 12, 13, - 13, 14, 10, - 14, 73, 10, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 73, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 74, 20, - 19, 20, 23, - 28, 27, 22, - 21, 41, 22, - 22, 23, 21, - 20, 21, 23, - 23, 24, 19, - 22, 27, 23, - 24, 23, 27, - 19, 24, 75, - 25, 75, 24, - 25, 24, 29, - 24, 27, 29, - 26, 29, 27, - 27, 28, 26, - 31, 36, 77, - 26, 34, 29, - 29, 30, 25, - 30, 29, 34, - 25, 30, 76, - 31, 76, 30, - 31, 30, 35, - 30, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 35, 36, 31, - 33, 39, 35, - 36, 35, 39, - 37, 36, 56, - 36, 39, 56, - 37, 77, 36, - 28, 16, 43, - 38, 56, 39, - 39, 40, 38, - 40, 39, 33, - 22, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 22, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 13, 12, 44, - 44, 40, 33, - 40, 44, 12, - 38, 40, 45, - 40, 12, 45, - 11, 45, 12, - 9, 46, 11, - 46, 9, 78, - 47, 49, 48, - 48, 49, 51, - 49, 79, 51, - 50, 80, 48, - 51, 50, 48, - 57, 56, 60, - 46, 53, 11, - 52, 46, 54, - 53, 46, 52, - 46, 78, 54, - 54, 50, 52, - 50, 54, 80, - 50, 55, 52, - 55, 50, 51, - 38, 60, 56, - 56, 57, 37, - 58, 57, 62, - 57, 60, 62, - 58, 81, 57, - 37, 57, 81, - 59, 60, 38, - 60, 59, 61, - 61, 62, 60, - 62, 63, 58, - 63, 62, 66, - 61, 66, 62, - 63, 66, 69, - 58, 63, 82, - 64, 82, 63, - 64, 63, 69, - 45, 59, 38, - 65, 66, 61, - 66, 65, 67, - 67, 69, 66, - 68, 69, 83, - 69, 68, 64, - 67, 83, 69, - 64, 68, 84, - 70, 83, 67, - 11, 53, 45, - 59, 45, 53, - 59, 53, 71, - 61, 59, 71, - 52, 71, 53, - 52, 55, 71, - 65, 71, 55, - 71, 65, 61, - 65, 55, 72, - 67, 65, 72, - 51, 72, 55, - 70, 72, 79, - 51, 79, 72, - 72, 70, 67, -}; - -// 0x07022518 -static const PaintingData *const inside_castle_seg7_painting_texture_maps_07022518[] = { - inside_castle_seg7_painting_texture_map_bottom_07021AE0, - inside_castle_seg7_painting_texture_map_top_07021FFC, -}; // 0x07022598 - 0x070225D8 static const Vtx inside_castle_seg7_vertex_hmc[] = { @@ -569,443 +108,6 @@ static const Gfx inside_castle_seg7_painting_dl_env_map_ripple[] = { gsSPEndDisplayList(), }; -// 0x07022660 - 0x07023042 -static const PaintingData inside_castle_seg7_painting_env_map_texture_map_07022660[] = { - 157, // num mappings - // Format: - // mesh vtx ID, texture X, texture Y - 0, 6100, -4832, - 1, 6100, -5142, - 2, 5582, -5142, - 3, 5582, -4526, - 4, 6100, -4218, - 5, 5070, -4832, - 6, 5070, -5142, - 7, 3030, -5142, - 8, 3030, -4832, - 9, 3540, -5142, - 10, 2520, -5142, - 11, 2520, -4526, - 12, 3030, -4218, - 13, 3540, -4526, - 14, 4050, -4832, - 15, 4560, -5142, - 16, 5070, -4218, - 17, 4560, -4526, - 18, 4050, -4218, - 19, 5582, -2074, - 20, 6100, -2380, - 21, 5582, -3300, - 22, 6100, -2994, - 23, 5582, -2686, - 24, 5070, -2380, - 25, 4560, -2074, - 26, 4560, -3300, - 27, 5070, -2994, - 28, 5070, -3606, - 29, 4050, -2380, - 30, 4560, -2686, - 31, 3540, -2074, - 32, 4050, -3606, - 33, 3540, -3300, - 34, 4050, -2994, - 35, 3540, -2686, - 36, 3030, -2380, - 37, 2520, -2074, - 38, 3030, -2994, - 39, 2520, -3300, - 40, 3030, -3606, - 41, 6100, -3606, - 42, 5582, -3912, - 43, 4560, -3912, - 44, 3540, -3912, - 45, 2520, -3912, - 46, 4050, -1768, - 47, 5070, -1768, - 48, 3030, -1768, - 49, 6100, 684, - 50, 6100, 990, - 51, 5582, 990, - 52, 5582, -236, - 53, 6100, 70, - 54, 5070, 684, - 55, 5582, 378, - 56, 4560, 990, - 57, 5070, 990, - 58, 4560, -236, - 59, 5070, 70, - 60, 5070, -542, - 61, 4050, 684, - 62, 4560, 378, - 63, 3540, 990, - 64, 4050, 990, - 65, 4050, 70, - 66, 3540, -236, - 67, 4050, -542, - 68, 3030, 684, - 69, 3540, 378, - 70, 2520, 990, - 71, 3030, 990, - 72, 2520, -236, - 73, 3030, 70, - 74, 3030, -542, - 75, 6100, -542, - 76, 5582, -1462, - 77, 6100, -1154, - 78, 5582, -848, - 79, 4560, -1462, - 80, 5070, -1154, - 81, 4560, -848, - 82, 3540, -1462, - 83, 4050, -1154, - 84, 3540, -848, - 85, 2520, -1462, - 86, 3030, -1154, - 87, 2010, -4832, - 88, 0, -5142, - 89, 0, -4832, - 90, 478, -5142, - 91, 478, -4526, - 92, 988, -4832, - 93, 2010, -4218, - 94, 1498, -4526, - 95, 1498, -5142, - 96, 988, -4218, - 97, 2520, -2686, - 98, 2010, -2380, - 99, 1498, -2074, - 100, 1498, -3300, - 101, 2010, -2994, - 102, 2010, -3606, - 103, 1498, -2686, - 104, 988, -2380, - 105, 478, -2074, - 106, 478, -3300, - 107, 988, -2994, - 108, 988, -3606, - 109, 478, -2686, - 110, 0, -2380, - 111, 0, -3606, - 112, 1498, -3912, - 113, 478, -3912, - 114, 1498, -1462, - 115, 988, -1768, - 116, 2010, -1768, - 117, 0, -1768, - 118, 478, -1462, - 119, 2010, 684, - 120, 2520, 378, - 121, 2010, 990, - 122, 1498, 990, - 123, 2010, -542, - 124, 2010, 70, - 125, 1498, -236, - 126, 988, 684, - 127, 1498, 378, - 128, 988, 990, - 129, 478, 990, - 130, 478, -236, - 131, 988, 70, - 132, 988, -542, - 133, 0, 684, - 134, 478, 378, - 135, 0, -542, - 136, 2520, -848, - 137, 2010, -1154, - 138, 1498, -848, - 139, 988, -1154, - 140, 478, -848, - 141, 4050, -5142, - 142, 6100, -2074, - 143, 6100, -1768, - 144, 5070, -2074, - 145, 4050, -2074, - 146, 3030, -2074, - 147, 2010, -5142, - 148, 0, -4218, - 149, 988, -5142, - 150, 2010, -2074, - 151, 988, -2074, - 152, 0, -2994, - 153, 0, -2074, - 154, 0, -1154, - 155, 0, 70, - 156, 0, 990, - -// inside_castle_seg7_painting_triangles_07022A10: - 264, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 8, 12, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 7, 8, 9, - 8, 7, 10, - 11, 8, 10, - 12, 8, 11, - 9, 8, 13, - 13, 14, 9, - 14, 141, 9, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 141, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 142, 20, - 19, 20, 23, - 28, 27, 21, - 21, 23, 22, - 22, 41, 21, - 20, 22, 23, - 23, 24, 19, - 21, 27, 23, - 24, 23, 27, - 25, 144, 24, - 19, 24, 144, - 24, 27, 30, - 25, 24, 30, - 26, 30, 27, - 27, 28, 26, - 36, 38, 97, - 26, 34, 30, - 29, 30, 34, - 30, 29, 25, - 25, 29, 145, - 31, 145, 29, - 31, 29, 35, - 29, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 33, 38, 35, - 35, 36, 31, - 36, 35, 38, - 37, 36, 97, - 37, 146, 36, - 31, 36, 146, - 28, 16, 43, - 38, 40, 39, - 39, 97, 38, - 40, 38, 33, - 21, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 21, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 44, 40, 33, - 13, 12, 44, - 40, 44, 12, - 39, 40, 45, - 40, 12, 45, - 48, 31, 146, - 11, 45, 12, - 25, 47, 144, - 46, 25, 145, - 47, 19, 144, - 19, 143, 142, - 31, 46, 145, - 60, 59, 52, - 49, 53, 55, - 50, 49, 51, - 51, 49, 55, - 52, 55, 53, - 53, 75, 52, - 54, 55, 59, - 52, 59, 55, - 55, 54, 51, - 54, 59, 62, - 56, 54, 62, - 57, 54, 56, - 54, 57, 51, - 58, 62, 59, - 59, 60, 58, - 68, 71, 63, - 61, 62, 65, - 58, 65, 62, - 62, 61, 56, - 61, 65, 69, - 63, 61, 69, - 64, 61, 63, - 61, 64, 56, - 65, 67, 66, - 66, 69, 65, - 67, 65, 58, - 68, 69, 73, - 69, 68, 63, - 66, 73, 69, - 68, 73, 120, - 70, 68, 120, - 71, 68, 70, - 72, 120, 73, - 73, 74, 72, - 74, 73, 66, - 75, 77, 78, - 52, 75, 78, - 76, 78, 77, - 77, 143, 76, - 76, 80, 78, - 60, 78, 80, - 78, 60, 52, - 46, 83, 79, - 58, 60, 81, - 60, 80, 81, - 79, 81, 80, - 80, 47, 79, - 47, 80, 76, - 81, 67, 58, - 67, 81, 83, - 79, 83, 81, - 66, 67, 84, - 67, 83, 84, - 82, 84, 83, - 83, 46, 82, - 84, 74, 66, - 82, 86, 84, - 74, 84, 86, - 74, 86, 136, - 72, 74, 136, - 85, 136, 86, - 86, 48, 85, - 48, 86, 82, - 25, 46, 79, - 79, 47, 25, - 82, 46, 31, - 19, 47, 76, - 76, 143, 19, - 31, 48, 82, - 37, 48, 146, - 85, 48, 37, - 10, 87, 11, - 87, 10, 147, - 92, 95, 149, - 88, 89, 90, - 89, 148, 91, - 90, 89, 91, - 91, 92, 90, - 92, 149, 90, - 93, 87, 94, - 87, 93, 11, - 94, 87, 95, - 87, 147, 95, - 95, 92, 94, - 96, 92, 91, - 92, 96, 94, - 39, 101, 97, - 97, 98, 37, - 98, 97, 101, - 99, 98, 103, - 99, 150, 98, - 37, 98, 150, - 98, 101, 103, - 100, 103, 101, - 101, 102, 100, - 102, 101, 39, - 100, 107, 103, - 103, 104, 99, - 104, 103, 107, - 105, 104, 109, - 105, 151, 104, - 99, 104, 151, - 104, 107, 109, - 106, 109, 107, - 107, 108, 106, - 108, 107, 100, - 109, 110, 105, - 106, 152, 109, - 110, 109, 152, - 105, 110, 153, - 111, 152, 106, - 11, 93, 45, - 102, 45, 93, - 45, 102, 39, - 102, 93, 112, - 100, 102, 112, - 94, 112, 93, - 112, 108, 100, - 108, 112, 96, - 94, 96, 112, - 106, 108, 113, - 108, 96, 113, - 91, 113, 96, - 91, 148, 113, - 113, 111, 106, - 111, 113, 148, - 114, 116, 99, - 99, 115, 114, - 115, 99, 151, - 99, 116, 150, - 72, 124, 120, - 116, 37, 150, - 37, 116, 85, - 117, 105, 153, - 105, 115, 151, - 105, 117, 118, - 118, 115, 105, - 119, 120, 124, - 120, 119, 70, - 119, 124, 127, - 119, 121, 70, - 121, 119, 122, - 122, 119, 127, - 123, 124, 72, - 124, 123, 125, - 125, 127, 124, - 126, 127, 131, - 127, 126, 122, - 125, 131, 127, - 126, 131, 134, - 128, 126, 129, - 129, 126, 134, - 126, 128, 122, - 136, 123, 72, - 130, 134, 131, - 131, 132, 130, - 132, 131, 125, - 133, 134, 155, - 134, 133, 129, - 130, 155, 134, - 133, 156, 129, - 135, 155, 130, - 123, 136, 137, - 85, 137, 136, - 139, 115, 118, - 123, 137, 138, - 125, 123, 138, - 114, 138, 137, - 137, 116, 114, - 116, 137, 85, - 114, 139, 138, - 132, 138, 139, - 138, 132, 125, - 132, 139, 140, - 130, 132, 140, - 115, 139, 114, - 118, 140, 139, - 135, 140, 154, - 118, 154, 140, - 140, 135, 130, - 117, 154, 118, -}; - -// 0x07023044 - 0x07023048 -static const PaintingData *const inside_castle_seg7_painting_env_map_texture_maps_07023044[] = { - inside_castle_seg7_painting_env_map_texture_map_07022660, -}; // 0x07023050 - 0x070230B0 static const Gfx inside_castle_seg7_painting_dl_bob[] = { @@ -1231,8 +333,7 @@ static const Gfx inside_castle_seg7_painting_dl_hmc[] = { gsSPLightColor(LIGHT_1, 0x6464ffff), gsSPLightColor(LIGHT_2, 0x404080ff), gsSPVertex(inside_castle_seg7_vertex_hmc, 4, 0), - gsSP1Triangle( 0, 1, 2, 0x0), - gsSP1Triangle( 0, 2, 3, 0x0), + gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; @@ -1315,7 +416,6 @@ const struct Painting bob_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_bob, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_bob, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1336,7 +436,6 @@ const struct Painting ccm_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_ccm, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_ccm, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1357,7 +456,6 @@ const struct Painting wf_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_wf, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_wf, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1378,7 +476,6 @@ const struct Painting jrb_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_jrb, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_jrb, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1399,7 +496,6 @@ const struct Painting lll_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_lll, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_lll, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1420,7 +516,6 @@ const struct Painting ssl_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_ssl, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_ssl, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1441,7 +536,6 @@ const struct Painting hmc_painting = { /* Ripple Rate */ 0.05f, 0.05f, /* Ripple Dispersion */ 15.0f, 15.0f, /* Normal DList */ inside_castle_seg7_painting_dl_hmc, - /* Texture Maps */ inside_castle_seg7_painting_env_map_texture_maps_07023044, /* Textures */ inside_castle_seg7_painting_textures_hmc_env, /* Texture w, h */ 32, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, @@ -1462,7 +556,6 @@ const struct Painting ddd_painting = { /* Ripple Rate */ 0.05f, 0.05f, /* Ripple Dispersion */ 15.0f, 15.0f, /* Normal DList */ inside_castle_seg7_painting_dl_ddd, - /* Texture Maps */ inside_castle_seg7_painting_env_map_texture_maps_07023044, /* Textures */ inside_castle_seg7_painting_textures_ddd_env, /* Texture w, h */ 32, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, @@ -1483,7 +576,6 @@ const struct Painting wdw_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_wdw, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_wdw, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1504,7 +596,6 @@ const struct Painting thi_tiny_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_thi, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1525,7 +616,6 @@ const struct Painting ttm_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_ttm, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_ttm, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1546,7 +636,6 @@ const struct Painting ttc_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_ttc, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_ttc, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1567,7 +656,6 @@ const struct Painting sl_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ inside_castle_seg7_painting_dl_sl, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_sl, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1588,7 +676,6 @@ const struct Painting thi_huge_painting = { /* Ripple Rate */ 0.12f, 0.07f, /* Ripple Dispersion */ 80.0f, 60.0f, /* Normal DList */ inside_castle_seg7_painting_dl_thi, - /* Texture Maps */ inside_castle_seg7_painting_texture_maps_07022518, /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, @@ -1608,7 +695,6 @@ const struct Painting rr_painting = { /* Ripple Rate */ 0.12f, 0.07f, /* Ripple Dispersion */ 80.0f, 60.0f, /* Normal DList */ NULL, - /* Texture Maps */ NULL, /* Textures */ NULL, /* Texture w, h */ 0, 0, /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 095c140af2..21d631a698 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -16,443 +16,6 @@ static const Gfx hmc_seg7_painting_dl_cotmc_normal_ripple[] = { gsSPEndDisplayList(), }; -// 0x070242F0 - 0x07024CD2 -static const PaintingData hmc_seg7_pool_texture_map_cotmc[] = { - 157, // num mappings - // Format: - // mesh vtx ID, texture X, texture Y - 0, 6100, -4832, - 1, 6100, -5142, - 2, 5582, -5142, - 3, 5582, -4526, - 4, 6100, -4218, - 5, 5070, -4832, - 6, 5070, -5142, - 7, 3030, -5142, - 8, 3030, -4832, - 9, 3540, -5142, - 10, 2520, -5142, - 11, 2520, -4526, - 12, 3030, -4218, - 13, 3540, -4526, - 14, 4050, -4832, - 15, 4560, -5142, - 16, 5070, -4218, - 17, 4560, -4526, - 18, 4050, -4218, - 19, 5582, -2074, - 20, 6100, -2380, - 21, 5582, -3300, - 22, 6100, -2994, - 23, 5582, -2686, - 24, 5070, -2380, - 25, 4560, -2074, - 26, 4560, -3300, - 27, 5070, -2994, - 28, 5070, -3606, - 29, 4050, -2380, - 30, 4560, -2686, - 31, 3540, -2074, - 32, 4050, -3606, - 33, 3540, -3300, - 34, 4050, -2994, - 35, 3540, -2686, - 36, 3030, -2380, - 37, 2520, -2074, - 38, 3030, -2994, - 39, 2520, -3300, - 40, 3030, -3606, - 41, 6100, -3606, - 42, 5582, -3912, - 43, 4560, -3912, - 44, 3540, -3912, - 45, 2520, -3912, - 46, 4050, -1768, - 47, 5070, -1768, - 48, 3030, -1768, - 49, 6100, 684, - 50, 6100, 990, - 51, 5582, 990, - 52, 5582, -236, - 53, 6100, 70, - 54, 5070, 684, - 55, 5582, 378, - 56, 4560, 990, - 57, 5070, 990, - 58, 4560, -236, - 59, 5070, 70, - 60, 5070, -542, - 61, 4050, 684, - 62, 4560, 378, - 63, 3540, 990, - 64, 4050, 990, - 65, 4050, 70, - 66, 3540, -236, - 67, 4050, -542, - 68, 3030, 684, - 69, 3540, 378, - 70, 2520, 990, - 71, 3030, 990, - 72, 2520, -236, - 73, 3030, 70, - 74, 3030, -542, - 75, 6100, -542, - 76, 5582, -1462, - 77, 6100, -1154, - 78, 5582, -848, - 79, 4560, -1462, - 80, 5070, -1154, - 81, 4560, -848, - 82, 3540, -1462, - 83, 4050, -1154, - 84, 3540, -848, - 85, 2520, -1462, - 86, 3030, -1154, - 87, 2010, -4832, - 88, 0, -5142, - 89, 0, -4832, - 90, 478, -5142, - 91, 478, -4526, - 92, 988, -4832, - 93, 2010, -4218, - 94, 1498, -4526, - 95, 1498, -5142, - 96, 988, -4218, - 97, 2520, -2686, - 98, 2010, -2380, - 99, 1498, -2074, - 100, 1498, -3300, - 101, 2010, -2994, - 102, 2010, -3606, - 103, 1498, -2686, - 104, 988, -2380, - 105, 478, -2074, - 106, 478, -3300, - 107, 988, -2994, - 108, 988, -3606, - 109, 478, -2686, - 110, 0, -2380, - 111, 0, -3606, - 112, 1498, -3912, - 113, 478, -3912, - 114, 1498, -1462, - 115, 988, -1768, - 116, 2010, -1768, - 117, 0, -1768, - 118, 478, -1462, - 119, 2010, 684, - 120, 2520, 378, - 121, 2010, 990, - 122, 1498, 990, - 123, 2010, -542, - 124, 2010, 70, - 125, 1498, -236, - 126, 988, 684, - 127, 1498, 378, - 128, 988, 990, - 129, 478, 990, - 130, 478, -236, - 131, 988, 70, - 132, 988, -542, - 133, 0, 684, - 134, 478, 378, - 135, 0, -542, - 136, 2520, -848, - 137, 2010, -1154, - 138, 1498, -848, - 139, 988, -1154, - 140, 478, -848, - 141, 4050, -5142, - 142, 6100, -2074, - 143, 6100, -1768, - 144, 5070, -2074, - 145, 4050, -2074, - 146, 3030, -2074, - 147, 2010, -5142, - 148, 0, -4218, - 149, 988, -5142, - 150, 2010, -2074, - 151, 988, -2074, - 152, 0, -2994, - 153, 0, -2074, - 154, 0, -1154, - 155, 0, 70, - 156, 0, 990, - - 264, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 8, 12, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 7, 8, 9, - 8, 7, 10, - 11, 8, 10, - 12, 8, 11, - 9, 8, 13, - 13, 14, 9, - 14, 141, 9, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 141, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 142, 20, - 19, 20, 23, - 28, 27, 21, - 21, 23, 22, - 22, 41, 21, - 20, 22, 23, - 23, 24, 19, - 21, 27, 23, - 24, 23, 27, - 25, 144, 24, - 19, 24, 144, - 24, 27, 30, - 25, 24, 30, - 26, 30, 27, - 27, 28, 26, - 36, 38, 97, - 26, 34, 30, - 29, 30, 34, - 30, 29, 25, - 25, 29, 145, - 31, 145, 29, - 31, 29, 35, - 29, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 33, 38, 35, - 35, 36, 31, - 36, 35, 38, - 37, 36, 97, - 37, 146, 36, - 31, 36, 146, - 28, 16, 43, - 38, 40, 39, - 39, 97, 38, - 40, 38, 33, - 21, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 21, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 44, 40, 33, - 13, 12, 44, - 40, 44, 12, - 39, 40, 45, - 40, 12, 45, - 48, 31, 146, - 11, 45, 12, - 25, 47, 144, - 46, 25, 145, - 47, 19, 144, - 19, 143, 142, - 31, 46, 145, - 60, 59, 52, - 49, 53, 55, - 50, 49, 51, - 51, 49, 55, - 52, 55, 53, - 53, 75, 52, - 54, 55, 59, - 52, 59, 55, - 55, 54, 51, - 54, 59, 62, - 56, 54, 62, - 57, 54, 56, - 54, 57, 51, - 58, 62, 59, - 59, 60, 58, - 68, 71, 63, - 61, 62, 65, - 58, 65, 62, - 62, 61, 56, - 61, 65, 69, - 63, 61, 69, - 64, 61, 63, - 61, 64, 56, - 65, 67, 66, - 66, 69, 65, - 67, 65, 58, - 68, 69, 73, - 69, 68, 63, - 66, 73, 69, - 68, 73, 120, - 70, 68, 120, - 71, 68, 70, - 72, 120, 73, - 73, 74, 72, - 74, 73, 66, - 75, 77, 78, - 52, 75, 78, - 76, 78, 77, - 77, 143, 76, - 76, 80, 78, - 60, 78, 80, - 78, 60, 52, - 46, 83, 79, - 58, 60, 81, - 60, 80, 81, - 79, 81, 80, - 80, 47, 79, - 47, 80, 76, - 81, 67, 58, - 67, 81, 83, - 79, 83, 81, - 66, 67, 84, - 67, 83, 84, - 82, 84, 83, - 83, 46, 82, - 84, 74, 66, - 82, 86, 84, - 74, 84, 86, - 74, 86, 136, - 72, 74, 136, - 85, 136, 86, - 86, 48, 85, - 48, 86, 82, - 25, 46, 79, - 79, 47, 25, - 82, 46, 31, - 19, 47, 76, - 76, 143, 19, - 31, 48, 82, - 37, 48, 146, - 85, 48, 37, - 10, 87, 11, - 87, 10, 147, - 92, 95, 149, - 88, 89, 90, - 89, 148, 91, - 90, 89, 91, - 91, 92, 90, - 92, 149, 90, - 93, 87, 94, - 87, 93, 11, - 94, 87, 95, - 87, 147, 95, - 95, 92, 94, - 96, 92, 91, - 92, 96, 94, - 39, 101, 97, - 97, 98, 37, - 98, 97, 101, - 99, 98, 103, - 99, 150, 98, - 37, 98, 150, - 98, 101, 103, - 100, 103, 101, - 101, 102, 100, - 102, 101, 39, - 100, 107, 103, - 103, 104, 99, - 104, 103, 107, - 105, 104, 109, - 105, 151, 104, - 99, 104, 151, - 104, 107, 109, - 106, 109, 107, - 107, 108, 106, - 108, 107, 100, - 109, 110, 105, - 106, 152, 109, - 110, 109, 152, - 105, 110, 153, - 111, 152, 106, - 11, 93, 45, - 102, 45, 93, - 45, 102, 39, - 102, 93, 112, - 100, 102, 112, - 94, 112, 93, - 112, 108, 100, - 108, 112, 96, - 94, 96, 112, - 106, 108, 113, - 108, 96, 113, - 91, 113, 96, - 91, 148, 113, - 113, 111, 106, - 111, 113, 148, - 114, 116, 99, - 99, 115, 114, - 115, 99, 151, - 99, 116, 150, - 72, 124, 120, - 116, 37, 150, - 37, 116, 85, - 117, 105, 153, - 105, 115, 151, - 105, 117, 118, - 118, 115, 105, - 119, 120, 124, - 120, 119, 70, - 119, 124, 127, - 119, 121, 70, - 121, 119, 122, - 122, 119, 127, - 123, 124, 72, - 124, 123, 125, - 125, 127, 124, - 126, 127, 131, - 127, 126, 122, - 125, 131, 127, - 126, 131, 134, - 128, 126, 129, - 129, 126, 134, - 126, 128, 122, - 136, 123, 72, - 130, 134, 131, - 131, 132, 130, - 132, 131, 125, - 133, 134, 155, - 134, 133, 129, - 130, 155, 134, - 133, 156, 129, - 135, 155, 130, - 123, 136, 137, - 85, 137, 136, - 139, 115, 118, - 123, 137, 138, - 125, 123, 138, - 114, 138, 137, - 137, 116, 114, - 116, 137, 85, - 114, 139, 138, - 132, 138, 139, - 138, 132, 125, - 132, 139, 140, - 130, 132, 140, - 115, 139, 114, - 118, 140, 139, - 135, 140, 154, - 118, 154, 140, - 140, 135, 130, - 117, 154, 118, -}; - -// 0x07024CD4 -static const PaintingData *const hmc_seg7_painting_texture_maps_cotmc[] = { - hmc_seg7_pool_texture_map_cotmc, -}; - // 0x07024CE0 - 0x070254E0 ALIGNED8 static const Texture hmc_seg7_texture_cotmc_pool_env[] = { #include "levels/hmc/7.rgba16.inc.c" @@ -484,7 +47,6 @@ const struct Painting cotmc_painting = { /* Ripple Rate */ 0.05f, 0.05f, /* Ripple Dispersion */ 15.0f, 15.0f, /* Normal DList */ hmc_seg7_painting_dl_cotmc_normal, - /* Texture Maps */ hmc_seg7_painting_texture_maps_cotmc, /* Textures */ hmc_seg7_painting_textures_cotmc, /* Texture w, h */ 32, 32, /* Ripple DList */ hmc_seg7_painting_dl_cotmc_normal_ripple, diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index bc6b6566b3..39ece7eca9 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -55,468 +55,6 @@ static const Gfx ttm_seg7_painting_dl_slide_normal_ripple[] = { gsSPEndDisplayList(), }; -// 0x07012450 - 0x0701296A -static const PaintingData ttm_seg7_painting_texture_map_bottom_07012450[] = { - 85, // num mappings - // Format: - // mesh vtx ID, texture X, texture Y - 49, 2016, 889, - 53, 2016, 685, - 55, 1843, 787, - 50, 2016, 992, - 51, 1843, 992, - 52, 1843, 583, - 75, 2016, 513, - 54, 1671, 889, - 59, 1671, 685, - 62, 1502, 787, - 56, 1502, 992, - 57, 1671, 992, - 58, 1502, 583, - 60, 1671, 513, - 61, 1330, 889, - 65, 1330, 685, - 63, 1162, 992, - 64, 1330, 992, - 66, 1162, 583, - 67, 1330, 513, - 69, 1162, 787, - 68, 989, 889, - 70, 821, 992, - 71, 989, 992, - 73, 989, 685, - 72, 821, 583, - 74, 989, 513, - 77, 2016, 308, - 78, 1843, 410, - 76, 1843, 204, - 81, 1502, 410, - 80, 1671, 308, - 47, 1671, 102, - 79, 1502, 204, - 46, 1330, 102, - 82, 1162, 204, - 83, 1330, 308, - 84, 1162, 410, - 86, 989, 308, - 85, 821, 204, - 48, 989, 102, - 25, 1502, 0, - 31, 1162, 0, - 19, 1843, 0, - 37, 821, 0, - 120, 821, 787, - 119, 649, 889, - 122, 481, 992, - 121, 649, 992, - 124, 649, 685, - 125, 481, 583, - 123, 649, 513, - 127, 481, 787, - 126, 308, 889, - 129, 140, 992, - 128, 308, 992, - 132, 308, 513, - 131, 308, 685, - 130, 140, 583, - 134, 140, 787, - 133, -32, 889, - 135, -32, 513, - 136, 821, 410, - 116, 649, 102, - 137, 649, 308, - 114, 481, 204, - 138, 481, 410, - 139, 308, 308, - 118, 140, 204, - 115, 308, 102, - 140, 140, 410, - 117, -32, 102, - 99, 481, 0, - 105, 140, 0, - 143, 2016, 102, - 145, 1330, 0, - 144, 1671, 0, - 142, 2016, 0, - 146, 989, 0, - 155, -32, 685, - 156, -32, 992, - 154, -32, 308, - 151, 308, 0, - 150, 649, 0, - 153, -32, 0, - - 132, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 13, 8, 5, - 0, 1, 2, - 3, 0, 4, - 4, 0, 2, - 5, 2, 1, - 1, 6, 5, - 7, 2, 8, - 5, 8, 2, - 2, 7, 4, - 7, 8, 9, - 10, 7, 9, - 11, 7, 10, - 7, 11, 4, - 12, 9, 8, - 8, 13, 12, - 21, 24, 45, - 14, 9, 15, - 12, 15, 9, - 9, 14, 10, - 16, 14, 20, - 17, 14, 16, - 14, 15, 20, - 14, 17, 10, - 15, 19, 18, - 18, 20, 15, - 19, 15, 12, - 20, 21, 16, - 18, 24, 20, - 21, 20, 24, - 22, 21, 45, - 23, 21, 22, - 21, 23, 16, - 24, 26, 25, - 25, 45, 24, - 26, 24, 18, - 6, 27, 28, - 5, 6, 28, - 29, 28, 27, - 27, 74, 29, - 29, 31, 28, - 13, 28, 31, - 28, 13, 5, - 36, 34, 35, - 12, 13, 30, - 13, 31, 30, - 31, 32, 33, - 32, 31, 29, - 33, 30, 31, - 33, 36, 30, - 30, 19, 12, - 19, 30, 36, - 18, 19, 37, - 19, 36, 37, - 34, 36, 33, - 35, 37, 36, - 37, 26, 18, - 35, 38, 37, - 26, 37, 38, - 25, 26, 62, - 26, 38, 62, - 38, 40, 39, - 39, 62, 38, - 40, 38, 35, - 41, 34, 33, - 33, 32, 41, - 42, 34, 75, - 34, 41, 75, - 35, 34, 42, - 32, 43, 76, - 41, 32, 76, - 43, 32, 29, - 29, 74, 43, - 43, 74, 77, - 46, 49, 52, - 42, 40, 35, - 39, 40, 44, - 40, 42, 78, - 44, 40, 78, - 25, 49, 45, - 45, 46, 22, - 46, 45, 49, - 47, 46, 52, - 48, 46, 47, - 46, 48, 22, - 58, 59, 57, - 49, 51, 50, - 50, 52, 49, - 51, 49, 25, - 50, 57, 52, - 52, 53, 47, - 53, 52, 57, - 53, 55, 47, - 54, 53, 59, - 55, 53, 54, - 53, 57, 59, - 56, 57, 50, - 57, 56, 58, - 58, 79, 59, - 59, 60, 54, - 60, 59, 79, - 60, 80, 54, - 61, 79, 58, - 62, 51, 25, - 39, 64, 62, - 51, 62, 64, - 50, 51, 66, - 51, 64, 66, - 63, 64, 39, - 64, 63, 65, - 65, 66, 64, - 66, 56, 50, - 56, 66, 67, - 65, 67, 66, - 58, 56, 70, - 56, 67, 70, - 67, 69, 68, - 68, 70, 67, - 69, 67, 65, - 70, 61, 58, - 68, 81, 70, - 61, 70, 81, - 71, 73, 84, - 71, 81, 68, - 72, 69, 65, - 65, 63, 72, - 68, 69, 73, - 69, 72, 82, - 73, 69, 82, - 44, 63, 39, - 63, 44, 83, - 72, 63, 83, - 73, 71, 68, -}; - -// 0x0701296C - 0x07012E84 -static const PaintingData ttm_seg7_painting_top_0701296C[] = { - 85, // num mappings - // Format: - // mesh vtx ID, texture X, texture Y - 0, 2016, 72, - 1, 2016, 0, - 2, 1843, 0, - 3, 1843, 174, - 4, 2016, 276, - 5, 1671, 72, - 6, 1671, 0, - 8, 989, 72, - 7, 989, 0, - 10, 821, 0, - 9, 1162, 0, - 11, 821, 174, - 12, 989, 276, - 13, 1162, 174, - 14, 1330, 72, - 15, 1502, 0, - 16, 1671, 276, - 17, 1502, 174, - 18, 1330, 276, - 19, 1843, 992, - 20, 2016, 889, - 22, 2016, 685, - 21, 1843, 583, - 23, 1843, 787, - 24, 1671, 889, - 25, 1502, 992, - 26, 1502, 583, - 27, 1671, 685, - 28, 1671, 481, - 30, 1502, 787, - 29, 1330, 889, - 31, 1162, 992, - 32, 1330, 481, - 33, 1162, 583, - 34, 1330, 685, - 35, 1162, 787, - 36, 989, 889, - 37, 821, 992, - 39, 821, 583, - 38, 989, 685, - 40, 989, 481, - 41, 2016, 481, - 42, 1843, 378, - 43, 1502, 378, - 44, 1162, 378, - 45, 821, 378, - 87, 649, 72, - 88, -32, 0, - 90, 140, 0, - 89, -32, 72, - 92, 308, 72, - 91, 140, 174, - 94, 481, 174, - 93, 649, 276, - 95, 481, 0, - 96, 308, 276, - 97, 821, 787, - 98, 649, 889, - 99, 481, 992, - 102, 649, 481, - 101, 649, 685, - 100, 481, 583, - 103, 481, 787, - 104, 308, 889, - 105, 140, 992, - 108, 308, 481, - 107, 308, 685, - 106, 140, 583, - 110, -32, 889, - 109, 140, 787, - 111, -32, 481, - 112, 481, 378, - 113, 140, 378, - 141, 1330, 0, - 142, 2016, 992, - 144, 1671, 992, - 145, 1330, 992, - 146, 989, 992, - 147, 649, 0, - 148, -32, 276, - 149, 308, 0, - 150, 649, 992, - 151, 308, 992, - 152, -32, 685, - 153, -32, 992, - - 132, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 10, 7, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 7, 8, 9, - 8, 7, 10, - 11, 7, 9, - 12, 7, 11, - 7, 12, 13, - 13, 14, 10, - 14, 73, 10, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 73, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 74, 20, - 19, 20, 23, - 28, 27, 22, - 21, 41, 22, - 22, 23, 21, - 20, 21, 23, - 23, 24, 19, - 22, 27, 23, - 24, 23, 27, - 19, 24, 75, - 25, 75, 24, - 25, 24, 29, - 24, 27, 29, - 26, 29, 27, - 27, 28, 26, - 31, 36, 77, - 26, 34, 29, - 29, 30, 25, - 30, 29, 34, - 25, 30, 76, - 31, 76, 30, - 31, 30, 35, - 30, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 35, 36, 31, - 33, 39, 35, - 36, 35, 39, - 37, 36, 56, - 36, 39, 56, - 37, 77, 36, - 28, 16, 43, - 38, 56, 39, - 39, 40, 38, - 40, 39, 33, - 22, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 22, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 13, 12, 44, - 44, 40, 33, - 40, 44, 12, - 38, 40, 45, - 40, 12, 45, - 11, 45, 12, - 9, 46, 11, - 46, 9, 78, - 47, 49, 48, - 48, 49, 51, - 49, 79, 51, - 50, 80, 48, - 51, 50, 48, - 57, 56, 60, - 46, 53, 11, - 52, 46, 54, - 53, 46, 52, - 46, 78, 54, - 54, 50, 52, - 50, 54, 80, - 50, 55, 52, - 55, 50, 51, - 38, 60, 56, - 56, 57, 37, - 58, 57, 62, - 57, 60, 62, - 58, 81, 57, - 37, 57, 81, - 59, 60, 38, - 60, 59, 61, - 61, 62, 60, - 62, 63, 58, - 63, 62, 66, - 61, 66, 62, - 63, 66, 69, - 58, 63, 82, - 64, 82, 63, - 64, 63, 69, - 45, 59, 38, - 65, 66, 61, - 66, 65, 67, - 67, 69, 66, - 68, 69, 83, - 69, 68, 64, - 67, 83, 69, - 64, 68, 84, - 70, 83, 67, - 11, 53, 45, - 59, 45, 53, - 59, 53, 71, - 61, 59, 71, - 52, 71, 53, - 52, 55, 71, - 65, 71, 55, - 71, 65, 61, - 65, 55, 72, - 67, 65, 72, - 51, 72, 55, - 70, 72, 79, - 51, 79, 72, - 72, 70, 67, -}; - -// 0x07012E88 -static const PaintingData *const ttm_seg7_painting_texture_maps_07012E88[] = { - ttm_seg7_painting_texture_map_bottom_07012450, - ttm_seg7_painting_top_0701296C, -}; - // 0x07012E98 - 0x07012EF8 static const Gfx ttm_seg7_painting_dl_slide_normal[] = { gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_begin), @@ -550,7 +88,6 @@ const struct Painting ttm_slide_painting = { /* Ripple Rate */ 0.24f, 0.14f, /* Ripple Dispersion */ 40.0f, 30.0f, /* Normal DList */ ttm_seg7_painting_dl_slide_normal, - /* Texture Maps */ ttm_seg7_painting_texture_maps_07012E88, /* Textures */ ttm_seg7_painting_textures_slide, /* Texture w, h */ 64, 32, /* Ripple DList */ ttm_seg7_painting_dl_slide_normal_ripple, diff --git a/src/game/paintings.c b/src/game/paintings.c index b6e9bc9426..55372867f2 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -604,7 +604,7 @@ Gfx *painting_model_view_transform(struct Painting *painting) { /** * Ripple a painting that has 1 or more images that need to be mapped */ -Gfx *painting_ripple_image(struct Painting *painting) { +Gfx *painting_ripple_image(struct Painting *painting, PaintingData **textureMaps) { PaintingData i; PaintingData meshVerts; PaintingData meshTris; @@ -612,7 +612,6 @@ Gfx *painting_ripple_image(struct Painting *painting) { PaintingData imageCount = painting->imageCount; PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; - PaintingData **textureMaps = segmented_to_virtual(painting->textureMaps); Texture **textures = segmented_to_virtual(painting->textureArray); Gfx *dlist = alloc_display_list((imageCount + 6) * sizeof(Gfx)); Gfx *gfx = dlist; @@ -646,13 +645,12 @@ Gfx *painting_ripple_image(struct Painting *painting) { /** * Ripple a painting that has 1 "environment map" texture. */ -Gfx *painting_ripple_env_mapped(struct Painting *painting) { +Gfx *painting_ripple_env_mapped(struct Painting *painting, PaintingData **textureMaps) { PaintingData meshVerts; PaintingData meshTris; PaintingData *textureMap; PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; - PaintingData **textureMaps = segmented_to_virtual(painting->textureMaps); Texture **tArray = segmented_to_virtual(painting->textureArray); Gfx *dlist = alloc_display_list(7 * sizeof(Gfx)); Gfx *gfx = dlist; @@ -701,10 +699,10 @@ Gfx *display_painting_rippling(struct Painting *painting) { // Map the painting's texture depending on the painting's texture type. switch (painting->textureType) { case PAINTING_IMAGE: - dlist = painting_ripple_image(painting); + dlist = painting_ripple_image(painting, segmented_to_virtual(seg2_painting_image_texture_maps)); break; case PAINTING_ENV_MAP: - dlist = painting_ripple_env_mapped(painting); + dlist = painting_ripple_env_mapped(painting, segmented_to_virtual(seg2_painting_env_map_texture_maps)); break; } @@ -850,7 +848,6 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con // Draw the painting. if (painting->imageCount > 0 && painting->normalDisplayList != NULL - && painting->textureMaps != NULL && painting->textureArray != NULL && painting->textureWidth > 0 && painting->textureHeight > 0 diff --git a/src/game/paintings.h b/src/game/paintings.h index 05408f40a3..7ae19423e5 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -57,9 +57,9 @@ enum TTMPaintingIDs { // Painting group ids enum PaintingGroups { - /* 0*/PAINTING_GROUP_HMC, - /* 1*/PAINTING_GROUP_INSIDE_CASTLE, - /* 2*/PAINTING_GROUP_TTM, + /* 0*/ PAINTING_GROUP_HMC, + /* 1*/ PAINTING_GROUP_INSIDE_CASTLE, + /* 2*/ PAINTING_GROUP_TTM, PAINTING_NUM_GROUPS, PAINTING_GROUP_NULL = -1, }; @@ -121,31 +121,29 @@ struct Painting { /// Display list used when the painting is normal. /*0x24*/ const Gfx *normalDisplayList; - /// Data used to map the texture to the mesh - /*0x28*/ const PaintingData *const *textureMaps; // Texture data - /*0x2C*/ const Texture *const *textureArray; - /*0x30*/ PaintingData textureWidth; - /*0x32*/ PaintingData textureHeight; + /*0x28*/ const Texture *const *textureArray; + /*0x2C*/ PaintingData textureWidth; + /*0x2E*/ PaintingData textureHeight; /// Display list used when the painting is rippling. - /*0x34*/ const Gfx *rippleDisplayList; + /*0x30*/ const Gfx *rippleDisplayList; /// Controls when a passive ripple starts. RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. - /*0x38*/ s8 rippleTrigger; + /*0x34*/ s8 rippleTrigger; /// The painting's transparency (0..255). Determines what layer the painting is in. - /*0x39*/ Alpha alpha; + /*0x35*/ Alpha alpha; /// Struct padding. - /*0x3A*/ PaintingData unused; + /*0x36*/ PaintingData unused; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. /// By default a painting is 614.0f x 614.0f - /*0x3C*/ f32 sizeX; - /*0x40*/ f32 sizeY; -}; /*0x44*/ + /*0x38*/ f32 sizeX; + /*0x3C*/ f32 sizeY; +}; /*0x40*/ /** * Contains the position and normal of a vertex in the painting's generated mesh. diff --git a/src/game/segment2.h b/src/game/segment2.h index c83f8ed700..9cf93912f0 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -42,8 +42,10 @@ extern Gfx dl_paintings_rippling_begin[]; extern Gfx dl_paintings_rippling_end[]; extern Gfx dl_paintings_env_mapped_begin[]; extern Gfx dl_paintings_env_mapped_end[]; -extern s16 seg2_painting_triangle_mesh[]; -extern s16 seg2_painting_mesh_neighbor_tris[]; +extern PaintingData seg2_painting_triangle_mesh[]; +extern PaintingData seg2_painting_mesh_neighbor_tris[]; +extern PaintingData *const seg2_painting_image_texture_maps[]; +extern PaintingData *const seg2_painting_env_map_texture_maps[]; extern Texture *main_hud_lut[58]; extern Gfx dl_hud_img_load_tex_block[]; extern Gfx dl_hud_img_begin[]; From d7503663a0af4ac4eded32b414f2b7f605c9f9b8 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 9 Aug 2022 19:49:00 -0700 Subject: [PATCH 08/81] Combine ripple setup dls + paintings.c gfx commands formatting + use PAINTING_SIZE for vertex dls --- bin/segment2.c | 6 ++ levels/castle_inside/painting.inc.c | 105 ++++++++++------------------ levels/hmc/areas/1/painting.inc.c | 27 +++---- levels/ttm/areas/1/painting.inc.c | 25 +++---- src/game/paintings.c | 51 ++++++++++---- src/game/paintings.h | 23 +++--- 6 files changed, 107 insertions(+), 130 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 75214870d2..b184971655 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2840,6 +2840,9 @@ const Gfx dl_paintings_rippling_begin[] = { gsSPLightColor(LIGHT_1, 0xffffffff), gsSPLightColor(LIGHT_2, 0x505050ff), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPTileSync(), + gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), + gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPEndDisplayList(), }; @@ -2859,6 +2862,9 @@ const Gfx dl_paintings_env_mapped_begin[] = { gsSPLightColor(LIGHT_1, 0xffffffff), gsSPLightColor(LIGHT_2, 0x505050ff), gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_ON), + gsDPTileSync(), + gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), + gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPEndDisplayList(), }; diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 3f26906d98..8f01c5e7bf 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -2,50 +2,50 @@ // 0x07021818 - 0x07021898 static const Vtx inside_castle_seg7_vertex_painting_textured[] = { - {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 307, 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 307, 0}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 307, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 307, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 614, 0}, 0, { 2012, -28}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 614, 0}, 0, { -32, -28}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 2012, -28}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x07021898 - 0x07021918 static const Vtx inside_castle_seg7_vertex_painting_sl[] = { - {{{ 0, 0, 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 614, 0, 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 614, 307, 0}, 0, { 2012, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 0, 307, 0}, 0, { -32, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 0, 307, 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 614, 307, 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 614, 614, 0}, 0, { 2012, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 0, 614, 0}, 0, { -32, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{ 0, 0, 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 2012, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, + {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, }; // 0x07021918 - 0x07021998 static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_1[] = { - {{{ -3046, -307, -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, -307, -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, 0, -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -3046, 0, -3724}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -3046, 0, -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, 0, -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, 307, -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -3046, 307, -3724}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -3046, -(PAINTING_SIZE / 2), -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -2742, -(PAINTING_SIZE / 2), -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -2742, 0, -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -3046, 0, -3724}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -3046, 0, -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -2742, 0, -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -2742, (PAINTING_SIZE / 2), -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -3046, (PAINTING_SIZE / 2), -3724}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x07021998 - 0x07021A18 static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_2[] = { - {{{ -1866, -307, -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, -307, -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, 0, -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1866, 0, -4258}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1866, 0, -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, 0, -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, 307, -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1866, 307, -4258}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1866, -(PAINTING_SIZE / 2), -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1562, -(PAINTING_SIZE / 2), -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1562, 0, -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1866, 0, -4258}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1866, 0, -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1562, 0, -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1562, (PAINTING_SIZE / 2), -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ -1866, (PAINTING_SIZE / 2), -4258}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x07021A18 - 0x07021A30 @@ -83,32 +83,14 @@ static const Gfx inside_castle_seg7_dl_painting_texture_end[] = { gsSPEndDisplayList(), }; -// 0x07021AC0 - 0x07021AE0 -static const Gfx inside_castle_seg7_painting_dl_image_ripple[] = { - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPEndDisplayList(), -}; - - // 0x07022598 - 0x070225D8 static const Vtx inside_castle_seg7_vertex_hmc[] = { - {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, -}; - -// 0x07022640 - 0x07022660 -static const Gfx inside_castle_seg7_painting_dl_env_map_ripple[] = { - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPEndDisplayList(), + {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; - // 0x07023050 - 0x070230B0 static const Gfx inside_castle_seg7_painting_dl_bob[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), @@ -418,7 +400,6 @@ const struct Painting bob_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_bob, /* Textures */ inside_castle_seg7_painting_textures_bob, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -438,7 +419,6 @@ const struct Painting ccm_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_ccm, /* Textures */ inside_castle_seg7_painting_textures_ccm, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -458,7 +438,6 @@ const struct Painting wf_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_wf, /* Textures */ inside_castle_seg7_painting_textures_wf, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -478,7 +457,6 @@ const struct Painting jrb_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_jrb, /* Textures */ inside_castle_seg7_painting_textures_jrb, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -498,7 +476,6 @@ const struct Painting lll_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_lll, /* Textures */ inside_castle_seg7_painting_textures_lll, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -518,7 +495,6 @@ const struct Painting ssl_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_ssl, /* Textures */ inside_castle_seg7_painting_textures_ssl, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -538,7 +514,6 @@ const struct Painting hmc_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_hmc, /* Textures */ inside_castle_seg7_painting_textures_hmc_env, /* Texture w, h */ 32, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -558,7 +533,6 @@ const struct Painting ddd_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_ddd, /* Textures */ inside_castle_seg7_painting_textures_ddd_env, /* Texture w, h */ 32, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_env_map_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xB4, /* Unused*/ 0, @@ -578,7 +552,6 @@ const struct Painting wdw_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_wdw, /* Textures */ inside_castle_seg7_painting_textures_wdw, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -598,7 +571,6 @@ const struct Painting thi_tiny_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_thi, /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -618,7 +590,6 @@ const struct Painting ttm_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_ttm, /* Textures */ inside_castle_seg7_painting_textures_ttm, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -638,7 +609,6 @@ const struct Painting ttc_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_ttc, /* Textures */ inside_castle_seg7_painting_textures_ttc, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -658,7 +628,6 @@ const struct Painting sl_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_sl, /* Textures */ inside_castle_seg7_painting_textures_sl, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -678,7 +647,6 @@ const struct Painting thi_huge_painting = { /* Normal DList */ inside_castle_seg7_painting_dl_thi, /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, @@ -697,7 +665,6 @@ const struct Painting rr_painting = { /* Normal DList */ NULL, /* Textures */ NULL, /* Texture w, h */ 0, 0, - /* Ripple DList */ inside_castle_seg7_painting_dl_image_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0x00, /* Unused*/ 0, diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 21d631a698..94a5a39622 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -2,23 +2,10 @@ // 0x07024228 - 0x07024268 static const Vtx hmc_seg7_vertex_cotmc_pool[] = { - {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 614, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, -}; - -// 0x070242D0 - 0x070242F0 -static const Gfx hmc_seg7_painting_dl_cotmc_normal_ripple[] = { - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPEndDisplayList(), -}; - -// 0x07024CE0 - 0x070254E0 -ALIGNED8 static const Texture hmc_seg7_texture_cotmc_pool_env[] = { -#include "levels/hmc/7.rgba16.inc.c" + {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x070254E0 - 0x07025518 @@ -31,6 +18,11 @@ static const Gfx hmc_seg7_painting_dl_cotmc_normal[] = { gsSPEndDisplayList(), }; +// 0x07024CE0 - 0x070254E0 +ALIGNED8 static const Texture hmc_seg7_texture_cotmc_pool_env[] = { +#include "levels/hmc/7.rgba16.inc.c" +}; + // 0x07025518 - 0x07025594 const Texture *const hmc_seg7_painting_textures_cotmc[] = { hmc_seg7_texture_cotmc_pool_env, @@ -49,7 +41,6 @@ const struct Painting cotmc_painting = { /* Normal DList */ hmc_seg7_painting_dl_cotmc_normal, /* Textures */ hmc_seg7_painting_textures_cotmc, /* Texture w, h */ 32, 32, - /* Ripple DList */ hmc_seg7_painting_dl_cotmc_normal_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Alpha */ 0xFF, /* Unused*/ 0, diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index 39ece7eca9..8ade39ff9d 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -2,14 +2,14 @@ // 0x07012308 - 0x07012388 static const Vtx ttm_seg7_vertex_slide_painting[] = { - {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 307, 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 307, 0}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 307, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 307, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 614, 614, 0}, 0, { 2012, -28}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, 614, 0}, 0, { -32, -28}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 2012, -28}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x07012388 - 0x070123A0 @@ -47,14 +47,6 @@ const Gfx ttm_seg7_sub_dl_slide_painting_normal_end[] = { gsSPEndDisplayList(), }; -// 0x07012430 - 0x07012450 -static const Gfx ttm_seg7_painting_dl_slide_normal_ripple[] = { - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPEndDisplayList(), -}; - // 0x07012E98 - 0x07012EF8 static const Gfx ttm_seg7_painting_dl_slide_normal[] = { gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_begin), @@ -90,7 +82,6 @@ const struct Painting ttm_slide_painting = { /* Normal DList */ ttm_seg7_painting_dl_slide_normal, /* Textures */ ttm_seg7_painting_textures_slide, /* Texture w, h */ 64, 32, - /* Ripple DList */ ttm_seg7_painting_dl_slide_normal_ripple, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Alpha */ 0xFF, /* Unused*/ 0, diff --git a/src/game/paintings.c b/src/game/paintings.c index 55372867f2..dab76197ce 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -480,16 +480,16 @@ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, Pa Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); u32 commands = ( - /*gLoadBlockTexture*/ 5 + + /*gLoadBlockTexture */ 5 + (triGroups * ( - /*gSPVertex*/ 1 + - /*gSPDisplayList*/ 1 + /*gSPVertex */ 1 + + /*gSPDisplayList */ 1 )) + - /*gSPVertex*/ 1 + + /*gSPVertex */ 1 + (remGroupTris * ( - /*gSP1Triangle*/ 1 + /*gSP1Triangle */ 1 )) + - /*gSPEndDisplayList*/ 1 + /*gSPEndDisplayList */ 1 ); Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; @@ -583,7 +583,11 @@ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, Pa * Orient the painting mesh for rendering. */ Gfx *painting_model_view_transform(struct Painting *painting) { - Gfx *dlist = alloc_display_list(2 * sizeof(Gfx)); + u32 commands = ( + /*gSPMatrix */ 1 + + /*gSPEndDisplayList */ 1 + ); + Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; // Scale @@ -595,7 +599,6 @@ Gfx *painting_model_view_transform(struct Painting *painting) { 1.0f ); gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); - gSPEndDisplayList(gfx); return dlist; @@ -613,7 +616,17 @@ Gfx *painting_ripple_image(struct Painting *painting, PaintingData **textureMaps PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; Texture **textures = segmented_to_virtual(painting->textureArray); - Gfx *dlist = alloc_display_list((imageCount + 6) * sizeof(Gfx)); + u32 commands = ( + /*gSPDisplayList */ 1 + + /*gSPDisplayList */ 1 + + (imageCount * ( + /*gSPDisplayList */ 1 + )) + + /*gSPPopMatrix */ 1 + + /*gSPDisplayList */ 1 + + /*gSPEndDisplayList */ 1 + ); + Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { @@ -622,7 +635,6 @@ Gfx *painting_ripple_image(struct Painting *painting, PaintingData **textureMaps gSPDisplayList(gfx++, painting_model_view_transform(painting)); gSPDisplayList(gfx++, dl_paintings_rippling_begin); - gSPDisplayList(gfx++, painting->rippleDisplayList); // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { @@ -652,7 +664,15 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting, PaintingData **textur PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; Texture **tArray = segmented_to_virtual(painting->textureArray); - Gfx *dlist = alloc_display_list(7 * sizeof(Gfx)); + u32 commands = ( + /*gSPDisplayList */ 1 + + /*gSPDisplayList */ 1 + + /*gSPDisplayList */ 1 + + /*gSPPopMatrix */ 1 + + /*gSPDisplayList */ 1 + + /*gSPEndDisplayList */ 1 + ); + Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { @@ -661,7 +681,6 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting, PaintingData **textur gSPDisplayList(gfx++, painting_model_view_transform(painting)); gSPDisplayList(gfx++, dl_paintings_env_mapped_begin); - gSPDisplayList(gfx++, painting->rippleDisplayList); // Map the image to the mesh's vertices. textureMap = segmented_to_virtual(textureMaps[0]); @@ -717,7 +736,13 @@ Gfx *display_painting_rippling(struct Painting *painting) { * Render a normal painting. */ Gfx *display_painting_not_rippling(struct Painting *painting) { - Gfx *dlist = alloc_display_list(4 * sizeof(Gfx)); + u32 commands = ( + /*gSPDisplayList */ 1 + + /*gSPDisplayList */ 1 + + /*gSPPopMatrix */ 1 + + /*gSPEndDisplayList */ 1 + ); + Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { diff --git a/src/game/paintings.h b/src/game/paintings.h index 7ae19423e5..83a8670b84 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -12,10 +12,10 @@ #define PAINTING_ID(id, grp) ((id) | ((grp) << 8)) /// The default painting side length. -#define PAINTING_SIZE 614.0f +#define PAINTING_SIZE 614 /// The depth of the area in front of the painting which triggers ripples without warping. -#define PAINTING_WOBBLE_DEPTH 100.0f +#define PAINTING_WOBBLE_DEPTH 100 /// The depth of the area behind the painting which triggers the warp. #define PAINTING_WARP_DEPTH PAINTING_SIZE @@ -24,7 +24,7 @@ #define PAINTING_EDGE_MARGIN (PAINTING_SIZE / 2) /// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. -#define PAINTING_MARIO_Y_OFFSET 50.0f +#define PAINTING_MARIO_Y_OFFSET 50 // HMC painting group enum HMCPaintingIDs { @@ -119,7 +119,7 @@ struct Painting { /*0x1C*/ f32 passiveDispersionFactor; /*0x20*/ f32 entryDispersionFactor; - /// Display list used when the painting is normal. + /// Display list used when the painting is not rippling. /*0x24*/ const Gfx *normalDisplayList; // Texture data @@ -127,23 +127,20 @@ struct Painting { /*0x2C*/ PaintingData textureWidth; /*0x2E*/ PaintingData textureHeight; - /// Display list used when the painting is rippling. - /*0x30*/ const Gfx *rippleDisplayList; - /// Controls when a passive ripple starts. RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. - /*0x34*/ s8 rippleTrigger; + /*0x30*/ s8 rippleTrigger; /// The painting's transparency (0..255). Determines what layer the painting is in. - /*0x35*/ Alpha alpha; + /*0x31*/ Alpha alpha; /// Struct padding. - /*0x36*/ PaintingData unused; + /*0x32*/ PaintingData unused; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. /// By default a painting is 614.0f x 614.0f - /*0x38*/ f32 sizeX; - /*0x3C*/ f32 sizeY; -}; /*0x40*/ + /*0x34*/ f32 sizeX; + /*0x38*/ f32 sizeY; +}; /*0x3C*/ /** * Contains the position and normal of a vertex in the painting's generated mesh. From da9e796457ffe450930588973b60555746337090 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 9 Aug 2022 20:46:27 -0700 Subject: [PATCH 09/81] Move ripple constants outside of Painting struct --- levels/castle_inside/painting.inc.c | 199 +++++++++------------------- levels/hmc/areas/1/painting.inc.c | 13 +- levels/ttm/areas/1/painting.inc.c | 13 +- src/game/paintings.c | 91 ++++++++----- src/game/paintings.h | 71 +++++----- 5 files changed, 171 insertions(+), 216 deletions(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 8f01c5e7bf..54d0bb2b49 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -389,284 +389,209 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = // 0x07023620 - 0x07023698 const struct Painting bob_painting = { - /* id */ PAINTING_ID_CASTLE_BOB, + /* ID */ PAINTING_ID_CASTLE_BOB, /* Image Count */ 2, + /* Alpha */ 0xFF, + /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_bob, /* Textures */ inside_castle_seg7_painting_textures_bob, - /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, - /* Size */ 614.0f, 614.0f, + /* Texture w, h */ 64, 32, /* Size */ 614.0f, 614.0f, }; // 0x07023698 - 0x07023710 const struct Painting ccm_painting = { - /* id */ PAINTING_ID_CASTLE_CCM, + /* ID */ PAINTING_ID_CASTLE_CCM, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_ccm, /* Textures */ inside_castle_seg7_painting_textures_ccm, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023710 - 0x07023788 const struct Painting wf_painting = { - /* id */ PAINTING_ID_CASTLE_WF, + /* ID */ PAINTING_ID_CASTLE_WF, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_wf, /* Textures */ inside_castle_seg7_painting_textures_wf, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023788 - 0x07023800 const struct Painting jrb_painting = { - /* id */ PAINTING_ID_CASTLE_JRB, + /* ID */ PAINTING_ID_CASTLE_JRB, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_jrb, /* Textures */ inside_castle_seg7_painting_textures_jrb, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023800 - 0x07023878 const struct Painting lll_painting = { - /* id */ PAINTING_ID_CASTLE_LLL, + /* ID */ PAINTING_ID_CASTLE_LLL, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_lll, /* Textures */ inside_castle_seg7_painting_textures_lll, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023878 - 0x070238F0 const struct Painting ssl_painting = { - /* id */ PAINTING_ID_CASTLE_SSL, + /* ID */ PAINTING_ID_CASTLE_SSL, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_ssl, /* Textures */ inside_castle_seg7_painting_textures_ssl, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x070238F0 - 0x07023968 const struct Painting hmc_painting = { - /* id */ PAINTING_ID_CASTLE_HMC, + /* ID */ PAINTING_ID_CASTLE_HMC, /* Image Count */ 1, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_ENV_MAP, - /* passive entry */ - /* Ripple Magnitude */ 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 0.98f, - /* Ripple Rate */ 0.05f, 0.05f, - /* Ripple Dispersion */ 15.0f, 15.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, + /* Ripple Animation */ RIPPLE_ANIM_CONTINUOUS, /* Normal DList */ inside_castle_seg7_painting_dl_hmc, /* Textures */ inside_castle_seg7_painting_textures_hmc_env, /* Texture w, h */ 32, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 768.0f, 768.0f, }; // 0x07023968 - 0x070239E0 const struct Painting ddd_painting = { - /* id */ PAINTING_ID_CASTLE_DDD, + /* ID */ PAINTING_ID_CASTLE_DDD, /* Image Count */ 1, + /* Alpha */ 0xB4, /* Texture Type */ PAINTING_ENV_MAP, - /* passive entry */ - /* Ripple Magnitude */ 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 0.98f, - /* Ripple Rate */ 0.05f, 0.05f, - /* Ripple Dispersion */ 15.0f, 15.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, + /* Ripple Animation */ RIPPLE_ANIM_CONTINUOUS, /* Normal DList */ inside_castle_seg7_painting_dl_ddd, /* Textures */ inside_castle_seg7_painting_textures_ddd_env, /* Texture w, h */ 32, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Alpha */ 0xB4, - /* Unused*/ 0, /* Size */ 819.2f, 819.2f, }; // 0x070239E0 - 0x07023A58 const struct Painting wdw_painting = { - /* id */ PAINTING_ID_CASTLE_WDW, + /* ID */ PAINTING_ID_CASTLE_WDW, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_wdw, /* Textures */ inside_castle_seg7_painting_textures_wdw, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 614.0f, 614.0f, }; // 0x07023A58 - 0x07023AD0 const struct Painting thi_tiny_painting = { - /* id */ PAINTING_ID_CASTLE_THI_TINY, + /* ID */ PAINTING_ID_CASTLE_THI_TINY, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_thi, /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 393.216f, 393.216f, }; // 0x07023AD0 - 0x07023B48 const struct Painting ttm_painting = { - /* id */ PAINTING_ID_CASTLE_TTM, + /* ID */ PAINTING_ID_CASTLE_TTM, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_ttm, /* Textures */ inside_castle_seg7_painting_textures_ttm, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 256.0f, 256.0f, }; // 0x07023B48 - 0x07023BC0 const struct Painting ttc_painting = { - /* id */ PAINTING_ID_CASTLE_TTC, + /* ID */ PAINTING_ID_CASTLE_TTC, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_ttc, /* Textures */ inside_castle_seg7_painting_textures_ttc, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 409.6f, 409.6f, }; // 0x07023BC0 - 0x07023C38 const struct Painting sl_painting = { - /* id */ PAINTING_ID_CASTLE_SL, + /* ID */ PAINTING_ID_CASTLE_SL, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ inside_castle_seg7_painting_dl_sl, /* Textures */ inside_castle_seg7_painting_textures_sl, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 716.8f, 716.8f, }; // 0x07023C38 - 0x07023CB0 const struct Painting thi_huge_painting = { - /* id */ PAINTING_ID_CASTLE_THI_HUGE, + /* ID */ PAINTING_ID_CASTLE_THI_HUGE, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 40.0f, 160.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.12f, 0.07f, - /* Ripple Dispersion */ 80.0f, 60.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY_LARGE, /* Normal DList */ inside_castle_seg7_painting_dl_thi, /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 1638.4f, 1638.4f, }; const struct Painting rr_painting = { - /* id */ PAINTING_ID_CASTLE_THI_HUGE, + /* ID */ PAINTING_ID_CASTLE_THI_HUGE, /* Image Count */ 0, + /* Alpha */ 0x00, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 40.0f, 160.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.12f, 0.07f, - /* Ripple Dispersion */ 80.0f, 60.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ NULL, /* Textures */ NULL, /* Texture w, h */ 0, 0, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0x00, - /* Unused*/ 0, /* Size */ 204.8f, 204.8f, }; diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 94a5a39622..14ce705369 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -30,19 +30,14 @@ const Texture *const hmc_seg7_painting_textures_cotmc[] = { // 0x0702551C (PaintingData) const struct Painting cotmc_painting = { - /* id */ PAINTING_ID_HMC_COTMC, + /* ID */ PAINTING_ID_HMC_COTMC, /* Image Count */ 1, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_ENV_MAP, - /* passive entry */ - /* Ripple Magnitude */ 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 0.98f, - /* Ripple Rate */ 0.05f, 0.05f, - /* Ripple Dispersion */ 15.0f, 15.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, + /* Ripple Animation */ RIPPLE_ANIM_CONTINUOUS, /* Normal DList */ hmc_seg7_painting_dl_cotmc_normal, /* Textures */ hmc_seg7_painting_textures_cotmc, /* Texture w, h */ 32, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 723.968018f, 723.968018f, }; diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index 8ade39ff9d..af63ce0830 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -71,19 +71,14 @@ ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { // 0x07012F00 (PaintingData) const struct Painting ttm_slide_painting = { - /* id */ PAINTING_ID_TTM_SLIDE, + /* ID */ PAINTING_ID_TTM_SLIDE, /* Image Count */ 2, + /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, /* Normal DList */ ttm_seg7_painting_dl_slide_normal, /* Textures */ ttm_seg7_painting_textures_slide, /* Texture w, h */ 64, 32, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Alpha */ 0xFF, - /* Unused*/ 0, /* Size */ 460.8f, 460.8f, }; diff --git a/src/game/paintings.c b/src/game/paintings.c index dab76197ce..1419eaf4c8 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -85,18 +85,45 @@ struct Object *gRipplingPainting = NULL; struct Object *gEnteredPainting = NULL; /** - * HMC painting group + * Info for ripple animations. */ -struct Painting *sHmcPaintings[] = { +static const struct RippleAnimationInfo sRippleAnimationInfo[] = { + { // RIPPLE_ANIM_CONTINUOUS + /* passive entry */ + /* Ripple Magnitude */ 10.0f, 30.0f, + /* Ripple Decay */ 1.0f, 0.98f, + /* Ripple Rate */ 0.05f, 0.05f, + /* Ripple Dispersion */ 15.0f, 15.0f, + }, + { // RIPPLE_ANIM_PROXIMITY + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + }, + { // RIPPLE_ANIM_PROXIMITY_LARGE + /* passive entry */ + /* Ripple Magnitude */ 40.0f, 160.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.12f, 0.07f, + /* Ripple Dispersion */ 80.0f, 60.0f, + } +}; + +/** + * HMC painting group. + */ +const struct Painting *sHmcPaintings[] = { /*Painting ID */ /*PAINTING_ID_HMC_COTMC */ &cotmc_painting, NULL, }; /** - * Inside Castle painting group + * Inside Castle painting group. */ -struct Painting *sInsideCastlePaintings[] = { +const struct Painting *sInsideCastlePaintings[] = { /*Painting ID */ /*PAINTING_ID_CASTLE_BOB */ &bob_painting, /*PAINTING_ID_CASTLE_CCM */ &ccm_painting, @@ -117,18 +144,18 @@ struct Painting *sInsideCastlePaintings[] = { }; /** - * TTM painting group + * TTM painting group. */ -struct Painting *sTtmPaintings[] = { +const struct Painting *sTtmPaintings[] = { /*Painting ID */ /*PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, NULL, }; /** - * Array of all painting groups + * Array of all painting groups. */ -struct Painting **sPaintingGroups[] = { +const struct Painting **sPaintingGroups[] = { /*Group ID */ /*PAINTING_GROUP_HMC */ sHmcPaintings, /*PAINTING_GROUP_INSIDE_CASTLE */ sInsideCastlePaintings, @@ -160,22 +187,23 @@ UNUSED s32 get_painting_group(void) { * @param resetTimer if TRUE, set the timer to 0 */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTimer) { - struct Painting *painting = obj->oPaintingPtr; + const struct Painting *painting = obj->oPaintingPtr; + const struct RippleAnimationInfo *anim = &sRippleAnimationInfo[painting->rippleAnimationType]; // Use a different set of variables depending on the state switch (state) { case PAINTING_RIPPLE: - obj->oPaintingCurrRippleMag = painting->passiveRippleMag; - obj->oPaintingRippleDecay = painting->passiveRippleDecay; - obj->oPaintingCurrRippleRate = painting->passiveRippleRate; - obj->oPaintingDispersionFactor = painting->passiveDispersionFactor; + obj->oPaintingCurrRippleMag = anim->passiveRippleMag; + obj->oPaintingRippleDecay = anim->passiveRippleDecay; + obj->oPaintingCurrRippleRate = anim->passiveRippleRate; + obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; break; case PAINTING_ENTERED: - obj->oPaintingCurrRippleMag = painting->entryRippleMag; - obj->oPaintingRippleDecay = painting->entryRippleDecay; - obj->oPaintingCurrRippleRate = painting->entryRippleRate; - obj->oPaintingDispersionFactor = painting->entryDispersionFactor; + obj->oPaintingCurrRippleMag = anim->entryRippleMag; + obj->oPaintingRippleDecay = anim->entryRippleDecay; + obj->oPaintingCurrRippleRate = anim->entryRippleRate; + obj->oPaintingDispersionFactor = anim->entryDispersionFactor; break; } @@ -254,8 +282,9 @@ void painting_update_mario_pos(struct Object *obj) { * Automatically changes the painting back to IDLE state (or RIPPLE for continuous paintings) if the * ripple's magnitude becomes small enough. */ -void painting_update_ripple_state(struct Painting *painting) { +void painting_update_ripple_state(const struct Painting *painting) { struct Object *obj = gCurGraphNodeObjectNode; + const struct RippleAnimationInfo *anim = &sRippleAnimationInfo[painting->rippleAnimationType]; if (obj->oPaintingUpdateCounter != obj->oLastPaintingUpdateCounter) { obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; @@ -278,12 +307,12 @@ void painting_update_ripple_state(struct Painting *painting) { // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. if ((obj->oPaintingState == PAINTING_ENTERED) - && (obj->oPaintingCurrRippleMag <= painting->passiveRippleMag)) { + && (obj->oPaintingCurrRippleMag <= anim->passiveRippleMag)) { obj->oPaintingState = PAINTING_RIPPLE; - obj->oPaintingCurrRippleMag = painting->passiveRippleMag; - obj->oPaintingRippleDecay = painting->passiveRippleDecay; - obj->oPaintingCurrRippleRate = painting->passiveRippleRate; - obj->oPaintingDispersionFactor = painting->passiveDispersionFactor; + obj->oPaintingCurrRippleMag = anim->passiveRippleMag; + obj->oPaintingRippleDecay = anim->passiveRippleDecay; + obj->oPaintingCurrRippleRate = anim->passiveRippleRate; + obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; } } } @@ -307,7 +336,7 @@ void painting_update_ripple_state(struct Painting *painting) { * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_generate_mesh(struct Painting *painting, PaintingData *mesh, PaintingData numTris) { +void painting_generate_mesh(const struct Painting *painting, PaintingData *mesh, PaintingData numTris) { struct Object *obj = gCurGraphNodeObjectNode; PaintingData i, tri; @@ -582,7 +611,7 @@ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, Pa /** * Orient the painting mesh for rendering. */ -Gfx *painting_model_view_transform(struct Painting *painting) { +Gfx *painting_model_view_transform(const struct Painting *painting) { u32 commands = ( /*gSPMatrix */ 1 + /*gSPEndDisplayList */ 1 @@ -607,7 +636,7 @@ Gfx *painting_model_view_transform(struct Painting *painting) { /** * Ripple a painting that has 1 or more images that need to be mapped */ -Gfx *painting_ripple_image(struct Painting *painting, PaintingData **textureMaps) { +Gfx *painting_ripple_image(const struct Painting *painting, PaintingData **textureMaps) { PaintingData i; PaintingData meshVerts; PaintingData meshTris; @@ -657,7 +686,7 @@ Gfx *painting_ripple_image(struct Painting *painting, PaintingData **textureMaps /** * Ripple a painting that has 1 "environment map" texture. */ -Gfx *painting_ripple_env_mapped(struct Painting *painting, PaintingData **textureMaps) { +Gfx *painting_ripple_env_mapped(const struct Painting *painting, PaintingData **textureMaps) { PaintingData meshVerts; PaintingData meshTris; PaintingData *textureMap; @@ -703,7 +732,7 @@ Gfx *painting_ripple_env_mapped(struct Painting *painting, PaintingData **textur * Generates a mesh, calculates vertex normals for lighting, and renders a rippling painting. * The mesh and vertex normals are regenerated and freed every frame. */ -Gfx *display_painting_rippling(struct Painting *painting) { +Gfx *display_painting_rippling(const struct Painting *painting) { PaintingData *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); PaintingData numVtx = mesh[0]; @@ -735,7 +764,7 @@ Gfx *display_painting_rippling(struct Painting *painting) { /** * Render a normal painting. */ -Gfx *display_painting_not_rippling(struct Painting *painting) { +Gfx *display_painting_not_rippling(const struct Painting *painting) { u32 commands = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -842,7 +871,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } Gfx *paintingDlist = NULL; - struct Painting *painting = obj->oPaintingPtr; + const struct Painting *painting = obj->oPaintingPtr; if (painting == NULL) { return NULL; @@ -933,7 +962,7 @@ void bhv_painting_init(void) { return; } - struct Painting **paintingGroup = sPaintingGroups[obj->oPaintingGroup]; + const struct Painting **paintingGroup = sPaintingGroups[obj->oPaintingGroup]; obj->oPaintingPtr = segmented_to_virtual(paintingGroup[obj->oPaintingId]); Vec3f roomFloorCheckPos; diff --git a/src/game/paintings.h b/src/game/paintings.h index 83a8670b84..28e666ce76 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -77,6 +77,13 @@ enum RippleTriggers { RIPPLE_TRIGGER_CONTINUOUS, }; +// Painting->rippleAnimationType +enum PaintingRippleAnimations { + RIPPLE_ANIM_CONTINUOUS, + RIPPLE_ANIM_PROXIMITY, + RIPPLE_ANIM_PROXIMITY_LARGE, +}; + // Painting->lastFlags, Painting->currFlags, Painting->changedFlags enum PaintingRippleFlags { // Not rippling. @@ -95,52 +102,56 @@ enum PaintingType { PAINTING_ENV_MAP }; -struct Painting { - /// Id of the painting warp node. - /*0x00*/ PaintingData id; - /// How many images should be drawn when the painting is rippling. - /*0x02*/ s8 imageCount; - /// Either PAINTING_IMAGE or PAINTING_ENV_MAP - /*0x03*/ s8 textureType; - +struct RippleAnimationInfo { /// Controls how high the peaks of the ripple are. - /*0x04*/ f32 passiveRippleMag; - /*0x08*/ f32 entryRippleMag; + /*0x00*/ f32 passiveRippleMag; + /*0x04*/ f32 entryRippleMag; /// Multiplier that controls how fast the ripple regresses to the IDLE state. - /*0x0C*/ f32 passiveRippleDecay; - /*0x10*/ f32 entryRippleDecay; + /*0x08*/ f32 passiveRippleDecay; + /*0x0C*/ f32 entryRippleDecay; /// Controls the ripple's frequency - /*0x14*/ f32 passiveRippleRate; - /*0x18*/ f32 entryRippleRate; + /*0x10*/ f32 passiveRippleRate; + /*0x14*/ f32 entryRippleRate; /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple - /*0x1C*/ f32 passiveDispersionFactor; - /*0x20*/ f32 entryDispersionFactor; + /*0x18*/ f32 passiveDispersionFactor; + /*0x1C*/ f32 entryDispersionFactor; +}; /*0x20*/ - /// Display list used when the painting is not rippling. - /*0x24*/ const Gfx *normalDisplayList; +struct Painting { + /// ID of the painting and the warp node. + /*0x00*/ PaintingData id; + + /// How many images should be drawn when the painting is rippling. + /*0x02*/ PaintingData imageCount; - // Texture data - /*0x28*/ const Texture *const *textureArray; - /*0x2C*/ PaintingData textureWidth; - /*0x2E*/ PaintingData textureHeight; + /// The painting's transparency (0..255). Determines the drawing layer of the painting. + /*0x04*/ Alpha alpha; + + /// Either PAINTING_IMAGE or PAINTING_ENV_MAP. + /*0x05*/ s8 textureType; /// Controls when a passive ripple starts. RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. - /*0x30*/ s8 rippleTrigger; + /*0x06*/ s8 rippleTrigger; + + /// Which animation type to use. RIPPLE_ANIM_CONTINUOUS, RIPPLE_ANIM_PROXIMITY, or RIPPLE_ANIM_PROXIMITY_LARGE. + /*0x07*/ s8 rippleAnimationType; - /// The painting's transparency (0..255). Determines what layer the painting is in. - /*0x31*/ Alpha alpha; + /// Display list used when the painting is not rippling. + /*0x08*/ const Gfx *normalDisplayList; - /// Struct padding. - /*0x32*/ PaintingData unused; + // Texture data. + /*0x0C*/ const Texture *const *textureArray; + /*0x10*/ PaintingData textureWidth; + /*0x12*/ PaintingData textureHeight; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. /// By default a painting is 614.0f x 614.0f - /*0x34*/ f32 sizeX; - /*0x38*/ f32 sizeY; -}; /*0x3C*/ + /*0x14*/ f32 sizeX; + /*0x18*/ f32 sizeY; +}; /*0x1C*/ /** * Contains the position and normal of a vertex in the painting's generated mesh. From ee96ec74175da5edec99d776b0b1cf53bfdd937c Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 9 Aug 2022 22:28:53 -0700 Subject: [PATCH 10/81] Remove extra newline --- levels/castle_inside/painting.inc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 54d0bb2b49..5719813931 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -392,7 +392,6 @@ const struct Painting bob_painting = { /* ID */ PAINTING_ID_CASTLE_BOB, /* Image Count */ 2, /* Alpha */ 0xFF, - /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, From f9cbf8f59cf265532e009c2dc051b23c8251d1c3 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 10 Aug 2022 15:59:15 -0700 Subject: [PATCH 11/81] Use defines for fake CCM paintings' coords --- levels/castle_inside/painting.inc.c | 68 +++++++++++++++++------------ 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 5719813931..964a06edc0 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -1,7 +1,7 @@ #include "game/paintings.h" // 0x07021818 - 0x07021898 -static const Vtx inside_castle_seg7_vertex_painting_textured[] = { +static const Vtx inside_castle_seg7_vertex_painting_textured_lighting[] = { {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, @@ -13,7 +13,7 @@ static const Vtx inside_castle_seg7_vertex_painting_textured[] = { }; // 0x07021898 - 0x07021918 -static const Vtx inside_castle_seg7_vertex_painting_sl[] = { +static const Vtx inside_castle_seg7_vertex_painting_textured_vertex_colored[] = { {{{ 0, 0, 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, @@ -24,28 +24,38 @@ static const Vtx inside_castle_seg7_vertex_painting_sl[] = { {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, }; +#define CCM_FAKE_1_X -3046 +#define CCM_FAKE_1_Z -3724 +#define CCM_FAKE_1_DX 304 // PAINTING_SIZE * sin(yaw) +#define CCM_FAKE_1_DZ -534 // PAINTING_SIZE * cos(yaw) + // 0x07021918 - 0x07021998 static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_1[] = { - {{{ -3046, -(PAINTING_SIZE / 2), -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, -(PAINTING_SIZE / 2), -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, 0, -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -3046, 0, -3724}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -3046, 0, -3724}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, 0, -4258}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -2742, (PAINTING_SIZE / 2), -4258}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -3046, (PAINTING_SIZE / 2), -3724}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + 0), -(PAINTING_SIZE / 2), (CCM_FAKE_1_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), -(PAINTING_SIZE / 2), (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), 0, (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + 0), 0, (CCM_FAKE_1_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + 0), 0, (CCM_FAKE_1_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), 0, (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), (PAINTING_SIZE / 2), (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + 0), (PAINTING_SIZE / 2), (CCM_FAKE_1_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; +#define CCM_FAKE_2_X -1866 +#define CCM_FAKE_2_Z -4258 +#define CCM_FAKE_2_DX 304 // PAINTING_SIZE * sin(yaw) +#define CCM_FAKE_2_DZ 534 // PAINTING_SIZE * cos(yaw) + // 0x07021998 - 0x07021A18 static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_2[] = { - {{{ -1866, -(PAINTING_SIZE / 2), -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, -(PAINTING_SIZE / 2), -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, 0, -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1866, 0, -4258}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1866, 0, -4258}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, 0, -3724}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1562, (PAINTING_SIZE / 2), -3724}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ -1866, (PAINTING_SIZE / 2), -4258}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + 0), -(PAINTING_SIZE / 2), (CCM_FAKE_2_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), -(PAINTING_SIZE / 2), (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), 0, (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + 0), 0, (CCM_FAKE_2_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + 0), 0, (CCM_FAKE_2_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), 0, (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), (PAINTING_SIZE / 2), (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + 0), (PAINTING_SIZE / 2), (CCM_FAKE_2_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x07021A18 - 0x07021A30 @@ -94,7 +104,7 @@ static const Vtx inside_castle_seg7_vertex_hmc[] = { // 0x07023050 - 0x070230B0 static const Gfx inside_castle_seg7_painting_dl_bob[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700B800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -110,7 +120,7 @@ static const Gfx inside_castle_seg7_painting_dl_bob[] = { // 0x070230B0 - 0x07023110 static const Gfx inside_castle_seg7_painting_dl_ccm[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -126,7 +136,7 @@ static const Gfx inside_castle_seg7_painting_dl_ccm[] = { // 0x07023110 - 0x07023170 static const Gfx inside_castle_seg7_painting_dl_wf[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700F800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -142,7 +152,7 @@ static const Gfx inside_castle_seg7_painting_dl_wf[] = { // 0x07023170 - 0x070231D0 static const Gfx inside_castle_seg7_painting_dl_jrb[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07011800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -158,7 +168,7 @@ static const Gfx inside_castle_seg7_painting_dl_jrb[] = { // 0x070231D0 - 0x07023230 static const Gfx inside_castle_seg7_painting_dl_lll[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07012800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -174,7 +184,7 @@ static const Gfx inside_castle_seg7_painting_dl_lll[] = { // 0x07023230 - 0x07023290 static const Gfx inside_castle_seg7_painting_dl_ssl[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07015800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -190,7 +200,7 @@ static const Gfx inside_castle_seg7_painting_dl_ssl[] = { // 0x07023290 - 0x070232F0 static const Gfx inside_castle_seg7_painting_dl_wdw[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07018800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -206,7 +216,7 @@ static const Gfx inside_castle_seg7_painting_dl_wdw[] = { // 0x070232F0 - 0x07023350 static const Gfx inside_castle_seg7_painting_dl_thi[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701A800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -222,7 +232,7 @@ static const Gfx inside_castle_seg7_painting_dl_thi[] = { // 0x07023350 - 0x070233B0 static const Gfx inside_castle_seg7_painting_dl_ttm[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701C800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -238,7 +248,7 @@ static const Gfx inside_castle_seg7_painting_dl_ttm[] = { // 0x070233B0 - 0x07023410 static const Gfx inside_castle_seg7_painting_dl_ttc[] = { gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701E800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), @@ -261,7 +271,7 @@ static const Gfx inside_castle_seg7_painting_dl_sl[] = { gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPVertex(inside_castle_seg7_vertex_painting_sl, 8, 0), + gsSPVertex(inside_castle_seg7_vertex_painting_textured_vertex_colored, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07020800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), From 168293d3bc445e1ddc3643e2d3e42dbe2c0a3a86 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 10 Aug 2022 16:01:37 -0700 Subject: [PATCH 12/81] Some paintings.c refactoring --- src/game/paintings.c | 190 +++++++++++++++++++++---------------------- src/game/paintings.h | 8 +- 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 1419eaf4c8..08761c10e4 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -61,56 +61,6 @@ * A CONTINUOUS painting will automatically reset to RIPPLE if its ripple magnitude becomes small enough. */ -/** - * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. - * - * This mesh only contains the vertex positions and normals. - * Paintings use an additional array to map textures to the mesh. - */ -struct PaintingMeshVertex *gPaintingMesh; - -/** - * The painting's surface normals, used to approximate each of the vertex normals (for gouraud shading). - */ -Vec3f *gPaintingTriNorms; - -/** - * The painting that is currently rippling. Only one painting can be rippling at once. - */ -struct Object *gRipplingPainting = NULL; - -/** - * The id of the painting Mario has entered. - */ -struct Object *gEnteredPainting = NULL; - -/** - * Info for ripple animations. - */ -static const struct RippleAnimationInfo sRippleAnimationInfo[] = { - { // RIPPLE_ANIM_CONTINUOUS - /* passive entry */ - /* Ripple Magnitude */ 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 0.98f, - /* Ripple Rate */ 0.05f, 0.05f, - /* Ripple Dispersion */ 15.0f, 15.0f, - }, - { // RIPPLE_ANIM_PROXIMITY - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, - }, - { // RIPPLE_ANIM_PROXIMITY_LARGE - /* passive entry */ - /* Ripple Magnitude */ 40.0f, 160.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.12f, 0.07f, - /* Ripple Dispersion */ 80.0f, 60.0f, - } -}; - /** * HMC painting group. */ @@ -155,13 +105,63 @@ const struct Painting *sTtmPaintings[] = { /** * Array of all painting groups. */ -const struct Painting **sPaintingGroups[] = { +const struct Painting * const* sPaintingGroups[] = { /*Group ID */ /*PAINTING_GROUP_HMC */ sHmcPaintings, /*PAINTING_GROUP_INSIDE_CASTLE */ sInsideCastlePaintings, /*PAINTING_GROUP_TTM */ sTtmPaintings, }; +/** + * The painting that is currently rippling. Only one painting can be rippling at once. + */ +struct Object *gRipplingPainting = NULL; + +/** + * The id of the painting Mario has entered. + */ +struct Object *gEnteredPainting = NULL; + +/** + * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. + * + * This mesh only contains the vertex positions and normals. + * Paintings use an additional array to map textures to the mesh. + */ +static struct PaintingMeshVertex *sPaintingMesh; + +/** + * The painting's surface normals, used to approximate each of the vertex normals (for gouraud shading). + */ +static Vec3f *sPaintingTriNorms; + +/** + * Info for ripple animations. + */ +static const struct RippleAnimationInfo sRippleAnimationInfo[] = { + { // RIPPLE_ANIM_CONTINUOUS + /* passive entry */ + /* Ripple Magnitude */ 10.0f, 30.0f, + /* Ripple Decay */ 1.0f, 0.98f, + /* Ripple Rate */ 0.05f, 0.05f, + /* Ripple Dispersion */ 15.0f, 15.0f, + }, + { // RIPPLE_ANIM_PROXIMITY + /* passive entry */ + /* Ripple Magnitude */ 20.0f, 80.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.24f, 0.14f, + /* Ripple Dispersion */ 40.0f, 30.0f, + }, + { // RIPPLE_ANIM_PROXIMITY_LARGE + /* passive entry */ + /* Ripple Magnitude */ 40.0f, 160.0f, + /* Ripple Decay */ 0.9608f, 0.9524f, + /* Ripple Rate */ 0.12f, 0.07f, + /* Ripple Dispersion */ 80.0f, 60.0f, + } +}; + /** * Get the painting group from gCurrLevelNum. */ @@ -252,12 +252,12 @@ void painting_update_mario_pos(struct Object *obj) { && marioLocalPos[0] < (obj->oPaintingPtr->sizeX + PAINTING_EDGE_MARGIN) && marioLocalPos[1] > -PAINTING_EDGE_MARGIN && marioLocalPos[1] < (obj->oPaintingPtr->sizeY + PAINTING_EDGE_MARGIN)) { - // Check whether Mario is in the wobble zone. + // Check whether Mario is inside the wobble zone. if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH && marioLocalPos[2] > 0.0f) { rippleFlags |= RIPPLE_FLAG_RIPPLE; } - // Check whether Mario is in the warp zone. + // Check whether Mario is inside the warp zone. if (marioLocalPos[2] < 0.0f && marioLocalPos[2] > -PAINTING_WARP_DEPTH) { rippleFlags |= RIPPLE_FLAG_ENTER; @@ -265,6 +265,7 @@ void painting_update_mario_pos(struct Object *obj) { } s8 lastFlags = obj->oPaintingCurrFlags; + // At most 1 of these will be nonzero. obj->oPaintingCurrFlags = rippleFlags; @@ -336,13 +337,13 @@ void painting_update_ripple_state(const struct Painting *painting) { * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_generate_mesh(const struct Painting *painting, PaintingData *mesh, PaintingData numTris) { +void painting_generate_mesh(const struct Painting *painting, const PaintingData *mesh, PaintingData numTris) { struct Object *obj = gCurGraphNodeObjectNode; PaintingData i, tri; - gPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(struct PaintingMeshVertex))); + sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(struct PaintingMeshVertex))); - struct PaintingMeshVertex *paintingMesh = gPaintingMesh; + struct PaintingMeshVertex *paintingMesh = sPaintingMesh; /// Controls the peaks of the ripple. f32 rippleMag = obj->oPaintingCurrRippleMag; @@ -410,23 +411,23 @@ void painting_generate_mesh(const struct Painting *painting, PaintingData *mesh, * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(PaintingData *mesh, PaintingData numVtx, PaintingData numTris) { +void painting_calculate_triangle_normals(const PaintingData *mesh, PaintingData numVtx, PaintingData numTris) { PaintingData i; Vec3s v; Vec3f vp0, vp1, vp2; - gPaintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); + sPaintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); for (i = 0; i < numTris; i++) { // Add 2 because of the 2 length entries preceding the list. PaintingData tri = ((numVtx * 3) + (i * 3) + 2); vec3s_copy(v, &mesh[tri]); - vec3s_to_vec3f(vp0, gPaintingMesh[v[0]].pos); - vec3s_to_vec3f(vp1, gPaintingMesh[v[1]].pos); - vec3s_to_vec3f(vp2, gPaintingMesh[v[2]].pos); + vec3s_to_vec3f(vp0, sPaintingMesh[v[0]].pos); + vec3s_to_vec3f(vp1, sPaintingMesh[v[1]].pos); + vec3s_to_vec3f(vp2, sPaintingMesh[v[2]].pos); // Cross product to find each triangle's normal vector. - find_vector_perpendicular_to_plane(gPaintingTriNorms[i], vp0, vp1, vp2); + find_vector_perpendicular_to_plane(sPaintingTriNorms[i], vp0, vp1, vp2); } } @@ -440,12 +441,12 @@ void painting_calculate_triangle_normals(PaintingData *mesh, PaintingData numVtx * The table is a list of entries in this format: * numNeighbors, tri0, tri1, ..., triN * - * Where each 'tri' is an index into gPaintingTriNorms. - * Entry i in `neighborTris` corresponds to the vertex at gPaintingMesh[i] + * Where each 'tri' is an index into sPaintingTriNorms. + * Entry i in `neighborTris` corresponds to the vertex at sPaintingMesh[i] * * The table used in game, seg2_painting_mesh_neighbor_tris, is in bin/segment2.c. */ -void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData numVtx) { +void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingData numVtx) { PaintingData tri; PaintingData i, j; PaintingData neighbors; @@ -458,8 +459,9 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu neighbors = neighborTris[entry]; for (j = 0; j < neighbors; j++) { tri = neighborTris[entry + j + 1]; - vec3f_add(n, gPaintingTriNorms[tri]); + vec3f_add(n, sPaintingTriNorms[tri]); } + // Move to the next vertex's entry entry += (neighbors + 1); @@ -469,9 +471,9 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu if (FLT_IS_NONZERO(nlen)) { nlen = (127.0f / sqrtf(nlen)); - vec3_prod_val(gPaintingMesh[i].norm, n, nlen); + vec3_prod_val(sPaintingMesh[i].norm, n, nlen); } else { - vec3_zero(gPaintingMesh[i].norm); + vec3_zero(sPaintingMesh[i].norm); } } } @@ -481,8 +483,8 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu #else #define VTX_BUF_MAX 16 #endif -#define TRI_PER_DL (VTX_BUF_MAX / 3) // 5 | 10 -#define VTX_PER_DL (TRI_PER_DL * 3) // 15 | 30 +#define TRI_PER_DL (VTX_BUF_MAX / 3) // 5 or 10 +#define VTX_PER_DL (TRI_PER_DL * 3) // 15 or 30 /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, @@ -491,7 +493,7 @@ void painting_average_vertex_normals(PaintingData *neighborTris, PaintingData nu * If the textureMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole * painting. */ -Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, PaintingData *textureMap, PaintingData mapVerts, PaintingData mapTris, Alpha alpha) { +Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeight, const PaintingData *textureMap, PaintingData mapVerts, PaintingData mapTris, Alpha alpha) { struct PaintingMeshVertex *mesh = NULL; PaintingData group; PaintingData groupIndex; @@ -547,7 +549,7 @@ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, Pa ty = textureMap[mapping + 3]; // Get a pointer to the current mesh. - mesh = &gPaintingMesh[meshVtx]; + mesh = &sPaintingMesh[meshVtx]; // Map the texture and place it in the verts array. make_vertex(verts, (groupIndex + map), @@ -576,7 +578,7 @@ Gfx *render_painting(Texture *img, PaintingData tWidth, PaintingData tHeight, Pa tx = textureMap[mapping + 2]; ty = textureMap[mapping + 3]; - mesh = &gPaintingMesh[meshVtx]; + mesh = &sPaintingMesh[meshVtx]; make_vertex(verts, ((triGroups * VTX_PER_DL) + map), mesh->pos[0], mesh->pos[1], @@ -636,15 +638,15 @@ Gfx *painting_model_view_transform(const struct Painting *painting) { /** * Ripple a painting that has 1 or more images that need to be mapped */ -Gfx *painting_ripple_image(const struct Painting *painting, PaintingData **textureMaps) { +Gfx *painting_ripple_image(const struct Painting *painting, const PaintingData **textureMaps) { PaintingData i; PaintingData meshVerts; PaintingData meshTris; - PaintingData *textureMap; + const PaintingData *textureMap; PaintingData imageCount = painting->imageCount; PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; - Texture **textures = segmented_to_virtual(painting->textureArray); + const Texture **textures = segmented_to_virtual(painting->textureArray); u32 commands = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -686,13 +688,13 @@ Gfx *painting_ripple_image(const struct Painting *painting, PaintingData **textu /** * Ripple a painting that has 1 "environment map" texture. */ -Gfx *painting_ripple_env_mapped(const struct Painting *painting, PaintingData **textureMaps) { +Gfx *painting_ripple_env_mapped(const struct Painting *painting, const PaintingData **textureMaps) { PaintingData meshVerts; PaintingData meshTris; - PaintingData *textureMap; + const PaintingData *textureMap; PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; - Texture **tArray = segmented_to_virtual(painting->textureArray); + const Texture **tArray = segmented_to_virtual(painting->textureArray); u32 commands = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -733,8 +735,8 @@ Gfx *painting_ripple_env_mapped(const struct Painting *painting, PaintingData ** * The mesh and vertex normals are regenerated and freed every frame. */ Gfx *display_painting_rippling(const struct Painting *painting) { - PaintingData *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); - PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); + const PaintingData *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); + const PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); PaintingData numVtx = mesh[0]; PaintingData numTris = mesh[(numVtx * 3) + 1]; Gfx *dlist = NULL; @@ -755,8 +757,8 @@ Gfx *display_painting_rippling(const struct Painting *painting) { } // The mesh data is freed every frame. - mem_pool_free(gEffectsMemoryPool, gPaintingMesh); - mem_pool_free(gEffectsMemoryPool, gPaintingTriNorms); + mem_pool_free(gEffectsMemoryPool, sPaintingMesh); + mem_pool_free(gEffectsMemoryPool, sPaintingTriNorms); return dlist; } @@ -907,11 +909,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con && painting->textureHeight > 0 && painting->alpha > 0) { // Determine whether the painting is opaque or transparent. - if (painting->alpha == 0xFF) { - SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); - } else { - SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_TRANSPARENT); - } + gen->fnNode.node.drawingLayer = ((painting->alpha == 0xFF) ? LAYER_OCCLUDE_SILHOUETTE_OPAQUE : LAYER_TRANSPARENT); if (obj->oPaintingState == PAINTING_IDLE) { paintingDlist = display_painting_not_rippling(painting); @@ -962,11 +960,9 @@ void bhv_painting_init(void) { return; } - const struct Painting **paintingGroup = sPaintingGroups[obj->oPaintingGroup]; + const struct Painting * const* paintingGroup = sPaintingGroups[obj->oPaintingGroup]; obj->oPaintingPtr = segmented_to_virtual(paintingGroup[obj->oPaintingId]); - Vec3f roomFloorCheckPos; - // The center of the painting, but with a z offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { (obj->oPaintingPtr->sizeX * 0.5f), @@ -978,13 +974,15 @@ void bhv_painting_init(void) { Vec3s rotation; vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); - // Set 'roomFloorCheckPos' to the world space coords of 'distPos'. - vec3f_local_pos_to_world_pos(roomFloorCheckPos, distPos, &obj->oPosVec, rotation); + Vec3f roomCheckPos; + + // Set 'roomCheckPos' to the world space coords of 'distPos'. + vec3f_local_pos_to_world_pos(roomCheckPos, distPos, &obj->oPosVec, rotation); // Set the object's room so that paintings only render in their room. - obj->oRoom = get_room_at_pos(roomFloorCheckPos[0], - roomFloorCheckPos[1], - roomFloorCheckPos[2]); + obj->oRoom = get_room_at_pos(roomCheckPos[0], + roomCheckPos[1], + roomCheckPos[2]); } void bhv_painting_loop(void) { diff --git a/src/game/paintings.h b/src/game/paintings.h index 28e666ce76..cf08546e08 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -7,6 +7,7 @@ #include "macros.h" #include "types.h" + /// Use to properly set a GraphNodeGenerated's parameter to point to the right painting. /// Use this for both bparam1 and bparam2 for painting objects. #define PAINTING_ID(id, grp) ((id) | ((grp) << 8)) @@ -26,6 +27,7 @@ /// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. #define PAINTING_MARIO_Y_OFFSET 50 + // HMC painting group enum HMCPaintingIDs { /* 0*/ PAINTING_ID_HMC_COTMC, @@ -102,6 +104,7 @@ enum PaintingType { PAINTING_ENV_MAP }; + struct RippleAnimationInfo { /// Controls how high the peaks of the ripple are. /*0x00*/ f32 passiveRippleMag; @@ -161,14 +164,15 @@ struct PaintingMeshVertex { /*0x06*/ Vec3c norm; }; /*0x0C*/ -extern struct PaintingMeshVertex *gPaintingMesh; -extern Vec3f *gPaintingTriNorms; + extern struct Object *gRipplingPainting; extern struct Object *gEnteredPainting; + Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); void bhv_painting_init(void); void bhv_painting_loop(void); + #endif // PAINTINGS_H From 5e992b540aca8c34a4092da8851b1a6cfd289f9f Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 10 Aug 2022 16:04:23 -0700 Subject: [PATCH 13/81] Revert change that was using unimplemented functionality in geo_painting_draw --- src/game/paintings.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 08761c10e4..0d6acd76e4 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -903,13 +903,17 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con // Draw the painting. if (painting->imageCount > 0 + && painting->alpha > 0 && painting->normalDisplayList != NULL && painting->textureArray != NULL && painting->textureWidth > 0 - && painting->textureHeight > 0 - && painting->alpha > 0) { + && painting->textureHeight > 0) { // Determine whether the painting is opaque or transparent. - gen->fnNode.node.drawingLayer = ((painting->alpha == 0xFF) ? LAYER_OCCLUDE_SILHOUETTE_OPAQUE : LAYER_TRANSPARENT); + if (painting->alpha == 0xFF) { + SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); + } else { + SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_TRANSPARENT); + } if (obj->oPaintingState == PAINTING_IDLE) { paintingDlist = display_painting_not_rippling(painting); From df051e3ad3a7e4b0b8f73a20deeba6a5f6752daa Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 10 Aug 2022 17:03:03 -0700 Subject: [PATCH 14/81] Partially update main paintings.c comment + more formatting --- src/game/paintings.c | 122 +++++++++++++++++++------------------------ src/game/paintings.h | 80 +++++++++++++++------------- 2 files changed, 100 insertions(+), 102 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 0d6acd76e4..254c436fd1 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -23,24 +23,17 @@ /** * @file paintings.c * - * Implements the rippling painting effect. Paintings are GraphNodes that exist without being connected - * to any particular object. + * Implements the rippling painting effect. Paintings are GraphNodes that are attached to a bhvPainting object. * * Paintings are defined in level data. Look at levels/castle_inside/painting.inc.c for examples. * * The ripple effect uses data that is split into several parts: - * The mesh positions are generated from a base mesh. See seg2_painting_triangle_mesh near the - * bottom of bin/segment2.c - * - * The lighting for the ripple is also generated from a base table, seg2_painting_mesh_neighbor_tris - * in bin/segment2.c - * - * Each painting's texture uses yet another table to map its texture to the mesh. - * These maps are in level data, see levels/castle_inside/painting.inc.c for example. - * - * Finally, each painting has two display lists, normal and rippling, which are defined in the same - * level data file as the Painting itself. See levels/castle_inside/painting.inc.c. - * + * In bin/segment2.c: + * seg2_painting_triangle_mesh: The mesh positions are generated from a base mesh. + * seg2_painting_mesh_neighbor_tris: The lighting for the ripple is also generated from a base table. + * Each painting's texture uses yet another table to map its texture to the mesh. + * In levels/[LEVEL]/painting.inc.c: + * Painting structs, texture pointers, non-ripple display lists. * * Painting state machine: * Paintings spawn in the PAINTING_IDLE state @@ -49,8 +42,7 @@ * reset to IDLE * * Paintings in the PAINTING_RIPPLE state are passively rippling. - * For RIPPLE_TRIGGER_PROXIMITY paintings, this means Mario bumped the wall in front of the - * painting. + * For RIPPLE_TRIGGER_PROXIMITY paintings, this means Mario bumped the front of the painting. * * Paintings that use RIPPLE_TRIGGER_CONTINUOUS try to transition to this state as soon as possible, * usually when Mario enters the room. @@ -65,8 +57,8 @@ * HMC painting group. */ const struct Painting *sHmcPaintings[] = { - /*Painting ID */ - /*PAINTING_ID_HMC_COTMC */ &cotmc_painting, + /* Painting ID */ + /* PAINTING_ID_HMC_COTMC */ &cotmc_painting, NULL, }; @@ -74,22 +66,22 @@ const struct Painting *sHmcPaintings[] = { * Inside Castle painting group. */ const struct Painting *sInsideCastlePaintings[] = { - /*Painting ID */ - /*PAINTING_ID_CASTLE_BOB */ &bob_painting, - /*PAINTING_ID_CASTLE_CCM */ &ccm_painting, - /*PAINTING_ID_CASTLE_WF */ &wf_painting, - /*PAINTING_ID_CASTLE_JRB */ &jrb_painting, - /*PAINTING_ID_CASTLE_LLL */ &lll_painting, - /*PAINTING_ID_CASTLE_SSL */ &ssl_painting, - /*PAINTING_ID_CASTLE_HMC */ &hmc_painting, - /*PAINTING_ID_CASTLE_DDD */ &ddd_painting, - /*PAINTING_ID_CASTLE_WDW */ &wdw_painting, - /*PAINTING_ID_CASTLE_THI_TINY */ &thi_tiny_painting, - /*PAINTING_ID_CASTLE_TTM */ &ttm_painting, - /*PAINTING_ID_CASTLE_TTC */ &ttc_painting, - /*PAINTING_ID_CASTLE_SL */ &sl_painting, - /*PAINTING_ID_CASTLE_THI_HUGE */ &thi_huge_painting, - /*PAINTING_ID_CASTLE_RR */ &rr_painting, + /* Painting ID */ + /* PAINTING_ID_CASTLE_BOB */ &bob_painting, + /* PAINTING_ID_CASTLE_CCM */ &ccm_painting, + /* PAINTING_ID_CASTLE_WF */ &wf_painting, + /* PAINTING_ID_CASTLE_JRB */ &jrb_painting, + /* PAINTING_ID_CASTLE_LLL */ &lll_painting, + /* PAINTING_ID_CASTLE_SSL */ &ssl_painting, + /* PAINTING_ID_CASTLE_HMC */ &hmc_painting, + /* PAINTING_ID_CASTLE_DDD */ &ddd_painting, + /* PAINTING_ID_CASTLE_WDW */ &wdw_painting, + /* PAINTING_ID_CASTLE_THI_TINY */ &thi_tiny_painting, + /* PAINTING_ID_CASTLE_TTM */ &ttm_painting, + /* PAINTING_ID_CASTLE_TTC */ &ttc_painting, + /* PAINTING_ID_CASTLE_SL */ &sl_painting, + /* PAINTING_ID_CASTLE_THI_HUGE */ &thi_huge_painting, + /* PAINTING_ID_CASTLE_RR */ &rr_painting, NULL, }; @@ -97,8 +89,8 @@ const struct Painting *sInsideCastlePaintings[] = { * TTM painting group. */ const struct Painting *sTtmPaintings[] = { - /*Painting ID */ - /*PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, + /* Painting ID */ + /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, NULL, }; @@ -106,10 +98,10 @@ const struct Painting *sTtmPaintings[] = { * Array of all painting groups. */ const struct Painting * const* sPaintingGroups[] = { - /*Group ID */ - /*PAINTING_GROUP_HMC */ sHmcPaintings, - /*PAINTING_GROUP_INSIDE_CASTLE */ sInsideCastlePaintings, - /*PAINTING_GROUP_TTM */ sTtmPaintings, + /* Group ID */ + /* PAINTING_GROUP_HMC */ sHmcPaintings, + /* PAINTING_GROUP_INSIDE_CASTLE */ sInsideCastlePaintings, + /* PAINTING_GROUP_TTM */ sTtmPaintings, }; /** @@ -833,25 +825,24 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) return; #endif // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected. - u32 bowsersSubBeaten = (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1); - // Get the other save file flags and check whether DDD has already moved back. - u32 dddBack = (save_file_get_flags() & SAVE_FLAG_DDD_MOVED_BACK); - - if (!bowsersSubBeaten && !dddBack) { - // If we haven't collected the star or moved the painting, put the painting at the front. - obj->oPosX = frontPos; - } else if (bowsersSubBeaten && !dddBack) { - // If we've collected the star but not moved the painting back, - // Each frame, move the painting by a certain speed towards the back area. - obj->oPosX += speed; - if (obj->oPosX >= backPos) { + if (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1) { + // Get the other save file flags and check whether DDD has already moved back. + if (save_file_get_flags() & SAVE_FLAG_DDD_MOVED_BACK) { + // If the painting has already moved back, place it in the back position. obj->oPosX = backPos; - // Tell the save file that we've moved DDD back. - save_file_set_flags(SAVE_FLAG_DDD_MOVED_BACK); + } else { + // If we've collected the star but not moved the painting back, + // Each frame, move the painting by a certain speed towards the back area. + obj->oPosX += speed; + if (obj->oPosX >= backPos) { + obj->oPosX = backPos; + // Tell the save file that we've moved DDD back. + save_file_set_flags(SAVE_FLAG_DDD_MOVED_BACK); + } } - } else if (bowsersSubBeaten && dddBack) { - // If the painting has already moved back, place it in the back position. - obj->oPosX = backPos; + } else { + // If we haven't collected the star, put the painting at the front. + obj->oPosX = frontPos; } } @@ -923,20 +914,18 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + // Proximity type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - // Proximity painting enter ripple. - painting_state(obj, PAINTING_ENTERED, FALSE, TRUE); + painting_state(obj, PAINTING_ENTERED, FALSE, TRUE); // Entering } else if (obj->oPaintingState != PAINTING_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - // Proximity painting wobble ripple. - painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE); + painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE); // Wobbling } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + // Continuous type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - // Continuous painting enter ripple. - painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); + painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); // Entering } else if (obj->oPaintingState == PAINTING_IDLE) { - // Continuous painting idle ripple. - painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE); + painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE); // Idle } } @@ -978,9 +967,8 @@ void bhv_painting_init(void) { Vec3s rotation; vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); - Vec3f roomCheckPos; - // Set 'roomCheckPos' to the world space coords of 'distPos'. + Vec3f roomCheckPos; vec3f_local_pos_to_world_pos(roomCheckPos, distPos, &obj->oPosVec, rotation); // Set the object's room so that paintings only render in their room. diff --git a/src/game/paintings.h b/src/game/paintings.h index cf08546e08..53ed444cc5 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -30,47 +30,52 @@ // HMC painting group enum HMCPaintingIDs { - /* 0*/ PAINTING_ID_HMC_COTMC, + /* Painting ID */ + /* 0 */ PAINTING_ID_HMC_COTMC, }; // Inside Castle painting group enum CastlePaintingIDs { - /* 0*/ PAINTING_ID_CASTLE_BOB, - /* 1*/ PAINTING_ID_CASTLE_CCM, - /* 2*/ PAINTING_ID_CASTLE_WF, - /* 3*/ PAINTING_ID_CASTLE_JRB, - /* 4*/ PAINTING_ID_CASTLE_LLL, - /* 5*/ PAINTING_ID_CASTLE_SSL, - /* 6*/ PAINTING_ID_CASTLE_HMC, - /* 7*/ PAINTING_ID_CASTLE_DDD, - /* 8*/ PAINTING_ID_CASTLE_WDW, - /* 9*/ PAINTING_ID_CASTLE_THI_TINY, - /*10*/ PAINTING_ID_CASTLE_TTM, - /*11*/ PAINTING_ID_CASTLE_TTC, - /*12*/ PAINTING_ID_CASTLE_SL, - /*13*/ PAINTING_ID_CASTLE_THI_HUGE, - /*14*/ PAINTING_ID_CASTLE_RR, + /* Painting ID */ + /* 0 */ PAINTING_ID_CASTLE_BOB, + /* 1 */ PAINTING_ID_CASTLE_CCM, + /* 2 */ PAINTING_ID_CASTLE_WF, + /* 3 */ PAINTING_ID_CASTLE_JRB, + /* 4 */ PAINTING_ID_CASTLE_LLL, + /* 5 */ PAINTING_ID_CASTLE_SSL, + /* 6 */ PAINTING_ID_CASTLE_HMC, + /* 7 */ PAINTING_ID_CASTLE_DDD, + /* 8 */ PAINTING_ID_CASTLE_WDW, + /* 9 */ PAINTING_ID_CASTLE_THI_TINY, + /* 10 */ PAINTING_ID_CASTLE_TTM, + /* 11 */ PAINTING_ID_CASTLE_TTC, + /* 12 */ PAINTING_ID_CASTLE_SL, + /* 13 */ PAINTING_ID_CASTLE_THI_HUGE, + /* 14 */ PAINTING_ID_CASTLE_RR, }; // TTM painting group enum TTMPaintingIDs { - /* 0*/ PAINTING_ID_TTM_SLIDE, + /* Painting ID */ + /* 0 */ PAINTING_ID_TTM_SLIDE, }; -// Painting group ids +// Painting group IDs enum PaintingGroups { - /* 0*/ PAINTING_GROUP_HMC, - /* 1*/ PAINTING_GROUP_INSIDE_CASTLE, - /* 2*/ PAINTING_GROUP_TTM, + /* Group ID */ + /* 0 */ PAINTING_GROUP_HMC, + /* 1 */ PAINTING_GROUP_INSIDE_CASTLE, + /* 2 */ PAINTING_GROUP_TTM, PAINTING_NUM_GROUPS, PAINTING_GROUP_NULL = -1, }; -// Painting->state -enum PaintingState { - PAINTING_IDLE, - PAINTING_RIPPLE, - PAINTING_ENTERED, +// Painting->textureType +enum PaintingType { + /// Painting that uses 1 or more images as a texture + PAINTING_IMAGE, + /// Painting that has one texture used for an environment map effect + PAINTING_ENV_MAP }; // Painting->rippleTrigger @@ -86,7 +91,7 @@ enum PaintingRippleAnimations { RIPPLE_ANIM_PROXIMITY_LARGE, }; -// Painting->lastFlags, Painting->currFlags, Painting->changedFlags +// oPaintingCurrFlags, oPaintingChangedFlags enum PaintingRippleFlags { // Not rippling. RIPPLE_FLAGS_NONE = 0x0, @@ -96,15 +101,17 @@ enum PaintingRippleFlags { RIPPLE_FLAG_RIPPLE = BIT(1), // 0x02 }; -// Painting->textureType -enum PaintingType { - /// Painting that uses 1 or more images as a texture - PAINTING_IMAGE, - /// Painting that has one texture used for an environment map effect - PAINTING_ENV_MAP +// oPaintingState +enum PaintingState { + PAINTING_IDLE, + PAINTING_RIPPLE, + PAINTING_ENTERED, }; +/** + * A list of preset constants for the ripple animation. + */ struct RippleAnimationInfo { /// Controls how high the peaks of the ripple are. /*0x00*/ f32 passiveRippleMag; @@ -114,15 +121,18 @@ struct RippleAnimationInfo { /*0x08*/ f32 passiveRippleDecay; /*0x0C*/ f32 entryRippleDecay; - /// Controls the ripple's frequency + /// Controls the ripple's frequency. /*0x10*/ f32 passiveRippleRate; /*0x14*/ f32 entryRippleRate; - /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple + /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple. /*0x18*/ f32 passiveDispersionFactor; /*0x1C*/ f32 entryDispersionFactor; }; /*0x20*/ +/** + * Painting info struct. + */ struct Painting { /// ID of the painting and the warp node. /*0x00*/ PaintingData id; From c3304316036cc4ac8a76ae490039add74e4c1002 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 10 Aug 2022 18:49:28 -0700 Subject: [PATCH 15/81] Rename 'commands' to 'gfxCmds' --- src/game/paintings.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 254c436fd1..1fcb2c2389 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -502,7 +502,7 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig PaintingData numVtx = (mapTris * 3); Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); - u32 commands = ( + u32 gfxCmds = ( /*gLoadBlockTexture */ 5 + (triGroups * ( /*gSPVertex */ 1 + @@ -514,7 +514,7 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig )) + /*gSPEndDisplayList */ 1 ); - Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); + Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); @@ -606,11 +606,11 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig * Orient the painting mesh for rendering. */ Gfx *painting_model_view_transform(const struct Painting *painting) { - u32 commands = ( + u32 gfxCmds = ( /*gSPMatrix */ 1 + /*gSPEndDisplayList */ 1 ); - Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); + Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; // Scale @@ -639,7 +639,7 @@ Gfx *painting_ripple_image(const struct Painting *painting, const PaintingData * PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; const Texture **textures = segmented_to_virtual(painting->textureArray); - u32 commands = ( + u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + (imageCount * ( @@ -649,7 +649,7 @@ Gfx *painting_ripple_image(const struct Painting *painting, const PaintingData * /*gSPDisplayList */ 1 + /*gSPEndDisplayList */ 1 ); - Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); + Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { @@ -687,7 +687,7 @@ Gfx *painting_ripple_env_mapped(const struct Painting *painting, const PaintingD PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; const Texture **tArray = segmented_to_virtual(painting->textureArray); - u32 commands = ( + u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -695,7 +695,7 @@ Gfx *painting_ripple_env_mapped(const struct Painting *painting, const PaintingD /*gSPDisplayList */ 1 + /*gSPEndDisplayList */ 1 ); - Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); + Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { @@ -759,13 +759,13 @@ Gfx *display_painting_rippling(const struct Painting *painting) { * Render a normal painting. */ Gfx *display_painting_not_rippling(const struct Painting *painting) { - u32 commands = ( + u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + /*gSPPopMatrix */ 1 + /*gSPEndDisplayList */ 1 ); - Gfx *dlist = alloc_display_list(commands * sizeof(Gfx)); + Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { From d1b0bad2fd200844d44bc76a9fd2b8469244f60c Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 14 Aug 2022 01:41:05 -0700 Subject: [PATCH 16/81] Automatic texture maps & non-rippling display lists for paintings --- bin/segment2.c | 1021 ++++++++++++++------------- levels/castle_inside/painting.inc.c | 563 +++++---------- levels/hmc/areas/1/painting.inc.c | 31 +- levels/ttm/areas/1/painting.inc.c | 76 +- src/game/paintings.c | 342 ++++++--- src/game/paintings.h | 34 +- src/game/segment2.h | 3 + 7 files changed, 954 insertions(+), 1116 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index b184971655..4fc730eead 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -5,6 +5,7 @@ #include "macros.h" #include "types.h" #include "game/ingame_menu.h" +#include "game/paintings.h" #include "make_const_nonconst.h" @@ -2841,8 +2842,6 @@ const Gfx dl_paintings_rippling_begin[] = { gsSPLightColor(LIGHT_2, 0x505050ff), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPEndDisplayList(), }; @@ -2854,6 +2853,40 @@ const Gfx dl_paintings_rippling_end[] = { gsSPEndDisplayList(), }; +const Gfx sub_dl_paintings_textured_begin[] = { + gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + // gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD), + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPTileSync(), + gsSPEndDisplayList(), +}; + +// 0x07021A48 - 0x07021AA0 +const Gfx dl_paintings_textured_shaded_begin[] = { + gsDPPipeSync(), + gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), + gsSPLightColor(LIGHT_1, 0xffffffff), + gsSPLightColor(LIGHT_2, 0x505050ff), + gsSPDisplayList(sub_dl_paintings_textured_begin), + gsSPEndDisplayList(), +}; + +// 0x07021A48 - 0x07021AA0 +const Gfx dl_paintings_textured_vertex_colored_begin[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_LIGHTING), + gsSPDisplayList(sub_dl_paintings_textured_begin), + gsSPEndDisplayList(), +}; + +// 0x07021AA0 - 0x07021AC0 +const Gfx dl_paintings_textured_end[] = { + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), + gsDPPipeSync(), + gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), + gsSPEndDisplayList(), +}; + // 0x020149C8 - 0x02014A00 const Gfx dl_paintings_env_mapped_begin[] = { gsDPPipeSync(), @@ -2861,10 +2894,10 @@ const Gfx dl_paintings_env_mapped_begin[] = { gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), gsSPLightColor(LIGHT_1, 0xffffffff), gsSPLightColor(LIGHT_2, 0x505050ff), +// gsSPLightColor(LIGHT_1, 0x6464ffff), +// gsSPLightColor(LIGHT_2, 0x404080ff), gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_ON), gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPEndDisplayList(), }; @@ -2893,169 +2926,172 @@ const Gfx dl_paintings_draw_ripples[] = { gsSPEndDisplayList(), }; +#define PDX (PAINTING_SIZE / 12.0f) // 51.2f +#define PDY (PAINTING_SIZE / 20.0f) // 30.72f + // 14A60: triangle mesh // 0x02014A60 const PaintingData seg2_painting_triangle_mesh[] = { 157, // numVtx // format: // 2D point (x, y), ripple (0 or 1) - 614, 583, 0, // 0 - 614, 614, 0, // 1 - 562, 614, 0, // 2 - 562, 553, 1, // 3 - 614, 522, 0, // 4 - 511, 583, 1, // 5 - 511, 614, 0, // 6 - 307, 614, 0, // 7 - 307, 583, 1, // 8 - 358, 614, 0, // 9 - 256, 614, 0, // 10 - 256, 553, 1, // 11 - 307, 522, 1, // 12 - 358, 553, 1, // 13 - 409, 583, 1, // 14 - 460, 614, 0, // 15 - 511, 522, 1, // 16 - 460, 553, 1, // 17 - 409, 522, 1, // 18 - 562, 307, 1, // 19 - 614, 338, 0, // 20 - 562, 430, 1, // 21 - 614, 399, 0, // 22 - 562, 368, 1, // 23 - 511, 338, 1, // 24 - 460, 307, 1, // 25 - 460, 430, 1, // 26 - 511, 399, 1, // 27 - 511, 460, 1, // 28 - 409, 338, 1, // 29 - 460, 368, 1, // 30 - 358, 307, 1, // 31 - 409, 460, 1, // 32 - 358, 430, 1, // 33 - 409, 399, 1, // 34 - 358, 368, 1, // 35 - 307, 338, 1, // 36 - 256, 307, 1, // 37 - 307, 399, 1, // 38 - 256, 430, 1, // 39 - 307, 460, 1, // 40 - 614, 460, 0, // 41 - 562, 491, 1, // 42 - 460, 491, 1, // 43 - 358, 491, 1, // 44 - 256, 491, 1, // 45 - 409, 276, 1, // 46 - 511, 276, 1, // 47 - 307, 276, 1, // 48 - 614, 31, 0, // 49 - 614, 0, 0, // 50 - 562, 0, 0, // 51 - 562, 123, 1, // 52 - 614, 92, 0, // 53 - 511, 31, 1, // 54 - 562, 61, 1, // 55 - 460, 0, 0, // 56 - 511, 0, 0, // 57 - 460, 123, 1, // 58 - 511, 92, 1, // 59 - 511, 153, 1, // 60 - 409, 31, 1, // 61 - 460, 61, 1, // 62 - 358, 0, 0, // 63 - 409, 0, 0, // 64 - 409, 92, 1, // 65 - 358, 123, 1, // 66 - 409, 153, 1, // 67 - 307, 31, 1, // 68 - 358, 61, 1, // 69 - 256, 0, 0, // 70 - 307, 0, 0, // 71 - 256, 123, 1, // 72 - 307, 92, 1, // 73 - 307, 153, 1, // 74 - 614, 153, 0, // 75 - 562, 246, 1, // 76 - 614, 215, 0, // 77 - 562, 184, 1, // 78 - 460, 246, 1, // 79 - 511, 215, 1, // 80 - 460, 184, 1, // 81 - 358, 246, 1, // 82 - 409, 215, 1, // 83 - 358, 184, 1, // 84 - 256, 246, 1, // 85 - 307, 215, 1, // 86 - 205, 583, 1, // 87 - 0, 614, 0, // 88 - 0, 583, 0, // 89 - 51, 614, 0, // 90 - 51, 553, 1, // 91 - 102, 583, 1, // 92 - 205, 522, 1, // 93 - 153, 553, 1, // 94 - 153, 614, 0, // 95 - 102, 522, 1, // 96 - 256, 368, 1, // 97 - 205, 338, 1, // 98 - 153, 307, 1, // 99 - 153, 430, 1, // 100 - 205, 399, 1, // 101 - 205, 460, 1, // 102 - 153, 368, 1, // 103 - 102, 338, 1, // 104 - 51, 307, 1, // 105 - 51, 430, 1, // 106 - 102, 399, 1, // 107 - 102, 460, 1, // 108 - 51, 368, 1, // 109 - 0, 338, 0, // 110 - 0, 460, 0, // 111 - 153, 491, 1, // 112 - 51, 491, 1, // 113 - 153, 246, 1, // 114 - 102, 276, 1, // 115 - 205, 276, 1, // 116 - 0, 276, 0, // 117 - 51, 246, 1, // 118 - 205, 31, 1, // 119 - 256, 61, 1, // 120 - 205, 0, 0, // 121 - 153, 0, 0, // 122 - 205, 153, 1, // 123 - 205, 92, 1, // 124 - 153, 123, 1, // 125 - 102, 31, 1, // 126 - 153, 61, 1, // 127 - 102, 0, 0, // 128 - 51, 0, 0, // 129 - 51, 123, 1, // 130 - 102, 92, 1, // 131 - 102, 153, 1, // 132 - 0, 31, 0, // 133 - 51, 61, 1, // 134 - 0, 153, 0, // 135 - 256, 184, 1, // 136 - 205, 215, 1, // 137 - 153, 184, 1, // 138 - 102, 215, 1, // 139 - 51, 184, 1, // 140 - 409, 614, 0, // 141 - 614, 307, 0, // 142 - 614, 276, 0, // 143 - 511, 307, 1, // 144 - 409, 307, 1, // 145 - 307, 307, 1, // 146 - 205, 614, 0, // 147 - 0, 522, 0, // 148 - 102, 614, 0, // 149 - 205, 307, 1, // 150 - 102, 307, 1, // 151 - 0, 399, 0, // 152 - 0, 307, 0, // 153 - 0, 215, 0, // 154 - 0, 92, 0, // 155 - 0, 0, 0, // 156 + (PDX * 12), (PDY * 19), 0, // 0 + (PDX * 12), (PDY * 20), 0, // 1 + (PDX * 11), (PDY * 20), 0, // 2 + (PDX * 11), (PDY * 18), 1, // 3 + (PDX * 12), (PDY * 17), 0, // 4 + (PDX * 10), (PDY * 19), 1, // 5 + (PDX * 10), (PDY * 20), 0, // 6 + (PDX * 6), (PDY * 20), 0, // 7 + (PDX * 6), (PDY * 19), 1, // 8 + (PDX * 7), (PDY * 20), 0, // 9 + (PDX * 5), (PDY * 20), 0, // 10 + (PDX * 5), (PDY * 18), 1, // 11 + (PDX * 6), (PDY * 17), 1, // 12 + (PDX * 7), (PDY * 18), 1, // 13 + (PDX * 8), (PDY * 19), 1, // 14 + (PDX * 9), (PDY * 20), 0, // 15 + (PDX * 10), (PDY * 17), 1, // 16 + (PDX * 9), (PDY * 18), 1, // 17 + (PDX * 8), (PDY * 17), 1, // 18 + (PDX * 11), (PDY * 10), 1, // 19 + (PDX * 12), (PDY * 11), 0, // 20 + (PDX * 11), (PDY * 14), 1, // 21 + (PDX * 12), (PDY * 13), 0, // 22 + (PDX * 11), (PDY * 12), 1, // 23 + (PDX * 10), (PDY * 11), 1, // 24 + (PDX * 9), (PDY * 10), 1, // 25 + (PDX * 9), (PDY * 14), 1, // 26 + (PDX * 10), (PDY * 13), 1, // 27 + (PDX * 10), (PDY * 15), 1, // 28 + (PDX * 8), (PDY * 11), 1, // 29 + (PDX * 9), (PDY * 12), 1, // 30 + (PDX * 7), (PDY * 10), 1, // 31 + (PDX * 8), (PDY * 15), 1, // 32 + (PDX * 7), (PDY * 14), 1, // 33 + (PDX * 8), (PDY * 13), 1, // 34 + (PDX * 7), (PDY * 12), 1, // 35 + (PDX * 6), (PDY * 11), 1, // 36 + (PDX * 5), (PDY * 10), 1, // 37 + (PDX * 6), (PDY * 13), 1, // 38 + (PDX * 5), (PDY * 14), 1, // 39 + (PDX * 6), (PDY * 15), 1, // 40 + (PDX * 12), (PDY * 15), 0, // 41 + (PDX * 11), (PDY * 16), 1, // 42 + (PDX * 9), (PDY * 16), 1, // 43 + (PDX * 7), (PDY * 16), 1, // 44 + (PDX * 5), (PDY * 16), 1, // 45 + (PDX * 8), (PDY * 9), 1, // 46 + (PDX * 10), (PDY * 9), 1, // 47 + (PDX * 6), (PDY * 9), 1, // 48 + (PDX * 12), (PDY * 1), 0, // 49 + (PDX * 12), (PDY * 0), 0, // 50 + (PDX * 11), (PDY * 0), 0, // 51 + (PDX * 11), (PDY * 4), 1, // 52 + (PDX * 12), (PDY * 3), 0, // 53 + (PDX * 10), (PDY * 1), 1, // 54 + (PDX * 11), (PDY * 2), 1, // 55 + (PDX * 9), (PDY * 0), 0, // 56 + (PDX * 10), (PDY * 0), 0, // 57 + (PDX * 9), (PDY * 4), 1, // 58 + (PDX * 10), (PDY * 3), 1, // 59 + (PDX * 10), (PDY * 5), 1, // 60 + (PDX * 8), (PDY * 1), 1, // 61 + (PDX * 9), (PDY * 2), 1, // 62 + (PDX * 7), (PDY * 0), 0, // 63 + (PDX * 8), (PDY * 0), 0, // 64 + (PDX * 8), (PDY * 3), 1, // 65 + (PDX * 7), (PDY * 4), 1, // 66 + (PDX * 8), (PDY * 5), 1, // 67 + (PDX * 6), (PDY * 1), 1, // 68 + (PDX * 7), (PDY * 2), 1, // 69 + (PDX * 5), (PDY * 0), 0, // 70 + (PDX * 6), (PDY * 0), 0, // 71 + (PDX * 5), (PDY * 4), 1, // 72 + (PDX * 6), (PDY * 3), 1, // 73 + (PDX * 6), (PDY * 5), 1, // 74 + (PDX * 12), (PDY * 5), 0, // 75 + (PDX * 11), (PDY * 8), 1, // 76 + (PDX * 12), (PDY * 7), 0, // 77 + (PDX * 11), (PDY * 6), 1, // 78 + (PDX * 9), (PDY * 8), 1, // 79 + (PDX * 10), (PDY * 7), 1, // 80 + (PDX * 9), (PDY * 6), 1, // 81 + (PDX * 7), (PDY * 8), 1, // 82 + (PDX * 8), (PDY * 7), 1, // 83 + (PDX * 7), (PDY * 6), 1, // 84 + (PDX * 5), (PDY * 8), 1, // 85 + (PDX * 6), (PDY * 7), 1, // 86 + (PDX * 4), (PDY * 19), 1, // 87 + (PDX * 0), (PDY * 20), 0, // 88 + (PDX * 0), (PDY * 19), 0, // 89 + (PDX * 1), (PDY * 20), 0, // 90 + (PDX * 1), (PDY * 18), 1, // 91 + (PDX * 2), (PDY * 19), 1, // 92 + (PDX * 4), (PDY * 17), 1, // 93 + (PDX * 3), (PDY * 18), 1, // 94 + (PDX * 3), (PDY * 20), 0, // 95 + (PDX * 2), (PDY * 17), 1, // 96 + (PDX * 5), (PDY * 12), 1, // 97 + (PDX * 4), (PDY * 11), 1, // 98 + (PDX * 3), (PDY * 10), 1, // 99 + (PDX * 3), (PDY * 14), 1, // 100 + (PDX * 4), (PDY * 13), 1, // 101 + (PDX * 4), (PDY * 15), 1, // 102 + (PDX * 3), (PDY * 12), 1, // 103 + (PDX * 2), (PDY * 11), 1, // 104 + (PDX * 1), (PDY * 10), 1, // 105 + (PDX * 1), (PDY * 14), 1, // 106 + (PDX * 2), (PDY * 13), 1, // 107 + (PDX * 2), (PDY * 15), 1, // 108 + (PDX * 1), (PDY * 12), 1, // 109 + (PDX * 0), (PDY * 11), 0, // 110 + (PDX * 0), (PDY * 15), 0, // 111 + (PDX * 3), (PDY * 16), 1, // 112 + (PDX * 1), (PDY * 16), 1, // 113 + (PDX * 3), (PDY * 8), 1, // 114 + (PDX * 2), (PDY * 9), 1, // 115 + (PDX * 4), (PDY * 9), 1, // 116 + (PDX * 0), (PDY * 9), 0, // 117 + (PDX * 1), (PDY * 8), 1, // 118 + (PDX * 4), (PDY * 1), 1, // 119 + (PDX * 5), (PDY * 2), 1, // 120 + (PDX * 4), (PDY * 0), 0, // 121 + (PDX * 3), (PDY * 0), 0, // 122 + (PDX * 4), (PDY * 5), 1, // 123 + (PDX * 4), (PDY * 3), 1, // 124 + (PDX * 3), (PDY * 4), 1, // 125 + (PDX * 2), (PDY * 1), 1, // 126 + (PDX * 3), (PDY * 2), 1, // 127 + (PDX * 2), (PDY * 0), 0, // 128 + (PDX * 1), (PDY * 0), 0, // 129 + (PDX * 1), (PDY * 4), 1, // 130 + (PDX * 2), (PDY * 3), 1, // 131 + (PDX * 2), (PDY * 5), 1, // 132 + (PDX * 0), (PDY * 1), 0, // 133 + (PDX * 1), (PDY * 2), 1, // 134 + (PDX * 0), (PDY * 5), 0, // 135 + (PDX * 5), (PDY * 6), 1, // 136 + (PDX * 4), (PDY * 7), 1, // 137 + (PDX * 3), (PDY * 6), 1, // 138 + (PDX * 2), (PDY * 7), 1, // 139 + (PDX * 1), (PDY * 6), 1, // 140 + (PDX * 8), (PDY * 20), 0, // 141 + (PDX * 12), (PDY * 10), 0, // 142 + (PDX * 12), (PDY * 9), 0, // 143 + (PDX * 10), (PDY * 10), 1, // 144 + (PDX * 8), (PDY * 10), 1, // 145 + (PDX * 6), (PDY * 10), 1, // 146 + (PDX * 4), (PDY * 20), 0, // 147 + (PDX * 0), (PDY * 17), 0, // 148 + (PDX * 2), (PDY * 20), 0, // 149 + (PDX * 4), (PDY * 10), 1, // 150 + (PDX * 2), (PDY * 10), 1, // 151 + (PDX * 0), (PDY * 13), 0, // 152 + (PDX * 0), (PDY * 10), 0, // 153 + (PDX * 0), (PDY * 7), 0, // 154 + (PDX * 0), (PDY * 3), 0, // 155 + (PDX * 0), (PDY * 0), 0, // 156 // triangles 264, 8, 12, 13, // 0 @@ -3324,6 +3360,9 @@ const PaintingData seg2_painting_triangle_mesh[] = { 117, 154, 118, // 263 }; +#undef PDX +#undef PDY + /* 0x02015444: seg2_painting_mesh_neighbor_tris * Lists the neighboring triangles for each vertex in the mesh. * Used when applying gouraud shading to the generated ripple mesh @@ -3496,92 +3535,92 @@ const PaintingData seg2_painting_mesh_neighbor_tris[] = { static const PaintingData seg2_painting_image_texture_map_bottom[] = { 85, // num mappings // Format: - // mesh vtx ID, texture X, texture Y - 49, 2016, 889, - 53, 2016, 685, - 55, 1843, 787, - 50, 2016, 992, - 51, 1843, 992, - 52, 1843, 583, - 75, 2016, 513, - 54, 1671, 889, - 59, 1671, 685, - 62, 1502, 787, - 56, 1502, 992, - 57, 1671, 992, - 58, 1502, 583, - 60, 1671, 513, - 61, 1330, 889, - 65, 1330, 685, - 63, 1162, 992, - 64, 1330, 992, - 66, 1162, 583, - 67, 1330, 513, - 69, 1162, 787, - 68, 989, 889, - 70, 821, 992, - 71, 989, 992, - 73, 989, 685, - 72, 821, 583, - 74, 989, 513, - 77, 2016, 308, - 78, 1843, 410, - 76, 1843, 204, - 81, 1502, 410, - 80, 1671, 308, - 47, 1671, 102, - 79, 1502, 204, - 46, 1330, 102, - 82, 1162, 204, - 83, 1330, 308, - 84, 1162, 410, - 86, 989, 308, - 85, 821, 204, - 48, 989, 102, - 25, 1502, 0, - 31, 1162, 0, - 19, 1843, 0, - 37, 821, 0, - 120, 821, 787, - 119, 649, 889, - 122, 481, 992, - 121, 649, 992, - 124, 649, 685, - 125, 481, 583, - 123, 649, 513, - 127, 481, 787, - 126, 308, 889, - 129, 140, 992, - 128, 308, 992, - 132, 308, 513, - 131, 308, 685, - 130, 140, 583, - 134, 140, 787, - 133, -32, 889, - 135, -32, 513, - 136, 821, 410, - 116, 649, 102, - 137, 649, 308, - 114, 481, 204, - 138, 481, 410, - 139, 308, 308, - 118, 140, 204, - 115, 308, 102, - 140, 140, 410, - 117, -32, 102, - 99, 481, 0, - 105, 140, 0, - 143, 2016, 102, - 145, 1330, 0, - 144, 1671, 0, - 142, 2016, 0, - 146, 989, 0, - 155, -32, 685, - 156, -32, 992, - 154, -32, 308, - 151, 308, 0, - 150, 649, 0, - 153, -32, 0, + // mesh vtx ID + 49, + 53, + 55, + 50, + 51, + 52, + 75, + 54, + 59, + 62, + 56, + 57, + 58, + 60, + 61, + 65, + 63, + 64, + 66, + 67, + 69, + 68, + 70, + 71, + 73, + 72, + 74, + 77, + 78, + 76, + 81, + 80, + 47, + 79, + 46, + 82, + 83, + 84, + 86, + 85, + 48, + 25, + 31, + 19, + 37, + 120, + 119, + 122, + 121, + 124, + 125, + 123, + 127, + 126, + 129, + 128, + 132, + 131, + 130, + 134, + 133, + 135, + 136, + 116, + 137, + 114, + 138, + 139, + 118, + 115, + 140, + 117, + 99, + 105, + 143, + 145, + 144, + 142, + 146, + 155, + 156, + 154, + 151, + 150, + 153, 132, // num groups // Grouped by 5 + one remainder group, @@ -3724,92 +3763,92 @@ static const PaintingData seg2_painting_image_texture_map_bottom[] = { static const PaintingData seg2_painting_image_texture_map_top[] = { 85, // num mappings // Format: - // mesh vtx ID, texture X, texture Y - 0, 2016, 72, - 1, 2016, 0, - 2, 1843, 0, - 3, 1843, 174, - 4, 2016, 276, - 5, 1671, 72, - 6, 1671, 0, - 8, 989, 72, - 7, 989, 0, - 10, 821, 0, - 9, 1162, 0, - 11, 821, 174, - 12, 989, 276, - 13, 1162, 174, - 14, 1330, 72, - 15, 1502, 0, - 16, 1671, 276, - 17, 1502, 174, - 18, 1330, 276, - 19, 1843, 992, - 20, 2016, 889, - 22, 2016, 685, - 21, 1843, 583, - 23, 1843, 787, - 24, 1671, 889, - 25, 1502, 992, - 26, 1502, 583, - 27, 1671, 685, - 28, 1671, 481, - 30, 1502, 787, - 29, 1330, 889, - 31, 1162, 992, - 32, 1330, 481, - 33, 1162, 583, - 34, 1330, 685, - 35, 1162, 787, - 36, 989, 889, - 37, 821, 992, - 39, 821, 583, - 38, 989, 685, - 40, 989, 481, - 41, 2016, 481, - 42, 1843, 378, - 43, 1502, 378, - 44, 1162, 378, - 45, 821, 378, - 87, 649, 72, - 88, -32, 0, - 90, 140, 0, - 89, -32, 72, - 92, 308, 72, - 91, 140, 174, - 94, 481, 174, - 93, 649, 276, - 95, 481, 0, - 96, 308, 276, - 97, 821, 787, - 98, 649, 889, - 99, 481, 992, - 102, 649, 481, - 101, 649, 685, - 100, 481, 583, - 103, 481, 787, - 104, 308, 889, - 105, 140, 992, - 108, 308, 481, - 107, 308, 685, - 106, 140, 583, - 110, -32, 889, - 109, 140, 787, - 111, -32, 481, - 112, 481, 378, - 113, 140, 378, - 141, 1330, 0, - 142, 2016, 992, - 144, 1671, 992, - 145, 1330, 992, - 146, 989, 992, - 147, 649, 0, - 148, -32, 276, - 149, 308, 0, - 150, 649, 992, - 151, 308, 992, - 152, -32, 685, - 153, -32, 992, + // mesh vtx ID + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 8, + 7, + 10, + 9, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 22, + 21, + 23, + 24, + 25, + 26, + 27, + 28, + 30, + 29, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 39, + 38, + 40, + 41, + 42, + 43, + 44, + 45, + 87, + 88, + 90, + 89, + 92, + 91, + 94, + 93, + 95, + 96, + 97, + 98, + 99, + 102, + 101, + 100, + 103, + 104, + 105, + 108, + 107, + 106, + 110, + 109, + 111, + 112, + 113, + 141, + 142, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, 132, // num groups // Grouped by 5 + one remainder group, @@ -3958,164 +3997,164 @@ const PaintingData *const seg2_painting_image_texture_maps[] = { static const PaintingData seg2_painting_env_map_texture_map[] = { 157, // num mappings // Format: - // mesh vtx ID, texture X, texture Y - 0, 6100, -4832, - 1, 6100, -5142, - 2, 5582, -5142, - 3, 5582, -4526, - 4, 6100, -4218, - 5, 5070, -4832, - 6, 5070, -5142, - 7, 3030, -5142, - 8, 3030, -4832, - 9, 3540, -5142, - 10, 2520, -5142, - 11, 2520, -4526, - 12, 3030, -4218, - 13, 3540, -4526, - 14, 4050, -4832, - 15, 4560, -5142, - 16, 5070, -4218, - 17, 4560, -4526, - 18, 4050, -4218, - 19, 5582, -2074, - 20, 6100, -2380, - 21, 5582, -3300, - 22, 6100, -2994, - 23, 5582, -2686, - 24, 5070, -2380, - 25, 4560, -2074, - 26, 4560, -3300, - 27, 5070, -2994, - 28, 5070, -3606, - 29, 4050, -2380, - 30, 4560, -2686, - 31, 3540, -2074, - 32, 4050, -3606, - 33, 3540, -3300, - 34, 4050, -2994, - 35, 3540, -2686, - 36, 3030, -2380, - 37, 2520, -2074, - 38, 3030, -2994, - 39, 2520, -3300, - 40, 3030, -3606, - 41, 6100, -3606, - 42, 5582, -3912, - 43, 4560, -3912, - 44, 3540, -3912, - 45, 2520, -3912, - 46, 4050, -1768, - 47, 5070, -1768, - 48, 3030, -1768, - 49, 6100, 684, - 50, 6100, 990, - 51, 5582, 990, - 52, 5582, -236, - 53, 6100, 70, - 54, 5070, 684, - 55, 5582, 378, - 56, 4560, 990, - 57, 5070, 990, - 58, 4560, -236, - 59, 5070, 70, - 60, 5070, -542, - 61, 4050, 684, - 62, 4560, 378, - 63, 3540, 990, - 64, 4050, 990, - 65, 4050, 70, - 66, 3540, -236, - 67, 4050, -542, - 68, 3030, 684, - 69, 3540, 378, - 70, 2520, 990, - 71, 3030, 990, - 72, 2520, -236, - 73, 3030, 70, - 74, 3030, -542, - 75, 6100, -542, - 76, 5582, -1462, - 77, 6100, -1154, - 78, 5582, -848, - 79, 4560, -1462, - 80, 5070, -1154, - 81, 4560, -848, - 82, 3540, -1462, - 83, 4050, -1154, - 84, 3540, -848, - 85, 2520, -1462, - 86, 3030, -1154, - 87, 2010, -4832, - 88, 0, -5142, - 89, 0, -4832, - 90, 478, -5142, - 91, 478, -4526, - 92, 988, -4832, - 93, 2010, -4218, - 94, 1498, -4526, - 95, 1498, -5142, - 96, 988, -4218, - 97, 2520, -2686, - 98, 2010, -2380, - 99, 1498, -2074, - 100, 1498, -3300, - 101, 2010, -2994, - 102, 2010, -3606, - 103, 1498, -2686, - 104, 988, -2380, - 105, 478, -2074, - 106, 478, -3300, - 107, 988, -2994, - 108, 988, -3606, - 109, 478, -2686, - 110, 0, -2380, - 111, 0, -3606, - 112, 1498, -3912, - 113, 478, -3912, - 114, 1498, -1462, - 115, 988, -1768, - 116, 2010, -1768, - 117, 0, -1768, - 118, 478, -1462, - 119, 2010, 684, - 120, 2520, 378, - 121, 2010, 990, - 122, 1498, 990, - 123, 2010, -542, - 124, 2010, 70, - 125, 1498, -236, - 126, 988, 684, - 127, 1498, 378, - 128, 988, 990, - 129, 478, 990, - 130, 478, -236, - 131, 988, 70, - 132, 988, -542, - 133, 0, 684, - 134, 478, 378, - 135, 0, -542, - 136, 2520, -848, - 137, 2010, -1154, - 138, 1498, -848, - 139, 988, -1154, - 140, 478, -848, - 141, 4050, -5142, - 142, 6100, -2074, - 143, 6100, -1768, - 144, 5070, -2074, - 145, 4050, -2074, - 146, 3030, -2074, - 147, 2010, -5142, - 148, 0, -4218, - 149, 988, -5142, - 150, 2010, -2074, - 151, 988, -2074, - 152, 0, -2994, - 153, 0, -2074, - 154, 0, -1154, - 155, 0, 70, - 156, 0, 990, + // mesh vtx ID + 0, + 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, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143, + 144, + 145, + 146, + 147, + 148, + 149, + 150, + 151, + 152, + 153, + 154, + 155, + 156, // inside_castle_seg7_painting_triangles_07022A10: 264, // num groups diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 964a06edc0..1dd65b25f3 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -1,29 +1,5 @@ #include "game/paintings.h" -// 0x07021818 - 0x07021898 -static const Vtx inside_castle_seg7_vertex_painting_textured_lighting[] = { - {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 2012, -28}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0x00, 0x00, 0x7f, 0xff}}}, -}; - -// 0x07021898 - 0x07021918 -static const Vtx inside_castle_seg7_vertex_painting_textured_vertex_colored[] = { - {{{ 0, 0, 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 0}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 992}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 2012, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, - {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0xdd, 0xdd, 0xdd, 0xff}}}, -}; - #define CCM_FAKE_1_X -3046 #define CCM_FAKE_1_Z -3724 #define CCM_FAKE_1_DX 304 // PAINTING_SIZE * sin(yaw) @@ -71,7 +47,7 @@ static const Gfx inside_castle_seg7_sub_dl_painting_top[] = { }; // 0x07021A48 - 0x07021AA0 -static const Gfx inside_castle_seg7_dl_painting_texture_begin[] = { +static const Gfx inside_castle_seg7_dl_painting_textured_shaded_begin[] = { gsDPPipeSync(), gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), @@ -86,210 +62,16 @@ static const Gfx inside_castle_seg7_dl_painting_texture_begin[] = { }; // 0x07021AA0 - 0x07021AC0 -static const Gfx inside_castle_seg7_dl_painting_texture_end[] = { - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - -// 0x07022598 - 0x070225D8 -static const Vtx inside_castle_seg7_vertex_hmc[] = { - {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, -}; - -// 0x07023050 - 0x070230B0 -static const Gfx inside_castle_seg7_painting_dl_bob[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700B800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700A800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x070230B0 - 0x07023110 -static const Gfx inside_castle_seg7_painting_dl_ccm[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700C800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x07023110 - 0x07023170 -static const Gfx inside_castle_seg7_painting_dl_wf[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700F800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700E800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x07023170 - 0x070231D0 -static const Gfx inside_castle_seg7_painting_dl_jrb[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07011800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07010800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x070231D0 - 0x07023230 -static const Gfx inside_castle_seg7_painting_dl_lll[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07012800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07013800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x07023230 - 0x07023290 -static const Gfx inside_castle_seg7_painting_dl_ssl[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07015800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07014800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x07023290 - 0x070232F0 -static const Gfx inside_castle_seg7_painting_dl_wdw[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07018800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07017800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x070232F0 - 0x07023350 -static const Gfx inside_castle_seg7_painting_dl_thi[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701A800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07019800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x07023350 - 0x070233B0 -static const Gfx inside_castle_seg7_painting_dl_ttm[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701C800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701B800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x070233B0 - 0x07023410 -static const Gfx inside_castle_seg7_painting_dl_ttc[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_lighting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701E800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701D800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), - gsSPEndDisplayList(), -}; - -// 0x07023410 - 0x070234C0 -static const Gfx inside_castle_seg7_painting_dl_sl[] = { - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - gsSPClearGeometryMode(G_LIGHTING), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPVertex(inside_castle_seg7_vertex_painting_textured_vertex_colored, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_07020800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0701F800), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), +static const Gfx inside_castle_seg7_dl_painting_textured_shaded_end[] = { gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPPipeSync(), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPSetGeometryMode(G_LIGHTING), gsSPEndDisplayList(), }; // 0x070234C0 - 0x07023520 const Gfx inside_castle_seg7_dl_ccm_fake_painting_1[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPDisplayList(inside_castle_seg7_dl_painting_textured_shaded_begin), gsSPVertex(inside_castle_seg7_vertex_painting_ccm_fake_1, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), gsDPLoadSync(), @@ -299,13 +81,13 @@ const Gfx inside_castle_seg7_dl_ccm_fake_painting_1[] = { gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), + gsSPDisplayList(inside_castle_seg7_dl_painting_textured_shaded_end), gsSPEndDisplayList(), }; // 0x07023520 - 0x07023580 const Gfx inside_castle_seg7_dl_ccm_fake_painting_2[] = { - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_begin), + gsSPDisplayList(inside_castle_seg7_dl_painting_textured_shaded_begin), gsSPVertex(inside_castle_seg7_vertex_painting_ccm_fake_2, 8, 0), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, inside_castle_seg7_texture_0700D800), gsDPLoadSync(), @@ -315,292 +97,263 @@ const Gfx inside_castle_seg7_dl_ccm_fake_painting_2[] = { gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), gsSPDisplayList(inside_castle_seg7_sub_dl_painting_top), - gsSPDisplayList(inside_castle_seg7_dl_painting_texture_end), + gsSPDisplayList(inside_castle_seg7_dl_painting_textured_shaded_end), gsSPEndDisplayList(), }; -// 0x07023580 - 0x070235B8 -static const Gfx inside_castle_seg7_painting_dl_hmc[] = { - gsDPPipeSync(), - gsSPLightColor(LIGHT_1, 0x6464ffff), - gsSPLightColor(LIGHT_2, 0x404080ff), - gsSPVertex(inside_castle_seg7_vertex_hmc, 4, 0), - gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), - gsSPEndDisplayList(), -}; - -// 0x070235B8 - 0x070235C0 -static const Gfx inside_castle_seg7_painting_dl_ddd[] = { - gsSPBranchList(inside_castle_seg7_painting_dl_hmc), -}; - ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_bob[] = { inside_castle_seg7_texture_0700B800, inside_castle_seg7_texture_0700A800, }; -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] = { - inside_castle_seg7_texture_0700D800, - inside_castle_seg7_texture_0700C800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = { - inside_castle_seg7_texture_0700F800, - inside_castle_seg7_texture_0700E800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] = { - inside_castle_seg7_texture_07011800, - inside_castle_seg7_texture_07010800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] = { - inside_castle_seg7_texture_07012800, - inside_castle_seg7_texture_07013800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] = { - inside_castle_seg7_texture_07015800, - inside_castle_seg7_texture_07014800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_hmc_env[] = { - inside_castle_seg7_texture_07016800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ddd_env[] = { - inside_castle_seg7_texture_07017000, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] = { - inside_castle_seg7_texture_07018800, - inside_castle_seg7_texture_07017800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] = { - inside_castle_seg7_texture_0701A800, - inside_castle_seg7_texture_07019800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] = { - inside_castle_seg7_texture_0701C800, - inside_castle_seg7_texture_0701B800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] = { - inside_castle_seg7_texture_0701E800, - inside_castle_seg7_texture_0701D800, -}; - -ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = { - inside_castle_seg7_texture_07020800, - inside_castle_seg7_texture_0701F800, -}; - // 0x07023620 - 0x07023698 const struct Painting bob_painting = { /* ID */ PAINTING_ID_CASTLE_BOB, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_bob), + /* Textures */ inside_castle_seg7_painting_textures_bob, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_bob, - /* Textures */ inside_castle_seg7_painting_textures_bob, - /* Texture w, h */ 64, 32, /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] = { + inside_castle_seg7_texture_0700D800, + inside_castle_seg7_texture_0700C800, }; // 0x07023698 - 0x07023710 const struct Painting ccm_painting = { /* ID */ PAINTING_ID_CASTLE_CCM, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ccm), + /* Textures */ inside_castle_seg7_painting_textures_ccm, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_ccm, - /* Textures */ inside_castle_seg7_painting_textures_ccm, - /* Texture w, h */ 64, 32, - /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = { + inside_castle_seg7_texture_0700F800, + inside_castle_seg7_texture_0700E800, }; // 0x07023710 - 0x07023788 const struct Painting wf_painting = { /* ID */ PAINTING_ID_CASTLE_WF, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wf), + /* Textures */ inside_castle_seg7_painting_textures_wf, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_wf, - /* Textures */ inside_castle_seg7_painting_textures_wf, - /* Texture w, h */ 64, 32, - /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] = { + inside_castle_seg7_texture_07011800, + inside_castle_seg7_texture_07010800, }; // 0x07023788 - 0x07023800 const struct Painting jrb_painting = { /* ID */ PAINTING_ID_CASTLE_JRB, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_jrb), + /* Textures */ inside_castle_seg7_painting_textures_jrb, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_jrb, - /* Textures */ inside_castle_seg7_painting_textures_jrb, - /* Texture w, h */ 64, 32, - /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] = { + inside_castle_seg7_texture_07012800, + inside_castle_seg7_texture_07013800, }; // 0x07023800 - 0x07023878 const struct Painting lll_painting = { /* ID */ PAINTING_ID_CASTLE_LLL, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_lll), + /* Textures */ inside_castle_seg7_painting_textures_lll, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_lll, - /* Textures */ inside_castle_seg7_painting_textures_lll, - /* Texture w, h */ 64, 32, - /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] = { + inside_castle_seg7_texture_07015800, + inside_castle_seg7_texture_07014800, }; // 0x07023878 - 0x070238F0 const struct Painting ssl_painting = { /* ID */ PAINTING_ID_CASTLE_SSL, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ssl), + /* Textures */ inside_castle_seg7_painting_textures_ssl, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_ssl, - /* Textures */ inside_castle_seg7_painting_textures_ssl, - /* Texture w, h */ 64, 32, - /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_hmc_env[] = { + inside_castle_seg7_texture_07016800, }; // 0x070238F0 - 0x07023968 const struct Painting hmc_painting = { /* ID */ PAINTING_ID_CASTLE_HMC, - /* Image Count */ 1, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_hmc_env), + /* Textures */ inside_castle_seg7_painting_textures_hmc_env, + /* Texture w, h */ 32, 32, /* Texture Type */ PAINTING_ENV_MAP, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Ripple Animation */ RIPPLE_ANIM_CONTINUOUS, - /* Normal DList */ inside_castle_seg7_painting_dl_hmc, - /* Textures */ inside_castle_seg7_painting_textures_hmc_env, - /* Texture w, h */ 32, 32, - /* Size */ 768.0f, 768.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 768.0f, 768.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ddd_env[] = { + inside_castle_seg7_texture_07017000, }; // 0x07023968 - 0x070239E0 const struct Painting ddd_painting = { /* ID */ PAINTING_ID_CASTLE_DDD, - /* Image Count */ 1, - /* Alpha */ 0xB4, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ddd_env), + /* Textures */ inside_castle_seg7_painting_textures_ddd_env, + /* Texture w, h */ 32, 32, /* Texture Type */ PAINTING_ENV_MAP, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Ripple Animation */ RIPPLE_ANIM_CONTINUOUS, - /* Normal DList */ inside_castle_seg7_painting_dl_ddd, - /* Textures */ inside_castle_seg7_painting_textures_ddd_env, - /* Texture w, h */ 32, 32, - /* Size */ 819.2f, 819.2f, + /* Shaded */ TRUE, + /* Alpha */ 0xB4, + /* Size */ 819.2f, 819.2f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] = { + inside_castle_seg7_texture_07018800, + inside_castle_seg7_texture_07017800, }; // 0x070239E0 - 0x07023A58 const struct Painting wdw_painting = { /* ID */ PAINTING_ID_CASTLE_WDW, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wdw), + /* Textures */ inside_castle_seg7_painting_textures_wdw, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_wdw, - /* Textures */ inside_castle_seg7_painting_textures_wdw, - /* Texture w, h */ 64, 32, - /* Size */ 614.0f, 614.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 614.0f, 614.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] = { + inside_castle_seg7_texture_0701A800, + inside_castle_seg7_texture_07019800, }; // 0x07023A58 - 0x07023AD0 const struct Painting thi_tiny_painting = { /* ID */ PAINTING_ID_CASTLE_THI_TINY, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), + /* Textures */ inside_castle_seg7_painting_textures_thi, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_thi, - /* Textures */ inside_castle_seg7_painting_textures_thi, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 393.216f, 393.216f, +}; + +// 0x07023C38 - 0x07023CB0 +const struct Painting thi_huge_painting = { + /* ID */ PAINTING_ID_CASTLE_THI_HUGE, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), + /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture w, h */ 64, 32, - /* Size */ 393.216f, 393.216f, + /* Texture Type */ PAINTING_IMAGE, + /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 1638.4f, 1638.4f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] = { + inside_castle_seg7_texture_0701C800, + inside_castle_seg7_texture_0701B800, }; // 0x07023AD0 - 0x07023B48 const struct Painting ttm_painting = { /* ID */ PAINTING_ID_CASTLE_TTM, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttm), + /* Textures */ inside_castle_seg7_painting_textures_ttm, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_ttm, - /* Textures */ inside_castle_seg7_painting_textures_ttm, - /* Texture w, h */ 64, 32, - /* Size */ 256.0f, 256.0f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 256.0f, 256.0f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] = { + inside_castle_seg7_texture_0701E800, + inside_castle_seg7_texture_0701D800, }; // 0x07023B48 - 0x07023BC0 const struct Painting ttc_painting = { /* ID */ PAINTING_ID_CASTLE_TTC, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttc), + /* Textures */ inside_castle_seg7_painting_textures_ttc, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_ttc, - /* Textures */ inside_castle_seg7_painting_textures_ttc, - /* Texture w, h */ 64, 32, - /* Size */ 409.6f, 409.6f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 409.6f, 409.6f, +}; + +ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = { + inside_castle_seg7_texture_07020800, + inside_castle_seg7_texture_0701F800, }; // 0x07023BC0 - 0x07023C38 const struct Painting sl_painting = { /* ID */ PAINTING_ID_CASTLE_SL, - /* Image Count */ 2, - /* Alpha */ 0xFF, - /* Texture Type */ PAINTING_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ inside_castle_seg7_painting_dl_sl, - /* Textures */ inside_castle_seg7_painting_textures_sl, + /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_sl), + /* Textures */ inside_castle_seg7_painting_textures_sl, /* Texture w, h */ 64, 32, - /* Size */ 716.8f, 716.8f, -}; - -// 0x07023C38 - 0x07023CB0 -const struct Painting thi_huge_painting = { - /* ID */ PAINTING_ID_CASTLE_THI_HUGE, - /* Image Count */ 2, - /* Alpha */ 0xFF, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY_LARGE, - /* Normal DList */ inside_castle_seg7_painting_dl_thi, - /* Textures */ inside_castle_seg7_painting_textures_thi, - /* Texture w, h */ 64, 32, - /* Size */ 1638.4f, 1638.4f, + /* Shaded */ FALSE, + /* Alpha */ 0xFF, + /* Size */ 716.8f, 716.8f, }; const struct Painting rr_painting = { /* ID */ PAINTING_ID_CASTLE_THI_HUGE, /* Image Count */ 0, - /* Alpha */ 0x00, + /* Textures */ NULL, + /* Texture w, h */ 0, 0, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ NULL, - /* Textures */ NULL, - /* Texture w, h */ 0, 0, - /* Size */ 204.8f, 204.8f, + /* Shaded */ TRUE, + /* Alpha */ 0x00, + /* Size */ 204.8f, 204.8f, }; diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 14ce705369..67eff7eca0 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -1,23 +1,5 @@ #include "game/paintings.h" -// 0x07024228 - 0x07024268 -static const Vtx hmc_seg7_vertex_cotmc_pool[] = { - {{{ 0, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, 0, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, PAINTING_SIZE, 0}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}}, -}; - -// 0x070254E0 - 0x07025518 -static const Gfx hmc_seg7_painting_dl_cotmc_normal[] = { - gsDPPipeSync(), - gsSPLightColor(LIGHT_1, 0x6464ffff), - gsSPLightColor(LIGHT_2, 0x404080ff), - gsSPVertex(hmc_seg7_vertex_cotmc_pool, 4, 0), - gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), - gsSPEndDisplayList(), -}; - // 0x07024CE0 - 0x070254E0 ALIGNED8 static const Texture hmc_seg7_texture_cotmc_pool_env[] = { #include "levels/hmc/7.rgba16.inc.c" @@ -31,13 +13,12 @@ const Texture *const hmc_seg7_painting_textures_cotmc[] = { // 0x0702551C (PaintingData) const struct Painting cotmc_painting = { /* ID */ PAINTING_ID_HMC_COTMC, - /* Image Count */ 1, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(hmc_seg7_painting_textures_cotmc), + /* Textures */ hmc_seg7_painting_textures_cotmc, + /* Texture w, h */ 32, 32, /* Texture Type */ PAINTING_ENV_MAP, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Ripple Animation */ RIPPLE_ANIM_CONTINUOUS, - /* Normal DList */ hmc_seg7_painting_dl_cotmc_normal, - /* Textures */ hmc_seg7_painting_textures_cotmc, - /* Texture w, h */ 32, 32, - /* Size */ 723.968018f, 723.968018f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 723.968018f, 723.968018f, }; diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index af63ce0830..7c85c34236 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -1,68 +1,5 @@ #include "game/paintings.h" -// 0x07012308 - 0x07012388 -static const Vtx ttm_seg7_vertex_slide_painting[] = { - {{{ 0, 0, 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, 0, 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, (PAINTING_SIZE / 2), 0}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, (PAINTING_SIZE / 2), 0}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{PAINTING_SIZE, PAINTING_SIZE, 0}, 0, { 2012, -28}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{ 0, PAINTING_SIZE, 0}, 0, { -32, -28}, {0x00, 0x00, 0x7f, 0xff}}}, -}; - -// 0x07012388 - 0x070123A0 -const Gfx ttm_seg7_sub_dl_slide_painting_bottom[] = { - gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), - gsSPEndDisplayList(), -}; - -// 0x070123A0 - 0x070123B8 -const Gfx ttm_seg7_sub_dl_slide_painting_top[] = { - gsSP2Triangles( 4, 5, 6, 0x0, 4, 6, 7, 0x0), - gsSPEndDisplayList(), -}; - -// 0x070123B8 - 0x07012410 -const Gfx ttm_seg7_sub_dl_slide_painting_normal_begin[] = { - gsDPPipeSync(), - gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - gsSPLightColor(LIGHT_1, 0xffffffff), - gsSPLightColor(LIGHT_2, 0x505050ff), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 6, G_TX_NOLOD), - gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPEndDisplayList(), -}; - -// 0x07012410 - 0x07012430 -const Gfx ttm_seg7_sub_dl_slide_painting_normal_end[] = { - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - -// 0x07012E98 - 0x07012EF8 -static const Gfx ttm_seg7_painting_dl_slide_normal[] = { - gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_begin), - gsSPVertex(ttm_seg7_vertex_slide_painting, 8, 0), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, ttm_seg7_texture_07004000), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_bottom), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, ttm_seg7_texture_07003000), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 64 * 32 - 1, CALC_DXT(64, G_IM_SIZ_16b_BYTES)), - gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_top), - gsSPDisplayList(ttm_seg7_sub_dl_slide_painting_normal_end), - gsSPEndDisplayList(), -}; - // 0x07012EF8 - 0x07012F78 ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { ttm_seg7_texture_07004000, @@ -72,13 +9,12 @@ ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { // 0x07012F00 (PaintingData) const struct Painting ttm_slide_painting = { /* ID */ PAINTING_ID_TTM_SLIDE, - /* Image Count */ 2, - /* Alpha */ 0xFF, + /* Image Count */ ARRAY_COUNT(ttm_seg7_painting_textures_slide), + /* Textures */ ttm_seg7_painting_textures_slide, + /* Texture w, h */ 64, 32, /* Texture Type */ PAINTING_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Ripple Animation */ RIPPLE_ANIM_PROXIMITY, - /* Normal DList */ ttm_seg7_painting_dl_slide_normal, - /* Textures */ ttm_seg7_painting_textures_slide, - /* Texture w, h */ 64, 32, - /* Size */ 460.8f, 460.8f, + /* Shaded */ TRUE, + /* Alpha */ 0xFF, + /* Size */ 460.8f, 460.8f, }; diff --git a/src/game/paintings.c b/src/game/paintings.c index 1fcb2c2389..4d0a13f2a0 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -170,6 +170,22 @@ UNUSED s32 get_painting_group(void) { } } +/** + * Returns a pointer to the RippleAnimationInfo that best fits the painting type. + */ +const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *painting) { + PaintingData rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; + if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + rippleAnimationType = RIPPLE_ANIM_PROXIMITY; + if (painting->sizeX >= (PAINTING_SIZE * 2) + || painting->sizeY >= (PAINTING_SIZE * 2)) { + rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; + } + } + + return &sRippleAnimationInfo[rippleAnimationType]; +} + /** * Set the painting's state, causing it to start a passive ripple or a ripple from Mario entering. * @@ -180,7 +196,7 @@ UNUSED s32 get_painting_group(void) { */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTimer) { const struct Painting *painting = obj->oPaintingPtr; - const struct RippleAnimationInfo *anim = &sRippleAnimationInfo[painting->rippleAnimationType]; + const struct RippleAnimationInfo *anim = get_ripple_animation(painting); // Use a different set of variables depending on the state switch (state) { @@ -224,6 +240,10 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTime * Check for Mario entering the painting. */ void painting_update_mario_pos(struct Object *obj) { + if (!gMarioObject) { + return; + } + s8 rippleFlags = RIPPLE_FLAGS_NONE; Vec3f marioWorldPos; @@ -277,7 +297,7 @@ void painting_update_mario_pos(struct Object *obj) { */ void painting_update_ripple_state(const struct Painting *painting) { struct Object *obj = gCurGraphNodeObjectNode; - const struct RippleAnimationInfo *anim = &sRippleAnimationInfo[painting->rippleAnimationType]; + const struct RippleAnimationInfo *anim = get_ripple_animation(painting); if (obj->oPaintingUpdateCounter != obj->oLastPaintingUpdateCounter) { obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; @@ -342,7 +362,7 @@ void painting_generate_mesh(const struct Painting *painting, const PaintingData /// Controls the ripple's frequency. f32 rippleRate = obj->oPaintingCurrRippleRate; /// Controls how fast the ripple spreads. - f32 dispersionFactor = obj->oPaintingDispersionFactor; + f32 dispersionFactor = (1.0f / obj->oPaintingDispersionFactor); /// How far the ripple has spread. f32 rippleTimer = obj->oPaintingRippleTimer; @@ -369,7 +389,7 @@ void painting_generate_mesh(const struct Painting *painting, const PaintingData dx = ((paintingMesh->pos[0] * sizeRatioX) - rippleX); dy = ((paintingMesh->pos[1] * sizeRatioY) - rippleY); // A larger dispersionFactor makes the ripple spread slower. - rippleDistance = sqrtf(sqr(dx) + sqr(dy)) / dispersionFactor; + rippleDistance = sqrtf(sqr(dx) + sqr(dy)) * dispersionFactor; if (rippleTimer < rippleDistance) { // If the ripple hasn't reached the point yet, make the point magnitude 0. @@ -412,7 +432,7 @@ void painting_calculate_triangle_normals(const PaintingData *mesh, PaintingData for (i = 0; i < numTris; i++) { // Add 2 because of the 2 length entries preceding the list. - PaintingData tri = ((numVtx * 3) + (i * 3) + 2); + PaintingData tri = (1 + (numVtx * 3) + 1 + (i * 3)); vec3s_copy(v, &mesh[tri]); vec3s_to_vec3f(vp0, sPaintingMesh[v[0]].pos); vec3s_to_vec3f(vp1, sPaintingMesh[v[1]].pos); @@ -475,8 +495,8 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD #else #define VTX_BUF_MAX 16 #endif -#define TRI_PER_DL (VTX_BUF_MAX / 3) // 5 or 10 -#define VTX_PER_DL (TRI_PER_DL * 3) // 15 or 30 +#define TRI_PER_GRP (VTX_BUF_MAX / 3) // 5 or 10 +#define VTX_PER_GRP (TRI_PER_GRP * 3) // 15 or 30 /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, @@ -485,7 +505,7 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD * If the textureMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole * painting. */ -Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeight, const PaintingData *textureMap, PaintingData mapVerts, PaintingData mapTris, Alpha alpha) { +Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageCount, PaintingData tWidth, PaintingData tHeight, const PaintingData *textureMap, Alpha alpha) { struct PaintingMeshVertex *mesh = NULL; PaintingData group; PaintingData groupIndex; @@ -493,13 +513,16 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig PaintingData triGroup; PaintingData mapping; PaintingData meshVtx; - PaintingData tx, ty; + s16 tx, ty; + + PaintingData mapVerts = textureMap[0]; + PaintingData mapTris = textureMap[mapVerts + 1]; - // We can fit VTX_PER_DL vertices in the RSP's vertex buffer. - // Group triangles by TRI_PER_DL, with one remainder group. - PaintingData triGroups = (mapTris / TRI_PER_DL); - PaintingData remGroupTris = (mapTris % TRI_PER_DL); - PaintingData numVtx = (mapTris * 3); + // We can fit VTX_PER_GRP vertices in the RSP's vertex buffer. + // Group triangles by TRI_PER_GRP, with one remainder group. + PaintingData triGroups = (mapTris / TRI_PER_GRP); + PaintingData remGroupTris = (mapTris % TRI_PER_GRP); + PaintingData numVtx = (mapTris * 3); // 3 verts per tri Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); u32 gfxCmds = ( @@ -519,30 +542,37 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); - // Draw the groups of TRI_PER_DL first. + f32 dy = (PAINTING_SIZE / imageCount); + s16 y1 = ((index + 1) * dy); + + f32 tWidthScale = (((tWidth - 0) * 32) / (f32)PAINTING_SIZE); + f32 tHeightScale = (((tHeight - 1) * 32) / dy); + + // Draw the groups of TRI_PER_GRP first. for (group = 0; group < triGroups; group++) { // The index of the first vertex in the group. - groupIndex = (group * VTX_PER_DL); + groupIndex = (group * VTX_PER_GRP); // The triangle groups are the second part of the texture map. - // Each group is a list of VTX_PER_DL mappings. - triGroup = ((mapVerts * 3) + groupIndex + 2); + // Each group is a list of VTX_PER_GRP mappings. + triGroup = (1 + mapVerts + 1 + groupIndex); // Vertices within the group - for (map = 0; map < VTX_PER_DL; map++) { + for (map = 0; map < VTX_PER_GRP; map++) { // The mapping is just an index into the earlier part of the textureMap. // Some mappings are repeated, for example, when multiple triangles share a vertex. - mapping = (textureMap[triGroup + map] * 3); + mapping = (textureMap[triGroup + map]); // The first entry is the ID of the vertex in the mesh. meshVtx = textureMap[mapping + 1]; - // The next two are the texture coordinates for that vertex. - tx = textureMap[mapping + 2]; - ty = textureMap[mapping + 3]; // Get a pointer to the current mesh. mesh = &sPaintingMesh[meshVtx]; + // Texture coordinates. + tx = ((mesh->pos[0] * tWidthScale) - 32); + ty = ((y1 - mesh->pos[1]) * tHeightScale); + // Map the texture and place it in the verts array. make_vertex(verts, (groupIndex + map), mesh->pos[0], @@ -552,26 +582,35 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig mesh->norm[0], mesh->norm[1], mesh->norm[2], - alpha); + alpha + ); } - // Load the vertices and draw the TRI_PER_DL triangles. - gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + groupIndex), VTX_PER_DL, 0); + // Load the vertices and draw the TRI_PER_GRP triangles. + gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + groupIndex), VTX_PER_GRP, 0); gSPDisplayList(gfx++, dl_paintings_draw_ripples); } - // One group left with < TRI_PER_DL triangles. - triGroup = ((mapVerts * 3) + (triGroups * VTX_PER_DL) + 2); + // One group left with < TRI_PER_GRP triangles. + triGroup = (1 + mapVerts + 1 + (triGroups * VTX_PER_GRP)); // Map the texture to the triangles. for (map = 0; map < (remGroupTris * 3); map++) { - mapping = (textureMap[triGroup + map] * 3); + // The mapping is just an index into the earlier part of the textureMap. + // Some mappings are repeated, for example, when multiple triangles share a vertex. + mapping = (textureMap[triGroup + map]); + + // The first entry is the ID of the vertex in the mesh. meshVtx = textureMap[mapping + 1]; - tx = textureMap[mapping + 2]; - ty = textureMap[mapping + 3]; + // Get a pointer to the current mesh. mesh = &sPaintingMesh[meshVtx]; - make_vertex(verts, ((triGroups * VTX_PER_DL) + map), + + // Texture coordinates. + tx = ((mesh->pos[0] * tWidthScale) - 32); + ty = ((y1 - mesh->pos[1]) * tHeightScale); + + make_vertex(verts, ((triGroups * VTX_PER_GRP) + map), mesh->pos[0], mesh->pos[1], mesh->pos[2], @@ -579,18 +618,20 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig mesh->norm[0], mesh->norm[1], mesh->norm[2], - alpha); + alpha + ); } // Draw the remaining triangles individually. - gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (triGroups * VTX_PER_DL)), (remGroupTris * 3), 0); + gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + (triGroups * VTX_PER_GRP)), (remGroupTris * 3), 0); for (group = 0; group < (remGroupTris * 3); group += 3) { gSP1Triangle(gfx++, (group + 0), (group + 1), (group + 2), - 0x0); + 0x0 + ); } gSPEndDisplayList(gfx); @@ -599,8 +640,8 @@ Gfx *render_painting(const Texture *img, PaintingData tWidth, PaintingData tHeig } #undef VTX_BUF_MAX -#undef TRI_PER_DL -#undef VTX_PER_DL +#undef TRI_PER_GRP +#undef VTX_PER_GRP /** * Orient the painting mesh for rendering. @@ -628,20 +669,46 @@ Gfx *painting_model_view_transform(const struct Painting *painting) { } /** - * Ripple a painting that has 1 or more images that need to be mapped + * Set up the texture format in the display list. + */ +void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeight) { + // Get the exponents (shift) of tWidth and tHeight for the texture map. + // Making this conversion into its own function does not work for some reason. + f32 tmp = tWidth; + s32 mskt = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 0x7F); + tmp = tHeight; + s32 msks = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 0x7F); + + // Set up the textures. + gDPSetTile((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, + (tWidth >> 2), 0, G_TX_RENDERTILE, 0, + (G_TX_WRAP | G_TX_NOMIRROR), msks, G_TX_NOLOD, + (G_TX_WRAP | G_TX_NOMIRROR), mskt, G_TX_NOLOD + ); + gDPSetTileSize((*gfx)++, 0, + 0, 0, + ((tWidth - 1) << G_TEXTURE_IMAGE_FRAC), + ((tHeight - 1) << G_TEXTURE_IMAGE_FRAC) + ); +} + +/** + * Ripple a painting that has 1 or more images that need to be mapped. */ -Gfx *painting_ripple_image(const struct Painting *painting, const PaintingData **textureMaps) { +Gfx *dl_painting_rippling(const struct Painting *painting) { PaintingData i; - PaintingData meshVerts; - PaintingData meshTris; const PaintingData *textureMap; PaintingData imageCount = painting->imageCount; PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; - const Texture **textures = segmented_to_virtual(painting->textureArray); + const Texture **tArray = segmented_to_virtual(painting->textureArray); + PaintingData isEnvMap = (painting->textureType == PAINTING_ENV_MAP); + u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + + /*gDPSetTile */ 1 + + /*gDPSetTileSize */ 1 + (imageCount * ( /*gSPDisplayList */ 1 )) + @@ -657,66 +724,32 @@ Gfx *painting_ripple_image(const struct Painting *painting, const PaintingData * } gSPDisplayList(gfx++, painting_model_view_transform(painting)); - gSPDisplayList(gfx++, dl_paintings_rippling_begin); + Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); + gSPDisplayList(gfx++, beginDl); + + painting_setup_textures(&gfx, tWidth, tHeight); + + //! TODO: Automatically determine texture maps for the image count. + const PaintingData **textureMaps = NULL; + if (imageCount > 1) { + textureMaps = segmented_to_virtual(seg2_painting_image_texture_maps); + } else { + textureMaps = segmented_to_virtual(seg2_painting_env_map_texture_maps); + } // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { textureMap = segmented_to_virtual(textureMaps[i]); - meshVerts = textureMap[0]; - meshTris = textureMap[(meshVerts * 3) + 1]; - gSPDisplayList(gfx++, render_painting(textures[i], tWidth, tHeight, textureMap, meshVerts, meshTris, painting->alpha)); + // Render a section of the painting. + gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, painting->alpha)); } // Update the ripple, may automatically reset the painting's state. painting_update_ripple_state(painting); gSPPopMatrix(gfx++, G_MTX_MODELVIEW); - gSPDisplayList(gfx++, dl_paintings_rippling_end); - gSPEndDisplayList(gfx); - - return dlist; -} - -/** - * Ripple a painting that has 1 "environment map" texture. - */ -Gfx *painting_ripple_env_mapped(const struct Painting *painting, const PaintingData **textureMaps) { - PaintingData meshVerts; - PaintingData meshTris; - const PaintingData *textureMap; - PaintingData tWidth = painting->textureWidth; - PaintingData tHeight = painting->textureHeight; - const Texture **tArray = segmented_to_virtual(painting->textureArray); - u32 gfxCmds = ( - /*gSPDisplayList */ 1 + - /*gSPDisplayList */ 1 + - /*gSPDisplayList */ 1 + - /*gSPPopMatrix */ 1 + - /*gSPDisplayList */ 1 + - /*gSPEndDisplayList */ 1 - ); - Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); - Gfx *gfx = dlist; - - if (dlist == NULL) { - return dlist; - } - - gSPDisplayList(gfx++, painting_model_view_transform(painting)); - gSPDisplayList(gfx++, dl_paintings_env_mapped_begin); - - // Map the image to the mesh's vertices. - textureMap = segmented_to_virtual(textureMaps[0]); - meshVerts = textureMap[0]; - meshTris = textureMap[(meshVerts * 3) + 1]; - - gSPDisplayList(gfx++, render_painting(tArray[0], tWidth, tHeight, textureMap, meshVerts, meshTris, painting->alpha)); - - // Update the ripple, may automatically reset the painting's state. - painting_update_ripple_state(painting); - - gSPPopMatrix(gfx++, G_MTX_MODELVIEW); - gSPDisplayList(gfx++, dl_paintings_env_mapped_end); + Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_rippling_end); + gSPDisplayList(gfx++, endDl); gSPEndDisplayList(gfx); return dlist; @@ -739,14 +772,7 @@ Gfx *display_painting_rippling(const struct Painting *painting) { painting_average_vertex_normals(neighborTris, numVtx); // Map the painting's texture depending on the painting's texture type. - switch (painting->textureType) { - case PAINTING_IMAGE: - dlist = painting_ripple_image(painting, segmented_to_virtual(seg2_painting_image_texture_maps)); - break; - case PAINTING_ENV_MAP: - dlist = painting_ripple_env_mapped(painting, segmented_to_virtual(seg2_painting_env_map_texture_maps)); - break; - } + dlist = dl_painting_rippling(painting); // The mesh data is freed every frame. mem_pool_free(gEffectsMemoryPool, sPaintingMesh); @@ -755,6 +781,107 @@ Gfx *display_painting_rippling(const struct Painting *painting) { return dlist; } +Gfx *dl_painting_not_rippling(const struct Painting *painting) { + Alpha alpha = painting->alpha; + + if (alpha == 0x00) { + return NULL; + } + + PaintingData imageCount = painting->imageCount; + s32 shaded = painting->shaded; + u32 gfxCmds = ( + /*gSPDisplayList */ 1 + + /*gDPSetTile */ 1 + + /*gDPSetTileSize */ 1 + + /*gSPVertex */ 1 + + (imageCount * ( + /*gDPSetTextureImage */ 1 + + /*gDPLoadSync */ 1 + + /*gDPLoadBlock */ 1 + + /*gSP2Triangles */ 1 + )) + + /*gSPDisplayList */ 1 + + (!shaded * ( + /*gSPSetGeometryMode */ 1 + )) + + /*gSPEndDisplayList */ 1 + ); + Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); + Gfx *gfx = dlist; + + if (dlist == NULL) { + return dlist; + } + + Vtx *verts = alloc_display_list((imageCount * 4) * sizeof(*verts)); + Vec3c n; + + const Texture **textures = segmented_to_virtual(painting->textureArray); + + s32 isEnvMap = (painting->textureType == PAINTING_ENV_MAP); + + if (isEnvMap) { + vec3_set(n, 0x00, 0x00, 0x7f); + gSPDisplayList(gfx++, dl_paintings_env_mapped_begin); + } else if (shaded) { + vec3_set(n, 0x00, 0x00, 0x7f); + gSPDisplayList(gfx++, dl_paintings_textured_shaded_begin); + } else { + vec3_same(n, 0xdd); + gSPDisplayList(gfx++, dl_paintings_textured_vertex_colored_begin); + } + + PaintingData tWidth = painting->textureWidth; + PaintingData tHeight = painting->textureHeight; + + painting_setup_textures(&gfx, tWidth, tHeight); + + const s16 s = ((tWidth * 32) - 32); + const s16 t = ((tHeight * 32) - 32); + + s32 idx = 0; + s16 dy = (PAINTING_SIZE / imageCount); + s16 y1, y2; + + // Generate vertices + for (s32 i = 0; i < imageCount; i++) { + y1 = (i * dy); + y2 = (y1 + dy); + make_vertex(verts, idx++, 0, y1, 0, -32, t, n[0], n[1], n[2], alpha); // Bottom Left + make_vertex(verts, idx++, PAINTING_SIZE, y1, 0, s, t, n[0], n[1], n[2], alpha); // Bottom Right + make_vertex(verts, idx++, PAINTING_SIZE, y2, 0, s, 0, n[0], n[1], n[2], alpha); // Top Right + make_vertex(verts, idx++, 0, y2, 0, -32, 0, n[0], n[1], n[2], alpha); // Top left + } + + gSPVertex(gfx++, verts, idx, 0); + + for (s32 i = 0; i < imageCount; i++) { + gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, textures[i]); + gDPLoadSync(gfx++); + gDPLoadBlock(gfx++, G_TX_LOADTILE, 0, 0, ((tWidth * tHeight) - 1), CALC_DXT(tWidth, G_IM_SIZ_16b_BYTES)); + s32 q = (i * 4); + gSP2Triangles(gfx++, + (q + 0), (q + 1), (q + 2), 0x0, + (q + 0), (q + 2), (q + 3), 0x0 + ); + } + + if (isEnvMap) { + gSPDisplayList(gfx++, dl_paintings_env_mapped_end); + } else { + gSPDisplayList(gfx++, dl_paintings_textured_end); + } + + if (!shaded) { + gSPSetGeometryMode(gfx++, G_LIGHTING); + } + + gSPEndDisplayList(gfx); + + return dlist; +} + /** * Render a normal painting. */ @@ -773,7 +900,7 @@ Gfx *display_painting_not_rippling(const struct Painting *painting) { } gSPDisplayList(gfx++, painting_model_view_transform(painting)); - gSPDisplayList(gfx++, painting->normalDisplayList); + gSPDisplayList(gfx++, dl_painting_not_rippling(painting)); gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); @@ -894,11 +1021,10 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con // Draw the painting. if (painting->imageCount > 0 - && painting->alpha > 0 - && painting->normalDisplayList != NULL && painting->textureArray != NULL && painting->textureWidth > 0 - && painting->textureHeight > 0) { + && painting->textureHeight > 0 + && painting->alpha > 0x00) { // Determine whether the painting is opaque or transparent. if (painting->alpha == 0xFF) { SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); @@ -972,9 +1098,11 @@ void bhv_painting_init(void) { vec3f_local_pos_to_world_pos(roomCheckPos, distPos, &obj->oPosVec, rotation); // Set the object's room so that paintings only render in their room. - obj->oRoom = get_room_at_pos(roomCheckPos[0], - roomCheckPos[1], - roomCheckPos[2]); + obj->oRoom = get_room_at_pos( + roomCheckPos[0], + roomCheckPos[1], + roomCheckPos[2] + ); } void bhv_painting_loop(void) { diff --git a/src/game/paintings.h b/src/game/paintings.h index 53ed444cc5..e66751bc9f 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -13,7 +13,7 @@ #define PAINTING_ID(id, grp) ((id) | ((grp) << 8)) /// The default painting side length. -#define PAINTING_SIZE 614 +#define PAINTING_SIZE 614.4f /// The depth of the area in front of the painting which triggers ripples without warping. #define PAINTING_WOBBLE_DEPTH 100 @@ -80,6 +80,7 @@ enum PaintingType { // Painting->rippleTrigger enum RippleTriggers { + RIPPLE_TRIGGER_NONE, RIPPLE_TRIGGER_PROXIMITY, RIPPLE_TRIGGER_CONTINUOUS, }; @@ -140,31 +141,28 @@ struct Painting { /// How many images should be drawn when the painting is rippling. /*0x02*/ PaintingData imageCount; - /// The painting's transparency (0..255). Determines the drawing layer of the painting. - /*0x04*/ Alpha alpha; + // Texture data. + /*0x04*/ const Texture *const *textureArray; + /*0x08*/ PaintingData textureWidth; + /*0x0A*/ PaintingData textureHeight; /// Either PAINTING_IMAGE or PAINTING_ENV_MAP. - /*0x05*/ s8 textureType; - - /// Controls when a passive ripple starts. RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. - /*0x06*/ s8 rippleTrigger; + /*0x0C*/ s8 textureType; - /// Which animation type to use. RIPPLE_ANIM_CONTINUOUS, RIPPLE_ANIM_PROXIMITY, or RIPPLE_ANIM_PROXIMITY_LARGE. - /*0x07*/ s8 rippleAnimationType; + /// Controls when a passive ripple starts. RIPPLE_TRIGGER_NONE, RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. + /*0x0D*/ s8 rippleTrigger; - /// Display list used when the painting is not rippling. - /*0x08*/ const Gfx *normalDisplayList; + /// Whether to use shading or not. + /*0x0E*/ s8 shaded; - // Texture data. - /*0x0C*/ const Texture *const *textureArray; - /*0x10*/ PaintingData textureWidth; - /*0x12*/ PaintingData textureHeight; + /// The painting's transparency (0..255). Determines the drawing layer of the painting. + /*0x0F*/ Alpha alpha; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. /// By default a painting is 614.0f x 614.0f - /*0x14*/ f32 sizeX; - /*0x18*/ f32 sizeY; -}; /*0x1C*/ + /*0x10*/ f32 sizeX; + /*0x14*/ f32 sizeY; +}; /*0x18*/ /** * Contains the position and normal of a vertex in the painting's generated mesh. diff --git a/src/game/segment2.h b/src/game/segment2.h index 9cf93912f0..80d40b814d 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -40,6 +40,9 @@ extern Gfx dl_waterbox_end[]; extern Gfx dl_paintings_draw_ripples[]; extern Gfx dl_paintings_rippling_begin[]; extern Gfx dl_paintings_rippling_end[]; +extern Gfx dl_paintings_textured_shaded_begin[]; +extern Gfx dl_paintings_textured_vertex_colored_begin[]; +extern Gfx dl_paintings_textured_end[]; extern Gfx dl_paintings_env_mapped_begin[]; extern Gfx dl_paintings_env_mapped_end[]; extern PaintingData seg2_painting_triangle_mesh[]; From 7fe7f6b083953b7ae12622643d95664c7102d5d6 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 16 Aug 2022 12:15:29 -0700 Subject: [PATCH 17/81] Fix tiny seam between painting segments --- src/game/paintings.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 4d0a13f2a0..c278c01705 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -571,7 +571,7 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC // Texture coordinates. tx = ((mesh->pos[0] * tWidthScale) - 32); - ty = ((y1 - mesh->pos[1]) * tHeightScale); + ty = (((y1 - mesh->pos[1]) * tHeightScale) + 4); // Map the texture and place it in the verts array. make_vertex(verts, (groupIndex + map), @@ -608,7 +608,7 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC // Texture coordinates. tx = ((mesh->pos[0] * tWidthScale) - 32); - ty = ((y1 - mesh->pos[1]) * tHeightScale); + ty = (((y1 - mesh->pos[1]) * tHeightScale) + 4); make_vertex(verts, ((triGroups * VTX_PER_GRP) + map), mesh->pos[0], @@ -675,9 +675,9 @@ void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeigh // Get the exponents (shift) of tWidth and tHeight for the texture map. // Making this conversion into its own function does not work for some reason. f32 tmp = tWidth; - s32 mskt = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 0x7F); + s32 mskt = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 127); tmp = tHeight; - s32 msks = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 0x7F); + s32 msks = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 127); // Set up the textures. gDPSetTile((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, @@ -837,8 +837,10 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { painting_setup_textures(&gfx, tWidth, tHeight); - const s16 s = ((tWidth * 32) - 32); - const s16 t = ((tHeight * 32) - 32); + const s16 s1 = -32; + const s16 t1 = 4; + const s16 s2 = ((tWidth * 32) - 32); + const s16 t2 = ((tHeight * 32) - 32) + 4; s32 idx = 0; s16 dy = (PAINTING_SIZE / imageCount); @@ -848,10 +850,10 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { for (s32 i = 0; i < imageCount; i++) { y1 = (i * dy); y2 = (y1 + dy); - make_vertex(verts, idx++, 0, y1, 0, -32, t, n[0], n[1], n[2], alpha); // Bottom Left - make_vertex(verts, idx++, PAINTING_SIZE, y1, 0, s, t, n[0], n[1], n[2], alpha); // Bottom Right - make_vertex(verts, idx++, PAINTING_SIZE, y2, 0, s, 0, n[0], n[1], n[2], alpha); // Top Right - make_vertex(verts, idx++, 0, y2, 0, -32, 0, n[0], n[1], n[2], alpha); // Top left + make_vertex(verts, idx++, 0, y1, 0, s1, t2, n[0], n[1], n[2], alpha); // Bottom Left + make_vertex(verts, idx++, PAINTING_SIZE, y1, 0, s2, t2, n[0], n[1], n[2], alpha); // Bottom Right + make_vertex(verts, idx++, PAINTING_SIZE, y2, 0, s2, t1, n[0], n[1], n[2], alpha); // Top Right + make_vertex(verts, idx++, 0, y2, 0, s1, t1, n[0], n[1], n[2], alpha); // Top left } gSPVertex(gfx++, verts, idx, 0); From 4b651cc174874abf31072b04a0b88001743dbc58 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 16 Aug 2022 15:48:50 -0700 Subject: [PATCH 18/81] Clean up painting texel calculations --- bin/segment2.c | 315 ++++++++++++++++++++++--------------------- src/game/paintings.c | 64 +++++---- 2 files changed, 197 insertions(+), 182 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 4fc730eead..9d94ea2142 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3372,163 +3372,164 @@ const PaintingData seg2_painting_triangle_mesh[] = { * The nth entry corresponds to the nth vertex in seg2_painting_triangle_mesh */ const PaintingData seg2_painting_mesh_neighbor_tris[] = { - 3, 1, 2, 3, - 1, 1, - 4, 1, 2, 4, 5, - 6, 2, 3, 5, 14, 59, 62, - 3, 3, 58, 59, - 6, 4, 5, 13, 14, 15, 16, - 2, 4, 13, - 2, 6, 7, - 6, 0, 6, 7, 8, 9, 10, - 4, 6, 10, 11, 12, - 4, 7, 8, 154, 155, - 6, 8, 9, 77, 154, 163, 194, - 6, 0, 9, 72, 73, 75, 77, - 6, 0, 10, 11, 19, 70, 72, - 6, 11, 12, 17, 18, 19, 20, - 4, 13, 16, 17, 18, - 6, 14, 15, 53, 61, 62, 64, - 6, 15, 16, 18, 20, 64, 67, - 6, 19, 20, 66, 67, 69, 70, - 8, 21, 22, 27, 31, 80, 81, 149, 150, - 3, 21, 22, 26, - 6, 23, 24, 25, 28, 57, 60, - 3, 24, 25, 26, - 6, 22, 24, 26, 27, 28, 29, - 6, 27, 29, 30, 31, 32, 33, - 8, 30, 33, 39, 40, 78, 79, 146, 147, - 6, 34, 35, 37, 44, 63, 65, - 6, 23, 28, 29, 32, 34, 35, - 6, 23, 35, 53, 60, 61, 63, - 6, 38, 39, 40, 41, 42, 43, - 6, 32, 33, 34, 37, 38, 39, - 8, 41, 42, 48, 52, 76, 82, 148, 151, - 6, 44, 46, 65, 66, 68, 69, - 6, 45, 46, 47, 56, 68, 71, - 6, 37, 38, 43, 44, 45, 46, - 6, 42, 43, 45, 47, 48, 49, - 6, 36, 48, 49, 50, 51, 52, - 8, 50, 51, 152, 153, 170, 174, 214, 215, - 6, 36, 47, 49, 54, 55, 56, - 6, 54, 55, 74, 169, 178, 196, - 6, 54, 56, 71, 73, 74, 75, - 3, 25, 57, 58, - 6, 57, 58, 59, 60, 61, 62, - 6, 53, 63, 64, 65, 66, 67, - 6, 68, 69, 70, 71, 72, 73, - 6, 74, 75, 77, 194, 195, 196, - 6, 79, 82, 125, 137, 146, 148, - 6, 78, 80, 129, 130, 147, 149, - 6, 76, 144, 145, 151, 152, 153, - 3, 84, 85, 86, - 1, 85, - 4, 85, 86, 91, 95, - 6, 83, 87, 88, 90, 119, 124, - 3, 84, 87, 88, - 6, 89, 91, 92, 93, 94, 95, - 6, 84, 86, 87, 89, 90, 91, - 4, 93, 94, 101, 105, - 2, 94, 95, - 6, 96, 97, 100, 108, 126, 131, - 6, 83, 89, 90, 92, 96, 97, - 6, 83, 97, 123, 124, 126, 127, - 6, 99, 101, 102, 103, 104, 105, - 6, 92, 93, 96, 99, 100, 101, - 4, 98, 103, 104, 110, - 2, 104, 105, - 6, 99, 100, 102, 106, 107, 108, - 6, 106, 107, 111, 117, 134, 138, - 6, 106, 108, 131, 132, 134, 135, - 6, 98, 109, 110, 112, 113, 114, - 6, 102, 103, 107, 109, 110, 111, - 4, 113, 114, 221, 223, - 2, 98, 114, - 6, 115, 116, 142, 213, 226, 236, - 6, 109, 111, 112, 115, 116, 117, - 6, 116, 117, 138, 140, 141, 142, - 3, 88, 118, 119, - 6, 120, 121, 122, 130, 149, 150, - 3, 118, 120, 121, - 6, 118, 119, 120, 122, 123, 124, - 6, 125, 128, 129, 133, 146, 147, - 6, 122, 123, 127, 128, 129, 130, - 6, 126, 127, 128, 131, 132, 133, - 6, 136, 137, 139, 145, 148, 151, - 6, 125, 132, 133, 135, 136, 137, - 6, 134, 135, 136, 138, 139, 140, - 6, 143, 144, 153, 215, 246, 252, - 6, 139, 140, 141, 143, 144, 145, - 6, 154, 155, 162, 163, 164, 165, - 1, 157, - 3, 157, 158, 159, - 4, 157, 159, 160, 161, - 6, 158, 159, 160, 167, 205, 206, - 6, 156, 160, 161, 166, 167, 168, - 6, 162, 163, 194, 195, 197, 199, - 6, 162, 164, 166, 168, 199, 202, - 4, 156, 164, 165, 166, - 6, 167, 168, 201, 202, 204, 205, - 6, 36, 50, 55, 169, 170, 171, - 6, 170, 171, 172, 173, 174, 175, - 8, 172, 173, 180, 184, 209, 210, 211, 212, - 6, 176, 177, 179, 188, 198, 200, - 6, 169, 171, 175, 176, 177, 178, - 6, 177, 178, 195, 196, 197, 198, - 6, 172, 175, 176, 179, 180, 181, - 6, 180, 181, 182, 183, 184, 185, - 8, 182, 183, 189, 192, 216, 217, 218, 219, - 6, 186, 187, 190, 193, 203, 207, - 6, 179, 181, 185, 186, 187, 188, - 6, 187, 188, 200, 201, 203, 204, - 6, 182, 185, 186, 189, 190, 191, - 3, 189, 191, 192, - 3, 193, 207, 208, - 6, 197, 198, 199, 200, 201, 202, - 6, 203, 204, 205, 206, 207, 208, - 6, 209, 210, 250, 251, 253, 258, - 6, 210, 211, 217, 219, 247, 258, - 6, 209, 212, 214, 215, 251, 252, - 3, 216, 218, 263, - 6, 218, 219, 247, 259, 261, 263, - 6, 220, 221, 222, 223, 224, 225, - 6, 112, 113, 115, 213, 220, 221, - 2, 223, 224, - 4, 224, 225, 230, 235, - 6, 226, 227, 236, 245, 248, 249, - 6, 213, 220, 222, 226, 227, 228, - 6, 227, 228, 231, 239, 249, 255, - 6, 229, 230, 232, 233, 234, 235, - 6, 222, 225, 228, 229, 230, 231, - 2, 233, 235, - 4, 233, 234, 241, 243, - 6, 237, 238, 242, 244, 257, 262, - 6, 229, 231, 232, 237, 238, 239, - 6, 238, 239, 254, 255, 256, 257, - 3, 240, 241, 243, - 6, 232, 234, 237, 240, 241, 242, - 3, 244, 260, 262, - 6, 141, 142, 143, 236, 245, 246, - 6, 245, 246, 248, 250, 251, 252, - 6, 248, 249, 250, 253, 254, 255, - 6, 247, 253, 254, 256, 258, 259, - 6, 256, 257, 259, 260, 261, 262, - 2, 12, 17, - 2, 21, 81, - 3, 81, 121, 150, - 4, 30, 31, 78, 80, - 4, 40, 41, 79, 82, - 4, 51, 52, 76, 152, - 2, 155, 165, - 3, 158, 206, 208, - 2, 156, 161, - 4, 173, 174, 212, 214, - 4, 183, 184, 211, 217, - 3, 190, 191, 193, - 2, 192, 216, - 3, 260, 261, 263, - 3, 240, 242, 244, - 1, 243, +// ID num, neighbors... + /* 0*/ 3, 1, 2, 3, + /* 1*/ 1, 1, + /* 2*/ 4, 1, 2, 4, 5, + /* 3*/ 6, 2, 3, 5, 14, 59, 62, + /* 4*/ 3, 3, 58, 59, + /* 5*/ 6, 4, 5, 13, 14, 15, 16, + /* 6*/ 2, 4, 13, + /* 7*/ 2, 6, 7, + /* 8*/ 6, 0, 6, 7, 8, 9, 10, + /* 9*/ 4, 6, 10, 11, 12, + /* 10*/ 4, 7, 8, 154, 155, + /* 11*/ 6, 8, 9, 77, 154, 163, 194, + /* 12*/ 6, 0, 9, 72, 73, 75, 77, + /* 13*/ 6, 0, 10, 11, 19, 70, 72, + /* 14*/ 6, 11, 12, 17, 18, 19, 20, + /* 15*/ 4, 13, 16, 17, 18, + /* 16*/ 6, 14, 15, 53, 61, 62, 64, + /* 17*/ 6, 15, 16, 18, 20, 64, 67, + /* 18*/ 6, 19, 20, 66, 67, 69, 70, + /* 19*/ 8, 21, 22, 27, 31, 80, 81, 149, 150, + /* 20*/ 3, 21, 22, 26, + /* 21*/ 6, 23, 24, 25, 28, 57, 60, + /* 22*/ 3, 24, 25, 26, + /* 23*/ 6, 22, 24, 26, 27, 28, 29, + /* 24*/ 6, 27, 29, 30, 31, 32, 33, + /* 25*/ 8, 30, 33, 39, 40, 78, 79, 146, 147, + /* 26*/ 6, 34, 35, 37, 44, 63, 65, + /* 27*/ 6, 23, 28, 29, 32, 34, 35, + /* 28*/ 6, 23, 35, 53, 60, 61, 63, + /* 29*/ 6, 38, 39, 40, 41, 42, 43, + /* 30*/ 6, 32, 33, 34, 37, 38, 39, + /* 31*/ 8, 41, 42, 48, 52, 76, 82, 148, 151, + /* 32*/ 6, 44, 46, 65, 66, 68, 69, + /* 33*/ 6, 45, 46, 47, 56, 68, 71, + /* 34*/ 6, 37, 38, 43, 44, 45, 46, + /* 35*/ 6, 42, 43, 45, 47, 48, 49, + /* 36*/ 6, 36, 48, 49, 50, 51, 52, + /* 37*/ 8, 50, 51, 152, 153, 170, 174, 214, 215, + /* 38*/ 6, 36, 47, 49, 54, 55, 56, + /* 39*/ 6, 54, 55, 74, 169, 178, 196, + /* 40*/ 6, 54, 56, 71, 73, 74, 75, + /* 41*/ 3, 25, 57, 58, + /* 42*/ 6, 57, 58, 59, 60, 61, 62, + /* 43*/ 6, 53, 63, 64, 65, 66, 67, + /* 44*/ 6, 68, 69, 70, 71, 72, 73, + /* 45*/ 6, 74, 75, 77, 194, 195, 196, + /* 46*/ 6, 79, 82, 125, 137, 146, 148, + /* 47*/ 6, 78, 80, 129, 130, 147, 149, + /* 48*/ 6, 76, 144, 145, 151, 152, 153, + /* 49*/ 3, 84, 85, 86, + /* 50*/ 1, 85, + /* 51*/ 4, 85, 86, 91, 95, + /* 52*/ 6, 83, 87, 88, 90, 119, 124, + /* 53*/ 3, 84, 87, 88, + /* 54*/ 6, 89, 91, 92, 93, 94, 95, + /* 55*/ 6, 84, 86, 87, 89, 90, 91, + /* 56*/ 4, 93, 94, 101, 105, + /* 57*/ 2, 94, 95, + /* 58*/ 6, 96, 97, 100, 108, 126, 131, + /* 59*/ 6, 83, 89, 90, 92, 96, 97, + /* 60*/ 6, 83, 97, 123, 124, 126, 127, + /* 61*/ 6, 99, 101, 102, 103, 104, 105, + /* 62*/ 6, 92, 93, 96, 99, 100, 101, + /* 63*/ 4, 98, 103, 104, 110, + /* 64*/ 2, 104, 105, + /* 65*/ 6, 99, 100, 102, 106, 107, 108, + /* 66*/ 6, 106, 107, 111, 117, 134, 138, + /* 67*/ 6, 106, 108, 131, 132, 134, 135, + /* 68*/ 6, 98, 109, 110, 112, 113, 114, + /* 69*/ 6, 102, 103, 107, 109, 110, 111, + /* 70*/ 4, 113, 114, 221, 223, + /* 71*/ 2, 98, 114, + /* 72*/ 6, 115, 116, 142, 213, 226, 236, + /* 73*/ 6, 109, 111, 112, 115, 116, 117, + /* 74*/ 6, 116, 117, 138, 140, 141, 142, + /* 75*/ 3, 88, 118, 119, + /* 76*/ 6, 120, 121, 122, 130, 149, 150, + /* 77*/ 3, 118, 120, 121, + /* 78*/ 6, 118, 119, 120, 122, 123, 124, + /* 79*/ 6, 125, 128, 129, 133, 146, 147, + /* 80*/ 6, 122, 123, 127, 128, 129, 130, + /* 81*/ 6, 126, 127, 128, 131, 132, 133, + /* 82*/ 6, 136, 137, 139, 145, 148, 151, + /* 83*/ 6, 125, 132, 133, 135, 136, 137, + /* 84*/ 6, 134, 135, 136, 138, 139, 140, + /* 85*/ 6, 143, 144, 153, 215, 246, 252, + /* 86*/ 6, 139, 140, 141, 143, 144, 145, + /* 87*/ 6, 154, 155, 162, 163, 164, 165, + /* 88*/ 1, 157, + /* 89*/ 3, 157, 158, 159, + /* 90*/ 4, 157, 159, 160, 161, + /* 91*/ 6, 158, 159, 160, 167, 205, 206, + /* 92*/ 6, 156, 160, 161, 166, 167, 168, + /* 93*/ 6, 162, 163, 194, 195, 197, 199, + /* 94*/ 6, 162, 164, 166, 168, 199, 202, + /* 95*/ 4, 156, 164, 165, 166, + /* 96*/ 6, 167, 168, 201, 202, 204, 205, + /* 97*/ 6, 36, 50, 55, 169, 170, 171, + /* 98*/ 6, 170, 171, 172, 173, 174, 175, + /* 99*/ 8, 172, 173, 180, 184, 209, 210, 211, 212, + /*100*/ 6, 176, 177, 179, 188, 198, 200, + /*101*/ 6, 169, 171, 175, 176, 177, 178, + /*102*/ 6, 177, 178, 195, 196, 197, 198, + /*103*/ 6, 172, 175, 176, 179, 180, 181, + /*104*/ 6, 180, 181, 182, 183, 184, 185, + /*105*/ 8, 182, 183, 189, 192, 216, 217, 218, 219, + /*106*/ 6, 186, 187, 190, 193, 203, 207, + /*107*/ 6, 179, 181, 185, 186, 187, 188, + /*108*/ 6, 187, 188, 200, 201, 203, 204, + /*109*/ 6, 182, 185, 186, 189, 190, 191, + /*110*/ 3, 189, 191, 192, + /*111*/ 3, 193, 207, 208, + /*112*/ 6, 197, 198, 199, 200, 201, 202, + /*113*/ 6, 203, 204, 205, 206, 207, 208, + /*114*/ 6, 209, 210, 250, 251, 253, 258, + /*115*/ 6, 210, 211, 217, 219, 247, 258, + /*116*/ 6, 209, 212, 214, 215, 251, 252, + /*117*/ 3, 216, 218, 263, + /*118*/ 6, 218, 219, 247, 259, 261, 263, + /*119*/ 6, 220, 221, 222, 223, 224, 225, + /*120*/ 6, 112, 113, 115, 213, 220, 221, + /*121*/ 2, 223, 224, + /*122*/ 4, 224, 225, 230, 235, + /*123*/ 6, 226, 227, 236, 245, 248, 249, + /*124*/ 6, 213, 220, 222, 226, 227, 228, + /*125*/ 6, 227, 228, 231, 239, 249, 255, + /*126*/ 6, 229, 230, 232, 233, 234, 235, + /*127*/ 6, 222, 225, 228, 229, 230, 231, + /*128*/ 2, 233, 235, + /*129*/ 4, 233, 234, 241, 243, + /*130*/ 6, 237, 238, 242, 244, 257, 262, + /*131*/ 6, 229, 231, 232, 237, 238, 239, + /*132*/ 6, 238, 239, 254, 255, 256, 257, + /*133*/ 3, 240, 241, 243, + /*134*/ 6, 232, 234, 237, 240, 241, 242, + /*135*/ 3, 244, 260, 262, + /*136*/ 6, 141, 142, 143, 236, 245, 246, + /*137*/ 6, 245, 246, 248, 250, 251, 252, + /*138*/ 6, 248, 249, 250, 253, 254, 255, + /*139*/ 6, 247, 253, 254, 256, 258, 259, + /*140*/ 6, 256, 257, 259, 260, 261, 262, + /*141*/ 2, 12, 17, + /*142*/ 2, 21, 81, + /*143*/ 3, 81, 121, 150, + /*144*/ 4, 30, 31, 78, 80, + /*145*/ 4, 40, 41, 79, 82, + /*146*/ 4, 51, 52, 76, 152, + /*147*/ 2, 155, 165, + /*148*/ 3, 158, 206, 208, + /*149*/ 2, 156, 161, + /*150*/ 4, 173, 174, 212, 214, + /*151*/ 4, 183, 184, 211, 217, + /*152*/ 3, 190, 191, 193, + /*153*/ 2, 192, 216, + /*154*/ 3, 260, 261, 263, + /*155*/ 3, 240, 242, 244, + /*156*/ 1, 243, }; // 0x07021AE0 - 0x07021FFA diff --git a/src/game/paintings.c b/src/game/paintings.c index c278c01705..b45b209f2b 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -349,11 +349,11 @@ void painting_update_ripple_state(const struct Painting *painting) { * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_generate_mesh(const struct Painting *painting, const PaintingData *mesh, PaintingData numTris) { +void painting_generate_mesh(const struct Painting *painting, const PaintingData *mesh, PaintingData numVtx) { struct Object *obj = gCurGraphNodeObjectNode; PaintingData i, tri; - sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(struct PaintingMeshVertex))); + sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); struct PaintingMeshVertex *paintingMesh = sPaintingMesh; @@ -378,7 +378,7 @@ void painting_generate_mesh(const struct Painting *painting, const PaintingData // Loop through all the painting vertices and calculate the ripple magnitude at each point. // Accesses are off by 1 since the first entry is the number of vertices. - for (i = 0; i < numTris; i++) { + for (i = 0; i < numVtx; i++) { tri = (i * 3); paintingMesh->pos[0] = mesh[tri + 1]; paintingMesh->pos[1] = mesh[tri + 2]; @@ -461,24 +461,24 @@ void painting_calculate_triangle_normals(const PaintingData *mesh, PaintingData void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingData numVtx) { PaintingData tri; PaintingData i, j; - PaintingData neighbors; + PaintingData numNeighbors; PaintingData entry = 0; for (i = 0; i < numVtx; i++) { Vec3f n = { 0.0f, 0.0f, 0.0f }; // The first number of each entry is the number of adjacent tris. - neighbors = neighborTris[entry]; - for (j = 0; j < neighbors; j++) { - tri = neighborTris[entry + j + 1]; + numNeighbors = neighborTris[entry]; + for (j = 0; j < numNeighbors; j++) { + tri = neighborTris[entry + 1 + j]; vec3f_add(n, sPaintingTriNorms[tri]); } // Move to the next vertex's entry - entry += (neighbors + 1); + entry += (1 + numNeighbors); // Average the surface normals from each neighboring tri. - vec3_div_val(n, neighbors); + vec3_div_val(n, numNeighbors); f32 nlen = vec3_sumsq(n); if (FLT_IS_NONZERO(nlen)) { @@ -498,6 +498,13 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD #define TRI_PER_GRP (VTX_BUF_MAX / 3) // 5 or 10 #define VTX_PER_GRP (TRI_PER_GRP * 3) // 15 or 30 +// Amount by which to shift the texture. +#define PTX_OFFSET_S 0 +#define PTX_OFFSET_T 4 + +// Convert image coordinates to texel coordinates. +#define ST(t) (((t) - 1) << 5) + /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, * using 'textureMap'. @@ -516,7 +523,7 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC s16 tx, ty; PaintingData mapVerts = textureMap[0]; - PaintingData mapTris = textureMap[mapVerts + 1]; + PaintingData mapTris = textureMap[1 + mapVerts]; // We can fit VTX_PER_GRP vertices in the RSP's vertex buffer. // Group triangles by TRI_PER_GRP, with one remainder group. @@ -542,11 +549,16 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); - f32 dy = (PAINTING_SIZE / imageCount); - s16 y1 = ((index + 1) * dy); + // Width and height of the section. + const f32 dx = (PAINTING_SIZE / 1); + const f32 dy = (PAINTING_SIZE / imageCount); + + // To scale the vertex positions into texture positions. + const f32 tWidthScale = (ST(tWidth ) / dx); + const f32 tHeightScale = (ST(tHeight) / dy); - f32 tWidthScale = (((tWidth - 0) * 32) / (f32)PAINTING_SIZE); - f32 tHeightScale = (((tHeight - 1) * 32) / dy); + // Starting Y position of the current section. + const s16 y1 = ((index + 1) * dy); // Draw the groups of TRI_PER_GRP first. for (group = 0; group < triGroups; group++) { @@ -564,14 +576,14 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC mapping = (textureMap[triGroup + map]); // The first entry is the ID of the vertex in the mesh. - meshVtx = textureMap[mapping + 1]; + meshVtx = textureMap[1 + mapping]; // Get a pointer to the current mesh. mesh = &sPaintingMesh[meshVtx]; // Texture coordinates. - tx = ((mesh->pos[0] * tWidthScale) - 32); - ty = (((y1 - mesh->pos[1]) * tHeightScale) + 4); + tx = (PTX_OFFSET_S + (mesh->pos[0] * tWidthScale)); + ty = (PTX_OFFSET_T + ((y1 - mesh->pos[1]) * tHeightScale)); // Map the texture and place it in the verts array. make_vertex(verts, (groupIndex + map), @@ -601,14 +613,14 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC mapping = (textureMap[triGroup + map]); // The first entry is the ID of the vertex in the mesh. - meshVtx = textureMap[mapping + 1]; + meshVtx = textureMap[1 + mapping]; // Get a pointer to the current mesh. mesh = &sPaintingMesh[meshVtx]; // Texture coordinates. - tx = ((mesh->pos[0] * tWidthScale) - 32); - ty = (((y1 - mesh->pos[1]) * tHeightScale) + 4); + tx = (PTX_OFFSET_S + (mesh->pos[0] * tWidthScale)); + ty = (PTX_OFFSET_T + ((y1 - mesh->pos[1]) * tHeightScale)); make_vertex(verts, ((triGroups * VTX_PER_GRP) + map), mesh->pos[0], @@ -729,7 +741,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { painting_setup_textures(&gfx, tWidth, tHeight); - //! TODO: Automatically determine texture maps for the image count. + //! TODO: Automatically determine texture maps based on the image count. const PaintingData **textureMaps = NULL; if (imageCount > 1) { textureMaps = segmented_to_virtual(seg2_painting_image_texture_maps); @@ -837,10 +849,12 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { painting_setup_textures(&gfx, tWidth, tHeight); - const s16 s1 = -32; - const s16 t1 = 4; - const s16 s2 = ((tWidth * 32) - 32); - const s16 t2 = ((tHeight * 32) - 32) + 4; + // Top left corner texture coordinates. + const s16 s1 = PTX_OFFSET_S; + const s16 t1 = PTX_OFFSET_T; + // Bottom right corner texture coordinates. + const s16 s2 = (s1 + ST(tWidth )); + const s16 t2 = (t1 + ST(tHeight)); s32 idx = 0; s16 dy = (PAINTING_SIZE / imageCount); From fc093b9fdbf38eb1306b9e12568eb31094831756 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 16 Aug 2022 21:57:17 -0700 Subject: [PATCH 19/81] Add get_exponent for painting texture setup + dl_painting_not_rippling cleanup --- src/game/paintings.c | 53 +++++++++++++++++++++++--------------------- src/game/paintings.h | 3 +++ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index b45b209f2b..fcb1f9aee2 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -498,13 +498,10 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD #define TRI_PER_GRP (VTX_BUF_MAX / 3) // 5 or 10 #define VTX_PER_GRP (TRI_PER_GRP * 3) // 15 or 30 -// Amount by which to shift the texture. +// Amount by which to shift the painting textures. #define PTX_OFFSET_S 0 #define PTX_OFFSET_T 4 -// Convert image coordinates to texel coordinates. -#define ST(t) (((t) - 1) << 5) - /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, * using 'textureMap'. @@ -554,8 +551,8 @@ Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageC const f32 dy = (PAINTING_SIZE / imageCount); // To scale the vertex positions into texture positions. - const f32 tWidthScale = (ST(tWidth ) / dx); - const f32 tHeightScale = (ST(tHeight) / dy); + const f32 tWidthScale = (TC(tWidth ) / dx); + const f32 tHeightScale = (TC(tHeight) / dy); // Starting Y position of the current section. const s16 y1 = ((index + 1) * dy); @@ -680,22 +677,26 @@ Gfx *painting_model_view_transform(const struct Painting *painting) { return dlist; } +/** + * Gets the exponent of an integer by converting it into a float and extracting the exponent bits. + */ +s32 get_exponent(s32 x) { + union { s32 i; f32 f; } b = { .f = x }; + return (((b.i >> 23) & (u32)BITMASK(8)) - 127); +} + /** * Set up the texture format in the display list. */ void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeight) { - // Get the exponents (shift) of tWidth and tHeight for the texture map. - // Making this conversion into its own function does not work for some reason. - f32 tmp = tWidth; - s32 mskt = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 127); - tmp = tHeight; - s32 msks = ((((*(s32 *)&tmp) >> 23) & (u32)BITMASK(8)) - 127); + u32 masks = get_exponent(tWidth); + u32 maskt = get_exponent(tHeight); // Set up the textures. gDPSetTile((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, (tWidth >> 2), 0, G_TX_RENDERTILE, 0, - (G_TX_WRAP | G_TX_NOMIRROR), msks, G_TX_NOLOD, - (G_TX_WRAP | G_TX_NOMIRROR), mskt, G_TX_NOLOD + (G_TX_WRAP | G_TX_NOMIRROR), maskt, G_TX_NOLOD, + (G_TX_WRAP | G_TX_NOMIRROR), masks, G_TX_NOLOD ); gDPSetTileSize((*gfx)++, 0, 0, 0, @@ -739,8 +740,6 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); - painting_setup_textures(&gfx, tWidth, tHeight); - //! TODO: Automatically determine texture maps based on the image count. const PaintingData **textureMaps = NULL; if (imageCount > 1) { @@ -749,6 +748,8 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { textureMaps = segmented_to_virtual(seg2_painting_env_map_texture_maps); } + painting_setup_textures(&gfx, tWidth, tHeight); + // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { textureMap = segmented_to_virtual(textureMaps[i]); @@ -804,9 +805,9 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { s32 shaded = painting->shaded; u32 gfxCmds = ( /*gSPDisplayList */ 1 + + /*gSPVertex */ 1 + /*gDPSetTile */ 1 + /*gDPSetTileSize */ 1 + - /*gSPVertex */ 1 + (imageCount * ( /*gDPSetTextureImage */ 1 + /*gDPLoadSync */ 1 + @@ -847,31 +848,33 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { PaintingData tWidth = painting->textureWidth; PaintingData tHeight = painting->textureHeight; - painting_setup_textures(&gfx, tWidth, tHeight); + const f32 dx = (PAINTING_SIZE / 1); + const f32 dy = (PAINTING_SIZE / imageCount); // Top left corner texture coordinates. const s16 s1 = PTX_OFFSET_S; const s16 t1 = PTX_OFFSET_T; // Bottom right corner texture coordinates. - const s16 s2 = (s1 + ST(tWidth )); - const s16 t2 = (t1 + ST(tHeight)); + const s16 s2 = (s1 + TC(tWidth )); + const s16 t2 = (t1 + TC(tHeight)); s32 idx = 0; - s16 dy = (PAINTING_SIZE / imageCount); s16 y1, y2; // Generate vertices for (s32 i = 0; i < imageCount; i++) { y1 = (i * dy); y2 = (y1 + dy); - make_vertex(verts, idx++, 0, y1, 0, s1, t2, n[0], n[1], n[2], alpha); // Bottom Left - make_vertex(verts, idx++, PAINTING_SIZE, y1, 0, s2, t2, n[0], n[1], n[2], alpha); // Bottom Right - make_vertex(verts, idx++, PAINTING_SIZE, y2, 0, s2, t1, n[0], n[1], n[2], alpha); // Top Right - make_vertex(verts, idx++, 0, y2, 0, s1, t1, n[0], n[1], n[2], alpha); // Top left + make_vertex(verts, idx++, 0, y1, 0, s1, t2, n[0], n[1], n[2], alpha); // Bottom Left + make_vertex(verts, idx++, dx, y1, 0, s2, t2, n[0], n[1], n[2], alpha); // Bottom Right + make_vertex(verts, idx++, dx, y2, 0, s2, t1, n[0], n[1], n[2], alpha); // Top Right + make_vertex(verts, idx++, 0, y2, 0, s1, t1, n[0], n[1], n[2], alpha); // Top left } gSPVertex(gfx++, verts, idx, 0); + painting_setup_textures(&gfx, tWidth, tHeight); + for (s32 i = 0; i < imageCount; i++) { gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, textures[i]); gDPLoadSync(gfx++); diff --git a/src/game/paintings.h b/src/game/paintings.h index e66751bc9f..3b7adae331 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -27,6 +27,9 @@ /// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. #define PAINTING_MARIO_Y_OFFSET 50 +// Convert image coordinates to texel coordinates. +#define TC(t) (((t) - 1) << 5) + // HMC painting group enum HMCPaintingIDs { From c7115d4a2cca9b7ce36806bc732d6b73ad98833c Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 29 Sep 2022 14:32:54 -0700 Subject: [PATCH 20/81] Fix seams between painting sections on console --- src/game/paintings.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index fcb1f9aee2..bdb911a3a3 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -688,15 +688,16 @@ s32 get_exponent(s32 x) { /** * Set up the texture format in the display list. */ -void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeight) { +void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeight, PaintingData isEnvMap) { + s16 cm = isEnvMap ? (G_TX_WRAP | G_TX_NOMIRROR) : G_TX_CLAMP; u32 masks = get_exponent(tWidth); u32 maskt = get_exponent(tHeight); // Set up the textures. gDPSetTile((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, (tWidth >> 2), 0, G_TX_RENDERTILE, 0, - (G_TX_WRAP | G_TX_NOMIRROR), maskt, G_TX_NOLOD, - (G_TX_WRAP | G_TX_NOMIRROR), masks, G_TX_NOLOD + cm, maskt, G_TX_NOLOD, + cm, masks, G_TX_NOLOD ); gDPSetTileSize((*gfx)++, 0, 0, 0, @@ -748,7 +749,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { textureMaps = segmented_to_virtual(seg2_painting_env_map_texture_maps); } - painting_setup_textures(&gfx, tWidth, tHeight); + painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { @@ -873,7 +874,7 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { gSPVertex(gfx++, verts, idx, 0); - painting_setup_textures(&gfx, tWidth, tHeight); + painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); for (s32 i = 0; i < imageCount; i++) { gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, textures[i]); From 2222429d9d6f06a618c249ee03af3b274ad3cb58 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 8 Oct 2022 13:04:48 -0700 Subject: [PATCH 21/81] Fix ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS comment + Undo removal of trailing whitespace --- include/config/config_game.h | 6 ++++-- src/engine/math_util.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/config/config_game.h b/include/config/config_game.h index 15e13562cf..8a4127f1de 100644 --- a/include/config/config_game.h +++ b/include/config/config_game.h @@ -4,8 +4,10 @@ * GAME SETTINGS * *****************/ -// Enables some mechanics that change behavior depending on hardcoded level numbers. -// TODO: separate this into separate defines, behavior params, or make these mechanics otherwise dynamic. +/** + * Enables some mechanics that change behavior depending on hardcoded level numbers. + * TODO: separate this into separate defines, behavior params, or make these mechanics otherwise dynamic. + */ // #define ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS /** diff --git a/src/engine/math_util.c b/src/engine/math_util.c index d90dbbe6d7..82b9454e1b 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -564,8 +564,8 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle) float m12 = dest[1][2]; float cosa = coss(angle); float sina = sins(angle); - dest[0][0] = cosa * m00 + sina * m10; - dest[0][1] = cosa * m01 + sina * m11; + dest[0][0] = cosa * m00 + sina * m10; + dest[0][1] = cosa * m01 + sina * m11; dest[0][2] = cosa * m02 + sina * m12; dest[1][0] = -sina * m00 + cosa * m10; dest[1][1] = -sina * m01 + cosa * m11; @@ -1287,7 +1287,7 @@ s32 anim_spline_poll(Vec3f result) { /** * @brief Checks if a ray intersects a surface using Möller–Trumbore intersection algorithm. - * + * * @param orig is the starting point of the ray. * @param dir is the normalized ray direction. * @param dir_length is the length of the ray. @@ -1335,7 +1335,7 @@ s32 ray_surface_intersect(Vec3f orig, Vec3f dir, f32 dir_length, struct Surface f32 u = f * vec3f_dot(s, h); // Check if 'u' is within bounds. if ((u < 0.0f) || (u > 1.0f)) return FALSE; - // Make 'q' the cross product of 's' and edge 1. + // Make 'q' the cross product of 's' and edge 1. Vec3f q; vec3f_cross(q, s, e1); // Make 'v' the cos(angle) between the ray and 'q', divided by 'det'. From a6676efee3a4132f17fc831bb146f33b77988695 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 8 Oct 2022 13:08:30 -0700 Subject: [PATCH 22/81] Revert some formatting changes in camera.c --- src/game/camera.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/game/camera.c b/src/game/camera.c index 809bfde700..533ca7549f 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9648,8 +9648,7 @@ void cutscene_exit_painting_start(struct Camera *c) { floorHeight = find_floor(c->pos[0], c->pos[1] + 10.f, c->pos[2], &floor); if (floorHeight != FLOOR_LOWER_LIMIT) { - floorHeight += 60.0f; - if (c->pos[1] < floorHeight) { + if (c->pos[1] < (floorHeight += 60.f)) { c->pos[1] = floorHeight; } } @@ -9682,10 +9681,10 @@ void cutscene_exit_painting_move_to_floor(struct Camera *c) { Vec3f floorHeight; vec3f_copy(floorHeight, sMarioCamState->pos); - floorHeight[1] = find_floor(sMarioCamState->pos[0], (sMarioCamState->pos[1] + 10.0f), sMarioCamState->pos[2], &floor); + floorHeight[1] = find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 10.f, sMarioCamState->pos[2], &floor); if (floor != NULL) { - floorHeight[1] = (floorHeight[1] + ((sMarioCamState->pos[1] - floorHeight[1]) * 0.7f) + 125.0f); + floorHeight[1] = floorHeight[1] + (sMarioCamState->pos[1] - floorHeight[1]) * 0.7f + 125.f; approach_vec3f_asymptotic(c->focus, floorHeight, 0.2f, 0.2f, 0.2f); if (floorHeight[1] < c->pos[1]) { @@ -9698,7 +9697,7 @@ void cutscene_exit_painting_move_to_floor(struct Camera *c) { * Cutscene played when Mario leaves a painting, either due to death or collecting a star. */ void cutscene_exit_painting(struct Camera *c) { - cutscene_event(cutscene_exit_painting_start, c, 0, 0); + cutscene_event(cutscene_exit_painting_start, c, 0, 0); cutscene_event(cutscene_exit_painting_move_to_mario, c, 5, -1); cutscene_event(cutscene_exit_painting_move_to_floor, c, 5, -1); From 3ea3c1fb3c8bd249eeece4225aa5a121ea4eb369 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 10 Oct 2022 15:30:17 -0700 Subject: [PATCH 23/81] Change painting object data pointer to const void --- include/object_fields.h | 4 +--- include/types.h | 2 -- src/game/camera.c | 4 +++- src/game/paintings.c | 42 +++++++++++++++++------------------------ src/game/paintings.h | 2 +- 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 1261a4da2b..5813c480ca 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -33,7 +33,6 @@ #define OBJECT_FIELD_CHAIN_SEGMENT(index) rawData.asChainSegment[index] #define OBJECT_FIELD_OBJ(index) rawData.asObject[index] #define OBJECT_FIELD_SURFACE(index) rawData.asSurface[index] -#define OBJECT_FIELD_PAINTING(index) rawData.asPainting[index] #define OBJECT_FIELD_VPTR(index) rawData.asVoidPtr[index] #define OBJECT_FIELD_CVPTR(index) rawData.asConstVoidPtr[index] #else @@ -44,7 +43,6 @@ #define OBJECT_FIELD_CHAIN_SEGMENT(index) ptrData.asChainSegment[index] #define OBJECT_FIELD_OBJ(index) ptrData.asObject[index] #define OBJECT_FIELD_SURFACE(index) ptrData.asSurface[index] -#define OBJECT_FIELD_PAINTING(index) rawData.asPainting[index] #define OBJECT_FIELD_VPTR(index) ptrData.asVoidPtr[index] #define OBJECT_FIELD_CVPTR(index) ptrData.asConstVoidPtr[index] #endif @@ -1257,7 +1255,7 @@ #define /*0x100*/ oYoshiTargetYaw OBJECT_FIELD_S32(0x1E) /* Painting */ -#define /*0x0F4*/ oPaintingPtr OBJECT_FIELD_PAINTING(0x1B) +#define /*0x0F4*/ oPaintingData OBJECT_FIELD_CVPTR(0x1B) #define /*0x0F8*/ oPaintingGroup OBJECT_FIELD_S16(0x1C, 0) #define /*0x0FA*/ oPaintingId OBJECT_FIELD_S16(0x1C, 1) #define /*0x1AC*/ oPaintingLocalMarioPosX OBJECT_FIELD_S16(0x1D, 0) diff --git a/include/types.h b/include/types.h index 300cd24a55..2e0f5189a6 100644 --- a/include/types.h +++ b/include/types.h @@ -315,7 +315,6 @@ struct Object { struct ChainSegment *asChainSegment[MAX_OBJECT_FIELDS]; struct Object *asObject[MAX_OBJECT_FIELDS]; struct Surface *asSurface[MAX_OBJECT_FIELDS]; - struct Painting *asPainting[MAX_OBJECT_FIELDS]; void *asVoidPtr[MAX_OBJECT_FIELDS]; const void *asConstVoidPtr[MAX_OBJECT_FIELDS]; #endif @@ -329,7 +328,6 @@ struct Object { struct ChainSegment *asChainSegment[MAX_OBJECT_FIELDS]; struct Object *asObject[MAX_OBJECT_FIELDS]; struct Surface *asSurface[MAX_OBJECT_FIELDS]; - struct Painting *asPainting[MAX_OBJECT_FIELDS]; void *asVoidPtr[MAX_OBJECT_FIELDS]; const void *asConstVoidPtr[MAX_OBJECT_FIELDS]; } ptrData; diff --git a/src/game/camera.c b/src/game/camera.c index 533ca7549f..85910e4ad0 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9584,9 +9584,11 @@ void cutscene_enter_painting(struct Camera *c) { struct Object *ripplingPainting = gCutsceneFocus; if (ripplingPainting != NULL) { + const struct Painting *painting = ripplingPainting->oPaintingData; + vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); - size = ((ripplingPainting->oPaintingPtr->sizeX + ripplingPainting->oPaintingPtr->sizeY) / 2.0f); + size = ((painting->sizeX + painting->sizeY) / 2.0f); focusOffset[0] = (size * 0.5f); focusOffset[1] = focusOffset[0]; focusOffset[2] = 0; diff --git a/src/game/paintings.c b/src/game/paintings.c index bdb911a3a3..98fa9cc343 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -154,22 +154,6 @@ static const struct RippleAnimationInfo sRippleAnimationInfo[] = { } }; -/** - * Get the painting group from gCurrLevelNum. - */ -UNUSED s32 get_painting_group(void) { - switch (gCurrLevelNum) { - case LEVEL_HMC: - return PAINTING_GROUP_HMC; - case LEVEL_CASTLE: - return PAINTING_GROUP_INSIDE_CASTLE; - case LEVEL_TTM: - return PAINTING_GROUP_TTM; - default: - return PAINTING_GROUP_NULL; - } -} - /** * Returns a pointer to the RippleAnimationInfo that best fits the painting type. */ @@ -195,7 +179,7 @@ const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *pa * @param resetTimer if TRUE, set the timer to 0 */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTimer) { - const struct Painting *painting = obj->oPaintingPtr; + const struct Painting *painting = obj->oPaintingData; const struct RippleAnimationInfo *anim = get_ripple_animation(painting); // Use a different set of variables depending on the state @@ -259,11 +243,14 @@ void painting_update_mario_pos(struct Object *obj) { // Get Mario's position in the painting's local space. vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); + // Get the const painting data. + const struct Painting *painting = obj->oPaintingData; + // Check if Mario is within the painting bounds laterally in local space. if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN - && marioLocalPos[0] < (obj->oPaintingPtr->sizeX + PAINTING_EDGE_MARGIN) + && marioLocalPos[0] < (painting->sizeX + PAINTING_EDGE_MARGIN) && marioLocalPos[1] > -PAINTING_EDGE_MARGIN - && marioLocalPos[1] < (obj->oPaintingPtr->sizeY + PAINTING_EDGE_MARGIN)) { + && marioLocalPos[1] < (painting->sizeY + PAINTING_EDGE_MARGIN)) { // Check whether Mario is inside the wobble zone. if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH && marioLocalPos[2] > 0.0f) { @@ -948,7 +935,7 @@ void reset_painting(struct Object *obj) { obj->oPaintingRippleTimer = 0; obj->oPaintingRippleX = 0; obj->oPaintingRippleY = 0; - if (obj->oPaintingPtr == &ddd_painting) { + if ((const struct Painting *)obj->oPaintingData == &ddd_painting) { // Move DDD painting to initial position, in case the animation // that moves the painting stops during level unload. obj->oPosX = 3456.0f; @@ -1010,13 +997,15 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con return NULL; } - Gfx *paintingDlist = NULL; - const struct Painting *painting = obj->oPaintingPtr; + // Get the const painting data. + const struct Painting *painting = obj->oPaintingData; if (painting == NULL) { return NULL; } + Gfx *paintingDlist = NULL; + if (callContext != GEO_CONTEXT_RENDER) { // Reset the update counter. obj->oLastPaintingUpdateCounter = (gAreaUpdateCounter - 1); @@ -1100,12 +1089,15 @@ void bhv_painting_init(void) { } const struct Painting * const* paintingGroup = sPaintingGroups[obj->oPaintingGroup]; - obj->oPaintingPtr = segmented_to_virtual(paintingGroup[obj->oPaintingId]); + const struct Painting *painting = segmented_to_virtual(paintingGroup[obj->oPaintingId]); + + // Set the object's painting data pointer. + obj->oPaintingData = painting; // The center of the painting, but with a z offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { - (obj->oPaintingPtr->sizeX * 0.5f), - (obj->oPaintingPtr->sizeY * 0.5f), + (painting->sizeX * 0.5f), + (painting->sizeY * 0.5f), PAINTING_WOBBLE_DEPTH // Distance in front of the painting to check for a room floor. }; diff --git a/src/game/paintings.h b/src/game/paintings.h index 3b7adae331..68d0baa50b 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -27,7 +27,7 @@ /// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. #define PAINTING_MARIO_Y_OFFSET 50 -// Convert image coordinates to texel coordinates. +/// Convert image coordinates to texel coordinates. #define TC(t) (((t) - 1) << 5) From d08afdef68f5805d64923a21a1438c81e13de51b Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 21 Oct 2022 13:24:46 -0700 Subject: [PATCH 24/81] Rename 'gRipplingPainting' to 'gRipplingPaintingObject' and 'gEnteredPainting' to 'gEnteredPaintingObject' --- src/game/behaviors/clock_arm.inc.c | 6 +++--- src/game/level_update.c | 8 ++++---- src/game/object_list_processor.c | 2 +- src/game/paintings.c | 20 ++++++++++---------- src/game/paintings.h | 4 ++-- src/game/sound_init.c | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/game/behaviors/clock_arm.inc.c b/src/game/behaviors/clock_arm.inc.c index 50e77d7ef5..61513deb55 100644 --- a/src/game/behaviors/clock_arm.inc.c +++ b/src/game/behaviors/clock_arm.inc.c @@ -16,8 +16,8 @@ void bhv_rotating_clock_arm_loop(void) { } } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_MOVING) { // If Mario is entering the Tick Tock Clock painting... - if (gEnteredPainting != NULL - && gEnteredPainting->oPaintingId == PAINTING_ID_CASTLE_TTC) { + if (gEnteredPaintingObject != NULL + && gEnteredPaintingObject->oPaintingId == PAINTING_ID_CASTLE_TTC) { // And this is the minute hand... if (cur_obj_has_behavior(bhvClockMinuteHand)) { // Set Tick Tick Clock's speed based on the angle of the hand. @@ -40,7 +40,7 @@ void bhv_rotating_clock_arm_loop(void) { o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_STOPPED } } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_STOPPED) { - if (gEnteredPainting == NULL) { + if (gEnteredPaintingObject == NULL) { o->oAction = TTC_PAINTING_CLOCK_ARM_ACT_MOVING; } } diff --git a/src/game/level_update.c b/src/game/level_update.c index 3e1a289619..ef5c1f4431 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -637,9 +637,9 @@ void initiate_painting_warp(void) { struct WarpNode *pWarpNode = NULL; if (gCurrentArea->paintingWarpNodes == NULL) { - gEnteredPainting = NULL; - } else if (gEnteredPainting != NULL) { - pWarpNode = &gCurrentArea->paintingWarpNodes[gEnteredPainting->oPaintingId]; + gEnteredPaintingObject = NULL; + } else if (gEnteredPaintingObject != NULL) { + pWarpNode = &gCurrentArea->paintingWarpNodes[gEnteredPaintingObject->oPaintingId]; if (pWarpNode != NULL) { if (gMarioState->action & ACT_FLAG_INTANGIBLE) { @@ -667,7 +667,7 @@ void initiate_painting_warp(void) { queue_rumble_data(80, 70); queue_rumble_decay(1); #endif - cutscene_object(CUTSCENE_ENTER_PAINTING, gEnteredPainting); + cutscene_object(CUTSCENE_ENTER_PAINTING, gEnteredPaintingObject); } } } else { diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 1d5b2650d9..be020376f6 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -518,7 +518,7 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { void clear_objects(void) { s32 i; - gEnteredPainting = NULL; + gEnteredPaintingObject = NULL; gTHIWaterDrained = 0; gTimeStopState = 0; gMarioObject = NULL; diff --git a/src/game/paintings.c b/src/game/paintings.c index 98fa9cc343..0e687596c7 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -107,12 +107,12 @@ const struct Painting * const* sPaintingGroups[] = { /** * The painting that is currently rippling. Only one painting can be rippling at once. */ -struct Object *gRipplingPainting = NULL; +struct Object *gRipplingPaintingObject = NULL; /** * The id of the painting Mario has entered. */ -struct Object *gEnteredPainting = NULL; +struct Object *gEnteredPaintingObject = NULL; /** * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. @@ -217,7 +217,7 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTime obj->oPaintingRippleTimer = 0; } - gRipplingPainting = obj; + gRipplingPaintingObject = obj; } /** @@ -300,7 +300,7 @@ void painting_update_ripple_state(const struct Painting *painting) { // If the painting is barely rippling, make it stop rippling. if (obj->oPaintingCurrRippleMag <= 1.0f) { obj->oPaintingState = PAINTING_IDLE; - gRipplingPainting = NULL; + gRipplingPaintingObject = NULL; } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // If the painting is doing the entry ripple but the ripples are as small as those from the @@ -915,13 +915,13 @@ Gfx *display_painting_not_rippling(const struct Painting *painting) { } /** - * Clear Mario-related state and clear gRipplingPainting. + * Clear Mario-related state and clear gRipplingPaintingObject. */ void reset_painting(struct Object *obj) { obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; - gRipplingPainting = NULL; + gRipplingPaintingObject = NULL; #ifdef NO_SEGMENTED_MEMORY // Make sure all variables are reset correctly. @@ -1066,10 +1066,10 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { // Mario has entered the painting. - gEnteredPainting = obj; - } else if (gEnteredPainting == obj) { - // Reset gEnteredPainting if it's this painting and this painting is not entered. - gEnteredPainting = NULL; + gEnteredPaintingObject = obj; + } else if (gEnteredPaintingObject == obj) { + // Reset gEnteredPaintingObject if it's this painting and this painting is not entered. + gEnteredPaintingObject = NULL; } } diff --git a/src/game/paintings.h b/src/game/paintings.h index 68d0baa50b..2e1dbe737e 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -176,8 +176,8 @@ struct PaintingMeshVertex { }; /*0x0C*/ -extern struct Object *gRipplingPainting; -extern struct Object *gEnteredPainting; +extern struct Object *gRipplingPaintingObject; +extern struct Object *gEnteredPaintingObject; Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); diff --git a/src/game/sound_init.c b/src/game/sound_init.c index f728335de0..5d3c2a3309 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -188,7 +188,7 @@ void play_menu_sounds(s16 soundMenuFlags) { * Called from threads: thread5_game_loop */ void play_painting_eject_sound(void) { - if (gRipplingPainting != NULL && gRipplingPainting->oPaintingState == PAINTING_ENTERED) { + if (gRipplingPaintingObject != NULL && gRipplingPaintingObject->oPaintingState == PAINTING_ENTERED) { // ripple when Mario enters painting if (!gPaintingEjectSoundPlayed) { play_sound(SOUND_GENERAL_PAINTING_EJECT, From 11fb0377fc0f47602cf0cd2802e72f3aca22b932 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 21 Oct 2022 13:33:39 -0700 Subject: [PATCH 25/81] Fix RR painting using the wrong ID --- levels/castle_inside/painting.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 1dd65b25f3..ef718de78f 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -347,7 +347,7 @@ const struct Painting sl_painting = { }; const struct Painting rr_painting = { - /* ID */ PAINTING_ID_CASTLE_THI_HUGE, + /* ID */ PAINTING_ID_CASTLE_RR, /* Image Count */ 0, /* Textures */ NULL, /* Texture w, h */ 0, 0, From e9dd49478fd45a40b782065704b8b74fc83f07f8 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 3 Nov 2022 04:07:13 -0700 Subject: [PATCH 26/81] Fix painting object field offsets --- include/object_fields.h | 18 +++++++++--------- src/game/paintings.c | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 5813c480ca..1440039a37 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1258,16 +1258,16 @@ #define /*0x0F4*/ oPaintingData OBJECT_FIELD_CVPTR(0x1B) #define /*0x0F8*/ oPaintingGroup OBJECT_FIELD_S16(0x1C, 0) #define /*0x0FA*/ oPaintingId OBJECT_FIELD_S16(0x1C, 1) -#define /*0x1AC*/ oPaintingLocalMarioPosX OBJECT_FIELD_S16(0x1D, 0) -#define /*0x1AE*/ oPaintingLocalMarioPosY OBJECT_FIELD_S16(0x1D, 1) +#define /*0x0FC*/ oPaintingLocalMarioPosX OBJECT_FIELD_S16(0x1D, 0) +#define /*0x0FE*/ oPaintingLocalMarioPosY OBJECT_FIELD_S16(0x1D, 1) #define /*0x100*/ oPaintingRippleX OBJECT_FIELD_S16(0x1E, 0) -#define /*0x104*/ oPaintingRippleY OBJECT_FIELD_S16(0x1E, 1) -#define /*0x108*/ oPaintingUpdateCounter OBJECT_FIELD_S16(0x1F, 0) -#define /*0x10C*/ oLastPaintingUpdateCounter OBJECT_FIELD_S16(0x1F, 1) -#define /*0x10C*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x21, 0) -#define /*0x10E*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x21, 1) -#define /*0x110*/ oPaintingState OBJECT_FIELD_S16(0x22, 0) -#define /*0x114*/ oPaintingRippleTimer OBJECT_FIELD_S16(0x22, 1) +#define /*0x102*/ oPaintingRippleY OBJECT_FIELD_S16(0x1E, 1) +#define /*0x104*/ oPaintingUpdateCounter OBJECT_FIELD_S16(0x1F, 0) +#define /*0x106*/ oPaintingLastUpdateCounter OBJECT_FIELD_S16(0x1F, 1) +#define /*0x108*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x20, 0) +#define /*0x10A*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x20, 1) +#define /*0x10C*/ oPaintingState OBJECT_FIELD_S16(0x21, 0) +#define /*0x10E*/ oPaintingRippleTimer OBJECT_FIELD_S16(0x21, 1) #define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) #define /*0x1A8*/ oPaintingRippleDecay OBJECT_FIELD_F32(0x48) #define /*0x1AC*/ oPaintingCurrRippleRate OBJECT_FIELD_F32(0x49) diff --git a/src/game/paintings.c b/src/game/paintings.c index 0e687596c7..56edae2c12 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -286,7 +286,7 @@ void painting_update_ripple_state(const struct Painting *painting) { struct Object *obj = gCurGraphNodeObjectNode; const struct RippleAnimationInfo *anim = get_ripple_animation(painting); - if (obj->oPaintingUpdateCounter != obj->oLastPaintingUpdateCounter) { + if (obj->oPaintingUpdateCounter != obj->oPaintingLastUpdateCounter) { obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; // Reset the timer to 0 if it overflows. @@ -1008,13 +1008,13 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con if (callContext != GEO_CONTEXT_RENDER) { // Reset the update counter. - obj->oLastPaintingUpdateCounter = (gAreaUpdateCounter - 1); + obj->oPaintingLastUpdateCounter = (gAreaUpdateCounter - 1); obj->oPaintingUpdateCounter = gAreaUpdateCounter; reset_painting(obj); } else if (callContext == GEO_CONTEXT_RENDER) { // Reset the update counter. - obj->oLastPaintingUpdateCounter = obj->oPaintingUpdateCounter; + obj->oPaintingLastUpdateCounter = obj->oPaintingUpdateCounter; obj->oPaintingUpdateCounter = gAreaUpdateCounter; #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) From 69330d30ecd5c028ba804f80806ceda8af6e0de8 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 7 Nov 2022 18:19:17 -0800 Subject: [PATCH 27/81] fix SurfaceClass enum --- include/surface_terrains.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/surface_terrains.h b/include/surface_terrains.h index 0f10067f61..8cf5e61fa7 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -240,7 +240,7 @@ enum SurfaceTypes { enum SurfaceClass { SURFACE_CLASS_DEFAULT, - SURFACE_CLASS_VERY_SLIPPERY = SURFACE_VERY_SLIPPERY, + SURFACE_CLASS_VERY_SLIPPERY, SURFACE_CLASS_SLIPPERY, SURFACE_CLASS_NOT_SLIPPERY }; From ab9f3279f44c296225640bd1701a92483890dd76 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 7 Nov 2022 19:08:26 -0800 Subject: [PATCH 28/81] Rename 'resetTimer' arg to 'doResetTimer' in painting_state --- src/game/paintings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 56edae2c12..1d1d6b0a9d 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -176,9 +176,9 @@ const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *pa * @param state The state to enter * @param painting,paintingGroup identifies the painting that is changing state * @param xSource,ySource what to use for the x and y origin of the ripple - * @param resetTimer if TRUE, set the timer to 0 + * @param doResetTimer if TRUE, set the timer to 0 */ -void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTimer) { +void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { const struct Painting *painting = obj->oPaintingData; const struct RippleAnimationInfo *anim = get_ripple_animation(painting); @@ -213,7 +213,7 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 resetTime // Set Mario's Y position for the WDW water level. gPaintingMarioYEntry = gMarioObject->oPosY; - if (resetTimer) { + if (doResetTimer) { obj->oPaintingRippleTimer = 0; } From 590084fd6af31d8eb2e5561a76fb66595cd96a8d Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 4 Dec 2022 20:04:49 -0500 Subject: [PATCH 29/81] Remove reset_painting and NO_SEGMENTED_MEMORY ifdef --- src/game/paintings.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 1d1d6b0a9d..8544af1aac 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -914,35 +914,7 @@ Gfx *display_painting_not_rippling(const struct Painting *painting) { return dlist; } -/** - * Clear Mario-related state and clear gRipplingPaintingObject. - */ -void reset_painting(struct Object *obj) { - obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; - obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; - - gRipplingPaintingObject = NULL; - -#ifdef NO_SEGMENTED_MEMORY - // Make sure all variables are reset correctly. - // With segmented memory the segments that contain the relevant - // Painting structs are reloaded from ROM upon level load. - obj->oPaintingState = PAINTING_IDLE; - obj->oPaintingCurrRippleMag = 0.0f; - obj->oPaintingRippleDecay = 1.0f; - obj->oPaintingCurrRippleRate = 0.0f; - obj->oPaintingDispersionFactor = 0.0f; - obj->oPaintingRippleTimer = 0; - obj->oPaintingRippleX = 0; - obj->oPaintingRippleY = 0; - if ((const struct Painting *)obj->oPaintingData == &ddd_painting) { - // Move DDD painting to initial position, in case the animation - // that moves the painting stops during level unload. - obj->oPosX = 3456.0f; - } -#endif -} - +#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) /** * Controls the x coordinate of the DDD painting. * @@ -979,6 +951,7 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) obj->oPosX = frontPos; } } +#endif /** * Render and update the painting whose id and group matches the values in the GraphNode's parameter. @@ -1006,13 +979,17 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con Gfx *paintingDlist = NULL; - if (callContext != GEO_CONTEXT_RENDER) { + if (callContext != GEO_CONTEXT_RENDER) { // Init // Reset the update counter. obj->oPaintingLastUpdateCounter = (gAreaUpdateCounter - 1); obj->oPaintingUpdateCounter = gAreaUpdateCounter; - reset_painting(obj); - } else if (callContext == GEO_CONTEXT_RENDER) { + // Clear Mario-related state and clear gRipplingPaintingObject. + obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; + obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; + + gRipplingPaintingObject = NULL; + } else if (callContext == GEO_CONTEXT_RENDER) { // Update // Reset the update counter. obj->oPaintingLastUpdateCounter = obj->oPaintingUpdateCounter; obj->oPaintingUpdateCounter = gAreaUpdateCounter; From 656c72ac91d5184ebfea393d9df55fbff0de1313 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 4 Dec 2022 22:11:13 -0500 Subject: [PATCH 30/81] Remove SAVE_FLAG_DDD_MOVED_BACK + allow paintings to move during some cutscenes. --- src/game/object_list_processor.c | 26 +++++--- src/game/paintings.c | 102 +++++++++++++++++-------------- src/game/save_file.c | 1 - src/game/save_file.h | 2 +- 4 files changed, 73 insertions(+), 58 deletions(-) diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index be020376f6..5e77188389 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -324,18 +324,26 @@ s32 update_objects_during_time_stop(struct ObjectNode *objList, struct ObjectNod // Selectively unfreeze certain objects if (!(gTimeStopState & TIME_STOP_ALL_OBJECTS)) { - if (gCurrentObject == gMarioObject && !(gTimeStopState & TIME_STOP_MARIO_AND_DOORS)) { + if (gCurrentObject->activeFlags & (ACTIVE_FLAG_UNIMPORTANT | ACTIVE_FLAG_INITIATED_TIME_STOP)) { unfrozen = TRUE; } - if ((gCurrentObject->oInteractType & (INTERACT_DOOR | INTERACT_WARP_DOOR)) - && !(gTimeStopState & TIME_STOP_MARIO_AND_DOORS)) { - unfrozen = TRUE; - } - - if (gCurrentObject->activeFlags - & (ACTIVE_FLAG_UNIMPORTANT | ACTIVE_FLAG_INITIATED_TIME_STOP)) { - unfrozen = TRUE; + if (!(gTimeStopState & TIME_STOP_MARIO_AND_DOORS)) { + // Mario + if (gCurrentObject == gMarioObject) { + unfrozen = TRUE; + } + + // Doors + if (gCurrentObject->oInteractType & (INTERACT_DOOR | INTERACT_WARP_DOOR)) { + unfrozen = TRUE; + } + + // Paintings + // HackerSM64 TODO: Make this an object flag. + if (cur_obj_has_behavior(bhvPainting)) { + unfrozen = TRUE; + } } } diff --git a/src/game/paintings.c b/src/game/paintings.c index 8544af1aac..7b2eb6433d 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -914,45 +914,6 @@ Gfx *display_painting_not_rippling(const struct Painting *painting) { return dlist; } -#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) -/** - * Controls the x coordinate of the DDD painting. - * - * Before Mario gets the "Board Bowser's Sub" star in DDD, the painting spawns at frontPos. - * - * If Mario just got the star, the painting's x coordinate moves to backPos at a rate of `speed` units. - * - * When the painting reaches backPos, a save flag is set so that the painting will spawn at backPos - * whenever it loads. - */ -void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) { -#ifdef UNLOCK_ALL - obj->oPosX = backPos; - return; -#endif - // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected. - if (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1) { - // Get the other save file flags and check whether DDD has already moved back. - if (save_file_get_flags() & SAVE_FLAG_DDD_MOVED_BACK) { - // If the painting has already moved back, place it in the back position. - obj->oPosX = backPos; - } else { - // If we've collected the star but not moved the painting back, - // Each frame, move the painting by a certain speed towards the back area. - obj->oPosX += speed; - if (obj->oPosX >= backPos) { - obj->oPosX = backPos; - // Tell the save file that we've moved DDD back. - save_file_set_flags(SAVE_FLAG_DDD_MOVED_BACK); - } - } - } else { - // If we haven't collected the star, put the painting at the front. - obj->oPosX = frontPos; - } -} -#endif - /** * Render and update the painting whose id and group matches the values in the GraphNode's parameter. * Use PAINTING_ID(id, group) to set the right parameter in a level's geo layout. @@ -994,14 +955,6 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con obj->oPaintingLastUpdateCounter = obj->oPaintingUpdateCounter; obj->oPaintingUpdateCounter = gAreaUpdateCounter; -#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) - // Update the ddd painting before drawing. - if (obj->oPaintingGroup == PAINTING_GROUP_INSIDE_CASTLE - && obj->oPaintingId == PAINTING_ID_CASTLE_DDD) { - move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); - } -#endif - // Update the painting info. painting_update_mario_pos(obj); @@ -1094,5 +1047,60 @@ void bhv_painting_init(void) { ); } + +#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) +s32 gDDDPaintingNotMoved = FALSE; + +/** + * Controls the x coordinate of the DDD painting. + * + * Before Mario gets the "Board Bowser's Sub" star in DDD, the painting spawns at frontPos. + * + * If Mario just got the star, the painting's x coordinate moves to backPos at a rate of `speed` units. + * + * When the painting reaches backPos, a save flag is set so that the painting will spawn at backPos + * whenever it loads. + */ +void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) { +#ifdef UNLOCK_ALL + obj->oPosX = backPos; + return; +#endif + // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected. + if (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1) { + // Check whether DDD has already moved back. + if (gDDDPaintingNotMoved) { + // If we've collected the star but not moved the painting back... + // Each frame, move the painting by a certain speed towards the back area. + obj->oPosX += speed; + if (obj->oPosX >= backPos) { + obj->oPosX = backPos; + + gDDDPaintingNotMoved = FALSE; + } + } else { + // If the painting has already moved back, place it in the back position. + obj->oPosX = backPos; + } + } else { + // If we haven't collected the star, put the painting at the front. + obj->oPosX = frontPos; + + // Set this so the painting gets moved once the star is collected. + gDDDPaintingNotMoved = TRUE; + } +} + +void bhv_painting_loop(void) { + struct Object *obj = o; + + // Update the DDD painting before drawing. + if (obj->oPaintingGroup == PAINTING_GROUP_INSIDE_CASTLE + && obj->oPaintingId == PAINTING_ID_CASTLE_DDD) { + move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); + } +} +#else void bhv_painting_loop(void) { } +#endif diff --git a/src/game/save_file.c b/src/game/save_file.c index fee7224a3d..355820206c 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -564,7 +564,6 @@ u32 save_file_get_flags(void) { SAVE_FLAG_HAVE_VANISH_CAP | SAVE_FLAG_UNLOCKED_BASEMENT_DOOR | SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR | - SAVE_FLAG_DDD_MOVED_BACK | SAVE_FLAG_MOAT_DRAINED | SAVE_FLAG_UNLOCKED_PSS_DOOR | SAVE_FLAG_UNLOCKED_WF_DOOR | diff --git a/src/game/save_file.h b/src/game/save_file.h index 146685946f..a38620bd61 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -114,7 +114,7 @@ enum SaveProgressFlags { SAVE_FLAG_HAVE_KEY_2 = (1 << 5), /* 0x00000020 */ SAVE_FLAG_UNLOCKED_BASEMENT_DOOR = (1 << 6), /* 0x00000040 */ SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR = (1 << 7), /* 0x00000080 */ - SAVE_FLAG_DDD_MOVED_BACK = (1 << 8), /* 0x00000100 */ + SAVE_FLAG_UNUSED_8 = (1 << 8), /* 0x00000100 */ SAVE_FLAG_MOAT_DRAINED = (1 << 9), /* 0x00000200 */ SAVE_FLAG_UNLOCKED_PSS_DOOR = (1 << 10), /* 0x00000400 */ SAVE_FLAG_UNLOCKED_WF_DOOR = (1 << 11), /* 0x00000800 */ From e3243cb91784730e1d74ab811eba99f4adea0043 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 5 Dec 2022 00:41:49 -0500 Subject: [PATCH 31/81] Add PAINTING_VERTEX macro for painting triangle mesh --- bin/segment2.c | 320 +++++++++++++++++++++++++------------------------ 1 file changed, 161 insertions(+), 159 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 9d94ea2142..c16dde8d91 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2926,8 +2926,10 @@ const Gfx dl_paintings_draw_ripples[] = { gsSPEndDisplayList(), }; -#define PDX (PAINTING_SIZE / 12.0f) // 51.2f -#define PDY (PAINTING_SIZE / 20.0f) // 30.72f +// Painting vertex coordinates +#define PDX(x) ((x) * (PAINTING_SIZE / 12.0f)) // 51.2f +#define PDY(y) ((y) * (PAINTING_SIZE / 20.0f)) // 30.72f +#define PAINTING_VERTEX(x, y, r) PDX(x), PDY(y), (r) // 14A60: triangle mesh // 0x02014A60 @@ -2935,163 +2937,163 @@ const PaintingData seg2_painting_triangle_mesh[] = { 157, // numVtx // format: // 2D point (x, y), ripple (0 or 1) - (PDX * 12), (PDY * 19), 0, // 0 - (PDX * 12), (PDY * 20), 0, // 1 - (PDX * 11), (PDY * 20), 0, // 2 - (PDX * 11), (PDY * 18), 1, // 3 - (PDX * 12), (PDY * 17), 0, // 4 - (PDX * 10), (PDY * 19), 1, // 5 - (PDX * 10), (PDY * 20), 0, // 6 - (PDX * 6), (PDY * 20), 0, // 7 - (PDX * 6), (PDY * 19), 1, // 8 - (PDX * 7), (PDY * 20), 0, // 9 - (PDX * 5), (PDY * 20), 0, // 10 - (PDX * 5), (PDY * 18), 1, // 11 - (PDX * 6), (PDY * 17), 1, // 12 - (PDX * 7), (PDY * 18), 1, // 13 - (PDX * 8), (PDY * 19), 1, // 14 - (PDX * 9), (PDY * 20), 0, // 15 - (PDX * 10), (PDY * 17), 1, // 16 - (PDX * 9), (PDY * 18), 1, // 17 - (PDX * 8), (PDY * 17), 1, // 18 - (PDX * 11), (PDY * 10), 1, // 19 - (PDX * 12), (PDY * 11), 0, // 20 - (PDX * 11), (PDY * 14), 1, // 21 - (PDX * 12), (PDY * 13), 0, // 22 - (PDX * 11), (PDY * 12), 1, // 23 - (PDX * 10), (PDY * 11), 1, // 24 - (PDX * 9), (PDY * 10), 1, // 25 - (PDX * 9), (PDY * 14), 1, // 26 - (PDX * 10), (PDY * 13), 1, // 27 - (PDX * 10), (PDY * 15), 1, // 28 - (PDX * 8), (PDY * 11), 1, // 29 - (PDX * 9), (PDY * 12), 1, // 30 - (PDX * 7), (PDY * 10), 1, // 31 - (PDX * 8), (PDY * 15), 1, // 32 - (PDX * 7), (PDY * 14), 1, // 33 - (PDX * 8), (PDY * 13), 1, // 34 - (PDX * 7), (PDY * 12), 1, // 35 - (PDX * 6), (PDY * 11), 1, // 36 - (PDX * 5), (PDY * 10), 1, // 37 - (PDX * 6), (PDY * 13), 1, // 38 - (PDX * 5), (PDY * 14), 1, // 39 - (PDX * 6), (PDY * 15), 1, // 40 - (PDX * 12), (PDY * 15), 0, // 41 - (PDX * 11), (PDY * 16), 1, // 42 - (PDX * 9), (PDY * 16), 1, // 43 - (PDX * 7), (PDY * 16), 1, // 44 - (PDX * 5), (PDY * 16), 1, // 45 - (PDX * 8), (PDY * 9), 1, // 46 - (PDX * 10), (PDY * 9), 1, // 47 - (PDX * 6), (PDY * 9), 1, // 48 - (PDX * 12), (PDY * 1), 0, // 49 - (PDX * 12), (PDY * 0), 0, // 50 - (PDX * 11), (PDY * 0), 0, // 51 - (PDX * 11), (PDY * 4), 1, // 52 - (PDX * 12), (PDY * 3), 0, // 53 - (PDX * 10), (PDY * 1), 1, // 54 - (PDX * 11), (PDY * 2), 1, // 55 - (PDX * 9), (PDY * 0), 0, // 56 - (PDX * 10), (PDY * 0), 0, // 57 - (PDX * 9), (PDY * 4), 1, // 58 - (PDX * 10), (PDY * 3), 1, // 59 - (PDX * 10), (PDY * 5), 1, // 60 - (PDX * 8), (PDY * 1), 1, // 61 - (PDX * 9), (PDY * 2), 1, // 62 - (PDX * 7), (PDY * 0), 0, // 63 - (PDX * 8), (PDY * 0), 0, // 64 - (PDX * 8), (PDY * 3), 1, // 65 - (PDX * 7), (PDY * 4), 1, // 66 - (PDX * 8), (PDY * 5), 1, // 67 - (PDX * 6), (PDY * 1), 1, // 68 - (PDX * 7), (PDY * 2), 1, // 69 - (PDX * 5), (PDY * 0), 0, // 70 - (PDX * 6), (PDY * 0), 0, // 71 - (PDX * 5), (PDY * 4), 1, // 72 - (PDX * 6), (PDY * 3), 1, // 73 - (PDX * 6), (PDY * 5), 1, // 74 - (PDX * 12), (PDY * 5), 0, // 75 - (PDX * 11), (PDY * 8), 1, // 76 - (PDX * 12), (PDY * 7), 0, // 77 - (PDX * 11), (PDY * 6), 1, // 78 - (PDX * 9), (PDY * 8), 1, // 79 - (PDX * 10), (PDY * 7), 1, // 80 - (PDX * 9), (PDY * 6), 1, // 81 - (PDX * 7), (PDY * 8), 1, // 82 - (PDX * 8), (PDY * 7), 1, // 83 - (PDX * 7), (PDY * 6), 1, // 84 - (PDX * 5), (PDY * 8), 1, // 85 - (PDX * 6), (PDY * 7), 1, // 86 - (PDX * 4), (PDY * 19), 1, // 87 - (PDX * 0), (PDY * 20), 0, // 88 - (PDX * 0), (PDY * 19), 0, // 89 - (PDX * 1), (PDY * 20), 0, // 90 - (PDX * 1), (PDY * 18), 1, // 91 - (PDX * 2), (PDY * 19), 1, // 92 - (PDX * 4), (PDY * 17), 1, // 93 - (PDX * 3), (PDY * 18), 1, // 94 - (PDX * 3), (PDY * 20), 0, // 95 - (PDX * 2), (PDY * 17), 1, // 96 - (PDX * 5), (PDY * 12), 1, // 97 - (PDX * 4), (PDY * 11), 1, // 98 - (PDX * 3), (PDY * 10), 1, // 99 - (PDX * 3), (PDY * 14), 1, // 100 - (PDX * 4), (PDY * 13), 1, // 101 - (PDX * 4), (PDY * 15), 1, // 102 - (PDX * 3), (PDY * 12), 1, // 103 - (PDX * 2), (PDY * 11), 1, // 104 - (PDX * 1), (PDY * 10), 1, // 105 - (PDX * 1), (PDY * 14), 1, // 106 - (PDX * 2), (PDY * 13), 1, // 107 - (PDX * 2), (PDY * 15), 1, // 108 - (PDX * 1), (PDY * 12), 1, // 109 - (PDX * 0), (PDY * 11), 0, // 110 - (PDX * 0), (PDY * 15), 0, // 111 - (PDX * 3), (PDY * 16), 1, // 112 - (PDX * 1), (PDY * 16), 1, // 113 - (PDX * 3), (PDY * 8), 1, // 114 - (PDX * 2), (PDY * 9), 1, // 115 - (PDX * 4), (PDY * 9), 1, // 116 - (PDX * 0), (PDY * 9), 0, // 117 - (PDX * 1), (PDY * 8), 1, // 118 - (PDX * 4), (PDY * 1), 1, // 119 - (PDX * 5), (PDY * 2), 1, // 120 - (PDX * 4), (PDY * 0), 0, // 121 - (PDX * 3), (PDY * 0), 0, // 122 - (PDX * 4), (PDY * 5), 1, // 123 - (PDX * 4), (PDY * 3), 1, // 124 - (PDX * 3), (PDY * 4), 1, // 125 - (PDX * 2), (PDY * 1), 1, // 126 - (PDX * 3), (PDY * 2), 1, // 127 - (PDX * 2), (PDY * 0), 0, // 128 - (PDX * 1), (PDY * 0), 0, // 129 - (PDX * 1), (PDY * 4), 1, // 130 - (PDX * 2), (PDY * 3), 1, // 131 - (PDX * 2), (PDY * 5), 1, // 132 - (PDX * 0), (PDY * 1), 0, // 133 - (PDX * 1), (PDY * 2), 1, // 134 - (PDX * 0), (PDY * 5), 0, // 135 - (PDX * 5), (PDY * 6), 1, // 136 - (PDX * 4), (PDY * 7), 1, // 137 - (PDX * 3), (PDY * 6), 1, // 138 - (PDX * 2), (PDY * 7), 1, // 139 - (PDX * 1), (PDY * 6), 1, // 140 - (PDX * 8), (PDY * 20), 0, // 141 - (PDX * 12), (PDY * 10), 0, // 142 - (PDX * 12), (PDY * 9), 0, // 143 - (PDX * 10), (PDY * 10), 1, // 144 - (PDX * 8), (PDY * 10), 1, // 145 - (PDX * 6), (PDY * 10), 1, // 146 - (PDX * 4), (PDY * 20), 0, // 147 - (PDX * 0), (PDY * 17), 0, // 148 - (PDX * 2), (PDY * 20), 0, // 149 - (PDX * 4), (PDY * 10), 1, // 150 - (PDX * 2), (PDY * 10), 1, // 151 - (PDX * 0), (PDY * 13), 0, // 152 - (PDX * 0), (PDY * 10), 0, // 153 - (PDX * 0), (PDY * 7), 0, // 154 - (PDX * 0), (PDY * 3), 0, // 155 - (PDX * 0), (PDY * 0), 0, // 156 + PAINTING_VERTEX(12, 19, 0), // 0 + PAINTING_VERTEX(12, 20, 0), // 1 + PAINTING_VERTEX(11, 20, 0), // 2 + PAINTING_VERTEX(11, 18, 1), // 3 + PAINTING_VERTEX(12, 17, 0), // 4 + PAINTING_VERTEX(10, 19, 1), // 5 + PAINTING_VERTEX(10, 20, 0), // 6 + PAINTING_VERTEX( 6, 20, 0), // 7 + PAINTING_VERTEX( 6, 19, 1), // 8 + PAINTING_VERTEX( 7, 20, 0), // 9 + PAINTING_VERTEX( 5, 20, 0), // 10 + PAINTING_VERTEX( 5, 18, 1), // 11 + PAINTING_VERTEX( 6, 17, 1), // 12 + PAINTING_VERTEX( 7, 18, 1), // 13 + PAINTING_VERTEX( 8, 19, 1), // 14 + PAINTING_VERTEX( 9, 20, 0), // 15 + PAINTING_VERTEX(10, 17, 1), // 16 + PAINTING_VERTEX( 9, 18, 1), // 17 + PAINTING_VERTEX( 8, 17, 1), // 18 + PAINTING_VERTEX(11, 10, 1), // 19 + PAINTING_VERTEX(12, 11, 0), // 20 + PAINTING_VERTEX(11, 14, 1), // 21 + PAINTING_VERTEX(12, 13, 0), // 22 + PAINTING_VERTEX(11, 12, 1), // 23 + PAINTING_VERTEX(10, 11, 1), // 24 + PAINTING_VERTEX( 9, 10, 1), // 25 + PAINTING_VERTEX( 9, 14, 1), // 26 + PAINTING_VERTEX(10, 13, 1), // 27 + PAINTING_VERTEX(10, 15, 1), // 28 + PAINTING_VERTEX( 8, 11, 1), // 29 + PAINTING_VERTEX( 9, 12, 1), // 30 + PAINTING_VERTEX( 7, 10, 1), // 31 + PAINTING_VERTEX( 8, 15, 1), // 32 + PAINTING_VERTEX( 7, 14, 1), // 33 + PAINTING_VERTEX( 8, 13, 1), // 34 + PAINTING_VERTEX( 7, 12, 1), // 35 + PAINTING_VERTEX( 6, 11, 1), // 36 + PAINTING_VERTEX( 5, 10, 1), // 37 + PAINTING_VERTEX( 6, 13, 1), // 38 + PAINTING_VERTEX( 5, 14, 1), // 39 + PAINTING_VERTEX( 6, 15, 1), // 40 + PAINTING_VERTEX(12, 15, 0), // 41 + PAINTING_VERTEX(11, 16, 1), // 42 + PAINTING_VERTEX( 9, 16, 1), // 43 + PAINTING_VERTEX( 7, 16, 1), // 44 + PAINTING_VERTEX( 5, 16, 1), // 45 + PAINTING_VERTEX( 8, 9, 1), // 46 + PAINTING_VERTEX(10, 9, 1), // 47 + PAINTING_VERTEX( 6, 9, 1), // 48 + PAINTING_VERTEX(12, 1, 0), // 49 + PAINTING_VERTEX(12, 0, 0), // 50 + PAINTING_VERTEX(11, 0, 0), // 51 + PAINTING_VERTEX(11, 4, 1), // 52 + PAINTING_VERTEX(12, 3, 0), // 53 + PAINTING_VERTEX(10, 1, 1), // 54 + PAINTING_VERTEX(11, 2, 1), // 55 + PAINTING_VERTEX( 9, 0, 0), // 56 + PAINTING_VERTEX(10, 0, 0), // 57 + PAINTING_VERTEX( 9, 4, 1), // 58 + PAINTING_VERTEX(10, 3, 1), // 59 + PAINTING_VERTEX(10, 5, 1), // 60 + PAINTING_VERTEX( 8, 1, 1), // 61 + PAINTING_VERTEX( 9, 2, 1), // 62 + PAINTING_VERTEX( 7, 0, 0), // 63 + PAINTING_VERTEX( 8, 0, 0), // 64 + PAINTING_VERTEX( 8, 3, 1), // 65 + PAINTING_VERTEX( 7, 4, 1), // 66 + PAINTING_VERTEX( 8, 5, 1), // 67 + PAINTING_VERTEX( 6, 1, 1), // 68 + PAINTING_VERTEX( 7, 2, 1), // 69 + PAINTING_VERTEX( 5, 0, 0), // 70 + PAINTING_VERTEX( 6, 0, 0), // 71 + PAINTING_VERTEX( 5, 4, 1), // 72 + PAINTING_VERTEX( 6, 3, 1), // 73 + PAINTING_VERTEX( 6, 5, 1), // 74 + PAINTING_VERTEX(12, 5, 0), // 75 + PAINTING_VERTEX(11, 8, 1), // 76 + PAINTING_VERTEX(12, 7, 0), // 77 + PAINTING_VERTEX(11, 6, 1), // 78 + PAINTING_VERTEX( 9, 8, 1), // 79 + PAINTING_VERTEX(10, 7, 1), // 80 + PAINTING_VERTEX( 9, 6, 1), // 81 + PAINTING_VERTEX( 7, 8, 1), // 82 + PAINTING_VERTEX( 8, 7, 1), // 83 + PAINTING_VERTEX( 7, 6, 1), // 84 + PAINTING_VERTEX( 5, 8, 1), // 85 + PAINTING_VERTEX( 6, 7, 1), // 86 + PAINTING_VERTEX( 4, 19, 1), // 87 + PAINTING_VERTEX( 0, 20, 0), // 88 + PAINTING_VERTEX( 0, 19, 0), // 89 + PAINTING_VERTEX( 1, 20, 0), // 90 + PAINTING_VERTEX( 1, 18, 1), // 91 + PAINTING_VERTEX( 2, 19, 1), // 92 + PAINTING_VERTEX( 4, 17, 1), // 93 + PAINTING_VERTEX( 3, 18, 1), // 94 + PAINTING_VERTEX( 3, 20, 0), // 95 + PAINTING_VERTEX( 2, 17, 1), // 96 + PAINTING_VERTEX( 5, 12, 1), // 97 + PAINTING_VERTEX( 4, 11, 1), // 98 + PAINTING_VERTEX( 3, 10, 1), // 99 + PAINTING_VERTEX( 3, 14, 1), // 100 + PAINTING_VERTEX( 4, 13, 1), // 101 + PAINTING_VERTEX( 4, 15, 1), // 102 + PAINTING_VERTEX( 3, 12, 1), // 103 + PAINTING_VERTEX( 2, 11, 1), // 104 + PAINTING_VERTEX( 1, 10, 1), // 105 + PAINTING_VERTEX( 1, 14, 1), // 106 + PAINTING_VERTEX( 2, 13, 1), // 107 + PAINTING_VERTEX( 2, 15, 1), // 108 + PAINTING_VERTEX( 1, 12, 1), // 109 + PAINTING_VERTEX( 0, 11, 0), // 110 + PAINTING_VERTEX( 0, 15, 0), // 111 + PAINTING_VERTEX( 3, 16, 1), // 112 + PAINTING_VERTEX( 1, 16, 1), // 113 + PAINTING_VERTEX( 3, 8, 1), // 114 + PAINTING_VERTEX( 2, 9, 1), // 115 + PAINTING_VERTEX( 4, 9, 1), // 116 + PAINTING_VERTEX( 0, 9, 0), // 117 + PAINTING_VERTEX( 1, 8, 1), // 118 + PAINTING_VERTEX( 4, 1, 1), // 119 + PAINTING_VERTEX( 5, 2, 1), // 120 + PAINTING_VERTEX( 4, 0, 0), // 121 + PAINTING_VERTEX( 3, 0, 0), // 122 + PAINTING_VERTEX( 4, 5, 1), // 123 + PAINTING_VERTEX( 4, 3, 1), // 124 + PAINTING_VERTEX( 3, 4, 1), // 125 + PAINTING_VERTEX( 2, 1, 1), // 126 + PAINTING_VERTEX( 3, 2, 1), // 127 + PAINTING_VERTEX( 2, 0, 0), // 128 + PAINTING_VERTEX( 1, 0, 0), // 129 + PAINTING_VERTEX( 1, 4, 1), // 130 + PAINTING_VERTEX( 2, 3, 1), // 131 + PAINTING_VERTEX( 2, 5, 1), // 132 + PAINTING_VERTEX( 0, 1, 0), // 133 + PAINTING_VERTEX( 1, 2, 1), // 134 + PAINTING_VERTEX( 0, 5, 0), // 135 + PAINTING_VERTEX( 5, 6, 1), // 136 + PAINTING_VERTEX( 4, 7, 1), // 137 + PAINTING_VERTEX( 3, 6, 1), // 138 + PAINTING_VERTEX( 2, 7, 1), // 139 + PAINTING_VERTEX( 1, 6, 1), // 140 + PAINTING_VERTEX( 8, 20, 0), // 141 + PAINTING_VERTEX(12, 10, 0), // 142 + PAINTING_VERTEX(12, 9, 0), // 143 + PAINTING_VERTEX(10, 10, 1), // 144 + PAINTING_VERTEX( 8, 10, 1), // 145 + PAINTING_VERTEX( 6, 10, 1), // 146 + PAINTING_VERTEX( 4, 20, 0), // 147 + PAINTING_VERTEX( 0, 17, 0), // 148 + PAINTING_VERTEX( 2, 20, 0), // 149 + PAINTING_VERTEX( 4, 10, 1), // 150 + PAINTING_VERTEX( 2, 10, 1), // 151 + PAINTING_VERTEX( 0, 13, 0), // 152 + PAINTING_VERTEX( 0, 10, 0), // 153 + PAINTING_VERTEX( 0, 7, 0), // 154 + PAINTING_VERTEX( 0, 3, 0), // 155 + PAINTING_VERTEX( 0, 0, 0), // 156 // triangles 264, 8, 12, 13, // 0 From a1ec042d13c8b7bc3d6e16b28dd1d5a383206a36 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 9 Dec 2022 17:43:21 -0500 Subject: [PATCH 32/81] Paintings use regular object warp nodes + remove painting groups + painting struct cleanup + fix gTTCSpeedSetting being changed on exit + change relative painting coords to s32 --- include/level_commands.h | 10 ++- include/object_fields.h | 22 +++--- levels/castle_inside/painting.inc.c | 105 ++++++++++++++++------------ levels/castle_inside/script.c | 74 ++++++++++---------- levels/hmc/areas/1/painting.inc.c | 7 +- levels/hmc/script.c | 2 +- levels/ttm/areas/1/painting.inc.c | 7 +- levels/ttm/script.c | 4 +- src/engine/level_script.c | 27 +------ src/game/area.c | 1 - src/game/area.h | 17 +++-- src/game/behaviors/clock_arm.inc.c | 22 +++--- src/game/level_update.c | 23 +++--- src/game/paintings.c | 87 ++++++----------------- src/game/paintings.h | 86 ++++++++--------------- 15 files changed, 210 insertions(+), 284 deletions(-) diff --git a/include/level_commands.h b/include/level_commands.h index ce7e8482dc..ac8659b333 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -47,7 +47,7 @@ enum LevelCommands { /*0x24*/ LEVEL_CMD_PLACE_OBJECT, /*0x25*/ LEVEL_CMD_INIT_MARIO, /*0x26*/ LEVEL_CMD_CREATE_WARP_NODE, - /*0x27*/ LEVEL_CMD_CREATE_PAINTING_WARP_NODE, + /*0x27*/ LEVEL_CMD_27, /*0x28*/ LEVEL_CMD_CREATE_INSTANT_WARP, /*0x29*/ LEVEL_CMD_LOAD_AREA, /*0x2A*/ LEVEL_CMD_UNLOAD_AREA, @@ -374,10 +374,14 @@ enum GoddardScene { CMD_BBBB(LEVEL_CMD_CREATE_WARP_NODE, 0x08, id, destLevel), \ CMD_BBBB(destArea, destNode, flags, 0x00) -#define PAINTING_WARP_NODE(id, destLevel, destArea, destNode, flags) \ - CMD_BBBB(LEVEL_CMD_CREATE_PAINTING_WARP_NODE, 0x08, id, destLevel), \ +#define CMD27(id, destLevel, destArea, destNode, flags) \ + CMD_BBBB(LEVEL_CMD_27, 0x08, id, destLevel), \ CMD_BBBB(destArea, destNode, flags, 0x00) +// Backwards compatibility: +#define PAINTING_WARP_NODE(id, destLevel, destArea, destNode, flags) \ + WARP_NODE(id, destLevel, destArea, destNode, flags) + #define INSTANT_WARP(index, destArea, displaceX, displaceY, displaceZ) \ CMD_BBBB(LEVEL_CMD_CREATE_INSTANT_WARP, 0x10, index, destArea), \ CMD_W(displaceX), \ diff --git a/include/object_fields.h b/include/object_fields.h index 673efded37..e0c53a5b33 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1256,18 +1256,16 @@ /* Painting */ #define /*0x0F4*/ oPaintingData OBJECT_FIELD_CVPTR(0x1B) -#define /*0x0F8*/ oPaintingGroup OBJECT_FIELD_S16(0x1C, 0) -#define /*0x0FA*/ oPaintingId OBJECT_FIELD_S16(0x1C, 1) -#define /*0x0FC*/ oPaintingLocalMarioPosX OBJECT_FIELD_S16(0x1D, 0) -#define /*0x0FE*/ oPaintingLocalMarioPosY OBJECT_FIELD_S16(0x1D, 1) -#define /*0x100*/ oPaintingRippleX OBJECT_FIELD_S16(0x1E, 0) -#define /*0x102*/ oPaintingRippleY OBJECT_FIELD_S16(0x1E, 1) -#define /*0x104*/ oPaintingUpdateCounter OBJECT_FIELD_S16(0x1F, 0) -#define /*0x106*/ oPaintingLastUpdateCounter OBJECT_FIELD_S16(0x1F, 1) -#define /*0x108*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x20, 0) -#define /*0x10A*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x20, 1) -#define /*0x10C*/ oPaintingState OBJECT_FIELD_S16(0x21, 0) -#define /*0x10E*/ oPaintingRippleTimer OBJECT_FIELD_S16(0x21, 1) +#define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_S32(0x1C) +#define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_S32(0x1D) +#define /*0x100*/ oPaintingRippleX OBJECT_FIELD_S32(0x1E) +#define /*0x104*/ oPaintingRippleY OBJECT_FIELD_S32(0x1F) +#define /*0x108*/ oPaintingUpdateCounter OBJECT_FIELD_S16(0x20, 0) +#define /*0x10A*/ oPaintingLastUpdateCounter OBJECT_FIELD_S16(0x20, 1) +#define /*0x10C*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x21, 0) +#define /*0x10E*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x21, 1) +#define /*0x110*/ oPaintingState OBJECT_FIELD_S16(0x22, 0) +#define /*0x112*/ oPaintingRippleTimer OBJECT_FIELD_S16(0x22, 1) #define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) #define /*0x1A8*/ oPaintingRippleDecay OBJECT_FIELD_F32(0x48) #define /*0x1AC*/ oPaintingCurrRippleRate OBJECT_FIELD_F32(0x49) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index ef718de78f..b1dc142f44 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -101,6 +101,8 @@ const Gfx inside_castle_seg7_dl_ccm_fake_painting_2[] = { gsSPEndDisplayList(), }; +/// - PAINTING_ID_CASTLE_BOB - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_bob[] = { inside_castle_seg7_texture_0700B800, inside_castle_seg7_texture_0700A800, @@ -108,17 +110,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_bob[] // 0x07023620 - 0x07023698 const struct Painting bob_painting = { - /* ID */ PAINTING_ID_CASTLE_BOB, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_bob), /* Textures */ inside_castle_seg7_painting_textures_bob, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_bob), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_CCM - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] = { inside_castle_seg7_texture_0700D800, inside_castle_seg7_texture_0700C800, @@ -126,17 +129,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] // 0x07023698 - 0x07023710 const struct Painting ccm_painting = { - /* ID */ PAINTING_ID_CASTLE_CCM, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ccm), /* Textures */ inside_castle_seg7_painting_textures_ccm, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ccm), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_WF - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = { inside_castle_seg7_texture_0700F800, inside_castle_seg7_texture_0700E800, @@ -144,17 +148,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = // 0x07023710 - 0x07023788 const struct Painting wf_painting = { - /* ID */ PAINTING_ID_CASTLE_WF, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wf), /* Textures */ inside_castle_seg7_painting_textures_wf, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wf), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_JRB - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] = { inside_castle_seg7_texture_07011800, inside_castle_seg7_texture_07010800, @@ -162,17 +167,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] // 0x07023788 - 0x07023800 const struct Painting jrb_painting = { - /* ID */ PAINTING_ID_CASTLE_JRB, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_jrb), /* Textures */ inside_castle_seg7_painting_textures_jrb, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_jrb), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_LLL - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] = { inside_castle_seg7_texture_07012800, inside_castle_seg7_texture_07013800, @@ -180,17 +186,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] // 0x07023800 - 0x07023878 const struct Painting lll_painting = { - /* ID */ PAINTING_ID_CASTLE_LLL, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_lll), /* Textures */ inside_castle_seg7_painting_textures_lll, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_lll), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_SSL - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] = { inside_castle_seg7_texture_07015800, inside_castle_seg7_texture_07014800, @@ -198,51 +205,54 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] // 0x07023878 - 0x070238F0 const struct Painting ssl_painting = { - /* ID */ PAINTING_ID_CASTLE_SSL, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ssl), /* Textures */ inside_castle_seg7_painting_textures_ssl, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ssl), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_HMC - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_hmc_env[] = { inside_castle_seg7_texture_07016800, }; // 0x070238F0 - 0x07023968 const struct Painting hmc_painting = { - /* ID */ PAINTING_ID_CASTLE_HMC, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_hmc_env), /* Textures */ inside_castle_seg7_painting_textures_hmc_env, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_hmc_env), /* Texture w, h */ 32, 32, - /* Texture Type */ PAINTING_ENV_MAP, + /* Texture Type */ PAINTING_TYPE_ENV_MAP, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 768.0f, 768.0f, }; +/// - PAINTING_ID_CASTLE_DDD - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ddd_env[] = { inside_castle_seg7_texture_07017000, }; // 0x07023968 - 0x070239E0 const struct Painting ddd_painting = { - /* ID */ PAINTING_ID_CASTLE_DDD, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ddd_env), /* Textures */ inside_castle_seg7_painting_textures_ddd_env, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ddd_env), /* Texture w, h */ 32, 32, - /* Texture Type */ PAINTING_ENV_MAP, + /* Texture Type */ PAINTING_TYPE_ENV_MAP, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Shaded */ TRUE, /* Alpha */ 0xB4, /* Size */ 819.2f, 819.2f, }; +/// - PAINTING_ID_CASTLE_WDW - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] = { inside_castle_seg7_texture_07018800, inside_castle_seg7_texture_07017800, @@ -250,17 +260,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] // 0x070239E0 - 0x07023A58 const struct Painting wdw_painting = { - /* ID */ PAINTING_ID_CASTLE_WDW, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wdw), /* Textures */ inside_castle_seg7_painting_textures_wdw, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wdw), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 614.0f, 614.0f, }; +/// - PAINTING_ID_CASTLE_THI_TINY - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] = { inside_castle_seg7_texture_0701A800, inside_castle_seg7_texture_07019800, @@ -268,30 +279,32 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] // 0x07023A58 - 0x07023AD0 const struct Painting thi_tiny_painting = { - /* ID */ PAINTING_ID_CASTLE_THI_TINY, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), /* Textures */ inside_castle_seg7_painting_textures_thi, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 393.216f, 393.216f, }; +/// - PAINTING_ID_CASTLE_THI_HUGE - + // 0x07023C38 - 0x07023CB0 const struct Painting thi_huge_painting = { - /* ID */ PAINTING_ID_CASTLE_THI_HUGE, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), /* Textures */ inside_castle_seg7_painting_textures_thi, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 1638.4f, 1638.4f, }; +/// - PAINTING_ID_CASTLE_TTM - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] = { inside_castle_seg7_texture_0701C800, inside_castle_seg7_texture_0701B800, @@ -299,17 +312,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] // 0x07023AD0 - 0x07023B48 const struct Painting ttm_painting = { - /* ID */ PAINTING_ID_CASTLE_TTM, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttm), /* Textures */ inside_castle_seg7_painting_textures_ttm, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttm), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 256.0f, 256.0f, }; +/// - PAINTING_ID_CASTLE_TTC - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] = { inside_castle_seg7_texture_0701E800, inside_castle_seg7_texture_0701D800, @@ -317,17 +331,18 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] // 0x07023B48 - 0x07023BC0 const struct Painting ttc_painting = { - /* ID */ PAINTING_ID_CASTLE_TTC, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttc), /* Textures */ inside_castle_seg7_painting_textures_ttc, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttc), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, /* Size */ 409.6f, 409.6f, }; +/// - PAINTING_ID_CASTLE_SL - + ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = { inside_castle_seg7_texture_07020800, inside_castle_seg7_texture_0701F800, @@ -335,23 +350,23 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = // 0x07023BC0 - 0x07023C38 const struct Painting sl_painting = { - /* ID */ PAINTING_ID_CASTLE_SL, - /* Image Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_sl), /* Textures */ inside_castle_seg7_painting_textures_sl, + /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_sl), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ FALSE, /* Alpha */ 0xFF, /* Size */ 716.8f, 716.8f, }; +/// - PAINTING_ID_CASTLE_RR - + const struct Painting rr_painting = { - /* ID */ PAINTING_ID_CASTLE_RR, - /* Image Count */ 0, /* Textures */ NULL, + /* Texture Count */ 0, /* Texture w, h */ 0, 0, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0x00, diff --git a/levels/castle_inside/script.c b/levels/castle_inside/script.c index 07ef1daf34..6a80278f88 100644 --- a/levels/castle_inside/script.c +++ b/levels/castle_inside/script.c @@ -30,21 +30,21 @@ static const LevelScript script_func_local_1[] = { WARP_NODE(/*id*/ 0x04, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x01, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x05, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x00, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x06, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x01, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -5222, 410, -154, /*angle*/ 0, 90, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_BOB, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -2611, -307, -4352, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_CCM, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -51, -205, -4506, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_WF, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 4300, 410, -538, /*angle*/ 0, 270, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_JRB, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_BOB, /*destLevel*/ LEVEL_BOB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_CCM, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_WF, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_JRB, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -5222, 410, -154, /*angle*/ 0, 90, 0, /*behParam*/ ((PAINTING_ID_CASTLE_BOB << 24) | (0x96 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -2611, -307, -4352, /*angle*/ 0, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_CCM << 24) | (0x97 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -51, -205, -4506, /*angle*/ 0, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_WF << 24) | (0x98 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 4300, 410, -538, /*angle*/ 0, 270, 0, /*behParam*/ ((PAINTING_ID_CASTLE_JRB << 24) | (0x99 << 16)), /*beh*/ bhvPainting), + WARP_NODE(/*id*/ 0x96, /*destLevel*/ LEVEL_BOB, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x97, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x98, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x99, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2013, 768, -2014, /*angle*/ 0, 0, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_PSS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_PSS, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5513, 512, -4324, /*angle*/ 0, 0, 0, /*behParam*/ 0x300B0000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_BITDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_BITDW, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 1963, 819, 1280, /*angle*/ 0, 0, 0, /*behParam*/ 0x050C0000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x0C, /*destLevel*/ LEVEL_SA, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - WARP_NODE(/*id*/ 0xF2, /*destLevel*/ LEVEL_TOTWC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x0C, /*destLevel*/ LEVEL_SA, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ WARP_NODE_LOOK_UP, /*destLevel*/ LEVEL_TOTWC, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 512, -650, /*angle*/ 0, 0, 0, /*behParam*/ 0x001E0000, /*beh*/ bhvInstantActiveWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, -50, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x001F0000, /*beh*/ bhvInstantActiveWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00200000, /*beh*/ bhvAirborneWarp), @@ -95,24 +95,24 @@ static const LevelScript script_func_local_2[] = { OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_50_STARS, /*pos*/ -127, 2253, 4762, /*angle*/ 0, 180, 0, /*behParam*/ 0x32000000, /*beh*/ bhvStarDoor), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_70_STARS, /*pos*/ -281, 3174, 3772, /*angle*/ 0, 0, 0, /*behParam*/ 0x46000000, /*beh*/ bhvStarDoor), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_70_STARS, /*pos*/ -127, 3174, 3772, /*angle*/ 0, 180, 0, /*behParam*/ 0x46000000, /*beh*/ bhvStarDoor), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -967, 1306, -143, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_WDW, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -4599, 1355, 3005, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_THI_TINY, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -547, 1357, 3813, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_TTM, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 0, 2714, 7233, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_TTC, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3180, 1408, -271, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_SL, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -5615, 1510, -3292, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_THI_HUGE, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -3513, 2970, 5989, /*angle*/ 270, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_RR, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_WDW, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_THI_TINY, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_TTM, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_TTC, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_SL, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_THI_HUGE, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_RR, /*destLevel*/ LEVEL_RR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -967, 1306, -143, /*angle*/ 0, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_WDW << 24) | (0x96 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -4599, 1355, 3005, /*angle*/ 0, 180, 0, /*behParam*/ ((PAINTING_ID_CASTLE_THI_TINY << 24) | (0x97 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -547, 1357, 3813, /*angle*/ 0, 180, 0, /*behParam*/ ((PAINTING_ID_CASTLE_TTM << 24) | (0x98 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 0, 2714, 7233, /*angle*/ 0, 180, 0, /*behParam*/ ((PAINTING_ID_CASTLE_TTC << 24) | (0x99 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3180, 1408, -271, /*angle*/ 0, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_SL << 24) | (0x9A << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -5615, 1510, -3292, /*angle*/ 0, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_THI_HUGE << 24) | (0x9B << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -3513, 2970, 5989, /*angle*/ 270, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_RR << 24) | (0x9C << 16)), /*beh*/ bhvPainting), + WARP_NODE(/*id*/ 0x96, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x97, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x98, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x99, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x9A, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x9B, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x9C, /*destLevel*/ LEVEL_RR, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3002, 2816, 5886, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F0A0000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WMOTR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WMOTR, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -230, 4813, -3352, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F0B0000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_BITS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_BITS, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -659, 1613, -350, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvPaintingStarCollectWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4693, 2157, 1828, /*angle*/ 0, 270, 0, /*behParam*/ 0x00330000, /*beh*/ bhvAirborneStarCollectWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -675, 1400, 3870, /*angle*/ 0, 0, 0, /*behParam*/ 0x00340000, /*beh*/ bhvPaintingStarCollectWarp), @@ -158,16 +158,16 @@ static const LevelScript script_func_local_3[] = { WARP_NODE(/*id*/ 0x02, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x02, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_30_STARS, /*pos*/ 307, -1074, 2074, /*angle*/ 0, 90, 0, /*behParam*/ 0x1E000000, /*beh*/ bhvStarDoor), OBJECT(/*model*/ MODEL_CASTLE_STAR_DOOR_30_STARS, /*pos*/ 307, -1074, 1920, /*angle*/ 0, 270, 0, /*behParam*/ 0x1E000000, /*beh*/ bhvStarDoor), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -1690, -1126, -3942, /*angle*/ 0, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_LLL, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -2611, -1178, -1075, /*angle*/ 0, 180, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_SSL, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 2099, -1485, -2278, /*angle*/ 270, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_HMC, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3456, -1075, 1587, /*angle*/ 0, 270, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_CASTLE_DDD, PAINTING_GROUP_INSIDE_CASTLE) << 16, /*beh*/ bhvPainting), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_LLL, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_SSL, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_HMC, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_CASTLE_DDD, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -1690, -1126, -3942, /*angle*/ 0, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_LLL << 24) | (0x96 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ -2611, -1178, -1075, /*angle*/ 0, 180, 0, /*behParam*/ ((PAINTING_ID_CASTLE_SSL << 24) | (0x97 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 2099, -1485, -2278, /*angle*/ 270, 0, 0, /*behParam*/ ((PAINTING_ID_CASTLE_HMC << 24) | (0x98 << 16)), /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3456, -1075, 1587, /*angle*/ 0, 270, 0, /*behParam*/ ((PAINTING_ID_CASTLE_DDD << 24) | (0x99 << 16)), /*beh*/ bhvPainting), + WARP_NODE(/*id*/ 0x96, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x97, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x98, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x99, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1280, 1997, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F180000, /*beh*/ bhvWarp), - WARP_NODE(/*id*/ 0x18, /*destLevel*/ LEVEL_BITFS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), + WARP_NODE(/*id*/ 0x18, /*destLevel*/ LEVEL_BITFS, /*destArea*/ 0x01, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1382, -819, -4150, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvPaintingStarCollectWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2918, -870, -875, /*angle*/ 0, 0, 0, /*behParam*/ 0x00330000, /*beh*/ bhvPaintingStarCollectWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2483, -1688, -2662, /*angle*/ 0, 270, 0, /*behParam*/ 0x00340000, /*beh*/ bhvLaunchStarCollectWarp), diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 67eff7eca0..321e81b6aa 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -1,5 +1,7 @@ #include "game/paintings.h" +/// - PAINTING_ID_HMC_COTMC - + // 0x07024CE0 - 0x070254E0 ALIGNED8 static const Texture hmc_seg7_texture_cotmc_pool_env[] = { #include "levels/hmc/7.rgba16.inc.c" @@ -12,11 +14,10 @@ const Texture *const hmc_seg7_painting_textures_cotmc[] = { // 0x0702551C (PaintingData) const struct Painting cotmc_painting = { - /* ID */ PAINTING_ID_HMC_COTMC, - /* Image Count */ ARRAY_COUNT(hmc_seg7_painting_textures_cotmc), /* Textures */ hmc_seg7_painting_textures_cotmc, + /* Texture Count */ ARRAY_COUNT(hmc_seg7_painting_textures_cotmc), /* Texture w, h */ 32, 32, - /* Texture Type */ PAINTING_ENV_MAP, + /* Texture Type */ PAINTING_TYPE_ENV_MAP, /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, /* Shaded */ TRUE, /* Alpha */ 0xFF, diff --git a/levels/hmc/script.c b/levels/hmc/script.c index 6a7ae5123a..96c2b7d871 100644 --- a/levels/hmc/script.c +++ b/levels/hmc/script.c @@ -95,7 +95,7 @@ const LevelScript level_hmc_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_HMC_RED_GRILLS, hmc_geo_000530), AREA(/*index*/ 1, hmc_geo_000B90), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 2989, -4485, 5135, /*angle*/ 270, 0, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_HMC_COTMC, PAINTING_GROUP_HMC) << 16, /*beh*/ bhvPainting), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 2989, -4485, 5135, /*angle*/ 270, 0, 0, /*behParam*/ ((PAINTING_ID_HMC_COTMC << 24) | (0x96 << 16)), /*beh*/ bhvPainting), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7152, 3161, 7181, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3351, -4690, 4773, /*angle*/ 0, 0, 0, /*behParam*/ 0x340B0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index 7c85c34236..2b5da222af 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -1,5 +1,7 @@ #include "game/paintings.h" +/// - PAINTING_ID_TTM_SLIDE - + // 0x07012EF8 - 0x07012F78 ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { ttm_seg7_texture_07004000, @@ -8,11 +10,10 @@ ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { // 0x07012F00 (PaintingData) const struct Painting ttm_slide_painting = { - /* ID */ PAINTING_ID_TTM_SLIDE, - /* Image Count */ ARRAY_COUNT(ttm_seg7_painting_textures_slide), /* Textures */ ttm_seg7_painting_textures_slide, + /* Texture Count */ ARRAY_COUNT(ttm_seg7_painting_textures_slide), /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_IMAGE, + /* Texture Type */ PAINTING_TYPE_IMAGE, /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, /* Shaded */ TRUE, /* Alpha */ 0xFF, diff --git a/levels/ttm/script.c b/levels/ttm/script.c index 1999c93bc1..1791aac8db 100644 --- a/levels/ttm/script.c +++ b/levels/ttm/script.c @@ -129,8 +129,8 @@ const LevelScript level_ttm_entry[] = { WARP_NODE(/*id*/ 0x14, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x14, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x15, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x16, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x16, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x15, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3072, 922, -819, /*angle*/ 0, 90, 0, /*behParam*/ PAINTING_ID(PAINTING_ID_TTM_SLIDE, PAINTING_GROUP_TTM) << 16, /*beh*/ bhvPainting), - PAINTING_WARP_NODE(/*id*/ PAINTING_ID_TTM_SLIDE, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_CHECKPOINT), + OBJECT(/*model*/ MODEL_PAINTING, /*pos*/ 3072, 922, -819, /*angle*/ 0, 90, 0, /*behParam*/ ((PAINTING_ID_TTM_SLIDE << 24) | (0x96 << 16)), /*beh*/ bhvPainting), + WARP_NODE(/*id*/ 0x96, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ WARP_NODE_MAIN_ENTRY, /*flags*/ WARP_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), JUMP_LINK(script_func_local_1), diff --git a/src/engine/level_script.c b/src/engine/level_script.c index f2b97b62d2..7a633944ea 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -31,8 +31,6 @@ #include "config.h" -#define NUM_PAINTING_WARP_NODES 45 - #define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd)) // These are equal @@ -559,28 +557,7 @@ static void level_cmd_set_terrain_type(void) { sCurrentCmd = CMD_NEXT; } -static void level_cmd_create_painting_warp_node(void) { - s32 i; - struct WarpNode *node; - - if (sCurrAreaIndex != -1) { - if (gAreas[sCurrAreaIndex].paintingWarpNodes == NULL) { - gAreas[sCurrAreaIndex].paintingWarpNodes = - alloc_only_pool_alloc(sLevelPool, NUM_PAINTING_WARP_NODES * sizeof(struct WarpNode)); - - for (i = 0; i < NUM_PAINTING_WARP_NODES; i++) { - gAreas[sCurrAreaIndex].paintingWarpNodes[i].id = 0; - } - } - - node = &gAreas[sCurrAreaIndex].paintingWarpNodes[CMD_GET(u8, 2)]; - - node->id = 1; - node->destLevel = CMD_GET(u8, 3) + CMD_GET(u8, 6); - node->destArea = CMD_GET(u8, 4); - node->destNode = CMD_GET(u8, 5); - } - +static void level_cmd_27(void) { sCurrentCmd = CMD_NEXT; } @@ -922,7 +899,7 @@ static void (*LevelScriptJumpTable[])(void) = { /*LEVEL_CMD_PLACE_OBJECT */ level_cmd_place_object, /*LEVEL_CMD_INIT_MARIO */ level_cmd_init_mario, /*LEVEL_CMD_CREATE_WARP_NODE */ level_cmd_create_warp_node, - /*LEVEL_CMD_CREATE_PAINTING_WARP_NODE */ level_cmd_create_painting_warp_node, + /*LEVEL_CMD_27 */ level_cmd_27, /*LEVEL_CMD_CREATE_INSTANT_WARP */ level_cmd_create_instant_warp, /*LEVEL_CMD_LOAD_AREA */ level_cmd_load_area, /*LEVEL_CMD_UNLOAD_AREA */ level_cmd_unload_area, diff --git a/src/game/area.c b/src/game/area.c index cd1c9ef20b..16f83a206c 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -193,7 +193,6 @@ void clear_areas(void) { gAreaData[i].surfaceRooms = NULL; gAreaData[i].macroObjects = NULL; gAreaData[i].warpNodes = NULL; - gAreaData[i].paintingWarpNodes = NULL; gAreaData[i].instantWarps = NULL; gAreaData[i].objectSpawnInfos = NULL; gAreaData[i].camera = NULL; diff --git a/src/game/area.h b/src/game/area.h index c9d09e727a..cfa2068267 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -64,15 +64,14 @@ struct Area { /*0x0C*/ RoomData *surfaceRooms; // (set from level script cmd 0x2F) /*0x10*/ MacroObject *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39) /*0x14*/ struct ObjectWarpNode *warpNodes; - /*0x18*/ struct WarpNode *paintingWarpNodes; - /*0x1C*/ struct InstantWarp *instantWarps; - /*0x20*/ struct SpawnInfo *objectSpawnInfos; - /*0x24*/ struct Camera *camera; - /*0x28*/ struct UnusedArea28 *unused; // Filled by level script 0x3A, but is unused. - /*0x2C*/ struct Whirlpool *whirlpools[2]; - /*0x34*/ u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30) - /*0x36*/ u16 musicParam; - /*0x38*/ u16 musicParam2; + /*0x18*/ struct InstantWarp *instantWarps; + /*0x1C*/ struct SpawnInfo *objectSpawnInfos; + /*0x20*/ struct Camera *camera; + /*0x24*/ struct UnusedArea28 *unused; // Filled by level script 0x3A, but is unused. + /*0x28*/ struct Whirlpool *whirlpools[2]; + /*0x30*/ u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30) + /*0x32*/ u16 musicParam; + /*0x34*/ u16 musicParam2; }; // All the transition data to be used in screen_transition.c diff --git a/src/game/behaviors/clock_arm.inc.c b/src/game/behaviors/clock_arm.inc.c index 61513deb55..2f75975454 100644 --- a/src/game/behaviors/clock_arm.inc.c +++ b/src/game/behaviors/clock_arm.inc.c @@ -6,30 +6,30 @@ void bhv_rotating_clock_arm_loop(void) { u16 rollAngle = o->oFaceAngleRoll; - // Seems to make sure Mario is on a default surface & 4 frames pass before - // allowing him to change the Tick Tock Clock speed setting. - // Probably a safety check for when you leave the level through the painting - // to make sure the setting isn't accidentally locked in as you fly out. if (o->oAction == TTC_PAINTING_CLOCK_ARM_WAIT) { - if (o->oTimer >= 4) { + // Make sure Mario not in a painting & 3 frames pass before allowing him to + // change the Tick Tock Clock speed setting. + // Probably a safety check for when you leave the level through the painting + // to make sure the setting isn't accidentally locked in as you fly out. + if (gEnteredPaintingObject == NULL && o->oTimer > 3) { o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_MOVING } } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_MOVING) { // If Mario is entering the Tick Tock Clock painting... - if (gEnteredPaintingObject != NULL - && gEnteredPaintingObject->oPaintingId == PAINTING_ID_CASTLE_TTC) { + if (gEnteredPaintingObject != NULL && GET_BPARAM1(gEnteredPaintingObject->oBehParams) == PAINTING_ID_CASTLE_TTC) { // And this is the minute hand... if (cur_obj_has_behavior(bhvClockMinuteHand)) { // Set Tick Tick Clock's speed based on the angle of the hand. // The angle actually counting down from 0xFFFF to 0 so // 11 o'clock is a small value and 1 o'clock is a large value. + //! These are not perfectly symmetrical. if (rollAngle < 0x0AAA) { // > 345 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_STOPPED; - } else if (rollAngle < 0x6AA4) { // 210..345 degrees from 12 o'clock. + } else if (rollAngle < 0x6AA4) { // 210..345 degrees from 12 o'clock. Should be 0x6AAA. gTTCSpeedSetting = TTC_SPEED_FAST; - } else if (rollAngle < 0x954C) { // 150..210 degrees from 12 o'clock. + } else if (rollAngle < 0x954C) { // 150..210 degrees from 12 o'clock. Should be 0x9555. gTTCSpeedSetting = TTC_SPEED_RANDOM; - } else if (rollAngle < 0xF546) { // 15..150 degrees from 12 o'clock. + } else if (rollAngle < 0xF546) { // 15..150 degrees from 12 o'clock. Should be 0xF555. gTTCSpeedSetting = TTC_SPEED_SLOW; } else { // < 15 degrees from 12 o'clock. gTTCSpeedSetting = TTC_SPEED_STOPPED; @@ -46,7 +46,7 @@ void bhv_rotating_clock_arm_loop(void) { } // Only rotate the hands until Mario enters the painting. - if (o->oAction < 2) { + if (o->oAction != TTC_PAINTING_CLOCK_ARM_ACT_STOPPED) { cur_obj_rotate_face_angle_using_vel(); } } diff --git a/src/game/level_update.c b/src/game/level_update.c index 65f02b4a3b..07946ad8c4 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -635,26 +635,23 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 warpFlags) * Check is Mario has entered a painting, and if so, initiate a warp. */ void initiate_painting_warp(void) { - struct WarpNode warpNode; - struct WarpNode *pWarpNode = NULL; + struct ObjectWarpNode *warpNode = NULL; - if (gCurrentArea->paintingWarpNodes == NULL) { - gEnteredPaintingObject = NULL; - } else if (gEnteredPaintingObject != NULL) { - pWarpNode = &gCurrentArea->paintingWarpNodes[gEnteredPaintingObject->oPaintingId]; + if (gEnteredPaintingObject != NULL) { + warpNode = area_get_warp_node(GET_BPARAM2(gEnteredPaintingObject->oBehParams)); - if (pWarpNode != NULL) { + if (warpNode != NULL) { if (gMarioState->action & ACT_FLAG_INTANGIBLE) { play_painting_eject_sound(); - } else if (pWarpNode->id != 0) { - warpNode = *pWarpNode; + } else { + struct WarpNode *node = &warpNode->node; - if (!(warpNode.destLevel & WARP_NO_CHECKPOINT)) { - sWarpCheckpointActive = check_warp_checkpoint(&warpNode); + if (!(node->destLevel & WARP_NO_CHECKPOINT)) { + sWarpCheckpointActive = check_warp_checkpoint(node); } - initiate_warp((warpNode.destLevel & WARP_DEST_LEVEL_NUM_MASK), warpNode.destArea, warpNode.destNode, WARP_FLAGS_NONE); - check_if_should_set_warp_checkpoint(&warpNode); + initiate_warp((node->destLevel & WARP_DEST_LEVEL_NUM_MASK), node->destArea, node->destNode, WARP_FLAGS_NONE); + check_if_should_set_warp_checkpoint(node); play_transition_after_delay(WARP_TRANSITION_FADE_INTO_COLOR, 30, 255, 255, 255, 45); level_set_transition(74, basic_update); diff --git a/src/game/paintings.c b/src/game/paintings.c index 7b2eb6433d..a6d4dffa6e 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -54,19 +54,11 @@ */ /** - * HMC painting group. + * Array of pointers to painting data structs. */ -const struct Painting *sHmcPaintings[] = { - /* Painting ID */ - /* PAINTING_ID_HMC_COTMC */ &cotmc_painting, - NULL, -}; - -/** - * Inside Castle painting group. - */ -const struct Painting *sInsideCastlePaintings[] = { +const struct Painting *sPaintings[] = { /* Painting ID */ + /* PAINTING_ID_NULL */ NULL, /* PAINTING_ID_CASTLE_BOB */ &bob_painting, /* PAINTING_ID_CASTLE_CCM */ &ccm_painting, /* PAINTING_ID_CASTLE_WF */ &wf_painting, @@ -82,28 +74,11 @@ const struct Painting *sInsideCastlePaintings[] = { /* PAINTING_ID_CASTLE_SL */ &sl_painting, /* PAINTING_ID_CASTLE_THI_HUGE */ &thi_huge_painting, /* PAINTING_ID_CASTLE_RR */ &rr_painting, - NULL, -}; - -/** - * TTM painting group. - */ -const struct Painting *sTtmPaintings[] = { - /* Painting ID */ + /* PAINTING_ID_HMC_COTMC */ &cotmc_painting, /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, NULL, }; -/** - * Array of all painting groups. - */ -const struct Painting * const* sPaintingGroups[] = { - /* Group ID */ - /* PAINTING_GROUP_HMC */ sHmcPaintings, - /* PAINTING_GROUP_INSIDE_CASTLE */ sInsideCastlePaintings, - /* PAINTING_GROUP_TTM */ sTtmPaintings, -}; - /** * The painting that is currently rippling. Only one painting can be rippling at once. */ @@ -158,9 +133,11 @@ static const struct RippleAnimationInfo sRippleAnimationInfo[] = { * Returns a pointer to the RippleAnimationInfo that best fits the painting type. */ const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *painting) { - PaintingData rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; + s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; + if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY; + if (painting->sizeX >= (PAINTING_SIZE * 2) || painting->sizeY >= (PAINTING_SIZE * 2)) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; @@ -496,7 +473,7 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD * If the textureMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole * painting. */ -Gfx *render_painting(const Texture *img, PaintingData index, PaintingData imageCount, PaintingData tWidth, PaintingData tHeight, const PaintingData *textureMap, Alpha alpha) { +Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *textureMap, Alpha alpha) { struct PaintingMeshVertex *mesh = NULL; PaintingData group; PaintingData groupIndex; @@ -675,7 +652,7 @@ s32 get_exponent(s32 x) { /** * Set up the texture format in the display list. */ -void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeight, PaintingData isEnvMap) { +void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { s16 cm = isEnvMap ? (G_TX_WRAP | G_TX_NOMIRROR) : G_TX_CLAMP; u32 masks = get_exponent(tWidth); u32 maskt = get_exponent(tHeight); @@ -697,13 +674,13 @@ void painting_setup_textures(Gfx **gfx, PaintingData tWidth, PaintingData tHeigh * Ripple a painting that has 1 or more images that need to be mapped. */ Gfx *dl_painting_rippling(const struct Painting *painting) { - PaintingData i; - const PaintingData *textureMap; - PaintingData imageCount = painting->imageCount; - PaintingData tWidth = painting->textureWidth; - PaintingData tHeight = painting->textureHeight; + s16 i; + const PaintingData *textureMap = NULL; + s16 imageCount = painting->imageCount; + s16 tWidth = painting->textureWidth; + s16 tHeight = painting->textureHeight; const Texture **tArray = segmented_to_virtual(painting->textureArray); - PaintingData isEnvMap = (painting->textureType == PAINTING_ENV_MAP); + s32 isEnvMap = (painting->textureType == PAINTING_TYPE_ENV_MAP); u32 gfxCmds = ( /*gSPDisplayList */ 1 + @@ -784,12 +761,7 @@ Gfx *display_painting_rippling(const struct Painting *painting) { Gfx *dl_painting_not_rippling(const struct Painting *painting) { Alpha alpha = painting->alpha; - - if (alpha == 0x00) { - return NULL; - } - - PaintingData imageCount = painting->imageCount; + s16 imageCount = painting->imageCount; s32 shaded = painting->shaded; u32 gfxCmds = ( /*gSPDisplayList */ 1 + @@ -820,7 +792,7 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { const Texture **textures = segmented_to_virtual(painting->textureArray); - s32 isEnvMap = (painting->textureType == PAINTING_ENV_MAP); + s32 isEnvMap = (painting->textureType == PAINTING_TYPE_ENV_MAP); if (isEnvMap) { vec3_set(n, 0x00, 0x00, 0x7f); @@ -833,8 +805,8 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { gSPDisplayList(gfx++, dl_paintings_textured_vertex_colored_begin); } - PaintingData tWidth = painting->textureWidth; - PaintingData tHeight = painting->textureHeight; + s16 tWidth = painting->textureWidth; + s16 tHeight = painting->textureHeight; const f32 dx = (PAINTING_SIZE / 1); const f32 dy = (PAINTING_SIZE / imageCount); @@ -926,11 +898,6 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con return NULL; } - // Failsafe for nonexistent painting groups. - if (obj->oPaintingGroup >= PAINTING_NUM_GROUPS) { - return NULL; - } - // Get the const painting data. const struct Painting *painting = obj->oPaintingData; @@ -1009,17 +976,10 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con void bhv_painting_init(void) { struct Object *obj = o; - // Get the painting group and id from the behavior params. - obj->oPaintingGroup = GET_BPARAM1(obj->oBehParams); - obj->oPaintingId = GET_BPARAM2(obj->oBehParams); - - // Failsafe for nonexistent painting groups. - if (obj->oPaintingGroup >= PAINTING_NUM_GROUPS) { - return; - } + // Get the painting id from the first byte behavior params. The second byte is used for the warp node ID. + s32 id = GET_BPARAM1(obj->oBehParams); - const struct Painting * const* paintingGroup = sPaintingGroups[obj->oPaintingGroup]; - const struct Painting *painting = segmented_to_virtual(paintingGroup[obj->oPaintingId]); + const struct Painting *painting = segmented_to_virtual(sPaintings[id]); // Set the object's painting data pointer. obj->oPaintingData = painting; @@ -1095,8 +1055,7 @@ void bhv_painting_loop(void) { struct Object *obj = o; // Update the DDD painting before drawing. - if (obj->oPaintingGroup == PAINTING_GROUP_INSIDE_CASTLE - && obj->oPaintingId == PAINTING_ID_CASTLE_DDD) { + if (GET_BPARAM1(obj->oBehParams) == PAINTING_ID_CASTLE_DDD) { move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); } } diff --git a/src/game/paintings.h b/src/game/paintings.h index 2e1dbe737e..41a537fef1 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -8,10 +8,6 @@ #include "types.h" -/// Use to properly set a GraphNodeGenerated's parameter to point to the right painting. -/// Use this for both bparam1 and bparam2 for painting objects. -#define PAINTING_ID(id, grp) ((id) | ((grp) << 8)) - /// The default painting side length. #define PAINTING_SIZE 614.4f @@ -31,54 +27,34 @@ #define TC(t) (((t) - 1) << 5) -// HMC painting group -enum HMCPaintingIDs { - /* Painting ID */ - /* 0 */ PAINTING_ID_HMC_COTMC, -}; - -// Inside Castle painting group -enum CastlePaintingIDs { - /* Painting ID */ - /* 0 */ PAINTING_ID_CASTLE_BOB, - /* 1 */ PAINTING_ID_CASTLE_CCM, - /* 2 */ PAINTING_ID_CASTLE_WF, - /* 3 */ PAINTING_ID_CASTLE_JRB, - /* 4 */ PAINTING_ID_CASTLE_LLL, - /* 5 */ PAINTING_ID_CASTLE_SSL, - /* 6 */ PAINTING_ID_CASTLE_HMC, - /* 7 */ PAINTING_ID_CASTLE_DDD, - /* 8 */ PAINTING_ID_CASTLE_WDW, - /* 9 */ PAINTING_ID_CASTLE_THI_TINY, - /* 10 */ PAINTING_ID_CASTLE_TTM, - /* 11 */ PAINTING_ID_CASTLE_TTC, - /* 12 */ PAINTING_ID_CASTLE_SL, - /* 13 */ PAINTING_ID_CASTLE_THI_HUGE, - /* 14 */ PAINTING_ID_CASTLE_RR, -}; - -// TTM painting group -enum TTMPaintingIDs { +enum PaintingIDs { /* Painting ID */ - /* 0 */ PAINTING_ID_TTM_SLIDE, -}; - -// Painting group IDs -enum PaintingGroups { - /* Group ID */ - /* 0 */ PAINTING_GROUP_HMC, - /* 1 */ PAINTING_GROUP_INSIDE_CASTLE, - /* 2 */ PAINTING_GROUP_TTM, - PAINTING_NUM_GROUPS, - PAINTING_GROUP_NULL = -1, + /* 0x00 */ PAINTING_ID_NULL, + /* 0x01 */ PAINTING_ID_CASTLE_BOB, + /* 0x02 */ PAINTING_ID_CASTLE_CCM, + /* 0x03 */ PAINTING_ID_CASTLE_WF, + /* 0x04 */ PAINTING_ID_CASTLE_JRB, + /* 0x05 */ PAINTING_ID_CASTLE_LLL, + /* 0x06 */ PAINTING_ID_CASTLE_SSL, + /* 0x07 */ PAINTING_ID_CASTLE_HMC, + /* 0x08 */ PAINTING_ID_CASTLE_DDD, + /* 0x09 */ PAINTING_ID_CASTLE_WDW, + /* 0x0A */ PAINTING_ID_CASTLE_THI_TINY, + /* 0x0B */ PAINTING_ID_CASTLE_TTM, + /* 0x0C */ PAINTING_ID_CASTLE_TTC, + /* 0x0D */ PAINTING_ID_CASTLE_SL, + /* 0x0E */ PAINTING_ID_CASTLE_THI_HUGE, + /* 0x0F */ PAINTING_ID_CASTLE_RR, + /* 0x10 */ PAINTING_ID_HMC_COTMC, + /* 0x11 */ PAINTING_ID_TTM_SLIDE, }; // Painting->textureType enum PaintingType { /// Painting that uses 1 or more images as a texture - PAINTING_IMAGE, + PAINTING_TYPE_IMAGE, /// Painting that has one texture used for an environment map effect - PAINTING_ENV_MAP + PAINTING_TYPE_ENV_MAP }; // Painting->rippleTrigger @@ -138,24 +114,24 @@ struct RippleAnimationInfo { * Painting info struct. */ struct Painting { - /// ID of the painting and the warp node. - /*0x00*/ PaintingData id; + /// Texture data. + /*0x00*/ const Texture *const *textureArray; + + /// How many textures the painting uses. + /*0x04*/ s32 imageCount; - /// How many images should be drawn when the painting is rippling. - /*0x02*/ PaintingData imageCount; + /// Texture size. + /*0x08*/ s16 textureWidth; + /*0x0A*/ s16 textureHeight; - // Texture data. - /*0x04*/ const Texture *const *textureArray; - /*0x08*/ PaintingData textureWidth; - /*0x0A*/ PaintingData textureHeight; - /// Either PAINTING_IMAGE or PAINTING_ENV_MAP. + /// Either PAINTING_TYPE_IMAGE or PAINTING_TYPE_ENV_MAP. /*0x0C*/ s8 textureType; /// Controls when a passive ripple starts. RIPPLE_TRIGGER_NONE, RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. /*0x0D*/ s8 rippleTrigger; - /// Whether to use shading or not. + /// Whether the painting uses shading when not rippling. Only used for Snowman's Land in vanilla and makes the transition to/from rippling not seamless. /*0x0E*/ s8 shaded; /// The painting's transparency (0..255). Determines the drawing layer of the painting. From 2436072bcd115214eea23c7ea14380df96538776 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 9 Dec 2022 21:41:13 -0500 Subject: [PATCH 33/81] Move painting functionality except for rendering into bhv_painting_loop + remove area update counter fields + change relative mario and ripple positions to floats --- include/level_commands.h | 8 +- include/object_fields.h | 18 +- src/game/paintings.c | 475 ++++++++++++++++++++------------------- 3 files changed, 251 insertions(+), 250 deletions(-) diff --git a/include/level_commands.h b/include/level_commands.h index ac8659b333..7f68d0b783 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -374,14 +374,14 @@ enum GoddardScene { CMD_BBBB(LEVEL_CMD_CREATE_WARP_NODE, 0x08, id, destLevel), \ CMD_BBBB(destArea, destNode, flags, 0x00) -#define CMD27(id, destLevel, destArea, destNode, flags) \ - CMD_BBBB(LEVEL_CMD_27, 0x08, id, destLevel), \ - CMD_BBBB(destArea, destNode, flags, 0x00) - // Backwards compatibility: #define PAINTING_WARP_NODE(id, destLevel, destArea, destNode, flags) \ WARP_NODE(id, destLevel, destArea, destNode, flags) +#define CMD27(id, destLevel, destArea, destNode, flags) \ + CMD_BBBB(LEVEL_CMD_27, 0x08, id, destLevel), \ + CMD_BBBB(destArea, destNode, flags, 0x00) + #define INSTANT_WARP(index, destArea, displaceX, displaceY, displaceZ) \ CMD_BBBB(LEVEL_CMD_CREATE_INSTANT_WARP, 0x10, index, destArea), \ CMD_W(displaceX), \ diff --git a/include/object_fields.h b/include/object_fields.h index e0c53a5b33..36d5b9297f 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1256,16 +1256,14 @@ /* Painting */ #define /*0x0F4*/ oPaintingData OBJECT_FIELD_CVPTR(0x1B) -#define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_S32(0x1C) -#define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_S32(0x1D) -#define /*0x100*/ oPaintingRippleX OBJECT_FIELD_S32(0x1E) -#define /*0x104*/ oPaintingRippleY OBJECT_FIELD_S32(0x1F) -#define /*0x108*/ oPaintingUpdateCounter OBJECT_FIELD_S16(0x20, 0) -#define /*0x10A*/ oPaintingLastUpdateCounter OBJECT_FIELD_S16(0x20, 1) -#define /*0x10C*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x21, 0) -#define /*0x10E*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x21, 1) -#define /*0x110*/ oPaintingState OBJECT_FIELD_S16(0x22, 0) -#define /*0x112*/ oPaintingRippleTimer OBJECT_FIELD_S16(0x22, 1) +#define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_F32(0x1C) +#define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_F32(0x1D) +#define /*0x100*/ oPaintingRippleX OBJECT_FIELD_F32(0x1E) +#define /*0x104*/ oPaintingRippleY OBJECT_FIELD_F32(0x1F) +#define /*0x108*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x20, 0) +#define /*0x10A*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x20, 1) +#define /*0x10C*/ oPaintingState OBJECT_FIELD_S32(0x21) +#define /*0x110*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x22) #define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) #define /*0x1A8*/ oPaintingRippleDecay OBJECT_FIELD_F32(0x48) #define /*0x1AC*/ oPaintingCurrRippleRate OBJECT_FIELD_F32(0x49) diff --git a/src/game/paintings.c b/src/game/paintings.c index a6d4dffa6e..7380c69656 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -76,7 +76,6 @@ const struct Painting *sPaintings[] = { /* PAINTING_ID_CASTLE_RR */ &rr_painting, /* PAINTING_ID_HMC_COTMC */ &cotmc_painting, /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, - NULL, }; /** @@ -129,170 +128,7 @@ static const struct RippleAnimationInfo sRippleAnimationInfo[] = { } }; -/** - * Returns a pointer to the RippleAnimationInfo that best fits the painting type. - */ -const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *painting) { - s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; - - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - rippleAnimationType = RIPPLE_ANIM_PROXIMITY; - - if (painting->sizeX >= (PAINTING_SIZE * 2) - || painting->sizeY >= (PAINTING_SIZE * 2)) { - rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; - } - } - - return &sRippleAnimationInfo[rippleAnimationType]; -} - -/** - * Set the painting's state, causing it to start a passive ripple or a ripple from Mario entering. - * - * @param state The state to enter - * @param painting,paintingGroup identifies the painting that is changing state - * @param xSource,ySource what to use for the x and y origin of the ripple - * @param doResetTimer if TRUE, set the timer to 0 - */ -void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { - const struct Painting *painting = obj->oPaintingData; - const struct RippleAnimationInfo *anim = get_ripple_animation(painting); - - // Use a different set of variables depending on the state - switch (state) { - case PAINTING_RIPPLE: - obj->oPaintingCurrRippleMag = anim->passiveRippleMag; - obj->oPaintingRippleDecay = anim->passiveRippleDecay; - obj->oPaintingCurrRippleRate = anim->passiveRippleRate; - obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; - break; - - case PAINTING_ENTERED: - obj->oPaintingCurrRippleMag = anim->entryRippleMag; - obj->oPaintingRippleDecay = anim->entryRippleDecay; - obj->oPaintingCurrRippleRate = anim->entryRippleRate; - obj->oPaintingDispersionFactor = anim->entryDispersionFactor; - break; - } - - obj->oPaintingState = state; - - // Set the ripple position. - if (centerRipples) { - obj->oPaintingRippleX = (painting->sizeX * 0.5f); - obj->oPaintingRippleY = (painting->sizeY * 0.5f); - } else { - obj->oPaintingRippleX = obj->oPaintingLocalMarioPosX; - obj->oPaintingRippleY = obj->oPaintingLocalMarioPosY; - } - - // Set Mario's Y position for the WDW water level. - gPaintingMarioYEntry = gMarioObject->oPosY; - - if (doResetTimer) { - obj->oPaintingRippleTimer = 0; - } - - gRipplingPaintingObject = obj; -} - -/** - * Check for Mario entering the painting. - */ -void painting_update_mario_pos(struct Object *obj) { - if (!gMarioObject) { - return; - } - - s8 rippleFlags = RIPPLE_FLAGS_NONE; - - Vec3f marioWorldPos; - Vec3f marioLocalPos; - Vec3s rotation; - - // Add PAINTING_MARIO_Y_OFFSET to make the ripple closer to Mario's center of mass. - vec3f_copy_y_off(marioWorldPos, &gMarioObject->oPosVec, PAINTING_MARIO_Y_OFFSET); - - // Get the painting's rotation. - vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); - - // Get Mario's position in the painting's local space. - vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); - - // Get the const painting data. - const struct Painting *painting = obj->oPaintingData; - - // Check if Mario is within the painting bounds laterally in local space. - if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN - && marioLocalPos[0] < (painting->sizeX + PAINTING_EDGE_MARGIN) - && marioLocalPos[1] > -PAINTING_EDGE_MARGIN - && marioLocalPos[1] < (painting->sizeY + PAINTING_EDGE_MARGIN)) { - // Check whether Mario is inside the wobble zone. - if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH - && marioLocalPos[2] > 0.0f) { - rippleFlags |= RIPPLE_FLAG_RIPPLE; - } - // Check whether Mario is inside the warp zone. - if (marioLocalPos[2] < 0.0f - && marioLocalPos[2] > -PAINTING_WARP_DEPTH) { - rippleFlags |= RIPPLE_FLAG_ENTER; - } - } - - s8 lastFlags = obj->oPaintingCurrFlags; - - // At most 1 of these will be nonzero. - obj->oPaintingCurrFlags = rippleFlags; - - // changedFlags is true if currFlags is true and lastFlags is false - // (Mario just entered the floor on this frame). - obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); - - obj->oPaintingLocalMarioPosX = marioLocalPos[0]; - obj->oPaintingLocalMarioPosY = marioLocalPos[1]; -} - -/** - * Update the ripple's timer and magnitude, making it propagate outwards. - * - * Automatically changes the painting back to IDLE state (or RIPPLE for continuous paintings) if the - * ripple's magnitude becomes small enough. - */ -void painting_update_ripple_state(const struct Painting *painting) { - struct Object *obj = gCurGraphNodeObjectNode; - const struct RippleAnimationInfo *anim = get_ripple_animation(painting); - - if (obj->oPaintingUpdateCounter != obj->oPaintingLastUpdateCounter) { - obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; - - // Reset the timer to 0 if it overflows. - if (obj->oPaintingRippleTimer < 0) { - obj->oPaintingRippleTimer = 0; - } - - obj->oPaintingRippleTimer++; - } - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - // If the painting is barely rippling, make it stop rippling. - if (obj->oPaintingCurrRippleMag <= 1.0f) { - obj->oPaintingState = PAINTING_IDLE; - gRipplingPaintingObject = NULL; - } - } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - // If the painting is doing the entry ripple but the ripples are as small as those from the - // passive ripple, make it do a passive ripple. - // If Mario goes below the surface but doesn't warp, the painting will eventually reset. - if ((obj->oPaintingState == PAINTING_ENTERED) - && (obj->oPaintingCurrRippleMag <= anim->passiveRippleMag)) { - obj->oPaintingState = PAINTING_RIPPLE; - obj->oPaintingCurrRippleMag = anim->passiveRippleMag; - obj->oPaintingRippleDecay = anim->passiveRippleDecay; - obj->oPaintingCurrRippleRate = anim->passiveRippleRate; - obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; - } - } -} +/// - DRAW - /** * Allocates and generates a mesh for the rippling painting effect by modifying the passed in `mesh` @@ -313,8 +149,8 @@ void painting_update_ripple_state(const struct Painting *painting) { * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_generate_mesh(const struct Painting *painting, const PaintingData *mesh, PaintingData numVtx) { - struct Object *obj = gCurGraphNodeObjectNode; +void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, PaintingData numVtx) { + const struct Painting *painting = obj->oPaintingData; PaintingData i, tri; sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); @@ -722,9 +558,6 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, painting->alpha)); } - // Update the ripple, may automatically reset the painting's state. - painting_update_ripple_state(painting); - gSPPopMatrix(gfx++, G_MTX_MODELVIEW); Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_rippling_end); gSPDisplayList(gfx++, endDl); @@ -737,7 +570,8 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { * Generates a mesh, calculates vertex normals for lighting, and renders a rippling painting. * The mesh and vertex normals are regenerated and freed every frame. */ -Gfx *display_painting_rippling(const struct Painting *painting) { +Gfx *display_painting_rippling(struct Object *obj) { + const struct Painting *painting = obj->oPaintingData; const PaintingData *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); const PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); PaintingData numVtx = mesh[0]; @@ -745,7 +579,7 @@ Gfx *display_painting_rippling(const struct Painting *painting) { Gfx *dlist = NULL; // Generate the mesh and its lighting data - painting_generate_mesh(painting, mesh, numVtx); + painting_generate_mesh(obj, mesh, numVtx); painting_calculate_triangle_normals(mesh, numVtx, numTris); painting_average_vertex_normals(neighborTris, numVtx); @@ -864,7 +698,8 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { /** * Render a normal painting. */ -Gfx *display_painting_not_rippling(const struct Painting *painting) { +Gfx *display_painting_not_rippling(struct Object *obj) { + const struct Painting *painting = obj->oPaintingData; u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -887,11 +722,9 @@ Gfx *display_painting_not_rippling(const struct Painting *painting) { } /** - * Render and update the painting whose id and group matches the values in the GraphNode's parameter. - * Use PAINTING_ID(id, group) to set the right parameter in a level's geo layout. + * Draw the painting. */ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context) { - struct GraphNodeGenerated *gen = (struct GraphNodeGenerated *) node; struct Object *obj = gCurGraphNodeObjectNode; if (obj == NULL) { @@ -907,24 +740,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con Gfx *paintingDlist = NULL; - if (callContext != GEO_CONTEXT_RENDER) { // Init - // Reset the update counter. - obj->oPaintingLastUpdateCounter = (gAreaUpdateCounter - 1); - obj->oPaintingUpdateCounter = gAreaUpdateCounter; - - // Clear Mario-related state and clear gRipplingPaintingObject. - obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; - obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; - - gRipplingPaintingObject = NULL; - } else if (callContext == GEO_CONTEXT_RENDER) { // Update - // Reset the update counter. - obj->oPaintingLastUpdateCounter = obj->oPaintingUpdateCounter; - obj->oPaintingUpdateCounter = gAreaUpdateCounter; - - // Update the painting info. - painting_update_mario_pos(obj); - + if (callContext == GEO_CONTEXT_RENDER) { // Draw the painting. if (painting->imageCount > 0 && painting->textureArray != NULL @@ -933,58 +749,28 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con && painting->alpha > 0x00) { // Determine whether the painting is opaque or transparent. if (painting->alpha == 0xFF) { - SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); + SET_GRAPH_NODE_LAYER(node->flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); } else { - SET_GRAPH_NODE_LAYER(gen->fnNode.node.flags, LAYER_TRANSPARENT); + SET_GRAPH_NODE_LAYER(node->flags, LAYER_TRANSPARENT); } if (obj->oPaintingState == PAINTING_IDLE) { - paintingDlist = display_painting_not_rippling(painting); + paintingDlist = display_painting_not_rippling(obj); } else { - paintingDlist = display_painting_rippling(painting); - } - } - - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - // Proximity type: - if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_ENTERED, FALSE, TRUE); // Entering - } else if (obj->oPaintingState != PAINTING_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE); // Wobbling + paintingDlist = display_painting_rippling(obj); } - } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - // Continuous type: - if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); // Entering - } else if (obj->oPaintingState == PAINTING_IDLE) { - painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE); // Idle - } - } - - if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { - // Mario has entered the painting. - gEnteredPaintingObject = obj; - } else if (gEnteredPaintingObject == obj) { - // Reset gEnteredPaintingObject if it's this painting and this painting is not entered. - gEnteredPaintingObject = NULL; } } return paintingDlist; } -void bhv_painting_init(void) { - struct Object *obj = o; +/// - INIT - - // Get the painting id from the first byte behavior params. The second byte is used for the warp node ID. - s32 id = GET_BPARAM1(obj->oBehParams); - - const struct Painting *painting = segmented_to_virtual(sPaintings[id]); - - // Set the object's painting data pointer. - obj->oPaintingData = painting; +void painting_update_room(struct Object *obj) { + const struct Painting *painting = obj->oPaintingData; - // The center of the painting, but with a z offset since paintings are usually between floor triangle edges laterally. + // The center of the painting, but with an offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { (painting->sizeX * 0.5f), (painting->sizeY * 0.5f), @@ -1007,6 +793,142 @@ void bhv_painting_init(void) { ); } +void bhv_painting_init(void) { + struct Object *obj = o; + + // Get the painting id from the first byte of the behavior params. The second byte is used for the warp node ID. + s32 id = GET_BPARAM1(obj->oBehParams); + + const struct Painting *painting = segmented_to_virtual(sPaintings[id]); + + // Set the object's painting data pointer. + obj->oPaintingData = painting; + + // Update the painting object's room. + painting_update_room(obj); + + // Clear Mario-related state and clear gRipplingPaintingObject. + obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; + obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; + + gRipplingPaintingObject = NULL; +} + +/// - LOOP - + +/** + * Check for Mario entering the painting. + */ +void painting_update_mario_pos(struct Object *obj) { + if (!gMarioObject) { + return; + } + + s8 rippleFlags = RIPPLE_FLAGS_NONE; + + Vec3f marioWorldPos; + Vec3f marioLocalPos; + Vec3s rotation; + + // Add PAINTING_MARIO_Y_OFFSET to make the ripple closer to Mario's center of mass. + vec3f_copy_y_off(marioWorldPos, &gMarioObject->oPosVec, PAINTING_MARIO_Y_OFFSET); + + // Get the painting's rotation. + vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); + + // Get Mario's position in the painting's local space. + vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); + + // Get the const painting data. + const struct Painting *painting = obj->oPaintingData; + + // Check if Mario is within the painting bounds laterally in local space. + if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN + && marioLocalPos[0] < (painting->sizeX + PAINTING_EDGE_MARGIN) + && marioLocalPos[1] > -PAINTING_EDGE_MARGIN + && marioLocalPos[1] < (painting->sizeY + PAINTING_EDGE_MARGIN)) { + // Check whether Mario is inside the wobble zone. + if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH + && marioLocalPos[2] > 0.0f) { + rippleFlags |= RIPPLE_FLAG_RIPPLE; + } + // Check whether Mario is inside the warp zone. + if (marioLocalPos[2] < 0.0f + && marioLocalPos[2] > -PAINTING_WARP_DEPTH) { + rippleFlags |= RIPPLE_FLAG_ENTER; + } + } + + s16 lastFlags = obj->oPaintingCurrFlags; + + // At most 1 of these will be nonzero. + obj->oPaintingCurrFlags = rippleFlags; + + // changedFlags is true if currFlags is true and lastFlags is false + // (Mario just entered the floor on this frame). + obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); + + obj->oPaintingLocalMarioPosX = marioLocalPos[0]; + obj->oPaintingLocalMarioPosY = marioLocalPos[1]; +} + +/** + * Returns a pointer to the RippleAnimationInfo that best fits the painting type. + */ +const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *painting) { + s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; + + if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + rippleAnimationType = RIPPLE_ANIM_PROXIMITY; + + if (painting->sizeX >= (PAINTING_SIZE * 2) + || painting->sizeY >= (PAINTING_SIZE * 2)) { + rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; + } + } + + return &sRippleAnimationInfo[rippleAnimationType]; +} + +/** + * Update the ripple's timer and magnitude, making it propagate outwards. + * + * Automatically changes the painting back to IDLE state (or RIPPLE for continuous paintings) if the + * ripple's magnitude becomes small enough. + */ +void painting_update_ripple_state(struct Object *obj) { + const struct Painting *painting = obj->oPaintingData; + const struct RippleAnimationInfo *anim = get_ripple_animation(painting); + + obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; + + // Reset the timer to 0 if it overflows. + if (obj->oPaintingRippleTimer < 0) { + obj->oPaintingRippleTimer = 0; + } + + obj->oPaintingRippleTimer++; + + if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + // If the painting is barely rippling, make it stop rippling. + if (obj->oPaintingCurrRippleMag <= 1.0f) { + obj->oPaintingState = PAINTING_IDLE; + gRipplingPaintingObject = NULL; + } + } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + // If the painting is doing the entry ripple but the ripples are as small as those from the + // passive ripple, make it do a passive ripple. + // If Mario goes below the surface but doesn't warp, the painting will eventually reset. + if ((obj->oPaintingState == PAINTING_ENTERED) + && (obj->oPaintingCurrRippleMag <= anim->passiveRippleMag)) { + obj->oPaintingState = PAINTING_RIPPLE; + obj->oPaintingCurrRippleMag = anim->passiveRippleMag; + obj->oPaintingRippleDecay = anim->passiveRippleDecay; + obj->oPaintingCurrRippleRate = anim->passiveRippleRate; + obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; + } + } +} #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) s32 gDDDPaintingNotMoved = FALSE; @@ -1050,16 +972,97 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) gDDDPaintingNotMoved = TRUE; } } +#endif // (ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS || UNLOCK_ALL) + +/** + * Set the painting's state, causing it to start a passive ripple or a ripple from Mario entering. + * + * @param state The state to enter + * @param painting,paintingGroup identifies the painting that is changing state + * @param xSource,ySource what to use for the x and y origin of the ripple + * @param doResetTimer if TRUE, set the timer to 0 + */ +void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { + const struct Painting *painting = obj->oPaintingData; + const struct RippleAnimationInfo *anim = get_ripple_animation(painting); + + // Use a different set of variables depending on the state + switch (state) { + case PAINTING_RIPPLE: + obj->oPaintingCurrRippleMag = anim->passiveRippleMag; + obj->oPaintingRippleDecay = anim->passiveRippleDecay; + obj->oPaintingCurrRippleRate = anim->passiveRippleRate; + obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; + break; + + case PAINTING_ENTERED: + obj->oPaintingCurrRippleMag = anim->entryRippleMag; + obj->oPaintingRippleDecay = anim->entryRippleDecay; + obj->oPaintingCurrRippleRate = anim->entryRippleRate; + obj->oPaintingDispersionFactor = anim->entryDispersionFactor; + break; + } + + obj->oPaintingState = state; + + // Set the ripple position. + if (centerRipples) { + obj->oPaintingRippleX = (painting->sizeX * 0.5f); + obj->oPaintingRippleY = (painting->sizeY * 0.5f); + } else { + obj->oPaintingRippleX = obj->oPaintingLocalMarioPosX; + obj->oPaintingRippleY = obj->oPaintingLocalMarioPosY; + } + + // Set Mario's Y position for the WDW water level. + gPaintingMarioYEntry = gMarioObject->oPosY; + + if (doResetTimer) { + obj->oPaintingRippleTimer = 0; + } + + gRipplingPaintingObject = obj; +} + void bhv_painting_loop(void) { struct Object *obj = o; + const struct Painting *painting = obj->oPaintingData; + + // Update the painting info. + painting_update_mario_pos(obj); + + // Update the ripple, may automatically reset the painting's state. + painting_update_ripple_state(obj); +#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) // Update the DDD painting before drawing. if (GET_BPARAM1(obj->oBehParams) == PAINTING_ID_CASTLE_DDD) { move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); } +#endif // (ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS || UNLOCK_ALL) + + if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + // Proximity type: + if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { + painting_state(obj, PAINTING_ENTERED, FALSE, TRUE ); // Entering + } else if (obj->oPaintingState != PAINTING_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { + painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE ); // Wobbling + } + } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + // Continuous type: + if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { + painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); // Entering + } else if (obj->oPaintingState == PAINTING_IDLE) { + painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE ); // Idle + } + } + + if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { + // Mario has entered the painting. + gEnteredPaintingObject = obj; + } else if (gEnteredPaintingObject == obj) { + // Reset gEnteredPaintingObject if it's this painting and this painting is not entered. + gEnteredPaintingObject = NULL; + } } -#else -void bhv_painting_loop(void) { -} -#endif From 2988324b9348d65b1b6cc64b7656bbdc7faae356 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 00:18:44 -0500 Subject: [PATCH 34/81] Improve painting texture map names + change imageCount check to switch --- bin/segment2.c | 17 +++++++++-------- src/game/paintings.c | 9 ++++----- src/game/segment2.h | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index c16dde8d91..48f22b5e15 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3364,6 +3364,7 @@ const PaintingData seg2_painting_triangle_mesh[] = { #undef PDX #undef PDY +#undef PAINTING_VERTEX /* 0x02015444: seg2_painting_mesh_neighbor_tris * Lists the neighboring triangles for each vertex in the mesh. @@ -3535,7 +3536,7 @@ const PaintingData seg2_painting_mesh_neighbor_tris[] = { }; // 0x07021AE0 - 0x07021FFA -static const PaintingData seg2_painting_image_texture_map_bottom[] = { +static const PaintingData seg2_painting_image_texture_map_2_bottom[] = { 85, // num mappings // Format: // mesh vtx ID @@ -3763,7 +3764,7 @@ static const PaintingData seg2_painting_image_texture_map_bottom[] = { }; // 0x07021FFC - 0x07022516 -static const PaintingData seg2_painting_image_texture_map_top[] = { +static const PaintingData seg2_painting_image_texture_map_2_top[] = { 85, // num mappings // Format: // mesh vtx ID @@ -3991,13 +3992,13 @@ static const PaintingData seg2_painting_image_texture_map_top[] = { }; // 0x07022518 -const PaintingData *const seg2_painting_image_texture_maps[] = { - seg2_painting_image_texture_map_bottom, - seg2_painting_image_texture_map_top, +const PaintingData *const seg2_painting_texture_maps_2[] = { + seg2_painting_image_texture_map_2_bottom, + seg2_painting_image_texture_map_2_top, }; // 0x07022660 - 0x07023042 -static const PaintingData seg2_painting_env_map_texture_map[] = { +static const PaintingData seg2_painting_texture_map_1[] = { 157, // num mappings // Format: // mesh vtx ID @@ -4430,6 +4431,6 @@ static const PaintingData seg2_painting_env_map_texture_map[] = { }; // 0x07023044 - 0x07023048 -const PaintingData *const seg2_painting_env_map_texture_maps[] = { - seg2_painting_env_map_texture_map, +const PaintingData *const seg2_painting_texture_maps_1[] = { + seg2_painting_texture_map_1, }; diff --git a/src/game/paintings.c b/src/game/paintings.c index 7380c69656..4838efa464 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -541,12 +541,11 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); - //! TODO: Automatically determine texture maps based on the image count. + //! TODO: Automatically create texture maps based on the image count. const PaintingData **textureMaps = NULL; - if (imageCount > 1) { - textureMaps = segmented_to_virtual(seg2_painting_image_texture_maps); - } else { - textureMaps = segmented_to_virtual(seg2_painting_env_map_texture_maps); + switch (imageCount) { + case 1: textureMaps = segmented_to_virtual(seg2_painting_texture_maps_1); break; + case 2: textureMaps = segmented_to_virtual(seg2_painting_texture_maps_2); break; } painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); diff --git a/src/game/segment2.h b/src/game/segment2.h index 80d40b814d..459f3f0ab7 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -47,8 +47,8 @@ extern Gfx dl_paintings_env_mapped_begin[]; extern Gfx dl_paintings_env_mapped_end[]; extern PaintingData seg2_painting_triangle_mesh[]; extern PaintingData seg2_painting_mesh_neighbor_tris[]; -extern PaintingData *const seg2_painting_image_texture_maps[]; -extern PaintingData *const seg2_painting_env_map_texture_maps[]; +extern PaintingData *const seg2_painting_texture_maps_1[]; +extern PaintingData *const seg2_painting_texture_maps_2[]; extern Texture *main_hud_lut[58]; extern Gfx dl_hud_img_load_tex_block[]; extern Gfx dl_hud_img_begin[]; From 3c17702b4d5d77d9a4de4a3288a6e2a499a04a5e Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 01:38:12 -0500 Subject: [PATCH 35/81] Remove gRipplingPaintingObject + clean up painting eject sound --- src/game/level_update.c | 11 +++++++++-- src/game/paintings.c | 19 ++++++------------- src/game/paintings.h | 1 - src/game/sound_init.c | 20 -------------------- src/game/sound_init.h | 3 --- 5 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 07946ad8c4..dcfeefee9b 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -631,6 +631,8 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 warpFlags) #endif } +s8 gPaintingEjectSoundPlayed = FALSE; + /** * Check is Mario has entered a painting, and if so, initiate a warp. */ @@ -642,7 +644,12 @@ void initiate_painting_warp(void) { if (warpNode != NULL) { if (gMarioState->action & ACT_FLAG_INTANGIBLE) { - play_painting_eject_sound(); + // Plays the painting eject sound effect if it has not already been played. + if (!gPaintingEjectSoundPlayed) { + gPaintingEjectSoundPlayed = TRUE; + play_sound(SOUND_GENERAL_PAINTING_EJECT, + gMarioState->marioObj->header.gfx.cameraToObject); + } } else { struct WarpNode *node = &warpNode->node; @@ -660,7 +667,7 @@ void initiate_painting_warp(void) { gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); + play_sound(SOUND_MENU_STAR_SOUND, gMarioState->marioObj->header.gfx.cameraToObject); fadeout_music(398); #if ENABLE_RUMBLE queue_rumble_data(80, 70); diff --git a/src/game/paintings.c b/src/game/paintings.c index 4838efa464..a9769432fb 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -78,11 +78,6 @@ const struct Painting *sPaintings[] = { /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, }; -/** - * The painting that is currently rippling. Only one painting can be rippling at once. - */ -struct Object *gRipplingPaintingObject = NULL; - /** * The id of the painting Mario has entered. */ @@ -766,6 +761,9 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con /// - INIT - +/** + * Updates a painting object's room from a point in front of the center of the painting. + */ void painting_update_room(struct Object *obj) { const struct Painting *painting = obj->oPaintingData; @@ -803,14 +801,12 @@ void bhv_painting_init(void) { // Set the object's painting data pointer. obj->oPaintingData = painting; - // Update the painting object's room. - painting_update_room(obj); - - // Clear Mario-related state and clear gRipplingPaintingObject. + // Clear flags. obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; - gRipplingPaintingObject = NULL; + // Update the painting object's room. + painting_update_room(obj); } /// - LOOP - @@ -912,7 +908,6 @@ void painting_update_ripple_state(struct Object *obj) { // If the painting is barely rippling, make it stop rippling. if (obj->oPaintingCurrRippleMag <= 1.0f) { obj->oPaintingState = PAINTING_IDLE; - gRipplingPaintingObject = NULL; } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // If the painting is doing the entry ripple but the ripples are as small as those from the @@ -1019,8 +1014,6 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi if (doResetTimer) { obj->oPaintingRippleTimer = 0; } - - gRipplingPaintingObject = obj; } diff --git a/src/game/paintings.h b/src/game/paintings.h index 41a537fef1..232e998c9f 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -152,7 +152,6 @@ struct PaintingMeshVertex { }; /*0x0C*/ -extern struct Object *gRipplingPaintingObject; extern struct Object *gEnteredPaintingObject; diff --git a/src/game/sound_init.c b/src/game/sound_init.c index 5d3c2a3309..403c9f3e59 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -76,8 +76,6 @@ static u32 sMenuSoundsExtra[] = { SOUND_ENV_ELEVATOR4, }; -s8 gPaintingEjectSoundPlayed = FALSE; - void play_menu_sounds_extra(s32 a, void *b); /** @@ -182,24 +180,6 @@ void play_menu_sounds(s16 soundMenuFlags) { #endif } -/** - * Plays the painting eject sound effect if it has not already been played - * - * Called from threads: thread5_game_loop - */ -void play_painting_eject_sound(void) { - if (gRipplingPaintingObject != NULL && gRipplingPaintingObject->oPaintingState == PAINTING_ENTERED) { - // ripple when Mario enters painting - if (!gPaintingEjectSoundPlayed) { - play_sound(SOUND_GENERAL_PAINTING_EJECT, - gMarioStates[0].marioObj->header.gfx.cameraToObject); - } - gPaintingEjectSoundPlayed = TRUE; - } else { - gPaintingEjectSoundPlayed = FALSE; - } -} - /** * Called from threads: thread5_game_loop */ diff --git a/src/game/sound_init.h b/src/game/sound_init.h index f12ecf748f..4dff1e7a81 100644 --- a/src/game/sound_init.h +++ b/src/game/sound_init.h @@ -23,8 +23,6 @@ enum SoundMenuMode { SOUND_MENU_MODE_HEADSET }; -extern s8 gPaintingEjectSoundPlayed; - void reset_volume(void); void raise_background_noise(s32 a); void lower_background_noise(s32 a); @@ -32,7 +30,6 @@ void disable_background_sound(void); void enable_background_sound(void); void set_sound_mode(u16 soundMode); void play_menu_sounds(s16 soundMenuFlags); -void play_painting_eject_sound(void); void play_infinite_stairs_music(void); void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer); void fadeout_music(s16 fadeOutTime); From 578e70ed4cae7e3a2fbd9195de74a4b099f2616e Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 17:49:58 -0500 Subject: [PATCH 36/81] RippleAnimationInfo struct changes --- include/object_fields.h | 4 +-- src/game/paintings.c | 71 +++++++++++++++++++---------------------- src/game/paintings.h | 27 +++++++--------- 3 files changed, 46 insertions(+), 56 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 36d5b9297f..fe7d496ff1 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1265,9 +1265,7 @@ #define /*0x10C*/ oPaintingState OBJECT_FIELD_S32(0x21) #define /*0x110*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x22) #define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) -#define /*0x1A8*/ oPaintingRippleDecay OBJECT_FIELD_F32(0x48) -#define /*0x1AC*/ oPaintingCurrRippleRate OBJECT_FIELD_F32(0x49) -#define /*0x1B0*/ oPaintingDispersionFactor OBJECT_FIELD_F32(0x4A) +#define /*0x1A8*/ oPaintingRippleInfo OBJECT_FIELD_CVPTR(0x48) /*Custom general defines: diff --git a/src/game/paintings.c b/src/game/paintings.c index a9769432fb..3211d5f837 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -97,29 +97,20 @@ static struct PaintingMeshVertex *sPaintingMesh; static Vec3f *sPaintingTriNorms; /** - * Info for ripple animations. + * A list of preset constants for the ripple animations. */ -static const struct RippleAnimationInfo sRippleAnimationInfo[] = { +static const struct RippleAnimationTypeInfo sRippleAnimations[] = { { // RIPPLE_ANIM_CONTINUOUS - /* passive entry */ - /* Ripple Magnitude */ 10.0f, 30.0f, - /* Ripple Decay */ 1.0f, 0.98f, - /* Ripple Rate */ 0.05f, 0.05f, - /* Ripple Dispersion */ 15.0f, 15.0f, + .passive = { .mag = 10.0f, .decay = 1.0f, .rate = 0.05f, .dispersion = 15.0f }, + .entry = { .mag = 30.0f, .decay = 0.98f, .rate = 0.05f, .dispersion = 15.0f } }, { // RIPPLE_ANIM_PROXIMITY - /* passive entry */ - /* Ripple Magnitude */ 20.0f, 80.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.24f, 0.14f, - /* Ripple Dispersion */ 40.0f, 30.0f, + .passive = { .mag = 20.0f, .decay = 0.9608f, .rate = 0.24f, .dispersion = 40.0f }, + .entry = { .mag = 80.0f, .decay = 0.9524f, .rate = 0.14f, .dispersion = 30.0f } }, { // RIPPLE_ANIM_PROXIMITY_LARGE - /* passive entry */ - /* Ripple Magnitude */ 40.0f, 160.0f, - /* Ripple Decay */ 0.9608f, 0.9524f, - /* Ripple Rate */ 0.12f, 0.07f, - /* Ripple Dispersion */ 80.0f, 60.0f, + .passive = { .mag = 40.0f, .decay = 0.9608f, .rate = 0.12f, .dispersion = 80.0f }, + .entry = { .mag = 160.0f, .decay = 0.9524f, .rate = 0.07f, .dispersion = 60.0f } } }; @@ -151,13 +142,14 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, Painti sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); struct PaintingMeshVertex *paintingMesh = sPaintingMesh; + const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; /// Controls the peaks of the ripple. f32 rippleMag = obj->oPaintingCurrRippleMag; /// Controls the ripple's frequency. - f32 rippleRate = obj->oPaintingCurrRippleRate; + f32 rippleRate = objRippleInfo->rate; /// Controls how fast the ripple spreads. - f32 dispersionFactor = (1.0f / obj->oPaintingDispersionFactor); + f32 dispersionFactor = (1.0f / objRippleInfo->dispersion); /// How far the ripple has spread. f32 rippleTimer = obj->oPaintingRippleTimer; @@ -800,6 +792,7 @@ void bhv_painting_init(void) { // Set the object's painting data pointer. obj->oPaintingData = painting; + obj->oPaintingRippleInfo = NULL; // Clear flags. obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; @@ -868,9 +861,9 @@ void painting_update_mario_pos(struct Object *obj) { } /** - * Returns a pointer to the RippleAnimationInfo that best fits the painting type. + * Returns a pointer to the RippleAnimationTypeInfo that best fits the painting type. */ -const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *painting) { +const struct RippleAnimationTypeInfo *painting_get_ripple_animation_type_info(const struct Painting *painting) { s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { @@ -882,7 +875,15 @@ const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *pa } } - return &sRippleAnimationInfo[rippleAnimationType]; + return &sRippleAnimations[rippleAnimationType]; +} + +/** + * Set a painting's ripple animation and magnitude. + */ +void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimationInfo *baseRippleInfo) { + obj->oPaintingCurrRippleMag = baseRippleInfo->mag; + obj->oPaintingRippleInfo = baseRippleInfo; } /** @@ -893,9 +894,11 @@ const struct RippleAnimationInfo *get_ripple_animation(const struct Painting *pa */ void painting_update_ripple_state(struct Object *obj) { const struct Painting *painting = obj->oPaintingData; - const struct RippleAnimationInfo *anim = get_ripple_animation(painting); + const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; - obj->oPaintingCurrRippleMag *= obj->oPaintingRippleDecay; + if (objRippleInfo != NULL) { + obj->oPaintingCurrRippleMag *= objRippleInfo->decay; + } // Reset the timer to 0 if it overflows. if (obj->oPaintingRippleTimer < 0) { @@ -910,16 +913,14 @@ void painting_update_ripple_state(struct Object *obj) { obj->oPaintingState = PAINTING_IDLE; } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + const struct RippleAnimationTypeInfo *rippleAnim = painting_get_ripple_animation_type_info(painting); // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. if ((obj->oPaintingState == PAINTING_ENTERED) - && (obj->oPaintingCurrRippleMag <= anim->passiveRippleMag)) { + && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { obj->oPaintingState = PAINTING_RIPPLE; - obj->oPaintingCurrRippleMag = anim->passiveRippleMag; - obj->oPaintingRippleDecay = anim->passiveRippleDecay; - obj->oPaintingCurrRippleRate = anim->passiveRippleRate; - obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; + painting_set_ripple_animation(obj, &rippleAnim->passive); } } } @@ -978,22 +979,16 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { const struct Painting *painting = obj->oPaintingData; - const struct RippleAnimationInfo *anim = get_ripple_animation(painting); + const struct RippleAnimationTypeInfo *rippleAnim = painting_get_ripple_animation_type_info(painting); // Use a different set of variables depending on the state switch (state) { case PAINTING_RIPPLE: - obj->oPaintingCurrRippleMag = anim->passiveRippleMag; - obj->oPaintingRippleDecay = anim->passiveRippleDecay; - obj->oPaintingCurrRippleRate = anim->passiveRippleRate; - obj->oPaintingDispersionFactor = anim->passiveDispersionFactor; + painting_set_ripple_animation(obj, &rippleAnim->passive); break; case PAINTING_ENTERED: - obj->oPaintingCurrRippleMag = anim->entryRippleMag; - obj->oPaintingRippleDecay = anim->entryRippleDecay; - obj->oPaintingCurrRippleRate = anim->entryRippleRate; - obj->oPaintingDispersionFactor = anim->entryDispersionFactor; + painting_set_ripple_animation(obj, &rippleAnim->entry); break; } diff --git a/src/game/paintings.h b/src/game/paintings.h index 232e998c9f..ff8a87bc17 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -90,24 +90,21 @@ enum PaintingState { /** - * A list of preset constants for the ripple animation. + * A list of preset constants for the ripple animations. */ struct RippleAnimationInfo { - /// Controls how high the peaks of the ripple are. - /*0x00*/ f32 passiveRippleMag; - /*0x04*/ f32 entryRippleMag; + /*0x00*/ const f32 mag; /// Controls how high the peaks of the ripple are. + /*0x04*/ const f32 decay; /// Multiplier that controls how fast the ripple regresses to the IDLE state. + /*0x08*/ const f32 rate; /// Controls the ripple's frequency. + /*0x0C*/ const f32 dispersion; /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple. +}; /*0x10*/ - /// Multiplier that controls how fast the ripple regresses to the IDLE state. - /*0x08*/ f32 passiveRippleDecay; - /*0x0C*/ f32 entryRippleDecay; - - /// Controls the ripple's frequency. - /*0x10*/ f32 passiveRippleRate; - /*0x14*/ f32 entryRippleRate; - - /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple. - /*0x18*/ f32 passiveDispersionFactor; - /*0x1C*/ f32 entryDispersionFactor; +/** + * A ripple animation pair. + */ +struct RippleAnimationTypeInfo { + /*0x00*/ const struct RippleAnimationInfo passive; + /*0x10*/ const struct RippleAnimationInfo entry; }; /*0x20*/ /** From 16ebce4cccf456f8af392a80cb5a96c15efb559f Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 17:50:48 -0500 Subject: [PATCH 37/81] Rename 'oPaintingRippleX' and 'oPaintingRippleY' to 'oPaintingRipplePosX' and 'oPaintingRipplePosY' --- include/object_fields.h | 4 ++-- src/game/paintings.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index fe7d496ff1..f0439d5067 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1258,8 +1258,8 @@ #define /*0x0F4*/ oPaintingData OBJECT_FIELD_CVPTR(0x1B) #define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_F32(0x1C) #define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_F32(0x1D) -#define /*0x100*/ oPaintingRippleX OBJECT_FIELD_F32(0x1E) -#define /*0x104*/ oPaintingRippleY OBJECT_FIELD_F32(0x1F) +#define /*0x100*/ oPaintingRipplePosX OBJECT_FIELD_F32(0x1E) +#define /*0x104*/ oPaintingRipplePosY OBJECT_FIELD_F32(0x1F) #define /*0x108*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x20, 0) #define /*0x10A*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x20, 1) #define /*0x10C*/ oPaintingState OBJECT_FIELD_S32(0x21) diff --git a/src/game/paintings.c b/src/game/paintings.c index 3211d5f837..529993afa9 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -154,8 +154,8 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, Painti f32 rippleTimer = obj->oPaintingRippleTimer; /// X and Y of the ripple origin. - f32 rippleX = obj->oPaintingRippleX; - f32 rippleY = obj->oPaintingRippleY; + f32 rippleX = obj->oPaintingRipplePosX; + f32 rippleY = obj->oPaintingRipplePosY; f32 sizeRatioX = (painting->sizeX / PAINTING_SIZE); f32 sizeRatioY = (painting->sizeY / PAINTING_SIZE); @@ -996,11 +996,11 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi // Set the ripple position. if (centerRipples) { - obj->oPaintingRippleX = (painting->sizeX * 0.5f); - obj->oPaintingRippleY = (painting->sizeY * 0.5f); + obj->oPaintingRipplePosX = (painting->sizeX * 0.5f); + obj->oPaintingRipplePosY = (painting->sizeY * 0.5f); } else { - obj->oPaintingRippleX = obj->oPaintingLocalMarioPosX; - obj->oPaintingRippleY = obj->oPaintingLocalMarioPosY; + obj->oPaintingRipplePosX = obj->oPaintingLocalMarioPosX; + obj->oPaintingRipplePosY = obj->oPaintingLocalMarioPosY; } // Set Mario's Y position for the WDW water level. From 5d12ebffc14a6b1fa4feee9bd06cd471f8d33c7b Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 18:09:52 -0500 Subject: [PATCH 38/81] Make WDW water level detextion relative to the painting instead of absolute height. --- src/game/mario_actions_cutscene.c | 3 ++- src/game/moving_texture.c | 6 +++--- src/game/paintings.c | 9 +++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 1fe602b50b..83b93baa30 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -2456,7 +2456,8 @@ static void end_peach_cutscene_run_to_castle(struct MarioState *m) { static void end_peach_cutscene_fade_out(struct MarioState *m) { if (m->actionState == ACT_STATE_END_PEACH_CUTSCENE_FADE_OUT_WARP) { level_trigger_warp(m, WARP_OP_CREDITS_NEXT); - gPaintingMarioYEntry = 1500.0f; // ensure medium water level in WDW credits cutscene + // Ensure medium water level in WDW credits cutscene. + gPaintingMarioYEntry = 194.0f; // This would be a little under one third of the painting's height. m->actionState = ACT_STATE_END_PEACH_CUTSCENE_FADE_OUT_END; } } diff --git a/src/game/moving_texture.c b/src/game/moving_texture.c index 194037c058..b3f740caa4 100644 --- a/src/game/moving_texture.c +++ b/src/game/moving_texture.c @@ -123,7 +123,7 @@ enum MovtexVtxColors { s8 gMovtexVtxColor = MOVTEX_VTX_COLOR_DEFAULT; /// The height at which Mario entered the last painting. Used for Wet-Dry World only. -float gPaintingMarioYEntry = 0.0f; +f32 gPaintingMarioYEntry = 0.0f; /// Variable to ensure the initial Wet-Dry World water level is set only once s32 gWdwWaterLevelSet = FALSE; @@ -261,9 +261,9 @@ Gfx *geo_wdw_set_initial_water_level(s32 callContext, UNUSED struct GraphNode *n gWdwWaterLevelSet = FALSE; } else if (callContext == GEO_CONTEXT_RENDER && gEnvironmentRegions != NULL && !gWdwWaterLevelSet) { - if (gPaintingMarioYEntry <= 1382.4f) { + if (gPaintingMarioYEntry <= 76.4f) { // A little under one Mario height above the bottom of the painting. wdwWaterHeight = 31; - } else if (gPaintingMarioYEntry >= 1600.0f) { + } else if (gPaintingMarioYEntry >= 294.0f) { // A little under half the painting's height. wdwWaterHeight = 2816; } else { wdwWaterHeight = 1024; diff --git a/src/game/paintings.c b/src/game/paintings.c index 529993afa9..290811fa1c 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -1003,8 +1003,13 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi obj->oPaintingRipplePosY = obj->oPaintingLocalMarioPosY; } - // Set Mario's Y position for the WDW water level. - gPaintingMarioYEntry = gMarioObject->oPosY; +#ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS + if (GET_BPARAM1(obj->oBehParams) == PAINTING_ID_CASTLE_WDW) { + // Set Mario's Y position for the WDW water level. + // The WDW painting is at 1306 in vanilla. + gPaintingMarioYEntry = gMarioObject->oPosY - obj->oPosY; + } +#endif if (doResetTimer) { obj->oPaintingRippleTimer = 0; From eed1293624882d364ef0b9e4e8f05b538fced0ea Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 18:38:32 -0500 Subject: [PATCH 39/81] Replace gEnteredPaintingObject with a MarioState field --- include/types.h | 1 + src/game/behaviors/clock_arm.inc.c | 10 ++++++---- src/game/level_update.c | 8 ++++---- src/game/mario.c | 2 ++ src/game/object_list_processor.c | 1 - src/game/paintings.c | 32 +++++++++++++----------------- src/game/paintings.h | 3 --- 7 files changed, 27 insertions(+), 30 deletions(-) diff --git a/include/types.h b/include/types.h index cd9dcd57c4..4397aac839 100644 --- a/include/types.h +++ b/include/types.h @@ -473,6 +473,7 @@ struct MarioState { /*0xC0*/ f32 quicksandDepth; /*0xC4*/ f32 windGravity; // -- HackerSM64 MarioState fields begin -- + struct Object *paintingObj; #ifdef BREATH_METER s16 breath; u8 breathCounter; diff --git a/src/game/behaviors/clock_arm.inc.c b/src/game/behaviors/clock_arm.inc.c index 2f75975454..f0986c27b5 100644 --- a/src/game/behaviors/clock_arm.inc.c +++ b/src/game/behaviors/clock_arm.inc.c @@ -4,21 +4,23 @@ * Main loop of the hour and minute hands of the Tick Tock Clock painting. */ void bhv_rotating_clock_arm_loop(void) { - u16 rollAngle = o->oFaceAngleRoll; + struct Object *paintingObj = gMarioState->paintingObj; if (o->oAction == TTC_PAINTING_CLOCK_ARM_WAIT) { // Make sure Mario not in a painting & 3 frames pass before allowing him to // change the Tick Tock Clock speed setting. // Probably a safety check for when you leave the level through the painting // to make sure the setting isn't accidentally locked in as you fly out. - if (gEnteredPaintingObject == NULL && o->oTimer > 3) { + if (paintingObj == NULL && o->oTimer > 3) { o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_MOVING } } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_MOVING) { // If Mario is entering the Tick Tock Clock painting... - if (gEnteredPaintingObject != NULL && GET_BPARAM1(gEnteredPaintingObject->oBehParams) == PAINTING_ID_CASTLE_TTC) { + if (paintingObj != NULL && GET_BPARAM1(paintingObj->oBehParams) == PAINTING_ID_CASTLE_TTC) { // And this is the minute hand... if (cur_obj_has_behavior(bhvClockMinuteHand)) { + u16 rollAngle = o->oFaceAngleRoll; + // Set Tick Tick Clock's speed based on the angle of the hand. // The angle actually counting down from 0xFFFF to 0 so // 11 o'clock is a small value and 1 o'clock is a large value. @@ -40,7 +42,7 @@ void bhv_rotating_clock_arm_loop(void) { o->oAction++; // TTC_PAINTING_CLOCK_ARM_ACT_STOPPED } } else if (o->oAction == TTC_PAINTING_CLOCK_ARM_ACT_STOPPED) { - if (gEnteredPaintingObject == NULL) { + if (paintingObj == NULL) { o->oAction = TTC_PAINTING_CLOCK_ARM_ACT_MOVING; } } diff --git a/src/game/level_update.c b/src/game/level_update.c index dcfeefee9b..f95a737fca 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -637,10 +637,10 @@ s8 gPaintingEjectSoundPlayed = FALSE; * Check is Mario has entered a painting, and if so, initiate a warp. */ void initiate_painting_warp(void) { - struct ObjectWarpNode *warpNode = NULL; + struct Object *paintingObj = gMarioState->paintingObj; - if (gEnteredPaintingObject != NULL) { - warpNode = area_get_warp_node(GET_BPARAM2(gEnteredPaintingObject->oBehParams)); + if (paintingObj != NULL) { + struct ObjectWarpNode *warpNode = area_get_warp_node(GET_BPARAM2(paintingObj->oBehParams)); if (warpNode != NULL) { if (gMarioState->action & ACT_FLAG_INTANGIBLE) { @@ -673,7 +673,7 @@ void initiate_painting_warp(void) { queue_rumble_data(80, 70); queue_rumble_decay(1); #endif - cutscene_object(CUTSCENE_ENTER_PAINTING, gEnteredPaintingObject); + cutscene_object(CUTSCENE_ENTER_PAINTING, paintingObj); } } } else { diff --git a/src/game/mario.c b/src/game/mario.c index ebf3bb2688..bd6a824dde 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1824,6 +1824,8 @@ void init_mario(void) { gMarioState->riddenObj = NULL; gMarioState->usedObj = NULL; + gMarioState->paintingObj = NULL; + gMarioState->waterLevel = find_water_level(gMarioSpawnInfo->startPos[0], gMarioSpawnInfo->startPos[2]); gMarioState->area = gCurrentArea; diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 5e77188389..97382e9029 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -526,7 +526,6 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { void clear_objects(void) { s32 i; - gEnteredPaintingObject = NULL; gTHIWaterDrained = 0; gTimeStopState = 0; gMarioObject = NULL; diff --git a/src/game/paintings.c b/src/game/paintings.c index 290811fa1c..fb10e5ae45 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -78,11 +78,6 @@ const struct Painting *sPaintings[] = { /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, }; -/** - * The id of the painting Mario has entered. - */ -struct Object *gEnteredPaintingObject = NULL; - /** * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. * @@ -807,7 +802,7 @@ void bhv_painting_init(void) { /** * Check for Mario entering the painting. */ -void painting_update_mario_pos(struct Object *obj) { +void painting_update_mario_pos_and_flags(struct Object *obj) { if (!gMarioObject) { return; } @@ -846,6 +841,9 @@ void painting_update_mario_pos(struct Object *obj) { rippleFlags |= RIPPLE_FLAG_ENTER; } } + + obj->oPaintingLocalMarioPosX = marioLocalPos[0]; + obj->oPaintingLocalMarioPosY = marioLocalPos[1]; s16 lastFlags = obj->oPaintingCurrFlags; @@ -855,9 +853,15 @@ void painting_update_mario_pos(struct Object *obj) { // changedFlags is true if currFlags is true and lastFlags is false // (Mario just entered the floor on this frame). obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); - - obj->oPaintingLocalMarioPosX = marioLocalPos[0]; - obj->oPaintingLocalMarioPosY = marioLocalPos[1]; + + // Detect whether Mario is entering this painting, and set paintingObj accordingly + if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { + // Mario has entered the painting. + gMarioState->paintingObj = obj; + } else if (gMarioState->paintingObj == obj) { + // Reset gMarioState->paintingObj if it's this painting and this painting is not entered. + gMarioState->paintingObj = NULL; + } } /** @@ -1022,7 +1026,7 @@ void bhv_painting_loop(void) { const struct Painting *painting = obj->oPaintingData; // Update the painting info. - painting_update_mario_pos(obj); + painting_update_mario_pos_and_flags(obj); // Update the ripple, may automatically reset the painting's state. painting_update_ripple_state(obj); @@ -1049,12 +1053,4 @@ void bhv_painting_loop(void) { painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE ); // Idle } } - - if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { - // Mario has entered the painting. - gEnteredPaintingObject = obj; - } else if (gEnteredPaintingObject == obj) { - // Reset gEnteredPaintingObject if it's this painting and this painting is not entered. - gEnteredPaintingObject = NULL; - } } diff --git a/src/game/paintings.h b/src/game/paintings.h index ff8a87bc17..9c227180ac 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -149,9 +149,6 @@ struct PaintingMeshVertex { }; /*0x0C*/ -extern struct Object *gEnteredPaintingObject; - - Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); void bhv_painting_init(void); From a73531aa411c96dcad79b637c1cd570c49a65d93 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 10 Dec 2022 22:22:01 -0500 Subject: [PATCH 40/81] small changes --- src/game/paintings.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index fb10e5ae45..541ebcc077 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -132,12 +132,12 @@ static const struct RippleAnimationTypeInfo sRippleAnimations[] = { */ void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, PaintingData numVtx) { const struct Painting *painting = obj->oPaintingData; + const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; PaintingData i, tri; sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); struct PaintingMeshVertex *paintingMesh = sPaintingMesh; - const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; /// Controls the peaks of the ripple. f32 rippleMag = obj->oPaintingCurrRippleMag; @@ -787,7 +787,6 @@ void bhv_painting_init(void) { // Set the object's painting data pointer. obj->oPaintingData = painting; - obj->oPaintingRippleInfo = NULL; // Clear flags. obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; @@ -976,9 +975,9 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) /** * Set the painting's state, causing it to start a passive ripple or a ripple from Mario entering. * + * @param obj identifies the painting that is changing state * @param state The state to enter - * @param painting,paintingGroup identifies the painting that is changing state - * @param xSource,ySource what to use for the x and y origin of the ripple + * @param centerRipples if TRUE, center the ripples instead of putting them at Mario's position * @param doResetTimer if TRUE, set the timer to 0 */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { From 508fe3958cbcebcc5304e4f94f000841b2542705 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 11 Dec 2022 20:01:39 -0500 Subject: [PATCH 41/81] Make 'sPaintingMesh' and 'sPaintingTriNorms' into local variables --- src/game/paintings.c | 115 +++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 64 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 541ebcc077..6b1b943b1b 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -78,19 +78,6 @@ const struct Painting *sPaintings[] = { /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, }; -/** - * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. - * - * This mesh only contains the vertex positions and normals. - * Paintings use an additional array to map textures to the mesh. - */ -static struct PaintingMeshVertex *sPaintingMesh; - -/** - * The painting's surface normals, used to approximate each of the vertex normals (for gouraud shading). - */ -static Vec3f *sPaintingTriNorms; - /** * A list of preset constants for the ripple animations. */ @@ -130,15 +117,11 @@ static const struct RippleAnimationTypeInfo sRippleAnimations[] = { * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, PaintingData numVtx) { +void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { const struct Painting *painting = obj->oPaintingData; const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; PaintingData i, tri; - sPaintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); - - struct PaintingMeshVertex *paintingMesh = sPaintingMesh; - /// Controls the peaks of the ripple. f32 rippleMag = obj->oPaintingCurrRippleMag; /// Controls the ripple's frequency. @@ -162,11 +145,11 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, Painti // Accesses are off by 1 since the first entry is the number of vertices. for (i = 0; i < numVtx; i++) { tri = (i * 3); - paintingMesh->pos[0] = mesh[tri + 1]; - paintingMesh->pos[1] = mesh[tri + 2]; + paintingMesh->pos[0] = meshData[tri + 1]; + paintingMesh->pos[1] = meshData[tri + 2]; // The "Z coordinate" of each vertex in the mesh is either 1 or 0. Instead of being an // actual coordinate, it just determines whether the vertex moves. - if (mesh[tri + 3]) { + if (meshData[tri + 3]) { // Scale and calculate the distance to the ripple origin. dx = ((paintingMesh->pos[0] * sizeRatioX) - rippleX); dy = ((paintingMesh->pos[1] * sizeRatioY) - rippleY); @@ -205,23 +188,21 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *mesh, Painti * * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(const PaintingData *mesh, PaintingData numVtx, PaintingData numTris) { +void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingData numVtx, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData i; Vec3s v; Vec3f vp0, vp1, vp2; - sPaintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); - for (i = 0; i < numTris; i++) { // Add 2 because of the 2 length entries preceding the list. PaintingData tri = (1 + (numVtx * 3) + 1 + (i * 3)); - vec3s_copy(v, &mesh[tri]); - vec3s_to_vec3f(vp0, sPaintingMesh[v[0]].pos); - vec3s_to_vec3f(vp1, sPaintingMesh[v[1]].pos); - vec3s_to_vec3f(vp2, sPaintingMesh[v[2]].pos); + vec3s_copy(v, &meshData[tri]); + vec3s_to_vec3f(vp0, paintingMesh[v[0]].pos); + vec3s_to_vec3f(vp1, paintingMesh[v[1]].pos); + vec3s_to_vec3f(vp2, paintingMesh[v[2]].pos); // Cross product to find each triangle's normal vector. - find_vector_perpendicular_to_plane(sPaintingTriNorms[i], vp0, vp1, vp2); + find_vector_perpendicular_to_plane(paintingTriNorms[i], vp0, vp1, vp2); } } @@ -240,7 +221,7 @@ void painting_calculate_triangle_normals(const PaintingData *mesh, PaintingData * * The table used in game, seg2_painting_mesh_neighbor_tris, is in bin/segment2.c. */ -void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingData numVtx) { +void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData tri; PaintingData i, j; PaintingData numNeighbors; @@ -253,7 +234,7 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD numNeighbors = neighborTris[entry]; for (j = 0; j < numNeighbors; j++) { tri = neighborTris[entry + 1 + j]; - vec3f_add(n, sPaintingTriNorms[tri]); + vec3f_add(n, paintingTriNorms[tri]); } // Move to the next vertex's entry @@ -265,9 +246,9 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD if (FLT_IS_NONZERO(nlen)) { nlen = (127.0f / sqrtf(nlen)); - vec3_prod_val(sPaintingMesh[i].norm, n, nlen); + vec3_prod_val(paintingMesh[i].norm, n, nlen); } else { - vec3_zero(sPaintingMesh[i].norm); + vec3_zero(paintingMesh[i].norm); } } } @@ -291,8 +272,8 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD * If the textureMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole * painting. */ -Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *textureMap, Alpha alpha) { - struct PaintingMeshVertex *mesh = NULL; +Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *textureMap, Alpha alpha, struct PaintingMeshVertex *paintingMesh) { + struct PaintingMeshVertex *currVtx = NULL; PaintingData group; PaintingData groupIndex; PaintingData map; @@ -358,21 +339,21 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, meshVtx = textureMap[1 + mapping]; // Get a pointer to the current mesh. - mesh = &sPaintingMesh[meshVtx]; + currVtx = &paintingMesh[meshVtx]; // Texture coordinates. - tx = (PTX_OFFSET_S + (mesh->pos[0] * tWidthScale)); - ty = (PTX_OFFSET_T + ((y1 - mesh->pos[1]) * tHeightScale)); + tx = (PTX_OFFSET_S + (currVtx->pos[0] * tWidthScale)); + ty = (PTX_OFFSET_T + ((y1 - currVtx->pos[1]) * tHeightScale)); // Map the texture and place it in the verts array. make_vertex(verts, (groupIndex + map), - mesh->pos[0], - mesh->pos[1], - mesh->pos[2], + currVtx->pos[0], + currVtx->pos[1], + currVtx->pos[2], tx, ty, - mesh->norm[0], - mesh->norm[1], - mesh->norm[2], + currVtx->norm[0], + currVtx->norm[1], + currVtx->norm[2], alpha ); } @@ -395,20 +376,20 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, meshVtx = textureMap[1 + mapping]; // Get a pointer to the current mesh. - mesh = &sPaintingMesh[meshVtx]; + currVtx = &paintingMesh[meshVtx]; // Texture coordinates. - tx = (PTX_OFFSET_S + (mesh->pos[0] * tWidthScale)); - ty = (PTX_OFFSET_T + ((y1 - mesh->pos[1]) * tHeightScale)); + tx = (PTX_OFFSET_S + (currVtx->pos[0] * tWidthScale)); + ty = (PTX_OFFSET_T + ((y1 - currVtx->pos[1]) * tHeightScale)); make_vertex(verts, ((triGroups * VTX_PER_GRP) + map), - mesh->pos[0], - mesh->pos[1], - mesh->pos[2], + currVtx->pos[0], + currVtx->pos[1], + currVtx->pos[2], tx, ty, - mesh->norm[0], - mesh->norm[1], - mesh->norm[2], + currVtx->norm[0], + currVtx->norm[1], + currVtx->norm[2], alpha ); } @@ -491,7 +472,7 @@ void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { /** * Ripple a painting that has 1 or more images that need to be mapped. */ -Gfx *dl_painting_rippling(const struct Painting *painting) { +Gfx *dl_painting_rippling(const struct Painting *painting, struct PaintingMeshVertex *paintingMesh) { s16 i; const PaintingData *textureMap = NULL; s16 imageCount = painting->imageCount; @@ -536,7 +517,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { for (i = 0; i < imageCount; i++) { textureMap = segmented_to_virtual(textureMaps[i]); // Render a section of the painting. - gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, painting->alpha)); + gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, painting->alpha, paintingMesh)); } gSPPopMatrix(gfx++, G_MTX_MODELVIEW); @@ -553,23 +534,29 @@ Gfx *dl_painting_rippling(const struct Painting *painting) { */ Gfx *display_painting_rippling(struct Object *obj) { const struct Painting *painting = obj->oPaintingData; - const PaintingData *mesh = segmented_to_virtual(seg2_painting_triangle_mesh); + const PaintingData *meshData = segmented_to_virtual(seg2_painting_triangle_mesh); const PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); - PaintingData numVtx = mesh[0]; - PaintingData numTris = mesh[(numVtx * 3) + 1]; + PaintingData numVtx = meshData[0]; + PaintingData numTris = meshData[(numVtx * 3) + 1]; Gfx *dlist = NULL; + // When a painting is rippling, this mesh is generated each frame using the Painting's parameters. + // This mesh only contains the vertex positions and normals. + // Paintings use an additional array to map textures to the mesh. + struct PaintingMeshVertex *paintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); + // The painting's surface normals, used to approximate each of the vertex normals (for gouraud shading). + Vec3f *paintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); // Generate the mesh and its lighting data - painting_generate_mesh(obj, mesh, numVtx); - painting_calculate_triangle_normals(mesh, numVtx, numTris); - painting_average_vertex_normals(neighborTris, numVtx); + painting_generate_mesh(obj, meshData, numVtx, paintingMesh); + painting_calculate_triangle_normals(meshData, numVtx, numTris, paintingMesh, paintingTriNorms); + painting_average_vertex_normals(neighborTris, numVtx, paintingMesh, paintingTriNorms); // Map the painting's texture depending on the painting's texture type. - dlist = dl_painting_rippling(painting); + dlist = dl_painting_rippling(painting, paintingMesh); // The mesh data is freed every frame. - mem_pool_free(gEffectsMemoryPool, sPaintingMesh); - mem_pool_free(gEffectsMemoryPool, sPaintingTriNorms); + mem_pool_free(gEffectsMemoryPool, paintingMesh); + mem_pool_free(gEffectsMemoryPool, paintingTriNorms); return dlist; } From d63bb4d3fc09f99ee68ec11ce8f061535de50841 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 11 Dec 2022 20:02:00 -0500 Subject: [PATCH 42/81] skip s16 conversion for ripple magnitude --- src/game/paintings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 6b1b943b1b..ee52fd89ed 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -163,7 +163,7 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, Pa // Use a cosine wave to make the ripple go up and down, // scaled by the painting's ripple magnitude, // round it to an int and return it. - paintingMesh->pos[2] = roundf(rippleMag * coss((s16)((rippleRate * (rippleTimer - rippleDistance)) * 0x10000))); + paintingMesh->pos[2] = roundf(rippleMag * coss((u16)((rippleRate * (rippleTimer - rippleDistance)) * (f32)0x10000))); } } else { paintingMesh->pos[2] = 0; From f396d89b426fecb9a9735975539bcaa4b7eb0e65 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 11 Dec 2022 20:07:10 -0500 Subject: [PATCH 43/81] Rename 'oPaintingData' to 'oPaintingImageInfo' --- include/object_fields.h | 2 +- src/game/camera.c | 2 +- src/game/paintings.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index f0439d5067..498d6c9ba7 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1255,7 +1255,7 @@ #define /*0x100*/ oYoshiTargetYaw OBJECT_FIELD_S32(0x1E) /* Painting */ -#define /*0x0F4*/ oPaintingData OBJECT_FIELD_CVPTR(0x1B) +#define /*0x0F4*/ oPaintingImageInfo OBJECT_FIELD_CVPTR(0x1B) #define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_F32(0x1C) #define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_F32(0x1D) #define /*0x100*/ oPaintingRipplePosX OBJECT_FIELD_F32(0x1E) diff --git a/src/game/camera.c b/src/game/camera.c index 4036d0e425..9acd662dee 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9584,7 +9584,7 @@ void cutscene_enter_painting(struct Camera *c) { struct Object *ripplingPainting = gCutsceneFocus; if (ripplingPainting != NULL) { - const struct Painting *painting = ripplingPainting->oPaintingData; + const struct Painting *painting = ripplingPainting->oPaintingImageInfo; vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); diff --git a/src/game/paintings.c b/src/game/paintings.c index ee52fd89ed..58f3f2ad8e 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -118,7 +118,7 @@ static const struct RippleAnimationTypeInfo sRippleAnimations[] = { * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; PaintingData i, tri; @@ -533,7 +533,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting, struct PaintingMeshVe * The mesh and vertex normals are regenerated and freed every frame. */ Gfx *display_painting_rippling(struct Object *obj) { - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; const PaintingData *meshData = segmented_to_virtual(seg2_painting_triangle_mesh); const PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); PaintingData numVtx = meshData[0]; @@ -667,7 +667,7 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { * Render a normal painting. */ Gfx *display_painting_not_rippling(struct Object *obj) { - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -700,7 +700,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } // Get the const painting data. - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; if (painting == NULL) { return NULL; @@ -739,7 +739,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con * Updates a painting object's room from a point in front of the center of the painting. */ void painting_update_room(struct Object *obj) { - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; // The center of the painting, but with an offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { @@ -773,7 +773,7 @@ void bhv_painting_init(void) { const struct Painting *painting = segmented_to_virtual(sPaintings[id]); // Set the object's painting data pointer. - obj->oPaintingData = painting; + obj->oPaintingImageInfo = painting; // Clear flags. obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; @@ -809,7 +809,7 @@ void painting_update_mario_pos_and_flags(struct Object *obj) { vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); // Get the const painting data. - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; // Check if Mario is within the painting bounds laterally in local space. if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN @@ -883,7 +883,7 @@ void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimat * ripple's magnitude becomes small enough. */ void painting_update_ripple_state(struct Object *obj) { - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; if (objRippleInfo != NULL) { @@ -968,7 +968,7 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) * @param doResetTimer if TRUE, set the timer to 0 */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; const struct RippleAnimationTypeInfo *rippleAnim = painting_get_ripple_animation_type_info(painting); // Use a different set of variables depending on the state @@ -1009,7 +1009,7 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi void bhv_painting_loop(void) { struct Object *obj = o; - const struct Painting *painting = obj->oPaintingData; + const struct Painting *painting = obj->oPaintingImageInfo; // Update the painting info. painting_update_mario_pos_and_flags(obj); From 2d237715870531462e427c6a2f52fd3dca3d7f10 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 00:39:38 -0500 Subject: [PATCH 44/81] Painting UV cleanup --- src/game/paintings.c | 67 ++++++++++++++++++++++++-------------------- src/game/paintings.h | 2 +- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 58f3f2ad8e..37afec8c8f 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -261,10 +261,6 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD #define TRI_PER_GRP (VTX_BUF_MAX / 3) // 5 or 10 #define VTX_PER_GRP (TRI_PER_GRP * 3) // 15 or 30 -// Amount by which to shift the painting textures. -#define PTX_OFFSET_S 0 -#define PTX_OFFSET_T 4 - /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, * using 'textureMap'. @@ -309,16 +305,16 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); - // Width and height of the section. + // Width and height of each section. const f32 dx = (PAINTING_SIZE / 1); const f32 dy = (PAINTING_SIZE / imageCount); - // To scale the vertex positions into texture positions. + // These are used to scale the vertex positions into texture positions. const f32 tWidthScale = (TC(tWidth ) / dx); const f32 tHeightScale = (TC(tHeight) / dy); - // Starting Y position of the current section. - const s16 y1 = ((index + 1) * dy); + // Bottom Y position of the current section. + const s16 y2 = ((index + 1) * dy); // Draw the groups of TRI_PER_GRP first. for (group = 0; group < triGroups; group++) { @@ -342,8 +338,8 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, currVtx = &paintingMesh[meshVtx]; // Texture coordinates. - tx = (PTX_OFFSET_S + (currVtx->pos[0] * tWidthScale)); - ty = (PTX_OFFSET_T + ((y1 - currVtx->pos[1]) * tHeightScale)); + tx = (currVtx->pos[0] * tWidthScale); + ty = ((y2 - currVtx->pos[1]) * tHeightScale); // Map the texture and place it in the verts array. make_vertex(verts, (groupIndex + map), @@ -379,8 +375,8 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, currVtx = &paintingMesh[meshVtx]; // Texture coordinates. - tx = (PTX_OFFSET_S + (currVtx->pos[0] * tWidthScale)); - ty = (PTX_OFFSET_T + ((y1 - currVtx->pos[1]) * tHeightScale)); + tx = (currVtx->pos[0] * tWidthScale); + ty = ((y2 - currVtx->pos[1]) * tHeightScale); make_vertex(verts, ((triGroups * VTX_PER_GRP) + map), currVtx->pos[0], @@ -610,41 +606,50 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { s16 tWidth = painting->textureWidth; s16 tHeight = painting->textureHeight; + // Width and height of each section. const f32 dx = (PAINTING_SIZE / 1); const f32 dy = (PAINTING_SIZE / imageCount); - // Top left corner texture coordinates. - const s16 s1 = PTX_OFFSET_S; - const s16 t1 = PTX_OFFSET_T; - // Bottom right corner texture coordinates. - const s16 s2 = (s1 + TC(tWidth )); - const s16 t2 = (t1 + TC(tHeight)); + // These are used to scale the vertex positions into texture positions. + const f32 tWidthScale = (TC(tWidth ) / dx); + const f32 tHeightScale = (TC(tHeight) / dy); - s32 idx = 0; + s16 x1 = 0; // Left + s16 x2 = dx; // Right + s16 s1 = (x1 * tWidthScale); // Left + s16 s2 = (x2 * tWidthScale); // Right s16 y1, y2; + s16 t1, t2; + + s32 vertIndex = 0; + s32 i; // Generate vertices - for (s32 i = 0; i < imageCount; i++) { - y1 = (i * dy); - y2 = (y1 + dy); - make_vertex(verts, idx++, 0, y1, 0, s1, t2, n[0], n[1], n[2], alpha); // Bottom Left - make_vertex(verts, idx++, dx, y1, 0, s2, t2, n[0], n[1], n[2], alpha); // Bottom Right - make_vertex(verts, idx++, dx, y2, 0, s2, t1, n[0], n[1], n[2], alpha); // Top Right - make_vertex(verts, idx++, 0, y2, 0, s1, t1, n[0], n[1], n[2], alpha); // Top left + for (i = 0; i < imageCount; i++) { + y1 = (i * dy); // Top + y2 = (y1 + dy); // Bottom + t1 = ((y2 - y1) * tHeightScale); // Top + t2 = ((y2 - y2) * tHeightScale); // Bottom + make_vertex(verts, vertIndex++, 0, y1, 0, s1, t1, n[0], n[1], n[2], alpha); // Bottom Left + make_vertex(verts, vertIndex++, dx, y1, 0, s2, t1, n[0], n[1], n[2], alpha); // Bottom Right + make_vertex(verts, vertIndex++, dx, y2, 0, s2, t2, n[0], n[1], n[2], alpha); // Top Right + make_vertex(verts, vertIndex++, 0, y2, 0, s1, t2, n[0], n[1], n[2], alpha); // Top left } - gSPVertex(gfx++, verts, idx, 0); + gSPVertex(gfx++, verts, vertIndex, 0); painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); - for (s32 i = 0; i < imageCount; i++) { + s32 quadIndex; + + for (i = 0; i < imageCount; i++) { gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, textures[i]); gDPLoadSync(gfx++); gDPLoadBlock(gfx++, G_TX_LOADTILE, 0, 0, ((tWidth * tHeight) - 1), CALC_DXT(tWidth, G_IM_SIZ_16b_BYTES)); - s32 q = (i * 4); + quadIndex = (i * 4); gSP2Triangles(gfx++, - (q + 0), (q + 1), (q + 2), 0x0, - (q + 0), (q + 2), (q + 3), 0x0 + (quadIndex + 0), (quadIndex + 1), (quadIndex + 2), 0x0, + (quadIndex + 0), (quadIndex + 2), (quadIndex + 3), 0x0 ); } diff --git a/src/game/paintings.h b/src/game/paintings.h index 9c227180ac..70f3c14afa 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -9,7 +9,7 @@ /// The default painting side length. -#define PAINTING_SIZE 614.4f +#define PAINTING_SIZE 614.0f /// The depth of the area in front of the painting which triggers ripples without warping. #define PAINTING_WOBBLE_DEPTH 100 From e27ba775338517677c9ed2932c333425f3fa128d Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 00:42:56 -0500 Subject: [PATCH 45/81] Make PaintingState enum names clearer --- src/game/paintings.c | 32 ++++++++++++++++---------------- src/game/paintings.h | 6 +++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 37afec8c8f..3ef4ce982f 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -36,12 +36,12 @@ * Painting structs, texture pointers, non-ripple display lists. * * Painting state machine: - * Paintings spawn in the PAINTING_IDLE state - * From IDLE, paintings can change to PAINTING_RIPPLE or PAINTING_ENTERED + * Paintings spawn in the PAINTING_STATE_IDLE state + * From IDLE, paintings can change to PAINTING_STATE_RIPPLING or PAINTING_STATE_ENTERED * - This state checks for ENTERED because if Mario waits long enough, a PROXIMITY painting could * reset to IDLE * - * Paintings in the PAINTING_RIPPLE state are passively rippling. + * Paintings in the PAINTING_STATE_RIPPLING state are passively rippling. * For RIPPLE_TRIGGER_PROXIMITY paintings, this means Mario bumped the front of the painting. * * Paintings that use RIPPLE_TRIGGER_CONTINUOUS try to transition to this state as soon as possible, @@ -49,7 +49,7 @@ * * A PROXIMITY painting will automatically reset to IDLE if its ripple magnitude becomes small enough. * - * Paintings in the PAINTING_ENTERED state have been entered by Mario. + * Paintings in the PAINTING_STATE_ENTERED state have been entered by Mario. * A CONTINUOUS painting will automatically reset to RIPPLE if its ripple magnitude becomes small enough. */ @@ -727,7 +727,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con SET_GRAPH_NODE_LAYER(node->flags, LAYER_TRANSPARENT); } - if (obj->oPaintingState == PAINTING_IDLE) { + if (obj->oPaintingState == PAINTING_STATE_IDLE) { paintingDlist = display_painting_not_rippling(obj); } else { paintingDlist = display_painting_rippling(obj); @@ -905,16 +905,16 @@ void painting_update_ripple_state(struct Object *obj) { if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // If the painting is barely rippling, make it stop rippling. if (obj->oPaintingCurrRippleMag <= 1.0f) { - obj->oPaintingState = PAINTING_IDLE; + obj->oPaintingState = PAINTING_STATE_IDLE; } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { const struct RippleAnimationTypeInfo *rippleAnim = painting_get_ripple_animation_type_info(painting); // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. - if ((obj->oPaintingState == PAINTING_ENTERED) + if ((obj->oPaintingState == PAINTING_STATE_ENTERED) && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { - obj->oPaintingState = PAINTING_RIPPLE; + obj->oPaintingState = PAINTING_STATE_RIPPLING; painting_set_ripple_animation(obj, &rippleAnim->passive); } } @@ -978,11 +978,11 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi // Use a different set of variables depending on the state switch (state) { - case PAINTING_RIPPLE: + case PAINTING_STATE_RIPPLING: painting_set_ripple_animation(obj, &rippleAnim->passive); break; - case PAINTING_ENTERED: + case PAINTING_STATE_ENTERED: painting_set_ripple_animation(obj, &rippleAnim->entry); break; } @@ -1032,16 +1032,16 @@ void bhv_painting_loop(void) { if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // Proximity type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_ENTERED, FALSE, TRUE ); // Entering - } else if (obj->oPaintingState != PAINTING_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - painting_state(obj, PAINTING_RIPPLE, FALSE, TRUE ); // Wobbling + painting_state(obj, PAINTING_STATE_ENTERED, FALSE, TRUE ); // Entering + } else if (obj->oPaintingState != PAINTING_STATE_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { + painting_state(obj, PAINTING_STATE_RIPPLING, FALSE, TRUE ); // Wobbling } } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_ENTERED, FALSE, FALSE); // Entering - } else if (obj->oPaintingState == PAINTING_IDLE) { - painting_state(obj, PAINTING_RIPPLE, TRUE, TRUE ); // Idle + painting_state(obj, PAINTING_STATE_ENTERED, FALSE, FALSE); // Entering + } else if (obj->oPaintingState == PAINTING_STATE_IDLE) { + painting_state(obj, PAINTING_STATE_RIPPLING, TRUE, TRUE ); // Idle } } } diff --git a/src/game/paintings.h b/src/game/paintings.h index 70f3c14afa..582bdb2b9a 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -83,9 +83,9 @@ enum PaintingRippleFlags { // oPaintingState enum PaintingState { - PAINTING_IDLE, - PAINTING_RIPPLE, - PAINTING_ENTERED, + PAINTING_STATE_IDLE, + PAINTING_STATE_RIPPLING, + PAINTING_STATE_ENTERED, }; From 66828dab80b3e3e9bc3fd8d0bb2b89a7c0bc22d0 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 14:56:12 -0500 Subject: [PATCH 46/81] Rename some structs --- include/object_fields.h | 2 +- levels/castle_inside/header.h | 30 +++--- levels/castle_inside/painting.inc.c | 30 +++--- levels/hmc/areas/1/painting.inc.c | 2 +- levels/hmc/header.h | 2 +- levels/ttm/areas/1/painting.inc.c | 2 +- levels/ttm/header.h | 2 +- src/game/camera.c | 4 +- src/game/paintings.c | 144 ++++++++++++++-------------- src/game/paintings.h | 14 +-- 10 files changed, 116 insertions(+), 116 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 498d6c9ba7..4cf18afe77 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1255,7 +1255,7 @@ #define /*0x100*/ oYoshiTargetYaw OBJECT_FIELD_S32(0x1E) /* Painting */ -#define /*0x0F4*/ oPaintingImageInfo OBJECT_FIELD_CVPTR(0x1B) +#define /*0x0F4*/ oPaintingImage OBJECT_FIELD_CVPTR(0x1B) #define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_F32(0x1C) #define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_F32(0x1D) #define /*0x100*/ oPaintingRipplePosX OBJECT_FIELD_F32(0x1E) diff --git a/levels/castle_inside/header.h b/levels/castle_inside/header.h index f476bcbf38..c91e689157 100644 --- a/levels/castle_inside/header.h +++ b/levels/castle_inside/header.h @@ -57,21 +57,21 @@ extern const GeoLayout castle_geo_001C10[]; // leveldata extern const Gfx inside_castle_seg7_dl_ccm_fake_painting_1[]; extern const Gfx inside_castle_seg7_dl_ccm_fake_painting_2[]; -extern struct Painting bob_painting; -extern struct Painting ccm_painting; -extern struct Painting wf_painting; -extern struct Painting jrb_painting; -extern struct Painting lll_painting; -extern struct Painting ssl_painting; -extern struct Painting hmc_painting; -extern struct Painting ddd_painting; -extern struct Painting wdw_painting; -extern struct Painting thi_tiny_painting; -extern struct Painting ttm_painting; -extern struct Painting ttc_painting; -extern struct Painting sl_painting; -extern struct Painting thi_huge_painting; -extern struct Painting rr_painting; +extern struct PaintingImage bob_painting; +extern struct PaintingImage ccm_painting; +extern struct PaintingImage wf_painting; +extern struct PaintingImage jrb_painting; +extern struct PaintingImage lll_painting; +extern struct PaintingImage ssl_painting; +extern struct PaintingImage hmc_painting; +extern struct PaintingImage ddd_painting; +extern struct PaintingImage wdw_painting; +extern struct PaintingImage thi_tiny_painting; +extern struct PaintingImage ttm_painting; +extern struct PaintingImage ttc_painting; +extern struct PaintingImage sl_painting; +extern struct PaintingImage thi_huge_painting; +extern struct PaintingImage rr_painting; extern const Gfx inside_castle_seg7_dl_bowser_1_painting[]; extern const Gfx inside_castle_seg7_dl_07028FD0[]; extern const Gfx inside_castle_seg7_dl_07029578[]; diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index b1dc142f44..f922e8e8d2 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -109,7 +109,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_bob[] }; // 0x07023620 - 0x07023698 -const struct Painting bob_painting = { +const struct PaintingImage bob_painting = { /* Textures */ inside_castle_seg7_painting_textures_bob, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_bob), /* Texture w, h */ 64, 32, @@ -128,7 +128,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] }; // 0x07023698 - 0x07023710 -const struct Painting ccm_painting = { +const struct PaintingImage ccm_painting = { /* Textures */ inside_castle_seg7_painting_textures_ccm, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ccm), /* Texture w, h */ 64, 32, @@ -147,7 +147,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = }; // 0x07023710 - 0x07023788 -const struct Painting wf_painting = { +const struct PaintingImage wf_painting = { /* Textures */ inside_castle_seg7_painting_textures_wf, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wf), /* Texture w, h */ 64, 32, @@ -166,7 +166,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] }; // 0x07023788 - 0x07023800 -const struct Painting jrb_painting = { +const struct PaintingImage jrb_painting = { /* Textures */ inside_castle_seg7_painting_textures_jrb, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_jrb), /* Texture w, h */ 64, 32, @@ -185,7 +185,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] }; // 0x07023800 - 0x07023878 -const struct Painting lll_painting = { +const struct PaintingImage lll_painting = { /* Textures */ inside_castle_seg7_painting_textures_lll, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_lll), /* Texture w, h */ 64, 32, @@ -204,7 +204,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] }; // 0x07023878 - 0x070238F0 -const struct Painting ssl_painting = { +const struct PaintingImage ssl_painting = { /* Textures */ inside_castle_seg7_painting_textures_ssl, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ssl), /* Texture w, h */ 64, 32, @@ -222,7 +222,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_hmc_en }; // 0x070238F0 - 0x07023968 -const struct Painting hmc_painting = { +const struct PaintingImage hmc_painting = { /* Textures */ inside_castle_seg7_painting_textures_hmc_env, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_hmc_env), /* Texture w, h */ 32, 32, @@ -240,7 +240,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ddd_en }; // 0x07023968 - 0x070239E0 -const struct Painting ddd_painting = { +const struct PaintingImage ddd_painting = { /* Textures */ inside_castle_seg7_painting_textures_ddd_env, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ddd_env), /* Texture w, h */ 32, 32, @@ -259,7 +259,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] }; // 0x070239E0 - 0x07023A58 -const struct Painting wdw_painting = { +const struct PaintingImage wdw_painting = { /* Textures */ inside_castle_seg7_painting_textures_wdw, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wdw), /* Texture w, h */ 64, 32, @@ -278,7 +278,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] }; // 0x07023A58 - 0x07023AD0 -const struct Painting thi_tiny_painting = { +const struct PaintingImage thi_tiny_painting = { /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), /* Texture w, h */ 64, 32, @@ -292,7 +292,7 @@ const struct Painting thi_tiny_painting = { /// - PAINTING_ID_CASTLE_THI_HUGE - // 0x07023C38 - 0x07023CB0 -const struct Painting thi_huge_painting = { +const struct PaintingImage thi_huge_painting = { /* Textures */ inside_castle_seg7_painting_textures_thi, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), /* Texture w, h */ 64, 32, @@ -311,7 +311,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] }; // 0x07023AD0 - 0x07023B48 -const struct Painting ttm_painting = { +const struct PaintingImage ttm_painting = { /* Textures */ inside_castle_seg7_painting_textures_ttm, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttm), /* Texture w, h */ 64, 32, @@ -330,7 +330,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] }; // 0x07023B48 - 0x07023BC0 -const struct Painting ttc_painting = { +const struct PaintingImage ttc_painting = { /* Textures */ inside_castle_seg7_painting_textures_ttc, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttc), /* Texture w, h */ 64, 32, @@ -349,7 +349,7 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = }; // 0x07023BC0 - 0x07023C38 -const struct Painting sl_painting = { +const struct PaintingImage sl_painting = { /* Textures */ inside_castle_seg7_painting_textures_sl, /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_sl), /* Texture w, h */ 64, 32, @@ -362,7 +362,7 @@ const struct Painting sl_painting = { /// - PAINTING_ID_CASTLE_RR - -const struct Painting rr_painting = { +const struct PaintingImage rr_painting = { /* Textures */ NULL, /* Texture Count */ 0, /* Texture w, h */ 0, 0, diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 321e81b6aa..91a4071d18 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -13,7 +13,7 @@ const Texture *const hmc_seg7_painting_textures_cotmc[] = { }; // 0x0702551C (PaintingData) -const struct Painting cotmc_painting = { +const struct PaintingImage cotmc_painting = { /* Textures */ hmc_seg7_painting_textures_cotmc, /* Texture Count */ ARRAY_COUNT(hmc_seg7_painting_textures_cotmc), /* Texture w, h */ 32, 32, diff --git a/levels/hmc/header.h b/levels/hmc/header.h index 9ff10e5f39..124f66fa75 100644 --- a/levels/hmc/header.h +++ b/levels/hmc/header.h @@ -75,7 +75,7 @@ extern const Gfx hmc_seg7_dl_07024110[]; extern const Gfx hmc_seg7_dl_07024268[]; extern const Gfx hmc_seg7_dl_070242A0[]; extern const Texture *const hmc_seg7_painting_textures_07025518[]; -extern struct Painting cotmc_painting; +extern struct PaintingImage cotmc_painting; extern const Collision hmc_seg7_collision_level[]; extern const MacroObject hmc_seg7_macro_objs[]; extern const RoomData hmc_seg7_rooms[]; diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index 2b5da222af..cd6afcfa5d 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -9,7 +9,7 @@ ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { }; // 0x07012F00 (PaintingData) -const struct Painting ttm_slide_painting = { +const struct PaintingImage ttm_slide_painting = { /* Textures */ ttm_seg7_painting_textures_slide, /* Texture Count */ ARRAY_COUNT(ttm_seg7_painting_textures_slide), /* Texture w, h */ 64, 32, diff --git a/levels/ttm/header.h b/levels/ttm/header.h index 3c06052631..2866088e7f 100644 --- a/levels/ttm/header.h +++ b/levels/ttm/header.h @@ -71,7 +71,7 @@ extern const Gfx ttm_seg7_dl_07012388[]; extern const Gfx ttm_seg7_dl_070123A0[]; extern const Gfx ttm_seg7_dl_070123B8[]; extern const Gfx ttm_seg7_dl_07012410[]; -extern struct Painting ttm_slide_painting; +extern struct PaintingImage ttm_slide_painting; extern const Gfx ttm_seg7_dl_07013430[]; extern const Gfx ttm_seg7_dl_07013608[]; extern const Collision ttm_seg7_collision_pitoune_2[]; diff --git a/src/game/camera.c b/src/game/camera.c index 9acd662dee..b02447a144 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9584,11 +9584,11 @@ void cutscene_enter_painting(struct Camera *c) { struct Object *ripplingPainting = gCutsceneFocus; if (ripplingPainting != NULL) { - const struct Painting *painting = ripplingPainting->oPaintingImageInfo; + const struct PaintingImage *paintingImage = ripplingPainting->oPaintingImage; vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); - size = ((painting->sizeX + painting->sizeY) / 2.0f); + size = ((paintingImage->sizeX + paintingImage->sizeY) / 2.0f); focusOffset[0] = (size * 0.5f); focusOffset[1] = focusOffset[0]; focusOffset[2] = 0; diff --git a/src/game/paintings.c b/src/game/paintings.c index 3ef4ce982f..e6a5b43719 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -33,7 +33,7 @@ * seg2_painting_mesh_neighbor_tris: The lighting for the ripple is also generated from a base table. * Each painting's texture uses yet another table to map its texture to the mesh. * In levels/[LEVEL]/painting.inc.c: - * Painting structs, texture pointers, non-ripple display lists. + * PaintingImage structs, texture pointers. * * Painting state machine: * Paintings spawn in the PAINTING_STATE_IDLE state @@ -56,7 +56,7 @@ /** * Array of pointers to painting data structs. */ -const struct Painting *sPaintings[] = { +const struct PaintingImage *sPaintings[] = { /* Painting ID */ /* PAINTING_ID_NULL */ NULL, /* PAINTING_ID_CASTLE_BOB */ &bob_painting, @@ -81,7 +81,7 @@ const struct Painting *sPaintings[] = { /** * A list of preset constants for the ripple animations. */ -static const struct RippleAnimationTypeInfo sRippleAnimations[] = { +const struct RippleAnimationPair sRippleAnimations[] = { { // RIPPLE_ANIM_CONTINUOUS .passive = { .mag = 10.0f, .decay = 1.0f, .rate = 0.05f, .dispersion = 15.0f }, .entry = { .mag = 30.0f, .decay = 0.98f, .rate = 0.05f, .dispersion = 15.0f } @@ -118,8 +118,8 @@ static const struct RippleAnimationTypeInfo sRippleAnimations[] = { * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. */ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { - const struct Painting *painting = obj->oPaintingImageInfo; - const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; + const struct RippleAnimation *objRippleInfo = obj->oPaintingRippleInfo; PaintingData i, tri; /// Controls the peaks of the ripple. @@ -135,8 +135,8 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, Pa f32 rippleX = obj->oPaintingRipplePosX; f32 rippleY = obj->oPaintingRipplePosY; - f32 sizeRatioX = (painting->sizeX / PAINTING_SIZE); - f32 sizeRatioY = (painting->sizeY / PAINTING_SIZE); + f32 sizeRatioX = (paintingImage->sizeX / PAINTING_SIZE); + f32 sizeRatioY = (paintingImage->sizeY / PAINTING_SIZE); f32 dx, dy; f32 rippleDistance; @@ -414,7 +414,7 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, /** * Orient the painting mesh for rendering. */ -Gfx *painting_model_view_transform(const struct Painting *painting) { +Gfx *painting_model_view_transform(const struct PaintingImage *paintingImage) { u32 gfxCmds = ( /*gSPMatrix */ 1 + /*gSPEndDisplayList */ 1 @@ -426,8 +426,8 @@ Gfx *painting_model_view_transform(const struct Painting *painting) { Mtx *scale = alloc_display_list(sizeof(Mtx)); guScale( scale, - (painting->sizeX / PAINTING_SIZE), - (painting->sizeY / PAINTING_SIZE), + (paintingImage->sizeX / PAINTING_SIZE), + (paintingImage->sizeY / PAINTING_SIZE), 1.0f ); gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); @@ -468,14 +468,14 @@ void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { /** * Ripple a painting that has 1 or more images that need to be mapped. */ -Gfx *dl_painting_rippling(const struct Painting *painting, struct PaintingMeshVertex *paintingMesh) { +Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct PaintingMeshVertex *paintingMesh) { s16 i; const PaintingData *textureMap = NULL; - s16 imageCount = painting->imageCount; - s16 tWidth = painting->textureWidth; - s16 tHeight = painting->textureHeight; - const Texture **tArray = segmented_to_virtual(painting->textureArray); - s32 isEnvMap = (painting->textureType == PAINTING_TYPE_ENV_MAP); + s16 imageCount = paintingImage->imageCount; + s16 tWidth = paintingImage->textureWidth; + s16 tHeight = paintingImage->textureHeight; + const Texture **tArray = segmented_to_virtual(paintingImage->textureArray); + s32 isEnvMap = (paintingImage->textureType == PAINTING_TYPE_ENV_MAP); u32 gfxCmds = ( /*gSPDisplayList */ 1 + @@ -496,7 +496,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting, struct PaintingMeshVe return dlist; } - gSPDisplayList(gfx++, painting_model_view_transform(painting)); + gSPDisplayList(gfx++, painting_model_view_transform(paintingImage)); Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); @@ -513,7 +513,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting, struct PaintingMeshVe for (i = 0; i < imageCount; i++) { textureMap = segmented_to_virtual(textureMaps[i]); // Render a section of the painting. - gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, painting->alpha, paintingMesh)); + gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, paintingImage->alpha, paintingMesh)); } gSPPopMatrix(gfx++, G_MTX_MODELVIEW); @@ -529,7 +529,7 @@ Gfx *dl_painting_rippling(const struct Painting *painting, struct PaintingMeshVe * The mesh and vertex normals are regenerated and freed every frame. */ Gfx *display_painting_rippling(struct Object *obj) { - const struct Painting *painting = obj->oPaintingImageInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; const PaintingData *meshData = segmented_to_virtual(seg2_painting_triangle_mesh); const PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); PaintingData numVtx = meshData[0]; @@ -548,7 +548,7 @@ Gfx *display_painting_rippling(struct Object *obj) { painting_average_vertex_normals(neighborTris, numVtx, paintingMesh, paintingTriNorms); // Map the painting's texture depending on the painting's texture type. - dlist = dl_painting_rippling(painting, paintingMesh); + dlist = dl_painting_rippling(paintingImage, paintingMesh); // The mesh data is freed every frame. mem_pool_free(gEffectsMemoryPool, paintingMesh); @@ -557,10 +557,10 @@ Gfx *display_painting_rippling(struct Object *obj) { return dlist; } -Gfx *dl_painting_not_rippling(const struct Painting *painting) { - Alpha alpha = painting->alpha; - s16 imageCount = painting->imageCount; - s32 shaded = painting->shaded; +Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { + Alpha alpha = paintingImage->alpha; + s16 imageCount = paintingImage->imageCount; + s32 shaded = paintingImage->shaded; u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPVertex */ 1 + @@ -588,9 +588,9 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { Vtx *verts = alloc_display_list((imageCount * 4) * sizeof(*verts)); Vec3c n; - const Texture **textures = segmented_to_virtual(painting->textureArray); + const Texture **textures = segmented_to_virtual(paintingImage->textureArray); - s32 isEnvMap = (painting->textureType == PAINTING_TYPE_ENV_MAP); + s32 isEnvMap = (paintingImage->textureType == PAINTING_TYPE_ENV_MAP); if (isEnvMap) { vec3_set(n, 0x00, 0x00, 0x7f); @@ -603,8 +603,8 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { gSPDisplayList(gfx++, dl_paintings_textured_vertex_colored_begin); } - s16 tWidth = painting->textureWidth; - s16 tHeight = painting->textureHeight; + s16 tWidth = paintingImage->textureWidth; + s16 tHeight = paintingImage->textureHeight; // Width and height of each section. const f32 dx = (PAINTING_SIZE / 1); @@ -672,7 +672,7 @@ Gfx *dl_painting_not_rippling(const struct Painting *painting) { * Render a normal painting. */ Gfx *display_painting_not_rippling(struct Object *obj) { - const struct Painting *painting = obj->oPaintingImageInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; u32 gfxCmds = ( /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + @@ -686,8 +686,8 @@ Gfx *display_painting_not_rippling(struct Object *obj) { return dlist; } - gSPDisplayList(gfx++, painting_model_view_transform(painting)); - gSPDisplayList(gfx++, dl_painting_not_rippling(painting)); + gSPDisplayList(gfx++, painting_model_view_transform(paintingImage)); + gSPDisplayList(gfx++, dl_painting_not_rippling(paintingImage)); gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); @@ -705,9 +705,9 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } // Get the const painting data. - const struct Painting *painting = obj->oPaintingImageInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; - if (painting == NULL) { + if (paintingImage == NULL) { return NULL; } @@ -715,13 +715,13 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con if (callContext == GEO_CONTEXT_RENDER) { // Draw the painting. - if (painting->imageCount > 0 - && painting->textureArray != NULL - && painting->textureWidth > 0 - && painting->textureHeight > 0 - && painting->alpha > 0x00) { + if (paintingImage->imageCount > 0 + && paintingImage->textureArray != NULL + && paintingImage->textureWidth > 0 + && paintingImage->textureHeight > 0 + && paintingImage->alpha > 0x00) { // Determine whether the painting is opaque or transparent. - if (painting->alpha == 0xFF) { + if (paintingImage->alpha == 0xFF) { SET_GRAPH_NODE_LAYER(node->flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); } else { SET_GRAPH_NODE_LAYER(node->flags, LAYER_TRANSPARENT); @@ -744,12 +744,12 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con * Updates a painting object's room from a point in front of the center of the painting. */ void painting_update_room(struct Object *obj) { - const struct Painting *painting = obj->oPaintingImageInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; // The center of the painting, but with an offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { - (painting->sizeX * 0.5f), - (painting->sizeY * 0.5f), + (paintingImage->sizeX * 0.5f), + (paintingImage->sizeY * 0.5f), PAINTING_WOBBLE_DEPTH // Distance in front of the painting to check for a room floor. }; @@ -775,10 +775,10 @@ void bhv_painting_init(void) { // Get the painting id from the first byte of the behavior params. The second byte is used for the warp node ID. s32 id = GET_BPARAM1(obj->oBehParams); - const struct Painting *painting = segmented_to_virtual(sPaintings[id]); + const struct PaintingImage *paintingImage = segmented_to_virtual(sPaintings[id]); // Set the object's painting data pointer. - obj->oPaintingImageInfo = painting; + obj->oPaintingImage = paintingImage; // Clear flags. obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; @@ -813,14 +813,14 @@ void painting_update_mario_pos_and_flags(struct Object *obj) { // Get Mario's position in the painting's local space. vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); - // Get the const painting data. - const struct Painting *painting = obj->oPaintingImageInfo; + // Get the const painting image data. + const struct PaintingImage *paintingImage = obj->oPaintingImage; // Check if Mario is within the painting bounds laterally in local space. if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN - && marioLocalPos[0] < (painting->sizeX + PAINTING_EDGE_MARGIN) + && marioLocalPos[0] < (paintingImage->sizeX + PAINTING_EDGE_MARGIN) && marioLocalPos[1] > -PAINTING_EDGE_MARGIN - && marioLocalPos[1] < (painting->sizeY + PAINTING_EDGE_MARGIN)) { + && marioLocalPos[1] < (paintingImage->sizeY + PAINTING_EDGE_MARGIN)) { // Check whether Mario is inside the wobble zone. if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH && marioLocalPos[2] > 0.0f) { @@ -832,7 +832,7 @@ void painting_update_mario_pos_and_flags(struct Object *obj) { rippleFlags |= RIPPLE_FLAG_ENTER; } } - + obj->oPaintingLocalMarioPosX = marioLocalPos[0]; obj->oPaintingLocalMarioPosY = marioLocalPos[1]; @@ -844,7 +844,7 @@ void painting_update_mario_pos_and_flags(struct Object *obj) { // changedFlags is true if currFlags is true and lastFlags is false // (Mario just entered the floor on this frame). obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); - + // Detect whether Mario is entering this painting, and set paintingObj accordingly if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { // Mario has entered the painting. @@ -856,16 +856,16 @@ void painting_update_mario_pos_and_flags(struct Object *obj) { } /** - * Returns a pointer to the RippleAnimationTypeInfo that best fits the painting type. + * Returns a pointer to the RippleAnimationPair that best fits the painting type. */ -const struct RippleAnimationTypeInfo *painting_get_ripple_animation_type_info(const struct Painting *painting) { +const struct RippleAnimationPair *painting_get_ripple_animation_type_info(const struct PaintingImage *paintingImage) { s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY; - if (painting->sizeX >= (PAINTING_SIZE * 2) - || painting->sizeY >= (PAINTING_SIZE * 2)) { + if (paintingImage->sizeX >= (PAINTING_SIZE * 2) + || paintingImage->sizeY >= (PAINTING_SIZE * 2)) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; } } @@ -876,7 +876,7 @@ const struct RippleAnimationTypeInfo *painting_get_ripple_animation_type_info(co /** * Set a painting's ripple animation and magnitude. */ -void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimationInfo *baseRippleInfo) { +void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimation *baseRippleInfo) { obj->oPaintingCurrRippleMag = baseRippleInfo->mag; obj->oPaintingRippleInfo = baseRippleInfo; } @@ -888,8 +888,8 @@ void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimat * ripple's magnitude becomes small enough. */ void painting_update_ripple_state(struct Object *obj) { - const struct Painting *painting = obj->oPaintingImageInfo; - const struct RippleAnimationInfo *objRippleInfo = obj->oPaintingRippleInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; + const struct RippleAnimation *objRippleInfo = obj->oPaintingRippleInfo; if (objRippleInfo != NULL) { obj->oPaintingCurrRippleMag *= objRippleInfo->decay; @@ -902,13 +902,13 @@ void painting_update_ripple_state(struct Object *obj) { obj->oPaintingRippleTimer++; - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // If the painting is barely rippling, make it stop rippling. if (obj->oPaintingCurrRippleMag <= 1.0f) { obj->oPaintingState = PAINTING_STATE_IDLE; } - } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - const struct RippleAnimationTypeInfo *rippleAnim = painting_get_ripple_animation_type_info(painting); + } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. @@ -973,8 +973,8 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) * @param doResetTimer if TRUE, set the timer to 0 */ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { - const struct Painting *painting = obj->oPaintingImageInfo; - const struct RippleAnimationTypeInfo *rippleAnim = painting_get_ripple_animation_type_info(painting); + const struct PaintingImage *paintingImage = obj->oPaintingImage; + const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); // Use a different set of variables depending on the state switch (state) { @@ -991,8 +991,8 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi // Set the ripple position. if (centerRipples) { - obj->oPaintingRipplePosX = (painting->sizeX * 0.5f); - obj->oPaintingRipplePosY = (painting->sizeY * 0.5f); + obj->oPaintingRipplePosX = (paintingImage->sizeX * 0.5f); + obj->oPaintingRipplePosY = (paintingImage->sizeY * 0.5f); } else { obj->oPaintingRipplePosX = obj->oPaintingLocalMarioPosX; obj->oPaintingRipplePosY = obj->oPaintingLocalMarioPosY; @@ -1014,7 +1014,7 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi void bhv_painting_loop(void) { struct Object *obj = o; - const struct Painting *painting = obj->oPaintingImageInfo; + const struct PaintingImage *paintingImage = obj->oPaintingImage; // Update the painting info. painting_update_mario_pos_and_flags(obj); @@ -1029,19 +1029,19 @@ void bhv_painting_loop(void) { } #endif // (ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS || UNLOCK_ALL) - if (painting->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { + if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // Proximity type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_STATE_ENTERED, FALSE, TRUE ); // Entering + painting_state(obj, PAINTING_STATE_ENTERED, FALSE, TRUE ); // Entering } else if (obj->oPaintingState != PAINTING_STATE_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - painting_state(obj, PAINTING_STATE_RIPPLING, FALSE, TRUE ); // Wobbling + painting_state(obj, PAINTING_STATE_RIPPLING, FALSE, TRUE ); // Wobbling } - } else if (painting->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { + } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_STATE_ENTERED, FALSE, FALSE); // Entering + painting_state(obj, PAINTING_STATE_ENTERED, FALSE, FALSE); // Entering } else if (obj->oPaintingState == PAINTING_STATE_IDLE) { - painting_state(obj, PAINTING_STATE_RIPPLING, TRUE, TRUE ); // Idle + painting_state(obj, PAINTING_STATE_RIPPLING, TRUE, TRUE ); // Idle } } } diff --git a/src/game/paintings.h b/src/game/paintings.h index 582bdb2b9a..8622f391bd 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -92,8 +92,8 @@ enum PaintingState { /** * A list of preset constants for the ripple animations. */ -struct RippleAnimationInfo { - /*0x00*/ const f32 mag; /// Controls how high the peaks of the ripple are. +struct RippleAnimation { + /*0x00*/ const f32 mag; /// Controls how high the peaks of the ripple are when the animation starts. /*0x04*/ const f32 decay; /// Multiplier that controls how fast the ripple regresses to the IDLE state. /*0x08*/ const f32 rate; /// Controls the ripple's frequency. /*0x0C*/ const f32 dispersion; /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple. @@ -102,15 +102,15 @@ struct RippleAnimationInfo { /** * A ripple animation pair. */ -struct RippleAnimationTypeInfo { - /*0x00*/ const struct RippleAnimationInfo passive; - /*0x10*/ const struct RippleAnimationInfo entry; +struct RippleAnimationPair { + /*0x00*/ const struct RippleAnimation passive; /// The ripple when the painting is continuously rippling or is lightly touched. + /*0x10*/ const struct RippleAnimation entry; /// The ripple when the painting is entered. }; /*0x20*/ /** * Painting info struct. */ -struct Painting { +struct PaintingImage { /// Texture data. /*0x00*/ const Texture *const *textureArray; @@ -135,7 +135,7 @@ struct Painting { /*0x0F*/ Alpha alpha; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. - /// By default a painting is 614.0f x 614.0f + /// By default a painting is 614.0f x 614.0f (PAINTING_SIZE). /*0x10*/ f32 sizeX; /*0x14*/ f32 sizeY; }; /*0x18*/ From 1d2c50eda84bbafb64ba438caac7d39ea8647e0f Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 15:23:36 -0500 Subject: [PATCH 47/81] Remove unused gsSPLightColor commands in dl_paintings_env_mapped_begin --- bin/segment2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 48f22b5e15..d53fd652b0 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2894,8 +2894,6 @@ const Gfx dl_paintings_env_mapped_begin[] = { gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), gsSPLightColor(LIGHT_1, 0xffffffff), gsSPLightColor(LIGHT_2, 0x505050ff), -// gsSPLightColor(LIGHT_1, 0x6464ffff), -// gsSPLightColor(LIGHT_2, 0x404080ff), gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_ON), gsDPTileSync(), gsSPEndDisplayList(), From ec318df0a628af985a7a578edf048ae012077d30 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 15:36:20 -0500 Subject: [PATCH 48/81] Fix some comments in paintings.h --- src/game/paintings.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/game/paintings.h b/src/game/paintings.h index 8622f391bd..b8e82a40b0 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -8,7 +8,7 @@ #include "types.h" -/// The default painting side length. +/// The default painting edge length. #define PAINTING_SIZE 614.0f /// The depth of the area in front of the painting which triggers ripples without warping. @@ -64,7 +64,7 @@ enum RippleTriggers { RIPPLE_TRIGGER_CONTINUOUS, }; -// Painting->rippleAnimationType +// Types of ripple animations. enum PaintingRippleAnimations { RIPPLE_ANIM_CONTINUOUS, RIPPLE_ANIM_PROXIMITY, @@ -75,10 +75,10 @@ enum PaintingRippleAnimations { enum PaintingRippleFlags { // Not rippling. RIPPLE_FLAGS_NONE = 0x0, - // Triggers an entry ripple. - RIPPLE_FLAG_ENTER = BIT(0), // 0x01 // Triggers a passive ripple. - RIPPLE_FLAG_RIPPLE = BIT(1), // 0x02 + RIPPLE_FLAG_RIPPLE = BIT(0), // 0x01 + // Triggers an entry ripple. + RIPPLE_FLAG_ENTER = BIT(1), // 0x02 }; // oPaintingState @@ -121,7 +121,6 @@ struct PaintingImage { /*0x08*/ s16 textureWidth; /*0x0A*/ s16 textureHeight; - /// Either PAINTING_TYPE_IMAGE or PAINTING_TYPE_ENV_MAP. /*0x0C*/ s8 textureType; @@ -134,7 +133,6 @@ struct PaintingImage { /// The painting's transparency (0..255). Determines the drawing layer of the painting. /*0x0F*/ Alpha alpha; - /// Uniformly scales the painting to a multiple of PAINTING_SIZE. /// By default a painting is 614.0f x 614.0f (PAINTING_SIZE). /*0x10*/ f32 sizeX; /*0x14*/ f32 sizeY; From d19ec643109716603b9ec4e832f4a9238d28a380 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 15:50:09 -0500 Subject: [PATCH 49/81] use oAction instead of oPaintingState --- include/object_fields.h | 3 +-- include/types.h | 2 +- src/game/paintings.c | 53 ++++++++++++++++++----------------------- src/game/paintings.h | 10 ++++---- 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 4cf18afe77..be75a29ad2 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1262,8 +1262,7 @@ #define /*0x104*/ oPaintingRipplePosY OBJECT_FIELD_F32(0x1F) #define /*0x108*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x20, 0) #define /*0x10A*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x20, 1) -#define /*0x10C*/ oPaintingState OBJECT_FIELD_S32(0x21) -#define /*0x110*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x22) +#define /*0x10C*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x21) #define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) #define /*0x1A8*/ oPaintingRippleInfo OBJECT_FIELD_CVPTR(0x48) diff --git a/include/types.h b/include/types.h index 4397aac839..bbb4970583 100644 --- a/include/types.h +++ b/include/types.h @@ -473,7 +473,7 @@ struct MarioState { /*0xC0*/ f32 quicksandDepth; /*0xC4*/ f32 windGravity; // -- HackerSM64 MarioState fields begin -- - struct Object *paintingObj; + struct Object *paintingObj; // The painting Mario is currently entering. #ifdef BREATH_METER s16 breath; u8 breathCounter; diff --git a/src/game/paintings.c b/src/game/paintings.c index e6a5b43719..a07a06e1fd 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -31,26 +31,24 @@ * In bin/segment2.c: * seg2_painting_triangle_mesh: The mesh positions are generated from a base mesh. * seg2_painting_mesh_neighbor_tris: The lighting for the ripple is also generated from a base table. - * Each painting's texture uses yet another table to map its texture to the mesh. + * Each painting's texture uses yet another table to determine the order to map its texture to the mesh. * In levels/[LEVEL]/painting.inc.c: * PaintingImage structs, texture pointers. * - * Painting state machine: - * Paintings spawn in the PAINTING_STATE_IDLE state - * From IDLE, paintings can change to PAINTING_STATE_RIPPLING or PAINTING_STATE_ENTERED - * - This state checks for ENTERED because if Mario waits long enough, a PROXIMITY painting could - * reset to IDLE + * Painting actions: + * Paintings spawn in the PAINTING_ACT_IDLE action + * From PAINTING_ACT_IDLE, paintings can change to PAINTING_ACT_RIPPLING or PAINTING_ACT_ENTERED + * - This action checks for PAINTING_ACT_ENTERED because if Mario waits long enough, a RIPPLE_TRIGGER_PROXIMITY painting could reset to PAINTING_ACT_IDLE * - * Paintings in the PAINTING_STATE_RIPPLING state are passively rippling. + * Paintings in PAINTING_ACT_RIPPLING are passively rippling. * For RIPPLE_TRIGGER_PROXIMITY paintings, this means Mario bumped the front of the painting. * - * Paintings that use RIPPLE_TRIGGER_CONTINUOUS try to transition to this state as soon as possible, - * usually when Mario enters the room. + * Paintings that use RIPPLE_TRIGGER_CONTINUOUS try to transition to this action as soon as possible, usually when Mario enters the room. * - * A PROXIMITY painting will automatically reset to IDLE if its ripple magnitude becomes small enough. + * A PROXIMITY painting will automatically reset to PAINTING_ACT_IDLE if its ripple magnitude becomes small enough. * - * Paintings in the PAINTING_STATE_ENTERED state have been entered by Mario. - * A CONTINUOUS painting will automatically reset to RIPPLE if its ripple magnitude becomes small enough. + * Paintings in PAINTING_ACT_ENTERED have been entered by Mario. + * A CONTINUOUS painting will automatically reset to PAINTING_ACT_RIPPLING if its ripple magnitude becomes small enough. */ /** @@ -727,7 +725,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con SET_GRAPH_NODE_LAYER(node->flags, LAYER_TRANSPARENT); } - if (obj->oPaintingState == PAINTING_STATE_IDLE) { + if (obj->oAction == PAINTING_ACT_IDLE) { paintingDlist = display_painting_not_rippling(obj); } else { paintingDlist = display_painting_rippling(obj); @@ -780,10 +778,6 @@ void bhv_painting_init(void) { // Set the object's painting data pointer. obj->oPaintingImage = paintingImage; - // Clear flags. - obj->oPaintingCurrFlags = RIPPLE_FLAGS_NONE; - obj->oPaintingChangedFlags = RIPPLE_FLAGS_NONE; - // Update the painting object's room. painting_update_room(obj); } @@ -905,16 +899,16 @@ void painting_update_ripple_state(struct Object *obj) { if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // If the painting is barely rippling, make it stop rippling. if (obj->oPaintingCurrRippleMag <= 1.0f) { - obj->oPaintingState = PAINTING_STATE_IDLE; + obj->oAction = PAINTING_ACT_IDLE; } } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. - if ((obj->oPaintingState == PAINTING_STATE_ENTERED) + if ((obj->oAction == PAINTING_ACT_ENTERED) && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { - obj->oPaintingState = PAINTING_STATE_RIPPLING; + obj->oAction = PAINTING_ACT_RIPPLING; painting_set_ripple_animation(obj, &rippleAnim->passive); } } @@ -978,16 +972,16 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi // Use a different set of variables depending on the state switch (state) { - case PAINTING_STATE_RIPPLING: + case PAINTING_ACT_RIPPLING: painting_set_ripple_animation(obj, &rippleAnim->passive); break; - case PAINTING_STATE_ENTERED: + case PAINTING_ACT_ENTERED: painting_set_ripple_animation(obj, &rippleAnim->entry); break; } - obj->oPaintingState = state; + obj->oAction = state; // Set the ripple position. if (centerRipples) { @@ -1011,7 +1005,6 @@ void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTi } } - void bhv_painting_loop(void) { struct Object *obj = o; const struct PaintingImage *paintingImage = obj->oPaintingImage; @@ -1032,16 +1025,16 @@ void bhv_painting_loop(void) { if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // Proximity type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_STATE_ENTERED, FALSE, TRUE ); // Entering - } else if (obj->oPaintingState != PAINTING_STATE_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - painting_state(obj, PAINTING_STATE_RIPPLING, FALSE, TRUE ); // Wobbling + painting_state(obj, PAINTING_ACT_ENTERED, FALSE, TRUE ); // Entering + } else if (obj->oAction != PAINTING_ACT_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { + painting_state(obj, PAINTING_ACT_RIPPLING, FALSE, TRUE ); // Wobbling } } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_STATE_ENTERED, FALSE, FALSE); // Entering - } else if (obj->oPaintingState == PAINTING_STATE_IDLE) { - painting_state(obj, PAINTING_STATE_RIPPLING, TRUE, TRUE ); // Idle + painting_state(obj, PAINTING_ACT_ENTERED, FALSE, FALSE); // Entering + } else if (obj->oAction == PAINTING_ACT_IDLE) { + painting_state(obj, PAINTING_ACT_RIPPLING, TRUE, TRUE ); // Idle } } } diff --git a/src/game/paintings.h b/src/game/paintings.h index b8e82a40b0..54090d979d 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -81,11 +81,11 @@ enum PaintingRippleFlags { RIPPLE_FLAG_ENTER = BIT(1), // 0x02 }; -// oPaintingState -enum PaintingState { - PAINTING_STATE_IDLE, - PAINTING_STATE_RIPPLING, - PAINTING_STATE_ENTERED, +// oAction +enum oActionsPainting { + PAINTING_ACT_IDLE, + PAINTING_ACT_RIPPLING, + PAINTING_ACT_ENTERED, }; From 04d832154c42d36f4bf2fc1ac0511f0c318069f7 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 17:46:10 -0500 Subject: [PATCH 50/81] Make some function names clearer --- src/game/paintings.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index a07a06e1fd..8854319a10 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -870,7 +870,7 @@ const struct RippleAnimationPair *painting_get_ripple_animation_type_info(const /** * Set a painting's ripple animation and magnitude. */ -void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimation *baseRippleInfo) { +void painting_set_ripple_animation_type(struct Object *obj, const struct RippleAnimation *baseRippleInfo) { obj->oPaintingCurrRippleMag = baseRippleInfo->mag; obj->oPaintingRippleInfo = baseRippleInfo; } @@ -878,10 +878,10 @@ void painting_set_ripple_animation(struct Object *obj, const struct RippleAnimat /** * Update the ripple's timer and magnitude, making it propagate outwards. * - * Automatically changes the painting back to IDLE state (or RIPPLE for continuous paintings) if the - * ripple's magnitude becomes small enough. + * Automatically changes the painting back to PAINTING_ACT_IDLE action (or PAINTING_ACT_RIPPLING for continuous paintings) + * if the ripple's magnitude becomes small enough. */ -void painting_update_ripple_state(struct Object *obj) { +void painting_update_ripples(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; const struct RippleAnimation *objRippleInfo = obj->oPaintingRippleInfo; @@ -908,8 +908,8 @@ void painting_update_ripple_state(struct Object *obj) { // If Mario goes below the surface but doesn't warp, the painting will eventually reset. if ((obj->oAction == PAINTING_ACT_ENTERED) && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { + painting_set_ripple_animation_type(obj, &rippleAnim->passive); obj->oAction = PAINTING_ACT_RIPPLING; - painting_set_ripple_animation(obj, &rippleAnim->passive); } } } @@ -959,30 +959,27 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) #endif // (ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS || UNLOCK_ALL) /** - * Set the painting's state, causing it to start a passive ripple or a ripple from Mario entering. + * Set the painting's action, causing it to start a passive ripple or a ripple from Mario entering. * - * @param obj identifies the painting that is changing state - * @param state The state to enter - * @param centerRipples if TRUE, center the ripples instead of putting them at Mario's position - * @param doResetTimer if TRUE, set the timer to 0 + * @param obj identifies the painting that is changing state. + * @param centerRipples if TRUE, center the ripples instead of putting them at Mario's position. + * @param doResetTimer if TRUE, set the timer to 0. */ -void painting_state(struct Object *obj, s8 state, s8 centerRipples, s8 doResetTimer) { +void painting_start_ripples(struct Object *obj, s8 centerRipples, s8 doResetTimer) { const struct PaintingImage *paintingImage = obj->oPaintingImage; const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); // Use a different set of variables depending on the state - switch (state) { + switch (obj->oAction) { case PAINTING_ACT_RIPPLING: - painting_set_ripple_animation(obj, &rippleAnim->passive); + painting_set_ripple_animation_type(obj, &rippleAnim->passive); break; case PAINTING_ACT_ENTERED: - painting_set_ripple_animation(obj, &rippleAnim->entry); + painting_set_ripple_animation_type(obj, &rippleAnim->entry); break; } - obj->oAction = state; - // Set the ripple position. if (centerRipples) { obj->oPaintingRipplePosX = (paintingImage->sizeX * 0.5f); @@ -1013,7 +1010,7 @@ void bhv_painting_loop(void) { painting_update_mario_pos_and_flags(obj); // Update the ripple, may automatically reset the painting's state. - painting_update_ripple_state(obj); + painting_update_ripples(obj); #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) // Update the DDD painting before drawing. @@ -1025,16 +1022,20 @@ void bhv_painting_loop(void) { if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // Proximity type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_ACT_ENTERED, FALSE, TRUE ); // Entering + obj->oAction = PAINTING_ACT_ENTERED; + painting_start_ripples(obj, FALSE, TRUE ); // Entering } else if (obj->oAction != PAINTING_ACT_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { - painting_state(obj, PAINTING_ACT_RIPPLING, FALSE, TRUE ); // Wobbling + obj->oAction = PAINTING_ACT_RIPPLING; + painting_start_ripples(obj, FALSE, TRUE ); // Wobbling } } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous type: if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { - painting_state(obj, PAINTING_ACT_ENTERED, FALSE, FALSE); // Entering + obj->oAction = PAINTING_ACT_ENTERED; + painting_start_ripples(obj, FALSE, FALSE); // Entering } else if (obj->oAction == PAINTING_ACT_IDLE) { - painting_state(obj, PAINTING_ACT_RIPPLING, TRUE, TRUE ); // Idle + obj->oAction = PAINTING_ACT_RIPPLING; + painting_start_ripples(obj, TRUE, TRUE ); // Idle } } } From 0b6417a46731c5af1178fd6b1e3887a7be69eb05 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 18:07:59 -0500 Subject: [PATCH 51/81] Remove 'oPaintingChangedFlags' + rename some object fields & enums --- include/object_fields.h | 5 ++-- src/game/paintings.c | 64 ++++++++++++++++++++--------------------- src/game/paintings.h | 25 ++++++++-------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index be75a29ad2..19cea80dda 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1260,11 +1260,10 @@ #define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_F32(0x1D) #define /*0x100*/ oPaintingRipplePosX OBJECT_FIELD_F32(0x1E) #define /*0x104*/ oPaintingRipplePosY OBJECT_FIELD_F32(0x1F) -#define /*0x108*/ oPaintingCurrFlags OBJECT_FIELD_S16(0x20, 0) -#define /*0x10A*/ oPaintingChangedFlags OBJECT_FIELD_S16(0x20, 1) +#define /*0x108*/ oPaintingFlags OBJECT_FIELD_S32(0x20) #define /*0x10C*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x21) #define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) -#define /*0x1A8*/ oPaintingRippleInfo OBJECT_FIELD_CVPTR(0x48) +#define /*0x1A8*/ oPaintingRippleAnimation OBJECT_FIELD_CVPTR(0x48) /*Custom general defines: diff --git a/src/game/paintings.c b/src/game/paintings.c index 8854319a10..28be8d49f6 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -80,15 +80,15 @@ const struct PaintingImage *sPaintings[] = { * A list of preset constants for the ripple animations. */ const struct RippleAnimationPair sRippleAnimations[] = { - { // RIPPLE_ANIM_CONTINUOUS + [RIPPLE_ANIM_CONTINUOUS] = { .passive = { .mag = 10.0f, .decay = 1.0f, .rate = 0.05f, .dispersion = 15.0f }, .entry = { .mag = 30.0f, .decay = 0.98f, .rate = 0.05f, .dispersion = 15.0f } }, - { // RIPPLE_ANIM_PROXIMITY + [RIPPLE_ANIM_PROXIMITY] = { .passive = { .mag = 20.0f, .decay = 0.9608f, .rate = 0.24f, .dispersion = 40.0f }, .entry = { .mag = 80.0f, .decay = 0.9524f, .rate = 0.14f, .dispersion = 30.0f } }, - { // RIPPLE_ANIM_PROXIMITY_LARGE + [RIPPLE_ANIM_PROXIMITY_LARGE] = { .passive = { .mag = 40.0f, .decay = 0.9608f, .rate = 0.12f, .dispersion = 80.0f }, .entry = { .mag = 160.0f, .decay = 0.9524f, .rate = 0.07f, .dispersion = 60.0f } } @@ -117,15 +117,15 @@ const struct RippleAnimationPair sRippleAnimations[] = { */ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { const struct PaintingImage *paintingImage = obj->oPaintingImage; - const struct RippleAnimation *objRippleInfo = obj->oPaintingRippleInfo; + const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; PaintingData i, tri; /// Controls the peaks of the ripple. f32 rippleMag = obj->oPaintingCurrRippleMag; /// Controls the ripple's frequency. - f32 rippleRate = objRippleInfo->rate; + f32 rippleRate = objRippleAnim->rate; /// Controls how fast the ripple spreads. - f32 dispersionFactor = (1.0f / objRippleInfo->dispersion); + f32 dispersionFactor = (1.0f / objRippleAnim->dispersion); /// How far the ripple has spread. f32 rippleTimer = obj->oPaintingRippleTimer; @@ -785,14 +785,14 @@ void bhv_painting_init(void) { /// - LOOP - /** - * Check for Mario entering the painting. + * Check for Mario entering the painting. Returns changed flags. */ -void painting_update_mario_pos_and_flags(struct Object *obj) { +s32 painting_update_mario_pos_and_flags(struct Object *obj) { if (!gMarioObject) { - return; + return PAINTING_FLAGS_NONE; } - s8 rippleFlags = RIPPLE_FLAGS_NONE; + s32 nextFlags = PAINTING_FLAGS_NONE; Vec3f marioWorldPos; Vec3f marioLocalPos; @@ -818,35 +818,35 @@ void painting_update_mario_pos_and_flags(struct Object *obj) { // Check whether Mario is inside the wobble zone. if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH && marioLocalPos[2] > 0.0f) { - rippleFlags |= RIPPLE_FLAG_RIPPLE; + nextFlags |= PAINTING_FLAG_RIPPLE; } // Check whether Mario is inside the warp zone. if (marioLocalPos[2] < 0.0f && marioLocalPos[2] > -PAINTING_WARP_DEPTH) { - rippleFlags |= RIPPLE_FLAG_ENTER; + nextFlags |= PAINTING_FLAG_ENTER; } } obj->oPaintingLocalMarioPosX = marioLocalPos[0]; obj->oPaintingLocalMarioPosY = marioLocalPos[1]; - s16 lastFlags = obj->oPaintingCurrFlags; - - // At most 1 of these will be nonzero. - obj->oPaintingCurrFlags = rippleFlags; - - // changedFlags is true if currFlags is true and lastFlags is false - // (Mario just entered the floor on this frame). - obj->oPaintingChangedFlags = ((lastFlags ^ obj->oPaintingCurrFlags) & obj->oPaintingCurrFlags); - // Detect whether Mario is entering this painting, and set paintingObj accordingly - if (obj->oPaintingCurrFlags & RIPPLE_FLAG_ENTER) { + if (nextFlags & PAINTING_FLAG_ENTER) { // Mario has entered the painting. gMarioState->paintingObj = obj; } else if (gMarioState->paintingObj == obj) { // Reset gMarioState->paintingObj if it's this painting and this painting is not entered. gMarioState->paintingObj = NULL; } + + s32 lastFlags = obj->oPaintingFlags; + + // At most 1 of these will be nonzero. + obj->oPaintingFlags = nextFlags; + + // changedFlags is true if currFlags is true and lastFlags is false + // (Mario just entered the floor on this frame). + return ((lastFlags ^ nextFlags) & nextFlags); } /** @@ -870,9 +870,9 @@ const struct RippleAnimationPair *painting_get_ripple_animation_type_info(const /** * Set a painting's ripple animation and magnitude. */ -void painting_set_ripple_animation_type(struct Object *obj, const struct RippleAnimation *baseRippleInfo) { - obj->oPaintingCurrRippleMag = baseRippleInfo->mag; - obj->oPaintingRippleInfo = baseRippleInfo; +void painting_set_ripple_animation_type(struct Object *obj, const struct RippleAnimation *baseRippleAnim) { + obj->oPaintingCurrRippleMag = baseRippleAnim->mag; + obj->oPaintingRippleAnimation = baseRippleAnim; } /** @@ -883,10 +883,10 @@ void painting_set_ripple_animation_type(struct Object *obj, const struct RippleA */ void painting_update_ripples(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; - const struct RippleAnimation *objRippleInfo = obj->oPaintingRippleInfo; + const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; - if (objRippleInfo != NULL) { - obj->oPaintingCurrRippleMag *= objRippleInfo->decay; + if (objRippleAnim != NULL) { + obj->oPaintingCurrRippleMag *= objRippleAnim->decay; } // Reset the timer to 0 if it overflows. @@ -1007,7 +1007,7 @@ void bhv_painting_loop(void) { const struct PaintingImage *paintingImage = obj->oPaintingImage; // Update the painting info. - painting_update_mario_pos_and_flags(obj); + s32 changedFlags = painting_update_mario_pos_and_flags(obj); // Update the ripple, may automatically reset the painting's state. painting_update_ripples(obj); @@ -1021,16 +1021,16 @@ void bhv_painting_loop(void) { if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { // Proximity type: - if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { + if (changedFlags & PAINTING_FLAG_ENTER) { obj->oAction = PAINTING_ACT_ENTERED; painting_start_ripples(obj, FALSE, TRUE ); // Entering - } else if (obj->oAction != PAINTING_ACT_ENTERED && (obj->oPaintingChangedFlags & RIPPLE_FLAG_RIPPLE)) { + } else if (obj->oAction != PAINTING_ACT_ENTERED && (changedFlags & PAINTING_FLAG_RIPPLE)) { obj->oAction = PAINTING_ACT_RIPPLING; painting_start_ripples(obj, FALSE, TRUE ); // Wobbling } } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous type: - if (obj->oPaintingChangedFlags & RIPPLE_FLAG_ENTER) { + if (changedFlags & PAINTING_FLAG_ENTER) { obj->oAction = PAINTING_ACT_ENTERED; painting_start_ripples(obj, FALSE, FALSE); // Entering } else if (obj->oAction == PAINTING_ACT_IDLE) { diff --git a/src/game/paintings.h b/src/game/paintings.h index 54090d979d..5ed7624bdc 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -49,6 +49,14 @@ enum PaintingIDs { /* 0x11 */ PAINTING_ID_TTM_SLIDE, }; +// Types of ripple animations. +enum PaintingRippleAnimations { + RIPPLE_ANIM_CONTINUOUS, + RIPPLE_ANIM_PROXIMITY, + RIPPLE_ANIM_PROXIMITY_LARGE, +}; + + // Painting->textureType enum PaintingType { /// Painting that uses 1 or more images as a texture @@ -64,21 +72,14 @@ enum RippleTriggers { RIPPLE_TRIGGER_CONTINUOUS, }; -// Types of ripple animations. -enum PaintingRippleAnimations { - RIPPLE_ANIM_CONTINUOUS, - RIPPLE_ANIM_PROXIMITY, - RIPPLE_ANIM_PROXIMITY_LARGE, -}; - -// oPaintingCurrFlags, oPaintingChangedFlags -enum PaintingRippleFlags { +// oPaintingFlags +enum PaintingFlags { // Not rippling. - RIPPLE_FLAGS_NONE = 0x0, + PAINTING_FLAGS_NONE = 0x0, // Triggers a passive ripple. - RIPPLE_FLAG_RIPPLE = BIT(0), // 0x01 + PAINTING_FLAG_RIPPLE = BIT(0), // 0x01 // Triggers an entry ripple. - RIPPLE_FLAG_ENTER = BIT(1), // 0x02 + PAINTING_FLAG_ENTER = BIT(1), // 0x02 }; // oAction From c97839cd347820d791587bac4f6dc929fa507ca7 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 18:25:42 -0500 Subject: [PATCH 52/81] Replace 'oPaintingLocalMarioPosX' and 'oPaintingLocalMarioPosY' with local variables --- include/object_fields.h | 6 ++---- src/game/paintings.c | 48 ++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 19cea80dda..30c0a39e3b 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1256,14 +1256,12 @@ /* Painting */ #define /*0x0F4*/ oPaintingImage OBJECT_FIELD_CVPTR(0x1B) -#define /*0x0F8*/ oPaintingLocalMarioPosX OBJECT_FIELD_F32(0x1C) -#define /*0x0FC*/ oPaintingLocalMarioPosY OBJECT_FIELD_F32(0x1D) +#define /*0x0F8*/ oPaintingRippleAnimation OBJECT_FIELD_CVPTR(0x1C) +#define /*0x0FC*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x1D) #define /*0x100*/ oPaintingRipplePosX OBJECT_FIELD_F32(0x1E) #define /*0x104*/ oPaintingRipplePosY OBJECT_FIELD_F32(0x1F) #define /*0x108*/ oPaintingFlags OBJECT_FIELD_S32(0x20) #define /*0x10C*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x21) -#define /*0x1A4*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x47) -#define /*0x1A8*/ oPaintingRippleAnimation OBJECT_FIELD_CVPTR(0x48) /*Custom general defines: diff --git a/src/game/paintings.c b/src/game/paintings.c index 28be8d49f6..ef9280fe6c 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -787,10 +787,8 @@ void bhv_painting_init(void) { /** * Check for Mario entering the painting. Returns changed flags. */ -s32 painting_update_mario_pos_and_flags(struct Object *obj) { - if (!gMarioObject) { - return PAINTING_FLAGS_NONE; - } +s32 painting_update_mario_pos_and_flags(struct Object *obj, f32 *localMarioX, f32 *localMarioY) { + struct MarioState *m = gMarioState; s32 nextFlags = PAINTING_FLAGS_NONE; @@ -799,7 +797,7 @@ s32 painting_update_mario_pos_and_flags(struct Object *obj) { Vec3s rotation; // Add PAINTING_MARIO_Y_OFFSET to make the ripple closer to Mario's center of mass. - vec3f_copy_y_off(marioWorldPos, &gMarioObject->oPosVec, PAINTING_MARIO_Y_OFFSET); + vec3f_copy_y_off(marioWorldPos, m->pos, PAINTING_MARIO_Y_OFFSET); // Get the painting's rotation. vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); @@ -827,16 +825,16 @@ s32 painting_update_mario_pos_and_flags(struct Object *obj) { } } - obj->oPaintingLocalMarioPosX = marioLocalPos[0]; - obj->oPaintingLocalMarioPosY = marioLocalPos[1]; + *localMarioX = marioLocalPos[0]; + *localMarioY = marioLocalPos[1]; // Detect whether Mario is entering this painting, and set paintingObj accordingly if (nextFlags & PAINTING_FLAG_ENTER) { // Mario has entered the painting. - gMarioState->paintingObj = obj; - } else if (gMarioState->paintingObj == obj) { + m->paintingObj = obj; + } else if (m->paintingObj == obj) { // Reset gMarioState->paintingObj if it's this painting and this painting is not entered. - gMarioState->paintingObj = NULL; + m->paintingObj = NULL; } s32 lastFlags = obj->oPaintingFlags; @@ -871,8 +869,8 @@ const struct RippleAnimationPair *painting_get_ripple_animation_type_info(const * Set a painting's ripple animation and magnitude. */ void painting_set_ripple_animation_type(struct Object *obj, const struct RippleAnimation *baseRippleAnim) { - obj->oPaintingCurrRippleMag = baseRippleAnim->mag; obj->oPaintingRippleAnimation = baseRippleAnim; + obj->oPaintingCurrRippleMag = baseRippleAnim->mag; } /** @@ -962,10 +960,10 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) * Set the painting's action, causing it to start a passive ripple or a ripple from Mario entering. * * @param obj identifies the painting that is changing state. - * @param centerRipples if TRUE, center the ripples instead of putting them at Mario's position. - * @param doResetTimer if TRUE, set the timer to 0. + * @param ripplePosX,ripplePosY the position of the ripples. + * @param shouldResetTimer if TRUE, set the timer to 0. */ -void painting_start_ripples(struct Object *obj, s8 centerRipples, s8 doResetTimer) { +void painting_start_ripples(struct Object *obj, f32 ripplePosX, f32 ripplePosY, s32 shouldResetTimer) { const struct PaintingImage *paintingImage = obj->oPaintingImage; const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); @@ -981,13 +979,8 @@ void painting_start_ripples(struct Object *obj, s8 centerRipples, s8 doResetTime } // Set the ripple position. - if (centerRipples) { - obj->oPaintingRipplePosX = (paintingImage->sizeX * 0.5f); - obj->oPaintingRipplePosY = (paintingImage->sizeY * 0.5f); - } else { - obj->oPaintingRipplePosX = obj->oPaintingLocalMarioPosX; - obj->oPaintingRipplePosY = obj->oPaintingLocalMarioPosY; - } + obj->oPaintingRipplePosX = ripplePosX; + obj->oPaintingRipplePosY = ripplePosY; #ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS if (GET_BPARAM1(obj->oBehParams) == PAINTING_ID_CASTLE_WDW) { @@ -997,7 +990,7 @@ void painting_start_ripples(struct Object *obj, s8 centerRipples, s8 doResetTime } #endif - if (doResetTimer) { + if (shouldResetTimer) { obj->oPaintingRippleTimer = 0; } } @@ -1005,9 +998,10 @@ void painting_start_ripples(struct Object *obj, s8 centerRipples, s8 doResetTime void bhv_painting_loop(void) { struct Object *obj = o; const struct PaintingImage *paintingImage = obj->oPaintingImage; + f32 localMarioX, localMarioY; // Update the painting info. - s32 changedFlags = painting_update_mario_pos_and_flags(obj); + s32 changedFlags = painting_update_mario_pos_and_flags(obj, &localMarioX, &localMarioY); // Update the ripple, may automatically reset the painting's state. painting_update_ripples(obj); @@ -1023,19 +1017,19 @@ void bhv_painting_loop(void) { // Proximity type: if (changedFlags & PAINTING_FLAG_ENTER) { obj->oAction = PAINTING_ACT_ENTERED; - painting_start_ripples(obj, FALSE, TRUE ); // Entering + painting_start_ripples(obj, localMarioX, localMarioY, TRUE); // Entering } else if (obj->oAction != PAINTING_ACT_ENTERED && (changedFlags & PAINTING_FLAG_RIPPLE)) { obj->oAction = PAINTING_ACT_RIPPLING; - painting_start_ripples(obj, FALSE, TRUE ); // Wobbling + painting_start_ripples(obj, localMarioX, localMarioY, TRUE); // Wobbling } } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous type: if (changedFlags & PAINTING_FLAG_ENTER) { obj->oAction = PAINTING_ACT_ENTERED; - painting_start_ripples(obj, FALSE, FALSE); // Entering + painting_start_ripples(obj, localMarioX, localMarioY, FALSE); // Entering } else if (obj->oAction == PAINTING_ACT_IDLE) { obj->oAction = PAINTING_ACT_RIPPLING; - painting_start_ripples(obj, TRUE, TRUE ); // Idle + painting_start_ripples(obj, (paintingImage->sizeX * 0.5f), (paintingImage->sizeY * 0.5f), TRUE); // Idle } } } From 9cee1eed3c480a9f6ad2d05bb0c9f81351edd32d Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 12 Dec 2022 18:46:42 -0500 Subject: [PATCH 53/81] Smaller PAINTING_EDGE_MARGIN --- src/game/paintings.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game/paintings.h b/src/game/paintings.h index 5ed7624bdc..8abbd8200b 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -17,8 +17,8 @@ /// The depth of the area behind the painting which triggers the warp. #define PAINTING_WARP_DEPTH PAINTING_SIZE -/// The space around the edges in which Mario is still considered within painting bounds. -#define PAINTING_EDGE_MARGIN (PAINTING_SIZE / 2) +/// The size of the buffer around the edges of the painting in which Mario is still considered within bounds. +#define PAINTING_EDGE_MARGIN 160 /// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. #define PAINTING_MARIO_Y_OFFSET 50 @@ -56,7 +56,6 @@ enum PaintingRippleAnimations { RIPPLE_ANIM_PROXIMITY_LARGE, }; - // Painting->textureType enum PaintingType { /// Painting that uses 1 or more images as a texture From 1ed0a72b94684d5bafa0469088909e2e8599b581 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 13 Dec 2022 16:17:38 -0500 Subject: [PATCH 54/81] rr_painting uses RIPPLE_TRIGGER_NONE --- levels/castle_inside/painting.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index f922e8e8d2..360466f3e0 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -367,7 +367,7 @@ const struct PaintingImage rr_painting = { /* Texture Count */ 0, /* Texture w, h */ 0, 0, /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, + /* Ripple Trigger */ RIPPLE_TRIGGER_NONE, /* Shaded */ TRUE, /* Alpha */ 0x00, /* Size */ 204.8f, 204.8f, From a5df7ffedf4d2c4ee2d4254893f998c5cdf0296c Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 13 Dec 2022 19:24:09 -0500 Subject: [PATCH 55/81] Add PAINTING_WOBBLE_WARP_THRESHOLD + Change paintings.h defines to use vanilla values + Change oPaintingFlags to oPaintingStoredAction + Combine painting_update_ripples into bhv_painting_loop --- include/object_fields.h | 4 +- src/game/paintings.c | 195 +++++++++++++++++++--------------------- src/game/paintings.h | 31 +++---- 3 files changed, 105 insertions(+), 125 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 30c0a39e3b..46d38c5eab 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1260,8 +1260,8 @@ #define /*0x0FC*/ oPaintingCurrRippleMag OBJECT_FIELD_F32(0x1D) #define /*0x100*/ oPaintingRipplePosX OBJECT_FIELD_F32(0x1E) #define /*0x104*/ oPaintingRipplePosY OBJECT_FIELD_F32(0x1F) -#define /*0x108*/ oPaintingFlags OBJECT_FIELD_S32(0x20) -#define /*0x10C*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x21) +#define /*0x108*/ oPaintingRippleTimer OBJECT_FIELD_S32(0x20) +#define /*0x10C*/ oPaintingStoredAction OBJECT_FIELD_S32(0x21) /*Custom general defines: diff --git a/src/game/paintings.c b/src/game/paintings.c index ef9280fe6c..cd5bbf73b4 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -55,25 +55,24 @@ * Array of pointers to painting data structs. */ const struct PaintingImage *sPaintings[] = { - /* Painting ID */ - /* PAINTING_ID_NULL */ NULL, - /* PAINTING_ID_CASTLE_BOB */ &bob_painting, - /* PAINTING_ID_CASTLE_CCM */ &ccm_painting, - /* PAINTING_ID_CASTLE_WF */ &wf_painting, - /* PAINTING_ID_CASTLE_JRB */ &jrb_painting, - /* PAINTING_ID_CASTLE_LLL */ &lll_painting, - /* PAINTING_ID_CASTLE_SSL */ &ssl_painting, - /* PAINTING_ID_CASTLE_HMC */ &hmc_painting, - /* PAINTING_ID_CASTLE_DDD */ &ddd_painting, - /* PAINTING_ID_CASTLE_WDW */ &wdw_painting, - /* PAINTING_ID_CASTLE_THI_TINY */ &thi_tiny_painting, - /* PAINTING_ID_CASTLE_TTM */ &ttm_painting, - /* PAINTING_ID_CASTLE_TTC */ &ttc_painting, - /* PAINTING_ID_CASTLE_SL */ &sl_painting, - /* PAINTING_ID_CASTLE_THI_HUGE */ &thi_huge_painting, - /* PAINTING_ID_CASTLE_RR */ &rr_painting, - /* PAINTING_ID_HMC_COTMC */ &cotmc_painting, - /* PAINTING_ID_TTM_SLIDE */ &ttm_slide_painting, + [PAINTING_ID_NULL ] = NULL, + [PAINTING_ID_CASTLE_BOB ] = &bob_painting, + [PAINTING_ID_CASTLE_CCM ] = &ccm_painting, + [PAINTING_ID_CASTLE_WF ] = &wf_painting, + [PAINTING_ID_CASTLE_JRB ] = &jrb_painting, + [PAINTING_ID_CASTLE_LLL ] = &lll_painting, + [PAINTING_ID_CASTLE_SSL ] = &ssl_painting, + [PAINTING_ID_CASTLE_HMC ] = &hmc_painting, + [PAINTING_ID_CASTLE_DDD ] = &ddd_painting, + [PAINTING_ID_CASTLE_WDW ] = &wdw_painting, + [PAINTING_ID_CASTLE_THI_TINY] = &thi_tiny_painting, + [PAINTING_ID_CASTLE_TTM ] = &ttm_painting, + [PAINTING_ID_CASTLE_TTC ] = &ttc_painting, + [PAINTING_ID_CASTLE_SL ] = &sl_painting, + [PAINTING_ID_CASTLE_THI_HUGE] = &thi_huge_painting, + [PAINTING_ID_CASTLE_RR ] = &rr_painting, + [PAINTING_ID_HMC_COTMC ] = &cotmc_painting, + [PAINTING_ID_TTM_SLIDE ] = &ttm_slide_painting, }; /** @@ -787,13 +786,13 @@ void bhv_painting_init(void) { /** * Check for Mario entering the painting. Returns changed flags. */ -s32 painting_update_mario_pos_and_flags(struct Object *obj, f32 *localMarioX, f32 *localMarioY) { +s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { struct MarioState *m = gMarioState; - s32 nextFlags = PAINTING_FLAGS_NONE; + // PAINTING_ACT_IDLE will not change the action. + s32 newAction = PAINTING_ACT_IDLE; Vec3f marioWorldPos; - Vec3f marioLocalPos; Vec3s rotation; // Add PAINTING_MARIO_Y_OFFSET to make the ripple closer to Mario's center of mass. @@ -813,38 +812,38 @@ s32 painting_update_mario_pos_and_flags(struct Object *obj, f32 *localMarioX, f3 && marioLocalPos[0] < (paintingImage->sizeX + PAINTING_EDGE_MARGIN) && marioLocalPos[1] > -PAINTING_EDGE_MARGIN && marioLocalPos[1] < (paintingImage->sizeY + PAINTING_EDGE_MARGIN)) { - // Check whether Mario is inside the wobble zone. - if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH - && marioLocalPos[2] > 0.0f) { - nextFlags |= PAINTING_FLAG_RIPPLE; - } - // Check whether Mario is inside the warp zone. - if (marioLocalPos[2] < 0.0f - && marioLocalPos[2] > -PAINTING_WARP_DEPTH) { - nextFlags |= PAINTING_FLAG_ENTER; + if (marioLocalPos[2] > PAINTING_WOBBLE_WARP_THRESHOLD) { + // In front of the painting, check whether Mario is inside the wobble zone. + if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH) { + newAction = PAINTING_ACT_RIPPLING; + } + } else { + // Behind the painting, check whether Mario is inside the warp zone. + if (marioLocalPos[2] > -PAINTING_WARP_DEPTH) { + newAction = PAINTING_ACT_ENTERED; + } } } - *localMarioX = marioLocalPos[0]; - *localMarioY = marioLocalPos[1]; - // Detect whether Mario is entering this painting, and set paintingObj accordingly - if (nextFlags & PAINTING_FLAG_ENTER) { - // Mario has entered the painting. + if (newAction == PAINTING_ACT_ENTERED) { + // Mario has entered the painting.aa m->paintingObj = obj; } else if (m->paintingObj == obj) { - // Reset gMarioState->paintingObj if it's this painting and this painting is not entered. + // Reset m->paintingObj if it's this painting and this painting is not entered. m->paintingObj = NULL; } - s32 lastFlags = obj->oPaintingFlags; + s32 oldAction = obj->oPaintingStoredAction; - // At most 1 of these will be nonzero. - obj->oPaintingFlags = nextFlags; + obj->oPaintingStoredAction = newAction; - // changedFlags is true if currFlags is true and lastFlags is false - // (Mario just entered the floor on this frame). - return ((lastFlags ^ nextFlags) & nextFlags); + // The action to change to later. PAINTING_ACT_IDLE will not update the action. + if (newAction != oldAction) { + return newAction; + } else { + return PAINTING_ACT_IDLE; + } } /** @@ -873,45 +872,6 @@ void painting_set_ripple_animation_type(struct Object *obj, const struct RippleA obj->oPaintingCurrRippleMag = baseRippleAnim->mag; } -/** - * Update the ripple's timer and magnitude, making it propagate outwards. - * - * Automatically changes the painting back to PAINTING_ACT_IDLE action (or PAINTING_ACT_RIPPLING for continuous paintings) - * if the ripple's magnitude becomes small enough. - */ -void painting_update_ripples(struct Object *obj) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; - const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; - - if (objRippleAnim != NULL) { - obj->oPaintingCurrRippleMag *= objRippleAnim->decay; - } - - // Reset the timer to 0 if it overflows. - if (obj->oPaintingRippleTimer < 0) { - obj->oPaintingRippleTimer = 0; - } - - obj->oPaintingRippleTimer++; - - if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - // If the painting is barely rippling, make it stop rippling. - if (obj->oPaintingCurrRippleMag <= 1.0f) { - obj->oAction = PAINTING_ACT_IDLE; - } - } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); - // If the painting is doing the entry ripple but the ripples are as small as those from the - // passive ripple, make it do a passive ripple. - // If Mario goes below the surface but doesn't warp, the painting will eventually reset. - if ((obj->oAction == PAINTING_ACT_ENTERED) - && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { - painting_set_ripple_animation_type(obj, &rippleAnim->passive); - obj->oAction = PAINTING_ACT_RIPPLING; - } - } -} - #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) s32 gDDDPaintingNotMoved = FALSE; @@ -998,38 +958,65 @@ void painting_start_ripples(struct Object *obj, f32 ripplePosX, f32 ripplePosY, void bhv_painting_loop(void) { struct Object *obj = o; const struct PaintingImage *paintingImage = obj->oPaintingImage; - f32 localMarioX, localMarioY; + Vec3f marioLocalPos; - // Update the painting info. - s32 changedFlags = painting_update_mario_pos_and_flags(obj, &localMarioX, &localMarioY); + // Update the painting's next action based on Mario's relative position. + s32 newAction = painting_update_mario_pos(obj, marioLocalPos); - // Update the ripple, may automatically reset the painting's state. - painting_update_ripples(obj); + const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; -#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) - // Update the DDD painting before drawing. - if (GET_BPARAM1(obj->oBehParams) == PAINTING_ID_CASTLE_DDD) { - move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); + // Decay the ripple over time. + if (objRippleAnim != NULL) { + obj->oPaintingCurrRippleMag *= objRippleAnim->decay; + } + + // Update the ripple's timer, making it propagate outwards. + if (obj->oPaintingRippleTimer++ < 0) { + // Reset the timer to 0 if it overflows. + obj->oPaintingRippleTimer = 0; } -#endif // (ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS || UNLOCK_ALL) if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { - // Proximity type: - if (changedFlags & PAINTING_FLAG_ENTER) { - obj->oAction = PAINTING_ACT_ENTERED; - painting_start_ripples(obj, localMarioX, localMarioY, TRUE); // Entering - } else if (obj->oAction != PAINTING_ACT_ENTERED && (changedFlags & PAINTING_FLAG_RIPPLE)) { - obj->oAction = PAINTING_ACT_RIPPLING; - painting_start_ripples(obj, localMarioX, localMarioY, TRUE); // Wobbling + // Proximity trigger type: + + // If the painting is barely rippling, make it stop rippling. + if (obj->oPaintingCurrRippleMag <= 1.0f) { + obj->oAction = PAINTING_ACT_IDLE; + } + + if (newAction == PAINTING_ACT_ENTERED) { + obj->oAction = newAction; + painting_start_ripples(obj, marioLocalPos[0], marioLocalPos[1], TRUE); // Start entering + } else if (obj->oAction != PAINTING_ACT_ENTERED && (newAction == PAINTING_ACT_RIPPLING)) { + obj->oAction = newAction; + painting_start_ripples(obj, marioLocalPos[0], marioLocalPos[1], TRUE); // Start wobbling } } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { - // Continuous type: - if (changedFlags & PAINTING_FLAG_ENTER) { - obj->oAction = PAINTING_ACT_ENTERED; - painting_start_ripples(obj, localMarioX, localMarioY, FALSE); // Entering + // Continuous trigger type: + + const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); + // If the painting is doing the entry ripple but the ripples are as small as those from the + // passive ripple, make it do a passive ripple. + // If Mario goes below the surface but doesn't warp, the painting will eventually reset. + if ((obj->oAction == PAINTING_ACT_ENTERED) + && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { + painting_set_ripple_animation_type(obj, &rippleAnim->passive); + obj->oAction = PAINTING_ACT_RIPPLING; + } + + if (newAction == PAINTING_ACT_ENTERED) { + obj->oAction = newAction; + painting_start_ripples(obj, marioLocalPos[0], marioLocalPos[1], FALSE); // Start entering } else if (obj->oAction == PAINTING_ACT_IDLE) { obj->oAction = PAINTING_ACT_RIPPLING; - painting_start_ripples(obj, (paintingImage->sizeX * 0.5f), (paintingImage->sizeY * 0.5f), TRUE); // Idle + painting_start_ripples(obj, (paintingImage->sizeX * 0.5f), (paintingImage->sizeY * 0.5f), TRUE); // Start idle wobbling } } + +#if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) + // Update the DDD painting before drawing. + if (GET_BPARAM1(obj->oBehParams) == PAINTING_ID_CASTLE_DDD) { + move_ddd_painting(obj, 3456.0f, 5529.6f, 20.0f); + } +#endif // (ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS || UNLOCK_ALL) } diff --git a/src/game/paintings.h b/src/game/paintings.h index 8abbd8200b..ca74000da2 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -8,20 +8,23 @@ #include "types.h" -/// The default painting edge length. -#define PAINTING_SIZE 614.0f +/// The default painting edge length. Default is 614.4f. +#define PAINTING_SIZE 614.4f -/// The depth of the area in front of the painting which triggers ripples without warping. -#define PAINTING_WOBBLE_DEPTH 100 +/// The depth of the area in front of the painting which triggers ripples without warping. Default is 102.4f. +#define PAINTING_WOBBLE_DEPTH 102.4f -/// The depth of the area behind the painting which triggers the warp. -#define PAINTING_WARP_DEPTH PAINTING_SIZE +/// The depth of the area behind the painting which triggers the warp. Default is 409.6f. +#define PAINTING_WARP_DEPTH 409.6f + +/// The threshold relative to the painting's plane between wobbling and warping. Default is -30.72f. +#define PAINTING_WOBBLE_WARP_THRESHOLD -30.72f /// The size of the buffer around the edges of the painting in which Mario is still considered within bounds. -#define PAINTING_EDGE_MARGIN 160 +#define PAINTING_EDGE_MARGIN 160.0f -/// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. -#define PAINTING_MARIO_Y_OFFSET 50 +/// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. Default is 50.0f +#define PAINTING_MARIO_Y_OFFSET 50.0f /// Convert image coordinates to texel coordinates. #define TC(t) (((t) - 1) << 5) @@ -71,16 +74,6 @@ enum RippleTriggers { RIPPLE_TRIGGER_CONTINUOUS, }; -// oPaintingFlags -enum PaintingFlags { - // Not rippling. - PAINTING_FLAGS_NONE = 0x0, - // Triggers a passive ripple. - PAINTING_FLAG_RIPPLE = BIT(0), // 0x01 - // Triggers an entry ripple. - PAINTING_FLAG_ENTER = BIT(1), // 0x02 -}; - // oAction enum oActionsPainting { PAINTING_ACT_IDLE, From 4fe3d3f6069da23ccf12514ecd38229035f4d7c1 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 13 Dec 2022 22:25:35 -0500 Subject: [PATCH 56/81] Remove redundant painting data from segment2.c --- bin/segment2.c | 1188 +++++++++++------------------------------- src/game/paintings.c | 69 ++- src/game/segment2.h | 9 +- 3 files changed, 325 insertions(+), 941 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index d53fd652b0..d735a14033 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2931,7 +2931,7 @@ const Gfx dl_paintings_draw_ripples[] = { // 14A60: triangle mesh // 0x02014A60 -const PaintingData seg2_painting_triangle_mesh[] = { +const PaintingData painting_data_mesh[] = { 157, // numVtx // format: // 2D point (x, y), ripple (0 or 1) @@ -3092,287 +3092,21 @@ const PaintingData seg2_painting_triangle_mesh[] = { PAINTING_VERTEX( 0, 7, 0), // 154 PAINTING_VERTEX( 0, 3, 0), // 155 PAINTING_VERTEX( 0, 0, 0), // 156 - // triangles - 264, - 8, 12, 13, // 0 - 0, 1, 2, // 1 - 3, 0, 2, // 2 - 4, 0, 3, // 3 - 5, 2, 6, // 4 - 2, 5, 3, // 5 - 7, 8, 9, // 6 - 8, 7, 10, // 7 - 11, 8, 10, // 8 - 12, 8, 11, // 9 - 9, 8, 13, // 10 - 13, 14, 9, // 11 - 14, 141, 9, // 12 - 5, 6, 15, // 13 - 5, 16, 3, // 14 - 16, 5, 17, // 15 - 17, 5, 15, // 16 - 14, 15, 141, // 17 - 15, 14, 17, // 18 - 18, 14, 13, // 19 - 14, 18, 17, // 20 - 19, 142, 20, // 21 - 19, 20, 23, // 22 - 28, 27, 21, // 23 - 21, 23, 22, // 24 - 22, 41, 21, // 25 - 20, 22, 23, // 26 - 23, 24, 19, // 27 - 21, 27, 23, // 28 - 24, 23, 27, // 29 - 25, 144, 24, // 30 - 19, 24, 144, // 31 - 24, 27, 30, // 32 - 25, 24, 30, // 33 - 26, 30, 27, // 34 - 27, 28, 26, // 35 - 36, 38, 97, // 36 - 26, 34, 30, // 37 - 29, 30, 34, // 38 - 30, 29, 25, // 39 - 25, 29, 145, // 40 - 31, 145, 29, // 41 - 31, 29, 35, // 42 - 29, 34, 35, // 43 - 32, 34, 26, // 44 - 33, 35, 34, // 45 - 34, 32, 33, // 46 - 33, 38, 35, // 47 - 35, 36, 31, // 48 - 36, 35, 38, // 49 - 37, 36, 97, // 50 - 37, 146, 36, // 51 - 31, 36, 146, // 52 - 28, 16, 43, // 53 - 38, 40, 39, // 54 - 39, 97, 38, // 55 - 40, 38, 33, // 56 - 21, 41, 42, // 57 - 41, 4, 42, // 58 - 3, 42, 4, // 59 - 42, 28, 21, // 60 - 28, 42, 16, // 61 - 3, 16, 42, // 62 - 26, 28, 43, // 63 - 17, 43, 16, // 64 - 43, 32, 26, // 65 - 32, 43, 18, // 66 - 17, 18, 43, // 67 - 33, 32, 44, // 68 - 32, 18, 44, // 69 - 13, 44, 18, // 70 - 44, 40, 33, // 71 - 13, 12, 44, // 72 - 40, 44, 12, // 73 - 39, 40, 45, // 74 - 40, 12, 45, // 75 - 48, 31, 146, // 76 - 11, 45, 12, // 77 - 25, 47, 144, // 78 - 46, 25, 145, // 79 - 47, 19, 144, // 80 - 19, 143, 142, // 81 - 31, 46, 145, // 82 - 60, 59, 52, // 83 - 49, 53, 55, // 84 - 50, 49, 51, // 85 - 51, 49, 55, // 86 - 52, 55, 53, // 87 - 53, 75, 52, // 88 - 54, 55, 59, // 89 - 52, 59, 55, // 90 - 55, 54, 51, // 91 - 54, 59, 62, // 92 - 56, 54, 62, // 93 - 57, 54, 56, // 94 - 54, 57, 51, // 95 - 58, 62, 59, // 96 - 59, 60, 58, // 97 - 68, 71, 63, // 98 - 61, 62, 65, // 99 - 58, 65, 62, // 100 - 62, 61, 56, // 101 - 61, 65, 69, // 102 - 63, 61, 69, // 103 - 64, 61, 63, // 104 - 61, 64, 56, // 105 - 65, 67, 66, // 106 - 66, 69, 65, // 107 - 67, 65, 58, // 108 - 68, 69, 73, // 109 - 69, 68, 63, // 110 - 66, 73, 69, // 111 - 68, 73, 120, // 112 - 70, 68, 120, // 113 - 71, 68, 70, // 114 - 72, 120, 73, // 115 - 73, 74, 72, // 116 - 74, 73, 66, // 117 - 75, 77, 78, // 118 - 52, 75, 78, // 119 - 76, 78, 77, // 120 - 77, 143, 76, // 121 - 76, 80, 78, // 122 - 60, 78, 80, // 123 - 78, 60, 52, // 124 - 46, 83, 79, // 125 - 58, 60, 81, // 126 - 60, 80, 81, // 127 - 79, 81, 80, // 128 - 80, 47, 79, // 129 - 47, 80, 76, // 130 - 81, 67, 58, // 131 - 67, 81, 83, // 132 - 79, 83, 81, // 133 - 66, 67, 84, // 134 - 67, 83, 84, // 135 - 82, 84, 83, // 136 - 83, 46, 82, // 137 - 84, 74, 66, // 138 - 82, 86, 84, // 139 - 74, 84, 86, // 140 - 74, 86, 136, // 141 - 72, 74, 136, // 142 - 85, 136, 86, // 143 - 86, 48, 85, // 144 - 48, 86, 82, // 145 - 25, 46, 79, // 146 - 79, 47, 25, // 147 - 82, 46, 31, // 148 - 19, 47, 76, // 149 - 76, 143, 19, // 150 - 31, 48, 82, // 151 - 37, 48, 146, // 152 - 85, 48, 37, // 153 - 10, 87, 11, // 154 - 87, 10, 147, // 155 - 92, 95, 149, // 156 - 88, 89, 90, // 157 - 89, 148, 91, // 158 - 90, 89, 91, // 159 - 91, 92, 90, // 160 - 92, 149, 90, // 161 - 93, 87, 94, // 162 - 87, 93, 11, // 163 - 94, 87, 95, // 164 - 87, 147, 95, // 165 - 95, 92, 94, // 166 - 96, 92, 91, // 167 - 92, 96, 94, // 168 - 39, 101, 97, // 169 - 97, 98, 37, // 170 - 98, 97, 101, // 171 - 99, 98, 103, // 172 - 99, 150, 98, // 173 - 37, 98, 150, // 174 - 98, 101, 103, // 175 - 100, 103, 101, // 176 - 101, 102, 100, // 177 - 102, 101, 39, // 178 - 100, 107, 103, // 179 - 103, 104, 99, // 180 - 104, 103, 107, // 181 - 105, 104, 109, // 182 - 105, 151, 104, // 183 - 99, 104, 151, // 184 - 104, 107, 109, // 185 - 106, 109, 107, // 186 - 107, 108, 106, // 187 - 108, 107, 100, // 188 - 109, 110, 105, // 189 - 106, 152, 109, // 190 - 110, 109, 152, // 191 - 105, 110, 153, // 192 - 111, 152, 106, // 193 - 11, 93, 45, // 194 - 102, 45, 93, // 195 - 45, 102, 39, // 196 - 102, 93, 112, // 197 - 100, 102, 112, // 198 - 94, 112, 93, // 199 - 112, 108, 100, // 200 - 108, 112, 96, // 201 - 94, 96, 112, // 202 - 106, 108, 113, // 203 - 108, 96, 113, // 204 - 91, 113, 96, // 205 - 91, 148, 113, // 206 - 113, 111, 106, // 207 - 111, 113, 148, // 208 - 114, 116, 99, // 209 - 99, 115, 114, // 210 - 115, 99, 151, // 211 - 99, 116, 150, // 212 - 72, 124, 120, // 213 - 116, 37, 150, // 214 - 37, 116, 85, // 215 - 117, 105, 153, // 216 - 105, 115, 151, // 217 - 105, 117, 118, // 218 - 118, 115, 105, // 219 - 119, 120, 124, // 220 - 120, 119, 70, // 221 - 119, 124, 127, // 222 - 119, 121, 70, // 223 - 121, 119, 122, // 224 - 122, 119, 127, // 225 - 123, 124, 72, // 226 - 124, 123, 125, // 227 - 125, 127, 124, // 228 - 126, 127, 131, // 229 - 127, 126, 122, // 230 - 125, 131, 127, // 231 - 126, 131, 134, // 232 - 128, 126, 129, // 233 - 129, 126, 134, // 234 - 126, 128, 122, // 235 - 136, 123, 72, // 236 - 130, 134, 131, // 237 - 131, 132, 130, // 238 - 132, 131, 125, // 239 - 133, 134, 155, // 240 - 134, 133, 129, // 241 - 130, 155, 134, // 242 - 133, 156, 129, // 243 - 135, 155, 130, // 244 - 123, 136, 137, // 245 - 85, 137, 136, // 246 - 139, 115, 118, // 247 - 123, 137, 138, // 248 - 125, 123, 138, // 249 - 114, 138, 137, // 250 - 137, 116, 114, // 251 - 116, 137, 85, // 252 - 114, 139, 138, // 253 - 132, 138, 139, // 254 - 138, 132, 125, // 255 - 132, 139, 140, // 256 - 130, 132, 140, // 257 - 115, 139, 114, // 258 - 118, 140, 139, // 259 - 135, 140, 154, // 260 - 118, 154, 140, // 261 - 140, 135, 130, // 262 - 117, 154, 118, // 263 }; #undef PDX #undef PDY #undef PAINTING_VERTEX -/* 0x02015444: seg2_painting_mesh_neighbor_tris +/* 0x02015444: painting_data_mesh_neighbor_tris * Lists the neighboring triangles for each vertex in the mesh. * Used when applying gouraud shading to the generated ripple mesh * * Format: * num neighbors, neighbor0, neighbor1, ... - * The nth entry corresponds to the nth vertex in seg2_painting_triangle_mesh + * The nth entry corresponds to the nth vertex in painting_data_mesh */ -const PaintingData seg2_painting_mesh_neighbor_tris[] = { +const PaintingData painting_data_mesh_neighbor_tris[] = { // ID num, neighbors... /* 0*/ 3, 1, 2, 3, /* 1*/ 1, 1, @@ -3533,632 +3267,8 @@ const PaintingData seg2_painting_mesh_neighbor_tris[] = { /*156*/ 1, 243, }; -// 0x07021AE0 - 0x07021FFA -static const PaintingData seg2_painting_image_texture_map_2_bottom[] = { - 85, // num mappings - // Format: - // mesh vtx ID - 49, - 53, - 55, - 50, - 51, - 52, - 75, - 54, - 59, - 62, - 56, - 57, - 58, - 60, - 61, - 65, - 63, - 64, - 66, - 67, - 69, - 68, - 70, - 71, - 73, - 72, - 74, - 77, - 78, - 76, - 81, - 80, - 47, - 79, - 46, - 82, - 83, - 84, - 86, - 85, - 48, - 25, - 31, - 19, - 37, - 120, - 119, - 122, - 121, - 124, - 125, - 123, - 127, - 126, - 129, - 128, - 132, - 131, - 130, - 134, - 133, - 135, - 136, - 116, - 137, - 114, - 138, - 139, - 118, - 115, - 140, - 117, - 99, - 105, - 143, - 145, - 144, - 142, - 146, - 155, - 156, - 154, - 151, - 150, - 153, - - 132, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 13, 8, 5, - 0, 1, 2, - 3, 0, 4, - 4, 0, 2, - 5, 2, 1, - 1, 6, 5, - 7, 2, 8, - 5, 8, 2, - 2, 7, 4, - 7, 8, 9, - 10, 7, 9, - 11, 7, 10, - 7, 11, 4, - 12, 9, 8, - 8, 13, 12, - 21, 24, 45, - 14, 9, 15, - 12, 15, 9, - 9, 14, 10, - 16, 14, 20, - 17, 14, 16, - 14, 15, 20, - 14, 17, 10, - 15, 19, 18, - 18, 20, 15, - 19, 15, 12, - 20, 21, 16, - 18, 24, 20, - 21, 20, 24, - 22, 21, 45, - 23, 21, 22, - 21, 23, 16, - 24, 26, 25, - 25, 45, 24, - 26, 24, 18, - 6, 27, 28, - 5, 6, 28, - 29, 28, 27, - 27, 74, 29, - 29, 31, 28, - 13, 28, 31, - 28, 13, 5, - 36, 34, 35, - 12, 13, 30, - 13, 31, 30, - 31, 32, 33, - 32, 31, 29, - 33, 30, 31, - 33, 36, 30, - 30, 19, 12, - 19, 30, 36, - 18, 19, 37, - 19, 36, 37, - 34, 36, 33, - 35, 37, 36, - 37, 26, 18, - 35, 38, 37, - 26, 37, 38, - 25, 26, 62, - 26, 38, 62, - 38, 40, 39, - 39, 62, 38, - 40, 38, 35, - 41, 34, 33, - 33, 32, 41, - 42, 34, 75, - 34, 41, 75, - 35, 34, 42, - 32, 43, 76, - 41, 32, 76, - 43, 32, 29, - 29, 74, 43, - 43, 74, 77, - 46, 49, 52, - 42, 40, 35, - 39, 40, 44, - 40, 42, 78, - 44, 40, 78, - 25, 49, 45, - 45, 46, 22, - 46, 45, 49, - 47, 46, 52, - 48, 46, 47, - 46, 48, 22, - 58, 59, 57, - 49, 51, 50, - 50, 52, 49, - 51, 49, 25, - 50, 57, 52, - 52, 53, 47, - 53, 52, 57, - 53, 55, 47, - 54, 53, 59, - 55, 53, 54, - 53, 57, 59, - 56, 57, 50, - 57, 56, 58, - 58, 79, 59, - 59, 60, 54, - 60, 59, 79, - 60, 80, 54, - 61, 79, 58, - 62, 51, 25, - 39, 64, 62, - 51, 62, 64, - 50, 51, 66, - 51, 64, 66, - 63, 64, 39, - 64, 63, 65, - 65, 66, 64, - 66, 56, 50, - 56, 66, 67, - 65, 67, 66, - 58, 56, 70, - 56, 67, 70, - 67, 69, 68, - 68, 70, 67, - 69, 67, 65, - 70, 61, 58, - 68, 81, 70, - 61, 70, 81, - 71, 73, 84, - 71, 81, 68, - 72, 69, 65, - 65, 63, 72, - 68, 69, 73, - 69, 72, 82, - 73, 69, 82, - 44, 63, 39, - 63, 44, 83, - 72, 63, 83, - 73, 71, 68, -}; - -// 0x07021FFC - 0x07022516 -static const PaintingData seg2_painting_image_texture_map_2_top[] = { - 85, // num mappings - // Format: - // mesh vtx ID - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 8, - 7, - 10, - 9, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 22, - 21, - 23, - 24, - 25, - 26, - 27, - 28, - 30, - 29, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 39, - 38, - 40, - 41, - 42, - 43, - 44, - 45, - 87, - 88, - 90, - 89, - 92, - 91, - 94, - 93, - 95, - 96, - 97, - 98, - 99, - 102, - 101, - 100, - 103, - 104, - 105, - 108, - 107, - 106, - 110, - 109, - 111, - 112, - 113, - 141, - 142, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - - 132, // num groups - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - 10, 7, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 7, 8, 9, - 8, 7, 10, - 11, 7, 9, - 12, 7, 11, - 7, 12, 13, - 13, 14, 10, - 14, 73, 10, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 73, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 74, 20, - 19, 20, 23, - 28, 27, 22, - 21, 41, 22, - 22, 23, 21, - 20, 21, 23, - 23, 24, 19, - 22, 27, 23, - 24, 23, 27, - 19, 24, 75, - 25, 75, 24, - 25, 24, 29, - 24, 27, 29, - 26, 29, 27, - 27, 28, 26, - 31, 36, 77, - 26, 34, 29, - 29, 30, 25, - 30, 29, 34, - 25, 30, 76, - 31, 76, 30, - 31, 30, 35, - 30, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 35, 36, 31, - 33, 39, 35, - 36, 35, 39, - 37, 36, 56, - 36, 39, 56, - 37, 77, 36, - 28, 16, 43, - 38, 56, 39, - 39, 40, 38, - 40, 39, 33, - 22, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 22, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 13, 12, 44, - 44, 40, 33, - 40, 44, 12, - 38, 40, 45, - 40, 12, 45, - 11, 45, 12, - 9, 46, 11, - 46, 9, 78, - 47, 49, 48, - 48, 49, 51, - 49, 79, 51, - 50, 80, 48, - 51, 50, 48, - 57, 56, 60, - 46, 53, 11, - 52, 46, 54, - 53, 46, 52, - 46, 78, 54, - 54, 50, 52, - 50, 54, 80, - 50, 55, 52, - 55, 50, 51, - 38, 60, 56, - 56, 57, 37, - 58, 57, 62, - 57, 60, 62, - 58, 81, 57, - 37, 57, 81, - 59, 60, 38, - 60, 59, 61, - 61, 62, 60, - 62, 63, 58, - 63, 62, 66, - 61, 66, 62, - 63, 66, 69, - 58, 63, 82, - 64, 82, 63, - 64, 63, 69, - 45, 59, 38, - 65, 66, 61, - 66, 65, 67, - 67, 69, 66, - 68, 69, 83, - 69, 68, 64, - 67, 83, 69, - 64, 68, 84, - 70, 83, 67, - 11, 53, 45, - 59, 45, 53, - 59, 53, 71, - 61, 59, 71, - 52, 71, 53, - 52, 55, 71, - 65, 71, 55, - 71, 65, 61, - 65, 55, 72, - 67, 65, 72, - 51, 72, 55, - 70, 72, 79, - 51, 79, 72, - 72, 70, 67, -}; - -// 0x07022518 -const PaintingData *const seg2_painting_texture_maps_2[] = { - seg2_painting_image_texture_map_2_bottom, - seg2_painting_image_texture_map_2_top, -}; - // 0x07022660 - 0x07023042 -static const PaintingData seg2_painting_texture_map_1[] = { - 157, // num mappings - // Format: - // mesh vtx ID - 0, - 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, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - -// inside_castle_seg7_painting_triangles_07022A10: +const PaintingData painting_data_triangles_1[] = { 264, // num groups // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles @@ -4429,6 +3539,290 @@ static const PaintingData seg2_painting_texture_map_1[] = { }; // 0x07023044 - 0x07023048 -const PaintingData *const seg2_painting_texture_maps_1[] = { - seg2_painting_texture_map_1, +const PaintingData *const painting_data_triangles_1_array[] = { + painting_data_triangles_1, +}; + +// 0x07021AE0 - 0x07021FFA +const PaintingData painting_data_triangles_2_bottom[] = { + 132, // num groups + // Grouped by 5 + one remainder group, + // = 15 vertices per group + a few extra triangles + 60, 59, 52, + 49, 53, 55, + 50, 49, 51, + 51, 49, 55, + 52, 55, 53, + 53, 75, 52, + 54, 55, 59, + 52, 59, 55, + 55, 54, 51, + 54, 59, 62, + 56, 54, 62, + 57, 54, 56, + 54, 57, 51, + 58, 62, 59, + 59, 60, 58, + 68, 73, 120, + 61, 62, 65, + 58, 65, 62, + 62, 61, 56, + 63, 61, 69, + 64, 61, 63, + 61, 65, 69, + 61, 64, 56, + 65, 67, 66, + 66, 69, 65, + 67, 65, 58, + 69, 68, 63, + 66, 73, 69, + 68, 69, 73, + 70, 68, 120, + 71, 68, 70, + 68, 71, 63, + 73, 74, 72, + 72, 120, 73, + 74, 73, 66, + 75, 77, 78, + 52, 75, 78, + 76, 78, 77, + 77, 143, 76, + 76, 80, 78, + 60, 78, 80, + 78, 60, 52, + 83, 46, 82, + 58, 60, 81, + 60, 80, 81, + 80, 47, 79, + 47, 80, 76, + 79, 81, 80, + 79, 83, 81, + 81, 67, 58, + 67, 81, 83, + 66, 67, 84, + 67, 83, 84, + 46, 83, 79, + 82, 84, 83, + 84, 74, 66, + 82, 86, 84, + 74, 84, 86, + 72, 74, 136, + 74, 86, 136, + 86, 48, 85, + 85, 136, 86, + 48, 86, 82, + 25, 46, 79, + 79, 47, 25, + 31, 46, 145, + 46, 25, 145, + 82, 46, 31, + 47, 19, 144, + 25, 47, 144, + 19, 47, 76, + 76, 143, 19, + 19, 143, 142, + 119, 124, 127, + 31, 48, 82, + 85, 48, 37, + 48, 31, 146, + 37, 48, 146, + 72, 124, 120, + 120, 119, 70, + 119, 120, 124, + 122, 119, 127, + 121, 119, 122, + 119, 121, 70, + 130, 134, 131, + 124, 123, 125, + 125, 127, 124, + 123, 124, 72, + 125, 131, 127, + 127, 126, 122, + 126, 127, 131, + 126, 128, 122, + 129, 126, 134, + 128, 126, 129, + 126, 131, 134, + 132, 131, 125, + 131, 132, 130, + 130, 155, 134, + 134, 133, 129, + 133, 134, 155, + 133, 156, 129, + 135, 155, 130, + 136, 123, 72, + 85, 137, 136, + 123, 136, 137, + 125, 123, 138, + 123, 137, 138, + 116, 137, 85, + 137, 116, 114, + 114, 138, 137, + 138, 132, 125, + 132, 138, 139, + 114, 139, 138, + 130, 132, 140, + 132, 139, 140, + 139, 115, 118, + 118, 140, 139, + 115, 139, 114, + 140, 135, 130, + 118, 154, 140, + 135, 140, 154, + 117, 105, 153, + 117, 154, 118, + 99, 115, 114, + 114, 116, 99, + 118, 115, 105, + 115, 99, 151, + 105, 115, 151, + 37, 116, 85, + 116, 37, 150, + 99, 116, 150, + 105, 117, 118, +}; + +// 0x07021FFC - 0x07022516 +const PaintingData painting_data_triangles_2_top[] = { + 132, // num groups + // Grouped by 5 + one remainder group, + // = 15 vertices per group + a few extra triangles + 9, 8, 13, + 0, 1, 2, + 3, 0, 2, + 4, 0, 3, + 5, 2, 6, + 2, 5, 3, + 8, 7, 10, + 7, 8, 9, + 11, 8, 10, + 12, 8, 11, + 8, 12, 13, + 13, 14, 9, + 14, 141, 9, + 5, 6, 15, + 5, 16, 3, + 16, 5, 17, + 17, 5, 15, + 14, 15, 141, + 15, 14, 17, + 18, 14, 13, + 14, 18, 17, + 19, 142, 20, + 19, 20, 23, + 28, 27, 21, + 22, 41, 21, + 21, 23, 22, + 20, 22, 23, + 23, 24, 19, + 21, 27, 23, + 24, 23, 27, + 19, 24, 144, + 25, 144, 24, + 25, 24, 30, + 24, 27, 30, + 26, 30, 27, + 27, 28, 26, + 31, 36, 146, + 26, 34, 30, + 30, 29, 25, + 29, 30, 34, + 25, 29, 145, + 31, 145, 29, + 31, 29, 35, + 29, 34, 35, + 32, 34, 26, + 33, 35, 34, + 34, 32, 33, + 35, 36, 31, + 33, 38, 35, + 36, 35, 38, + 37, 36, 97, + 36, 38, 97, + 37, 146, 36, + 28, 16, 43, + 39, 97, 38, + 38, 40, 39, + 40, 38, 33, + 21, 41, 42, + 41, 4, 42, + 3, 42, 4, + 42, 28, 21, + 28, 42, 16, + 3, 16, 42, + 26, 28, 43, + 17, 43, 16, + 43, 32, 26, + 32, 43, 18, + 17, 18, 43, + 33, 32, 44, + 32, 18, 44, + 13, 44, 18, + 13, 12, 44, + 44, 40, 33, + 40, 44, 12, + 39, 40, 45, + 40, 12, 45, + 11, 45, 12, + 10, 87, 11, + 87, 10, 147, + 88, 89, 90, + 90, 89, 91, + 89, 148, 91, + 92, 149, 90, + 91, 92, 90, + 98, 97, 101, + 87, 93, 11, + 94, 87, 95, + 93, 87, 94, + 87, 147, 95, + 95, 92, 94, + 92, 95, 149, + 92, 96, 94, + 96, 92, 91, + 39, 101, 97, + 97, 98, 37, + 99, 98, 103, + 98, 101, 103, + 99, 150, 98, + 37, 98, 150, + 102, 101, 39, + 101, 102, 100, + 100, 103, 101, + 103, 104, 99, + 104, 103, 107, + 100, 107, 103, + 104, 107, 109, + 99, 104, 151, + 105, 151, 104, + 105, 104, 109, + 45, 102, 39, + 108, 107, 100, + 107, 108, 106, + 106, 109, 107, + 110, 109, 152, + 109, 110, 105, + 106, 152, 109, + 105, 110, 153, + 111, 152, 106, + 11, 93, 45, + 102, 45, 93, + 102, 93, 112, + 100, 102, 112, + 94, 112, 93, + 94, 96, 112, + 108, 112, 96, + 112, 108, 100, + 108, 96, 113, + 106, 108, 113, + 91, 113, 96, + 111, 113, 148, + 91, 148, 113, + 113, 111, 106, +}; + +// 0x07022518 +const PaintingData *const painting_data_triangles_2_array[] = { + painting_data_triangles_2_bottom, + painting_data_triangles_2_top, }; diff --git a/src/game/paintings.c b/src/game/paintings.c index cd5bbf73b4..8c1aadfa55 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -29,8 +29,8 @@ * * The ripple effect uses data that is split into several parts: * In bin/segment2.c: - * seg2_painting_triangle_mesh: The mesh positions are generated from a base mesh. - * seg2_painting_mesh_neighbor_tris: The lighting for the ripple is also generated from a base table. + * painting_data_mesh: The mesh positions are generated from a base mesh. + * painting_data_mesh_neighbor_tris: The lighting for the ripple is also generated from a base table. * Each painting's texture uses yet another table to determine the order to map its texture to the mesh. * In levels/[LEVEL]/painting.inc.c: * PaintingImage structs, texture pointers. @@ -112,7 +112,7 @@ const struct RippleAnimationPair sRippleAnimations[] = { * vN x, vN y, movable * Where x and y are from 0 to PAINTING_SIZE, movable is 0 or 1. * - * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. + * The mesh used in game, painting_data_mesh, is in bin/segment2.c. */ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { const struct PaintingImage *paintingImage = obj->oPaintingImage; @@ -183,16 +183,16 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, Pa * triN v0, triN v1, triN v2 * Where each v0, v1, v2 is an index into the first list in `mesh`. * - * The mesh used in game, seg2_painting_triangle_mesh, is in bin/segment2.c. + * The mesh used in game, painting_data_mesh, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingData numVtx, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { +void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData i; Vec3s v; Vec3f vp0, vp1, vp2; for (i = 0; i < numTris; i++) { // Add 2 because of the 2 length entries preceding the list. - PaintingData tri = (1 + (numVtx * 3) + 1 + (i * 3)); + PaintingData tri = (1 + (i * 3)); vec3s_copy(v, &meshData[tri]); vec3s_to_vec3f(vp0, paintingMesh[v[0]].pos); vec3s_to_vec3f(vp1, paintingMesh[v[1]].pos); @@ -216,7 +216,7 @@ void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingD * Where each 'tri' is an index into sPaintingTriNorms. * Entry i in `neighborTris` corresponds to the vertex at sPaintingMesh[i] * - * The table used in game, seg2_painting_mesh_neighbor_tris, is in bin/segment2.c. + * The table used in game, painting_data_mesh_neighbor_tris, is in bin/segment2.c. */ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData tri; @@ -259,24 +259,20 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD #define VTX_PER_GRP (TRI_PER_GRP * 3) // 15 or 30 /** - * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, - * using 'textureMap'. + * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, using 'triangleMap'. * - * If the textureMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole - * painting. + * If the triangleMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole painting. */ -Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *textureMap, Alpha alpha, struct PaintingMeshVertex *paintingMesh) { +Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *triangleMap, Alpha alpha, struct PaintingMeshVertex *paintingMesh) { struct PaintingMeshVertex *currVtx = NULL; PaintingData group; PaintingData groupIndex; PaintingData map; PaintingData triGroup; - PaintingData mapping; PaintingData meshVtx; s16 tx, ty; - PaintingData mapVerts = textureMap[0]; - PaintingData mapTris = textureMap[1 + mapVerts]; + PaintingData mapTris = triangleMap[0]; // We can fit VTX_PER_GRP vertices in the RSP's vertex buffer. // Group triangles by TRI_PER_GRP, with one remainder group. @@ -320,16 +316,12 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, // The triangle groups are the second part of the texture map. // Each group is a list of VTX_PER_GRP mappings. - triGroup = (1 + mapVerts + 1 + groupIndex); + triGroup = (1 + groupIndex); // Vertices within the group for (map = 0; map < VTX_PER_GRP; map++) { - // The mapping is just an index into the earlier part of the textureMap. - // Some mappings are repeated, for example, when multiple triangles share a vertex. - mapping = (textureMap[triGroup + map]); - - // The first entry is the ID of the vertex in the mesh. - meshVtx = textureMap[1 + mapping]; + // Get the vertex index. + meshVtx = (triangleMap[triGroup + map]); // Get a pointer to the current mesh. currVtx = &paintingMesh[meshVtx]; @@ -357,16 +349,12 @@ Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, } // One group left with < TRI_PER_GRP triangles. - triGroup = (1 + mapVerts + 1 + (triGroups * VTX_PER_GRP)); + triGroup = (1 + (triGroups * VTX_PER_GRP)); // Map the texture to the triangles. for (map = 0; map < (remGroupTris * 3); map++) { - // The mapping is just an index into the earlier part of the textureMap. - // Some mappings are repeated, for example, when multiple triangles share a vertex. - mapping = (textureMap[triGroup + map]); - - // The first entry is the ID of the vertex in the mesh. - meshVtx = textureMap[1 + mapping]; + // Get the vertex index. + meshVtx = (triangleMap[triGroup + map]); // Get a pointer to the current mesh. currVtx = &paintingMesh[meshVtx]; @@ -467,7 +455,7 @@ void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { */ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct PaintingMeshVertex *paintingMesh) { s16 i; - const PaintingData *textureMap = NULL; + const PaintingData *triangleMap = NULL; s16 imageCount = paintingImage->imageCount; s16 tWidth = paintingImage->textureWidth; s16 tHeight = paintingImage->textureHeight; @@ -497,20 +485,20 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); - //! TODO: Automatically create texture maps based on the image count. - const PaintingData **textureMaps = NULL; + //! TODO: Automatically create triangle maps based on the image count. + const PaintingData **triangleMaps = NULL; switch (imageCount) { - case 1: textureMaps = segmented_to_virtual(seg2_painting_texture_maps_1); break; - case 2: textureMaps = segmented_to_virtual(seg2_painting_texture_maps_2); break; + case 1: triangleMaps = segmented_to_virtual(painting_data_triangles_1_array); break; + case 2: triangleMaps = segmented_to_virtual(painting_data_triangles_2_array); break; } painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { - textureMap = segmented_to_virtual(textureMaps[i]); + triangleMap = segmented_to_virtual(triangleMaps[i]); // Render a section of the painting. - gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, textureMap, paintingImage->alpha, paintingMesh)); + gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, triangleMap, paintingImage->alpha, paintingMesh)); } gSPPopMatrix(gfx++, G_MTX_MODELVIEW); @@ -527,10 +515,11 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain */ Gfx *display_painting_rippling(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; - const PaintingData *meshData = segmented_to_virtual(seg2_painting_triangle_mesh); - const PaintingData *neighborTris = segmented_to_virtual(seg2_painting_mesh_neighbor_tris); + const PaintingData *meshData = segmented_to_virtual(painting_data_mesh); + const PaintingData *triangleData = segmented_to_virtual(painting_data_triangles_1); + const PaintingData *neighborTris = segmented_to_virtual(painting_data_mesh_neighbor_tris); PaintingData numVtx = meshData[0]; - PaintingData numTris = meshData[(numVtx * 3) + 1]; + PaintingData numTris = triangleData[0]; Gfx *dlist = NULL; // When a painting is rippling, this mesh is generated each frame using the Painting's parameters. // This mesh only contains the vertex positions and normals. @@ -541,7 +530,7 @@ Gfx *display_painting_rippling(struct Object *obj) { // Generate the mesh and its lighting data painting_generate_mesh(obj, meshData, numVtx, paintingMesh); - painting_calculate_triangle_normals(meshData, numVtx, numTris, paintingMesh, paintingTriNorms); + painting_calculate_triangle_normals(triangleData, numTris, paintingMesh, paintingTriNorms); painting_average_vertex_normals(neighborTris, numVtx, paintingMesh, paintingTriNorms); // Map the painting's texture depending on the painting's texture type. diff --git a/src/game/segment2.h b/src/game/segment2.h index 459f3f0ab7..e55594d079 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -45,10 +45,11 @@ extern Gfx dl_paintings_textured_vertex_colored_begin[]; extern Gfx dl_paintings_textured_end[]; extern Gfx dl_paintings_env_mapped_begin[]; extern Gfx dl_paintings_env_mapped_end[]; -extern PaintingData seg2_painting_triangle_mesh[]; -extern PaintingData seg2_painting_mesh_neighbor_tris[]; -extern PaintingData *const seg2_painting_texture_maps_1[]; -extern PaintingData *const seg2_painting_texture_maps_2[]; +extern PaintingData painting_data_mesh[]; +extern PaintingData painting_data_mesh_neighbor_tris[]; +extern PaintingData painting_data_triangles_1[]; +extern PaintingData *const painting_data_triangles_1_array[]; +extern PaintingData *const painting_data_triangles_2_array[]; extern Texture *main_hud_lut[58]; extern Gfx dl_hud_img_load_tex_block[]; extern Gfx dl_hud_img_begin[]; From 9aab0fd00c2b4c62c10088f409fa00792a38505d Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 13 Dec 2022 22:30:12 -0500 Subject: [PATCH 57/81] Rename 'painting_data_mesh' to 'painting_data_vertices' --- bin/segment2.c | 152 +++++++++++++++++++++---------------------- src/game/paintings.c | 8 +-- src/game/segment2.h | 2 +- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index d735a14033..deb99e94ab 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2931,7 +2931,7 @@ const Gfx dl_paintings_draw_ripples[] = { // 14A60: triangle mesh // 0x02014A60 -const PaintingData painting_data_mesh[] = { +const PaintingData painting_data_vertices[] = { 157, // numVtx // format: // 2D point (x, y), ripple (0 or 1) @@ -3104,7 +3104,7 @@ const PaintingData painting_data_mesh[] = { * * Format: * num neighbors, neighbor0, neighbor1, ... - * The nth entry corresponds to the nth vertex in painting_data_mesh + * The nth entry corresponds to the nth vertex in painting_data_vertices */ const PaintingData painting_data_mesh_neighbor_tris[] = { // ID num, neighbors... @@ -3272,80 +3272,80 @@ const PaintingData painting_data_triangles_1[] = { 264, // num groups // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles - 8, 12, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 7, 8, 9, - 8, 7, 10, - 11, 8, 10, - 12, 8, 11, - 9, 8, 13, - 13, 14, 9, - 14, 141, 9, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 141, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 142, 20, - 19, 20, 23, - 28, 27, 21, - 21, 23, 22, - 22, 41, 21, - 20, 22, 23, - 23, 24, 19, - 21, 27, 23, - 24, 23, 27, - 25, 144, 24, - 19, 24, 144, - 24, 27, 30, - 25, 24, 30, - 26, 30, 27, - 27, 28, 26, - 36, 38, 97, - 26, 34, 30, - 29, 30, 34, - 30, 29, 25, - 25, 29, 145, - 31, 145, 29, - 31, 29, 35, - 29, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 33, 38, 35, - 35, 36, 31, - 36, 35, 38, - 37, 36, 97, - 37, 146, 36, - 31, 36, 146, - 28, 16, 43, - 38, 40, 39, - 39, 97, 38, - 40, 38, 33, - 21, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 21, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 44, 40, 33, - 13, 12, 44, - 40, 44, 12, + 8, 12, 13, // 1 + 0, 1, 2, // 1 + 3, 0, 2, // 1 + 4, 0, 3, // 1 + 5, 2, 6, // 1 + 2, 5, 3, // 1 + 7, 8, 9, // + 8, 7, 10, // + 11, 8, 10, // + 12, 8, 11, // + 9, 8, 13, // + 13, 14, 9, // + 14, 141, 9, // + 5, 6, 15, // + 5, 16, 3, // + 16, 5, 17, // + 17, 5, 15, // + 14, 15, 141, // + 15, 14, 17, // + 18, 14, 13, // + 14, 18, 17, // + 19, 142, 20, // + 19, 20, 23, // + 28, 27, 21, // + 21, 23, 22, // + 22, 41, 21, // + 20, 22, 23, // + 23, 24, 19, // + 21, 27, 23, // + 24, 23, 27, // + 25, 144, 24, // + 19, 24, 144, // + 24, 27, 30, // + 25, 24, 30, // + 26, 30, 27, // + 27, 28, 26, // + 36, 38, 97, // + 26, 34, 30, // + 29, 30, 34, // + 30, 29, 25, // + 25, 29, 145, // + 31, 145, 29, // + 31, 29, 35, // + 29, 34, 35, // + 32, 34, 26, // + 33, 35, 34, // + 34, 32, 33, // + 33, 38, 35, // + 35, 36, 31, // + 36, 35, 38, // + 37, 36, 97, // + 37, 146, 36, // + 31, 36, 146, // + 28, 16, 43, // + 38, 40, 39, // + 39, 97, 38, // + 40, 38, 33, // + 21, 41, 42, // + 41, 4, 42, // + 3, 42, 4, // + 42, 28, 21, // + 28, 42, 16, // + 3, 16, 42, // + 26, 28, 43, // + 17, 43, 16, // + 43, 32, 26, // + 32, 43, 18, // + 17, 18, 43, // + 33, 32, 44, // + 32, 18, 44, // + 13, 44, 18, // + 44, 40, 33, // + 13, 12, 44, // + 40, 44, 12, // 39, 40, 45, 40, 12, 45, 48, 31, 146, diff --git a/src/game/paintings.c b/src/game/paintings.c index 8c1aadfa55..c961e1c442 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -29,7 +29,7 @@ * * The ripple effect uses data that is split into several parts: * In bin/segment2.c: - * painting_data_mesh: The mesh positions are generated from a base mesh. + * painting_data_vertices: The mesh positions are generated from a base mesh. * painting_data_mesh_neighbor_tris: The lighting for the ripple is also generated from a base table. * Each painting's texture uses yet another table to determine the order to map its texture to the mesh. * In levels/[LEVEL]/painting.inc.c: @@ -112,7 +112,7 @@ const struct RippleAnimationPair sRippleAnimations[] = { * vN x, vN y, movable * Where x and y are from 0 to PAINTING_SIZE, movable is 0 or 1. * - * The mesh used in game, painting_data_mesh, is in bin/segment2.c. + * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { const struct PaintingImage *paintingImage = obj->oPaintingImage; @@ -183,7 +183,7 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, Pa * triN v0, triN v1, triN v2 * Where each v0, v1, v2 is an index into the first list in `mesh`. * - * The mesh used in game, painting_data_mesh, is in bin/segment2.c. + * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData i; @@ -515,7 +515,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain */ Gfx *display_painting_rippling(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; - const PaintingData *meshData = segmented_to_virtual(painting_data_mesh); + const PaintingData *meshData = segmented_to_virtual(painting_data_vertices); const PaintingData *triangleData = segmented_to_virtual(painting_data_triangles_1); const PaintingData *neighborTris = segmented_to_virtual(painting_data_mesh_neighbor_tris); PaintingData numVtx = meshData[0]; diff --git a/src/game/segment2.h b/src/game/segment2.h index e55594d079..976de1e326 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -45,7 +45,7 @@ extern Gfx dl_paintings_textured_vertex_colored_begin[]; extern Gfx dl_paintings_textured_end[]; extern Gfx dl_paintings_env_mapped_begin[]; extern Gfx dl_paintings_env_mapped_end[]; -extern PaintingData painting_data_mesh[]; +extern PaintingData painting_data_vertices[]; extern PaintingData painting_data_mesh_neighbor_tris[]; extern PaintingData painting_data_triangles_1[]; extern PaintingData *const painting_data_triangles_1_array[]; From dbfb89d19c1a6dc13578262a3d2477c41aa09755 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 14 Dec 2022 15:35:29 -0500 Subject: [PATCH 58/81] Update some variable names --- src/game/paintings.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index c961e1c442..8e6602cbb1 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -114,7 +114,7 @@ const struct RippleAnimationPair sRippleAnimations[] = { * * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ -void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { +void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { const struct PaintingImage *paintingImage = obj->oPaintingImage; const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; PaintingData i, tri; @@ -142,11 +142,11 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, Pa // Accesses are off by 1 since the first entry is the number of vertices. for (i = 0; i < numVtx; i++) { tri = (i * 3); - paintingMesh->pos[0] = meshData[tri + 1]; - paintingMesh->pos[1] = meshData[tri + 2]; + paintingMesh->pos[0] = vtxData[tri + 1]; + paintingMesh->pos[1] = vtxData[tri + 2]; // The "Z coordinate" of each vertex in the mesh is either 1 or 0. Instead of being an // actual coordinate, it just determines whether the vertex moves. - if (meshData[tri + 3]) { + if (vtxData[tri + 3]) { // Scale and calculate the distance to the ripple origin. dx = ((paintingMesh->pos[0] * sizeRatioX) - rippleX); dy = ((paintingMesh->pos[1] * sizeRatioY) - rippleY); @@ -185,21 +185,21 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *meshData, Pa * * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { - PaintingData i; - Vec3s v; - Vec3f vp0, vp1, vp2; +void painting_calculate_triangle_normals(const PaintingData *triangleData, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { + PaintingData i, j; + Vec3s vi; // Vertex indices + Vec3f vp[3]; // Vertex positions for (i = 0; i < numTris; i++) { // Add 2 because of the 2 length entries preceding the list. PaintingData tri = (1 + (i * 3)); - vec3s_copy(v, &meshData[tri]); - vec3s_to_vec3f(vp0, paintingMesh[v[0]].pos); - vec3s_to_vec3f(vp1, paintingMesh[v[1]].pos); - vec3s_to_vec3f(vp2, paintingMesh[v[2]].pos); + vec3s_copy(vi, &triangleData[tri]); + for (j = 0; j < 3; j++) { + vec3s_to_vec3f(vp[j], paintingMesh[vi[j]].pos); + } // Cross product to find each triangle's normal vector. - find_vector_perpendicular_to_plane(paintingTriNorms[i], vp0, vp1, vp2); + find_vector_perpendicular_to_plane(paintingTriNorms[i], vp[0], vp[1], vp[2]); } } @@ -213,8 +213,8 @@ void painting_calculate_triangle_normals(const PaintingData *meshData, PaintingD * The table is a list of entries in this format: * numNeighbors, tri0, tri1, ..., triN * - * Where each 'tri' is an index into sPaintingTriNorms. - * Entry i in `neighborTris` corresponds to the vertex at sPaintingMesh[i] + * Where each 'tri' is an index into paintingTriNorms. + * Entry i in `neighborTris` corresponds to the vertex at paintingMesh[i] * * The table used in game, painting_data_mesh_neighbor_tris, is in bin/segment2.c. */ @@ -263,7 +263,7 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD * * If the triangleMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole painting. */ -Gfx *render_painting(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *triangleMap, Alpha alpha, struct PaintingMeshVertex *paintingMesh) { +Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *triangleMap, Alpha alpha, struct PaintingMeshVertex *paintingMesh) { struct PaintingMeshVertex *currVtx = NULL; PaintingData group; PaintingData groupIndex; @@ -498,7 +498,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain for (i = 0; i < imageCount; i++) { triangleMap = segmented_to_virtual(triangleMaps[i]); // Render a section of the painting. - gSPDisplayList(gfx++, render_painting(tArray[i], i, imageCount, tWidth, tHeight, triangleMap, paintingImage->alpha, paintingMesh)); + gSPDisplayList(gfx++, render_painting_segment(tArray[i], i, imageCount, tWidth, tHeight, triangleMap, paintingImage->alpha, paintingMesh)); } gSPPopMatrix(gfx++, G_MTX_MODELVIEW); @@ -515,10 +515,10 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain */ Gfx *display_painting_rippling(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; - const PaintingData *meshData = segmented_to_virtual(painting_data_vertices); + const PaintingData *vtxData = segmented_to_virtual(painting_data_vertices); const PaintingData *triangleData = segmented_to_virtual(painting_data_triangles_1); const PaintingData *neighborTris = segmented_to_virtual(painting_data_mesh_neighbor_tris); - PaintingData numVtx = meshData[0]; + PaintingData numVtx = vtxData[0]; PaintingData numTris = triangleData[0]; Gfx *dlist = NULL; // When a painting is rippling, this mesh is generated each frame using the Painting's parameters. @@ -529,7 +529,7 @@ Gfx *display_painting_rippling(struct Object *obj) { Vec3f *paintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); // Generate the mesh and its lighting data - painting_generate_mesh(obj, meshData, numVtx, paintingMesh); + painting_generate_mesh(obj, vtxData, numVtx, paintingMesh); painting_calculate_triangle_normals(triangleData, numTris, paintingMesh, paintingTriNorms); painting_average_vertex_normals(neighborTris, numVtx, paintingMesh, paintingTriNorms); From 98a413af2382102056018ee0530f27d4ac651c5a Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 14 Dec 2022 18:10:45 -0500 Subject: [PATCH 59/81] Fix some typos/formatting --- bin/segment2.c | 6 +++--- src/game/paintings.c | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index deb99e94ab..c6de3a6d81 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3269,7 +3269,7 @@ const PaintingData painting_data_mesh_neighbor_tris[] = { // 0x07022660 - 0x07023042 const PaintingData painting_data_triangles_1[] = { - 264, // num groups + 264, // num triangles // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles 8, 12, 13, // 1 @@ -3545,7 +3545,7 @@ const PaintingData *const painting_data_triangles_1_array[] = { // 0x07021AE0 - 0x07021FFA const PaintingData painting_data_triangles_2_bottom[] = { - 132, // num groups + 132, // num triangles // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles 60, 59, 52, @@ -3684,7 +3684,7 @@ const PaintingData painting_data_triangles_2_bottom[] = { // 0x07021FFC - 0x07022516 const PaintingData painting_data_triangles_2_top[] = { - 132, // num groups + 132, // num triangles // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles 9, 8, 13, diff --git a/src/game/paintings.c b/src/game/paintings.c index 8e6602cbb1..d8a2476ec7 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -52,7 +52,7 @@ */ /** - * Array of pointers to painting data structs. + * Array of pointers to painting image data structs. */ const struct PaintingImage *sPaintings[] = { [PAINTING_ID_NULL ] = NULL, @@ -187,7 +187,7 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai */ void painting_calculate_triangle_normals(const PaintingData *triangleData, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData i, j; - Vec3s vi; // Vertex indices + s16 vi[3]; // Vertex indices Vec3f vp[3]; // Vertex positions for (i = 0; i < numTris; i++) { @@ -262,8 +262,10 @@ void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingD * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, using 'triangleMap'. * * If the triangleMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole painting. + * + * TODO: Automatically create seams between segments based on the image count. */ -Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, const PaintingData *triangleMap, Alpha alpha, struct PaintingMeshVertex *paintingMesh) { +Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, struct PaintingMeshVertex *paintingMesh, const PaintingData *triangleMap, PaintingData numTris, Alpha alpha) { struct PaintingMeshVertex *currVtx = NULL; PaintingData group; PaintingData groupIndex; @@ -272,13 +274,11 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 PaintingData meshVtx; s16 tx, ty; - PaintingData mapTris = triangleMap[0]; - // We can fit VTX_PER_GRP vertices in the RSP's vertex buffer. // Group triangles by TRI_PER_GRP, with one remainder group. - PaintingData triGroups = (mapTris / TRI_PER_GRP); - PaintingData remGroupTris = (mapTris % TRI_PER_GRP); - PaintingData numVtx = (mapTris * 3); // 3 verts per tri + PaintingData triGroups = (numTris / TRI_PER_GRP); + PaintingData remGroupTris = (numTris % TRI_PER_GRP); + PaintingData numVtx = (numTris * 3); // 3 verts per tri Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); u32 gfxCmds = ( @@ -498,7 +498,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain for (i = 0; i < imageCount; i++) { triangleMap = segmented_to_virtual(triangleMaps[i]); // Render a section of the painting. - gSPDisplayList(gfx++, render_painting_segment(tArray[i], i, imageCount, tWidth, tHeight, triangleMap, paintingImage->alpha, paintingMesh)); + gSPDisplayList(gfx++, render_painting_segment(tArray[i], i, imageCount, tWidth, tHeight, paintingMesh, triangleMap, triangleMap[0], paintingImage->alpha)); } gSPPopMatrix(gfx++, G_MTX_MODELVIEW); @@ -690,7 +690,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con return NULL; } - // Get the const painting data. + // Get the const painting image data. const struct PaintingImage *paintingImage = obj->oPaintingImage; if (paintingImage == NULL) { @@ -763,7 +763,7 @@ void bhv_painting_init(void) { const struct PaintingImage *paintingImage = segmented_to_virtual(sPaintings[id]); - // Set the object's painting data pointer. + // Set the object's painting image data pointer. obj->oPaintingImage = paintingImage; // Update the painting object's room. @@ -773,7 +773,7 @@ void bhv_painting_init(void) { /// - LOOP - /** - * Check for Mario entering the painting. Returns changed flags. + * Check for Mario entering the painting. Returns changed action. */ s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { struct MarioState *m = gMarioState; @@ -816,7 +816,7 @@ s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { // Detect whether Mario is entering this painting, and set paintingObj accordingly if (newAction == PAINTING_ACT_ENTERED) { - // Mario has entered the painting.aa + // Mario has entered the painting. m->paintingObj = obj; } else if (m->paintingObj == obj) { // Reset m->paintingObj if it's this painting and this painting is not entered. From aaa2250c29967b021f2e0cefaaf3f54560777bb0 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 14 Dec 2022 18:29:17 -0500 Subject: [PATCH 60/81] Automatically determine neighboring triangles for each vertex instead of using a hardcoded list --- bin/segment2.c | 462 +------------------------------------------ src/game/paintings.c | 47 ++--- src/game/paintings.h | 9 + src/game/segment2.h | 5 +- 4 files changed, 37 insertions(+), 486 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index c6de3a6d81..d51c2ba3d9 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3098,456 +3098,12 @@ const PaintingData painting_data_vertices[] = { #undef PDY #undef PAINTING_VERTEX -/* 0x02015444: painting_data_mesh_neighbor_tris - * Lists the neighboring triangles for each vertex in the mesh. - * Used when applying gouraud shading to the generated ripple mesh - * - * Format: - * num neighbors, neighbor0, neighbor1, ... - * The nth entry corresponds to the nth vertex in painting_data_vertices - */ -const PaintingData painting_data_mesh_neighbor_tris[] = { -// ID num, neighbors... - /* 0*/ 3, 1, 2, 3, - /* 1*/ 1, 1, - /* 2*/ 4, 1, 2, 4, 5, - /* 3*/ 6, 2, 3, 5, 14, 59, 62, - /* 4*/ 3, 3, 58, 59, - /* 5*/ 6, 4, 5, 13, 14, 15, 16, - /* 6*/ 2, 4, 13, - /* 7*/ 2, 6, 7, - /* 8*/ 6, 0, 6, 7, 8, 9, 10, - /* 9*/ 4, 6, 10, 11, 12, - /* 10*/ 4, 7, 8, 154, 155, - /* 11*/ 6, 8, 9, 77, 154, 163, 194, - /* 12*/ 6, 0, 9, 72, 73, 75, 77, - /* 13*/ 6, 0, 10, 11, 19, 70, 72, - /* 14*/ 6, 11, 12, 17, 18, 19, 20, - /* 15*/ 4, 13, 16, 17, 18, - /* 16*/ 6, 14, 15, 53, 61, 62, 64, - /* 17*/ 6, 15, 16, 18, 20, 64, 67, - /* 18*/ 6, 19, 20, 66, 67, 69, 70, - /* 19*/ 8, 21, 22, 27, 31, 80, 81, 149, 150, - /* 20*/ 3, 21, 22, 26, - /* 21*/ 6, 23, 24, 25, 28, 57, 60, - /* 22*/ 3, 24, 25, 26, - /* 23*/ 6, 22, 24, 26, 27, 28, 29, - /* 24*/ 6, 27, 29, 30, 31, 32, 33, - /* 25*/ 8, 30, 33, 39, 40, 78, 79, 146, 147, - /* 26*/ 6, 34, 35, 37, 44, 63, 65, - /* 27*/ 6, 23, 28, 29, 32, 34, 35, - /* 28*/ 6, 23, 35, 53, 60, 61, 63, - /* 29*/ 6, 38, 39, 40, 41, 42, 43, - /* 30*/ 6, 32, 33, 34, 37, 38, 39, - /* 31*/ 8, 41, 42, 48, 52, 76, 82, 148, 151, - /* 32*/ 6, 44, 46, 65, 66, 68, 69, - /* 33*/ 6, 45, 46, 47, 56, 68, 71, - /* 34*/ 6, 37, 38, 43, 44, 45, 46, - /* 35*/ 6, 42, 43, 45, 47, 48, 49, - /* 36*/ 6, 36, 48, 49, 50, 51, 52, - /* 37*/ 8, 50, 51, 152, 153, 170, 174, 214, 215, - /* 38*/ 6, 36, 47, 49, 54, 55, 56, - /* 39*/ 6, 54, 55, 74, 169, 178, 196, - /* 40*/ 6, 54, 56, 71, 73, 74, 75, - /* 41*/ 3, 25, 57, 58, - /* 42*/ 6, 57, 58, 59, 60, 61, 62, - /* 43*/ 6, 53, 63, 64, 65, 66, 67, - /* 44*/ 6, 68, 69, 70, 71, 72, 73, - /* 45*/ 6, 74, 75, 77, 194, 195, 196, - /* 46*/ 6, 79, 82, 125, 137, 146, 148, - /* 47*/ 6, 78, 80, 129, 130, 147, 149, - /* 48*/ 6, 76, 144, 145, 151, 152, 153, - /* 49*/ 3, 84, 85, 86, - /* 50*/ 1, 85, - /* 51*/ 4, 85, 86, 91, 95, - /* 52*/ 6, 83, 87, 88, 90, 119, 124, - /* 53*/ 3, 84, 87, 88, - /* 54*/ 6, 89, 91, 92, 93, 94, 95, - /* 55*/ 6, 84, 86, 87, 89, 90, 91, - /* 56*/ 4, 93, 94, 101, 105, - /* 57*/ 2, 94, 95, - /* 58*/ 6, 96, 97, 100, 108, 126, 131, - /* 59*/ 6, 83, 89, 90, 92, 96, 97, - /* 60*/ 6, 83, 97, 123, 124, 126, 127, - /* 61*/ 6, 99, 101, 102, 103, 104, 105, - /* 62*/ 6, 92, 93, 96, 99, 100, 101, - /* 63*/ 4, 98, 103, 104, 110, - /* 64*/ 2, 104, 105, - /* 65*/ 6, 99, 100, 102, 106, 107, 108, - /* 66*/ 6, 106, 107, 111, 117, 134, 138, - /* 67*/ 6, 106, 108, 131, 132, 134, 135, - /* 68*/ 6, 98, 109, 110, 112, 113, 114, - /* 69*/ 6, 102, 103, 107, 109, 110, 111, - /* 70*/ 4, 113, 114, 221, 223, - /* 71*/ 2, 98, 114, - /* 72*/ 6, 115, 116, 142, 213, 226, 236, - /* 73*/ 6, 109, 111, 112, 115, 116, 117, - /* 74*/ 6, 116, 117, 138, 140, 141, 142, - /* 75*/ 3, 88, 118, 119, - /* 76*/ 6, 120, 121, 122, 130, 149, 150, - /* 77*/ 3, 118, 120, 121, - /* 78*/ 6, 118, 119, 120, 122, 123, 124, - /* 79*/ 6, 125, 128, 129, 133, 146, 147, - /* 80*/ 6, 122, 123, 127, 128, 129, 130, - /* 81*/ 6, 126, 127, 128, 131, 132, 133, - /* 82*/ 6, 136, 137, 139, 145, 148, 151, - /* 83*/ 6, 125, 132, 133, 135, 136, 137, - /* 84*/ 6, 134, 135, 136, 138, 139, 140, - /* 85*/ 6, 143, 144, 153, 215, 246, 252, - /* 86*/ 6, 139, 140, 141, 143, 144, 145, - /* 87*/ 6, 154, 155, 162, 163, 164, 165, - /* 88*/ 1, 157, - /* 89*/ 3, 157, 158, 159, - /* 90*/ 4, 157, 159, 160, 161, - /* 91*/ 6, 158, 159, 160, 167, 205, 206, - /* 92*/ 6, 156, 160, 161, 166, 167, 168, - /* 93*/ 6, 162, 163, 194, 195, 197, 199, - /* 94*/ 6, 162, 164, 166, 168, 199, 202, - /* 95*/ 4, 156, 164, 165, 166, - /* 96*/ 6, 167, 168, 201, 202, 204, 205, - /* 97*/ 6, 36, 50, 55, 169, 170, 171, - /* 98*/ 6, 170, 171, 172, 173, 174, 175, - /* 99*/ 8, 172, 173, 180, 184, 209, 210, 211, 212, - /*100*/ 6, 176, 177, 179, 188, 198, 200, - /*101*/ 6, 169, 171, 175, 176, 177, 178, - /*102*/ 6, 177, 178, 195, 196, 197, 198, - /*103*/ 6, 172, 175, 176, 179, 180, 181, - /*104*/ 6, 180, 181, 182, 183, 184, 185, - /*105*/ 8, 182, 183, 189, 192, 216, 217, 218, 219, - /*106*/ 6, 186, 187, 190, 193, 203, 207, - /*107*/ 6, 179, 181, 185, 186, 187, 188, - /*108*/ 6, 187, 188, 200, 201, 203, 204, - /*109*/ 6, 182, 185, 186, 189, 190, 191, - /*110*/ 3, 189, 191, 192, - /*111*/ 3, 193, 207, 208, - /*112*/ 6, 197, 198, 199, 200, 201, 202, - /*113*/ 6, 203, 204, 205, 206, 207, 208, - /*114*/ 6, 209, 210, 250, 251, 253, 258, - /*115*/ 6, 210, 211, 217, 219, 247, 258, - /*116*/ 6, 209, 212, 214, 215, 251, 252, - /*117*/ 3, 216, 218, 263, - /*118*/ 6, 218, 219, 247, 259, 261, 263, - /*119*/ 6, 220, 221, 222, 223, 224, 225, - /*120*/ 6, 112, 113, 115, 213, 220, 221, - /*121*/ 2, 223, 224, - /*122*/ 4, 224, 225, 230, 235, - /*123*/ 6, 226, 227, 236, 245, 248, 249, - /*124*/ 6, 213, 220, 222, 226, 227, 228, - /*125*/ 6, 227, 228, 231, 239, 249, 255, - /*126*/ 6, 229, 230, 232, 233, 234, 235, - /*127*/ 6, 222, 225, 228, 229, 230, 231, - /*128*/ 2, 233, 235, - /*129*/ 4, 233, 234, 241, 243, - /*130*/ 6, 237, 238, 242, 244, 257, 262, - /*131*/ 6, 229, 231, 232, 237, 238, 239, - /*132*/ 6, 238, 239, 254, 255, 256, 257, - /*133*/ 3, 240, 241, 243, - /*134*/ 6, 232, 234, 237, 240, 241, 242, - /*135*/ 3, 244, 260, 262, - /*136*/ 6, 141, 142, 143, 236, 245, 246, - /*137*/ 6, 245, 246, 248, 250, 251, 252, - /*138*/ 6, 248, 249, 250, 253, 254, 255, - /*139*/ 6, 247, 253, 254, 256, 258, 259, - /*140*/ 6, 256, 257, 259, 260, 261, 262, - /*141*/ 2, 12, 17, - /*142*/ 2, 21, 81, - /*143*/ 3, 81, 121, 150, - /*144*/ 4, 30, 31, 78, 80, - /*145*/ 4, 40, 41, 79, 82, - /*146*/ 4, 51, 52, 76, 152, - /*147*/ 2, 155, 165, - /*148*/ 3, 158, 206, 208, - /*149*/ 2, 156, 161, - /*150*/ 4, 173, 174, 212, 214, - /*151*/ 4, 183, 184, 211, 217, - /*152*/ 3, 190, 191, 193, - /*153*/ 2, 192, 216, - /*154*/ 3, 260, 261, 263, - /*155*/ 3, 240, 242, 244, - /*156*/ 1, 243, -}; - // 0x07022660 - 0x07023042 -const PaintingData painting_data_triangles_1[] = { +const PaintingData painting_data_triangles[] = { 264, // num triangles // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles - 8, 12, 13, // 1 - 0, 1, 2, // 1 - 3, 0, 2, // 1 - 4, 0, 3, // 1 - 5, 2, 6, // 1 - 2, 5, 3, // 1 - 7, 8, 9, // - 8, 7, 10, // - 11, 8, 10, // - 12, 8, 11, // - 9, 8, 13, // - 13, 14, 9, // - 14, 141, 9, // - 5, 6, 15, // - 5, 16, 3, // - 16, 5, 17, // - 17, 5, 15, // - 14, 15, 141, // - 15, 14, 17, // - 18, 14, 13, // - 14, 18, 17, // - 19, 142, 20, // - 19, 20, 23, // - 28, 27, 21, // - 21, 23, 22, // - 22, 41, 21, // - 20, 22, 23, // - 23, 24, 19, // - 21, 27, 23, // - 24, 23, 27, // - 25, 144, 24, // - 19, 24, 144, // - 24, 27, 30, // - 25, 24, 30, // - 26, 30, 27, // - 27, 28, 26, // - 36, 38, 97, // - 26, 34, 30, // - 29, 30, 34, // - 30, 29, 25, // - 25, 29, 145, // - 31, 145, 29, // - 31, 29, 35, // - 29, 34, 35, // - 32, 34, 26, // - 33, 35, 34, // - 34, 32, 33, // - 33, 38, 35, // - 35, 36, 31, // - 36, 35, 38, // - 37, 36, 97, // - 37, 146, 36, // - 31, 36, 146, // - 28, 16, 43, // - 38, 40, 39, // - 39, 97, 38, // - 40, 38, 33, // - 21, 41, 42, // - 41, 4, 42, // - 3, 42, 4, // - 42, 28, 21, // - 28, 42, 16, // - 3, 16, 42, // - 26, 28, 43, // - 17, 43, 16, // - 43, 32, 26, // - 32, 43, 18, // - 17, 18, 43, // - 33, 32, 44, // - 32, 18, 44, // - 13, 44, 18, // - 44, 40, 33, // - 13, 12, 44, // - 40, 44, 12, // - 39, 40, 45, - 40, 12, 45, - 48, 31, 146, - 11, 45, 12, - 25, 47, 144, - 46, 25, 145, - 47, 19, 144, - 19, 143, 142, - 31, 46, 145, - 60, 59, 52, - 49, 53, 55, - 50, 49, 51, - 51, 49, 55, - 52, 55, 53, - 53, 75, 52, - 54, 55, 59, - 52, 59, 55, - 55, 54, 51, - 54, 59, 62, - 56, 54, 62, - 57, 54, 56, - 54, 57, 51, - 58, 62, 59, - 59, 60, 58, - 68, 71, 63, - 61, 62, 65, - 58, 65, 62, - 62, 61, 56, - 61, 65, 69, - 63, 61, 69, - 64, 61, 63, - 61, 64, 56, - 65, 67, 66, - 66, 69, 65, - 67, 65, 58, - 68, 69, 73, - 69, 68, 63, - 66, 73, 69, - 68, 73, 120, - 70, 68, 120, - 71, 68, 70, - 72, 120, 73, - 73, 74, 72, - 74, 73, 66, - 75, 77, 78, - 52, 75, 78, - 76, 78, 77, - 77, 143, 76, - 76, 80, 78, - 60, 78, 80, - 78, 60, 52, - 46, 83, 79, - 58, 60, 81, - 60, 80, 81, - 79, 81, 80, - 80, 47, 79, - 47, 80, 76, - 81, 67, 58, - 67, 81, 83, - 79, 83, 81, - 66, 67, 84, - 67, 83, 84, - 82, 84, 83, - 83, 46, 82, - 84, 74, 66, - 82, 86, 84, - 74, 84, 86, - 74, 86, 136, - 72, 74, 136, - 85, 136, 86, - 86, 48, 85, - 48, 86, 82, - 25, 46, 79, - 79, 47, 25, - 82, 46, 31, - 19, 47, 76, - 76, 143, 19, - 31, 48, 82, - 37, 48, 146, - 85, 48, 37, - 10, 87, 11, - 87, 10, 147, - 92, 95, 149, - 88, 89, 90, - 89, 148, 91, - 90, 89, 91, - 91, 92, 90, - 92, 149, 90, - 93, 87, 94, - 87, 93, 11, - 94, 87, 95, - 87, 147, 95, - 95, 92, 94, - 96, 92, 91, - 92, 96, 94, - 39, 101, 97, - 97, 98, 37, - 98, 97, 101, - 99, 98, 103, - 99, 150, 98, - 37, 98, 150, - 98, 101, 103, - 100, 103, 101, - 101, 102, 100, - 102, 101, 39, - 100, 107, 103, - 103, 104, 99, - 104, 103, 107, - 105, 104, 109, - 105, 151, 104, - 99, 104, 151, - 104, 107, 109, - 106, 109, 107, - 107, 108, 106, - 108, 107, 100, - 109, 110, 105, - 106, 152, 109, - 110, 109, 152, - 105, 110, 153, - 111, 152, 106, - 11, 93, 45, - 102, 45, 93, - 45, 102, 39, - 102, 93, 112, - 100, 102, 112, - 94, 112, 93, - 112, 108, 100, - 108, 112, 96, - 94, 96, 112, - 106, 108, 113, - 108, 96, 113, - 91, 113, 96, - 91, 148, 113, - 113, 111, 106, - 111, 113, 148, - 114, 116, 99, - 99, 115, 114, - 115, 99, 151, - 99, 116, 150, - 72, 124, 120, - 116, 37, 150, - 37, 116, 85, - 117, 105, 153, - 105, 115, 151, - 105, 117, 118, - 118, 115, 105, - 119, 120, 124, - 120, 119, 70, - 119, 124, 127, - 119, 121, 70, - 121, 119, 122, - 122, 119, 127, - 123, 124, 72, - 124, 123, 125, - 125, 127, 124, - 126, 127, 131, - 127, 126, 122, - 125, 131, 127, - 126, 131, 134, - 128, 126, 129, - 129, 126, 134, - 126, 128, 122, - 136, 123, 72, - 130, 134, 131, - 131, 132, 130, - 132, 131, 125, - 133, 134, 155, - 134, 133, 129, - 130, 155, 134, - 133, 156, 129, - 135, 155, 130, - 123, 136, 137, - 85, 137, 136, - 139, 115, 118, - 123, 137, 138, - 125, 123, 138, - 114, 138, 137, - 137, 116, 114, - 116, 137, 85, - 114, 139, 138, - 132, 138, 139, - 138, 132, 125, - 132, 139, 140, - 130, 132, 140, - 115, 139, 114, - 118, 140, 139, - 135, 140, 154, - 118, 154, 140, - 140, 135, 130, - 117, 154, 118, -}; - -// 0x07023044 - 0x07023048 -const PaintingData *const painting_data_triangles_1_array[] = { - painting_data_triangles_1, -}; - -// 0x07021AE0 - 0x07021FFA -const PaintingData painting_data_triangles_2_bottom[] = { - 132, // num triangles - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles + // Bottom half 60, 59, 52, 49, 53, 55, 50, 49, 51, @@ -3680,13 +3236,7 @@ const PaintingData painting_data_triangles_2_bottom[] = { 116, 37, 150, 99, 116, 150, 105, 117, 118, -}; - -// 0x07021FFC - 0x07022516 -const PaintingData painting_data_triangles_2_top[] = { - 132, // num triangles - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles + // Top half 9, 8, 13, 0, 1, 2, 3, 0, 2, @@ -3820,9 +3370,3 @@ const PaintingData painting_data_triangles_2_top[] = { 91, 148, 113, 113, 111, 106, }; - -// 0x07022518 -const PaintingData *const painting_data_triangles_2_array[] = { - painting_data_triangles_2_bottom, - painting_data_triangles_2_top, -}; diff --git a/src/game/paintings.c b/src/game/paintings.c index d8a2476ec7..57cdff0ec8 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -185,8 +185,9 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai * * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(const PaintingData *triangleData, PaintingData numTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { +void painting_calculate_triangle_normals(const PaintingData *triangleData, struct PaintingNeighborTris *neighborTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData i, j; + PaintingData numTris = triangleData[0]; s16 vi[3]; // Vertex indices Vec3f vp[3]; // Vertex positions @@ -196,6 +197,10 @@ void painting_calculate_triangle_normals(const PaintingData *triangleData, Paint vec3s_copy(vi, &triangleData[tri]); for (j = 0; j < 3; j++) { vec3s_to_vec3f(vp[j], paintingMesh[vi[j]].pos); + struct PaintingNeighborTris *vtn = &neighborTris[vi[j]]; + if (vtn->numNeighbors < ARRAY_COUNT(vtn->neighborTris)) { + vtn->neighborTris[vtn->numNeighbors++] = i; + } } // Cross product to find each triangle's normal vector. @@ -218,25 +223,23 @@ void painting_calculate_triangle_normals(const PaintingData *triangleData, Paint * * The table used in game, painting_data_mesh_neighbor_tris, is in bin/segment2.c. */ -void painting_average_vertex_normals(const PaintingData *neighborTris, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { +void painting_average_vertex_normals(struct PaintingNeighborTris *neighborTris, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { PaintingData tri; PaintingData i, j; PaintingData numNeighbors; - PaintingData entry = 0; for (i = 0; i < numVtx; i++) { Vec3f n = { 0.0f, 0.0f, 0.0f }; // The first number of each entry is the number of adjacent tris. - numNeighbors = neighborTris[entry]; + struct PaintingNeighborTris *vtn = &neighborTris[i]; + numNeighbors = vtn->numNeighbors; + for (j = 0; j < numNeighbors; j++) { - tri = neighborTris[entry + 1 + j]; + tri = vtn->neighborTris[j]; vec3f_add(n, paintingTriNorms[tri]); } - // Move to the next vertex's entry - entry += (1 + numNeighbors); - // Average the surface normals from each neighboring tri. vec3_div_val(n, numNeighbors); f32 nlen = vec3_sumsq(n); @@ -453,9 +456,8 @@ void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { /** * Ripple a painting that has 1 or more images that need to be mapped. */ -Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct PaintingMeshVertex *paintingMesh) { +Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct PaintingMeshVertex *paintingMesh, const PaintingData *triangleMap) { s16 i; - const PaintingData *triangleMap = NULL; s16 imageCount = paintingImage->imageCount; s16 tWidth = paintingImage->textureWidth; s16 tHeight = paintingImage->textureHeight; @@ -485,20 +487,15 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); - //! TODO: Automatically create triangle maps based on the image count. - const PaintingData **triangleMaps = NULL; - switch (imageCount) { - case 1: triangleMaps = segmented_to_virtual(painting_data_triangles_1_array); break; - case 2: triangleMaps = segmented_to_virtual(painting_data_triangles_2_array); break; - } - painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); + PaintingData numTris = (triangleMap[0] / imageCount); // Map each image to the mesh's vertices. for (i = 0; i < imageCount; i++) { - triangleMap = segmented_to_virtual(triangleMaps[i]); // Render a section of the painting. - gSPDisplayList(gfx++, render_painting_segment(tArray[i], i, imageCount, tWidth, tHeight, paintingMesh, triangleMap, triangleMap[0], paintingImage->alpha)); + gSPDisplayList(gfx++, render_painting_segment(tArray[i], i, imageCount, tWidth, tHeight, paintingMesh, triangleMap, numTris, paintingImage->alpha)); + + triangleMap += (numTris * 3); } gSPPopMatrix(gfx++, G_MTX_MODELVIEW); @@ -516,28 +513,32 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain Gfx *display_painting_rippling(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; const PaintingData *vtxData = segmented_to_virtual(painting_data_vertices); - const PaintingData *triangleData = segmented_to_virtual(painting_data_triangles_1); - const PaintingData *neighborTris = segmented_to_virtual(painting_data_mesh_neighbor_tris); + const PaintingData *triangleData = segmented_to_virtual(painting_data_triangles); PaintingData numVtx = vtxData[0]; PaintingData numTris = triangleData[0]; Gfx *dlist = NULL; // When a painting is rippling, this mesh is generated each frame using the Painting's parameters. // This mesh only contains the vertex positions and normals. // Paintings use an additional array to map textures to the mesh. + //! TODO: Find out why clearing this causes flickering. struct PaintingMeshVertex *paintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); + // A list of neighbor triangles for each vertes. This gets cleared each frame while 'paintingMesh' isn't. + struct PaintingNeighborTris *neighborTris = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingNeighborTris))); + bzero(neighborTris, (numVtx * sizeof(struct PaintingNeighborTris))); // The painting's surface normals, used to approximate each of the vertex normals (for gouraud shading). Vec3f *paintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); // Generate the mesh and its lighting data painting_generate_mesh(obj, vtxData, numVtx, paintingMesh); - painting_calculate_triangle_normals(triangleData, numTris, paintingMesh, paintingTriNorms); + painting_calculate_triangle_normals(triangleData, neighborTris, paintingMesh, paintingTriNorms); painting_average_vertex_normals(neighborTris, numVtx, paintingMesh, paintingTriNorms); // Map the painting's texture depending on the painting's texture type. - dlist = dl_painting_rippling(paintingImage, paintingMesh); + dlist = dl_painting_rippling(paintingImage, paintingMesh, triangleData); // The mesh data is freed every frame. mem_pool_free(gEffectsMemoryPool, paintingMesh); + mem_pool_free(gEffectsMemoryPool, neighborTris); mem_pool_free(gEffectsMemoryPool, paintingTriNorms); return dlist; diff --git a/src/game/paintings.h b/src/game/paintings.h index ca74000da2..c889356443 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -139,6 +139,15 @@ struct PaintingMeshVertex { /*0x06*/ Vec3c norm; }; /*0x0C*/ +/** + * Lists the neighboring triangles for each vertex in the mesh. + * Used when applying gouraud shading to the generated ripple mesh. + */ +struct PaintingNeighborTris { + /*0x00*/ s16 numNeighbors; + /*0x02*/ s16 neighborTris[9]; +}; /*0x14*/ + Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); diff --git a/src/game/segment2.h b/src/game/segment2.h index 976de1e326..ba2db4b23f 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -46,10 +46,7 @@ extern Gfx dl_paintings_textured_end[]; extern Gfx dl_paintings_env_mapped_begin[]; extern Gfx dl_paintings_env_mapped_end[]; extern PaintingData painting_data_vertices[]; -extern PaintingData painting_data_mesh_neighbor_tris[]; -extern PaintingData painting_data_triangles_1[]; -extern PaintingData *const painting_data_triangles_1_array[]; -extern PaintingData *const painting_data_triangles_2_array[]; +extern PaintingData painting_data_triangles[]; extern Texture *main_hud_lut[58]; extern Gfx dl_hud_img_load_tex_block[]; extern Gfx dl_hud_img_begin[]; From 09ca176cb9581d89af09429a03fed300302250bd Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 14 Dec 2022 18:36:35 -0500 Subject: [PATCH 61/81] Rename 'PaintingIDs' to 'PaintingImageIDs' --- src/game/paintings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/paintings.h b/src/game/paintings.h index c889356443..37cb0a9ba0 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -30,7 +30,7 @@ #define TC(t) (((t) - 1) << 5) -enum PaintingIDs { +enum PaintingImageIDs { /* Painting ID */ /* 0x00 */ PAINTING_ID_NULL, /* 0x01 */ PAINTING_ID_CASTLE_BOB, From be58ea7396d037a5a47b671e1c50655c62f0e9bd Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 14 Dec 2022 21:27:06 -0500 Subject: [PATCH 62/81] WARP_DEST_LEVEL_NUM_MASK Usage --- src/game/level_update.c | 4 ++-- src/game/save_file.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index f95a737fca..60a64fbb56 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -557,7 +557,7 @@ void check_instant_warp(void) { s16 music_unchanged_through_warp(s16 arg) { struct ObjectWarpNode *warpNode = area_get_warp_node(arg); - s16 levelNum = warpNode->node.destLevel & 0x7F; + s16 levelNum = (warpNode->node.destLevel & WARP_DEST_LEVEL_NUM_MASK); s16 destArea = warpNode->node.destArea; s16 unchanged = TRUE; @@ -873,7 +873,7 @@ void initiate_delayed_warp(void) { default: warpNode = area_get_warp_node(sSourceWarpNodeId); - initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea, + initiate_warp((warpNode->node.destLevel & WARP_DEST_LEVEL_NUM_MASK), warpNode->node.destArea, warpNode->node.destNode, sDelayedWarpArg); check_if_should_set_warp_checkpoint(&warpNode->node); diff --git a/src/game/save_file.c b/src/game/save_file.c index 355820206c..7de873d459 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -741,7 +741,7 @@ void check_if_should_set_warp_checkpoint(struct WarpNode *warpNode) { // Overwrite the warp checkpoint variables. gWarpCheckpoint.actNum = gCurrActNum; gWarpCheckpoint.courseNum = gCurrCourseNum; - gWarpCheckpoint.levelID = warpNode->destLevel & 0x7F; + gWarpCheckpoint.levelID = (warpNode->destLevel & WARP_DEST_LEVEL_NUM_MASK); gWarpCheckpoint.areaNum = warpNode->destArea; gWarpCheckpoint.warpNode = warpNode->destNode; } @@ -754,7 +754,7 @@ void check_if_should_set_warp_checkpoint(struct WarpNode *warpNode) { */ s32 check_warp_checkpoint(struct WarpNode *warpNode) { s16 warpCheckpointActive = FALSE; - s16 currCourseNum = gLevelToCourseNumTable[(warpNode->destLevel & 0x7F) - 1]; + s16 currCourseNum = gLevelToCourseNumTable[(warpNode->destLevel & WARP_DEST_LEVEL_NUM_MASK) - 1]; // gSavedCourseNum is only used in this function. if (gWarpCheckpoint.courseNum != COURSE_NONE && gSavedCourseNum == currCourseNum From 23ea8b013058d49d27d1c2239342aecbc1fd479a Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 14 Dec 2022 22:54:59 -0500 Subject: [PATCH 63/81] Add PAINTING_IMAGE_TYPE_INVISIBLE + format PaintingImage structs --- levels/castle_inside/painting.inc.c | 284 +++++++++++++++------------- levels/hmc/areas/1/painting.inc.c | 19 +- levels/ttm/areas/1/painting.inc.c | 19 +- src/game/paintings.c | 9 +- src/game/paintings.h | 34 ++-- 5 files changed, 193 insertions(+), 172 deletions(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 360466f3e0..3ce60e4617 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -108,16 +108,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_bob[] inside_castle_seg7_texture_0700A800, }; -// 0x07023620 - 0x07023698 const struct PaintingImage bob_painting = { - /* Textures */ inside_castle_seg7_painting_textures_bob, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_bob), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_bob, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_bob), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_CCM - @@ -127,16 +128,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ccm[] inside_castle_seg7_texture_0700C800, }; -// 0x07023698 - 0x07023710 const struct PaintingImage ccm_painting = { - /* Textures */ inside_castle_seg7_painting_textures_ccm, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ccm), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_ccm, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_ccm), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_WF - @@ -146,16 +148,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wf[] = inside_castle_seg7_texture_0700E800, }; -// 0x07023710 - 0x07023788 const struct PaintingImage wf_painting = { - /* Textures */ inside_castle_seg7_painting_textures_wf, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wf), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_wf, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_wf), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_JRB - @@ -165,16 +168,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_jrb[] inside_castle_seg7_texture_07010800, }; -// 0x07023788 - 0x07023800 const struct PaintingImage jrb_painting = { - /* Textures */ inside_castle_seg7_painting_textures_jrb, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_jrb), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_jrb, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_jrb), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_LLL - @@ -184,16 +188,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_lll[] inside_castle_seg7_texture_07013800, }; -// 0x07023800 - 0x07023878 const struct PaintingImage lll_painting = { - /* Textures */ inside_castle_seg7_painting_textures_lll, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_lll), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_lll, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_lll), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_SSL - @@ -203,16 +208,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ssl[] inside_castle_seg7_texture_07014800, }; -// 0x07023878 - 0x070238F0 const struct PaintingImage ssl_painting = { - /* Textures */ inside_castle_seg7_painting_textures_ssl, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ssl), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_ssl, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_ssl), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_HMC - @@ -221,16 +227,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_hmc_en inside_castle_seg7_texture_07016800, }; -// 0x070238F0 - 0x07023968 const struct PaintingImage hmc_painting = { - /* Textures */ inside_castle_seg7_painting_textures_hmc_env, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_hmc_env), - /* Texture w, h */ 32, 32, - /* Texture Type */ PAINTING_TYPE_ENV_MAP, - /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 768.0f, 768.0f, + .textureArray = inside_castle_seg7_painting_textures_hmc_env, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_hmc_env), + .textureWidth = 32, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_ENV_MAP, + .rippleTrigger = RIPPLE_TRIGGER_CONTINUOUS, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 768.0f, + .sizeY = 768.0f, }; /// - PAINTING_ID_CASTLE_DDD - @@ -239,16 +246,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ddd_en inside_castle_seg7_texture_07017000, }; -// 0x07023968 - 0x070239E0 const struct PaintingImage ddd_painting = { - /* Textures */ inside_castle_seg7_painting_textures_ddd_env, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ddd_env), - /* Texture w, h */ 32, 32, - /* Texture Type */ PAINTING_TYPE_ENV_MAP, - /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Shaded */ TRUE, - /* Alpha */ 0xB4, - /* Size */ 819.2f, 819.2f, + .textureArray = inside_castle_seg7_painting_textures_ddd_env, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_ddd_env), + .textureWidth = 32, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_ENV_MAP, + .rippleTrigger = RIPPLE_TRIGGER_CONTINUOUS, + .shaded = TRUE, + .alpha = 0xB4, + .sizeX = 819.2f, + .sizeY = 819.2f, }; /// - PAINTING_ID_CASTLE_WDW - @@ -258,16 +266,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_wdw[] inside_castle_seg7_texture_07017800, }; -// 0x070239E0 - 0x07023A58 const struct PaintingImage wdw_painting = { - /* Textures */ inside_castle_seg7_painting_textures_wdw, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_wdw), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 614.0f, 614.0f, + .textureArray = inside_castle_seg7_painting_textures_wdw, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_wdw), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 614.0f, + .sizeY = 614.0f, }; /// - PAINTING_ID_CASTLE_THI_TINY - @@ -277,30 +286,32 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_thi[] inside_castle_seg7_texture_07019800, }; -// 0x07023A58 - 0x07023AD0 const struct PaintingImage thi_tiny_painting = { - /* Textures */ inside_castle_seg7_painting_textures_thi, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 393.216f, 393.216f, + .textureArray = inside_castle_seg7_painting_textures_thi, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 393.216f, + .sizeY = 393.216f, }; /// - PAINTING_ID_CASTLE_THI_HUGE - -// 0x07023C38 - 0x07023CB0 const struct PaintingImage thi_huge_painting = { - /* Textures */ inside_castle_seg7_painting_textures_thi, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 1638.4f, 1638.4f, + .textureArray = inside_castle_seg7_painting_textures_thi, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_thi), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 1638.4f, + .sizeY = 1638.4f, }; /// - PAINTING_ID_CASTLE_TTM - @@ -310,16 +321,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttm[] inside_castle_seg7_texture_0701B800, }; -// 0x07023AD0 - 0x07023B48 const struct PaintingImage ttm_painting = { - /* Textures */ inside_castle_seg7_painting_textures_ttm, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttm), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 256.0f, 256.0f, + .textureArray = inside_castle_seg7_painting_textures_ttm, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_ttm), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 256.0f, + .sizeY = 256.0f, }; /// - PAINTING_ID_CASTLE_TTC - @@ -329,16 +341,17 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_ttc[] inside_castle_seg7_texture_0701D800, }; -// 0x07023B48 - 0x07023BC0 const struct PaintingImage ttc_painting = { - /* Textures */ inside_castle_seg7_painting_textures_ttc, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_ttc), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 409.6f, 409.6f, + .textureArray = inside_castle_seg7_painting_textures_ttc, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_ttc), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 409.6f, + .sizeY = 409.6f, }; /// - PAINTING_ID_CASTLE_SL - @@ -348,27 +361,30 @@ ALIGNED8 static const Texture *const inside_castle_seg7_painting_textures_sl[] = inside_castle_seg7_texture_0701F800, }; -// 0x07023BC0 - 0x07023C38 const struct PaintingImage sl_painting = { - /* Textures */ inside_castle_seg7_painting_textures_sl, - /* Texture Count */ ARRAY_COUNT(inside_castle_seg7_painting_textures_sl), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ FALSE, - /* Alpha */ 0xFF, - /* Size */ 716.8f, 716.8f, + .textureArray = inside_castle_seg7_painting_textures_sl, + .imageCount = ARRAY_COUNT(inside_castle_seg7_painting_textures_sl), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = FALSE, + .alpha = 0xFF, + .sizeX = 716.8f, + .sizeY = 716.8f, }; /// - PAINTING_ID_CASTLE_RR - const struct PaintingImage rr_painting = { - /* Textures */ NULL, - /* Texture Count */ 0, - /* Texture w, h */ 0, 0, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_NONE, - /* Shaded */ TRUE, - /* Alpha */ 0x00, - /* Size */ 204.8f, 204.8f, + .textureArray = NULL, + .imageCount = 0, + .textureWidth = 0, + .textureHeight = 0, + .imageType = PAINTING_IMAGE_TYPE_INVISIBLE, + .rippleTrigger = RIPPLE_TRIGGER_NONE, + .shaded = TRUE, + .alpha = 0x00, + .sizeX = 204.8f, + .sizeY = 204.8f, }; diff --git a/levels/hmc/areas/1/painting.inc.c b/levels/hmc/areas/1/painting.inc.c index 91a4071d18..ce4e475962 100644 --- a/levels/hmc/areas/1/painting.inc.c +++ b/levels/hmc/areas/1/painting.inc.c @@ -12,14 +12,15 @@ const Texture *const hmc_seg7_painting_textures_cotmc[] = { hmc_seg7_texture_cotmc_pool_env, }; -// 0x0702551C (PaintingData) const struct PaintingImage cotmc_painting = { - /* Textures */ hmc_seg7_painting_textures_cotmc, - /* Texture Count */ ARRAY_COUNT(hmc_seg7_painting_textures_cotmc), - /* Texture w, h */ 32, 32, - /* Texture Type */ PAINTING_TYPE_ENV_MAP, - /* Ripple Trigger */ RIPPLE_TRIGGER_CONTINUOUS, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 723.968018f, 723.968018f, + .textureArray = hmc_seg7_painting_textures_cotmc, + .imageCount = ARRAY_COUNT(hmc_seg7_painting_textures_cotmc), + .textureWidth = 32, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_ENV_MAP, + .rippleTrigger = RIPPLE_TRIGGER_CONTINUOUS, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 723.968018f, + .sizeY = 723.968018f, }; diff --git a/levels/ttm/areas/1/painting.inc.c b/levels/ttm/areas/1/painting.inc.c index cd6afcfa5d..04af167fc7 100644 --- a/levels/ttm/areas/1/painting.inc.c +++ b/levels/ttm/areas/1/painting.inc.c @@ -8,14 +8,15 @@ ALIGNED8 static const Texture *const ttm_seg7_painting_textures_slide[] = { ttm_seg7_texture_07003000, }; -// 0x07012F00 (PaintingData) const struct PaintingImage ttm_slide_painting = { - /* Textures */ ttm_seg7_painting_textures_slide, - /* Texture Count */ ARRAY_COUNT(ttm_seg7_painting_textures_slide), - /* Texture w, h */ 64, 32, - /* Texture Type */ PAINTING_TYPE_IMAGE, - /* Ripple Trigger */ RIPPLE_TRIGGER_PROXIMITY, - /* Shaded */ TRUE, - /* Alpha */ 0xFF, - /* Size */ 460.8f, 460.8f, + .textureArray = ttm_seg7_painting_textures_slide, + .imageCount = ARRAY_COUNT(ttm_seg7_painting_textures_slide), + .textureWidth = 64, + .textureHeight = 32, + .imageType = PAINTING_IMAGE_TYPE_TEXTURE, + .rippleTrigger = RIPPLE_TRIGGER_PROXIMITY, + .shaded = TRUE, + .alpha = 0xFF, + .sizeX = 460.8f, + .sizeY = 460.8f, }; diff --git a/src/game/paintings.c b/src/game/paintings.c index 57cdff0ec8..89f6348bc0 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -462,7 +462,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain s16 tWidth = paintingImage->textureWidth; s16 tHeight = paintingImage->textureHeight; const Texture **tArray = segmented_to_virtual(paintingImage->textureArray); - s32 isEnvMap = (paintingImage->textureType == PAINTING_TYPE_ENV_MAP); + s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); u32 gfxCmds = ( /*gSPDisplayList */ 1 + @@ -577,7 +577,7 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { const Texture **textures = segmented_to_virtual(paintingImage->textureArray); - s32 isEnvMap = (paintingImage->textureType == PAINTING_TYPE_ENV_MAP); + s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); if (isEnvMap) { vec3_set(n, 0x00, 0x00, 0x7f); @@ -702,10 +702,11 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con if (callContext == GEO_CONTEXT_RENDER) { // Draw the painting. - if (paintingImage->imageCount > 0 - && paintingImage->textureArray != NULL + if (paintingImage->textureArray != NULL + && paintingImage->imageCount > 0 && paintingImage->textureWidth > 0 && paintingImage->textureHeight > 0 + && paintingImage->imageType != PAINTING_IMAGE_TYPE_INVISIBLE && paintingImage->alpha > 0x00) { // Determine whether the painting is opaque or transparent. if (paintingImage->alpha == 0xFF) { diff --git a/src/game/paintings.h b/src/game/paintings.h index 37cb0a9ba0..d4fa370987 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -59,12 +59,14 @@ enum PaintingRippleAnimations { RIPPLE_ANIM_PROXIMITY_LARGE, }; -// Painting->textureType +// Painting->imageType enum PaintingType { - /// Painting that uses 1 or more images as a texture - PAINTING_TYPE_IMAGE, - /// Painting that has one texture used for an environment map effect - PAINTING_TYPE_ENV_MAP + /// Painting that is invisible. + PAINTING_IMAGE_TYPE_INVISIBLE, + /// Painting that uses 1 or more textures as a texture. + PAINTING_IMAGE_TYPE_TEXTURE, + /// Painting that has one texture used for an environment map effect. + PAINTING_IMAGE_TYPE_ENV_MAP }; // Painting->rippleTrigger @@ -108,27 +110,27 @@ struct PaintingImage { /*0x00*/ const Texture *const *textureArray; /// How many textures the painting uses. - /*0x04*/ s32 imageCount; + /*0x04*/ const s32 imageCount; /// Texture size. - /*0x08*/ s16 textureWidth; - /*0x0A*/ s16 textureHeight; + /*0x08*/ const s16 textureWidth; + /*0x0A*/ const s16 textureHeight; - /// Either PAINTING_TYPE_IMAGE or PAINTING_TYPE_ENV_MAP. - /*0x0C*/ s8 textureType; + /// Controls how the painting image is displayed. PAINTING_IMAGE_TYPE_INVISIBLE, PAINTING_IMAGE_TYPE_TEXTURE, or PAINTING_IMAGE_TYPE_ENV_MAP. + /*0x0C*/ const s8 imageType; - /// Controls when a passive ripple starts. RIPPLE_TRIGGER_NONE, RIPPLE_TRIGGER_CONTINUOUS or RIPPLE_TRIGGER_PROXIMITY. - /*0x0D*/ s8 rippleTrigger; + /// Controls when a passive ripple starts. RIPPLE_TRIGGER_NONE, RIPPLE_TRIGGER_CONTINUOUS, or RIPPLE_TRIGGER_PROXIMITY. + /*0x0D*/ const s8 rippleTrigger; /// Whether the painting uses shading when not rippling. Only used for Snowman's Land in vanilla and makes the transition to/from rippling not seamless. - /*0x0E*/ s8 shaded; + /*0x0E*/ const s8 shaded; /// The painting's transparency (0..255). Determines the drawing layer of the painting. - /*0x0F*/ Alpha alpha; + /*0x0F*/ const Alpha alpha; /// By default a painting is 614.0f x 614.0f (PAINTING_SIZE). - /*0x10*/ f32 sizeX; - /*0x14*/ f32 sizeY; + /*0x10*/ const f32 sizeX; + /*0x14*/ const f32 sizeY; }; /*0x18*/ /** From 3a526ef10fdedf80d90179626d9ea8510982d0d2 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 15 Dec 2022 17:57:03 -0500 Subject: [PATCH 64/81] Center scaled paintings during cutscenes --- src/game/camera.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/game/camera.c b/src/game/camera.c index b02447a144..e71a53e948 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9585,18 +9585,20 @@ void cutscene_enter_painting(struct Camera *c) { if (ripplingPainting != NULL) { const struct PaintingImage *paintingImage = ripplingPainting->oPaintingImage; + f32 sizeX = paintingImage->sizeX; + f32 sizeY = paintingImage->sizeY; vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); - size = ((paintingImage->sizeX + paintingImage->sizeY) / 2.0f); - focusOffset[0] = (size * 0.5f); - focusOffset[1] = focusOffset[0]; + focusOffset[0] = (sizeX * 0.5f); + focusOffset[1] = (sizeY * 0.5f); focusOffset[2] = 0; vec3f_copy(paintingPos, &ripplingPainting->oPosVec); offset_rotated(focus, paintingPos, focusOffset, paintingAngle); approach_vec3f_asymptotic(c->focus, focus, 0.1f, 0.1f, 0.1f); + size = ((sizeX + sizeY) / 2.0f); focusOffset[2] = -(((size * 1000.f) / 2) / 307.f); offset_rotated(focus, paintingPos, focusOffset, paintingAngle); floorHeight = find_floor(focus[0], focus[1] + 500.f, focus[2], &highFloor) + 125.f; From be01f6c5d2e5fa4d563b05830fcad5dafba3599b Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 15 Dec 2022 19:05:35 -0500 Subject: [PATCH 65/81] Use object scale as painting scale instead of painting_model_view_transform --- src/game/camera.c | 5 ++--- src/game/paintings.c | 33 ++++----------------------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/game/camera.c b/src/game/camera.c index e71a53e948..0073496f7a 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9584,9 +9584,8 @@ void cutscene_enter_painting(struct Camera *c) { struct Object *ripplingPainting = gCutsceneFocus; if (ripplingPainting != NULL) { - const struct PaintingImage *paintingImage = ripplingPainting->oPaintingImage; - f32 sizeX = paintingImage->sizeX; - f32 sizeY = paintingImage->sizeY; + f32 sizeX = (ripplingPainting->header.gfx.scale[0] * PAINTING_SIZE); + f32 sizeY = (ripplingPainting->header.gfx.scale[1] * PAINTING_SIZE); vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); diff --git a/src/game/paintings.c b/src/game/paintings.c index 89f6348bc0..3f583c69a9 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -399,31 +399,6 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 #undef TRI_PER_GRP #undef VTX_PER_GRP -/** - * Orient the painting mesh for rendering. - */ -Gfx *painting_model_view_transform(const struct PaintingImage *paintingImage) { - u32 gfxCmds = ( - /*gSPMatrix */ 1 + - /*gSPEndDisplayList */ 1 - ); - Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); - Gfx *gfx = dlist; - - // Scale - Mtx *scale = alloc_display_list(sizeof(Mtx)); - guScale( - scale, - (paintingImage->sizeX / PAINTING_SIZE), - (paintingImage->sizeY / PAINTING_SIZE), - 1.0f - ); - gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); - gSPEndDisplayList(gfx); - - return dlist; -} - /** * Gets the exponent of an integer by converting it into a float and extracting the exponent bits. */ @@ -465,7 +440,6 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); u32 gfxCmds = ( - /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + /*gDPSetTile */ 1 + /*gDPSetTileSize */ 1 + @@ -483,7 +457,6 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain return dlist; } - gSPDisplayList(gfx++, painting_model_view_transform(paintingImage)); Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); @@ -661,7 +634,6 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { Gfx *display_painting_not_rippling(struct Object *obj) { const struct PaintingImage *paintingImage = obj->oPaintingImage; u32 gfxCmds = ( - /*gSPDisplayList */ 1 + /*gSPDisplayList */ 1 + /*gSPPopMatrix */ 1 + /*gSPEndDisplayList */ 1 @@ -673,7 +645,6 @@ Gfx *display_painting_not_rippling(struct Object *obj) { return dlist; } - gSPDisplayList(gfx++, painting_model_view_transform(paintingImage)); gSPDisplayList(gfx++, dl_painting_not_rippling(paintingImage)); gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); @@ -768,6 +739,10 @@ void bhv_painting_init(void) { // Set the object's painting image data pointer. obj->oPaintingImage = paintingImage; + // Set the object's scale. + obj->header.gfx.scale[0] = (paintingImage->sizeX / PAINTING_SIZE); + obj->header.gfx.scale[1] = (paintingImage->sizeY / PAINTING_SIZE); + // Update the painting object's room. painting_update_room(obj); } From 04210115ecb284a14d9bbc31323a2a6d88fcabec Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 15 Dec 2022 22:10:24 -0500 Subject: [PATCH 66/81] Clean up non-rippling painting dl --- src/game/paintings.c | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 3f583c69a9..c8a659015b 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -446,7 +446,6 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain (imageCount * ( /*gSPDisplayList */ 1 )) + - /*gSPPopMatrix */ 1 + /*gSPDisplayList */ 1 + /*gSPEndDisplayList */ 1 ); @@ -471,7 +470,6 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain triangleMap += (numTris * 3); } - gSPPopMatrix(gfx++, G_MTX_MODELVIEW); Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_rippling_end); gSPDisplayList(gfx++, endDl); gSPEndDisplayList(gfx); @@ -563,7 +561,7 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { gSPDisplayList(gfx++, dl_paintings_textured_vertex_colored_begin); } - s16 tWidth = paintingImage->textureWidth; + s16 tWidth = paintingImage->textureWidth; s16 tHeight = paintingImage->textureHeight; // Width and height of each section. @@ -613,11 +611,8 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { ); } - if (isEnvMap) { - gSPDisplayList(gfx++, dl_paintings_env_mapped_end); - } else { - gSPDisplayList(gfx++, dl_paintings_textured_end); - } + Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_textured_end); + gSPDisplayList(gfx++, endDl); if (!shaded) { gSPSetGeometryMode(gfx++, G_LIGHTING); @@ -628,30 +623,6 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { return dlist; } -/** - * Render a normal painting. - */ -Gfx *display_painting_not_rippling(struct Object *obj) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; - u32 gfxCmds = ( - /*gSPDisplayList */ 1 + - /*gSPPopMatrix */ 1 + - /*gSPEndDisplayList */ 1 - ); - Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); - Gfx *gfx = dlist; - - if (dlist == NULL) { - return dlist; - } - - gSPDisplayList(gfx++, dl_painting_not_rippling(paintingImage)); - gSPPopMatrix(gfx++, G_MTX_MODELVIEW); - gSPEndDisplayList(gfx); - - return dlist; -} - /** * Draw the painting. */ @@ -687,7 +658,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } if (obj->oAction == PAINTING_ACT_IDLE) { - paintingDlist = display_painting_not_rippling(obj); + paintingDlist = dl_painting_not_rippling(paintingImage); } else { paintingDlist = display_painting_rippling(obj); } From bb5ad7835a5643becc6d8689eaae855dadec3705 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 16 Dec 2022 00:07:17 -0500 Subject: [PATCH 67/81] Formatting changes :) --- bin/segment2.c | 2 +- src/game/paintings.c | 86 ++++++++++++++++++++------------------------ src/game/segment2.h | 2 +- 3 files changed, 40 insertions(+), 50 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index d51c2ba3d9..8ac2d53848 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2909,7 +2909,7 @@ const Gfx dl_paintings_env_mapped_end[] = { }; // 0x02014A30 - 0x02014A60 -const Gfx dl_paintings_draw_ripples[] = { +const Gfx dl_paintings_ripple_triangles[] = { #ifdef F3DEX_GBI_2 gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), diff --git a/src/game/paintings.c b/src/game/paintings.c index c8a659015b..a5ba0bdf72 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -115,7 +115,6 @@ const struct RippleAnimationPair sRippleAnimations[] = { * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; PaintingData i, tri; @@ -132,24 +131,30 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai f32 rippleX = obj->oPaintingRipplePosX; f32 rippleY = obj->oPaintingRipplePosY; - f32 sizeRatioX = (paintingImage->sizeX / PAINTING_SIZE); - f32 sizeRatioY = (paintingImage->sizeY / PAINTING_SIZE); + f32 sizeRatioX = obj->header.gfx.scale[0]; + f32 sizeRatioY = obj->header.gfx.scale[1]; f32 dx, dy; f32 rippleDistance; + PaintingData vtxX, vtxY; + // Loop through all the painting vertices and calculate the ripple magnitude at each point. // Accesses are off by 1 since the first entry is the number of vertices. for (i = 0; i < numVtx; i++) { tri = (i * 3); - paintingMesh->pos[0] = vtxData[tri + 1]; - paintingMesh->pos[1] = vtxData[tri + 2]; + + vtxX = vtxData[tri + 1]; + vtxY = vtxData[tri + 2]; + + paintingMesh->pos[0] = vtxX; + paintingMesh->pos[1] = vtxY; // The "Z coordinate" of each vertex in the mesh is either 1 or 0. Instead of being an // actual coordinate, it just determines whether the vertex moves. if (vtxData[tri + 3]) { // Scale and calculate the distance to the ripple origin. - dx = ((paintingMesh->pos[0] * sizeRatioX) - rippleX); - dy = ((paintingMesh->pos[1] * sizeRatioY) - rippleY); + dx = ((vtxX * sizeRatioX) - rippleX); + dy = ((vtxY * sizeRatioY) - rippleY); // A larger dispersionFactor makes the ripple spread slower. rippleDistance = sqrtf(sqr(dx) + sqr(dy)) * dispersionFactor; @@ -186,18 +191,18 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ void painting_calculate_triangle_normals(const PaintingData *triangleData, struct PaintingNeighborTris *neighborTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { + struct PaintingNeighborTris *vtn = NULL; PaintingData i, j; - PaintingData numTris = triangleData[0]; - s16 vi[3]; // Vertex indices + PaintingData numTris = *triangleData++; Vec3f vp[3]; // Vertex positions for (i = 0; i < numTris; i++) { - // Add 2 because of the 2 length entries preceding the list. - PaintingData tri = (1 + (i * 3)); - vec3s_copy(vi, &triangleData[tri]); + // Get the 3 vertices from the triangle. for (j = 0; j < 3; j++) { - vec3s_to_vec3f(vp[j], paintingMesh[vi[j]].pos); - struct PaintingNeighborTris *vtn = &neighborTris[vi[j]]; + vec3s_to_vec3f(vp[j], paintingMesh[triangleData[j]].pos); + + // Add the current triangle to each vertex's neighbors list. + vtn = &neighborTris[triangleData[j]]; if (vtn->numNeighbors < ARRAY_COUNT(vtn->neighborTris)) { vtn->neighborTris[vtn->numNeighbors++] = i; } @@ -205,6 +210,8 @@ void painting_calculate_triangle_normals(const PaintingData *triangleData, struc // Cross product to find each triangle's normal vector. find_vector_perpendicular_to_plane(paintingTriNorms[i], vp[0], vp[1], vp[2]); + + triangleData += 3; } } @@ -235,13 +242,14 @@ void painting_average_vertex_normals(struct PaintingNeighborTris *neighborTris, struct PaintingNeighborTris *vtn = &neighborTris[i]; numNeighbors = vtn->numNeighbors; + // Average the surface normals from each neighboring tri. for (j = 0; j < numNeighbors; j++) { tri = vtn->neighborTris[j]; vec3f_add(n, paintingTriNorms[tri]); } - // Average the surface normals from each neighboring tri. vec3_div_val(n, numNeighbors); + f32 nlen = vec3_sumsq(n); if (FLT_IS_NONZERO(nlen)) { @@ -258,14 +266,14 @@ void painting_average_vertex_normals(struct PaintingNeighborTris *neighborTris, #else #define VTX_BUF_MAX 16 #endif -#define TRI_PER_GRP (VTX_BUF_MAX / 3) // 5 or 10 -#define VTX_PER_GRP (TRI_PER_GRP * 3) // 15 or 30 +#define TRI_PER_GRP (VTX_BUF_MAX / 3) // Rounded, 5 or 10 +#define VTX_PER_GRP (TRI_PER_GRP * 3) // Rounded, 15 or 30 /** * Creates a display list that draws the rippling painting, with 'img' mapped to the painting's mesh, using 'triangleMap'. * * If the triangleMap doesn't describe the whole mesh, then multiple calls are needed to draw the whole painting. - * + * * TODO: Automatically create seams between segments based on the image count. */ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, struct PaintingMeshVertex *paintingMesh, const PaintingData *triangleMap, PaintingData numTris, Alpha alpha) { @@ -274,8 +282,6 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 PaintingData groupIndex; PaintingData map; PaintingData triGroup; - PaintingData meshVtx; - s16 tx, ty; // We can fit VTX_PER_GRP vertices in the RSP's vertex buffer. // Group triangles by TRI_PER_GRP, with one remainder group. @@ -305,7 +311,7 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 const f32 dx = (PAINTING_SIZE / 1); const f32 dy = (PAINTING_SIZE / imageCount); - // These are used to scale the vertex positions into texture positions. + // These are used to scale the texture positions into vertex positions. const f32 tWidthScale = (TC(tWidth ) / dx); const f32 tHeightScale = (TC(tHeight) / dy); @@ -317,28 +323,19 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 // The index of the first vertex in the group. groupIndex = (group * VTX_PER_GRP); - // The triangle groups are the second part of the texture map. // Each group is a list of VTX_PER_GRP mappings. triGroup = (1 + groupIndex); // Vertices within the group for (map = 0; map < VTX_PER_GRP; map++) { - // Get the vertex index. - meshVtx = (triangleMap[triGroup + map]); - - // Get a pointer to the current mesh. - currVtx = &paintingMesh[meshVtx]; - - // Texture coordinates. - tx = (currVtx->pos[0] * tWidthScale); - ty = ((y2 - currVtx->pos[1]) * tHeightScale); - - // Map the texture and place it in the verts array. + // Get a pointer to the current vertex. + currVtx = &paintingMesh[triangleMap[triGroup + map]]; make_vertex(verts, (groupIndex + map), currVtx->pos[0], currVtx->pos[1], currVtx->pos[2], - tx, ty, + (currVtx->pos[0] * tWidthScale), + ((y2 - currVtx->pos[1]) * tHeightScale), currVtx->norm[0], currVtx->norm[1], currVtx->norm[2], @@ -348,7 +345,7 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 // Load the vertices and draw the TRI_PER_GRP triangles. gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL(verts + groupIndex), VTX_PER_GRP, 0); - gSPDisplayList(gfx++, dl_paintings_draw_ripples); + gSPDisplayList(gfx++, dl_paintings_ripple_triangles); } // One group left with < TRI_PER_GRP triangles. @@ -356,21 +353,14 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 // Map the texture to the triangles. for (map = 0; map < (remGroupTris * 3); map++) { - // Get the vertex index. - meshVtx = (triangleMap[triGroup + map]); - - // Get a pointer to the current mesh. - currVtx = &paintingMesh[meshVtx]; - - // Texture coordinates. - tx = (currVtx->pos[0] * tWidthScale); - ty = ((y2 - currVtx->pos[1]) * tHeightScale); - + // Get a pointer to the current vertex. + currVtx = &paintingMesh[triangleMap[triGroup + map]]; make_vertex(verts, ((triGroups * VTX_PER_GRP) + map), currVtx->pos[0], currVtx->pos[1], currVtx->pos[2], - tx, ty, + (currVtx->pos[0] * tWidthScale), + ((y2 - currVtx->pos[1]) * tHeightScale), currVtx->norm[0], currVtx->norm[1], currVtx->norm[2], @@ -580,6 +570,7 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { s16 t1, t2; s32 vertIndex = 0; + s32 quadIndex; s32 i; // Generate vertices @@ -598,8 +589,6 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); - s32 quadIndex; - for (i = 0; i < imageCount; i++) { gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, textures[i]); gDPLoadSync(gfx++); @@ -810,6 +799,7 @@ void painting_set_ripple_animation_type(struct Object *obj, const struct RippleA } #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) +// Whether the painting should be moved or not. s32 gDDDPaintingNotMoved = FALSE; /** diff --git a/src/game/segment2.h b/src/game/segment2.h index ba2db4b23f..729dcc2401 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -37,7 +37,7 @@ extern Gfx dl_skybox_end[]; extern Gfx dl_waterbox_ia16_begin[]; extern Gfx dl_waterbox_rgba16_begin[]; extern Gfx dl_waterbox_end[]; -extern Gfx dl_paintings_draw_ripples[]; +extern Gfx dl_paintings_ripple_triangles[]; extern Gfx dl_paintings_rippling_begin[]; extern Gfx dl_paintings_rippling_end[]; extern Gfx dl_paintings_textured_shaded_begin[]; From f0509d42f89d0e35094e846ff176402dce1680ac Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 16 Dec 2022 02:21:43 -0500 Subject: [PATCH 68/81] Don't use PAINTING_SIZE for fake CCM paintings --- levels/castle_inside/painting.inc.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/levels/castle_inside/painting.inc.c b/levels/castle_inside/painting.inc.c index 3ce60e4617..6fdddfcd57 100644 --- a/levels/castle_inside/painting.inc.c +++ b/levels/castle_inside/painting.inc.c @@ -1,37 +1,41 @@ #include "game/paintings.h" +#define CCM_FAKE_SIZE 614 + #define CCM_FAKE_1_X -3046 #define CCM_FAKE_1_Z -3724 -#define CCM_FAKE_1_DX 304 // PAINTING_SIZE * sin(yaw) -#define CCM_FAKE_1_DZ -534 // PAINTING_SIZE * cos(yaw) +// yaw ~ 150.33 +#define CCM_FAKE_1_DX 304 // CCM_FAKE_SIZE * sin(yaw) +#define CCM_FAKE_1_DZ -534 // CCM_FAKE_SIZE * cos(yaw) // 0x07021918 - 0x07021998 static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_1[] = { - {{{(CCM_FAKE_1_X + 0), -(PAINTING_SIZE / 2), (CCM_FAKE_1_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), -(PAINTING_SIZE / 2), (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + 0), -(CCM_FAKE_SIZE / 2), (CCM_FAKE_1_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), -(CCM_FAKE_SIZE / 2), (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), 0, (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_1_X + 0), 0, (CCM_FAKE_1_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_1_X + 0), 0, (CCM_FAKE_1_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), 0, (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), (PAINTING_SIZE / 2), (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{(CCM_FAKE_1_X + 0), (PAINTING_SIZE / 2), (CCM_FAKE_1_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + CCM_FAKE_1_DX), (CCM_FAKE_SIZE / 2), (CCM_FAKE_1_Z + CCM_FAKE_1_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_1_X + 0), (CCM_FAKE_SIZE / 2), (CCM_FAKE_1_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; #define CCM_FAKE_2_X -1866 #define CCM_FAKE_2_Z -4258 -#define CCM_FAKE_2_DX 304 // PAINTING_SIZE * sin(yaw) -#define CCM_FAKE_2_DZ 534 // PAINTING_SIZE * cos(yaw) +// yaw ~ 29.66 +#define CCM_FAKE_2_DX 304 // CCM_FAKE_SIZE * sin(yaw) +#define CCM_FAKE_2_DZ 534 // CCM_FAKE_SIZE * cos(yaw) // 0x07021998 - 0x07021A18 static const Vtx inside_castle_seg7_vertex_painting_ccm_fake_2[] = { - {{{(CCM_FAKE_2_X + 0), -(PAINTING_SIZE / 2), (CCM_FAKE_2_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), -(PAINTING_SIZE / 2), (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + 0), -(CCM_FAKE_SIZE / 2), (CCM_FAKE_2_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), -(CCM_FAKE_SIZE / 2), (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), 0, (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_2_X + 0), 0, (CCM_FAKE_2_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_2_X + 0), 0, (CCM_FAKE_2_Z + 0)}, 0, { -32, 992}, {0x00, 0x00, 0x7f, 0xff}}}, {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), 0, (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 992}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), (PAINTING_SIZE / 2), (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, - {{{(CCM_FAKE_2_X + 0), (PAINTING_SIZE / 2), (CCM_FAKE_2_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + CCM_FAKE_2_DX), (CCM_FAKE_SIZE / 2), (CCM_FAKE_2_Z + CCM_FAKE_2_DZ)}, 0, { 2012, 0}, {0x00, 0x00, 0x7f, 0xff}}}, + {{{(CCM_FAKE_2_X + 0), (CCM_FAKE_SIZE / 2), (CCM_FAKE_2_Z + 0)}, 0, { -32, 0}, {0x00, 0x00, 0x7f, 0xff}}}, }; // 0x07021A18 - 0x07021A30 From bfdae6018221670bdb789e79664b755bbbd9bab5 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 6 Jan 2023 16:23:07 -0500 Subject: [PATCH 69/81] Painting scale changes --- bin/segment2.c | 1 + src/game/camera.c | 9 +++--- src/game/paintings.c | 67 +++++++++++++++++++++++++++++--------------- src/game/paintings.h | 22 +++++++++------ 4 files changed, 63 insertions(+), 36 deletions(-) diff --git a/bin/segment2.c b/bin/segment2.c index 8ac2d53848..3892c4f5ba 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -3103,6 +3103,7 @@ const PaintingData painting_data_triangles[] = { 264, // num triangles // Grouped by 5 + one remainder group, // = 15 vertices per group + a few extra triangles + // Bottom half 60, 59, 52, 49, 53, 55, diff --git a/src/game/camera.c b/src/game/camera.c index 0073496f7a..cf779d691c 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -9584,17 +9584,16 @@ void cutscene_enter_painting(struct Camera *c) { struct Object *ripplingPainting = gCutsceneFocus; if (ripplingPainting != NULL) { - f32 sizeX = (ripplingPainting->header.gfx.scale[0] * PAINTING_SIZE); - f32 sizeY = (ripplingPainting->header.gfx.scale[1] * PAINTING_SIZE); - + vec3f_copy(paintingPos, &ripplingPainting->oPosVec); vec3i_to_vec3s(paintingAngle, &ripplingPainting->oFaceAngleVec); + f32 sizeX = ripplingPainting->header.gfx.scale[0]; + f32 sizeY = ripplingPainting->header.gfx.scale[1]; + focusOffset[0] = (sizeX * 0.5f); focusOffset[1] = (sizeY * 0.5f); focusOffset[2] = 0; - vec3f_copy(paintingPos, &ripplingPainting->oPosVec); - offset_rotated(focus, paintingPos, focusOffset, paintingAngle); approach_vec3f_asymptotic(c->focus, focus, 0.1f, 0.1f, 0.1f); size = ((sizeX + sizeY) / 2.0f); diff --git a/src/game/paintings.c b/src/game/paintings.c index a5ba0bdf72..a2df4fbe18 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -131,8 +131,8 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai f32 rippleX = obj->oPaintingRipplePosX; f32 rippleY = obj->oPaintingRipplePosY; - f32 sizeRatioX = obj->header.gfx.scale[0]; - f32 sizeRatioY = obj->header.gfx.scale[1]; + f32 sizeRatioX = (obj->header.gfx.scale[0] / PAINTING_SIZE); + f32 sizeRatioY = (obj->header.gfx.scale[1] / PAINTING_SIZE); f32 dx, dy; f32 rippleDistance; @@ -430,6 +430,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); u32 gfxCmds = ( + /*gSPMatrix */ 1 + /*gSPDisplayList */ 1 + /*gDPSetTile */ 1 + /*gDPSetTileSize */ 1 + @@ -437,6 +438,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain /*gSPDisplayList */ 1 )) + /*gSPDisplayList */ 1 + + /*gSPPopMatrix */ 1 + /*gSPEndDisplayList */ 1 ); Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); @@ -445,6 +447,15 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain if (dlist == NULL) { return dlist; } + // Scale + Mtx *scale = alloc_display_list(sizeof(Mtx)); + guScale( + scale, + (1.0f / PAINTING_SIZE), + (1.0f / PAINTING_SIZE), + 1.0f + ); + gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); @@ -462,6 +473,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_rippling_end); gSPDisplayList(gfx++, endDl); + gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); return dlist; @@ -505,11 +517,13 @@ Gfx *display_painting_rippling(struct Object *obj) { return dlist; } -Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { +Gfx *dl_painting_not_rippling(struct Object *obj) { + const struct PaintingImage *paintingImage = obj->oPaintingImage; Alpha alpha = paintingImage->alpha; s16 imageCount = paintingImage->imageCount; s32 shaded = paintingImage->shaded; u32 gfxCmds = ( + /*gSPMatrix */ 1 + /*gSPDisplayList */ 1 + /*gSPVertex */ 1 + /*gDPSetTile */ 1 + @@ -524,6 +538,7 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { (!shaded * ( /*gSPSetGeometryMode */ 1 )) + + /*gSPPopMatrix */ 1 + /*gSPEndDisplayList */ 1 ); Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); @@ -533,6 +548,16 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { return dlist; } + // Scale + Mtx *scale = alloc_display_list(sizeof(Mtx)); + guScale( + scale, + (1.0f / PAINTING_SIZE), + (1.0f / PAINTING_SIZE), + 1.0f + ); + gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); + Vtx *verts = alloc_display_list((imageCount * 4) * sizeof(*verts)); Vec3c n; @@ -607,6 +632,7 @@ Gfx *dl_painting_not_rippling(const struct PaintingImage *paintingImage) { gSPSetGeometryMode(gfx++, G_LIGHTING); } + gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); return dlist; @@ -647,7 +673,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } if (obj->oAction == PAINTING_ACT_IDLE) { - paintingDlist = dl_painting_not_rippling(paintingImage); + paintingDlist = dl_painting_not_rippling(obj); } else { paintingDlist = display_painting_rippling(obj); } @@ -663,12 +689,10 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con * Updates a painting object's room from a point in front of the center of the painting. */ void painting_update_room(struct Object *obj) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; - // The center of the painting, but with an offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { - (paintingImage->sizeX * 0.5f), - (paintingImage->sizeY * 0.5f), + (obj->header.gfx.scale[0] * 0.5f), + (obj->header.gfx.scale[1] * 0.5f), PAINTING_WOBBLE_DEPTH // Distance in front of the painting to check for a room floor. }; @@ -699,9 +723,9 @@ void bhv_painting_init(void) { // Set the object's painting image data pointer. obj->oPaintingImage = paintingImage; - // Set the object's scale. - obj->header.gfx.scale[0] = (paintingImage->sizeX / PAINTING_SIZE); - obj->header.gfx.scale[1] = (paintingImage->sizeY / PAINTING_SIZE); + // Set the object's initial scale. + obj->header.gfx.scale[0] = paintingImage->sizeX; + obj->header.gfx.scale[1] = paintingImage->sizeY; // Update the painting object's room. painting_update_room(obj); @@ -730,14 +754,11 @@ s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { // Get Mario's position in the painting's local space. vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); - // Get the const painting image data. - const struct PaintingImage *paintingImage = obj->oPaintingImage; - // Check if Mario is within the painting bounds laterally in local space. if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN - && marioLocalPos[0] < (paintingImage->sizeX + PAINTING_EDGE_MARGIN) + && marioLocalPos[0] < (obj->header.gfx.scale[0] + PAINTING_EDGE_MARGIN) && marioLocalPos[1] > -PAINTING_EDGE_MARGIN - && marioLocalPos[1] < (paintingImage->sizeY + PAINTING_EDGE_MARGIN)) { + && marioLocalPos[1] < (obj->header.gfx.scale[1] + PAINTING_EDGE_MARGIN)) { if (marioLocalPos[2] > PAINTING_WOBBLE_WARP_THRESHOLD) { // In front of the painting, check whether Mario is inside the wobble zone. if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH) { @@ -775,14 +796,15 @@ s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { /** * Returns a pointer to the RippleAnimationPair that best fits the painting type. */ -const struct RippleAnimationPair *painting_get_ripple_animation_type_info(const struct PaintingImage *paintingImage) { +const struct RippleAnimationPair *painting_get_ripple_animation_type_info(struct Object *obj) { + const struct PaintingImage *paintingImage = obj->oPaintingImage; s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY; - if (paintingImage->sizeX >= (PAINTING_SIZE * 2) - || paintingImage->sizeY >= (PAINTING_SIZE * 2)) { + if (obj->header.gfx.scale[0] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD + || obj->header.gfx.scale[1] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; } } @@ -851,8 +873,7 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) * @param shouldResetTimer if TRUE, set the timer to 0. */ void painting_start_ripples(struct Object *obj, f32 ripplePosX, f32 ripplePosY, s32 shouldResetTimer) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; - const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); + const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(obj); // Use a different set of variables depending on the state switch (obj->oAction) { @@ -921,7 +942,7 @@ void bhv_painting_loop(void) { } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous trigger type: - const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(paintingImage); + const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(obj); // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. @@ -936,7 +957,7 @@ void bhv_painting_loop(void) { painting_start_ripples(obj, marioLocalPos[0], marioLocalPos[1], FALSE); // Start entering } else if (obj->oAction == PAINTING_ACT_IDLE) { obj->oAction = PAINTING_ACT_RIPPLING; - painting_start_ripples(obj, (paintingImage->sizeX * 0.5f), (paintingImage->sizeY * 0.5f), TRUE); // Start idle wobbling + painting_start_ripples(obj, (obj->header.gfx.scale[0] * 0.5f), (obj->header.gfx.scale[1] * 0.5f), TRUE); // Start idle wobbling } } diff --git a/src/game/paintings.h b/src/game/paintings.h index d4fa370987..524be5288a 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -8,25 +8,31 @@ #include "types.h" -/// The default painting edge length. Default is 614.4f. -#define PAINTING_SIZE 614.4f +// The size of the stored painting mesh model, before it is created and scaled down to 1x1. +// Vanilla is 614.4f, changed to 600.0f in HackerSM64 to prevent rounding issues. +// Changing this affects the painting's lighting. The larger the difference between this and +// the final size of the painting, the greater the difference in lighting. +#define PAINTING_SIZE 600.0f -/// The depth of the area in front of the painting which triggers ripples without warping. Default is 102.4f. +// The threshold of scale at which to use a larger ripple animation in sRippleAnimations. Default is 1200.0f. +#define PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD 1200.0f + +// The depth of the area in front of the painting which triggers ripples without warping. Default is 102.4f. #define PAINTING_WOBBLE_DEPTH 102.4f -/// The depth of the area behind the painting which triggers the warp. Default is 409.6f. +// The depth of the area behind the painting which triggers the warp. Default is 409.6f. #define PAINTING_WARP_DEPTH 409.6f -/// The threshold relative to the painting's plane between wobbling and warping. Default is -30.72f. +// The threshold relative to the painting's plane between wobbling and warping. Default is -30.72f. #define PAINTING_WOBBLE_WARP_THRESHOLD -30.72f -/// The size of the buffer around the edges of the painting in which Mario is still considered within bounds. +// The size of the buffer around the edges of the painting in which Mario is still considered within bounds. #define PAINTING_EDGE_MARGIN 160.0f -/// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. Default is 50.0f +// This is added to Mario's Y position to make the ripple closer to Mario's center of mass. Default is 50.0f #define PAINTING_MARIO_Y_OFFSET 50.0f -/// Convert image coordinates to texel coordinates. +// Convert image coordinates to texel coordinates. #define TC(t) (((t) - 1) << 5) From cc683d2415ee539e34be5c43ad5e031b56a972d4 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sat, 14 Jan 2023 14:40:38 -0500 Subject: [PATCH 70/81] 'vec3f_local_pos_to_world_pos' and 'vec3f_world_pos_to_local_pos' documentation + fix some comments --- src/engine/math_util.c | 16 ++++++++++++++-- src/game/paintings.c | 20 +++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 2f22c72407..0059fd36da 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -777,7 +777,13 @@ void mtxf_rotate_xy(Mtx *mtx, s16 angle) { } /** - * Makes 'destWorldPos' the world space equivalent of 'srcLocalPos'. + * @brief Converts a position in a local frame of reference into the same + * position in global world-space, and stores it in 'destWorldPos'. + * + * @param destWorldPos Where the resulting global world-space position is stored. + * @param srcLocalPos The position in the local frame of reference to convert from. + * @param originPos The origin position of the local frame of reference (in global world-space). + * @param rotation The rotation of the local frame of reference (in global world-space). */ void vec3f_local_pos_to_world_pos(Vec3f destWorldPos, Vec3f srcLocalPos, Vec3f originPos, Vec3s rotation) { Mat4 mtx; @@ -788,7 +794,13 @@ void vec3f_local_pos_to_world_pos(Vec3f destWorldPos, Vec3f srcLocalPos, Vec3f o } /** - * Makes 'destLocalPos' the local space equivalent of 'srcWorldPos'. + * @brief Converts a global world-space position into the same position but + * from a local frame of reference, and stores the result in 'destLocalPos'. + * + * @param destLocalPos Where the resulting position in the local frame of reference is stored. + * @param srcWorldPos The position in global world-space to convert from. + * @param originPos The origin position of the local frame of reference (in global world-space). + * @param rotation The rotation of the local frame of reference (in global world-space). */ void vec3f_world_pos_to_local_pos(Vec3f destLocalPos, Vec3f srcWorldPos, Vec3f originPos, Vec3s rotation) { Mat4 mtx; diff --git a/src/game/paintings.c b/src/game/paintings.c index a2df4fbe18..1e11b66769 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -51,6 +51,7 @@ * A CONTINUOUS painting will automatically reset to PAINTING_ACT_RIPPLING if its ripple magnitude becomes small enough. */ + /** * Array of pointers to painting image data structs. */ @@ -81,18 +82,19 @@ const struct PaintingImage *sPaintings[] = { const struct RippleAnimationPair sRippleAnimations[] = { [RIPPLE_ANIM_CONTINUOUS] = { .passive = { .mag = 10.0f, .decay = 1.0f, .rate = 0.05f, .dispersion = 15.0f }, - .entry = { .mag = 30.0f, .decay = 0.98f, .rate = 0.05f, .dispersion = 15.0f } + .entry = { .mag = 30.0f, .decay = 0.98f, .rate = 0.05f, .dispersion = 15.0f }, }, [RIPPLE_ANIM_PROXIMITY] = { .passive = { .mag = 20.0f, .decay = 0.9608f, .rate = 0.24f, .dispersion = 40.0f }, - .entry = { .mag = 80.0f, .decay = 0.9524f, .rate = 0.14f, .dispersion = 30.0f } + .entry = { .mag = 80.0f, .decay = 0.9524f, .rate = 0.14f, .dispersion = 30.0f }, }, [RIPPLE_ANIM_PROXIMITY_LARGE] = { .passive = { .mag = 40.0f, .decay = 0.9608f, .rate = 0.12f, .dispersion = 80.0f }, - .entry = { .mag = 160.0f, .decay = 0.9524f, .rate = 0.07f, .dispersion = 60.0f } - } + .entry = { .mag = 160.0f, .decay = 0.9524f, .rate = 0.07f, .dispersion = 60.0f }, + }, }; + /// - DRAW - /** @@ -149,8 +151,8 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai paintingMesh->pos[0] = vtxX; paintingMesh->pos[1] = vtxY; - // The "Z coordinate" of each vertex in the mesh is either 1 or 0. Instead of being an - // actual coordinate, it just determines whether the vertex moves. + // The "Z coordinate" of each vertex in painting_data_vertices is either 1 or 0. + // Instead of being an actual coordinate, it just determines whether the vertex can move or not. if (vtxData[tri + 3]) { // Scale and calculate the distance to the ripple origin. dx = ((vtxX * sizeRatioX) - rippleX); @@ -405,7 +407,6 @@ void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { u32 masks = get_exponent(tWidth); u32 maskt = get_exponent(tHeight); - // Set up the textures. gDPSetTile((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, (tWidth >> 2), 0, G_TX_RENDERTILE, 0, cm, maskt, G_TX_NOLOD, @@ -493,7 +494,7 @@ Gfx *display_painting_rippling(struct Object *obj) { // When a painting is rippling, this mesh is generated each frame using the Painting's parameters. // This mesh only contains the vertex positions and normals. // Paintings use an additional array to map textures to the mesh. - //! TODO: Find out why clearing this causes flickering. + //! TODO: Find out why clearing this between frames causes flickering. struct PaintingMeshVertex *paintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); // A list of neighbor triangles for each vertes. This gets cleared each frame while 'paintingMesh' isn't. struct PaintingNeighborTris *neighborTris = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingNeighborTris))); @@ -510,6 +511,7 @@ Gfx *display_painting_rippling(struct Object *obj) { dlist = dl_painting_rippling(paintingImage, paintingMesh, triangleData); // The mesh data is freed every frame. + //! This data is not actually cleared. mem_pool_free(gEffectsMemoryPool, paintingMesh); mem_pool_free(gEffectsMemoryPool, neighborTris); mem_pool_free(gEffectsMemoryPool, paintingTriNorms); @@ -751,7 +753,7 @@ s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { // Get the painting's rotation. vec3i_to_vec3s(rotation, &obj->oFaceAngleVec); - // Get Mario's position in the painting's local space. + // Get Mario's position in the painting's frame of reference. vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); // Check if Mario is within the painting bounds laterally in local space. From 4744c9cd7fe89fa4d8934705794a7bc38f17f6d8 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 17 Mar 2023 13:39:21 -0400 Subject: [PATCH 71/81] Remove unused externs --- levels/hmc/header.h | 3 --- levels/ttm/header.h | 4 ---- 2 files changed, 7 deletions(-) diff --git a/levels/hmc/header.h b/levels/hmc/header.h index 124f66fa75..8e070392dd 100644 --- a/levels/hmc/header.h +++ b/levels/hmc/header.h @@ -72,9 +72,6 @@ extern const Gfx hmc_seg7_dl_07023090[]; extern const Gfx hmc_seg7_dl_07023BC8[]; extern const Gfx hmc_seg7_dl_07023E10[]; extern const Gfx hmc_seg7_dl_07024110[]; -extern const Gfx hmc_seg7_dl_07024268[]; -extern const Gfx hmc_seg7_dl_070242A0[]; -extern const Texture *const hmc_seg7_painting_textures_07025518[]; extern struct PaintingImage cotmc_painting; extern const Collision hmc_seg7_collision_level[]; extern const MacroObject hmc_seg7_macro_objs[]; diff --git a/levels/ttm/header.h b/levels/ttm/header.h index 2866088e7f..7484b029a4 100644 --- a/levels/ttm/header.h +++ b/levels/ttm/header.h @@ -67,10 +67,6 @@ extern const Gfx ttm_seg7_dl_07011608[]; extern const Gfx ttm_seg7_dl_07011C78[]; extern const Gfx ttm_seg7_dl_07011D78[]; extern const Gfx ttm_seg7_dl_07012270[]; -extern const Gfx ttm_seg7_dl_07012388[]; -extern const Gfx ttm_seg7_dl_070123A0[]; -extern const Gfx ttm_seg7_dl_070123B8[]; -extern const Gfx ttm_seg7_dl_07012410[]; extern struct PaintingImage ttm_slide_painting; extern const Gfx ttm_seg7_dl_07013430[]; extern const Gfx ttm_seg7_dl_07013608[]; From 199486a29901da5057a34bb32ff3a2bedf794f35 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Tue, 28 Mar 2023 12:35:28 -0400 Subject: [PATCH 72/81] improve gfx allocation (formatting) + add gsLoadBlockTexture --- include/ique/PR/gbi.h | 1 + include/n64/PR/gbi.h | 1 + src/game/geo_misc.h | 8 ++++++ src/game/paintings.c | 63 +++++++++++++++++++++---------------------- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/include/ique/PR/gbi.h b/include/ique/PR/gbi.h index 5f2a1e46f1..30c1765a97 100755 --- a/include/ique/PR/gbi.h +++ b/include/ique/PR/gbi.h @@ -1837,6 +1837,7 @@ typedef union { /* * Macros to assemble the graphics display list */ +#define SIZEOF_GFX_CMD(_cmd) sizeof((Gfx[]){gs##_cmd}) /* * DMA macros diff --git a/include/n64/PR/gbi.h b/include/n64/PR/gbi.h index 7461fa9170..e1e657d158 100644 --- a/include/n64/PR/gbi.h +++ b/include/n64/PR/gbi.h @@ -1861,6 +1861,7 @@ typedef union { /* * Macros to assemble the graphics display list */ +#define SIZEOF_GFX_CMD(_cmd) sizeof((Gfx[]){gs##_cmd}) /* * DMA macros diff --git a/src/game/geo_misc.h b/src/game/geo_misc.h index 5e7c297e12..56605a5bb1 100644 --- a/src/game/geo_misc.h +++ b/src/game/geo_misc.h @@ -36,4 +36,12 @@ extern Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, UN gDPLoadBlock((dl), G_TX_LOADTILE, 0, 0, (width) * (height) - 1, CALC_DXT((width), G_IM_SIZ_16b_BYTES)) \ } +#define gsLoadBlockTexture(width, height, format, image) \ + gsDPSetTextureImage((format), G_IM_SIZ_16b, 1, (image)), \ + gsDPTileSync(), \ + gsDPSetTile((format), G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, \ + G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), \ + gsDPLoadSync(), \ + gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (width) * (height) - 1, CALC_DXT((width), G_IM_SIZ_16b_BYTES)) \ + #endif // GEO_MISC_H diff --git a/src/game/paintings.c b/src/game/paintings.c index 1e11b66769..1fa449f0e0 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -292,19 +292,18 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 PaintingData numVtx = (numTris * 3); // 3 verts per tri Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); - u32 gfxCmds = ( - /*gLoadBlockTexture */ 5 + + Gfx *dlist = alloc_display_list( + SIZEOF_GFX_CMD(LoadBlockTexture(0,0,0,0)) + (triGroups * ( - /*gSPVertex */ 1 + - /*gSPDisplayList */ 1 + SIZEOF_GFX_CMD(SPVertex(0,0,0)) + + SIZEOF_GFX_CMD(SPDisplayList(0)) )) + - /*gSPVertex */ 1 + + SIZEOF_GFX_CMD(SPVertex(0,0,0)) + (remGroupTris * ( - /*gSP1Triangle */ 1 + SIZEOF_GFX_CMD(SP1Triangle(0,0,0,0)) )) + - /*gSPEndDisplayList */ 1 + SIZEOF_GFX_CMD(SPEndDisplayList()) ); - Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); @@ -430,19 +429,18 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain const Texture **tArray = segmented_to_virtual(paintingImage->textureArray); s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); - u32 gfxCmds = ( - /*gSPMatrix */ 1 + - /*gSPDisplayList */ 1 + - /*gDPSetTile */ 1 + - /*gDPSetTileSize */ 1 + + Gfx *dlist = alloc_display_list( + SIZEOF_GFX_CMD(SPMatrix(0,0)) + + SIZEOF_GFX_CMD(SPDisplayList(0)) + + SIZEOF_GFX_CMD(DPSetTile(0,0,0,0,0,0,0,0,0,0,0,0)) + + SIZEOF_GFX_CMD(DPSetTileSize(0,0,0,0,0)) + (imageCount * ( - /*gSPDisplayList */ 1 + SIZEOF_GFX_CMD(SPDisplayList(0)) )) + - /*gSPDisplayList */ 1 + - /*gSPPopMatrix */ 1 + - /*gSPEndDisplayList */ 1 + SIZEOF_GFX_CMD(SPDisplayList(0)) + + SIZEOF_GFX_CMD(SPPopMatrix(0)) + + SIZEOF_GFX_CMD(SPEndDisplayList()) ); - Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { @@ -524,26 +522,25 @@ Gfx *dl_painting_not_rippling(struct Object *obj) { Alpha alpha = paintingImage->alpha; s16 imageCount = paintingImage->imageCount; s32 shaded = paintingImage->shaded; - u32 gfxCmds = ( - /*gSPMatrix */ 1 + - /*gSPDisplayList */ 1 + - /*gSPVertex */ 1 + - /*gDPSetTile */ 1 + - /*gDPSetTileSize */ 1 + + Gfx *dlist = alloc_display_list( + SIZEOF_GFX_CMD(SPMatrix(0,0)) + + SIZEOF_GFX_CMD(SPDisplayList(0)) + + SIZEOF_GFX_CMD(SPVertex(0,0,0)) + + SIZEOF_GFX_CMD(DPSetTile(0,0,0,0,0,0,0,0,0,0,0,0)) + + SIZEOF_GFX_CMD(DPSetTileSize(0,0,0,0,0)) + (imageCount * ( - /*gDPSetTextureImage */ 1 + - /*gDPLoadSync */ 1 + - /*gDPLoadBlock */ 1 + - /*gSP2Triangles */ 1 + SIZEOF_GFX_CMD(DPSetTextureImage(0,0,0,0)) + + SIZEOF_GFX_CMD(DPLoadSync()) + + SIZEOF_GFX_CMD(DPLoadBlock(0,0,0,0,0)) + + SIZEOF_GFX_CMD(SP2Triangles(0,0,0,0,0,0,0,0)) )) + - /*gSPDisplayList */ 1 + + SIZEOF_GFX_CMD(SPDisplayList(0)) + (!shaded * ( - /*gSPSetGeometryMode */ 1 + SIZEOF_GFX_CMD(SPSetGeometryMode(0)) )) + - /*gSPPopMatrix */ 1 + - /*gSPEndDisplayList */ 1 + SIZEOF_GFX_CMD(SPPopMatrix(0)) + + SIZEOF_GFX_CMD(SPEndDisplayList()) ); - Gfx *dlist = alloc_display_list(gfxCmds * sizeof(Gfx)); Gfx *gfx = dlist; if (dlist == NULL) { From 5f694b9333fe97d98de1c49eb86ea674a3e77596 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 7 Apr 2023 18:33:06 -0400 Subject: [PATCH 73/81] pointer formatting changes --- src/game/paintings.c | 128 +++++++++++++++++++++++-------------------- src/game/paintings.h | 4 +- 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 1fa449f0e0..17a9b6457f 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -51,11 +51,10 @@ * A CONTINUOUS painting will automatically reset to PAINTING_ACT_RIPPLING if its ripple magnitude becomes small enough. */ - /** * Array of pointers to painting image data structs. */ -const struct PaintingImage *sPaintings[] = { +const struct PaintingImage* sPaintings[] = { [PAINTING_ID_NULL ] = NULL, [PAINTING_ID_CASTLE_BOB ] = &bob_painting, [PAINTING_ID_CASTLE_CCM ] = &ccm_painting, @@ -116,8 +115,8 @@ const struct RippleAnimationPair sRippleAnimations[] = { * * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ -void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh) { - const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; +void painting_generate_mesh(struct Object* obj, const PaintingData* vtxData, PaintingData numVtx, struct PaintingMeshVertex* paintingMesh) { + const struct RippleAnimation* objRippleAnim = obj->oPaintingRippleAnimation; PaintingData i, tri; /// Controls the peaks of the ripple. @@ -192,8 +191,8 @@ void painting_generate_mesh(struct Object *obj, const PaintingData *vtxData, Pai * * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(const PaintingData *triangleData, struct PaintingNeighborTris *neighborTris, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { - struct PaintingNeighborTris *vtn = NULL; +void painting_calculate_triangle_normals(const PaintingData *triangleData, struct PaintingNeighborTris* neighborTris, struct PaintingMeshVertex* paintingMesh, Vec3f* paintingTriNorms) { + struct PaintingNeighborTris* vtn = NULL; PaintingData i, j; PaintingData numTris = *triangleData++; Vec3f vp[3]; // Vertex positions @@ -232,7 +231,7 @@ void painting_calculate_triangle_normals(const PaintingData *triangleData, struc * * The table used in game, painting_data_mesh_neighbor_tris, is in bin/segment2.c. */ -void painting_average_vertex_normals(struct PaintingNeighborTris *neighborTris, PaintingData numVtx, struct PaintingMeshVertex *paintingMesh, Vec3f *paintingTriNorms) { +void painting_average_vertex_normals(struct PaintingNeighborTris* neighborTris, PaintingData numVtx, struct PaintingMeshVertex* paintingMesh, Vec3f* paintingTriNorms) { PaintingData tri; PaintingData i, j; PaintingData numNeighbors; @@ -241,7 +240,7 @@ void painting_average_vertex_normals(struct PaintingNeighborTris *neighborTris, Vec3f n = { 0.0f, 0.0f, 0.0f }; // The first number of each entry is the number of adjacent tris. - struct PaintingNeighborTris *vtn = &neighborTris[i]; + struct PaintingNeighborTris* vtn = &neighborTris[i]; numNeighbors = vtn->numNeighbors; // Average the surface normals from each neighboring tri. @@ -278,8 +277,8 @@ void painting_average_vertex_normals(struct PaintingNeighborTris *neighborTris, * * TODO: Automatically create seams between segments based on the image count. */ -Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, struct PaintingMeshVertex *paintingMesh, const PaintingData *triangleMap, PaintingData numTris, Alpha alpha) { - struct PaintingMeshVertex *currVtx = NULL; +Gfx* render_painting_segment(const Texture* img, s16 index, s16 imageCount, s16 tWidth, s16 tHeight, struct PaintingMeshVertex* paintingMesh, const PaintingData* triangleMap, PaintingData numTris, Alpha alpha) { + struct PaintingMeshVertex* currVtx = NULL; PaintingData group; PaintingData groupIndex; PaintingData map; @@ -291,8 +290,8 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 PaintingData remGroupTris = (numTris % TRI_PER_GRP); PaintingData numVtx = (numTris * 3); // 3 verts per tri - Vtx *verts = alloc_display_list(numVtx * sizeof(Vtx)); - Gfx *dlist = alloc_display_list( + Vtx* verts = alloc_display_list(numVtx * sizeof(Vtx)); + Gfx* dlist = alloc_display_list( SIZEOF_GFX_CMD(LoadBlockTexture(0,0,0,0)) + (triGroups * ( SIZEOF_GFX_CMD(SPVertex(0,0,0)) + @@ -304,7 +303,7 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 )) + SIZEOF_GFX_CMD(SPEndDisplayList()) ); - Gfx *gfx = dlist; + Gfx* gfx = dlist; gLoadBlockTexture(gfx++, tWidth, tHeight, G_IM_FMT_RGBA, img); @@ -393,15 +392,22 @@ Gfx *render_painting_segment(const Texture *img, s16 index, s16 imageCount, s16 /** * Gets the exponent of an integer by converting it into a float and extracting the exponent bits. */ -s32 get_exponent(s32 x) { - union { s32 i; f32 f; } b = { .f = x }; - return (((b.i >> 23) & (u32)BITMASK(8)) - 127); +static s32 get_exponent(s32 x) { + union { + struct PACKED { + u32 sign : 1; + u32 exponent : 8; + u32 mantissa : 23; + }; + f32 f; + } b = { .f = x }; + return (b.exponent - 127); } /** * Set up the texture format in the display list. */ -void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { +void painting_setup_textures(Gfx** gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { s16 cm = isEnvMap ? (G_TX_WRAP | G_TX_NOMIRROR) : G_TX_CLAMP; u32 masks = get_exponent(tWidth); u32 maskt = get_exponent(tHeight); @@ -421,15 +427,15 @@ void painting_setup_textures(Gfx **gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { /** * Ripple a painting that has 1 or more images that need to be mapped. */ -Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct PaintingMeshVertex *paintingMesh, const PaintingData *triangleMap) { +Gfx* dl_painting_rippling(const struct PaintingImage* paintingImage, struct PaintingMeshVertex* paintingMesh, const PaintingData* triangleMap) { s16 i; s16 imageCount = paintingImage->imageCount; s16 tWidth = paintingImage->textureWidth; s16 tHeight = paintingImage->textureHeight; - const Texture **tArray = segmented_to_virtual(paintingImage->textureArray); + const Texture** tArray = segmented_to_virtual(paintingImage->textureArray); s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); - Gfx *dlist = alloc_display_list( + Gfx* dlist = alloc_display_list( SIZEOF_GFX_CMD(SPMatrix(0,0)) + SIZEOF_GFX_CMD(SPDisplayList(0)) + SIZEOF_GFX_CMD(DPSetTile(0,0,0,0,0,0,0,0,0,0,0,0)) + @@ -441,13 +447,13 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain SIZEOF_GFX_CMD(SPPopMatrix(0)) + SIZEOF_GFX_CMD(SPEndDisplayList()) ); - Gfx *gfx = dlist; + Gfx* gfx = dlist; if (dlist == NULL) { return dlist; } // Scale - Mtx *scale = alloc_display_list(sizeof(Mtx)); + Mtx* scale = alloc_display_list(sizeof(Mtx)); guScale( scale, (1.0f / PAINTING_SIZE), @@ -456,7 +462,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain ); gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); - Gfx *beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); + Gfx* beginDl = (isEnvMap ? dl_paintings_env_mapped_begin : dl_paintings_rippling_begin); gSPDisplayList(gfx++, beginDl); painting_setup_textures(&gfx, tWidth, tHeight, isEnvMap); @@ -470,7 +476,7 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain triangleMap += (numTris * 3); } - Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_rippling_end); + Gfx* endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_rippling_end); gSPDisplayList(gfx++, endDl); gSPPopMatrix(gfx++, G_MTX_MODELVIEW); gSPEndDisplayList(gfx); @@ -482,20 +488,20 @@ Gfx *dl_painting_rippling(const struct PaintingImage *paintingImage, struct Pain * Generates a mesh, calculates vertex normals for lighting, and renders a rippling painting. * The mesh and vertex normals are regenerated and freed every frame. */ -Gfx *display_painting_rippling(struct Object *obj) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; - const PaintingData *vtxData = segmented_to_virtual(painting_data_vertices); - const PaintingData *triangleData = segmented_to_virtual(painting_data_triangles); +Gfx* display_painting_rippling(struct Object* obj) { + const struct PaintingImage* paintingImage = obj->oPaintingImage; + const PaintingData* vtxData = segmented_to_virtual(painting_data_vertices); + const PaintingData* triangleData = segmented_to_virtual(painting_data_triangles); PaintingData numVtx = vtxData[0]; PaintingData numTris = triangleData[0]; - Gfx *dlist = NULL; + Gfx* dlist = NULL; // When a painting is rippling, this mesh is generated each frame using the Painting's parameters. // This mesh only contains the vertex positions and normals. // Paintings use an additional array to map textures to the mesh. //! TODO: Find out why clearing this between frames causes flickering. - struct PaintingMeshVertex *paintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); + struct PaintingMeshVertex* paintingMesh = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingMeshVertex))); // A list of neighbor triangles for each vertes. This gets cleared each frame while 'paintingMesh' isn't. - struct PaintingNeighborTris *neighborTris = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingNeighborTris))); + struct PaintingNeighborTris* neighborTris = mem_pool_alloc(gEffectsMemoryPool, (numVtx * sizeof(struct PaintingNeighborTris))); bzero(neighborTris, (numVtx * sizeof(struct PaintingNeighborTris))); // The painting's surface normals, used to approximate each of the vertex normals (for gouraud shading). Vec3f *paintingTriNorms = mem_pool_alloc(gEffectsMemoryPool, (numTris * sizeof(Vec3f))); @@ -517,12 +523,12 @@ Gfx *display_painting_rippling(struct Object *obj) { return dlist; } -Gfx *dl_painting_not_rippling(struct Object *obj) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; +Gfx* dl_painting_not_rippling(struct Object* obj) { + const struct PaintingImage* paintingImage = obj->oPaintingImage; Alpha alpha = paintingImage->alpha; s16 imageCount = paintingImage->imageCount; s32 shaded = paintingImage->shaded; - Gfx *dlist = alloc_display_list( + Gfx* dlist = alloc_display_list( SIZEOF_GFX_CMD(SPMatrix(0,0)) + SIZEOF_GFX_CMD(SPDisplayList(0)) + SIZEOF_GFX_CMD(SPVertex(0,0,0)) + @@ -541,14 +547,14 @@ Gfx *dl_painting_not_rippling(struct Object *obj) { SIZEOF_GFX_CMD(SPPopMatrix(0)) + SIZEOF_GFX_CMD(SPEndDisplayList()) ); - Gfx *gfx = dlist; + Gfx* gfx = dlist; if (dlist == NULL) { return dlist; } // Scale - Mtx *scale = alloc_display_list(sizeof(Mtx)); + Mtx* scale = alloc_display_list(sizeof(Mtx)); guScale( scale, (1.0f / PAINTING_SIZE), @@ -557,10 +563,10 @@ Gfx *dl_painting_not_rippling(struct Object *obj) { ); gSPMatrix(gfx++, scale, (G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH)); - Vtx *verts = alloc_display_list((imageCount * 4) * sizeof(*verts)); + Vtx* verts = alloc_display_list((imageCount * 4) * sizeof(*verts)); Vec3c n; - const Texture **textures = segmented_to_virtual(paintingImage->textureArray); + const Texture** textures = segmented_to_virtual(paintingImage->textureArray); s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); @@ -624,7 +630,7 @@ Gfx *dl_painting_not_rippling(struct Object *obj) { ); } - Gfx *endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_textured_end); + Gfx* endDl = (isEnvMap ? dl_paintings_env_mapped_end : dl_paintings_textured_end); gSPDisplayList(gfx++, endDl); if (!shaded) { @@ -640,21 +646,21 @@ Gfx *dl_painting_not_rippling(struct Object *obj) { /** * Draw the painting. */ -Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context) { - struct Object *obj = gCurGraphNodeObjectNode; +Gfx* geo_painting_draw(s32 callContext, struct GraphNode* node, UNUSED void* context) { + struct Object* obj = gCurGraphNodeObjectNode; if (obj == NULL) { return NULL; } // Get the const painting image data. - const struct PaintingImage *paintingImage = obj->oPaintingImage; + const struct PaintingImage* paintingImage = obj->oPaintingImage; if (paintingImage == NULL) { return NULL; } - Gfx *paintingDlist = NULL; + Gfx* paintingDlist = NULL; if (callContext == GEO_CONTEXT_RENDER) { // Draw the painting. @@ -687,7 +693,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con /** * Updates a painting object's room from a point in front of the center of the painting. */ -void painting_update_room(struct Object *obj) { +void painting_update_room(struct Object* obj) { // The center of the painting, but with an offset since paintings are usually between floor triangle edges laterally. Vec3f distPos = { (obj->header.gfx.scale[0] * 0.5f), @@ -712,12 +718,12 @@ void painting_update_room(struct Object *obj) { } void bhv_painting_init(void) { - struct Object *obj = o; + struct Object* obj = o; // Get the painting id from the first byte of the behavior params. The second byte is used for the warp node ID. s32 id = GET_BPARAM1(obj->oBehParams); - const struct PaintingImage *paintingImage = segmented_to_virtual(sPaintings[id]); + const struct PaintingImage* paintingImage = segmented_to_virtual(sPaintings[id]); // Set the object's painting image data pointer. obj->oPaintingImage = paintingImage; @@ -735,8 +741,8 @@ void bhv_painting_init(void) { /** * Check for Mario entering the painting. Returns changed action. */ -s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { - struct MarioState *m = gMarioState; +s32 painting_update_mario_pos(struct Object* obj, Vec3f marioLocalPos) { + struct MarioState* m = gMarioState; // PAINTING_ACT_IDLE will not change the action. s32 newAction = PAINTING_ACT_IDLE; @@ -795,8 +801,8 @@ s32 painting_update_mario_pos(struct Object *obj, Vec3f marioLocalPos) { /** * Returns a pointer to the RippleAnimationPair that best fits the painting type. */ -const struct RippleAnimationPair *painting_get_ripple_animation_type_info(struct Object *obj) { - const struct PaintingImage *paintingImage = obj->oPaintingImage; +const struct RippleAnimationPair* painting_get_ripple_animation_type_info(struct Object* obj) { + const struct PaintingImage* paintingImage = obj->oPaintingImage; s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { @@ -814,7 +820,7 @@ const struct RippleAnimationPair *painting_get_ripple_animation_type_info(struct /** * Set a painting's ripple animation and magnitude. */ -void painting_set_ripple_animation_type(struct Object *obj, const struct RippleAnimation *baseRippleAnim) { +void painting_set_ripple_animation_type(struct Object* obj, const struct RippleAnimation* baseRippleAnim) { obj->oPaintingRippleAnimation = baseRippleAnim; obj->oPaintingCurrRippleMag = baseRippleAnim->mag; } @@ -833,13 +839,17 @@ s32 gDDDPaintingNotMoved = FALSE; * When the painting reaches backPos, a save flag is set so that the painting will spawn at backPos * whenever it loads. */ -void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) { +void move_ddd_painting(struct Object* obj, f32 frontPos, f32 backPos, f32 speed) { #ifdef UNLOCK_ALL obj->oPosX = backPos; return; #endif // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected. - if (save_file_get_star_flags((gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD)) & STAR_FLAG_ACT_1) { + if (save_file_get_star_flags( + (gCurrSaveFileNum - 1), + COURSE_NUM_TO_INDEX(COURSE_DDD) + ) & STAR_FLAG_ACT_1 + ) { // Check whether DDD has already moved back. if (gDDDPaintingNotMoved) { // If we've collected the star but not moved the painting back... @@ -871,8 +881,8 @@ void move_ddd_painting(struct Object *obj, f32 frontPos, f32 backPos, f32 speed) * @param ripplePosX,ripplePosY the position of the ripples. * @param shouldResetTimer if TRUE, set the timer to 0. */ -void painting_start_ripples(struct Object *obj, f32 ripplePosX, f32 ripplePosY, s32 shouldResetTimer) { - const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(obj); +void painting_start_ripples(struct Object* obj, f32 ripplePosX, f32 ripplePosY, s32 shouldResetTimer) { + const struct RippleAnimationPair* rippleAnim = painting_get_ripple_animation_type_info(obj); // Use a different set of variables depending on the state switch (obj->oAction) { @@ -903,14 +913,14 @@ void painting_start_ripples(struct Object *obj, f32 ripplePosX, f32 ripplePosY, } void bhv_painting_loop(void) { - struct Object *obj = o; - const struct PaintingImage *paintingImage = obj->oPaintingImage; + struct Object* obj = o; + const struct PaintingImage* paintingImage = obj->oPaintingImage; Vec3f marioLocalPos; // Update the painting's next action based on Mario's relative position. s32 newAction = painting_update_mario_pos(obj, marioLocalPos); - const struct RippleAnimation *objRippleAnim = obj->oPaintingRippleAnimation; + const struct RippleAnimation* objRippleAnim = obj->oPaintingRippleAnimation; // Decay the ripple over time. if (objRippleAnim != NULL) { @@ -941,7 +951,7 @@ void bhv_painting_loop(void) { } else if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_CONTINUOUS) { // Continuous trigger type: - const struct RippleAnimationPair *rippleAnim = painting_get_ripple_animation_type_info(obj); + const struct RippleAnimationPair* rippleAnim = painting_get_ripple_animation_type_info(obj); // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. diff --git a/src/game/paintings.h b/src/game/paintings.h index 524be5288a..ea9a1aa515 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -113,7 +113,7 @@ struct RippleAnimationPair { */ struct PaintingImage { /// Texture data. - /*0x00*/ const Texture *const *textureArray; + /*0x00*/ const Texture* const* textureArray; /// How many textures the painting uses. /*0x04*/ const s32 imageCount; @@ -157,7 +157,7 @@ struct PaintingNeighborTris { }; /*0x14*/ -Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); +Gfx* geo_painting_draw(s32 callContext, struct GraphNode* node, UNUSED void* context); void bhv_painting_init(void); void bhv_painting_loop(void); From 33b70550e81404e75928573aee7e64430372c710 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 10 Apr 2023 14:08:19 -0400 Subject: [PATCH 74/81] Fix arg formatting in painting_calculate_triangle_normals --- src/game/paintings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/paintings.c b/src/game/paintings.c index 17a9b6457f..ca0baeb2c2 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -191,7 +191,7 @@ void painting_generate_mesh(struct Object* obj, const PaintingData* vtxData, Pai * * The mesh used in game, painting_data_vertices, is in bin/segment2.c. */ -void painting_calculate_triangle_normals(const PaintingData *triangleData, struct PaintingNeighborTris* neighborTris, struct PaintingMeshVertex* paintingMesh, Vec3f* paintingTriNorms) { +void painting_calculate_triangle_normals(const PaintingData* triangleData, struct PaintingNeighborTris* neighborTris, struct PaintingMeshVertex* paintingMesh, Vec3f* paintingTriNorms) { struct PaintingNeighborTris* vtn = NULL; PaintingData i, j; PaintingData numTris = *triangleData++; From 41dc7217bee1df351ece11efa2caffe0d6814420 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Mon, 10 Apr 2023 14:18:36 -0400 Subject: [PATCH 75/81] initiate_painting_warp pointer formatting --- src/game/level_update.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index efbcf7363d..551dbb2ef4 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -654,10 +654,10 @@ s8 gPaintingEjectSoundPlayed = FALSE; * Check is Mario has entered a painting, and if so, initiate a warp. */ void initiate_painting_warp(void) { - struct Object *paintingObj = gMarioState->paintingObj; + struct Object* paintingObj = gMarioState->paintingObj; if (paintingObj != NULL) { - struct ObjectWarpNode *warpNode = area_get_warp_node(GET_BPARAM2(paintingObj->oBehParams)); + struct ObjectWarpNode* warpNode = area_get_warp_node(GET_BPARAM2(paintingObj->oBehParams)); if (warpNode != NULL) { if (gMarioState->action & ACT_FLAG_INTANGIBLE) { @@ -668,7 +668,7 @@ void initiate_painting_warp(void) { gMarioState->marioObj->header.gfx.cameraToObject); } } else { - struct WarpNode *node = &warpNode->node; + struct WarpNode* node = &warpNode->node; if (!(node->destLevel & WARP_NO_CHECKPOINT)) { sWarpCheckpointActive = check_warp_checkpoint(node); From dc0d6c698c7ca6a751d652688663e1e9e6a418c8 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Sun, 16 Apr 2023 14:55:39 -0400 Subject: [PATCH 76/81] _Bool/enum usage --- src/game/level_update.c | 2 +- src/game/paintings.c | 60 +++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 551dbb2ef4..d3a80007e2 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -648,7 +648,7 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 warpFlags) #endif } -s8 gPaintingEjectSoundPlayed = FALSE; +_Bool gPaintingEjectSoundPlayed = FALSE; /** * Check is Mario has entered a painting, and if so, initiate a warp. diff --git a/src/game/paintings.c b/src/game/paintings.c index ca0baeb2c2..654c7017af 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -407,7 +407,7 @@ static s32 get_exponent(s32 x) { /** * Set up the texture format in the display list. */ -void painting_setup_textures(Gfx** gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { +void painting_setup_textures(Gfx** gfx, s16 tWidth, s16 tHeight, _Bool isEnvMap) { s16 cm = isEnvMap ? (G_TX_WRAP | G_TX_NOMIRROR) : G_TX_CLAMP; u32 masks = get_exponent(tWidth); u32 maskt = get_exponent(tHeight); @@ -428,12 +428,11 @@ void painting_setup_textures(Gfx** gfx, s16 tWidth, s16 tHeight, s32 isEnvMap) { * Ripple a painting that has 1 or more images that need to be mapped. */ Gfx* dl_painting_rippling(const struct PaintingImage* paintingImage, struct PaintingMeshVertex* paintingMesh, const PaintingData* triangleMap) { - s16 i; s16 imageCount = paintingImage->imageCount; s16 tWidth = paintingImage->textureWidth; s16 tHeight = paintingImage->textureHeight; const Texture** tArray = segmented_to_virtual(paintingImage->textureArray); - s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); + _Bool isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); Gfx* dlist = alloc_display_list( SIZEOF_GFX_CMD(SPMatrix(0,0)) + @@ -469,7 +468,7 @@ Gfx* dl_painting_rippling(const struct PaintingImage* paintingImage, struct Pain PaintingData numTris = (triangleMap[0] / imageCount); // Map each image to the mesh's vertices. - for (i = 0; i < imageCount; i++) { + for (s16 i = 0; i < imageCount; i++) { // Render a section of the painting. gSPDisplayList(gfx++, render_painting_segment(tArray[i], i, imageCount, tWidth, tHeight, paintingMesh, triangleMap, numTris, paintingImage->alpha)); @@ -568,7 +567,7 @@ Gfx* dl_painting_not_rippling(struct Object* obj) { const Texture** textures = segmented_to_virtual(paintingImage->textureArray); - s32 isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); + _Bool isEnvMap = (paintingImage->imageType == PAINTING_IMAGE_TYPE_ENV_MAP); if (isEnvMap) { vec3_set(n, 0x00, 0x00, 0x7f); @@ -664,12 +663,14 @@ Gfx* geo_painting_draw(s32 callContext, struct GraphNode* node, UNUSED void* con if (callContext == GEO_CONTEXT_RENDER) { // Draw the painting. - if (paintingImage->textureArray != NULL - && paintingImage->imageCount > 0 - && paintingImage->textureWidth > 0 - && paintingImage->textureHeight > 0 - && paintingImage->imageType != PAINTING_IMAGE_TYPE_INVISIBLE - && paintingImage->alpha > 0x00) { + if ( + paintingImage->textureArray != NULL && + paintingImage->imageCount > 0 && + paintingImage->textureWidth > 0 && + paintingImage->textureHeight > 0 && + paintingImage->imageType != PAINTING_IMAGE_TYPE_INVISIBLE && + paintingImage->alpha > 0x00 + ) { // Determine whether the painting is opaque or transparent. if (paintingImage->alpha == 0xFF) { SET_GRAPH_NODE_LAYER(node->flags, LAYER_OCCLUDE_SILHOUETTE_OPAQUE); @@ -741,11 +742,11 @@ void bhv_painting_init(void) { /** * Check for Mario entering the painting. Returns changed action. */ -s32 painting_update_mario_pos(struct Object* obj, Vec3f marioLocalPos) { +enum oActionsPainting painting_update_mario_pos(struct Object* obj, Vec3f marioLocalPos) { struct MarioState* m = gMarioState; // PAINTING_ACT_IDLE will not change the action. - s32 newAction = PAINTING_ACT_IDLE; + enum oActionsPainting newAction = PAINTING_ACT_IDLE; Vec3f marioWorldPos; Vec3s rotation; @@ -760,10 +761,12 @@ s32 painting_update_mario_pos(struct Object* obj, Vec3f marioLocalPos) { vec3f_world_pos_to_local_pos(marioLocalPos, marioWorldPos, &obj->oPosVec, rotation); // Check if Mario is within the painting bounds laterally in local space. - if (marioLocalPos[0] > -PAINTING_EDGE_MARGIN - && marioLocalPos[0] < (obj->header.gfx.scale[0] + PAINTING_EDGE_MARGIN) - && marioLocalPos[1] > -PAINTING_EDGE_MARGIN - && marioLocalPos[1] < (obj->header.gfx.scale[1] + PAINTING_EDGE_MARGIN)) { + if ( + marioLocalPos[0] > -PAINTING_EDGE_MARGIN && + marioLocalPos[0] < (obj->header.gfx.scale[0] + PAINTING_EDGE_MARGIN) && + marioLocalPos[1] > -PAINTING_EDGE_MARGIN && + marioLocalPos[1] < (obj->header.gfx.scale[1] + PAINTING_EDGE_MARGIN) + ) { if (marioLocalPos[2] > PAINTING_WOBBLE_WARP_THRESHOLD) { // In front of the painting, check whether Mario is inside the wobble zone. if (marioLocalPos[2] < PAINTING_WOBBLE_DEPTH) { @@ -786,7 +789,7 @@ s32 painting_update_mario_pos(struct Object* obj, Vec3f marioLocalPos) { m->paintingObj = NULL; } - s32 oldAction = obj->oPaintingStoredAction; + enum oActionsPainting oldAction = obj->oPaintingStoredAction; obj->oPaintingStoredAction = newAction; @@ -808,8 +811,10 @@ const struct RippleAnimationPair* painting_get_ripple_animation_type_info(struct if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY; - if (obj->header.gfx.scale[0] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD - || obj->header.gfx.scale[1] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD) { + if ( + obj->header.gfx.scale[0] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD || + obj->header.gfx.scale[1] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD + ) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; } } @@ -827,7 +832,7 @@ void painting_set_ripple_animation_type(struct Object* obj, const struct RippleA #if defined(ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS) || defined(UNLOCK_ALL) // Whether the painting should be moved or not. -s32 gDDDPaintingNotMoved = FALSE; +_Bool gDDDPaintingNotMoved = FALSE; /** * Controls the x coordinate of the DDD painting. @@ -845,7 +850,8 @@ void move_ddd_painting(struct Object* obj, f32 frontPos, f32 backPos, f32 speed) return; #endif // Obtain the DDD star flags and find out whether Board Bowser's Sub was collected. - if (save_file_get_star_flags( + if ( + save_file_get_star_flags( (gCurrSaveFileNum - 1), COURSE_NUM_TO_INDEX(COURSE_DDD) ) & STAR_FLAG_ACT_1 @@ -881,7 +887,7 @@ void move_ddd_painting(struct Object* obj, f32 frontPos, f32 backPos, f32 speed) * @param ripplePosX,ripplePosY the position of the ripples. * @param shouldResetTimer if TRUE, set the timer to 0. */ -void painting_start_ripples(struct Object* obj, f32 ripplePosX, f32 ripplePosY, s32 shouldResetTimer) { +void painting_start_ripples(struct Object* obj, f32 ripplePosX, f32 ripplePosY, _Bool shouldResetTimer) { const struct RippleAnimationPair* rippleAnim = painting_get_ripple_animation_type_info(obj); // Use a different set of variables depending on the state @@ -918,7 +924,7 @@ void bhv_painting_loop(void) { Vec3f marioLocalPos; // Update the painting's next action based on Mario's relative position. - s32 newAction = painting_update_mario_pos(obj, marioLocalPos); + enum oActionsPainting newAction = painting_update_mario_pos(obj, marioLocalPos); const struct RippleAnimation* objRippleAnim = obj->oPaintingRippleAnimation; @@ -955,8 +961,10 @@ void bhv_painting_loop(void) { // If the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple. // If Mario goes below the surface but doesn't warp, the painting will eventually reset. - if ((obj->oAction == PAINTING_ACT_ENTERED) - && (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag)) { + if ( + (obj->oAction == PAINTING_ACT_ENTERED) && + (obj->oPaintingCurrRippleMag <= rippleAnim->passive.mag) + ) { painting_set_ripple_animation_type(obj, &rippleAnim->passive); obj->oAction = PAINTING_ACT_RIPPLING; } From b518acfc7d1a96587b6a72daccc1eb7d76e0fd8a Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 26 Apr 2023 12:28:20 -0400 Subject: [PATCH 77/81] use _Bool for 'shaded' --- src/game/paintings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/paintings.h b/src/game/paintings.h index ea9a1aa515..c2c4e6fe76 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -129,7 +129,7 @@ struct PaintingImage { /*0x0D*/ const s8 rippleTrigger; /// Whether the painting uses shading when not rippling. Only used for Snowman's Land in vanilla and makes the transition to/from rippling not seamless. - /*0x0E*/ const s8 shaded; + /*0x0E*/ const _Bool shaded; /// The painting's transparency (0..255). Determines the drawing layer of the painting. /*0x0F*/ const Alpha alpha; From e02659d23d3cd3e3c592374dd0744592d7ce79ad Mon Sep 17 00:00:00 2001 From: Arceveti Date: Fri, 1 Sep 2023 19:22:14 -0700 Subject: [PATCH 78/81] Improve painting struct definitions --- src/game/paintings.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/game/paintings.h b/src/game/paintings.h index c2c4e6fe76..d3ceb47371 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -93,25 +93,25 @@ enum oActionsPainting { /** * A list of preset constants for the ripple animations. */ -struct RippleAnimation { +typedef struct RippleAnimation { /*0x00*/ const f32 mag; /// Controls how high the peaks of the ripple are when the animation starts. /*0x04*/ const f32 decay; /// Multiplier that controls how fast the ripple regresses to the IDLE state. /*0x08*/ const f32 rate; /// Controls the ripple's frequency. /*0x0C*/ const f32 dispersion; /// The rate at which the magnitude of the ripple decreases as you move farther from the central point of the ripple. -}; /*0x10*/ +} RippleAnimation; /*0x10*/ /** * A ripple animation pair. */ -struct RippleAnimationPair { +typedef struct RippleAnimationPair { /*0x00*/ const struct RippleAnimation passive; /// The ripple when the painting is continuously rippling or is lightly touched. /*0x10*/ const struct RippleAnimation entry; /// The ripple when the painting is entered. -}; /*0x20*/ +} RippleAnimationPair; /*0x20*/ /** * Painting info struct. */ -struct PaintingImage { +typedef struct PaintingImage { /// Texture data. /*0x00*/ const Texture* const* textureArray; @@ -137,24 +137,24 @@ struct PaintingImage { /// By default a painting is 614.0f x 614.0f (PAINTING_SIZE). /*0x10*/ const f32 sizeX; /*0x14*/ const f32 sizeY; -}; /*0x18*/ +} PaintingImage; /*0x18*/ /** * Contains the position and normal of a vertex in the painting's generated mesh. */ -struct PaintingMeshVertex { +typedef struct PaintingMeshVertex { /*0x00*/ Vec3s pos; /*0x06*/ Vec3c norm; -}; /*0x0C*/ +} PaintingMeshVertex; /*0x0C*/ /** * Lists the neighboring triangles for each vertex in the mesh. * Used when applying gouraud shading to the generated ripple mesh. */ -struct PaintingNeighborTris { +typedef struct PaintingNeighborTris { /*0x00*/ s16 numNeighbors; /*0x02*/ s16 neighborTris[9]; -}; /*0x14*/ +} PaintingNeighborTris; /*0x14*/ Gfx* geo_painting_draw(s32 callContext, struct GraphNode* node, UNUSED void* context); From bd83b076253899ebef78eeedbd52af10ccf8a0e8 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 7 Sep 2023 15:24:43 -0700 Subject: [PATCH 79/81] Some documentation + add IEEE754 unions + formatting --- include/types.h | 22 +++++++++++++++++ src/game/paintings.c | 57 +++++++++++++++++++++----------------------- src/game/paintings.h | 4 ++-- 3 files changed, 51 insertions(+), 32 deletions(-) diff --git a/include/types.h b/include/types.h index bbb4970583..7a2ea6ee65 100644 --- a/include/types.h +++ b/include/types.h @@ -24,6 +24,28 @@ #define SCREEN_CENTER_X (SCREEN_WIDTH / 2) #define SCREEN_CENTER_Y (SCREEN_HEIGHT / 2) +typedef union { + struct PACKED { + /*0x00*/ u32 sign : 1; + /*0x00*/ u32 exponent : 8; + /*0x01*/ u32 mantissa : 23; + }; /*0x04*/ + s32 asS32; + u32 asU32; + f32 asF32; +} IEEE754_f32; /*0x04*/ + +typedef union { + struct PACKED { + /*0x00*/ u64 sign : 1; + /*0x00*/ u64 exponent : 11; + /*0x01*/ u64 mantissa : 52; + }; /*0x08*/ + s64 asS64; + u64 asU64; + f64 asF64; +} IEEE754_f64; /*0x08*/ + struct Config { f32 audioFrequency; #ifdef WIDE diff --git a/src/game/paintings.c b/src/game/paintings.c index 654c7017af..61d5a6dc34 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -391,24 +391,18 @@ Gfx* render_painting_segment(const Texture* img, s16 index, s16 imageCount, s16 /** * Gets the exponent of an integer by converting it into a float and extracting the exponent bits. + * Equivalent to log2(x) or __builtin_ctz(x) but faster. */ static s32 get_exponent(s32 x) { - union { - struct PACKED { - u32 sign : 1; - u32 exponent : 8; - u32 mantissa : 23; - }; - f32 f; - } b = { .f = x }; - return (b.exponent - 127); + IEEE754_f32 val = { .asF32 = x }; + return (val.exponent - 127); } /** * Set up the texture format in the display list. */ void painting_setup_textures(Gfx** gfx, s16 tWidth, s16 tHeight, _Bool isEnvMap) { - s16 cm = isEnvMap ? (G_TX_WRAP | G_TX_NOMIRROR) : G_TX_CLAMP; + s16 cm = (isEnvMap ? (G_TX_WRAP | G_TX_NOMIRROR) : G_TX_CLAMP); u32 masks = get_exponent(tWidth); u32 maskt = get_exponent(tHeight); @@ -664,12 +658,12 @@ Gfx* geo_painting_draw(s32 callContext, struct GraphNode* node, UNUSED void* con if (callContext == GEO_CONTEXT_RENDER) { // Draw the painting. if ( - paintingImage->textureArray != NULL && - paintingImage->imageCount > 0 && - paintingImage->textureWidth > 0 && - paintingImage->textureHeight > 0 && - paintingImage->imageType != PAINTING_IMAGE_TYPE_INVISIBLE && - paintingImage->alpha > 0x00 + (paintingImage->textureArray != NULL) && + (paintingImage->imageCount > 0) && + (paintingImage->textureWidth > 0) && + (paintingImage->textureHeight > 0) && + (paintingImage->imageType != PAINTING_IMAGE_TYPE_INVISIBLE) && + (paintingImage->alpha > 0x00) ) { // Determine whether the painting is opaque or transparent. if (paintingImage->alpha == 0xFF) { @@ -718,11 +712,14 @@ void painting_update_room(struct Object* obj) { ); } +/** + * @brief Initializes a painting object. + */ void bhv_painting_init(void) { struct Object* obj = o; // Get the painting id from the first byte of the behavior params. The second byte is used for the warp node ID. - s32 id = GET_BPARAM1(obj->oBehParams); + enum PaintingImageIDs id = GET_BPARAM1(obj->oBehParams); const struct PaintingImage* paintingImage = segmented_to_virtual(sPaintings[id]); @@ -762,10 +759,10 @@ enum oActionsPainting painting_update_mario_pos(struct Object* obj, Vec3f marioL // Check if Mario is within the painting bounds laterally in local space. if ( - marioLocalPos[0] > -PAINTING_EDGE_MARGIN && - marioLocalPos[0] < (obj->header.gfx.scale[0] + PAINTING_EDGE_MARGIN) && - marioLocalPos[1] > -PAINTING_EDGE_MARGIN && - marioLocalPos[1] < (obj->header.gfx.scale[1] + PAINTING_EDGE_MARGIN) + (marioLocalPos[0] > -PAINTING_EDGE_MARGIN) && + (marioLocalPos[0] < (obj->header.gfx.scale[0] + PAINTING_EDGE_MARGIN)) && + (marioLocalPos[1] > -PAINTING_EDGE_MARGIN) && + (marioLocalPos[1] < (obj->header.gfx.scale[1] + PAINTING_EDGE_MARGIN)) ) { if (marioLocalPos[2] > PAINTING_WOBBLE_WARP_THRESHOLD) { // In front of the painting, check whether Mario is inside the wobble zone. @@ -806,14 +803,14 @@ enum oActionsPainting painting_update_mario_pos(struct Object* obj, Vec3f marioL */ const struct RippleAnimationPair* painting_get_ripple_animation_type_info(struct Object* obj) { const struct PaintingImage* paintingImage = obj->oPaintingImage; - s8 rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; + enum PaintingRippleAnimations rippleAnimationType = RIPPLE_ANIM_CONTINUOUS; if (paintingImage->rippleTrigger == RIPPLE_TRIGGER_PROXIMITY) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY; if ( - obj->header.gfx.scale[0] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD || - obj->header.gfx.scale[1] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD + (obj->header.gfx.scale[0] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD) || + (obj->header.gfx.scale[1] >= PAINTING_SCALE_LARGE_RIPPLE_THRESHOLD) ) { rippleAnimationType = RIPPLE_ANIM_PROXIMITY_LARGE; } @@ -837,12 +834,12 @@ _Bool gDDDPaintingNotMoved = FALSE; /** * Controls the x coordinate of the DDD painting. * - * Before Mario gets the "Board Bowser's Sub" star in DDD, the painting spawns at frontPos. - * - * If Mario just got the star, the painting's x coordinate moves to backPos at a rate of `speed` units. + * Before Mario gets the "Board Bowser's Sub" star in DDD, the painting spawns at frontPos, and set gDDDPaintingNotMoved to TRUE. * - * When the painting reaches backPos, a save flag is set so that the painting will spawn at backPos - * whenever it loads. + * If Mario has the star, and the painting was last seen at frontPos (gDDDPaintingNotMoved == TRUE), the painting's x coordinate moves to backPos at a rate of `speed` units. + * When the painting reaches backPos, gDDDPaintingNotMoved is set to FALSE. + * + * If Mario has the star, and the painting was never seen at frontPos or it has already moved (gDDDPaintingNotMoved == FALSE), the painting will spawn at backPos. */ void move_ddd_painting(struct Object* obj, f32 frontPos, f32 backPos, f32 speed) { #ifdef UNLOCK_ALL @@ -950,7 +947,7 @@ void bhv_painting_loop(void) { if (newAction == PAINTING_ACT_ENTERED) { obj->oAction = newAction; painting_start_ripples(obj, marioLocalPos[0], marioLocalPos[1], TRUE); // Start entering - } else if (obj->oAction != PAINTING_ACT_ENTERED && (newAction == PAINTING_ACT_RIPPLING)) { + } else if ((obj->oAction != PAINTING_ACT_ENTERED) && (newAction == PAINTING_ACT_RIPPLING)) { obj->oAction = newAction; painting_start_ripples(obj, marioLocalPos[0], marioLocalPos[1], TRUE); // Start wobbling } diff --git a/src/game/paintings.h b/src/game/paintings.h index d3ceb47371..8136d261f7 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -122,10 +122,10 @@ typedef struct PaintingImage { /*0x08*/ const s16 textureWidth; /*0x0A*/ const s16 textureHeight; - /// Controls how the painting image is displayed. PAINTING_IMAGE_TYPE_INVISIBLE, PAINTING_IMAGE_TYPE_TEXTURE, or PAINTING_IMAGE_TYPE_ENV_MAP. + /// Controls how the painting image is displayed. enum PaintingType. /*0x0C*/ const s8 imageType; - /// Controls when a passive ripple starts. RIPPLE_TRIGGER_NONE, RIPPLE_TRIGGER_CONTINUOUS, or RIPPLE_TRIGGER_PROXIMITY. + /// Controls when a passive ripple starts. enum RippleTriggers. /*0x0D*/ const s8 rippleTrigger; /// Whether the painting uses shading when not rippling. Only used for Snowman's Land in vanilla and makes the transition to/from rippling not seamless. From 0761d2fdecc153df8a48ca37af00c677c5fba3b1 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Wed, 27 Sep 2023 14:54:29 -0700 Subject: [PATCH 80/81] Fix(?) painting warp checkpoints --- src/game/level_update.c | 6 +++--- src/game/save_file.c | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 0dfc33d091..3319bd2430 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -680,7 +680,7 @@ void initiate_painting_warp(void) { } else { struct WarpNode* node = &warpNode->node; - if (!(node->destLevel & WARP_NO_CHECKPOINT)) { + if (!(node->destLevel & WARP_CHECKPOINT)) { sWarpCheckpointActive = check_warp_checkpoint(node); } @@ -762,8 +762,8 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { break; case WARP_OP_WARP_FLOOR: - if ((m->floor) && (m->floor->force & 0xFF)) { - sSourceWarpNodeId = m->floor->force & 0xFF; + if (m->floor && (m->floor->force & 0xFF)) { + sSourceWarpNodeId = (m->floor->force & 0xFF); } else { sSourceWarpNodeId = WARP_NODE_WARP_FLOOR; if (area_get_warp_node(sSourceWarpNodeId) == NULL) { diff --git a/src/game/save_file.c b/src/game/save_file.c index 5d625891c6..0f245343c1 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -765,11 +765,11 @@ void disable_warp_checkpoint(void) { void check_if_should_set_warp_checkpoint(struct WarpNode *warpNode) { if (warpNode->destLevel & WARP_CHECKPOINT) { // Overwrite the warp checkpoint variables. - gWarpCheckpoint.actNum = gCurrActNum; + gWarpCheckpoint.actNum = gCurrActNum; gWarpCheckpoint.courseNum = gCurrCourseNum; - gWarpCheckpoint.levelID = (warpNode->destLevel & WARP_DEST_LEVEL_NUM_MASK); - gWarpCheckpoint.areaNum = warpNode->destArea; - gWarpCheckpoint.warpNode = warpNode->destNode; + gWarpCheckpoint.levelID = (warpNode->destLevel & WARP_DEST_LEVEL_NUM_MASK); + gWarpCheckpoint.areaNum = warpNode->destArea; + gWarpCheckpoint.warpNode = warpNode->destNode; } } @@ -783,11 +783,14 @@ s32 check_warp_checkpoint(struct WarpNode *warpNode) { s16 currCourseNum = gLevelToCourseNumTable[(warpNode->destLevel & WARP_DEST_LEVEL_NUM_MASK) - 1]; // gSavedCourseNum is only used in this function. - if (gWarpCheckpoint.courseNum != COURSE_NONE && gSavedCourseNum == currCourseNum - && gWarpCheckpoint.actNum == gCurrActNum) { - warpNode->destLevel = gWarpCheckpoint.levelID; - warpNode->destArea = gWarpCheckpoint.areaNum; - warpNode->destNode = gWarpCheckpoint.warpNode; + if ( + (gWarpCheckpoint.courseNum != COURSE_NONE) && + (gSavedCourseNum == currCourseNum) && + (gWarpCheckpoint.actNum == gCurrActNum) + ) { + warpNode->destLevel = gWarpCheckpoint.levelID; + warpNode->destArea = gWarpCheckpoint.areaNum; + warpNode->destNode = gWarpCheckpoint.warpNode; warpCheckpointActive = TRUE; } else { // Disable the warp checkpoint just in case the other 2 conditions failed? From e6c6a8b6917575cee91a272469d1cb4bd7c37bc7 Mon Sep 17 00:00:00 2001 From: Arceveti Date: Thu, 28 Sep 2023 10:57:13 -0700 Subject: [PATCH 81/81] Move segment2 paintings data to paintings.c.in --- bin/segment2.c | 541 +----------------------------------- bin/segment2/paintings.c.in | 539 +++++++++++++++++++++++++++++++++++ 2 files changed, 540 insertions(+), 540 deletions(-) create mode 100644 bin/segment2/paintings.c.in diff --git a/bin/segment2.c b/bin/segment2.c index 385124e49e..d12dfb4c0f 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2969,543 +2969,4 @@ const Gfx dl_ia8_up_arrow_end[] = { gsSPEndDisplayList(), }; -// 0x02014958 - 0x02014960 - -// 0x02014970 - 0x020149A8 -const Gfx dl_paintings_rippling_begin[] = { - gsDPPipeSync(), - gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), - gsDPSetCombineMode(G_CC_MODULATERGBA, G_CC_MODULATERGBA), - gsSPLightColor(LIGHT_1, 0xffffffff), - gsSPLightColor(LIGHT_2, 0x505050ff), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsDPTileSync(), - gsSPEndDisplayList(), -}; - -// 0x020149A8 - 0x020149C8 -const Gfx dl_paintings_rippling_end[] = { - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - -const Gfx sub_dl_paintings_textured_begin[] = { - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), - // gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD), - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsDPTileSync(), - gsSPEndDisplayList(), -}; - -// 0x07021A48 - 0x07021AA0 -const Gfx dl_paintings_textured_shaded_begin[] = { - gsDPPipeSync(), - gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), - gsSPLightColor(LIGHT_1, 0xffffffff), - gsSPLightColor(LIGHT_2, 0x505050ff), - gsSPDisplayList(sub_dl_paintings_textured_begin), - gsSPEndDisplayList(), -}; - -// 0x07021A48 - 0x07021AA0 -const Gfx dl_paintings_textured_vertex_colored_begin[] = { - gsDPPipeSync(), - gsSPClearGeometryMode(G_LIGHTING), - gsSPDisplayList(sub_dl_paintings_textured_begin), - gsSPEndDisplayList(), -}; - -// 0x07021AA0 - 0x07021AC0 -const Gfx dl_paintings_textured_end[] = { - gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - -// 0x020149C8 - 0x02014A00 -const Gfx dl_paintings_env_mapped_begin[] = { - gsDPPipeSync(), - gsSPSetGeometryMode(G_LIGHTING | G_TEXTURE_GEN), - gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), - gsSPLightColor(LIGHT_1, 0xffffffff), - gsSPLightColor(LIGHT_2, 0x505050ff), - gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_ON), - gsDPTileSync(), - gsSPEndDisplayList(), -}; - -// 0x02014A00 - 0x02014A30 -const Gfx dl_paintings_env_mapped_end[] = { - gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_OFF), - gsDPPipeSync(), - gsSPGeometryModeSetFirst(G_TEXTURE_GEN, G_LIGHTING), - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPEndDisplayList(), -}; - -// 0x02014A30 - 0x02014A60 -const Gfx dl_paintings_ripple_triangles[] = { -#ifdef F3DEX_GBI_2 - gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), - gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), - gsSP2Triangles(12, 13, 14, 0x0, 15, 16, 17, 0x0), - gsSP2Triangles(18, 19, 20, 0x0, 21, 22, 23, 0x0), - gsSP2Triangles(24, 25, 26, 0x0, 27, 28, 29, 0x0), -#else - gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), - gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), - gsSP1Triangle( 12, 13, 14, 0x0), -#endif - gsSPEndDisplayList(), -}; - -// Painting vertex coordinates -#define PDX(x) ((x) * (PAINTING_SIZE / 12.0f)) // 51.2f -#define PDY(y) ((y) * (PAINTING_SIZE / 20.0f)) // 30.72f -#define PAINTING_VERTEX(x, y, r) PDX(x), PDY(y), (r) - -// 14A60: triangle mesh -// 0x02014A60 -const PaintingData painting_data_vertices[] = { - 157, // numVtx - // format: - // 2D point (x, y), ripple (0 or 1) - PAINTING_VERTEX(12, 19, 0), // 0 - PAINTING_VERTEX(12, 20, 0), // 1 - PAINTING_VERTEX(11, 20, 0), // 2 - PAINTING_VERTEX(11, 18, 1), // 3 - PAINTING_VERTEX(12, 17, 0), // 4 - PAINTING_VERTEX(10, 19, 1), // 5 - PAINTING_VERTEX(10, 20, 0), // 6 - PAINTING_VERTEX( 6, 20, 0), // 7 - PAINTING_VERTEX( 6, 19, 1), // 8 - PAINTING_VERTEX( 7, 20, 0), // 9 - PAINTING_VERTEX( 5, 20, 0), // 10 - PAINTING_VERTEX( 5, 18, 1), // 11 - PAINTING_VERTEX( 6, 17, 1), // 12 - PAINTING_VERTEX( 7, 18, 1), // 13 - PAINTING_VERTEX( 8, 19, 1), // 14 - PAINTING_VERTEX( 9, 20, 0), // 15 - PAINTING_VERTEX(10, 17, 1), // 16 - PAINTING_VERTEX( 9, 18, 1), // 17 - PAINTING_VERTEX( 8, 17, 1), // 18 - PAINTING_VERTEX(11, 10, 1), // 19 - PAINTING_VERTEX(12, 11, 0), // 20 - PAINTING_VERTEX(11, 14, 1), // 21 - PAINTING_VERTEX(12, 13, 0), // 22 - PAINTING_VERTEX(11, 12, 1), // 23 - PAINTING_VERTEX(10, 11, 1), // 24 - PAINTING_VERTEX( 9, 10, 1), // 25 - PAINTING_VERTEX( 9, 14, 1), // 26 - PAINTING_VERTEX(10, 13, 1), // 27 - PAINTING_VERTEX(10, 15, 1), // 28 - PAINTING_VERTEX( 8, 11, 1), // 29 - PAINTING_VERTEX( 9, 12, 1), // 30 - PAINTING_VERTEX( 7, 10, 1), // 31 - PAINTING_VERTEX( 8, 15, 1), // 32 - PAINTING_VERTEX( 7, 14, 1), // 33 - PAINTING_VERTEX( 8, 13, 1), // 34 - PAINTING_VERTEX( 7, 12, 1), // 35 - PAINTING_VERTEX( 6, 11, 1), // 36 - PAINTING_VERTEX( 5, 10, 1), // 37 - PAINTING_VERTEX( 6, 13, 1), // 38 - PAINTING_VERTEX( 5, 14, 1), // 39 - PAINTING_VERTEX( 6, 15, 1), // 40 - PAINTING_VERTEX(12, 15, 0), // 41 - PAINTING_VERTEX(11, 16, 1), // 42 - PAINTING_VERTEX( 9, 16, 1), // 43 - PAINTING_VERTEX( 7, 16, 1), // 44 - PAINTING_VERTEX( 5, 16, 1), // 45 - PAINTING_VERTEX( 8, 9, 1), // 46 - PAINTING_VERTEX(10, 9, 1), // 47 - PAINTING_VERTEX( 6, 9, 1), // 48 - PAINTING_VERTEX(12, 1, 0), // 49 - PAINTING_VERTEX(12, 0, 0), // 50 - PAINTING_VERTEX(11, 0, 0), // 51 - PAINTING_VERTEX(11, 4, 1), // 52 - PAINTING_VERTEX(12, 3, 0), // 53 - PAINTING_VERTEX(10, 1, 1), // 54 - PAINTING_VERTEX(11, 2, 1), // 55 - PAINTING_VERTEX( 9, 0, 0), // 56 - PAINTING_VERTEX(10, 0, 0), // 57 - PAINTING_VERTEX( 9, 4, 1), // 58 - PAINTING_VERTEX(10, 3, 1), // 59 - PAINTING_VERTEX(10, 5, 1), // 60 - PAINTING_VERTEX( 8, 1, 1), // 61 - PAINTING_VERTEX( 9, 2, 1), // 62 - PAINTING_VERTEX( 7, 0, 0), // 63 - PAINTING_VERTEX( 8, 0, 0), // 64 - PAINTING_VERTEX( 8, 3, 1), // 65 - PAINTING_VERTEX( 7, 4, 1), // 66 - PAINTING_VERTEX( 8, 5, 1), // 67 - PAINTING_VERTEX( 6, 1, 1), // 68 - PAINTING_VERTEX( 7, 2, 1), // 69 - PAINTING_VERTEX( 5, 0, 0), // 70 - PAINTING_VERTEX( 6, 0, 0), // 71 - PAINTING_VERTEX( 5, 4, 1), // 72 - PAINTING_VERTEX( 6, 3, 1), // 73 - PAINTING_VERTEX( 6, 5, 1), // 74 - PAINTING_VERTEX(12, 5, 0), // 75 - PAINTING_VERTEX(11, 8, 1), // 76 - PAINTING_VERTEX(12, 7, 0), // 77 - PAINTING_VERTEX(11, 6, 1), // 78 - PAINTING_VERTEX( 9, 8, 1), // 79 - PAINTING_VERTEX(10, 7, 1), // 80 - PAINTING_VERTEX( 9, 6, 1), // 81 - PAINTING_VERTEX( 7, 8, 1), // 82 - PAINTING_VERTEX( 8, 7, 1), // 83 - PAINTING_VERTEX( 7, 6, 1), // 84 - PAINTING_VERTEX( 5, 8, 1), // 85 - PAINTING_VERTEX( 6, 7, 1), // 86 - PAINTING_VERTEX( 4, 19, 1), // 87 - PAINTING_VERTEX( 0, 20, 0), // 88 - PAINTING_VERTEX( 0, 19, 0), // 89 - PAINTING_VERTEX( 1, 20, 0), // 90 - PAINTING_VERTEX( 1, 18, 1), // 91 - PAINTING_VERTEX( 2, 19, 1), // 92 - PAINTING_VERTEX( 4, 17, 1), // 93 - PAINTING_VERTEX( 3, 18, 1), // 94 - PAINTING_VERTEX( 3, 20, 0), // 95 - PAINTING_VERTEX( 2, 17, 1), // 96 - PAINTING_VERTEX( 5, 12, 1), // 97 - PAINTING_VERTEX( 4, 11, 1), // 98 - PAINTING_VERTEX( 3, 10, 1), // 99 - PAINTING_VERTEX( 3, 14, 1), // 100 - PAINTING_VERTEX( 4, 13, 1), // 101 - PAINTING_VERTEX( 4, 15, 1), // 102 - PAINTING_VERTEX( 3, 12, 1), // 103 - PAINTING_VERTEX( 2, 11, 1), // 104 - PAINTING_VERTEX( 1, 10, 1), // 105 - PAINTING_VERTEX( 1, 14, 1), // 106 - PAINTING_VERTEX( 2, 13, 1), // 107 - PAINTING_VERTEX( 2, 15, 1), // 108 - PAINTING_VERTEX( 1, 12, 1), // 109 - PAINTING_VERTEX( 0, 11, 0), // 110 - PAINTING_VERTEX( 0, 15, 0), // 111 - PAINTING_VERTEX( 3, 16, 1), // 112 - PAINTING_VERTEX( 1, 16, 1), // 113 - PAINTING_VERTEX( 3, 8, 1), // 114 - PAINTING_VERTEX( 2, 9, 1), // 115 - PAINTING_VERTEX( 4, 9, 1), // 116 - PAINTING_VERTEX( 0, 9, 0), // 117 - PAINTING_VERTEX( 1, 8, 1), // 118 - PAINTING_VERTEX( 4, 1, 1), // 119 - PAINTING_VERTEX( 5, 2, 1), // 120 - PAINTING_VERTEX( 4, 0, 0), // 121 - PAINTING_VERTEX( 3, 0, 0), // 122 - PAINTING_VERTEX( 4, 5, 1), // 123 - PAINTING_VERTEX( 4, 3, 1), // 124 - PAINTING_VERTEX( 3, 4, 1), // 125 - PAINTING_VERTEX( 2, 1, 1), // 126 - PAINTING_VERTEX( 3, 2, 1), // 127 - PAINTING_VERTEX( 2, 0, 0), // 128 - PAINTING_VERTEX( 1, 0, 0), // 129 - PAINTING_VERTEX( 1, 4, 1), // 130 - PAINTING_VERTEX( 2, 3, 1), // 131 - PAINTING_VERTEX( 2, 5, 1), // 132 - PAINTING_VERTEX( 0, 1, 0), // 133 - PAINTING_VERTEX( 1, 2, 1), // 134 - PAINTING_VERTEX( 0, 5, 0), // 135 - PAINTING_VERTEX( 5, 6, 1), // 136 - PAINTING_VERTEX( 4, 7, 1), // 137 - PAINTING_VERTEX( 3, 6, 1), // 138 - PAINTING_VERTEX( 2, 7, 1), // 139 - PAINTING_VERTEX( 1, 6, 1), // 140 - PAINTING_VERTEX( 8, 20, 0), // 141 - PAINTING_VERTEX(12, 10, 0), // 142 - PAINTING_VERTEX(12, 9, 0), // 143 - PAINTING_VERTEX(10, 10, 1), // 144 - PAINTING_VERTEX( 8, 10, 1), // 145 - PAINTING_VERTEX( 6, 10, 1), // 146 - PAINTING_VERTEX( 4, 20, 0), // 147 - PAINTING_VERTEX( 0, 17, 0), // 148 - PAINTING_VERTEX( 2, 20, 0), // 149 - PAINTING_VERTEX( 4, 10, 1), // 150 - PAINTING_VERTEX( 2, 10, 1), // 151 - PAINTING_VERTEX( 0, 13, 0), // 152 - PAINTING_VERTEX( 0, 10, 0), // 153 - PAINTING_VERTEX( 0, 7, 0), // 154 - PAINTING_VERTEX( 0, 3, 0), // 155 - PAINTING_VERTEX( 0, 0, 0), // 156 -}; - -#undef PDX -#undef PDY -#undef PAINTING_VERTEX - -// 0x07022660 - 0x07023042 -const PaintingData painting_data_triangles[] = { - 264, // num triangles - // Grouped by 5 + one remainder group, - // = 15 vertices per group + a few extra triangles - - // Bottom half - 60, 59, 52, - 49, 53, 55, - 50, 49, 51, - 51, 49, 55, - 52, 55, 53, - 53, 75, 52, - 54, 55, 59, - 52, 59, 55, - 55, 54, 51, - 54, 59, 62, - 56, 54, 62, - 57, 54, 56, - 54, 57, 51, - 58, 62, 59, - 59, 60, 58, - 68, 73, 120, - 61, 62, 65, - 58, 65, 62, - 62, 61, 56, - 63, 61, 69, - 64, 61, 63, - 61, 65, 69, - 61, 64, 56, - 65, 67, 66, - 66, 69, 65, - 67, 65, 58, - 69, 68, 63, - 66, 73, 69, - 68, 69, 73, - 70, 68, 120, - 71, 68, 70, - 68, 71, 63, - 73, 74, 72, - 72, 120, 73, - 74, 73, 66, - 75, 77, 78, - 52, 75, 78, - 76, 78, 77, - 77, 143, 76, - 76, 80, 78, - 60, 78, 80, - 78, 60, 52, - 83, 46, 82, - 58, 60, 81, - 60, 80, 81, - 80, 47, 79, - 47, 80, 76, - 79, 81, 80, - 79, 83, 81, - 81, 67, 58, - 67, 81, 83, - 66, 67, 84, - 67, 83, 84, - 46, 83, 79, - 82, 84, 83, - 84, 74, 66, - 82, 86, 84, - 74, 84, 86, - 72, 74, 136, - 74, 86, 136, - 86, 48, 85, - 85, 136, 86, - 48, 86, 82, - 25, 46, 79, - 79, 47, 25, - 31, 46, 145, - 46, 25, 145, - 82, 46, 31, - 47, 19, 144, - 25, 47, 144, - 19, 47, 76, - 76, 143, 19, - 19, 143, 142, - 119, 124, 127, - 31, 48, 82, - 85, 48, 37, - 48, 31, 146, - 37, 48, 146, - 72, 124, 120, - 120, 119, 70, - 119, 120, 124, - 122, 119, 127, - 121, 119, 122, - 119, 121, 70, - 130, 134, 131, - 124, 123, 125, - 125, 127, 124, - 123, 124, 72, - 125, 131, 127, - 127, 126, 122, - 126, 127, 131, - 126, 128, 122, - 129, 126, 134, - 128, 126, 129, - 126, 131, 134, - 132, 131, 125, - 131, 132, 130, - 130, 155, 134, - 134, 133, 129, - 133, 134, 155, - 133, 156, 129, - 135, 155, 130, - 136, 123, 72, - 85, 137, 136, - 123, 136, 137, - 125, 123, 138, - 123, 137, 138, - 116, 137, 85, - 137, 116, 114, - 114, 138, 137, - 138, 132, 125, - 132, 138, 139, - 114, 139, 138, - 130, 132, 140, - 132, 139, 140, - 139, 115, 118, - 118, 140, 139, - 115, 139, 114, - 140, 135, 130, - 118, 154, 140, - 135, 140, 154, - 117, 105, 153, - 117, 154, 118, - 99, 115, 114, - 114, 116, 99, - 118, 115, 105, - 115, 99, 151, - 105, 115, 151, - 37, 116, 85, - 116, 37, 150, - 99, 116, 150, - 105, 117, 118, - // Top half - 9, 8, 13, - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 2, 6, - 2, 5, 3, - 8, 7, 10, - 7, 8, 9, - 11, 8, 10, - 12, 8, 11, - 8, 12, 13, - 13, 14, 9, - 14, 141, 9, - 5, 6, 15, - 5, 16, 3, - 16, 5, 17, - 17, 5, 15, - 14, 15, 141, - 15, 14, 17, - 18, 14, 13, - 14, 18, 17, - 19, 142, 20, - 19, 20, 23, - 28, 27, 21, - 22, 41, 21, - 21, 23, 22, - 20, 22, 23, - 23, 24, 19, - 21, 27, 23, - 24, 23, 27, - 19, 24, 144, - 25, 144, 24, - 25, 24, 30, - 24, 27, 30, - 26, 30, 27, - 27, 28, 26, - 31, 36, 146, - 26, 34, 30, - 30, 29, 25, - 29, 30, 34, - 25, 29, 145, - 31, 145, 29, - 31, 29, 35, - 29, 34, 35, - 32, 34, 26, - 33, 35, 34, - 34, 32, 33, - 35, 36, 31, - 33, 38, 35, - 36, 35, 38, - 37, 36, 97, - 36, 38, 97, - 37, 146, 36, - 28, 16, 43, - 39, 97, 38, - 38, 40, 39, - 40, 38, 33, - 21, 41, 42, - 41, 4, 42, - 3, 42, 4, - 42, 28, 21, - 28, 42, 16, - 3, 16, 42, - 26, 28, 43, - 17, 43, 16, - 43, 32, 26, - 32, 43, 18, - 17, 18, 43, - 33, 32, 44, - 32, 18, 44, - 13, 44, 18, - 13, 12, 44, - 44, 40, 33, - 40, 44, 12, - 39, 40, 45, - 40, 12, 45, - 11, 45, 12, - 10, 87, 11, - 87, 10, 147, - 88, 89, 90, - 90, 89, 91, - 89, 148, 91, - 92, 149, 90, - 91, 92, 90, - 98, 97, 101, - 87, 93, 11, - 94, 87, 95, - 93, 87, 94, - 87, 147, 95, - 95, 92, 94, - 92, 95, 149, - 92, 96, 94, - 96, 92, 91, - 39, 101, 97, - 97, 98, 37, - 99, 98, 103, - 98, 101, 103, - 99, 150, 98, - 37, 98, 150, - 102, 101, 39, - 101, 102, 100, - 100, 103, 101, - 103, 104, 99, - 104, 103, 107, - 100, 107, 103, - 104, 107, 109, - 99, 104, 151, - 105, 151, 104, - 105, 104, 109, - 45, 102, 39, - 108, 107, 100, - 107, 108, 106, - 106, 109, 107, - 110, 109, 152, - 109, 110, 105, - 106, 152, 109, - 105, 110, 153, - 111, 152, 106, - 11, 93, 45, - 102, 45, 93, - 102, 93, 112, - 100, 102, 112, - 94, 112, 93, - 94, 96, 112, - 108, 112, 96, - 112, 108, 100, - 108, 96, 113, - 106, 108, 113, - 91, 113, 96, - 111, 113, 148, - 91, 148, 113, - 113, 111, 106, -}; +#include "segment2/paintings.c.in" diff --git a/bin/segment2/paintings.c.in b/bin/segment2/paintings.c.in new file mode 100644 index 0000000000..2558fb288b --- /dev/null +++ b/bin/segment2/paintings.c.in @@ -0,0 +1,539 @@ + +// 0x02014970 - 0x020149A8 +const Gfx dl_paintings_rippling_begin[] = { + gsDPPipeSync(), + gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), + gsDPSetCombineMode(G_CC_MODULATERGBA, G_CC_MODULATERGBA), + gsSPLightColor(LIGHT_1, 0xffffffff), + gsSPLightColor(LIGHT_2, 0x505050ff), + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPTileSync(), + gsSPEndDisplayList(), +}; + +// 0x020149A8 - 0x020149C8 +const Gfx dl_paintings_rippling_end[] = { + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), + gsDPPipeSync(), + gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), + gsSPEndDisplayList(), +}; + +const Gfx sub_dl_paintings_textured_begin[] = { + gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + // gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD), + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPTileSync(), + gsSPEndDisplayList(), +}; + +// 0x07021A48 - 0x07021AA0 +const Gfx dl_paintings_textured_shaded_begin[] = { + gsDPPipeSync(), + gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH), + gsSPLightColor(LIGHT_1, 0xffffffff), + gsSPLightColor(LIGHT_2, 0x505050ff), + gsSPDisplayList(sub_dl_paintings_textured_begin), + gsSPEndDisplayList(), +}; + +// 0x07021A48 - 0x07021AA0 +const Gfx dl_paintings_textured_vertex_colored_begin[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_LIGHTING), + gsSPDisplayList(sub_dl_paintings_textured_begin), + gsSPEndDisplayList(), +}; + +// 0x07021AA0 - 0x07021AC0 +const Gfx dl_paintings_textured_end[] = { + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), + gsDPPipeSync(), + gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), + gsSPEndDisplayList(), +}; + +// 0x020149C8 - 0x02014A00 +const Gfx dl_paintings_env_mapped_begin[] = { + gsDPPipeSync(), + gsSPSetGeometryMode(G_LIGHTING | G_TEXTURE_GEN), + gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), + gsSPLightColor(LIGHT_1, 0xffffffff), + gsSPLightColor(LIGHT_2, 0x505050ff), + gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_ON), + gsDPTileSync(), + gsSPEndDisplayList(), +}; + +// 0x02014A00 - 0x02014A30 +const Gfx dl_paintings_env_mapped_end[] = { + gsSPTexture(0x4000, 0x4000, 0, G_TX_RENDERTILE, G_OFF), + gsDPPipeSync(), + gsSPGeometryModeSetFirst(G_TEXTURE_GEN, G_LIGHTING), + gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), + gsSPEndDisplayList(), +}; + +// 0x02014A30 - 0x02014A60 +const Gfx dl_paintings_ripple_triangles[] = { +#ifdef F3DEX_GBI_2 + gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), + gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), + gsSP2Triangles(12, 13, 14, 0x0, 15, 16, 17, 0x0), + gsSP2Triangles(18, 19, 20, 0x0, 21, 22, 23, 0x0), + gsSP2Triangles(24, 25, 26, 0x0, 27, 28, 29, 0x0), +#else + gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), + gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), + gsSP1Triangle( 12, 13, 14, 0x0), +#endif + gsSPEndDisplayList(), +}; + +// Painting vertex coordinates +#define PDX(x) ((x) * (PAINTING_SIZE / 12.0f)) // 51.2f +#define PDY(y) ((y) * (PAINTING_SIZE / 20.0f)) // 30.72f +#define PAINTING_VERTEX(x, y, r) PDX(x), PDY(y), (r) + +// 14A60: triangle mesh +// 0x02014A60 +const PaintingData painting_data_vertices[] = { + 157, // numVtx + // format: + // 2D point (x, y), ripple (0 or 1) + PAINTING_VERTEX(12, 19, 0), // 0 + PAINTING_VERTEX(12, 20, 0), // 1 + PAINTING_VERTEX(11, 20, 0), // 2 + PAINTING_VERTEX(11, 18, 1), // 3 + PAINTING_VERTEX(12, 17, 0), // 4 + PAINTING_VERTEX(10, 19, 1), // 5 + PAINTING_VERTEX(10, 20, 0), // 6 + PAINTING_VERTEX( 6, 20, 0), // 7 + PAINTING_VERTEX( 6, 19, 1), // 8 + PAINTING_VERTEX( 7, 20, 0), // 9 + PAINTING_VERTEX( 5, 20, 0), // 10 + PAINTING_VERTEX( 5, 18, 1), // 11 + PAINTING_VERTEX( 6, 17, 1), // 12 + PAINTING_VERTEX( 7, 18, 1), // 13 + PAINTING_VERTEX( 8, 19, 1), // 14 + PAINTING_VERTEX( 9, 20, 0), // 15 + PAINTING_VERTEX(10, 17, 1), // 16 + PAINTING_VERTEX( 9, 18, 1), // 17 + PAINTING_VERTEX( 8, 17, 1), // 18 + PAINTING_VERTEX(11, 10, 1), // 19 + PAINTING_VERTEX(12, 11, 0), // 20 + PAINTING_VERTEX(11, 14, 1), // 21 + PAINTING_VERTEX(12, 13, 0), // 22 + PAINTING_VERTEX(11, 12, 1), // 23 + PAINTING_VERTEX(10, 11, 1), // 24 + PAINTING_VERTEX( 9, 10, 1), // 25 + PAINTING_VERTEX( 9, 14, 1), // 26 + PAINTING_VERTEX(10, 13, 1), // 27 + PAINTING_VERTEX(10, 15, 1), // 28 + PAINTING_VERTEX( 8, 11, 1), // 29 + PAINTING_VERTEX( 9, 12, 1), // 30 + PAINTING_VERTEX( 7, 10, 1), // 31 + PAINTING_VERTEX( 8, 15, 1), // 32 + PAINTING_VERTEX( 7, 14, 1), // 33 + PAINTING_VERTEX( 8, 13, 1), // 34 + PAINTING_VERTEX( 7, 12, 1), // 35 + PAINTING_VERTEX( 6, 11, 1), // 36 + PAINTING_VERTEX( 5, 10, 1), // 37 + PAINTING_VERTEX( 6, 13, 1), // 38 + PAINTING_VERTEX( 5, 14, 1), // 39 + PAINTING_VERTEX( 6, 15, 1), // 40 + PAINTING_VERTEX(12, 15, 0), // 41 + PAINTING_VERTEX(11, 16, 1), // 42 + PAINTING_VERTEX( 9, 16, 1), // 43 + PAINTING_VERTEX( 7, 16, 1), // 44 + PAINTING_VERTEX( 5, 16, 1), // 45 + PAINTING_VERTEX( 8, 9, 1), // 46 + PAINTING_VERTEX(10, 9, 1), // 47 + PAINTING_VERTEX( 6, 9, 1), // 48 + PAINTING_VERTEX(12, 1, 0), // 49 + PAINTING_VERTEX(12, 0, 0), // 50 + PAINTING_VERTEX(11, 0, 0), // 51 + PAINTING_VERTEX(11, 4, 1), // 52 + PAINTING_VERTEX(12, 3, 0), // 53 + PAINTING_VERTEX(10, 1, 1), // 54 + PAINTING_VERTEX(11, 2, 1), // 55 + PAINTING_VERTEX( 9, 0, 0), // 56 + PAINTING_VERTEX(10, 0, 0), // 57 + PAINTING_VERTEX( 9, 4, 1), // 58 + PAINTING_VERTEX(10, 3, 1), // 59 + PAINTING_VERTEX(10, 5, 1), // 60 + PAINTING_VERTEX( 8, 1, 1), // 61 + PAINTING_VERTEX( 9, 2, 1), // 62 + PAINTING_VERTEX( 7, 0, 0), // 63 + PAINTING_VERTEX( 8, 0, 0), // 64 + PAINTING_VERTEX( 8, 3, 1), // 65 + PAINTING_VERTEX( 7, 4, 1), // 66 + PAINTING_VERTEX( 8, 5, 1), // 67 + PAINTING_VERTEX( 6, 1, 1), // 68 + PAINTING_VERTEX( 7, 2, 1), // 69 + PAINTING_VERTEX( 5, 0, 0), // 70 + PAINTING_VERTEX( 6, 0, 0), // 71 + PAINTING_VERTEX( 5, 4, 1), // 72 + PAINTING_VERTEX( 6, 3, 1), // 73 + PAINTING_VERTEX( 6, 5, 1), // 74 + PAINTING_VERTEX(12, 5, 0), // 75 + PAINTING_VERTEX(11, 8, 1), // 76 + PAINTING_VERTEX(12, 7, 0), // 77 + PAINTING_VERTEX(11, 6, 1), // 78 + PAINTING_VERTEX( 9, 8, 1), // 79 + PAINTING_VERTEX(10, 7, 1), // 80 + PAINTING_VERTEX( 9, 6, 1), // 81 + PAINTING_VERTEX( 7, 8, 1), // 82 + PAINTING_VERTEX( 8, 7, 1), // 83 + PAINTING_VERTEX( 7, 6, 1), // 84 + PAINTING_VERTEX( 5, 8, 1), // 85 + PAINTING_VERTEX( 6, 7, 1), // 86 + PAINTING_VERTEX( 4, 19, 1), // 87 + PAINTING_VERTEX( 0, 20, 0), // 88 + PAINTING_VERTEX( 0, 19, 0), // 89 + PAINTING_VERTEX( 1, 20, 0), // 90 + PAINTING_VERTEX( 1, 18, 1), // 91 + PAINTING_VERTEX( 2, 19, 1), // 92 + PAINTING_VERTEX( 4, 17, 1), // 93 + PAINTING_VERTEX( 3, 18, 1), // 94 + PAINTING_VERTEX( 3, 20, 0), // 95 + PAINTING_VERTEX( 2, 17, 1), // 96 + PAINTING_VERTEX( 5, 12, 1), // 97 + PAINTING_VERTEX( 4, 11, 1), // 98 + PAINTING_VERTEX( 3, 10, 1), // 99 + PAINTING_VERTEX( 3, 14, 1), // 100 + PAINTING_VERTEX( 4, 13, 1), // 101 + PAINTING_VERTEX( 4, 15, 1), // 102 + PAINTING_VERTEX( 3, 12, 1), // 103 + PAINTING_VERTEX( 2, 11, 1), // 104 + PAINTING_VERTEX( 1, 10, 1), // 105 + PAINTING_VERTEX( 1, 14, 1), // 106 + PAINTING_VERTEX( 2, 13, 1), // 107 + PAINTING_VERTEX( 2, 15, 1), // 108 + PAINTING_VERTEX( 1, 12, 1), // 109 + PAINTING_VERTEX( 0, 11, 0), // 110 + PAINTING_VERTEX( 0, 15, 0), // 111 + PAINTING_VERTEX( 3, 16, 1), // 112 + PAINTING_VERTEX( 1, 16, 1), // 113 + PAINTING_VERTEX( 3, 8, 1), // 114 + PAINTING_VERTEX( 2, 9, 1), // 115 + PAINTING_VERTEX( 4, 9, 1), // 116 + PAINTING_VERTEX( 0, 9, 0), // 117 + PAINTING_VERTEX( 1, 8, 1), // 118 + PAINTING_VERTEX( 4, 1, 1), // 119 + PAINTING_VERTEX( 5, 2, 1), // 120 + PAINTING_VERTEX( 4, 0, 0), // 121 + PAINTING_VERTEX( 3, 0, 0), // 122 + PAINTING_VERTEX( 4, 5, 1), // 123 + PAINTING_VERTEX( 4, 3, 1), // 124 + PAINTING_VERTEX( 3, 4, 1), // 125 + PAINTING_VERTEX( 2, 1, 1), // 126 + PAINTING_VERTEX( 3, 2, 1), // 127 + PAINTING_VERTEX( 2, 0, 0), // 128 + PAINTING_VERTEX( 1, 0, 0), // 129 + PAINTING_VERTEX( 1, 4, 1), // 130 + PAINTING_VERTEX( 2, 3, 1), // 131 + PAINTING_VERTEX( 2, 5, 1), // 132 + PAINTING_VERTEX( 0, 1, 0), // 133 + PAINTING_VERTEX( 1, 2, 1), // 134 + PAINTING_VERTEX( 0, 5, 0), // 135 + PAINTING_VERTEX( 5, 6, 1), // 136 + PAINTING_VERTEX( 4, 7, 1), // 137 + PAINTING_VERTEX( 3, 6, 1), // 138 + PAINTING_VERTEX( 2, 7, 1), // 139 + PAINTING_VERTEX( 1, 6, 1), // 140 + PAINTING_VERTEX( 8, 20, 0), // 141 + PAINTING_VERTEX(12, 10, 0), // 142 + PAINTING_VERTEX(12, 9, 0), // 143 + PAINTING_VERTEX(10, 10, 1), // 144 + PAINTING_VERTEX( 8, 10, 1), // 145 + PAINTING_VERTEX( 6, 10, 1), // 146 + PAINTING_VERTEX( 4, 20, 0), // 147 + PAINTING_VERTEX( 0, 17, 0), // 148 + PAINTING_VERTEX( 2, 20, 0), // 149 + PAINTING_VERTEX( 4, 10, 1), // 150 + PAINTING_VERTEX( 2, 10, 1), // 151 + PAINTING_VERTEX( 0, 13, 0), // 152 + PAINTING_VERTEX( 0, 10, 0), // 153 + PAINTING_VERTEX( 0, 7, 0), // 154 + PAINTING_VERTEX( 0, 3, 0), // 155 + PAINTING_VERTEX( 0, 0, 0), // 156 +}; + +#undef PDX +#undef PDY +#undef PAINTING_VERTEX + +// 0x07022660 - 0x07023042 +const PaintingData painting_data_triangles[] = { + 264, // num triangles + // Grouped by 5 + one remainder group, + // = 15 vertices per group + a few extra triangles + + // Bottom half + 60, 59, 52, + 49, 53, 55, + 50, 49, 51, + 51, 49, 55, + 52, 55, 53, + 53, 75, 52, + 54, 55, 59, + 52, 59, 55, + 55, 54, 51, + 54, 59, 62, + 56, 54, 62, + 57, 54, 56, + 54, 57, 51, + 58, 62, 59, + 59, 60, 58, + 68, 73, 120, + 61, 62, 65, + 58, 65, 62, + 62, 61, 56, + 63, 61, 69, + 64, 61, 63, + 61, 65, 69, + 61, 64, 56, + 65, 67, 66, + 66, 69, 65, + 67, 65, 58, + 69, 68, 63, + 66, 73, 69, + 68, 69, 73, + 70, 68, 120, + 71, 68, 70, + 68, 71, 63, + 73, 74, 72, + 72, 120, 73, + 74, 73, 66, + 75, 77, 78, + 52, 75, 78, + 76, 78, 77, + 77, 143, 76, + 76, 80, 78, + 60, 78, 80, + 78, 60, 52, + 83, 46, 82, + 58, 60, 81, + 60, 80, 81, + 80, 47, 79, + 47, 80, 76, + 79, 81, 80, + 79, 83, 81, + 81, 67, 58, + 67, 81, 83, + 66, 67, 84, + 67, 83, 84, + 46, 83, 79, + 82, 84, 83, + 84, 74, 66, + 82, 86, 84, + 74, 84, 86, + 72, 74, 136, + 74, 86, 136, + 86, 48, 85, + 85, 136, 86, + 48, 86, 82, + 25, 46, 79, + 79, 47, 25, + 31, 46, 145, + 46, 25, 145, + 82, 46, 31, + 47, 19, 144, + 25, 47, 144, + 19, 47, 76, + 76, 143, 19, + 19, 143, 142, + 119, 124, 127, + 31, 48, 82, + 85, 48, 37, + 48, 31, 146, + 37, 48, 146, + 72, 124, 120, + 120, 119, 70, + 119, 120, 124, + 122, 119, 127, + 121, 119, 122, + 119, 121, 70, + 130, 134, 131, + 124, 123, 125, + 125, 127, 124, + 123, 124, 72, + 125, 131, 127, + 127, 126, 122, + 126, 127, 131, + 126, 128, 122, + 129, 126, 134, + 128, 126, 129, + 126, 131, 134, + 132, 131, 125, + 131, 132, 130, + 130, 155, 134, + 134, 133, 129, + 133, 134, 155, + 133, 156, 129, + 135, 155, 130, + 136, 123, 72, + 85, 137, 136, + 123, 136, 137, + 125, 123, 138, + 123, 137, 138, + 116, 137, 85, + 137, 116, 114, + 114, 138, 137, + 138, 132, 125, + 132, 138, 139, + 114, 139, 138, + 130, 132, 140, + 132, 139, 140, + 139, 115, 118, + 118, 140, 139, + 115, 139, 114, + 140, 135, 130, + 118, 154, 140, + 135, 140, 154, + 117, 105, 153, + 117, 154, 118, + 99, 115, 114, + 114, 116, 99, + 118, 115, 105, + 115, 99, 151, + 105, 115, 151, + 37, 116, 85, + 116, 37, 150, + 99, 116, 150, + 105, 117, 118, + // Top half + 9, 8, 13, + 0, 1, 2, + 3, 0, 2, + 4, 0, 3, + 5, 2, 6, + 2, 5, 3, + 8, 7, 10, + 7, 8, 9, + 11, 8, 10, + 12, 8, 11, + 8, 12, 13, + 13, 14, 9, + 14, 141, 9, + 5, 6, 15, + 5, 16, 3, + 16, 5, 17, + 17, 5, 15, + 14, 15, 141, + 15, 14, 17, + 18, 14, 13, + 14, 18, 17, + 19, 142, 20, + 19, 20, 23, + 28, 27, 21, + 22, 41, 21, + 21, 23, 22, + 20, 22, 23, + 23, 24, 19, + 21, 27, 23, + 24, 23, 27, + 19, 24, 144, + 25, 144, 24, + 25, 24, 30, + 24, 27, 30, + 26, 30, 27, + 27, 28, 26, + 31, 36, 146, + 26, 34, 30, + 30, 29, 25, + 29, 30, 34, + 25, 29, 145, + 31, 145, 29, + 31, 29, 35, + 29, 34, 35, + 32, 34, 26, + 33, 35, 34, + 34, 32, 33, + 35, 36, 31, + 33, 38, 35, + 36, 35, 38, + 37, 36, 97, + 36, 38, 97, + 37, 146, 36, + 28, 16, 43, + 39, 97, 38, + 38, 40, 39, + 40, 38, 33, + 21, 41, 42, + 41, 4, 42, + 3, 42, 4, + 42, 28, 21, + 28, 42, 16, + 3, 16, 42, + 26, 28, 43, + 17, 43, 16, + 43, 32, 26, + 32, 43, 18, + 17, 18, 43, + 33, 32, 44, + 32, 18, 44, + 13, 44, 18, + 13, 12, 44, + 44, 40, 33, + 40, 44, 12, + 39, 40, 45, + 40, 12, 45, + 11, 45, 12, + 10, 87, 11, + 87, 10, 147, + 88, 89, 90, + 90, 89, 91, + 89, 148, 91, + 92, 149, 90, + 91, 92, 90, + 98, 97, 101, + 87, 93, 11, + 94, 87, 95, + 93, 87, 94, + 87, 147, 95, + 95, 92, 94, + 92, 95, 149, + 92, 96, 94, + 96, 92, 91, + 39, 101, 97, + 97, 98, 37, + 99, 98, 103, + 98, 101, 103, + 99, 150, 98, + 37, 98, 150, + 102, 101, 39, + 101, 102, 100, + 100, 103, 101, + 103, 104, 99, + 104, 103, 107, + 100, 107, 103, + 104, 107, 109, + 99, 104, 151, + 105, 151, 104, + 105, 104, 109, + 45, 102, 39, + 108, 107, 100, + 107, 108, 106, + 106, 109, 107, + 110, 109, 152, + 109, 110, 105, + 106, 152, 109, + 105, 110, 153, + 111, 152, 106, + 11, 93, 45, + 102, 45, 93, + 102, 93, 112, + 100, 102, 112, + 94, 112, 93, + 94, 96, 112, + 108, 112, 96, + 112, 108, 100, + 108, 96, 113, + 106, 108, 113, + 91, 113, 96, + 111, 113, 148, + 91, 148, 113, + 113, 111, 106, +};