Lay some groundwork for more documentation, fix compilation error, put backgrounds into enum

This commit is contained in:
Agent X 2025-04-26 23:29:21 -04:00
parent 5d5147cb0e
commit bf85d9f9d5
22 changed files with 121 additions and 78 deletions

View File

@ -2721,38 +2721,30 @@ G_TEXRECTFLIP = 0xe5
--- @type integer
G_TEXRECT = 0xe4
--- @type integer
BACKGROUND_OCEAN_SKY = 0
BACKGROUND_OCEAN_SKY = 0 --- @type SkyBackgroundParams
BACKGROUND_FLAMING_SKY = 1 --- @type SkyBackgroundParams
BACKGROUND_UNDERWATER_CITY = 2 --- @type SkyBackgroundParams
BACKGROUND_BELOW_CLOUDS = 3 --- @type SkyBackgroundParams
BACKGROUND_SNOW_MOUNTAINS = 4 --- @type SkyBackgroundParams
BACKGROUND_DESERT = 5 --- @type SkyBackgroundParams
BACKGROUND_HAUNTED = 6 --- @type SkyBackgroundParams
BACKGROUND_GREEN_SKY = 7 --- @type SkyBackgroundParams
BACKGROUND_ABOVE_CLOUDS = 8 --- @type SkyBackgroundParams
BACKGROUND_PURPLE_SKY = 9 --- @type SkyBackgroundParams
BACKGROUND_CUSTOM = 10 --- @type SkyBackgroundParams
--- @type integer
BACKGROUND_FLAMING_SKY = 1
--- @type integer
BACKGROUND_UNDERWATER_CITY = 2
--- @type integer
BACKGROUND_BELOW_CLOUDS = 3
--- @type integer
BACKGROUND_SNOW_MOUNTAINS = 4
--- @type integer
BACKGROUND_DESERT = 5
--- @type integer
BACKGROUND_HAUNTED = 6
--- @type integer
BACKGROUND_GREEN_SKY = 7
--- @type integer
BACKGROUND_ABOVE_CLOUDS = 8
--- @type integer
BACKGROUND_PURPLE_SKY = 9
--- @type integer
BACKGROUND_CUSTOM = 10
--- @alias SkyBackgroundParams
--- | `BACKGROUND_OCEAN_SKY`
--- | `BACKGROUND_FLAMING_SKY`
--- | `BACKGROUND_UNDERWATER_CITY`
--- | `BACKGROUND_BELOW_CLOUDS`
--- | `BACKGROUND_SNOW_MOUNTAINS`
--- | `BACKGROUND_DESERT`
--- | `BACKGROUND_HAUNTED`
--- | `BACKGROUND_GREEN_SKY`
--- | `BACKGROUND_ABOVE_CLOUDS`
--- | `BACKGROUND_PURPLE_SKY`
--- | `BACKGROUND_CUSTOM`
--- @type integer
GRAPH_RENDER_ACTIVE = (1 << 0)

View File

@ -1,7 +1,7 @@
-- AUTOGENERATED FOR CODE EDITORS --
--- @param o Object
--- @return MarioSpawnType
--- @return integer
--- Derives a `MARIO_SPAWN_*` constant from `o`
function get_mario_spawn_type(o)
-- ...
@ -5945,6 +5945,7 @@ end
--- @param airAction integer
--- @param animation integer
--- @return integer
--- Builds on `common_slide_action` by also allowing Mario to jump out of a slide if A is pressed after a short delay. If the sliding slows enough, Mario transitions to a specified stopping action
function common_slide_action_with_jump(m, stopAction, jumpAction, airAction, animation)
-- ...
end
@ -5985,6 +5986,7 @@ end
--- @param endAction integer
--- @param airAction integer
--- @return integer
--- Handles a special landing in quicksand after a jump. Over several frames, Mario emerges from the quicksand. First part of the animation reduces his quicksand depth. Ends with a normal landing action or transitions back to air if he leaves the ground
function quicksand_jump_land_action(m, animation1, animation2, endAction, airAction)
-- ...
end
@ -6006,24 +6008,28 @@ end
--- @param m MarioState
--- @param animation integer
--- @param endAction integer
--- Performs a stationary step, sets `m`'s animation and sets action to `endAction` once the animation finishes
function animated_stationary_ground_step(m, animation, endAction)
-- ...
end
--- @param m MarioState
--- @return integer
--- Updates Mario's punching state
function mario_update_punch_sequence(m)
-- ...
end
--- @param m MarioState
--- @return integer
--- Checks for and handles common conditions that would cancel Mario's current object action. This includes transitioning to a water plunge if below the water level, becoming squished if appropriate, or switching to standing death action if Mario is dead
function check_common_object_cancels(m)
-- ...
end
--- @param m MarioState
--- @return integer
--- Executes Mario's current object action by first checking common object cancels, then updating quicksand state. Dispatches to the appropriate action function, such as punching, throwing, picking up Bowser, etc
function mario_execute_object_action(m)
-- ...
end
@ -9757,7 +9763,7 @@ function set_fog_intensity(intensity)
-- ...
end
--- @return integer
--- @return SkyBackgroundParams
--- Gets the current skybox
function get_skybox()
-- ...

