From 7627c8511d1a7848cf28fced80dc1b56af37d214 Mon Sep 17 00:00:00 2001 From: CrashOveride95 Date: Tue, 8 Dec 2020 19:28:12 -0500 Subject: [PATCH] Add Rumble support --- Makefile | 12 ++++- README.md | 13 +++-- asm/rom_header.s | 16 ++----- include/PR/region.h | 4 +- include/config.h | 3 ++ include/types.h | 3 +- src/buffers/buffers.c | 3 +- src/buffers/buffers.h | 3 +- src/game/behaviors/capswitch.inc.c | 2 +- .../behaviors/controllable_platform.inc.c | 2 +- src/game/behaviors/exclamation_box.inc.c | 2 +- src/game/behaviors/mushroom_1up.inc.c | 2 +- src/game/behaviors/purple_switch.inc.c | 2 +- src/game/behaviors/star_door.inc.c | 4 +- src/game/behaviors/treasure_chest.inc.c | 2 +- src/game/behaviors/water_pillar.inc.c | 2 +- src/game/behaviors/wdw_water_level.inc.c | 2 +- src/game/game_init.c | 10 ++-- src/game/ingame_menu.c | 2 +- src/game/interaction.c | 28 +++++------ src/game/level_update.c | 6 +-- src/game/main.c | 2 +- src/game/main.h | 8 ++-- src/game/mario.c | 8 ++-- src/game/mario_actions_airborne.c | 48 +++++++++---------- src/game/mario_actions_automatic.c | 14 +++--- src/game/mario_actions_cutscene.c | 16 +++---- src/game/mario_actions_moving.c | 12 ++--- src/game/mario_actions_object.c | 14 +++--- src/game/mario_actions_stationary.c | 4 +- src/game/mario_actions_submerged.c | 6 +-- src/game/rumble_init.c | 3 +- src/game/rumble_init.h | 4 +- src/game/save_file.c | 8 ++-- src/game/sound_init.c | 2 +- src/game/spawn_sound.c | 2 +- src/menu/file_select.c | 48 +++++++++---------- src/menu/level_select_menu.c | 4 +- src/menu/star_select.c | 2 +- 39 files changed, 167 insertions(+), 161 deletions(-) diff --git a/Makefile b/Makefile index a62c42d2..857efefc 100644 --- a/Makefile +++ b/Makefile @@ -209,8 +209,8 @@ endif BUILD_DIR_BASE := build # BUILD_DIR is the location where all build artifacts are placed BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION) -ROM := $(BUILD_DIR)/$(TARGET).z64 -ELF := $(BUILD_DIR)/$(TARGET).elf +ROM := $(BUILD_DIR)/$(TARGET_STRING).z64 +ELF := $(BUILD_DIR)/$(TARGET_STRING).elf LD_SCRIPT := sm64.ld YAY0_DIR := $(BUILD_DIR)/bin SOUND_BIN_DIR := $(BUILD_DIR)/sound @@ -649,12 +649,20 @@ $(GLOBAL_ASM_DEP).$(NON_MATCHING): # Compile C code $(BUILD_DIR)/%.o: %.c $(call print,Compiling:,$<,$@) +ifeq ($(COMPILER),ido) @$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< $(V)$(CC) -c $(CFLAGS) -o $@ $< +else + $(V)$(CC) -c $(CFLAGS) -MMD -MF $(BUILD_DIR)/$*.d -o $@ $< +endif $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c $(call print,Compiling:,$<,$@) +ifeq ($(COMPILER),ido) @$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< $(V)$(CC) -c $(CFLAGS) -o $@ $< +else + $(V)$(CC) -c $(CFLAGS) -MMD -MF $(BUILD_DIR)/$*.d -o $@ $< +endif # Alternate compiler flags needed for matching ifeq ($(COMPILER),ido) diff --git a/README.md b/README.md index bcea8997..4ea76d94 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@ - This repo contains a full decompilation of Super Mario 64 (J), (U), (E), and (SH). - Naming and documentation of the source code and data structures are in progress. -- Efforts to decompile the Shindou ROM steadily advance. -- It will be edited to allow for the usage of the final "N64 OS" library, version ``2.0L`` -- Support for Shindou Rumble Pak code may be included in the future. -- It will be patched with someone2639's shiftable segments patch -- It will have extremely WIP HVQM full motion video support +- It has been edited to allow for the usage of the final "N64 OS" library, version ``2.0L`` +- Shindou Rumble Pak code is on for all regions. +- It has been patched with someone2639's shiftable segments patch +- It will have HVQM full motion video support - Getting UNFLoader (flashcart USB library) to work with the game is in progress. ## FAQ @@ -19,9 +18,9 @@ This puts me at a crossroads of either touching leaked code and requiring GCC, o I went with the latter. -Thanks to "someone2639 on soundcloud xd" for this hacky-ass idea +Thanks to "someone2639" for this hacky-ass idea -Q: Will this allow me to use Rumble/FlashRAM/Transfer Pak/microcode swapping/Other Cool N64 Features? +Q: Will this allow me to use FlashRAM/Transfer Pak/microcode swapping/Other Cool N64 Features? A: Theoretically, all yes. diff --git a/asm/rom_header.s b/asm/rom_header.s index c056acdb..4eeaa07f 100644 --- a/asm/rom_header.s +++ b/asm/rom_header.s @@ -8,16 +8,10 @@ .word entry_point /* Entrypoint */ /* Revision */ -.if VERSION_SH == 1 - .word 0x00001448 -.elseif VERSION_EU == 1 - .word 0x00001446 -.else /* NTSC-U and NTSC-J 1.0 */ - .word 0x00001444 -.endif +.word 0x0000144C -.word 0x4EAA3D0E /* Checksum 1 */ -.word 0x74757C24 /* Checksum 2 */ +.word 0x00000000 /* Checksum 1 */ +.word 0x00000000 /* Checksum 2 */ .word 0x00000000 /* Unknown */ .word 0x00000000 /* Unknown */ .if VERSION_SH == 1 @@ -38,8 +32,4 @@ .ascii "P" /* PAL (Europe) */ .endif -.if VERSION_SH == 1 - .byte 0x03 /* Version (Shindou) */ -.else .byte 0x00 /* Version */ -.endif diff --git a/include/PR/region.h b/include/PR/region.h index 0ac8a253..8df46ba0 100644 --- a/include/PR/region.h +++ b/include/PR/region.h @@ -73,8 +73,8 @@ extern "C" { */ /* Perform alignment on input 's' */ -#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1)) - +//#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1)) +//commented out due to sm64 conflict /*************************************** * diff --git a/include/config.h b/include/config.h index 211a086a..471c6217 100644 --- a/include/config.h +++ b/include/config.h @@ -23,6 +23,9 @@ /// Fixes bug where it shows a star when you grab a key in bowser battle stages #define BUGFIX_STAR_BOWSER_KEY (0 || VERSION_US || VERSION_EU || VERSION_SH) +// Support Rumble Pak +#define ENABLE_RUMBLE (1 || VERSION_SH) + // Screen Size Defines #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 diff --git a/include/types.h b/include/types.h index c6e801e1..1b7152f6 100644 --- a/include/types.h +++ b/include/types.h @@ -6,6 +6,7 @@ #include #include "macros.h" +#include "config.h" // Certain functions are marked as having return values, but do not @@ -30,7 +31,7 @@ struct Controller /*0x12*/ u16 buttonPressed; /*0x14*/ OSContStatus *statusData; /*0x18*/ OSContPad *controllerData; -#ifdef VERSION_SH +#if ENABLE_RUMBLE /*0x1C*/ int port; #endif }; diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c index 72b031bc..527fce94 100644 --- a/src/buffers/buffers.c +++ b/src/buffers/buffers.c @@ -1,6 +1,7 @@ #include #include "buffers.h" +#include "config.h" ALIGNED8 u8 gDecompressionHeap[0xD000]; #if defined(VERSION_EU) @@ -15,7 +16,7 @@ ALIGNED8 u8 gIdleThreadStack[0x800]; ALIGNED8 u8 gThread3Stack[0x2000]; ALIGNED8 u8 gThread4Stack[0x2000]; ALIGNED8 u8 gThread5Stack[0x2000]; -#ifdef VERSION_SH +#if ENABLE_RUMBLE ALIGNED8 u8 gThread6Stack[0x2000]; #endif // 0x400 bytes diff --git a/src/buffers/buffers.h b/src/buffers/buffers.h index b9abbf6b..92c97c93 100644 --- a/src/buffers/buffers.h +++ b/src/buffers/buffers.h @@ -5,6 +5,7 @@ #include "game/save_file.h" #include "game/game_init.h" +#include "config.h" extern u8 gDecompressionHeap[]; @@ -18,7 +19,7 @@ extern u8 gIdleThreadStack[]; extern u8 gThread3Stack[]; extern u8 gThread4Stack[]; extern u8 gThread5Stack[]; -#ifdef VERSION_SH +#if ENABLE_RUMBLE extern u8 gThread6Stack[]; #endif diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index 65ae62d2..3db6dd7c 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -31,7 +31,7 @@ void cap_switch_act_2(void) { cur_obj_shake_screen(SHAKE_POS_SMALL); spawn_mist_particles(); spawn_triangle_break_particles(60, 139, 0.3f, o->oBehParams2ndByte); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif } diff --git a/src/game/behaviors/controllable_platform.inc.c b/src/game/behaviors/controllable_platform.inc.c index 17e8beee..c22fe64d 100644 --- a/src/game/behaviors/controllable_platform.inc.c +++ b/src/game/behaviors/controllable_platform.inc.c @@ -79,7 +79,7 @@ void controllable_platform_hit_wall(s8 sp1B) { D_80331694 = 5; cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(50, 80); #endif } diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index 86486c35..3fb177f0 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -78,7 +78,7 @@ void exclamation_box_act_2(void) { o->oGravity = -8.0f; o->oFloorHeight = o->oPosY; o->oAction = 3; -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif } diff --git a/src/game/behaviors/mushroom_1up.inc.c b/src/game/behaviors/mushroom_1up.inc.c index 1466802d..aac7c98d 100644 --- a/src/game/behaviors/mushroom_1up.inc.c +++ b/src/game/behaviors/mushroom_1up.inc.c @@ -7,7 +7,7 @@ void bhv_1up_interact(void) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); gMarioState->numLives++; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif } diff --git a/src/game/behaviors/purple_switch.inc.c b/src/game/behaviors/purple_switch.inc.c index 912f7c00..a90483aa 100644 --- a/src/game/behaviors/purple_switch.inc.c +++ b/src/game/behaviors/purple_switch.inc.c @@ -32,7 +32,7 @@ void bhv_purple_switch_loop(void) { cur_obj_play_sound_2(SOUND_GENERAL2_PURPLE_SWITCH); o->oAction = PURPLE_SWITCH_TICKING; cur_obj_shake_screen(SHAKE_POS_SMALL); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif } diff --git a/src/game/behaviors/star_door.inc.c b/src/game/behaviors/star_door.inc.c index 2d7dad1f..4ae7bc82 100644 --- a/src/game/behaviors/star_door.inc.c +++ b/src/game/behaviors/star_door.inc.c @@ -22,7 +22,7 @@ void bhv_star_door_loop(void) { case 1: if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) { cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_OPEN); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(35, 30); #endif } @@ -39,7 +39,7 @@ void bhv_star_door_loop(void) { case 3: if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) { cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_CLOSE); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(35, 30); #endif } diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c index 938a7581..34b855e9 100644 --- a/src/game/behaviors/treasure_chest.inc.c +++ b/src/game/behaviors/treasure_chest.inc.c @@ -136,7 +136,7 @@ void bhv_treasure_chest_ship_loop(void) { gEnvironmentRegions[6] = -335; o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers_2(2); #endif } diff --git a/src/game/behaviors/water_pillar.inc.c b/src/game/behaviors/water_pillar.inc.c index 60920c73..bd414724 100644 --- a/src/game/behaviors/water_pillar.inc.c +++ b/src/game/behaviors/water_pillar.inc.c @@ -40,7 +40,7 @@ void water_level_pillar_undrained(void) { (s32) approach_f32_symmetric(gEnvironmentLevels[2], -2450.0f, 5.0f); gEnvironmentLevels[0] = (s32) approach_f32_symmetric(gEnvironmentLevels[0], -2450.0f, 5.0f); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers_2(2); #endif } else diff --git a/src/game/behaviors/wdw_water_level.inc.c b/src/game/behaviors/wdw_water_level.inc.c index 6a8a346b..c077ee2c 100644 --- a/src/game/behaviors/wdw_water_level.inc.c +++ b/src/game/behaviors/wdw_water_level.inc.c @@ -49,7 +49,7 @@ void bhv_water_level_diamond_loop(void) { cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN); // same as above } o->oAngleVelYaw = 0x800; -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers_2(2); #endif } diff --git a/src/game/game_init.c b/src/game/game_init.c index 2c0da171..ed892029 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -495,7 +495,7 @@ void read_controller_inputs(void) { if (gControllerBits) { osRecvMesg(&gSIEventMesgQueue, &D_80339BEC, OS_MESG_BLOCK); osContGetReadData(&gControllerPads[0]); -#ifdef VERSION_SH +#if ENABLE_RUMBLE release_rumble_pak_control(); #endif } @@ -564,7 +564,7 @@ void init_controllers(void) { // into any port in order to play the game. this was probably // so if any of the ports didn't work, you can have controllers // plugged into any of them and it will work. -#ifdef VERSION_SH +#if ENABLE_RUMBLE gControllers[cont].port = port; #endif gControllers[cont].statusData = &gControllerStatuses[port]; @@ -599,11 +599,11 @@ void thread5_game_loop(UNUSED void *arg) { struct LevelCommand *addr; setup_game_memory(); -#ifdef VERSION_SH +#if ENABLE_RUMBLE init_rumble_pak_scheduler_queue(); #endif init_controllers(); -#ifdef VERSION_SH +#if ENABLE_RUMBLE create_thread_6(); #endif save_file_load_all(); @@ -628,7 +628,7 @@ void thread5_game_loop(UNUSED void *arg) { // if any controllers are plugged in, start read the data for when // read_controller_inputs is called later. if (gControllerBits) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE block_until_rumble_pak_free(); #endif osContStartReadData(&gSIEventMesgQueue); diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 8190f88d..9344738d 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -2770,7 +2770,7 @@ void print_hud_course_complete_coins(s16 x, s16 y) { if (gCourseCompleteCoins == 50 || gCourseCompleteCoins == 100 || gCourseCompleteCoins == 150) { play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource); - gMarioState[0].numLives++; + gMarioState->numLives++; } } diff --git a/src/game/interaction.c b/src/game/interaction.c index 1ae0b24e..5dee7891 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -699,7 +699,7 @@ u32 take_damage_from_interact_object(struct MarioState *m) { m->hurtCounter += 4 * damage; -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif set_camera_shake_from_hit(shake); @@ -750,7 +750,7 @@ u32 interact_coin(struct MarioState *m, UNUSED u32 interactType, struct Object * && m->numCoins >= 100) { bhv_spawn_star_no_level_exit(6); } -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (o->oDamageOrCoinValue >= 2) { queue_rumble_data(5, 80); } @@ -773,7 +773,7 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O if (m->health >= 0x100) { mario_stop_riding_and_holding(m); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif @@ -876,7 +876,7 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object * m->interactObj = o; m->usedObj = o; -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (o->collisionData == segmented_to_virtual(warp_pipe_seg3_collision_03009AC8)) { play_sound(SOUND_MENU_ENTER_PIPE, m->marioObj->header.gfx.cameraToObject); queue_rumble_data(15, 80); @@ -1123,7 +1123,7 @@ u32 interact_whirlpool(struct MarioState *m, UNUSED u32 interactType, struct Obj marioObj->oMarioWhirlpoolPosY = m->pos[1] - o->oPosY; play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(30, 60); #endif return set_mario_action(m, ACT_CAUGHT_IN_WHIRLPOOL, 0); @@ -1159,7 +1159,7 @@ u32 interact_flame(struct MarioState *m, UNUSED u32 interactType, struct Object if (!sInvulnerable && !(m->flags & MARIO_METAL_CAP) && !(m->flags & MARIO_VANISH_CAP) && !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif o->oInteractStatus = INT_STATUS_INTERACTED; @@ -1238,7 +1238,7 @@ u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object m->interactObj = o; if (interaction & INT_ATTACK_NOT_FROM_BELOW) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif push_mario_out_of_object(m, o, 5.0f); @@ -1263,7 +1263,7 @@ u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object push_mario_out_of_object(m, o, 5.0f); drop_and_set_mario_action(m, bully_knock_back_mario(m), 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return TRUE; @@ -1282,7 +1282,7 @@ u32 interact_shock(struct MarioState *m, UNUSED u32 interactType, struct Object take_damage_from_interact_object(m); play_sound(SOUND_MARIO_ATTACKED, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(70, 60); #endif @@ -1331,7 +1331,7 @@ u32 interact_hit_from_below(struct MarioState *m, UNUSED u32 interactType, struc } if (interaction & INT_ANY_ATTACK) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif attack_object(o, interaction); @@ -1373,7 +1373,7 @@ u32 interact_bounce_top(struct MarioState *m, UNUSED u32 interactType, struct Ob } if (interaction & INT_ATTACK_NOT_FROM_BELOW) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif attack_object(o, interaction); @@ -1495,7 +1495,7 @@ u32 check_object_grab_mario(struct MarioState *m, UNUSED u32 interactType, struc update_mario_sound_and_camera(m); play_sound(SOUND_MARIO_OOOF, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return set_mario_action(m, ACT_GRABBED, 0); @@ -1546,7 +1546,7 @@ u32 interact_pole(struct MarioState *m, UNUSED u32 interactType, struct Object * marioObj->oMarioPoleYawVel = (s32)(m->forwardVel * 0x100 + 0x1000); #endif reset_mario_pitch(m); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return set_mario_action(m, ACT_GRAB_POLE_FAST, 0); @@ -1568,7 +1568,7 @@ u32 interact_hoot(struct MarioState *m, UNUSED u32 interactType, struct Object * m->interactObj = o; m->usedObj = o; -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif update_mario_sound_and_camera(m); diff --git a/src/game/level_update.c b/src/game/level_update.c index 1be745dc..8f313c3b 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -689,7 +689,7 @@ void initiate_painting_warp(void) { play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); fadeout_music(398); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(80, 70); func_sh_8024C89C(1); #endif @@ -1004,7 +1004,7 @@ s32 play_mode_normal(void) { set_play_mode(PLAY_MODE_CHANGE_AREA); } else if (pressed_pause()) { lower_background_noise(1); -#ifdef VERSION_SH +#if ENABLE_RUMBLE cancel_rumble(); #endif gCameraMovementFlags |= CAM_MOVE_PAUSE_SCREEN; @@ -1217,7 +1217,7 @@ s32 init_level(void) { set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0); } } -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (gCurrDemoInput == NULL) { cancel_rumble(); } diff --git a/src/game/main.c b/src/game/main.c index d7386393..12cc0856 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -254,7 +254,7 @@ void handle_vblank(void) { start_sptask(M_GFXTASK); } } -#ifdef VERSION_SH +#if ENABLE_RUMBLE rumble_thread_update_vi(); #endif diff --git a/src/game/main.h b/src/game/main.h index a3e1e92d..bdc88e07 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -1,6 +1,8 @@ #ifndef MAIN_H #define MAIN_H +#include + struct RumbleData { u8 unk00; u8 unk01; @@ -24,7 +26,7 @@ extern OSThread gIdleThread; extern OSThread gMainThread; extern OSThread gGameLoopThread; extern OSThread gSoundThread; -#ifdef VERSION_SH +#if ENABLE_RUMBLE extern OSThread gRumblePakThread; extern OSPfs gRumblePakPfs; @@ -33,7 +35,7 @@ extern OSPfs gRumblePakPfs; extern OSMesgQueue gPIMesgQueue; extern OSMesgQueue gIntrMesgQueue; extern OSMesgQueue gSPTaskMesgQueue; -#ifdef VERSION_SH +#if ENABLE_RUMBLE extern OSMesgQueue gRumblePakSchedulerMesgQueue; extern OSMesgQueue gRumbleThreadVIMesgQueue; #endif @@ -46,7 +48,7 @@ extern OSIoMesg gDmaIoMesg; extern OSMesg D_80339BEC; extern OSMesgQueue gDmaMesgQueue; extern OSMesgQueue gSIEventMesgQueue; -#ifdef VERSION_SH +#if ENABLE_RUMBLE extern OSMesg gRumblePakSchedulerMesgBuf[1]; extern OSMesg gRumbleThreadVIMesgBuf[1]; diff --git a/src/game/mario.c b/src/game/mario.c index 96df7938..523e51d0 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1495,8 +1495,8 @@ void update_mario_health(struct MarioState *m) { // Play a noise to alert the player when Mario is close to drowning. if (((m->action & ACT_GROUP_MASK) == ACT_GROUP_SUBMERGED) && (m->health < 0x300)) { play_sound(SOUND_MOVING_ALMOST_DROWNING, gGlobalSoundSource); -#ifdef VERSION_SH - if (!gRumblePakTimer) { +#if ENABLE_RUMBLE + if (gRumblePakTimer == 0) { gRumblePakTimer = 36; if (is_rumble_finished_and_queue_empty()) { queue_rumble_data(3, 30); @@ -1677,7 +1677,7 @@ static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capM } } -#ifdef VERSION_SH +#if ENABLE_RUMBLE void func_sh_8025574C(void) { if (gMarioState->particleFlags & PARTICLE_HORIZONTAL_STAR) { queue_rumble_data(5, 80); @@ -1770,7 +1770,7 @@ s32 execute_mario_action(UNUSED struct Object *o) { play_infinite_stairs_music(); gMarioState->marioObj->oInteractStatus = 0; -#ifdef VERSION_SH +#if ENABLE_RUMBLE func_sh_8025574C(); #endif diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 34090a55..f2ea0b90 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -80,7 +80,7 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) { if (m->vel[1] < -55.0f) { if (fallHeight > 3000.0f) { m->hurtCounter += (m->flags & MARIO_CAP_ON_HEAD) ? 16 : 24; -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif set_camera_shake_from_hit(SHAKE_FALL_DAMAGE); @@ -89,7 +89,7 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) { } else if (fallHeight > damageHeight && !mario_floor_is_slippery(m)) { m->hurtCounter += (m->flags & MARIO_CAP_ON_HEAD) ? 8 : 12; m->squishTimer = 30; -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif set_camera_shake_from_hit(SHAKE_FALL_DAMAGE); @@ -133,7 +133,7 @@ s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction) { #endif m->particleFlags |= PARTICLE_MIST_CIRCLE; drop_and_set_mario_action(m, ACT_FEET_STUCK_IN_GROUND, 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return TRUE; @@ -385,7 +385,7 @@ u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, set_mario_animation(m, animation); if (m->forwardVel > 16.0f) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 40); #endif mario_bonk_reflection(m, FALSE); @@ -493,7 +493,7 @@ s32 act_triple_jump(struct MarioState *m) { #endif common_air_action_step(m, ACT_TRIPLE_JUMP_LAND, MARIO_ANIM_TRIPLE_JUMP, 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->action == ACT_TRIPLE_JUMP_LAND) { queue_rumble_data(5, 40); } @@ -509,7 +509,7 @@ s32 act_backflip(struct MarioState *m) { play_mario_sound(m, SOUND_ACTION_TERRAIN_JUMP, SOUND_MARIO_YAH_WAH_HOO); common_air_action_step(m, ACT_BACKFLIP_LAND, MARIO_ANIM_BACKFLIP, 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->action == ACT_BACKFLIP_LAND) { queue_rumble_data(5, 40); } @@ -641,7 +641,7 @@ s32 act_long_jump(struct MarioState *m) { } common_air_action_step(m, ACT_LONG_JUMP_LAND, animation, AIR_STEP_CHECK_LEDGE_GRAB); -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->action == ACT_LONG_JUMP_LAND) { queue_rumble_data(5, 40); } @@ -712,7 +712,7 @@ s32 act_twirling(struct MarioState *m) { } m->marioObj->header.gfx.angle[1] += m->twirlYaw; -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -749,7 +749,7 @@ s32 act_dive(struct MarioState *m) { case AIR_STEP_LANDED: if (should_get_stuck_in_ground(m) && m->faceAngle[0] == -0x2AAA) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif #ifdef VERSION_JP @@ -947,7 +947,7 @@ s32 act_ground_pound(struct MarioState *m) { stepResult = perform_air_step(m, 0); if (stepResult == AIR_STEP_LANDED) { if (should_get_stuck_in_ground(m)) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif #ifdef VERSION_JP @@ -998,7 +998,7 @@ s32 act_burning_jump(struct MarioState *m) { if (m->health < 0x100) { m->health = 0xFF; } -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -1020,7 +1020,7 @@ s32 act_burning_fall(struct MarioState *m) { if (m->health < 0x100) { m->health = 0xFF; } -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -1071,7 +1071,7 @@ s32 act_crazy_box_bounce(struct MarioState *m) { m->heldObj = NULL; set_mario_action(m, ACT_STOMACH_SLIDE, 0); } -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif m->particleFlags |= PARTICLE_MIST_CIRCLE; @@ -1103,7 +1103,7 @@ u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFall break; case AIR_STEP_LANDED: -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->action != ACT_SOFT_BONK) { queue_rumble_data(5, 40); } @@ -1505,7 +1505,7 @@ s32 act_hold_butt_slide_air(struct MarioState *m) { } s32 act_lava_boost(struct MarioState *m) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (!(m->flags & MARIO_MARIO_SOUND_PLAYED)) { play_sound_if_no_flag(m, SOUND_MARIO_ON_FIRE, MARIO_MARIO_SOUND_PLAYED); queue_rumble_data(5, 80); @@ -1529,7 +1529,7 @@ s32 act_lava_boost(struct MarioState *m) { } m->vel[1] = 84.0f; play_sound(SOUND_MARIO_ON_FIRE, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif } else { @@ -1567,7 +1567,7 @@ s32 act_lava_boost(struct MarioState *m) { } m->marioBodyState->eyeState = MARIO_EYES_DEAD; -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -1679,7 +1679,7 @@ s32 act_shot_from_cannon(struct MarioState *m) { set_mario_action(m, ACT_DIVE_SLIDE, 0); m->faceAngle[0] = 0; set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif break; @@ -1713,7 +1713,7 @@ s32 act_shot_from_cannon(struct MarioState *m) { if (m->vel[1] > 0.0f) { m->particleFlags |= PARTICLE_DUST; } -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -1778,7 +1778,7 @@ s32 act_flying(struct MarioState *m) { m->faceAngle[0] = 0; set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 60); #endif break; @@ -1833,7 +1833,7 @@ s32 act_flying(struct MarioState *m) { play_sound(SOUND_MARIO_YAHOO_WAHA_YIPPEE + ((gAudioRandom % 5) << 16), m->marioObj->header.gfx.cameraToObject); #endif -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(50, 40); #endif } @@ -1849,7 +1849,7 @@ s32 act_riding_hoot(struct MarioState *m) { m->usedObj->oHootMarioReleaseTime = gGlobalTimer; play_sound_if_no_flag(m, SOUND_MARIO_UH, MARIO_MARIO_SOUND_PLAYED); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(4, 40); #endif return set_mario_action(m, ACT_FREEFALL, 0); @@ -1907,7 +1907,7 @@ s32 act_flying_triple_jump(struct MarioState *m) { if (is_anim_past_end(m)) { set_mario_animation(m, MARIO_ANIM_FORWARD_SPINNING); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(8, 80); #endif m->actionState = 1; @@ -1970,7 +1970,7 @@ s32 act_vertical_wind(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_FORWARD_SPINNING_FLIP); if (m->marioObj->header.gfx.animInfo.animFrame == 1) { play_sound(SOUND_ACTION_SPIN, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(8, 80); #endif } diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 22690873..d9b75e8b 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -171,7 +171,7 @@ s32 act_holding_pole(struct MarioState *m) { } } play_climbing_sounds(m, 2); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif set_sound_moving_speed(SOUND_BANK_MOVING, marioObj->oMarioPoleYawVel / 0x100 * 2); @@ -385,7 +385,7 @@ void update_hang_stationary(struct MarioState *m) { } s32 act_start_hanging(struct MarioState *m) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->actionTimer++ == 0) { queue_rumble_data(5, 80); } @@ -470,7 +470,7 @@ s32 act_hang_moving(struct MarioState *m) { if (m->marioObj->header.gfx.animInfo.animFrame == 12) { play_sound(SOUND_ACTION_HANGING_STEP, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(1, 30); #endif } @@ -662,7 +662,7 @@ s32 act_grabbed(struct MarioState *m) { m->faceAngle[1] = m->usedObj->oMoveAngleYaw; vec3f_copy(m->pos, m->marioObj->header.gfx.pos); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 60); #endif @@ -744,14 +744,14 @@ s32 act_in_cannon(struct MarioState *m) { m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; set_mario_action(m, ACT_SHOT_FROM_CANNON, 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); #endif m->usedObj->oAction = 2; return FALSE; } else if (m->faceAngle[0] != startFacePitch || m->faceAngle[1] != startFaceYaw) { play_sound(SOUND_MOVING_AIM_CANNON, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers_2(0); #endif } @@ -838,7 +838,7 @@ s32 act_tornado_twirling(struct MarioState *m) { vec3f_copy(m->marioObj->header.gfx.pos, m->pos); vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1] + m->twirlYaw, 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index e2cbbb6b..1e6d7135 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1163,7 +1163,7 @@ s32 act_death_exit(struct MarioState *m) { #else play_sound(SOUND_MARIO_OOOF2, m->marioObj->header.gfx.cameraToObject); #endif -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif m->numLives--; @@ -1198,7 +1198,7 @@ s32 act_falling_death_exit(struct MarioState *m) { #else play_sound(SOUND_MARIO_OOOF2, m->marioObj->header.gfx.cameraToObject); #endif -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif m->numLives--; @@ -1245,7 +1245,7 @@ s32 act_special_death_exit(struct MarioState *m) { } if (launch_mario_until_land(m, ACT_HARD_BACKWARD_GROUND_KB, MARIO_ANIM_BACKWARD_AIR_KB, -24.0f)) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif m->numLives--; @@ -1331,7 +1331,7 @@ s32 act_bbh_enter_spin(struct MarioState *m) { m->flags &= ~MARIO_UNKNOWN_08; if (perform_air_step(m, 0) == AIR_STEP_LANDED) { level_trigger_warp(m, WARP_OP_UNKNOWN_02); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(15, 80); #endif m->actionState = 4; @@ -1399,7 +1399,7 @@ s32 act_teleport_fade_out(struct MarioState *m) { set_mario_animation(m, m->prevAction == ACT_CROUCHING ? MARIO_ANIM_CROUCHING : MARIO_ANIM_FIRST_PERSON); -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->actionTimer == 0) { queue_rumble_data(30, 70); func_sh_8024C89C(2); @@ -1425,7 +1425,7 @@ s32 act_teleport_fade_in(struct MarioState *m) { play_sound_if_no_flag(m, SOUND_ACTION_TELEPORT, MARIO_ACTION_SOUND_PLAYED); set_mario_animation(m, MARIO_ANIM_FIRST_PERSON); -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->actionTimer == 0) { queue_rumble_data(30, 70); func_sh_8024C89C(2); @@ -1518,7 +1518,7 @@ s32 act_squished(struct MarioState *m) { // Both of the 1.8's are really floats, but one of them has to // be written as a double for this to match on -O2. vec3f_set(m->marioObj->header.gfx.scale, 1.8, 0.05f, 1.8f); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(10, 80); #endif m->actionState = 1; @@ -1622,7 +1622,7 @@ void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFra if (animFrame == -1) { play_sound_and_spawn_particles(m, SOUND_ACTION_TERRAIN_STUCK_IN_GROUND, 1); } else if (animFrame == unstuckFrame) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif play_sound_and_spawn_particles(m, SOUND_ACTION_UNSTUCK_FROM_GROUND, 1); diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 8b8e8e1b..1bde8ce7 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -1238,7 +1238,7 @@ s32 act_riding_shell_ground(struct MarioState *m) { } adjust_sound_for_speed(m); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -1344,7 +1344,7 @@ s32 act_burning_ground(struct MarioState *m) { } m->marioBodyState->eyeState = MARIO_EYES_DEAD; -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif return FALSE; @@ -1362,7 +1362,7 @@ void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 vec3f_copy(pos, m->pos); play_sound(SOUND_MOVING_TERRAIN_SLIDE + m->terrainSoundAddend, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif @@ -1488,7 +1488,7 @@ s32 act_crouch_slide(struct MarioState *m) { s32 act_slide_kick_slide(struct MarioState *m) { if (m->input & INPUT_A_PRESSED) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return set_jumping_action(m, ACT_FORWARD_ROLLOUT, 0); @@ -1520,7 +1520,7 @@ s32 act_slide_kick_slide(struct MarioState *m) { s32 stomach_slide_action(struct MarioState *m, u32 stopAction, u32 airAction, s32 animation) { if (m->actionTimer == 5) { if (!(m->input & INPUT_ABOVE_SLIDE) && (m->input & (INPUT_A_PRESSED | INPUT_B_PRESSED))) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return drop_and_set_mario_action( @@ -1556,7 +1556,7 @@ s32 act_hold_stomach_slide(struct MarioState *m) { s32 act_dive_slide(struct MarioState *m) { if (!(m->input & INPUT_ABOVE_SLIDE) && (m->input & (INPUT_A_PRESSED | INPUT_B_PRESSED))) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif return set_mario_action(m, m->forwardVel > 0.0f ? ACT_FORWARD_ROLLOUT : ACT_BACKWARD_ROLLOUT, diff --git a/src/game/mario_actions_object.c b/src/game/mario_actions_object.c index fabc3635..50638024 100644 --- a/src/game/mario_actions_object.c +++ b/src/game/mario_actions_object.c @@ -264,7 +264,7 @@ s32 act_throwing(struct MarioState *m) { mario_throw_held_object(m); play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED); play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(3, 50); #endif } @@ -286,7 +286,7 @@ s32 act_heavy_throw(struct MarioState *m) { mario_drop_held_object(m); play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED); play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(3, 50); #endif } @@ -318,7 +318,7 @@ s32 act_picking_up_bowser(struct MarioState *m) { m->angleVel[1] = 0; m->marioBodyState->grabPos = GRAB_POS_BOWSER; mario_grab_used_object(m); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif play_sound(SOUND_MARIO_HRMM, m->marioObj->header.gfx.cameraToObject); @@ -396,13 +396,13 @@ s32 act_holding_bowser(struct MarioState *m) { // play sound on overflow if (m->angleVel[1] <= -0x100 && spin < m->faceAngle[1]) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(4, 20); #endif play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject); } if (m->angleVel[1] >= 0x100 && spin > m->faceAngle[1]) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(4, 20); #endif play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject); @@ -421,12 +421,12 @@ s32 act_holding_bowser(struct MarioState *m) { s32 act_releasing_bowser(struct MarioState *m) { if (++m->actionTimer == 1) { if (m->actionArg == 0) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 50); #endif mario_throw_held_object(m); } else { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(4, 50); #endif mario_drop_held_object(m); diff --git a/src/game/mario_actions_stationary.c b/src/game/mario_actions_stationary.c index 580d2544..000b8839 100644 --- a/src/game/mario_actions_stationary.c +++ b/src/game/mario_actions_stationary.c @@ -792,14 +792,14 @@ s32 act_shockwave_bounce(struct MarioState *m) { f32 sp18; if (m->marioObj->oInteractStatus & INT_STATUS_HIT_BY_SHOCKWAVE) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(70, 40); #endif return hurt_and_set_mario_action(m, ACT_SHOCKED, 0, 4); } if (m->actionTimer == 0) { -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(70, 40); #endif if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_UNK1) { diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index 2db01580..9f5c5599 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -802,7 +802,7 @@ static s32 act_water_throw(struct MarioState *m) { if (m->actionTimer++ == 5) { mario_throw_held_object(m); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(3, 50); #endif } @@ -978,7 +978,7 @@ static s32 act_water_plunge(struct MarioState *m) { m->particleFlags |= PARTICLE_WATER_SPLASH; m->actionState = 1; -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (m->prevAction & ACT_FLAG_AIR) { queue_rumble_data(5, 80); } @@ -1087,7 +1087,7 @@ static s32 act_caught_in_whirlpool(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_GENERAL_FALL); vec3f_copy(m->marioObj->header.gfx.pos, m->pos); vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0); -#ifdef VERSION_SH +#if ENABLE_RUMBLE reset_rumble_timers(); #endif diff --git a/src/game/rumble_init.c b/src/game/rumble_init.c index effbf0bc..f7629397 100644 --- a/src/game/rumble_init.c +++ b/src/game/rumble_init.c @@ -4,8 +4,9 @@ #include "buffers/buffers.h" #include "main.h" #include "rumble_init.h" +#include "config.h" -#ifdef VERSION_SH +#if ENABLE_RUMBLE OSThread gRumblePakThread; diff --git a/src/game/rumble_init.h b/src/game/rumble_init.h index 67aca829..c421b059 100644 --- a/src/game/rumble_init.h +++ b/src/game/rumble_init.h @@ -1,7 +1,7 @@ #ifndef RUMBLE_INIT_H #define RUMBLE_INIT_H -#ifdef VERSION_SH +#if ENABLE_RUMBLE extern s32 gRumblePakTimer; @@ -18,6 +18,6 @@ void cancel_rumble(void); void create_thread_6(void); void rumble_thread_update_vi(void); -#endif // VERSION_SH +#endif // ENABLE_RUMBLE #endif // RUMBLE_INIT_H diff --git a/src/game/save_file.c b/src/game/save_file.c index 9cc97a5f..02e5bdc8 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -64,12 +64,12 @@ static s32 read_eeprom_data(void *buffer, s32 size) { u32 offset = (u32)((u8 *) buffer - (u8 *) &gSaveBuffer) / 8; do { -#ifdef VERSION_SH +#if ENABLE_RUMBLE block_until_rumble_pak_free(); #endif triesLeft--; status = osEepromLongRead(&gSIEventMesgQueue, offset, buffer, size); -#ifdef VERSION_SH +#if ENABLE_RUMBLE release_rumble_pak_control(); #endif } while (triesLeft > 0 && status != 0); @@ -92,12 +92,12 @@ static s32 write_eeprom_data(void *buffer, s32 size) { u32 offset = (u32)((u8 *) buffer - (u8 *) &gSaveBuffer) >> 3; do { -#ifdef VERSION_SH +#if ENABLE_RUMBLE block_until_rumble_pak_free(); #endif triesLeft--; status = osEepromLongWrite(&gSIEventMesgQueue, offset, buffer, size); -#ifdef VERSION_SH +#if ENABLE_RUMBLE release_rumble_pak_control(); #endif } while (triesLeft > 0 && status != 0); diff --git a/src/game/sound_init.c b/src/game/sound_init.c index 49122920..eb11aa30 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -169,7 +169,7 @@ void play_menu_sounds(s16 soundMenuFlags) { if (soundMenuFlags & 0x100) { play_menu_sounds_extra(20, NULL); } -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (soundMenuFlags & SOUND_MENU_FLAG_LETGOMARIOFACE) { queue_rumble_data(10, 60); } diff --git a/src/game/spawn_sound.c b/src/game/spawn_sound.c index a59767d6..18168b59 100644 --- a/src/game/spawn_sound.c +++ b/src/game/spawn_sound.c @@ -68,7 +68,7 @@ void cur_obj_play_sound_1(s32 soundMagic) { void cur_obj_play_sound_2(s32 soundMagic) { if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) { play_sound(soundMagic, gCurrentObject->header.gfx.cameraToObject); -#ifdef VERSION_SH +#if ENABLE_RUMBLE if (soundMagic == SOUND_OBJ_BOWSER_WALK) { queue_rumble_data(3, 60); } diff --git a/src/menu/file_select.c b/src/menu/file_select.c index c8947978..9437dcc6 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -548,7 +548,7 @@ void exit_score_file_to_score_menu(struct Object *scoreFileButton, s8 scoreButto if (scoreFileButton->oMenuButtonState == MENU_BUTTON_STATE_FULLSCREEN && sCursorClickingTimer == 2) { play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif scoreFileButton->oMenuButtonState = MENU_BUTTON_STATE_SHRINKING; @@ -643,7 +643,7 @@ void check_score_menu_clicked_buttons(struct Object *scoreButton) { if (buttonID == MENU_BUTTON_SCORE_RETURN || buttonID == MENU_BUTTON_SCORE_COPY_FILE || buttonID == MENU_BUTTON_SCORE_ERASE_FILE) { play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN_OUT; @@ -654,7 +654,7 @@ void check_score_menu_clicked_buttons(struct Object *scoreButton) { // If clicked in a existing save file, select it too see it's score if (save_file_exists(buttonID - MENU_BUTTON_SCORE_MIN) == TRUE) { play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_GROWING; @@ -663,7 +663,7 @@ void check_score_menu_clicked_buttons(struct Object *scoreButton) { else { // If clicked in a non-existing save file, play buzz sound play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[buttonID]->oMenuButtonState = @@ -759,7 +759,7 @@ void copy_action_file_button(struct Object *copyButton, s32 copyFileButtonID) { if (save_file_exists(copyFileButtonID - MENU_BUTTON_COPY_MIN) == TRUE) { // If clicked in a existing save file, ask where it wants to copy play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[copyFileButtonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN; @@ -770,7 +770,7 @@ void copy_action_file_button(struct Object *copyButton, s32 copyFileButtonID) { } else { // If clicked in a non-existing save file, play buzz sound play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[copyFileButtonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN_OUT; @@ -785,7 +785,7 @@ void copy_action_file_button(struct Object *copyButton, s32 copyFileButtonID) { if (save_file_exists(copyFileButtonID - MENU_BUTTON_COPY_MIN) == FALSE) { // If clicked in a non-existing save file, copy the file play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif copyButton->oMenuButtonActionPhase = COPY_PHASE_COPY_COMPLETE; @@ -800,7 +800,7 @@ void copy_action_file_button(struct Object *copyButton, s32 copyFileButtonID) { // If clicked in a existing save file, play buzz sound if (MENU_BUTTON_COPY_FILE_A + sSelectedFileIndex == copyFileButtonID) { play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[MENU_BUTTON_COPY_FILE_A + sSelectedFileIndex]->oMenuButtonState = @@ -843,7 +843,7 @@ void check_copy_menu_clicked_buttons(struct Object *copyButton) { || buttonID == MENU_BUTTON_COPY_ERASE_FILE) { if (copyButton->oMenuButtonActionPhase == COPY_PHASE_MAIN) { play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN_OUT; @@ -941,7 +941,7 @@ void erase_action_file_button(struct Object *eraseButton, s32 eraseFileButtonID) if (save_file_exists(eraseFileButtonID - MENU_BUTTON_ERASE_MIN) == TRUE) { // If clicked in a existing save file, ask if it wants to delete it play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[eraseFileButtonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN; @@ -952,7 +952,7 @@ void erase_action_file_button(struct Object *eraseButton, s32 eraseFileButtonID) } else { // If clicked in a non-existing save file, play buzz sound play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[eraseFileButtonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN_OUT; @@ -969,7 +969,7 @@ void erase_action_file_button(struct Object *eraseButton, s32 eraseFileButtonID) // Note: The prompt functions are actually called when the ERASE_MSG_PROMPT // message is displayed with print_erase_menu_prompt play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[MENU_BUTTON_ERASE_MIN + sSelectedFileIndex]->oMenuButtonState = @@ -999,7 +999,7 @@ void check_erase_menu_clicked_buttons(struct Object *eraseButton) { || buttonID == MENU_BUTTON_ERASE_COPY_FILE) { if (eraseButton->oMenuButtonActionPhase == ERASE_PHASE_MAIN) { play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN_OUT; @@ -1094,7 +1094,7 @@ void check_sound_mode_menu_clicked_buttons(struct Object *soundModeButton) { || buttonID == MENU_BUTTON_HEADSET) { if (soundModeButton->oMenuButtonActionPhase == SOUND_MODE_PHASE_MAIN) { play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[buttonID]->oMenuButtonState = MENU_BUTTON_STATE_ZOOM_IN_OUT; @@ -1425,28 +1425,28 @@ void check_main_menu_clicked_buttons(void) { switch (sSelectedButtonID) { case MENU_BUTTON_PLAY_FILE_A: play_sound(SAVE_FILE_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif break; case MENU_BUTTON_PLAY_FILE_B: play_sound(SAVE_FILE_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif break; case MENU_BUTTON_PLAY_FILE_C: play_sound(SAVE_FILE_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif break; case MENU_BUTTON_PLAY_FILE_D: play_sound(SAVE_FILE_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif @@ -1454,28 +1454,28 @@ void check_main_menu_clicked_buttons(void) { // Play sound of the button clicked and render buttons of that menu. case MENU_BUTTON_SCORE: play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif render_score_menu_buttons(sMainMenuButtons[MENU_BUTTON_SCORE]); break; case MENU_BUTTON_COPY: play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif render_copy_menu_buttons(sMainMenuButtons[MENU_BUTTON_COPY]); break; case MENU_BUTTON_ERASE: play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif render_erase_menu_buttons(sMainMenuButtons[MENU_BUTTON_ERASE]); break; case MENU_BUTTON_SOUND_MODE: play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif render_sound_mode_menu_buttons(sMainMenuButtons[MENU_BUTTON_SOUND_MODE]); @@ -2248,7 +2248,7 @@ void print_erase_menu_prompt(s16 x, s16 y) { // ..and is hovering "YES", delete file if (sEraseYesNoHoverState == MENU_ERASE_HOVER_YES) { play_sound(SOUND_MARIO_WAAAOOOW, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[MENU_BUTTON_ERASE]->oMenuButtonActionPhase = ERASE_PHASE_MARIO_ERASED; @@ -2263,7 +2263,7 @@ void print_erase_menu_prompt(s16 x, s16 y) { // ..and is hovering "NO", return back to main phase } else if (sEraseYesNoHoverState == MENU_ERASE_HOVER_NO) { play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(5, 80); #endif sMainMenuButtons[MENU_BUTTON_ERASE_MIN + sSelectedFileIndex]->oMenuButtonState = diff --git a/src/menu/level_select_menu.c b/src/menu/level_select_menu.c index 2b1010b3..22891290 100644 --- a/src/menu/level_select_menu.c +++ b/src/menu/level_select_menu.c @@ -152,7 +152,7 @@ s32 intro_default(void) { if (gPlayer1Controller->buttonPressed & START_BUTTON) { play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif @@ -178,7 +178,7 @@ s32 intro_game_over(void) { if (gPlayer1Controller->buttonPressed & START_BUTTON) { play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource); -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif diff --git a/src/menu/star_select.c b/src/menu/star_select.c index 025dbf24..07610faa 100644 --- a/src/menu/star_select.c +++ b/src/menu/star_select.c @@ -421,7 +421,7 @@ s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused #else play_sound(SOUND_MENU_STAR_SOUND_LETS_A_GO, gGlobalSoundSource); #endif -#ifdef VERSION_SH +#if ENABLE_RUMBLE queue_rumble_data(60, 70); func_sh_8024C89C(1); #endif