Merge branch 'dev' of github.com:sm64ex-coop-dev/sm64ex-coop into dev

This commit is contained in:
MysterD 2023-05-10 15:21:00 -07:00
commit b22230db5d
24 changed files with 499 additions and 250 deletions

View file

@ -3461,44 +3461,6 @@ GRAPH_RENDER_PLAYER = (1 << 7)
--- @type integer
GRAPH_RENDER_Z_BUFFER = (1 << 3)
--- @type integer
INT_ANY_ATTACK = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)
--- @type integer
INT_ATTACK_NOT_FROM_BELOW = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)
--- @type integer
INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)
--- @type integer
INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)
--- @class InteractionFlag
--- @type InteractionFlag
INT_GROUND_POUND_OR_TWIRL = (1 << 0)
--- @type InteractionFlag
INT_PUNCH = (1 << 1)
--- @type InteractionFlag
INT_KICK = (1 << 2)
--- @type InteractionFlag
INT_TRIP = (1 << 3)
--- @type InteractionFlag
INT_SLIDE_KICK = (1 << 4)
--- @type InteractionFlag
INT_FAST_ATTACK_OR_SHELL = (1 << 5)
--- @type InteractionFlag
INT_HIT_FROM_ABOVE = (1 << 6)
--- @type InteractionFlag
INT_HIT_FROM_BELOW = (1 << 7)
--- @type integer
ATTACK_FAST_ATTACK = 5
@ -3517,6 +3479,18 @@ ATTACK_KICK_OR_TRIP = 2
--- @type integer
ATTACK_PUNCH = 1
--- @type integer
INT_ANY_ATTACK = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)
--- @type integer
INT_ATTACK_NOT_FROM_BELOW = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)
--- @type integer
INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)
--- @type integer
INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)
--- @type integer
INT_STATUS_ATTACKED_MARIO = (1 << 13)
@ -3613,6 +3587,38 @@ INT_SUBTYPE_STAR_DOOR = 0x00000020
--- @type integer
INT_SUBTYPE_TWIRL_BOUNCE = 0x00000080
--- @class InteractionFlag
--- @type InteractionFlag
INT_GROUND_POUND = (1 << 0)
--- @type InteractionFlag
INT_PUNCH = (1 << 1)
--- @type InteractionFlag
INT_KICK = (1 << 2)
--- @type InteractionFlag
INT_TRIP = (1 << 3)
--- @type InteractionFlag
INT_SLIDE_KICK = (1 << 4)
--- @type InteractionFlag
INT_FAST_ATTACK_OR_SHELL = (1 << 5)
--- @type InteractionFlag
INT_HIT_FROM_ABOVE = (1 << 6)
--- @type InteractionFlag
INT_HIT_FROM_BELOW = (1 << 7)
--- @type InteractionFlag
INT_TWIRL = (1 << 8)
--- @type InteractionFlag
INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL)
--- @class InteractionType
--- @type InteractionType
@ -7286,6 +7292,9 @@ ACT_FLAG_CUSTOM_ACTION = (1 << 30)
--- @type integer
ACT_FLAG_DIVING = (1 << 19)
--- @type integer
ACT_FLAG_FLYING = (ACT_FLAG_AIR | ACT_FLAG_DIVING | ACT_FLAG_ATTACKING | ACT_FLAG_SWIMMING_OR_FLYING)
--- @type integer
ACT_FLAG_HANGING = (1 << 21)

View file

@ -3893,6 +3893,12 @@ function seq_player_unlower_volume(player, fadeDuration)
-- ...
end
--- @param fadeOutTime integer
--- @return nil
function set_audio_fadeout(fadeOutTime)
-- ...
end
--- @param player integer
--- @param bankMask integer
--- @return nil
@ -3913,6 +3919,12 @@ function stop_background_music(seqId)
-- ...
end
--- @param fadeTimer integer
--- @return nil
function stop_secondary_music(fadeTimer)
-- ...
end
--- @param soundBits integer
--- @param pos Vec3f
--- @return nil
@ -3931,6 +3943,13 @@ function stop_sounds_in_continuous_banks()
-- ...
end
--- @param m MarioState
--- @param o Object
--- @return integer
function determine_interaction(m, o)
-- ...
end
--- @param m MarioState
--- @return integer
function does_mario_have_normal_cap_on_head(m)

View file

