Added a level script function to easily set a skybox for each area

In your level script add the function
CHANGE_AREA_SKYBOX(Area ID, Skybox Segment Start, Skybox Segment End) .
This commit is contained in:
Mineqwerty
2021-09-04 20:27:21 -04:00
parent 2d86f0a404
commit 33fa7013b0
5 changed files with 23 additions and 2 deletions

View File

@@ -190,6 +190,12 @@
CMD_PTR(romEnd)
#endif
#define CHANGE_AREA_SKYBOX(area, segStart, segEnd) \
CMD_BBH(0x3D, 0x0C, area), \
CMD_PTR(segStart), \
CMD_PTR(segEnd)
#define INIT_LEVEL() \
CMD_BBH(0x1B, 0x04, 0x0000)

View File

@@ -303,6 +303,13 @@ static void level_cmd_load_yay0_texture(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_change_area_skybox(int area, u8 *start, u8 *end) {
u8 areaCheck = CMD_GET(s16, 2);
gAreaSkyboxStart[areaCheck-1] = CMD_GET(void *, 4);
gAreaSkyboxEnd[areaCheck-1] = CMD_GET(void *, 8);
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_init_level(void) {
init_graph_node_start(NULL, (struct GraphNodeStart *) &gObjParentGraphNode);
clear_objects();
@@ -819,6 +826,7 @@ static void (*LevelScriptJumpTable[])(void) = {
/*3A*/ level_cmd_3A,
/*3B*/ level_cmd_create_whirlpool,
/*3C*/ level_cmd_get_or_set_var,
/*3D*/ level_cmd_change_area_skybox,
};
struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {

View File

@@ -225,7 +225,7 @@ void load_area(s32 index) {
if (gCurrentArea == NULL && gAreaData[index].unk04 != NULL) {
gCurrentArea = &gAreaData[index];
gCurrAreaIndex = gCurrentArea->index;
if (gCurrentArea->terrainData != NULL) {
load_area_terrain(index, gCurrentArea->terrainData, gCurrentArea->surfaceRooms,
gCurrentArea->macroObjects);
@@ -236,7 +236,7 @@ void load_area(s32 index) {
}
load_obj_warp_nodes();
geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_LOAD);
geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_LOAD);
}
}
@@ -259,6 +259,9 @@ void load_mario_area(void) {
gCurrentArea->flags |= 0x01;
spawn_objects_from_info(0, gMarioSpawnInfo);
}
if (gAreaSkyboxStart[gCurrAreaIndex-1]) {
load_segment_decompress(0x0A, gAreaSkyboxStart[gCurrAreaIndex-1], gAreaSkyboxEnd[gCurrAreaIndex-1]);
}
}
void unload_mario_area(void) {

View File

@@ -66,6 +66,8 @@ u8 gIsConsole;
#ifdef WIDE
u8 gWidescreen;
#endif
u8 *gAreaSkyboxStart[7];
u8 *gAreaSkyboxEnd[7];
u16 sCurrFBNum = 0;
u16 frameBufferIndex = 0;

View File

@@ -45,6 +45,8 @@ extern u8 gIsConsole;
#ifdef WIDE
extern u8 gWidescreen;
#endif
extern u8 *gAreaSkyboxStart[7];
extern u8 *gAreaSkyboxEnd[7];
#ifdef EEP
extern s8 gEepromProbe;
#endif