diff --git a/Makefile b/Makefile
index 9d6784dd0..c48906cb4 100644
--- a/Makefile
+++ b/Makefile
@@ -235,6 +235,8 @@ else
endif
ifeq ($(TARGET_RPI),1)
+ $(info Compiling for Raspberry Pi)
+ DISCORD_SDK := 0
machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
# Raspberry Pi B+, Zero, etc
@@ -244,6 +246,7 @@ ifeq ($(TARGET_RPI),1)
# Raspberry Pi 2 and 3 in ARM 32bit mode
ifneq (,$(findstring armv7l,$(machine)))
+ $(info ARM 32bit mode)
model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown')
ifneq (,$(findstring 3,$(model)))
OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3
@@ -255,6 +258,7 @@ ifeq ($(TARGET_RPI),1)
# RPi3 or RPi4, in ARM64 (aarch64) mode. NEEDS TESTING 32BIT.
# DO NOT pass -mfpu stuff here, thats for 32bit ARM only and will fail for 64bit ARM.
ifneq (,$(findstring aarch64,$(machine)))
+ $(info ARM64 mode)
model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown')
ifneq (,$(findstring 3,$(model)))
OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -O3
@@ -347,11 +351,6 @@ ifeq ($(HEADLESS),1)
CONTROLLER_API :=
endif
-ifeq ($(TARGET_RPI),1)
- $(info Compiling for Raspberry Pi)
- DISCORD_SDK := 0
-endif
-
# NON_MATCHING - whether to build a matching, identical copy of the ROM
# 1 - enable some alternate, more portable code that does not produce a matching ROM
# 0 - build a matching ROM
@@ -626,7 +625,11 @@ else ifeq ($(OSX_BUILD),1)
# This really shouldn't be required, but I got tired of trying to do it the "right way"
BASS_LIBS := lib/bass/bass.dylib lib/bass/libbass.dylib lib/bass/bass_fx.dylib lib/bass/libbass_fx.dylib
else ifeq ($(TARGET_RPI),1)
- BASS_LIBS := lib/bass/arm/libbass.so lib/bass/arm/libbass_fx.so
+ ifneq (,$(findstring aarch64,$(machine)))
+ BASS_LIBS := lib/bass/arm/aarch64/libbass.so lib/bass/arm/aarch64/libbass_fx.so
+ else
+ BASS_LIBS := lib/bass/arm/libbass.so lib/bass/arm/libbass_fx.so
+ endif
else
BASS_LIBS := lib/bass/libbass.so lib/bass/libbass_fx.so
endif
@@ -922,7 +925,11 @@ ifeq ($(WINDOWS_BUILD),1)
else ifeq ($(OSX_BUILD),1)
LDFLAGS += -L./lib/lua/mac/ -l lua53
else ifeq ($(TARGET_RPI),1)
- LDFLAGS += -Llib/lua/linux -l:liblua53-arm.a
+ ifneq (,$(findstring aarch64,$(machine)))
+ LDFLAGS += -Llib/lua/linux -l:liblua53-arm64.a
+ else
+ LDFLAGS += -Llib/lua/linux -l:liblua53-arm.a
+ endif
else
LDFLAGS += -Llib/lua/linux -l:liblua53.a
endif
diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua
index e8a18632d..28f750976 100644
--- a/autogen/lua_definitions/constants.lua
+++ b/autogen/lua_definitions/constants.lua
@@ -7937,7 +7937,10 @@ HOOK_ON_PACKET_RECEIVE = 22
HOOK_USE_ACT_SELECT = 23
--- @type LuaHookedEventType
-HOOK_MAX = 24
+HOOK_ON_CHANGE_CAMERA_ANGLE = 24
+
+--- @type LuaHookedEventType
+HOOK_MAX = 25
--- @class HudDisplayFlags
diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua
index 7d6620b9a..d4ab82b34 100644
--- a/autogen/lua_definitions/functions.lua
+++ b/autogen/lua_definitions/functions.lua
@@ -3023,6 +3023,11 @@ function camera_set_use_course_specific_settings(enable)
-- ...
end
+--- @return nil
+function center_rom_hack_camera()
+ -- ...
+end
+
--- @param from Vec3f
--- @param to Vec3f
--- @param maxPitch integer
@@ -7720,6 +7725,11 @@ function get_hand_foot_pos_z(m, index)
-- ...
end
+--- @return integer
+function get_last_star_or_key()
+ -- ...
+end
+
--- @return integer
function get_network_area_timer()
-- ...
@@ -7806,6 +7816,12 @@ function set_environment_region(index, value)
-- ...
end
+--- @param value integer
+--- @return nil
+function set_last_star_or_key(value)
+ -- ...
+end
+
--- @param far number
--- @return nil
function set_override_far(far)
diff --git a/docs/lua/constants.md b/docs/lua/constants.md
index 3f9747fd9..0a899cf48 100644
--- a/docs/lua/constants.md
+++ b/docs/lua/constants.md
@@ -2803,7 +2803,8 @@
| HOOK_ON_DEATH | 21 |
| HOOK_ON_PACKET_RECEIVE | 22 |
| HOOK_USE_ACT_SELECT | 23 |
-| HOOK_MAX | 24 |
+| HOOK_ON_CHANGE_CAMERA_ANGLE | 24 |
+| HOOK_MAX | 25 |
[:arrow_up_small:](#)
diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md
index 754b81eb0..d24db7f95 100644
--- a/docs/lua/functions-3.md
+++ b/docs/lua/functions-3.md
@@ -378,6 +378,24 @@
+## [center_rom_hack_camera](#center_rom_hack_camera)
+
+### Lua Example
+`center_rom_hack_camera()`
+
+### Parameters
+- None
+
+### Returns
+- None
+
+### C Prototype
+`void center_rom_hack_camera(void);`
+
+[:arrow_up_small:](#)
+
+
+
## [clamp_pitch](#clamp_pitch)
### Lua Example
diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md
index 55f559911..9d7937aa4 100644
--- a/docs/lua/functions-4.md
+++ b/docs/lua/functions-4.md
@@ -6908,6 +6908,24 @@
+## [get_last_star_or_key](#get_last_star_or_key)
+
+### Lua Example
+`local integerValue = get_last_star_or_key()`
+
+### Parameters
+- None
+
+### Returns
+- `integer`
+
+### C Prototype
+`s32 get_last_star_or_key(void);`
+
+[:arrow_up_small:](#)
+
+
+
## [get_network_area_timer](#get_network_area_timer)
### Lua Example
@@ -7171,6 +7189,26 @@
+## [set_last_star_or_key](#set_last_star_or_key)
+
+### Lua Example
+`set_last_star_or_key(value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| value | `integer` |
+
+### Returns
+- None
+
+### C Prototype
+`void set_last_star_or_key(u8 value);`
+
+[:arrow_up_small:](#)
+
+
+
## [set_override_far](#set_override_far)
### Lua Example
diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index 1a0195983..ccb04ddaf 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -615,6 +615,7 @@
- [camera_approach_s16_symmetric_bool](functions-3.md#camera_approach_s16_symmetric_bool)
- [camera_course_processing](functions-3.md#camera_course_processing)
- [camera_set_use_course_specific_settings](functions-3.md#camera_set_use_course_specific_settings)
+ - [center_rom_hack_camera](functions-3.md#center_rom_hack_camera)
- [clamp_pitch](functions-3.md#clamp_pitch)
- [clamp_positions_and_find_yaw](functions-3.md#clamp_positions_and_find_yaw)
- [collide_with_walls](functions-3.md#collide_with_walls)
@@ -1438,6 +1439,7 @@
- [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x)
- [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y)
- [get_hand_foot_pos_z](functions-4.md#get_hand_foot_pos_z)
+ - [get_last_star_or_key](functions-4.md#get_last_star_or_key)
- [get_network_area_timer](functions-4.md#get_network_area_timer)
- [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer)
- [hud_get_value](functions-4.md#hud_get_value)
@@ -1451,6 +1453,7 @@
- [play_transition](functions-4.md#play_transition)
- [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot)
- [set_environment_region](functions-4.md#set_environment_region)
+ - [set_last_star_or_key](functions-4.md#set_last_star_or_key)
- [set_override_far](functions-4.md#set_override_far)
- [set_override_fov](functions-4.md#set_override_fov)
- [set_override_near](functions-4.md#set_override_near)
diff --git a/lib/bass/arm/aarch64/libbass.so b/lib/bass/arm/aarch64/libbass.so
new file mode 100644
index 000000000..aaaac9275
Binary files /dev/null and b/lib/bass/arm/aarch64/libbass.so differ
diff --git a/lib/bass/arm/aarch64/libbass_fx.so b/lib/bass/arm/aarch64/libbass_fx.so
new file mode 100644
index 000000000..45faa9399
Binary files /dev/null and b/lib/bass/arm/aarch64/libbass_fx.so differ
diff --git a/lib/lua/linux/liblua53-arm64.a b/lib/lua/linux/liblua53-arm64.a
new file mode 100644
index 000000000..d2c15bf71
Binary files /dev/null and b/lib/lua/linux/liblua53-arm64.a differ
diff --git a/mods/arena/camera.lua b/mods/arena/camera.lua
index a6994f510..6e61bc6d3 100644
--- a/mods/arena/camera.lua
+++ b/mods/arena/camera.lua
@@ -1,16 +1,10 @@
-
camera_set_use_course_specific_settings(false)
sOverrideCameraModes = {
[CAMERA_MODE_RADIAL] = true,
[CAMERA_MODE_OUTWARD_RADIAL] = true,
- [CAMERA_MODE_BEHIND_MARIO] = true,
[CAMERA_MODE_CLOSE] = true,
- --[CAMERA_MODE_C_UP] = true,
- [CAMERA_MODE_WATER_SURFACE] = true,
[CAMERA_MODE_SLIDE_HOOT] = true,
- --[CAMERA_MODE_INSIDE_CANNON] = true,
- --[CAMERA_MODE_BOSS_FIGHT] = true,
[CAMERA_MODE_PARALLEL_TRACKING] = true,
[CAMERA_MODE_FIXED] = true,
[CAMERA_MODE_8_DIRECTIONS] = true,
@@ -18,8 +12,9 @@ sOverrideCameraModes = {
[CAMERA_MODE_SPIRAL_STAIRS] = true,
}
+local m = gMarioStates[0]
+
function override_camera()
- local m = gMarioStates[0]
local np = gNetworkPlayers[0]
if sOverrideCameraModes[m.area.camera.mode] == nil then
@@ -34,8 +29,6 @@ function override_camera()
end
function on_set_camera_mode(c, mode, frames)
- local m = gMarioStates[0]
-
if mode == CAMERA_MODE_ROM_HACK then
return true
end
@@ -54,3 +47,8 @@ function on_set_camera_mode(c, mode, frames)
end
hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode)
+hook_event(HOOK_UPDATE, function()
+ if (m.controller.buttonPressed & L_TRIG) ~= 0 then
+ center_rom_hack_camera()
+ end
+end)
diff --git a/mods/sm74/camera.lua b/mods/sm74/camera.lua
index 919778d1c..93edb42c4 100644
--- a/mods/sm74/camera.lua
+++ b/mods/sm74/camera.lua
@@ -10,8 +10,9 @@ sOverrideCameraModes = {
[CAMERA_MODE_SPIRAL_STAIRS] = true,
}
+local m = gMarioStates[0]
+
function override_camera()
- local m = gMarioStates[0]
local np = gNetworkPlayers[0]
if sOverrideCameraModes[m.area.camera.mode] == nil then
@@ -26,8 +27,6 @@ function override_camera()
end
function on_set_camera_mode(c, mode, frames)
- local m = gMarioStates[0]
-
if mode == CAMERA_MODE_ROM_HACK then
return true
end
@@ -46,3 +45,8 @@ function on_set_camera_mode(c, mode, frames)
end
hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode)
+hook_event(HOOK_UPDATE, function()
+ if (m.controller.buttonPressed & L_TRIG) ~= 0 then
+ center_rom_hack_camera()
+ end
+end)
diff --git a/mods/star-road/camera.lua b/mods/star-road/camera.lua
index 919778d1c..93edb42c4 100644
--- a/mods/star-road/camera.lua
+++ b/mods/star-road/camera.lua
@@ -10,8 +10,9 @@ sOverrideCameraModes = {
[CAMERA_MODE_SPIRAL_STAIRS] = true,
}
+local m = gMarioStates[0]
+
function override_camera()
- local m = gMarioStates[0]
local np = gNetworkPlayers[0]
if sOverrideCameraModes[m.area.camera.mode] == nil then
@@ -26,8 +27,6 @@ function override_camera()
end
function on_set_camera_mode(c, mode, frames)
- local m = gMarioStates[0]
-
if mode == CAMERA_MODE_ROM_HACK then
return true
end
@@ -46,3 +45,8 @@ function on_set_camera_mode(c, mode, frames)
end
hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode)
+hook_event(HOOK_UPDATE, function()
+ if (m.controller.buttonPressed & L_TRIG) ~= 0 then
+ center_rom_hack_camera()
+ end
+end)
diff --git a/src/game/behaviors/bowser_key.inc.c b/src/game/behaviors/bowser_key.inc.c
index 65a9d2622..2e195b71b 100644
--- a/src/game/behaviors/bowser_key.inc.c
+++ b/src/game/behaviors/bowser_key.inc.c
@@ -45,6 +45,8 @@ void bhv_bowser_key_loop(void) {
} else {
obj_set_hitbox(o, &sBowserKeyHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
+ extern u8 gLastCollectedStarOrKey;
+ gLastCollectedStarOrKey = 1;
mark_obj_for_deletion(o);
o->oInteractStatus = 0;
}
diff --git a/src/game/behaviors/scuttlebug.inc.c b/src/game/behaviors/scuttlebug.inc.c
index 0e43807b4..99c1548c0 100644
--- a/src/game/behaviors/scuttlebug.inc.c
+++ b/src/game/behaviors/scuttlebug.inc.c
@@ -61,7 +61,7 @@ void bhv_scuttlebug_loop(void) {
case 1:
o->oForwardVel = 5.0f;
if (cur_obj_lateral_dist_from_obj_to_home(player) > 1000.0f) {
- //angleToPlayer = angleToPlayer;
+ angleToPlayer = cur_obj_angle_to_home();
} else {
if (o->oScuttlebugUnkF8 == 0) {
o->oScuttlebugUnkFC = 0;
diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c
index 488cbccdb..045fb40ab 100644
--- a/src/game/behaviors/sparkle_spawn_star.inc.c
+++ b/src/game/behaviors/sparkle_spawn_star.inc.c
@@ -35,6 +35,8 @@ void bhv_spawned_star_init(void) {
void set_sparkle_spawn_star_hitbox(void) {
obj_set_hitbox(o, &sSparkleSpawnStarHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
+ extern u8 gLastCollectedStarOrKey;
+ gLastCollectedStarOrKey = 0;
mark_obj_for_deletion(o);
o->oInteractStatus = 0;
}
diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c
index 203e29e09..76f3fab09 100644
--- a/src/game/behaviors/spawn_star.inc.c
+++ b/src/game/behaviors/spawn_star.inc.c
@@ -31,6 +31,8 @@ void bhv_collect_star_loop(void) {
o->oFaceAngleYaw += 0x800;
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
+ extern u8 gLastCollectedStarOrKey;
+ gLastCollectedStarOrKey = 0;
mark_obj_for_deletion(o);
o->oInteractStatus = 0;
}
diff --git a/src/game/camera.c b/src/game/camera.c
index 8171b44d9..ccbcb3b00 100644
--- a/src/game/camera.c
+++ b/src/game/camera.c
@@ -3066,10 +3066,17 @@ void update_camera(struct Camera *c) {
#endif
) {
if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_TRIG) {
+ bool returnValue = true;
if (set_cam_angle(0) == CAM_ANGLE_LAKITU) {
- set_cam_angle(CAM_ANGLE_MARIO);
+ smlua_call_event_hooks_change_camera_angle_params(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_MARIO, &returnValue);
+ if (returnValue) {
+ set_cam_angle(CAM_ANGLE_MARIO);
+ }
} else {
- set_cam_angle(CAM_ANGLE_LAKITU);
+ smlua_call_event_hooks_change_camera_angle_params(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_LAKITU, &returnValue);
+ if (returnValue) {
+ set_cam_angle(CAM_ANGLE_LAKITU);
+ }
}
}
}
@@ -11847,6 +11854,11 @@ void rom_hack_cam_walk(Vec3f pos, Vec3f dir, f32 dist) {
static s16 sRomHackOffset = 0;
+void center_rom_hack_camera(void) {
+ sRomHackYaw = DEGREES(180 + 90) - gMarioStates[0].intendedYaw;
+ sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);
+}
+
/**
* A mode that has 8 camera angles, 45 degrees apart, that is slightly smarter
*/
@@ -11892,12 +11904,6 @@ void mode_rom_hack_camera(struct Camera *c) {
sRomHackZoom = 0;
}
- // center camera
- if (gMarioStates[0].controller->buttonPressed & L_TRIG) {
- sRomHackYaw = DEGREES(180 + 90) - gMarioStates[0].intendedYaw;
- sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);
- }
-
// clamp yaw
sRomHackYaw = (sRomHackYaw / DEGREES(45)) * DEGREES(45);
diff --git a/src/game/camera.h b/src/game/camera.h
index c54720318..c7a02ed23 100644
--- a/src/game/camera.h
+++ b/src/game/camera.h
@@ -785,5 +785,6 @@ s32 set_camera_mode_fixed(struct Camera* c, s16 x, s16 y, s16 z);
void camera_set_use_course_specific_settings(u8 enable);
void rom_hack_cam_set_collisions(u8 enable);
+void center_rom_hack_camera(void);
#endif // CAMERA_H
diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c
index f805375da..df882b762 100644
--- a/src/game/ingame_menu.c
+++ b/src/game/ingame_menu.c
@@ -47,6 +47,7 @@ s16 gCutsceneMsgYOffset;
extern u8 gLastCompletedCourseNum;
extern u8 gLastCompletedStarNum;
+u8 gLastCollectedStarOrKey = 0;
enum DialogBoxState {
DIALOG_STATE_OPENING,
@@ -3111,7 +3112,7 @@ void render_course_complete_lvl_info_and_hud_str(void) {
print_generic_string(63, 167, textCourse);
print_generic_string(CRS_NUM_X3, 167, strCourseNum);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
- } else if (gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) {
+ } else if ((gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS) && gLastCollectedStarOrKey == 1) {
name = segmented_to_virtual(courseNameTbl[gLastCompletedCourseNum - 1]);
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, gDialogTextAlpha);
diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c
index a6a04ec8c..bdbc8a0e4 100644
--- a/src/game/mario_actions_cutscene.c
+++ b/src/game/mario_actions_cutscene.c
@@ -57,6 +57,8 @@ static s8 D_8032CBE4 = 0;
static s8 D_8032CBE8 = 0;
static s8 D_8032CBEC[7] = { 2, 3, 2, 1, 2, 3, 2 };
+extern u8 gLastCollectedStarOrKey;
+
static BehaviorScript* localDialogNPCBehavior = NULL;
/**
@@ -1288,8 +1290,8 @@ s32 act_exit_land_save_dialog(struct MarioState *m) {
if (!(m->flags & MARIO_CAP_ON_HEAD)) {
m->actionState = 2; // star exit without cap
}
- if (gLastCompletedCourseNum == COURSE_BITDW
- || gLastCompletedCourseNum == COURSE_BITFS) {
+ if ((gLastCompletedCourseNum == COURSE_BITDW || gLastCompletedCourseNum == COURSE_BITFS)
+ && gLastCollectedStarOrKey == 1) {
m->actionState = 1; // key exit
}
}
diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c
index 4b9f043db..b549fbaa5 100644
--- a/src/pc/lua/smlua_constants_autogen.c
+++ b/src/pc/lua/smlua_constants_autogen.c
@@ -2822,7 +2822,8 @@ char gSmluaConstants[] = ""
"HOOK_ON_DEATH = 21\n"
"HOOK_ON_PACKET_RECEIVE = 22\n"
"HOOK_USE_ACT_SELECT = 23\n"
-"HOOK_MAX = 24\n"
+"HOOK_ON_CHANGE_CAMERA_ANGLE = 24\n"
+"HOOK_MAX = 25\n"
"ACTION_HOOK_EVERY_FRAME = 0\n"
"ACTION_HOOK_GRAVITY = 1\n"
"ACTION_HOOK_MAX = 2\n"
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index 73b5a1a91..7583b8a3b 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -5786,6 +5786,15 @@ int smlua_func_camera_set_use_course_specific_settings(lua_State* L) {
return 1;
}
+int smlua_func_center_rom_hack_camera(UNUSED lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
+
+
+ center_rom_hack_camera();
+
+ return 1;
+}
+
int smlua_func_clamp_pitch(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
@@ -16991,6 +17000,15 @@ int smlua_func_get_hand_foot_pos_z(lua_State* L) {
return 1;
}
+int smlua_func_get_last_star_or_key(UNUSED lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
+
+
+ lua_pushinteger(L, get_last_star_or_key());
+
+ return 1;
+}
+
int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
@@ -17150,6 +17168,17 @@ int smlua_func_set_environment_region(lua_State* L) {
return 1;
}
+int smlua_func_set_last_star_or_key(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ u8 value = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'set_last_star_or_key'"); return 0; }
+
+ set_last_star_or_key(value);
+
+ return 1;
+}
+
int smlua_func_set_override_far(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
@@ -18695,6 +18724,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "camera_approach_s16_symmetric_bool", smlua_func_camera_approach_s16_symmetric_bool);
smlua_bind_function(L, "camera_course_processing", smlua_func_camera_course_processing);
smlua_bind_function(L, "camera_set_use_course_specific_settings", smlua_func_camera_set_use_course_specific_settings);
+ smlua_bind_function(L, "center_rom_hack_camera", smlua_func_center_rom_hack_camera);
smlua_bind_function(L, "clamp_pitch", smlua_func_clamp_pitch);
smlua_bind_function(L, "clamp_positions_and_find_yaw", smlua_func_clamp_positions_and_find_yaw);
smlua_bind_function(L, "collide_with_walls", smlua_func_collide_with_walls);
@@ -19515,6 +19545,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);
smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z);
+ smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key);
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
@@ -19528,6 +19559,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "play_transition", smlua_func_play_transition);
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
+ smlua_bind_function(L, "set_last_star_or_key", smlua_func_set_last_star_or_key);
smlua_bind_function(L, "set_override_far", smlua_func_set_override_far);
smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov);
smlua_bind_function(L, "set_override_near", smlua_func_set_override_near);
diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c
index e20f69c8c..e04aa5cc6 100644
--- a/src/pc/lua/smlua_hooks.c
+++ b/src/pc/lua/smlua_hooks.c
@@ -477,6 +477,35 @@ void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookT
}
}
+void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType hookType, s16 mode, bool* returnValue) {
+ lua_State* L = gLuaState;
+ if (L == NULL) { return; }
+ *returnValue = true;
+
+ struct LuaHookedEvent* hook = &sHookedEvents[hookType];
+ for (int i = 0; i < hook->count; i++) {
+ s32 prevTop = lua_gettop(L);
+
+ // push the callback onto the stack
+ lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
+
+ // push params
+ lua_pushinteger(L, mode);
+
+ // call the callback
+ if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i])) {
+ LOG_LUA("Failed to call the callback: %u", hookType);
+ continue;
+ }
+
+ // output the return value
+ if (lua_type(L, -1) == LUA_TBOOLEAN) {
+ *returnValue = smlua_to_boolean(L, -1);
+ }
+ lua_settop(L, prevTop);
+ }
+}
+
void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex) {
lua_State* L = gLuaState;
if (L == NULL) { return; }
diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h
index 07e26c329..a006f6d36 100644
--- a/src/pc/lua/smlua_hooks.h
+++ b/src/pc/lua/smlua_hooks.h
@@ -35,6 +35,7 @@ enum LuaHookedEventType {
HOOK_ON_DEATH,
HOOK_ON_PACKET_RECEIVE,
HOOK_USE_ACT_SELECT,
+ HOOK_ON_CHANGE_CAMERA_ANGLE,
HOOK_MAX,
};
@@ -63,6 +64,7 @@ static const char* LuaHookedEventTypeName[] = {
"HOOK_ON_DEATH",
"HOOK_ON_PACKET_RECEIVE",
"HOOK_USE_ACT_SELECT",
+ "HOOK_ON_CHANGE_CAMERA_ANGLE",
"HOOK_MAX"
};
@@ -94,6 +96,7 @@ void smlua_call_event_hooks_interact_params_ret_bool(enum LuaHookedEventType hoo
void smlua_call_event_hooks_object_param(enum LuaHookedEventType hookType, struct Object* obj);
bool smlua_call_event_hooks_ret_int(enum LuaHookedEventType hookType, s32* returnValue);
void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookType, struct Camera *c, s16 mode, s16 frames, bool* returnValue);
+void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType hookType, s16 mode, bool* returnValue);
void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex);
void smlua_call_event_hooks_use_act_select(enum LuaHookedEventType hookType, int value, bool* foundHook, bool* returnValue);
diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c
index 1cd8ef405..eadb1f203 100644
--- a/src/pc/lua/utils/smlua_misc_utils.c
+++ b/src/pc/lua/utils/smlua_misc_utils.c
@@ -47,6 +47,15 @@ void hud_show(void) {
gOverrideHideHud = 0;
}
+extern u8 gLastCollectedStarOrKey;
+s32 get_last_star_or_key(void) {
+ return gLastCollectedStarOrKey;
+}
+
+void set_last_star_or_key(u8 value) {
+ gLastCollectedStarOrKey = value;
+}
+
s32 hud_get_value(enum HudDisplayValue type) {
switch (type) {
case HUD_DISPLAY_LIVES: return gHudDisplay.lives;
diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h
index 7615f7f1a..b2ecf1966 100644
--- a/src/pc/lua/utils/smlua_misc_utils.h
+++ b/src/pc/lua/utils/smlua_misc_utils.h
@@ -65,6 +65,8 @@ bool is_game_paused(void);
bool is_transition_playing(void);
s16 get_dialog_id(void);
+s32 get_last_star_or_key(void);
+void set_last_star_or_key(u8 value);
u32 allocate_mario_action(u32 actFlags);
diff --git a/src/pc/network/network.c b/src/pc/network/network.c
index 59debee28..0d9bb6a83 100644
--- a/src/pc/network/network.c
+++ b/src/pc/network/network.c
@@ -19,6 +19,7 @@
#include "pc/mods/mods.h"
#include "pc/crash_handler.h"
#include "pc/debuglog.h"
+#include "game/camera.h"
// fix warnings when including rendering_graph_node
#undef near
@@ -531,6 +532,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) {
extern s16 gChangeLevel;
gChangeLevel = LEVEL_CASTLE_GROUNDS;
network_player_init();
+ camera_set_use_course_specific_settings(true);
free_vtx_scroll_targets();
struct Controller* cnt = gMarioStates[0].controller;