View File

@ -27,6 +27,7 @@
- [first_person_cam.h](#first_person_camh)
- [gbi.h](#gbih)
- [geo_commands.h](#geo_commandsh)
- [enum SkyBackgroundParams](#enum-SkyBackgroundParams)
- [graph_node.h](#graph_nodeh)
- [interaction.c](#interactionc)
- [interaction.h](#interactionh)
@ -1286,17 +1287,21 @@
<br />
## [geo_commands.h](#geo_commands.h)
- BACKGROUND_OCEAN_SKY
- BACKGROUND_FLAMING_SKY
- BACKGROUND_UNDERWATER_CITY
- BACKGROUND_BELOW_CLOUDS
- BACKGROUND_SNOW_MOUNTAINS
- BACKGROUND_DESERT
- BACKGROUND_HAUNTED
- BACKGROUND_GREEN_SKY
- BACKGROUND_ABOVE_CLOUDS
- BACKGROUND_PURPLE_SKY
- BACKGROUND_CUSTOM
### [enum SkyBackgroundParams](#SkyBackgroundParams)
| Identifier | Value |
| :--------- | :---- |
| BACKGROUND_OCEAN_SKY | 0 |
| BACKGROUND_FLAMING_SKY | 1 |
| BACKGROUND_UNDERWATER_CITY | 2 |
| BACKGROUND_BELOW_CLOUDS | 3 |
| BACKGROUND_SNOW_MOUNTAINS | 4 |
| BACKGROUND_DESERT | 5 |
| BACKGROUND_HAUNTED | 6 |
| BACKGROUND_GREEN_SKY | 7 |
| BACKGROUND_ABOVE_CLOUDS | 8 |
| BACKGROUND_PURPLE_SKY | 9 |
| BACKGROUND_CUSTOM | 10 |
[:arrow_up_small:](#)

View File

@ -3052,6 +3052,9 @@ Applies shared logic for sliding-related actions while playing sliding sounds, m
## [common_slide_action_with_jump](#common_slide_action_with_jump)
### Description
Builds on `common_slide_action` by also allowing Mario to jump out of a slide if A is pressed after a short delay. If the sliding slows enough, Mario transitions to a specified stopping action
### Lua Example
`local integerValue = common_slide_action_with_jump(m, stopAction, jumpAction, airAction, animation)`
@ -3154,6 +3157,9 @@ Applies movement upon landing from a jump or fall. Adjusts velocity based on slo
## [quicksand_jump_land_action](#quicksand_jump_land_action)
### Description
Handles a special landing in quicksand after a jump. Over several frames, Mario emerges from the quicksand. First part of the animation reduces his quicksand depth. Ends with a normal landing action or transitions back to air if he leaves the ground
### Lua Example
`local integerValue = quicksand_jump_land_action(m, animation1, animation2, endAction, airAction)`
@ -3230,6 +3236,9 @@ Executes Mario's current moving actions by: checking common cancellations (e.g.,
## [animated_stationary_ground_step](#animated_stationary_ground_step)
### Description
Performs a stationary step, sets `m`'s animation and sets action to `endAction` once the animation finishes
### Lua Example
`animated_stationary_ground_step(m, animation, endAction)`
@ -3252,6 +3261,9 @@ Executes Mario's current moving actions by: checking common cancellations (e.g.,
## [mario_update_punch_sequence](#mario_update_punch_sequence)
### Description
Updates Mario's punching state
### Lua Example
`local integerValue = mario_update_punch_sequence(m)`
@ -3272,6 +3284,9 @@ Executes Mario's current moving actions by: checking common cancellations (e.g.,
## [check_common_object_cancels](#check_common_object_cancels)
### Description
Checks for and handles common conditions that would cancel Mario's current object action. This includes transitioning to a water plunge if below the water level, becoming squished if appropriate, or switching to standing death action if Mario is dead
### Lua Example
`local integerValue = check_common_object_cancels(m)`
@ -3292,6 +3307,9 @@ Executes Mario's current moving actions by: checking common cancellations (e.g.,
## [mario_execute_object_action](#mario_execute_object_action)
### Description
Executes Mario's current object action by first checking common object cancels, then updating quicksand state. Dispatches to the appropriate action function, such as punching, throwing, picking up Bowser, etc
### Lua Example
`local integerValue = mario_execute_object_action(m)`

View File

@ -1709,16 +1709,16 @@ Sets the intensity of the fog (this value scales very quickly, 1.0 to 1.1 is a d
Gets the current skybox
### Lua Example
`local integerValue = get_skybox()`
`local enumValue = get_skybox()`
### Parameters
- None
### Returns
- `integer`
[enum SkyBackgroundParams](constants.md#enum-SkyBackgroundParams)
### C Prototype
`s8 get_skybox(void);`
`enum SkyBackgroundParams get_skybox(void);`
[:arrow_up_small:](#)

View File

@ -2634,7 +2634,7 @@ N/A
Derives a `MARIO_SPAWN_*` constant from `o`
### Lua Example
`local enumValue = get_mario_spawn_type(o)`
`local integerValue = get_mario_spawn_type(o)`
### Parameters
| Field | Type |
@ -2642,10 +2642,10 @@ Derives a `MARIO_SPAWN_*` constant from `o`
| o | [Object](structs.md#Object) |
### Returns
[enum MarioSpawnType](constants.md#enum-MarioSpawnType)
- `integer`
### C Prototype
`enum MarioSpawnType get_mario_spawn_type(struct Object *o);`
`u32 get_mario_spawn_type(struct Object *o);`
[:arrow_up_small:](#)

View File

@ -11,17 +11,19 @@
#include "game/mario_actions_cutscene.h"
// sky background params
#define BACKGROUND_OCEAN_SKY 0
#define BACKGROUND_FLAMING_SKY 1
#define BACKGROUND_UNDERWATER_CITY 2
#define BACKGROUND_BELOW_CLOUDS 3
#define BACKGROUND_SNOW_MOUNTAINS 4
#define BACKGROUND_DESERT 5
#define BACKGROUND_HAUNTED 6
#define BACKGROUND_GREEN_SKY 7
#define BACKGROUND_ABOVE_CLOUDS 8
#define BACKGROUND_PURPLE_SKY 9
#define BACKGROUND_CUSTOM 10
enum SkyBackgroundParams {
BACKGROUND_OCEAN_SKY,
BACKGROUND_FLAMING_SKY,
BACKGROUND_UNDERWATER_CITY,
BACKGROUND_BELOW_CLOUDS,
BACKGROUND_SNOW_MOUNTAINS,
BACKGROUND_DESERT,
BACKGROUND_HAUNTED,
BACKGROUND_GREEN_SKY,
BACKGROUND_ABOVE_CLOUDS,
BACKGROUND_PURPLE_SKY,
BACKGROUND_CUSTOM
};
// geo layout macros

View File

@ -2,7 +2,7 @@
const GeoLayout rr_geo_000770[] = {
GEO_CULLING_RADIUS(1500),
GEO_OPEN_NODE(),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, rr_seg7_dl_0700E830),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_DECAL, rr_seg7_dl_0700E830),
GEO_CLOSE_NODE(),
GEO_END(),
};

View File

@ -2,7 +2,7 @@
const GeoLayout rr_geo_0007E8[] = {
GEO_CULLING_RADIUS(2500),
GEO_OPEN_NODE(),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, rr_seg7_dl_07015C68),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_DECAL, rr_seg7_dl_07015C68),
GEO_CLOSE_NODE(),
GEO_END(),
};

View File

@ -2,7 +2,7 @@
const GeoLayout rr_geo_000800[] = {
GEO_CULLING_RADIUS(4500),
GEO_OPEN_NODE(),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, rr_seg7_dl_07017530),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_DECAL, rr_seg7_dl_07017530),
GEO_CLOSE_NODE(),
GEO_END(),
};

View File

@ -2,7 +2,7 @@
const GeoLayout rr_geo_000818[] = {
GEO_CULLING_RADIUS(5000),
GEO_OPEN_NODE(),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, rr_seg7_dl_07018B58),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_DECAL, rr_seg7_dl_07018B58),
GEO_CLOSE_NODE(),
GEO_END(),
};

View File

@ -18,7 +18,7 @@ const GeoLayout thi_geo_000608[] = {
GEO_DISPLAY_LIST(LAYER_OPAQUE, thi_seg7_dl_07005260),
GEO_DISPLAY_LIST(LAYER_OPAQUE, thi_seg7_dl_07006968),
GEO_DISPLAY_LIST(LAYER_ALPHA, thi_seg7_dl_07007008),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT, thi_seg7_dl_070072E8),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_DECAL, thi_seg7_dl_070072E8),
GEO_DISPLAY_LIST(LAYER_TRANSPARENT_DECAL, thi_seg7_dl_070073C0),
GEO_ASM( 0, geo_movtex_pause_control),
GEO_ASM(0x1301, geo_movtex_draw_water_regions),

View File

@ -147,7 +147,7 @@ void print_intro_text(void) {
}
}
enum MarioSpawnType get_mario_spawn_type(struct Object *o) {
u32 get_mario_spawn_type(struct Object *o) {
if (o == NULL || o->behavior == NULL) { return MARIO_SPAWN_NONE; }
const BehaviorScript *behavior = virtual_to_segmented(0x13, o->behavior);

View File

@ -158,7 +158,7 @@ extern u8 gSpawnedStarHiddenCount;
void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e);
void print_intro_text(void);
/* |description|Derives a `MARIO_SPAWN_*` constant from `o`|descriptionEnd| */
enum MarioSpawnType get_mario_spawn_type(struct Object *o);
u32 get_mario_spawn_type(struct Object *o);
/* |description|
Finds a warp node in the current area by its ID. The warp node must exist in the list of warp nodes for the current area.

View File

@ -419,7 +419,7 @@ void init_mario_after_warp(void) {
if (spawnNode == NULL || spawnNode->object == NULL) { spawnNode = area_get_any_warp_node(); }
if (spawnNode == NULL || spawnNode->object == NULL) { return; }
enum MarioSpawnType marioSpawnType = get_mario_spawn_type(spawnNode->object);
u32 marioSpawnType = get_mario_spawn_type(spawnNode->object);
if (gMarioState && gMarioState->action != ACT_UNINITIALIZED) {
for (s32 i = 0; i < MAX_PLAYERS; i++) {

View File

@ -1574,8 +1574,7 @@ void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32
Builds on `common_slide_action` by also allowing Mario to jump out of a slide if A is pressed after a short delay.
If the sliding slows enough, Mario transitions to a specified stopping action
|descriptionEnd| */
s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jumpAction, u32 airAction,
s32 animation) {
s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jumpAction, u32 airAction, s32 animation) {
if (!m) { return FALSE; }
if (m->actionTimer == 5) {
if (m->input & INPUT_A_PRESSED) {
@ -2124,10 +2123,10 @@ s32 act_backflip_land(struct MarioState *m) {
}
/* |description|
Handles a special landing in quicksand after a jump. Over several frames, Mario emerges from the quicksand. First part of the animation reduces his quicksand depth. Ends with a normal landing action or transitions back to air if he leaves the ground
Handles a special landing in quicksand after a jump. Over several frames, Mario emerges from the quicksand.
First part of the animation reduces his quicksand depth. Ends with a normal landing action or transitions back to air if he leaves the ground
|descriptionEnd| */
s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animation2, u32 endAction,
u32 airAction) {
s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animation2, u32 endAction, u32 airAction) {
if (!m) { return FALSE; }
if (m->actionTimer++ < 6) {
m->quicksandDepth -= (7 - m->actionTimer) * 0.8f;

View File

@ -22,6 +22,7 @@
*/
s8 sPunchingForwardVelocities[8] = { 0, 1, 1, 2, 3, 5, 7, 10 };
/* |description|Performs a stationary step, sets `m`'s animation and sets action to `endAction` once the animation finishes|descriptionEnd| */
void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction) {
stationary_ground_step(m);
set_character_animation(m, animation);
@ -30,6 +31,7 @@ void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 en
}
}
/* |description|Updates Mario's punching state|descriptionEnd| */
s32 mario_update_punch_sequence(struct MarioState *m) {
if (!m) { return 0; }
u32 endAction, crouchEndAction;
@ -474,6 +476,11 @@ s32 act_releasing_bowser(struct MarioState *m) {
return FALSE;
}
/* |description|
Checks for and handles common conditions that would cancel Mario's current object action. This includes transitioning
to a water plunge if below the water level, becoming squished if appropriate, or switching to standing death action
if Mario is dead
|descriptionEnd| */
s32 check_common_object_cancels(struct MarioState *m) {
if (!m) { return 0; }
if (m->playerIndex != 0) { return FALSE; }
@ -497,6 +504,10 @@ s32 check_common_object_cancels(struct MarioState *m) {
return FALSE;
}
/* |description|
Executes Mario's current object action by first checking common object cancels, then updating quicksand state.
Dispatches to the appropriate action function, such as punching, throwing, picking up Bowser, etc
|descriptionEnd| */
s32 mario_execute_object_action(struct MarioState *m) {
if (!m) { return FALSE; }
s32 cancel;

View File

@ -22,6 +22,7 @@
#include "pc/lua/smlua.h"
#include "hardcoded.h"
/* |description||descriptionEnd| */
s32 check_common_idle_cancels(struct MarioState *m) {
if (!m) { return 0; }
mario_drop_held_object(m);
@ -65,6 +66,7 @@ s32 check_common_idle_cancels(struct MarioState *m) {
return FALSE;
}
/* |description||descriptionEnd| */
s32 check_common_hold_idle_cancels(struct MarioState *m) {
if (!m) { return 0; }
if (m->floor && m->floor->normal.y < 0.29237169f) {
@ -186,6 +188,7 @@ s32 act_idle(struct MarioState *m) {
return FALSE;
}
/* |description||descriptionEnd| */
void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound) {
if (!m) { return; }
if (!m->marioObj) { return; }
@ -653,6 +656,7 @@ s32 act_hold_panting_unused(struct MarioState *m) {
return FALSE;
}
/* |description||descriptionEnd| */
void stopping_step(struct MarioState *m, s32 animID, u32 action) {
stationary_ground_step(m);
set_character_animation(m, animID);
@ -876,6 +880,7 @@ s32 act_shockwave_bounce(struct MarioState *m) {
return FALSE;
}
/* |description||descriptionEnd| */
s32 landing_step(struct MarioState *m, s32 arg1, u32 action) {
stationary_ground_step(m);
set_character_animation(m, arg1);
@ -885,6 +890,7 @@ s32 landing_step(struct MarioState *m, s32 arg1, u32 action) {
return FALSE;
}
/* |description||descriptionEnd| */
s32 check_common_landing_cancels(struct MarioState *m, u32 action) {
if (!m) { return 0; }
if (m->input & INPUT_UNKNOWN_10) {
@ -1148,6 +1154,7 @@ s32 act_first_person(struct MarioState *m) {
return FALSE;
}
/* |description||descriptionEnd| */
s32 check_common_stationary_cancels(struct MarioState *m) {
if (!m) { return 0; }
if (m->playerIndex != 0) { return FALSE; }
@ -1179,6 +1186,7 @@ s32 check_common_stationary_cancels(struct MarioState *m) {
return FALSE;
}
/* |description||descriptionEnd| */
s32 mario_execute_stationary_action(struct MarioState *m) {
if (!m) { return FALSE; }
s32 cancel;

View File

@ -703,6 +703,7 @@ struct PcDebug gPcDebug = {
0x9A2269E87B26BE68,
0x0E76DE227D813019,
0x12ABA8362D430002,
0x0BF8F9C076430007,
},
.id = DEFAULT_ID,
.bhvOffset = /* 0x12 */ 0,

View File

@ -7,7 +7,7 @@
#define MIXER 0x3DCE3B097C30006
struct PcDebug {
u64 tags[16];
u64 tags[17];
u64 id;
u64 bhvOffset;
s64 debugId;

View File

@ -87,7 +87,7 @@ void set_fog_intensity(f32 intensity) {
///
s8 get_skybox(void) {
enum SkyBackgroundParams get_skybox(void) {
if (gOverrideBackground != -1) { return gOverrideBackground; }
return gReadOnlyBackground;
}

View File

@ -3,6 +3,7 @@
#include "pc/lua/smlua.h"
#include "types.h"
#include "geo_commands.h"
#define C0(cmd, pos, width) (((cmd)->words.w0 >> (pos)) & ((1U << width) - 1))
#define GFX_OP(cmd) C0(cmd, 24, 8)
@ -47,7 +48,7 @@ f32 get_fog_intensity(void);
void set_fog_intensity(f32 intensity);
/* |description|Gets the current skybox|descriptionEnd| */
s8 get_skybox(void);
enum SkyBackgroundParams get_skybox(void);
/* |description|Sets the override skybox|descriptionEnd| */
void set_override_skybox(s8 background);
/* |description|Gets a value of the global skybox color|descriptionEnd| */