@ -19,8 +19,8 @@
- [geo_commands.h](#geo_commandsh)
- [graph_node.h](#graph_nodeh)
- [interaction.c](#interactionc)
- [enum InteractionFlag](#enum-InteractionFlag)
- [interaction.h](#interactionh)
- [enum InteractionFlag](#enum-InteractionFlag)
- [enum InteractionType](#enum-InteractionType)
- [level_commands.h](#level_commandsh)
- [level_defines.h](#level_definesh)
@ -1193,22 +1193,6 @@
<br />
## [interaction.c](#interaction.c)
- INT_ANY_ATTACK
- INT_ATTACK_NOT_FROM_BELOW
- INT_ATTACK_NOT_WEAK_FROM_ABOVE
- INT_ATTACK_SLIDE
### [enum InteractionFlag](#InteractionFlag)
| Identifier | Value |
| :--------- | :---- |
| INT_GROUND_POUND_OR_TWIRL | (1 << 0) |
| INT_PUNCH | (1 << 1) |
| INT_KICK | (1 << 2) |
| INT_TRIP | (1 << 3) |
| INT_SLIDE_KICK | (1 << 4) |
| INT_FAST_ATTACK_OR_SHELL | (1 << 5) |
| INT_HIT_FROM_ABOVE | (1 << 6) |
| INT_HIT_FROM_BELOW | (1 << 7) |
[:arrow_up_small:](#)
@ -1221,6 +1205,10 @@
- ATTACK_GROUND_POUND_OR_TWIRL
- ATTACK_KICK_OR_TRIP
- ATTACK_PUNCH
- INT_ANY_ATTACK
- INT_ATTACK_NOT_FROM_BELOW
- INT_ATTACK_NOT_WEAK_FROM_ABOVE
- INT_ATTACK_SLIDE
- INT_STATUS_ATTACKED_MARIO
- INT_STATUS_ATTACK_MASK
- INT_STATUS_GRABBED_MARIO
@ -1254,6 +1242,20 @@
- INT_SUBTYPE_STAR_DOOR
- INT_SUBTYPE_TWIRL_BOUNCE
### [enum InteractionFlag](#InteractionFlag)
| Identifier | Value |
| :--------- | :---- |
| INT_GROUND_POUND | (1 << 0) |
| INT_PUNCH | (1 << 1) |
| INT_KICK | (1 << 2) |
| INT_TRIP | (1 << 3) |
| INT_SLIDE_KICK | (1 << 4) |
| INT_FAST_ATTACK_OR_SHELL | (1 << 5) |
| INT_HIT_FROM_ABOVE | (1 << 6) |
| INT_HIT_FROM_BELOW | (1 << 7) |
| INT_TWIRL | (1 << 8) |
| INT_GROUND_POUND_OR_TWIRL | (INT_GROUND_POUND | INT_TWIRL) |
### [enum InteractionType](#InteractionType)
| Identifier | Value |
| :--------- | :---- |
@ -2614,6 +2616,7 @@
- ACT_FLAG_CONTROL_JUMP_HEIGHT
- ACT_FLAG_CUSTOM_ACTION
- ACT_FLAG_DIVING
- ACT_FLAG_FLYING
- ACT_FLAG_HANGING
- ACT_FLAG_IDLE
- ACT_FLAG_INTANGIBLE

View file

@ -2910,6 +2910,26 @@
<br />
## [set_audio_fadeout](#set_audio_fadeout)
### Lua Example
`set_audio_fadeout(fadeOutTime)`
### Parameters
| Field | Type |
| ----- | ---- |
| fadeOutTime | `integer` |
### Returns
- None
### C Prototype
`void set_audio_fadeout(u16 fadeOutTime);`
[:arrow_up_small:](#)
<br />
## [sound_banks_disable](#sound_banks_disable)
### Lua Example
@ -2972,6 +2992,26 @@
<br />
## [stop_secondary_music](#stop_secondary_music)
### Lua Example
`stop_secondary_music(fadeTimer)`
### Parameters
| Field | Type |
| ----- | ---- |
| fadeTimer | `integer` |
### Returns
- None
### C Prototype
`void stop_secondary_music(u16 fadeTimer);`
[:arrow_up_small:](#)
<br />
## [stop_sound](#stop_sound)
### Lua Example
@ -3037,6 +3077,27 @@
<br />
## [determine_interaction](#determine_interaction)
### Lua Example
`local integerValue = determine_interaction(m, o)`
### Parameters
| Field | Type |
| ----- | ---- |
| m | [MarioState](structs.md#MarioState) |
| o | [Object](structs.md#Object) |
### Returns
- `integer`
### C Prototype
`u32 determine_interaction(struct MarioState *m, struct Object *o);`
[:arrow_up_small:](#)
<br />
## [does_mario_have_normal_cap_on_head](#does_mario_have_normal_cap_on_head)
### Lua Example

View file

@ -766,9 +766,11 @@
- [seq_player_fade_out](functions-3.md#seq_player_fade_out)
- [seq_player_lower_volume](functions-3.md#seq_player_lower_volume)
- [seq_player_unlower_volume](functions-3.md#seq_player_unlower_volume)
- [set_audio_fadeout](functions-3.md#set_audio_fadeout)
- [sound_banks_disable](functions-3.md#sound_banks_disable)
- [sound_banks_enable](functions-3.md#sound_banks_enable)
- [stop_background_music](functions-3.md#stop_background_music)
- [stop_secondary_music](functions-3.md#stop_secondary_music)
- [stop_sound](functions-3.md#stop_sound)
- [stop_sounds_from_source](functions-3.md#stop_sounds_from_source)
- [stop_sounds_in_continuous_banks](functions-3.md#stop_sounds_in_continuous_banks)
@ -776,6 +778,7 @@
<br />
- interaction.h
- [determine_interaction](functions-3.md#determine_interaction)
- [does_mario_have_normal_cap_on_head](functions-3.md#does_mario_have_normal_cap_on_head)
- [get_door_save_file_flag](functions-3.md#get_door_save_file_flag)
- [interact_damage](functions-3.md#interact_damage)

View file

@ -169,6 +169,7 @@
#define ACT_FLAG_WATER_OR_TEXT /* 0x20000000 */ (1 << 29)
#define ACT_FLAG_CUSTOM_ACTION /* 0x40000000 */ (1 << 30)
#define ACT_FLAG_THROWING /* 0x80000000 */ (1 << 31)
#define ACT_FLAG_FLYING (ACT_FLAG_AIR | ACT_FLAG_DIVING | ACT_FLAG_ATTACKING | ACT_FLAG_SWIMMING_OR_FLYING)
#define ACT_UNINITIALIZED 0x00000000 // (0x000)

View file

@ -115,6 +115,14 @@ local function name_without_hex(name)
return s
end
local function split(s)
local result = {}
for match in (s):gmatch(string.format("[^%s]+", " ")) do
table.insert(result, match)
end
return result
end
local function on_hud_render()
if gGlobalSyncTable.dist == 0 or (not showSelfTag and network_player_connected_count() == 1) or not gNetworkPlayers[0].currAreaSyncValid or obj_get_first_with_behavior_id(id_bhvActSelector) ~= nil then return end
@ -123,13 +131,11 @@ local function on_hud_render()
for i = if_then_else(showSelfTag, 0, 1), (MAX_PLAYERS - 1) do
local m = gMarioStates[i]
if m.marioBodyState.updateTorsoTime == gMarioStates[0].marioBodyState.updateTorsoTime and active_player(m) ~= 0 and m.action ~= ACT_IN_CANNON and (m.playerIndex ~= 0 or (m.playerIndex == 0 and m.action ~= ACT_FIRST_PERSON)) then
local out = { x = 0, y = 0, z = 0 }
local pos = { x = m.marioObj.header.gfx.pos.x, y = m.pos.y + 210, z = m.marioObj.header.gfx.pos.z }
djui_hud_world_pos_to_screen_pos(pos, out)
local out = { x = 0, y = 0, z = 0 }
local pos = { x = m.marioObj.header.gfx.pos.x, y = m.pos.y + 210, z = m.marioObj.header.gfx.pos.z }
if djui_hud_world_pos_to_screen_pos(pos, out) and m.marioBodyState.updateTorsoTime == gMarioStates[0].marioBodyState.updateTorsoTime and active_player(m) ~= 0 and m.action ~= ACT_IN_CANNON and (m.playerIndex ~= 0 or (m.playerIndex == 0 and m.action ~= ACT_FIRST_PERSON)) then
local scale = MAX_SCALE
local dist = vec3f_dist(gMarioStates[0].pos, m.pos)
local dist = vec3f_dist(gLakituState.pos, m.pos)
if m.playerIndex ~= 0 and dist > 1000 then
scale = 0.5
scale = scale + dist / gGlobalSyncTable.dist
@ -162,33 +168,58 @@ local function on_hud_render()
end
end
local function on_nametag_distance_command(msg)
local function on_distance_command(msg)
if not network_is_server() and not network_is_moderator() then
djui_chat_message_create("\\#d86464\\You do not have permission to run this command.")
return true
end
local dist = tonumber(msg)
if dist ~= nil then
djui_chat_message_create("Set nametag distance to " .. msg)
gGlobalSyncTable.dist = dist
return true
else
djui_chat_message_create("/nametags \\#00ffff\\distance\\#ffff00\\ [number]\\#ffffff\\\nSets the distance at which nametags disappear,\ndefault is \\#ffff00\\7000\\#ffffff\\, \\#ffff00\\0\\#ffffff\\ turns nametags off")
return true
end
return false
end
local function on_show_health_command()
local function on_show_health_command(msg)
if msg == "?" then
djui_chat_message_create("/nametags \\#00ffff\\show-health\\#ffffff\\\nToggles showing health above the nametag, default is \\#00ff00\\ON")
return true
end
showHealth = not showHealth
djui_chat_message_create("Show health status: " .. on_or_off(showHealth))
return true
end
local function on_show_tag_command()
local function on_show_tag_command(msg)
if msg == "?" then
djui_chat_message_create("/nametags \\#00ffff\\show-tag\\#ffffff\\\nToggles your own nametag on or off, default is \\#ff0000\\OFF")
return true
end
showSelfTag = not showSelfTag
djui_chat_message_create("Show my tag status: " .. on_or_off(showSelfTag))
return true
end
hook_event(HOOK_ON_HUD_RENDER, on_hud_render)
if network_is_server() then
hook_chat_command("nametag-distance", "[number] set the distance at which nametags disappear, default is 7000, 0 turns nametags off", on_nametag_distance_command)
local function on_nametags_command(msg)
local args = split(msg)
if args[1] == "distance" then
return on_distance_command(args[2])
elseif args[1] == "show-health" then
return on_show_health_command(args[2])
elseif args[1] == "show-tag" then
return on_show_tag_command(args[2])
end
return false
end
hook_chat_command("show-health", "to toggle showing health above the nametag, default is \\#00ff00\\ON", on_show_health_command)
hook_chat_command("show-tag", "to toggle your own nametag on or off, default is \\#ff0000\\OFF", on_show_tag_command)
hook_event(HOOK_ON_HUD_RENDER, on_hud_render)
hook_chat_command("nametags", "[show-tag|show-health|distance]", on_nametags_command)

View file

@ -5,6 +5,7 @@
#include "data.h"
#include "seqplayer.h"
#include "external.h"
#include "internal.h"
#include "playback.h"
#include "synthesis.h"
#include "game/level_update.h"
@ -424,11 +425,11 @@ u16 sSoundBanksThatLowerBackgroundMusic = 0;
u8 sUnused80332114 = 0; // never read, set to 0
u16 sUnused80332118 = 0; // never read, set to 0
u8 sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_UNSET;
u8 D_80332120 = 0;
u8 D_80332124 = 0;
u8 sCurrentSecondaryMusicSeqId = 0;
u8 sCurrentSecondaryMusicVolume = 0;
#if defined(VERSION_EU) || defined(VERSION_SH)
u8 D_EU_80300558 = 0;
u8 sRemainingEnvFadeInSkips = 0;
#endif
u8 sBackgroundMusicQueueSize = 0;
@ -453,7 +454,7 @@ s8 D_SH_80343E48_pad[0x8];
#endif
struct Sound sSoundRequests[0x100] = { 0 };
struct ChannelVolumeScaleFade D_80360928[SEQUENCE_PLAYERS][CHANNELS_MAX] = { 0 };
struct ChannelVolumeScaleFade sVolumeScaleFades[SEQUENCE_PLAYERS][CHANNELS_MAX] = { 0 };
u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT] = { 0 };
u8 sCurrentSound[SOUND_BANK_COUNT][MAX_CHANNELS_PER_SOUND_BANK] = { 0 }; // index into sSoundBanks
@ -510,7 +511,7 @@ static void update_game_sound(void);
static void fade_channel_volume_scale(u8 player, u8 channelId, u8 targetScale, u16 fadeTimer);
void process_level_music_dynamics(void);
static u8 begin_background_music_fade(u16 fadeDuration);
void func_80320ED8(void);
void fade_in_env_music(void);
static s16 get_level_dynamics(s16 levelNum, s16 index) {
if (levelNum < 0 || levelNum >= LEVEL_COUNT) {
@ -820,7 +821,7 @@ void maybe_tick_game_sound(void) {
void func_eu_802e9bec(s32 player, s32 channel, s32 arg2) {
// EU verson of unused_803209D8
// chan->stopSomething2 = arg2?
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x08, player, channel, 0), (s8)arg2);
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_GENERAL_STOP, player, channel, 0), (s8)arg2);
}
#else
@ -1430,7 +1431,7 @@ static void update_game_sound(void) {
if (sSoundMovingSpeed[bank] > 8) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(
AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1));
#else
value = get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1);
@ -1439,7 +1440,7 @@ static void update_game_sound(void) {
#endif
} else {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1)
* ((sSoundMovingSpeed[bank] + 8.0f) / 16));
#else
@ -1449,7 +1450,7 @@ static void update_game_sound(void) {
#endif
}
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_pan(*sSoundBanks[bank][soundIndex].x,
*sSoundBanks[bank][soundIndex].z));
#else
@ -1462,7 +1463,7 @@ static void update_game_sound(void) {
== (SOUND_MOVING_FLYING & SOUNDARGS_MASK_SOUNDID)) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(
AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex)
+ ((f32) sSoundMovingSpeed[bank] / US_FLOAT(80.0)));
#else
@ -1473,7 +1474,7 @@ static void update_game_sound(void) {
} else {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(
AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex)
+ ((f32) sSoundMovingSpeed[bank] / US_FLOAT(400.0)));
#else
@ -1483,7 +1484,7 @@ static void update_game_sound(void) {
#endif
}
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_reverb(bank, soundIndex, channelIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
@ -1495,9 +1496,9 @@ static void update_game_sound(void) {
// fallthrough
case SOUND_BANK_MENU:
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), 1);
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), 64);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), 1);
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), 64);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = 1.0f;
@ -1510,14 +1511,14 @@ static void update_game_sound(void) {
case SOUND_BANK_LUIGI_VOICE:
case SOUND_BANK_WARIO_VOICE:
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_reverb(bank, soundIndex, channelIndex));
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1));
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_pan(*sSoundBanks[bank][soundIndex].x,
*sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume =
@ -1538,14 +1539,14 @@ static void update_game_sound(void) {
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_reverb(bank, soundIndex, channelIndex));
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK2));
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_pan(*sSoundBanks[bank][soundIndex].x,
*sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
@ -1603,7 +1604,7 @@ static void update_game_sound(void) {
if (sSoundMovingSpeed[bank] > 8) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(
AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1));
#else
value = get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1);
@ -1612,7 +1613,7 @@ static void update_game_sound(void) {
#endif
} else {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1)
* ((sSoundMovingSpeed[bank] + 8.0f) / 16));
#else
@ -1622,7 +1623,7 @@ static void update_game_sound(void) {
#endif
}
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_pan(*sSoundBanks[bank][soundIndex].x,
*sSoundBanks[bank][soundIndex].z));
#else
@ -1635,7 +1636,7 @@ static void update_game_sound(void) {
== (SOUND_MOVING_FLYING & SOUNDARGS_MASK_SOUNDID)) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(
AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex)
+ ((f32) sSoundMovingSpeed[bank] / US_FLOAT(80.0)));
#else
@ -1646,7 +1647,7 @@ static void update_game_sound(void) {
} else {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(
AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex)
+ ((f32) sSoundMovingSpeed[bank] / US_FLOAT(400.0)));
#else
@ -1656,7 +1657,7 @@ static void update_game_sound(void) {
#endif
}
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_reverb(bank, soundIndex, channelIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
@ -1668,9 +1669,9 @@ static void update_game_sound(void) {
// fallthrough
case SOUND_BANK_MENU:
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0), 1);
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0), 64);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0), 1);
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0), 64);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = 1.0f;
@ -1681,14 +1682,14 @@ static void update_game_sound(void) {
case SOUND_BANK_ACTION:
case SOUND_BANK_MARIO_VOICE:
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_reverb(bank, soundIndex, channelIndex));
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK1));
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_pan(*sSoundBanks[bank][soundIndex].x,
*sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume =
@ -1709,14 +1710,14 @@ static void update_game_sound(void) {
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x05, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_reverb(bank, soundIndex, channelIndex));
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x02, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK2));
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x03, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_NEW_PAN, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_pan(*sSoundBanks[bank][soundIndex].x,
*sSoundBanks[bank][soundIndex].z) * 127.0f + 0.5f);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
@ -1737,7 +1738,7 @@ static void update_game_sound(void) {
// add custom pitch bend
if (soundIndex < SOUND_INDEX_COUNT && sSoundBanks[bank][soundIndex].customFreqScale != 0) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x04, SEQ_PLAYER_SFX, channelIndex, 0),
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_FREQ_SCALE, SEQ_PLAYER_SFX, channelIndex, 0),
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale
* sSoundBanks[bank][soundIndex].customFreqScale);
#else
@ -1772,12 +1773,12 @@ static void seq_player_play_sequence(u8 player, u8 seqId, u16 arg2) {
}
for (i = 0; i < CHANNELS_MAX; i++) {
D_80360928[player][i].remainingFrames = 0;
sVolumeScaleFades[player][i].remainingFrames = 0;
}
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_s8(AUDIO_CMD_ARGS(0x46, player, 0, 0), seqId & SEQ_VARIATION);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x82, player, seqId & SEQ_BASE_ID, 0), arg2);
queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_SEQUENCE_VARIATION, player, 0, 0), seqId & SEQ_VARIATION);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_LOAD_SEQUENCE, player, seqId & SEQ_BASE_ID, 0), arg2);
if (player == SEQ_PLAYER_LEVEL) {
targetVolume = begin_background_music_fade(0);
@ -1815,7 +1816,7 @@ void seq_player_fade_out(u8 player, u16 fadeDuration) {
if (!player) {
sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
}
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x83, player, 0, 0), fd);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_FADE_TO_ZERO_VOLUME, player, 0, 0), fd);
#else
if (player == SEQ_PLAYER_LEVEL) {
sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
@ -1841,7 +1842,7 @@ static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale
struct ChannelVolumeScaleFade *temp;
if (gSequencePlayers[player].channels[channelIndex] != &gSequenceChannelNone) {
temp = &D_80360928[player][channelIndex];
temp = &sVolumeScaleFades[player][channelIndex];
temp->remainingFrames = fadeDuration;
temp->velocity = ((f32)(targetScale / US_FLOAT(127.0))
- gSequencePlayers[player].channels[channelIndex]->volumeScale)
@ -1854,31 +1855,29 @@ static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale
/**
* Called from threads: thread4_sound, thread5_game_loop (EU only)
*/
static void func_8031F96C(u8 player) {
u8 i;
static void fade_seqplayer_channels(u8 player) {
// Loop over channels
for (i = 0; i < CHANNELS_MAX; i++) {
for (u8 i = 0; i < CHANNELS_MAX; i++) {
if (gSequencePlayers[player].channels[i] != &gSequenceChannelNone
&& D_80360928[player][i].remainingFrames != 0) {
D_80360928[player][i].current += D_80360928[player][i].velocity;
&& sVolumeScaleFades[player][i].remainingFrames != 0) {
sVolumeScaleFades[player][i].current += sVolumeScaleFades[player][i].velocity;
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x01, player, i, 0),
D_80360928[player][i].current);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME_SCALE, player, i, 0),
sVolumeScaleFades[player][i].current);
#else
gSequencePlayers[player].channels[i]->volumeScale = D_80360928[player][i].current;
gSequencePlayers[player].channels[i]->volumeScale = sVolumeScaleFades[player][i].current;
#endif
D_80360928[player][i].remainingFrames--;
if (D_80360928[player][i].remainingFrames == 0) {
sVolumeScaleFades[player][i].remainingFrames--;
if (sVolumeScaleFades[player][i].remainingFrames == 0) {
#if defined(VERSION_EU)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x01, player, i, 0),
FLOAT_CAST(D_80360928[player][i].target) / 127.0);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME_SCALE, player, i, 0),
FLOAT_CAST(sVolumeScaleFades[player][i].target) / 127.0);
#elif defined(VERSION_SH)
queue_audio_cmd_f32(AUDIO_CMD_ARGS(0x01, player, i, 0),
FLOAT_CAST(D_80360928[player][i].target) / 127.0f);
queue_audio_cmd_f32(AUDIO_CMD_ARGS(AUDIO_CMD_VOLUME_SCALE, player, i, 0),
FLOAT_CAST(sVolumeScaleFades[player][i].target) / 127.0f);
#else
gSequencePlayers[player].channels[i]->volumeScale =
D_80360928[player][i].target / 127.0f;
sVolumeScaleFades[player][i].target / 127.0f;
#endif
}
}
@ -1902,9 +1901,9 @@ void process_level_music_dynamics(void) {
s16 dur2;
u16 bit;
func_8031F96C(0);
func_8031F96C(2);
func_80320ED8();
fade_seqplayer_channels(0);
fade_seqplayer_channels(2);
fade_in_env_music();
if (sMusicDynamicDelay != 0) {
sMusicDynamicDelay--;
} else {
@ -2149,9 +2148,9 @@ void set_audio_muted(u8 muted) {
for (i = 0; i < SEQUENCE_PLAYERS; i++) {
#if defined(VERSION_EU) || defined(VERSION_SH)
if (muted)
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0xf1, 0, 0, 0), 0);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_MUTE_ALL_SEQUENCE_PLAYERS, 0, 0, 0), 0);
else
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0xf2, 0, 0, 0), 0);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS, 0, 0, 0), 0);
#else
gSequencePlayers[i].muted = muted;
#endif
@ -2187,7 +2186,7 @@ void sound_init(void) {
sSoundBanks[i][0].next = 0xff;
// Set free list to contain every sound slot
for (j = 1; j < 40 - 1; j++) {
for (j = 1; j < SOUND_INDEX_COUNT - 1; j++) {
sSoundBanks[i][j].prev = j - 1;
sSoundBanks[i][j].next = j + 1;
}
@ -2197,7 +2196,7 @@ void sound_init(void) {
for (j = 0; j < 3; j++) {
for (i = 0; i < CHANNELS_MAX; i++) {
D_80360928[j][i].remainingFrames = 0;
sVolumeScaleFades[j][i].remainingFrames = 0;
}
}
@ -2216,8 +2215,8 @@ void sound_init(void) {
gSoundMode = SOUND_MODE_STEREO;
sBackgroundMusicQueueSize = 0;
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_UNSET;
D_80332120 = 0;
D_80332124 = 0;
sCurrentSecondaryMusicSeqId = 0;
sCurrentSecondaryMusicVolume = 0;
sNumProcessedSoundRequests = 0;
sSoundRequestCount = 0;
}
@ -2595,14 +2594,14 @@ u8 is_current_background_music_volume_lowered(void) {
/**
* Called from threads: thread4_sound, thread5_game_loop (EU only)
*/
void func_80320ED8(void) {
void fade_in_env_music(void) {
#if defined(VERSION_EU) || defined(VERSION_SH)
if (D_EU_80300558 != 0) {
D_EU_80300558--;
if (sRemainingEnvFadeInSkips != 0) {
sRemainingEnvFadeInSkips--;
}
if (gSequencePlayers[SEQ_PLAYER_ENV].enabled
|| sBackgroundMusicMaxTargetVolume == TARGET_VOLUME_UNSET || D_EU_80300558 != 0) {
|| sBackgroundMusicMaxTargetVolume == TARGET_VOLUME_UNSET || sRemainingEnvFadeInSkips != 0) {
#else
if (gSequencePlayers[SEQ_PLAYER_ENV].enabled
|| sBackgroundMusicMaxTargetVolume == TARGET_VOLUME_UNSET) {
@ -2614,10 +2613,10 @@ void func_80320ED8(void) {
begin_background_music_fade(50);
if (sBackgroundMusicTargetVolume != TARGET_VOLUME_UNSET
&& (D_80332120 == SEQ_EVENT_MERRY_GO_ROUND || D_80332120 == SEQ_EVENT_PIRANHA_PLANT)) {
seq_player_play_sequence(SEQ_PLAYER_ENV, D_80332120, 1);
if (D_80332124 != 0xff) {
seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, 1, D_80332124);
&& (sCurrentSecondaryMusicSeqId == SEQ_EVENT_MERRY_GO_ROUND || sCurrentSecondaryMusicSeqId == SEQ_EVENT_PIRANHA_PLANT)) {
seq_player_play_sequence(SEQ_PLAYER_ENV, sCurrentSecondaryMusicSeqId, 1);
if (sCurrentSecondaryMusicVolume != 0xff) {
seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, 1, sCurrentSecondaryMusicVolume);
}
}
}
@ -2640,24 +2639,24 @@ void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer)
if (volume < 0x80) {
seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, fadeTimer, volume);
}
D_80332124 = volume;
D_80332120 = seqId;
sCurrentSecondaryMusicVolume = volume;
sCurrentSecondaryMusicSeqId = seqId;
} else if (volume != 0xff) {
sBackgroundMusicTargetVolume = bgMusicVolume + TARGET_VOLUME_IS_PRESENT_FLAG;
begin_background_music_fade(fadeTimer);
seq_player_fade_to_target_volume(SEQ_PLAYER_ENV, fadeTimer, volume);
D_80332124 = volume;
sCurrentSecondaryMusicVolume = volume;
}
}
/**
* Called from threads: thread5_game_loop
*/
void func_80321080(u16 fadeTimer) {
void stop_secondary_music(u16 fadeTimer) {
if (sBackgroundMusicTargetVolume != TARGET_VOLUME_UNSET) {
sBackgroundMusicTargetVolume = TARGET_VOLUME_UNSET;
D_80332120 = 0;
D_80332124 = 0;
sCurrentSecondaryMusicSeqId = 0;
sCurrentSecondaryMusicVolume = 0;
begin_background_music_fade(fadeTimer);
seq_player_fade_out(SEQ_PLAYER_ENV, fadeTimer);
}
@ -2666,16 +2665,14 @@ void func_80321080(u16 fadeTimer) {
/**
* Called from threads: thread3_main, thread5_game_loop
*/
void func_803210D4(u16 fadeDuration) {
u8 i;
void set_audio_fadeout(u16 fadeDuration) {
if (sHasStartedFadeOut) {
return;
}
if (gSequencePlayers[SEQ_PLAYER_LEVEL].enabled == TRUE) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x83, 0, 0, 0), fadeDuration);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_FADE_TO_ZERO_VOLUME, 0, 0, 0), fadeDuration);
#else
seq_player_fade_to_zero_volume(SEQ_PLAYER_LEVEL, fadeDuration);
#endif
@ -2683,13 +2680,13 @@ void func_803210D4(u16 fadeDuration) {
if (gSequencePlayers[SEQ_PLAYER_ENV].enabled == TRUE) {
#if defined(VERSION_EU) || defined(VERSION_SH)
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0x83, SEQ_PLAYER_ENV, 0, 0), fadeDuration);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_FADE_TO_ZERO_VOLUME, SEQ_PLAYER_ENV, 0, 0), fadeDuration);
#else
seq_player_fade_to_zero_volume(SEQ_PLAYER_ENV, fadeDuration);
#endif
}
for (i = 0; i < SOUND_BANK_COUNT; i++) {
for (s32 i = 0; i < SOUND_BANK_COUNT; i++) {
if (i != SOUND_BANK_MENU) {
fade_channel_volume_scale(SEQ_PLAYER_SFX, i, 0, fadeDuration / 16);
}
@ -2705,7 +2702,7 @@ void play_course_clear(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_COLLECT_STAR, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 0;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2717,7 +2714,7 @@ void play_peachs_jingle(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_PEACH_MESSAGE, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 0;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2733,7 +2730,7 @@ void play_puzzle_jingle(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_SOLVE_PUZZLE, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2745,7 +2742,7 @@ void play_star_fanfare(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_HIGH_SCORE, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2760,7 +2757,7 @@ void play_power_star_jingle(u8 arg0) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_CUTSCENE_STAR_SPAWN, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2772,7 +2769,7 @@ void play_race_fanfare(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_RACE, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2784,7 +2781,7 @@ void play_toads_jingle(void) {
seq_player_play_sequence(SEQ_PLAYER_ENV, SEQ_EVENT_TOAD_MESSAGE, 0);
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_IS_PRESENT_FLAG | 20;
#if defined(VERSION_EU) || defined(VERSION_SH)
D_EU_80300558 = 2;
sRemainingEnvFadeInSkips = 2;
#endif
begin_background_music_fade(50);
}
@ -2803,7 +2800,7 @@ void sound_reset(u8 presetId) {
disable_all_sequence_players();
sound_init();
#ifdef VERSION_SH
queue_audio_cmd_u32(AUDIO_CMD_ARGS(0xF2, 0, 0, 0), 0);
queue_audio_cmd_u32(AUDIO_CMD_ARGS(AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS, 0, 0, 0), 0);
#endif
#if defined(VERSION_JP) || defined(VERSION_US)
audio_reset_session(&gAudioSessionPresets[presetId]);

View file

@ -10,10 +10,6 @@
// bit which may be read by the sequence script.
#define SEQUENCE_ARGS(priority, seqId) ((priority << 8) | seqId)
#if defined(VERSION_EU) || defined(VERSION_SH)
#define AUDIO_CMD_ARGS(cmd, arg1, arg2, arg3) (((cmd & 0xff) << 24) | ((arg1 & 0xff) << 16) | ((arg2 & 0xff) << 8) | (arg3 & 0xff))
#endif
#define SOUND_MODE_STEREO 0
#define SOUND_MODE_MONO 3
#define SOUND_MODE_HEADSET 1
@ -65,8 +61,8 @@ u8 get_current_background_music_target_volume(void);
u8 get_current_background_music_max_target_volume(void);
u8 is_current_background_music_volume_lowered(void);
void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer);
void func_80321080(u16 fadeTimer);
void func_803210D4(u16 fadeOutTime);
void stop_secondary_music(u16 fadeTimer);
void set_audio_fadeout(u16 fadeOutTime);
void play_course_clear(void);
void play_peachs_jingle(void);
void play_puzzle_jingle(void);

View file

@ -86,6 +86,37 @@
#define eu_stubbed_printf_3(msg, a, b, c)
#endif
#if defined(VERSION_EU) || defined(VERSION_SH)
#define AUDIO_CMD_ARGS(cmd, arg1, arg2, arg3) (((cmd & 0xff) << 24) | ((arg1 & 0xff) << 16) | ((arg2 & 0xff) << 8) | (arg3 & 0xff))
// Channel audio commands
#define AUDIO_CMD_VOLUME_SCALE 1
#define AUDIO_CMD_VOLUME 2
#define AUDIO_CMD_NEW_PAN 3
#define AUDIO_CMD_FREQ_SCALE 4
#define AUDIO_CMD_REVERB 5
#define AUDIO_CMD_SOUND_SCRIPT 6 // Unused, There is spots it could be added, But it isn't in practice.
#define AUDIO_CMD_GENERAL_STOP 8
// Sequence player audio commands
#define AUDIO_CMD_FADE_VOLUME_SCALE 0x41
#define AUDIO_CMD_SEQUENCE_VARIATION 0x46
#define AUDIO_CMD_TEMPO 0x47
#define AUDIO_CMD_TRANSPOSITION 0x48
// Sequence audio commands
#define AUDIO_CMD_PRELOAD_SEQUENCE 0x81
#define AUDIO_CMD_LOAD_SEQUENCE 0x82
#define AUDIO_CMD_FADE_TO_ZERO_VOLUME 0x83
#define AUDIO_CMD_LOAD_SEQUENCE2 0x88
// Other audio commands
#define AUDIO_CMD_SOUND_MODE 0xf0
#define AUDIO_CMD_MUTE_ALL_SEQUENCE_PLAYERS 0xf1
#define AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS 0xf2
#endif
struct NotePool;
struct AudioListItem

View file

@ -65,18 +65,18 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
s32 i;
switch (cmd->u.s.op) {
case 0x81:
preload_sequence(cmd->u.s.arg2, 3);
case AUDIO_CMD_PRELOAD_SEQUENCE:
preload_sequence(cmd->u.s.arg2, PRELOAD_BANKS | PRELOAD_SEQUENCE);
break;
case 0x82:
case 0x88:
case AUDIO_CMD_LOAD_SEQUENCE:
case AUDIO_CMD_LOAD_SEQUENCE2:
load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3);
seq_player_fade_from_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32);
//LOG_DEBUG("Playing sequence with arguments: %d, 0x%X, %d", cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3);
break;
case 0x83:
case AUDIO_CMD_FADE_TO_ZERO_VOLUME:
if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) {
if (cmd->u2.as_s32 == 0) {
sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]);
@ -87,18 +87,18 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
}
break;
case 0xf0:
case AUDIO_CMD_SOUND_MODE:
gSoundMode = cmd->u2.as_s32;
break;
case 0xf1:
case AUDIO_CMD_MUTE_ALL_SEQUENCE_PLAYERS:
for (i = 0; i < 4; i++) {
gSequencePlayers[i].muted = TRUE;
gSequencePlayers[i].recalculateVolume = TRUE;
}
break;
case 0xf2:
case AUDIO_CMD_UNMUTE_ALL_SEQUENCE_PLAYERS:
for (i = 0; i < 4; i++) {
gSequencePlayers[i].muted = FALSE;
gSequencePlayers[i].recalculateVolume = TRUE;
@ -191,20 +191,20 @@ void process_queued_audio_cmds(u32 arg0) {
}
else if ((cmd->u.s.op & 0x40) != 0) {
switch (cmd->u.s.op) {
case 0x41:
case AUDIO_CMD_FADE_VOLUME_SCALE:
seqPlayer->fadeVolumeScale = cmd->u2.as_f32;
seqPlayer->recalculateVolume = TRUE;
break;
case 0x47:
case AUDIO_CMD_TEMPO:
seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT;
break;
case 0x48:
case AUDIO_CMD_TRANSPOSITION:
seqPlayer->transposition = cmd->u2.as_s8;
break;
case 0x46:
case AUDIO_CMD_SEQUENCE_VARIATION:
seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8;
break;
}
@ -214,31 +214,31 @@ void process_queued_audio_cmds(u32 arg0) {
if (IS_SEQUENCE_CHANNEL_VALID(chan))
{
switch (cmd->u.s.op) {
case 1:
case AUDIO_CMD_VOLUME_SCALE:
chan->volumeScale = cmd->u2.as_f32;
chan->changes.as_bitfields.volume = TRUE;
break;
case 2:
case AUDIO_CMD_VOLUME:
chan->volume = cmd->u2.as_f32;
chan->changes.as_bitfields.volume = TRUE;
break;
case 3:
case AUDIO_CMD_NEW_PAN:
chan->newPan = cmd->u2.as_s8;
chan->changes.as_bitfields.pan = TRUE;
break;
case 4:
case AUDIO_CMD_FREQ_SCALE:
chan->freqScale = cmd->u2.as_f32;
chan->changes.as_bitfields.freqScale = TRUE;
break;
case 5:
case AUDIO_CMD_REVERB:
chan->reverb = cmd->u2.as_s8;
break;
case 6:
case AUDIO_CMD_SOUND_SCRIPT:
if (cmd->u.s.arg3 < 8) {
chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8;
}
break;
case 8:
case AUDIO_CMD_GENERAL_STOP:
chan->stopSomething2 = cmd->u2.as_s8;
}
}

View file

@ -938,7 +938,7 @@ static void level_cmd_place_object_ext(void) {
return;
}
if (sCurrAreaIndex != -1 && ((CMD_GET(u8, 2) & val7) || CMD_GET(u8, 2) == 0x1F)) {
if (sCurrAreaIndex != -1 && (gLevelValues.disableActs || (CMD_GET(u8, 2) & val7) || CMD_GET(u8, 2) == 0x1F)) {
u16 model = CMD_GET(u8, 3);
if (model >= MAX_LOADED_GRAPH_NODES) { model = MODEL_NONE; }
spawnInfo = alloc_only_pool_alloc(sLevelPool, sizeof(struct SpawnInfo));
@ -1010,7 +1010,7 @@ static void level_cmd_place_object_ext2(void) {
return;
}
if (sCurrAreaIndex != -1 && ((CMD_GET(u8, 2) & val7) || CMD_GET(u8, 2) == 0x1F)) {
if (sCurrAreaIndex != -1 && (gLevelValues.disableActs || (CMD_GET(u8, 2) & val7) || CMD_GET(u8, 2) == 0x1F)) {
spawnInfo = alloc_only_pool_alloc(sLevelPool, sizeof(struct SpawnInfo));
spawnInfo->startPos[0] = CMD_GET(s16, 4);

View file

@ -52,7 +52,7 @@ static void handle_merry_go_round_music(void) {
// The merry-go-round is a dynamic surface.
gMarioCurrentRoom != BBH_DYNAMIC_SURFACE_ROOM
&& gMarioCurrentRoom != BBH_NEAR_MERRY_GO_ROUND_ROOM) {
func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling
stop_secondary_music(300); // Switch to BBH music? FIXME: Audio needs labelling
o->oMerryGoRoundMusicShouldPlay = FALSE;
} else {
cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING);
@ -93,6 +93,6 @@ void bhv_merry_go_round_loop(void) {
handle_merry_go_round_music();
} else {
o->oAngleVelYaw = 0;
func_80321080(300); // Switch to BBH music? FIXME: Audio needs labelling
stop_secondary_music(300); // Switch to BBH music? FIXME: Audio needs labelling
}
}

View file

@ -136,7 +136,7 @@ void bhv_blue_coin_switch_loop(void) {
// If Mario is on the switch and has ground-pounded,
// recede and get ready to start ticking.
if (gMarioObject->platform == o) {
if (gMarioStates[0].action == ACT_GROUND_POUND_LAND) {
if (determine_interaction(&gMarioStates[0], o) & INT_GROUND_POUND) {
// Set to BLUE_COIN_SWITCH_ACT_RECEDING
o->oAction++;

View file

@ -42,7 +42,7 @@ s32 piranha_plant_check_interactions(void) {
s32 i;
s32 interacted = 1;
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
func_80321080(50);
stop_secondary_music(50);
if (o->oInteractStatus & INT_STATUS_WAS_ATTACKED) {
cur_obj_play_sound_2(SOUND_OBJ2_PIRANHA_PLANT_DYING);
@ -104,7 +104,7 @@ void piranha_plant_act_sleeping(void) {
o->oPiranhaPlantSleepMusicState = PIRANHA_PLANT_SLEEP_MUSIC_PLAYING;
} else if (o->oPiranhaPlantSleepMusicState == PIRANHA_PLANT_SLEEP_MUSIC_PLAYING) {
o->oPiranhaPlantSleepMusicState++;
func_80321080(50);
stop_secondary_music(50);
}
piranha_plant_check_interactions();
}
@ -123,7 +123,7 @@ void piranha_plant_act_woken_up(void) {
o->oDamageOrCoinValue = 3;
#endif
if (o->oTimer == 0)
func_80321080(50);
stop_secondary_music(50);
if (piranha_plant_check_interactions() == 0) {
if (o->oTimer > 10) {

View file

@ -31,7 +31,7 @@ void bhv_thi_tiny_island_top_loop(void) {
if (!(gTHIWaterDrained & 1)) {
if (o->oAction == 0) {
if (distanceToPlayer < 500.0f)
if (marioState && marioState->action == ACT_GROUND_POUND_LAND) {
if (marioState && !(marioState->action & ACT_FLAG_AIR) && (determine_interaction(marioState, o) & INT_GROUND_POUND) != 0) {
o->oAction++;
cur_obj_spawn_particles(&D_8032F134);
spawn_triangle_break_particles(20, 138, 0.3f, 3);

View file

@ -463,8 +463,8 @@ static void newcam_update_values(void) {
}
}
switch (gMarioStates[0].action) {
case ACT_FLYING: centering = 1; break;
if ((gMarioStates[0].action & ACT_FLAG_FLYING) == ACT_FLAG_FLYING) {
centering = 1;
}
static u32 sLastAction = 0;

View file

@ -33,31 +33,6 @@
#include "pc/lua/smlua_hooks.h"
#include "pc/cheats.h"
enum InteractionFlag {
INT_GROUND_POUND_OR_TWIRL = (1 << 0), // 0x01
INT_PUNCH = (1 << 1), // 0x02
INT_KICK = (1 << 2), // 0x04
INT_TRIP = (1 << 3), // 0x08
INT_SLIDE_KICK = (1 << 4), // 0x10
INT_FAST_ATTACK_OR_SHELL = (1 << 5), // 0x20
INT_HIT_FROM_ABOVE = (1 << 6), // 0x40
INT_HIT_FROM_BELOW = (1 << 7), // 0x80
};
#define INT_ATTACK_NOT_FROM_BELOW \
(INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK \
| INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)
#define INT_ANY_ATTACK \
(INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK \
| INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)
#define INT_ATTACK_NOT_WEAK_FROM_ABOVE \
(INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)
#define INT_ATTACK_SLIDE \
(INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)
u8 sDelayInvincTimer;
s16 gInteractionInvulnerable;
u32 interact_coin(struct MarioState *, u32, struct Object *);
@ -208,7 +183,7 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o
}
if (interaction == 0 && action & ACT_FLAG_ATTACKING) {
if (action == ACT_PUNCHING || action == ACT_MOVE_PUNCHING || action == ACT_JUMP_KICK) {
if (m->flags & (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING)) {
s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1];
if (m->flags & MARIO_PUNCHING) {
@ -230,17 +205,29 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o
}
}
} else if (action == ACT_GROUND_POUND || action == ACT_TWIRLING) {
} else if (action == ACT_GROUND_POUND) {
if (m->vel[1] < 0.0f) {
interaction = INT_GROUND_POUND_OR_TWIRL;
interaction = INT_GROUND_POUND;
}
} else if (action == ACT_GROUND_POUND_LAND || action == ACT_TWIRL_LAND) {
} else if (action == ACT_TWIRLING) {
if (m->vel[1] < 0.0f) {
interaction = INT_TWIRL;
}
} else if (action == ACT_GROUND_POUND_LAND) {
// Neither ground pounding nor twirling change Mario's vertical speed on landing.,
// so the speed check is nearly always true (perhaps not if you land while going upwards?)
// Additionally, actionState it set on each first thing in their action, so this is
// only true prior to the very first frame (i.e. active 1 frame prior to it run).
if (m->vel[1] < 0.0f && m->actionState == 0) {
interaction = INT_GROUND_POUND_OR_TWIRL;
interaction = INT_GROUND_POUND;
}
} else if (action == ACT_TWIRL_LAND) {
// Neither ground pounding nor twirling change Mario's vertical speed on landing.,
// so the speed check is nearly always true (perhaps not if you land while going upwards?)
// Additionally, actionState it set on each first thing in their action, so this is
// only true prior to the very first frame (i.e. active 1 frame prior to it run).
if (m->vel[1] < 0.0f && m->actionState == 0) {
interaction = INT_TWIRL;
}
} else if (action == ACT_SLIDE_KICK || action == ACT_SLIDE_KICK_SLIDE) {
interaction = INT_SLIDE_KICK;
@ -284,6 +271,8 @@ u32 attack_object(struct Object *o, s32 interaction) {
u32 attackType = 0;
switch (interaction) {
case INT_GROUND_POUND:
case INT_TWIRL:
case INT_GROUND_POUND_OR_TWIRL:
attackType = ATTACK_GROUND_POUND_OR_TWIRL;
break;

View file

@ -40,6 +40,24 @@ enum InteractionType {
INTERACT_PLAYER = /* 0x80000000 */ (1 << 31),
};
enum InteractionFlag {
INT_GROUND_POUND = /* 0x00000001 */ (1 << 0),
INT_PUNCH = /* 0x00000002 */ (1 << 1),
INT_KICK = /* 0x00000004 */ (1 << 2),
INT_TRIP = /* 0x00000008 */ (1 << 3),
INT_SLIDE_KICK = /* 0x00000010 */ (1 << 4),
INT_FAST_ATTACK_OR_SHELL = /* 0x00000020 */ (1 << 5),
INT_HIT_FROM_ABOVE = /* 0x00000040 */ (1 << 6),
INT_HIT_FROM_BELOW = /* 0x00000080 */ (1 << 7),
INT_TWIRL = /* 0x00000100 */ (1 << 8),
INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL),
};
#define INT_ATTACK_NOT_FROM_BELOW (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)
#define INT_ANY_ATTACK (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)
#define INT_ATTACK_NOT_WEAK_FROM_ABOVE (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)
#define INT_ATTACK_SLIDE (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)
// INTERACT_WARP
#define INT_SUBTYPE_FADING_WARP 0x00000001
@ -119,5 +137,6 @@ void mario_handle_special_floors(struct MarioState *m);
u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* victim);
u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o);
u32 interact_damage(struct MarioState *m, UNUSED u32 interactType, struct Object *o);
u32 determine_interaction(struct MarioState *m, struct Object *o);
#endif // INTERACTION_H

View file

@ -1874,6 +1874,10 @@ s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum) {
return hookUseActSelect;
}
if (gLevelValues.disableActs) {
return 0;
}
if (gCurrCourseNum > COURSE_STAGES_MAX || warpCheckpointActive) {
return 0;
}

View file

@ -2534,7 +2534,7 @@ s32 cur_obj_is_mario_ground_pounding_platform(void) {
if (!is_player_active(&gMarioStates[i])) { continue; }
if (!gMarioStates[i].marioObj) { continue; }
if (gMarioStates[i].marioObj->platform == o) {
if (gMarioStates[i].action == ACT_GROUND_POUND_LAND) {
if (determine_interaction(&gMarioStates[i], o) & INT_GROUND_POUND) {
return TRUE;
}
}

View file

@ -214,7 +214,7 @@ void play_infinite_stairs_music(void) {
if (shouldPlay) {
play_secondary_music(SEQ_EVENT_ENDLESS_STAIRS, 0, 255, 1000);
} else {
func_80321080(500);
stop_secondary_music(500);
}
}
}
@ -241,7 +241,7 @@ void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer) {
* Called from threads: thread3_main, thread5_game_loop
*/
void fadeout_music(s16 fadeOutTime) {
func_803210D4(fadeOutTime);
set_audio_fadeout(fadeOutTime);
sCurrentMusic = MUSIC_NONE;
sCurrentShellMusic = MUSIC_NONE;
sCurrentCapMusic = MUSIC_NONE;

View file

@ -10,6 +10,7 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n"
" end\n"
"}\n"
"\n"
"_CPointer = {\n"
" __index = function (t,k)\n"
" return nil\n"
@ -23,6 +24,7 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n"
" end\n"
"}\n"
"\n"
"_SyncTable = {\n"
" __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n"
@ -34,6 +36,7 @@ char gSmluaConstants[] = ""
" _set_sync_table_field(t, k, v)\n"
" end\n"
"}\n"
"\n"
"_ReadOnlyTable = {\n"
" __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n"
@ -42,6 +45,7 @@ char gSmluaConstants[] = ""
" __newindex = function (t,k,v)\n"
" end\n"
"}\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param src Vec3f\n"
"--- @return Vec3f\n"
@ -51,6 +55,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param x number\n"
"--- @param y number\n"
@ -62,6 +67,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param a Vec3f\n"
"--- @return Vec3f\n"
@ -71,6 +77,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param a Vec3f\n"
"--- @param b Vec3f\n"
@ -81,6 +88,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @param a number\n"
"--- @return Vec3f\n"
@ -90,6 +98,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3f\n"
"--- @return Vec3f\n"
"function vec3f_normalize(dest)\n"
@ -97,23 +106,28 @@ char gSmluaConstants[] = ""
" if divisor == 0 then\n"
" return dest\n"
" end\n"
"\n"
" local invsqrt = 1.0 / divisor\n"
" dest.x = dest.x * invsqrt\n"
" dest.y = dest.y * invsqrt\n"
" dest.z = dest.z * invsqrt\n"
"\n"
" return dest\n"
"end\n"
"\n"
"--- @param a Vec3f\n"
"--- @return number\n"
"function vec3f_length(a)\n"
" return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n"
"end\n"
"\n"
"--- @param a Vec3f\n"
"--- @param b Vec3f\n"
"--- @return number\n"
"function vec3f_dot(a, b)\n"
" return a.x * b.x + a.y * b.y + a.z * b.z\n"
"end\n"
"\n"
"--- @param vec Vec3f\n"
"--- @param onto Vec3f\n"
"--- @return Vec3f\n"
@ -125,6 +139,7 @@ char gSmluaConstants[] = ""
" vec3f_mul(out, numerator / denominator)\n"
" return out\n"
"end\n"
"\n"
"--- @param v1 Vec3f\n"
"--- @param v2 Vec3f\n"
"--- @return number\n"
@ -134,6 +149,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param src Vec3s\n"
"--- @return Vec3s\n"
@ -143,6 +159,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param x number\n"
"--- @param y number\n"
@ -154,6 +171,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param a Vec3s\n"
"--- @return Vec3s\n"
@ -163,6 +181,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param a Vec3s\n"
"--- @param b Vec3s\n"
@ -173,6 +192,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n"
" return dest\n"
"end\n"
"\n"
"--- @param dest Vec3s\n"
"--- @param a number\n"
"--- @return Vec3s\n"
@ -182,6 +202,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n"
" return dest\n"
"end\n"
"\n"
"--- @param v1 Vec3s\n"
"--- @param v2 Vec3s\n"
"--- @return number\n"
@ -191,6 +212,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n"
"\n"
"--- @param current number\n"
"--- @param target number\n"
"--- @param inc number\n"
@ -210,6 +232,7 @@ char gSmluaConstants[] = ""
" end\n"
" return current;\n"
"end\n"
"\n"
"--- @param current number\n"
"--- @param target number\n"
"--- @param inc number\n"
@ -227,6 +250,7 @@ char gSmluaConstants[] = ""
" current = target\n"
" end\n"
" end\n"
"\n"
" -- keep within 32 bits\n"
" if current > 2147483647 then\n"
" current = -2147483648 + (current - 2147483647)\n"
@ -235,6 +259,7 @@ char gSmluaConstants[] = ""
" end\n"
" return current;\n"
"end\n"
"\n"
"--- @param bank number\n"
"--- @param soundID number\n"
"--- @param priority number\n"
@ -244,9 +269,11 @@ char gSmluaConstants[] = ""
" if flags == nil then flags = 0 end\n"
" return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n"
"end\n"
"\n"
"-------------\n"
"-- courses --\n"
"-------------\n"
"\n"
"--- @type integer\n"
"COURSE_NONE = 0\n"
"--- @type integer\n"
@ -1344,18 +1371,6 @@ char gSmluaConstants[] = ""
"GEO_CONTEXT_AREA_LOAD = 3\n"
"GEO_CONTEXT_AREA_INIT = 4\n"
"GEO_CONTEXT_HELD_OBJ = 5\n"
"INT_GROUND_POUND_OR_TWIRL = (1 << 0)\n"
"INT_PUNCH = (1 << 1)\n"
"INT_KICK = (1 << 2)\n"
"INT_TRIP = (1 << 3)\n"
"INT_SLIDE_KICK = (1 << 4)\n"
"INT_FAST_ATTACK_OR_SHELL = (1 << 5)\n"
"INT_HIT_FROM_ABOVE = (1 << 6)\n"
"INT_HIT_FROM_BELOW = (1 << 7)\n"
"INT_ATTACK_NOT_FROM_BELOW = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)\n"
"INT_ANY_ATTACK = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)\n"
"INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)\n"
"INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)\n"
"INTERACT_HOOT = (1 << 0)\n"
"INTERACT_GRABBABLE = (1 << 1)\n"
"INTERACT_DOOR = (1 << 2)\n"
@ -1388,6 +1403,20 @@ char gSmluaConstants[] = ""
"INTERACT_SHOCK = (1 << 29)\n"
"INTERACT_IGLOO_BARRIER = (1 << 30)\n"
"INTERACT_PLAYER = (1 << 31)\n"
"INT_GROUND_POUND = (1 << 0)\n"
"INT_PUNCH = (1 << 1)\n"
"INT_KICK = (1 << 2)\n"
"INT_TRIP = (1 << 3)\n"
"INT_SLIDE_KICK = (1 << 4)\n"
"INT_FAST_ATTACK_OR_SHELL = (1 << 5)\n"
"INT_HIT_FROM_ABOVE = (1 << 6)\n"
"INT_HIT_FROM_BELOW = (1 << 7)\n"
"INT_TWIRL = (1 << 8)\n"
"INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL)\n"
"INT_ATTACK_NOT_FROM_BELOW = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)\n"
"INT_ANY_ATTACK = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)\n"
"INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)\n"
"INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)\n"
"INT_SUBTYPE_FADING_WARP = 0x00000001\n"
"INT_SUBTYPE_DELAY_INVINCIBILITY = 0x00000002\n"
"INT_SUBTYPE_BIG_KNOCKBACK = 0x00000008\n"
@ -2658,6 +2687,7 @@ char gSmluaConstants[] = ""
"ACT_FLAG_WATER_OR_TEXT = (1 << 29)\n"
"ACT_FLAG_CUSTOM_ACTION = (1 << 30)\n"
"ACT_FLAG_THROWING = (1 << 31)\n"
"ACT_FLAG_FLYING = (ACT_FLAG_AIR | ACT_FLAG_DIVING | ACT_FLAG_ATTACKING | ACT_FLAG_SWIMMING_OR_FLYING)\n"
"ACT_UNINITIALIZED = 0x00000000\n"
"ACT_IDLE = 0x0C400201\n"
"ACT_START_SLEEPING = 0x0C400202\n"

View file

@ -12299,6 +12299,23 @@ int smlua_func_seq_player_unlower_volume(lua_State* L) {
return 1;
}
int smlua_func_set_audio_fadeout(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_audio_fadeout", 1, top);
return 0;
}
u16 fadeOutTime = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_audio_fadeout"); return 0; }
set_audio_fadeout(fadeOutTime);
return 1;
}
int smlua_func_sound_banks_disable(lua_State* L) {
if (L == NULL) { return 0; }
@ -12354,6 +12371,23 @@ int smlua_func_stop_background_music(lua_State* L) {
return 1;
}
int smlua_func_stop_secondary_music(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "stop_secondary_music", 1, top);
return 0;
}
u16 fadeTimer = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "stop_secondary_music"); return 0; }
stop_secondary_music(fadeTimer);
return 1;
}
int smlua_func_stop_sound(lua_State* L) {
if (L == NULL) { return 0; }
@ -12425,6 +12459,25 @@ int smlua_func_stop_sounds_in_continuous_banks(UNUSED lua_State* L) {
// interaction.h //
///////////////////
int smlua_func_determine_interaction(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 2) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "determine_interaction", 2, top);
return 0;
}
struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "determine_interaction"); return 0; }
struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "determine_interaction"); return 0; }
lua_pushinteger(L, determine_interaction(m, o));
return 1;
}
int smlua_func_does_mario_have_normal_cap_on_head(lua_State* L) {
if (L == NULL) { return 0; }
@ -30155,14 +30208,17 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "seq_player_fade_out", smlua_func_seq_player_fade_out);
smlua_bind_function(L, "seq_player_lower_volume", smlua_func_seq_player_lower_volume);
smlua_bind_function(L, "seq_player_unlower_volume", smlua_func_seq_player_unlower_volume);
smlua_bind_function(L, "set_audio_fadeout", smlua_func_set_audio_fadeout);
smlua_bind_function(L, "sound_banks_disable", smlua_func_sound_banks_disable);
smlua_bind_function(L, "sound_banks_enable", smlua_func_sound_banks_enable);
smlua_bind_function(L, "stop_background_music", smlua_func_stop_background_music);
smlua_bind_function(L, "stop_secondary_music", smlua_func_stop_secondary_music);
smlua_bind_function(L, "stop_sound", smlua_func_stop_sound);
smlua_bind_function(L, "stop_sounds_from_source", smlua_func_stop_sounds_from_source);
smlua_bind_function(L, "stop_sounds_in_continuous_banks", smlua_func_stop_sounds_in_continuous_banks);
// interaction.h
smlua_bind_function(L, "determine_interaction", smlua_func_determine_interaction);
smlua_bind_function(L, "does_mario_have_normal_cap_on_head", smlua_func_does_mario_have_normal_cap_on_head);
smlua_bind_function(L, "get_door_save_file_flag", smlua_func_get_door_save_file_flag);
smlua_bind_function(L, "interact_damage", smlua_func_interact_damage);