From ce864043c109b72a2cf215717b94dcfa1e3e19fb Mon Sep 17 00:00:00 2001 From: Zerocker Date: Sun, 24 May 2020 23:52:03 +0900 Subject: [PATCH] Enabled rumble for all versions. --- build.sh | 2 +- include/types.h | 2 - src/game/behaviors/capswitch.inc.c | 2 - src/game/behaviors/exclamation_box.inc.c | 2 - src/game/behaviors/purple_switch.inc.c | 2 - src/game/behaviors/star_door.inc.c | 4 -- 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/interaction.c | 40 +++-------------- src/game/level_update.c | 7 +-- src/game/main.c | 15 +++---- src/game/main.h | 8 ++-- src/game/mario.c | 6 --- src/game/mario_actions_airborne.c | 55 ++++-------------------- src/game/mario_actions_automatic.c | 16 ------- src/game/mario_actions_cutscene.c | 16 ------- src/game/mario_actions_moving.c | 27 ++++-------- src/game/mario_actions_object.c | 14 ------ src/game/mario_actions_stationary.c | 4 -- src/game/mario_actions_submerged.c | 10 +---- src/game/save_file.c | 8 ---- src/game/sound_init.c | 3 +- src/game/spawn_sound.c | 3 +- src/game/thread6.c | 52 ++++++---------------- src/game/thread6.h | 6 +-- src/pc/pc_main.c | 10 ++++- 27 files changed, 63 insertions(+), 265 deletions(-) diff --git a/build.sh b/build.sh index d5429ce5..87d3597b 100644 --- a/build.sh +++ b/build.sh @@ -86,7 +86,7 @@ for i in ${!OPTIONS[@]}; do done printf "\n${YELLOW} Executing: ${CYAN}make ${CMDL} -j${RESET}\n\n" -PATH=/mingw32/bin:/mingw64/bin:$PATH make $CMDL -j -d +PATH=/mingw32/bin:/mingw64/bin:$PATH make $CMDL -j if [ "${CMDL}" != " clean" ]; then diff --git a/include/types.h b/include/types.h index 870223eb..48b4fcd0 100644 --- a/include/types.h +++ b/include/types.h @@ -30,9 +30,7 @@ struct Controller /*0x12*/ u16 buttonPressed; /*0x14*/ OSContStatus *statusData; /*0x18*/ OSContPad *controllerData; -#ifdef VERSION_SH /*0x1C*/ int port; -#endif }; typedef f32 Vec2f[2]; diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index 7b8cae57..ab745560 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -31,9 +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 queue_rumble_data(5, 80); -#endif } } else { sp1C = cur_obj_update_dialog_with_cutscene(1, 0x0C, CUTSCENE_CAP_SWITCH_PRESS, 0); diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index 86486c35..8034dd3d 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -78,9 +78,7 @@ void exclamation_box_act_2(void) { o->oGravity = -8.0f; o->oFloorHeight = o->oPosY; o->oAction = 3; -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif } load_object_collision_model(); } diff --git a/src/game/behaviors/purple_switch.inc.c b/src/game/behaviors/purple_switch.inc.c index 3035bd6b..9c210acc 100644 --- a/src/game/behaviors/purple_switch.inc.c +++ b/src/game/behaviors/purple_switch.inc.c @@ -32,9 +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 queue_rumble_data(5, 80); -#endif } break; /** diff --git a/src/game/behaviors/star_door.inc.c b/src/game/behaviors/star_door.inc.c index 2d7dad1f..4390efcb 100644 --- a/src/game/behaviors/star_door.inc.c +++ b/src/game/behaviors/star_door.inc.c @@ -22,9 +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 queue_rumble_data(35, 30); -#endif } cur_obj_become_intangible(); o->oUnkBC = -8.0f; @@ -39,9 +37,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 queue_rumble_data(35, 30); -#endif } o->oUnkBC = 8.0f; star_door_update_pos(); diff --git a/src/game/behaviors/water_pillar.inc.c b/src/game/behaviors/water_pillar.inc.c index 801069ca..498e9bd0 100644 --- a/src/game/behaviors/water_pillar.inc.c +++ b/src/game/behaviors/water_pillar.inc.c @@ -40,9 +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 reset_rumble_timers_2(2); -#endif } else o->oAction++; break; diff --git a/src/game/behaviors/wdw_water_level.inc.c b/src/game/behaviors/wdw_water_level.inc.c index 6a8a346b..63d58fc7 100644 --- a/src/game/behaviors/wdw_water_level.inc.c +++ b/src/game/behaviors/wdw_water_level.inc.c @@ -49,9 +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 reset_rumble_timers_2(2); -#endif } break; case WATER_LEVEL_DIAMOND_ACT_IDLE_SPINNING: diff --git a/src/game/game_init.c b/src/game/game_init.c index ffcf7a18..9afd28a6 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -564,9 +564,7 @@ void init_controllers(void) { // into any port in order to play the game. this was probably // so if any of the ports didnt work, you can have controllers // plugged into any of them and it will work. -#ifdef VERSION_SH gControllers[cont].port = port; -#endif gControllers[cont].statusData = &gControllerStatuses[port]; gControllers[cont++].controllerData = &gControllerPads[port]; } @@ -606,13 +604,9 @@ static struct LevelCommand *levelCommandAddr; void thread5_game_loop(UNUSED void *arg) { setup_game_memory(); -#ifdef VERSION_SH init_rumble_pak_scheduler_queue(); -#endif init_controllers(); -#ifdef VERSION_SH create_thread_6(); -#endif save_file_load_all(); set_vblank_handler(2, &gGameVblankHandler, &gGameVblankQueue, (OSMesg) 1); @@ -638,9 +632,7 @@ void game_loop_one_iteration(void) { // read_controller_inputs is called later. if (gControllerBits) { -#ifdef VERSION_SH - block_until_rumble_pak_free(); -#endif + // block_until_rumble_pak_free(); osContStartReadData(&gSIEventMesgQueue); } diff --git a/src/game/interaction.c b/src/game/interaction.c index b8f3f881..199911fb 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -697,9 +697,7 @@ u32 take_damage_from_interact_object(struct MarioState *m) { m->hurtCounter += 4 * damage; -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif set_camera_shake_from_hit(shake); return damage; } @@ -747,11 +745,10 @@ 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 (o->oDamageOrCoinValue >= 2) { queue_rumble_data(5, 80); } -#endif return FALSE; } @@ -770,9 +767,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 queue_rumble_data(5, 80); -#endif if (!noExit) { m->hurtCounter = 0; @@ -874,7 +869,6 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object * m->interactObj = o; m->usedObj = o; -#ifdef VERSION_SH 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); @@ -882,12 +876,6 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object * play_sound(SOUND_MENU_ENTER_HOLE, m->marioObj->header.gfx.cameraToObject); queue_rumble_data(12, 80); } -#else - play_sound(o->collisionData == segmented_to_virtual(warp_pipe_seg3_collision_03009AC8) - ? SOUND_MENU_ENTER_PIPE - : SOUND_MENU_ENTER_HOLE, - m->marioObj->header.gfx.cameraToObject); -#endif mario_stop_riding_object(m); return set_mario_action(m, ACT_DISAPPEARED, (WARP_OP_WARP_OBJECT << 16) + 2); @@ -1098,9 +1086,8 @@ u32 interact_tornado(struct MarioState *m, UNUSED u32 interactType, struct Objec marioObj->oMarioTornadoPosY = m->pos[1] - o->oPosY; play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH queue_rumble_data(30, 60); -#endif + return set_mario_action(m, ACT_TORNADO_TWIRLING, m->action == ACT_TWIRLING); } @@ -1121,9 +1108,8 @@ 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 queue_rumble_data(30, 60); -#endif + return set_mario_action(m, ACT_CAUGHT_IN_WHIRLPOOL, 0); } @@ -1157,9 +1143,8 @@ 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 queue_rumble_data(5, 80); -#endif + o->oInteractStatus = INT_STATUS_INTERACTED; m->interactObj = o; @@ -1235,9 +1220,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 queue_rumble_data(5, 80); -#endif push_mario_out_of_object(m, o, 5.0f); m->forwardVel = -16.0f; @@ -1260,9 +1243,8 @@ 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 queue_rumble_data(5, 80); -#endif + return TRUE; } @@ -1279,9 +1261,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 queue_rumble_data(70, 60); -#endif if (m->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) { return drop_and_set_mario_action(m, ACT_WATER_SHOCKED, 0); @@ -1327,9 +1307,7 @@ u32 interact_hit_from_below(struct MarioState *m, UNUSED u32 interactType, struc } if (interaction & INT_ANY_ATTACK) { -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif attack_object(o, interaction); bounce_back_from_attack(m, interaction); @@ -1368,9 +1346,7 @@ u32 interact_bounce_top(struct MarioState *m, UNUSED u32 interactType, struct Ob } if (interaction & INT_ATTACK_NOT_FROM_BELOW) { -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif attack_object(o, interaction); bounce_back_from_attack(m, interaction); @@ -1487,9 +1463,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 queue_rumble_data(5, 80); -#endif return set_mario_action(m, ACT_GRABBED, 0); } } @@ -1538,9 +1512,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 queue_rumble_data(5, 80); -#endif return set_mario_action(m, ACT_GRAB_POLE_FAST, 0); } } @@ -1560,9 +1532,7 @@ u32 interact_hoot(struct MarioState *m, UNUSED u32 interactType, struct Object * m->interactObj = o; m->usedObj = o; -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif update_mario_sound_and_camera(m); return set_mario_action(m, ACT_RIDING_HOOT, 0); } diff --git a/src/game/level_update.c b/src/game/level_update.c index 052959c4..bbbebed0 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -687,10 +687,8 @@ void initiate_painting_warp(void) { play_sound(SOUND_MENU_STAR_SOUND, gDefaultSoundArgs); fadeout_music(398); -#ifdef VERSION_SH queue_rumble_data(80, 70); func_sh_8024C89C(1); -#endif } } } @@ -1005,9 +1003,7 @@ s32 play_mode_normal(void) { set_play_mode(PLAY_MODE_CHANGE_AREA); } else if (pressed_pause()) { lower_background_noise(1); -#ifdef VERSION_SH cancel_rumble(); -#endif gCameraMovementFlags |= CAM_MOVE_PAUSE_SCREEN; set_play_mode(PLAY_MODE_PAUSED); } @@ -1225,11 +1221,10 @@ s32 init_level(void) { set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0); } } -#ifdef VERSION_SH + if (gCurrDemoInput == NULL) { cancel_rumble(); } -#endif if (gMarioState->action == ACT_INTRO_CUTSCENE) { sound_banks_disable(2, 0x0330); diff --git a/src/game/main.c b/src/game/main.c index 2d6bf1d9..6f4ad77b 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -25,7 +25,7 @@ OSThread gIdleThread; OSThread gMainThread; OSThread gGameLoopThread; OSThread gSoundThread; -#ifdef VERSION_SH +#ifndef VERSION_SH OSThread gRumblePakThread; s32 gRumblePakPfs; // Actually an OSPfs but we don't have that header yet @@ -38,7 +38,7 @@ OSMesgQueue gSIEventMesgQueue; OSMesgQueue gPIMesgQueue; OSMesgQueue gIntrMesgQueue; OSMesgQueue gSPTaskMesgQueue; -#ifdef VERSION_SH +#ifndef VERSION_SH OSMesgQueue gRumblePakSchedulerMesgQueue; OSMesgQueue gRumbleThreadVIMesgQueue; #endif @@ -47,7 +47,7 @@ OSMesg gPIMesgBuf[32]; OSMesg gSIEventMesgBuf[1]; OSMesg gIntrMesgBuf[16]; OSMesg gUnknownMesgBuf[16]; -#ifdef VERSION_SH +#ifndef VERSION_SH OSMesg gRumblePakSchedulerMesgBuf[1]; OSMesg gRumbleThreadVIMesgBuf[1]; @@ -152,7 +152,7 @@ void create_thread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, osCreateThread(thread, id, entry, arg, sp, pri); } -#ifdef VERSION_SH +#ifndef VERSION_SH extern void func_sh_802F69CC(void); #endif @@ -162,7 +162,7 @@ void handle_nmi_request(void) { func_80320890(); sound_banks_disable(2, 0x037A); fadeout_music(90); -#ifdef VERSION_SH +#ifndef VERSION_SH func_sh_802F69CC(); #endif } @@ -233,7 +233,7 @@ void handle_vblank(void) { stub_main_3(); sNumVblanks++; -#ifdef VERSION_SH +#ifndef VERSION_SH if (gResetTimer > 0 && gResetTimer < 100) { gResetTimer++; } @@ -268,9 +268,8 @@ void handle_vblank(void) { start_sptask(M_GFXTASK); } } -#ifdef VERSION_SH + rumble_thread_update_vi(); -#endif // Notify the game loop about the vblank. if (gVblankHandler1 != NULL) { diff --git a/src/game/main.h b/src/game/main.h index 901b1c0a..e00cee30 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -24,7 +24,7 @@ extern OSThread gIdleThread; extern OSThread gMainThread; extern OSThread gGameLoopThread; extern OSThread gSoundThread; -#ifdef VERSION_SH +#ifndef VERSION_SH extern OSThread gRumblePakThread; extern s32 gRumblePakPfs; // Actually an OSPfs but we don't have that header yet @@ -33,7 +33,7 @@ extern s32 gRumblePakPfs; // Actually an OSPfs but we don't have that header yet extern OSMesgQueue gPIMesgQueue; extern OSMesgQueue gIntrMesgQueue; extern OSMesgQueue gSPTaskMesgQueue; -#ifdef VERSION_SH +#ifndef VERSION_SH extern OSMesgQueue gRumblePakSchedulerMesgQueue; extern OSMesgQueue gRumbleThreadVIMesgQueue; #endif @@ -46,7 +46,7 @@ extern OSIoMesg gDmaIoMesg; extern OSMesg D_80339BEC; extern OSMesgQueue gDmaMesgQueue; extern OSMesgQueue gSIEventMesgQueue; -#ifdef VERSION_SH +#ifndef VERSION_SH extern OSMesg gRumblePakSchedulerMesgBuf[1]; extern OSMesg gRumbleThreadVIMesgBuf[1]; @@ -73,6 +73,6 @@ extern s8 gShowDebugText; extern void set_vblank_handler(s32 a, struct VblankHandler *b, OSMesgQueue *queue, OSMesg *msg); extern void dispatch_audio_sptask(struct SPTask *spTask); extern void send_display_list(struct SPTask *a); -extern void main(void); +// extern void main(void); #endif diff --git a/src/game/mario.c b/src/game/mario.c index e00d6e60..9da30d59 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1534,7 +1534,6 @@ 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, gDefaultSoundArgs); -#ifdef VERSION_SH if (!gRumblePakTimer) { gRumblePakTimer = 36; if (is_rumble_finished_and_queue_empty()) { @@ -1543,7 +1542,6 @@ void update_mario_health(struct MarioState *m) { } } else { gRumblePakTimer = 0; -#endif } } } @@ -1721,7 +1719,6 @@ static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capM } } -#ifdef VERSION_SH void func_sh_8025574C(void) { if (gMarioState->particleFlags & PARTICLE_HORIZONTAL_STAR) { queue_rumble_data(5, 80); @@ -1734,7 +1731,6 @@ void func_sh_8025574C(void) { reset_rumble_timers(); } } -#endif /** * Main function for executing Mario's behavior. @@ -1831,9 +1827,7 @@ s32 execute_mario_action(UNUSED struct Object *o) { play_infinite_stairs_music(); gMarioState->marioObj->oInteractStatus = 0; -#ifdef VERSION_SH func_sh_8025574C(); -#endif return gMarioState->particleFlags; } diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 451035ae..9289fd6c 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -83,18 +83,15 @@ 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 queue_rumble_data(5, 80); -#endif set_camera_shake_from_hit(SHAKE_FALL_DAMAGE); play_sound(SOUND_MARIO_ATTACKED, m->marioObj->header.gfx.cameraToObject); return drop_and_set_mario_action(m, hardFallAction, 4); } 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 + queue_rumble_data(5, 80); -#endif set_camera_shake_from_hit(SHAKE_FALL_DAMAGE); play_sound(SOUND_MARIO_ATTACKED, m->marioObj->header.gfx.cameraToObject); } @@ -136,9 +133,8 @@ 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 + queue_rumble_data(5, 80); -#endif return TRUE; } @@ -388,9 +384,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 queue_rumble_data(5, 40); -#endif mario_bonk_reflection(m, FALSE); m->faceAngle[1] += 0x8000; @@ -496,11 +490,9 @@ 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 (m->action == ACT_TRIPLE_JUMP_LAND) { queue_rumble_data(5, 40); } -#endif play_flip_sounds(m, 2, 8, 20); return FALSE; } @@ -512,11 +504,10 @@ 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 (m->action == ACT_BACKFLIP_LAND) { queue_rumble_data(5, 40); } -#endif play_flip_sounds(m, 2, 3, 17); return FALSE; } @@ -644,11 +635,10 @@ 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 (m->action == ACT_LONG_JUMP_LAND) { queue_rumble_data(5, 40); } -#endif return FALSE; } @@ -749,9 +739,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 queue_rumble_data(5, 80); -#endif #ifdef VERSION_JP play_sound(SOUND_MARIO_OOOF, m->marioObj->header.gfx.cameraToObject); #else @@ -947,9 +935,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 queue_rumble_data(5, 80); -#endif #ifdef VERSION_JP play_sound(SOUND_MARIO_OOOF, m->marioObj->header.gfx.cameraToObject); #else @@ -998,9 +984,8 @@ s32 act_burning_jump(struct MarioState *m) { if (m->health < 0x100) { m->health = 0xFF; } -#ifdef VERSION_SH + reset_rumble_timers(); -#endif return FALSE; } @@ -1020,9 +1005,8 @@ s32 act_burning_fall(struct MarioState *m) { if (m->health < 0x100) { m->health = 0xFF; } -#ifdef VERSION_SH + reset_rumble_timers(); -#endif return FALSE; } @@ -1071,9 +1055,7 @@ s32 act_crazy_box_bounce(struct MarioState *m) { m->heldObj = NULL; set_mario_action(m, ACT_STOMACH_SLIDE, 0); } -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif m->particleFlags |= PARTICLE_MIST_CIRCLE; break; @@ -1103,11 +1085,9 @@ u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFall break; case AIR_STEP_LANDED: -#ifdef VERSION_SH if (m->action == ACT_SOFT_BONK) { queue_rumble_data(5, 80); } -#endif if (!check_fall_damage_or_get_stuck(m, hardFallAction)) { #ifndef VERSION_JP if (m->action == ACT_THROWN_FORWARD || m->action == ACT_THROWN_BACKWARD) { @@ -1506,14 +1486,11 @@ s32 act_hold_butt_slide_air(struct MarioState *m) { } s32 act_lava_boost(struct MarioState *m) { -#ifdef VERSION_SH 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); } -#else play_sound_if_no_flag(m, SOUND_MARIO_ON_FIRE, MARIO_MARIO_SOUND_PLAYED); -#endif if (!(m->input & INPUT_NONZERO_ANALOG)) { m->forwardVel = approach_f32(m->forwardVel, 0.0f, 0.35f, 0.35f); @@ -1530,9 +1507,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 queue_rumble_data(5, 80); -#endif } else { play_mario_heavy_landing_sound(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND); if (m->actionState < 2 && m->vel[1] < 0.0f) { @@ -1568,9 +1543,8 @@ s32 act_lava_boost(struct MarioState *m) { } m->marioBodyState->eyeState = MARIO_EYES_DEAD; -#ifdef VERSION_SH + reset_rumble_timers(); -#endif return FALSE; } @@ -1690,9 +1664,7 @@ s32 act_shot_from_cannon(struct MarioState *m) { gLakituState.mode = CAMERA_MODE_NEWCAM; } #endif -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif break; case AIR_STEP_HIT_WALL: @@ -1734,9 +1706,8 @@ s32 act_shot_from_cannon(struct MarioState *m) { if (m->vel[1] > 0.0f) { m->particleFlags |= PARTICLE_DUST; } -#ifdef VERSION_SH + reset_rumble_timers(); -#endif return FALSE; } @@ -1839,9 +1810,7 @@ s32 act_flying(struct MarioState *m) { gLakituState.mode = CAMERA_MODE_NEWCAM; } #endif -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif break; case AIR_STEP_HIT_WALL: @@ -1904,9 +1873,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 queue_rumble_data(50, 40); -#endif } play_sound(SOUND_MOVING_FLYING, m->marioObj->header.gfx.cameraToObject); @@ -1920,9 +1887,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 queue_rumble_data(4, 40); -#endif return set_mario_action(m, ACT_FREEFALL, 0); } @@ -1988,9 +1953,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 queue_rumble_data(8, 80); -#endif m->actionState = 1; } } @@ -2063,9 +2026,7 @@ s32 act_vertical_wind(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_FORWARD_SPINNING_FLIP); if (m->marioObj->header.gfx.unk38.animFrame == 1) { play_sound(SOUND_ACTION_SPIN, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH queue_rumble_data(8, 80); -#endif } if (is_anim_past_end(m)) { diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index d2a36491..bc94f489 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -171,9 +171,7 @@ s32 act_holding_pole(struct MarioState *m) { } } play_climbing_sounds(m, 2); -#ifdef VERSION_SH reset_rumble_timers(); -#endif func_80320A4C(1, marioObj->oMarioPoleYawVel / 0x100 * 2); } else { marioObj->oMarioPoleYawVel = 0; @@ -385,13 +383,9 @@ void update_hang_stationary(struct MarioState *m) { } s32 act_start_hanging(struct MarioState *m) { -#ifdef VERSION_SH if (m->actionTimer++ == 0) { queue_rumble_data(5, 80); } -#else - m->actionTimer++; -#endif if ((m->input & INPUT_NONZERO_ANALOG) && m->actionTimer >= 31) { return set_mario_action(m, ACT_HANGING, 0); @@ -470,9 +464,7 @@ s32 act_hang_moving(struct MarioState *m) { if (m->marioObj->header.gfx.unk38.animFrame == 12) { play_sound(SOUND_ACTION_HANGING_STEP, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH queue_rumble_data(5, 30); -#endif } if (is_anim_past_end(m)) { @@ -662,9 +654,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 queue_rumble_data(5, 60); -#endif return set_mario_action(m, (m->forwardVel >= 0.0f) ? ACT_THROWN_FORWARD : ACT_THROWN_BACKWARD, thrown); @@ -744,17 +734,13 @@ 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 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 reset_rumble_timers_2(0); -#endif } } } @@ -840,9 +826,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 reset_rumble_timers(); -#endif return FALSE; } diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index ef413cd9..30c0033a 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1178,9 +1178,7 @@ s32 act_death_exit(struct MarioState *m) { #else play_sound(SOUND_MARIO_OOOF2, m->marioObj->header.gfx.cameraToObject); #endif -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif m->numLives--; // restore 7.75 units of health m->healCounter = 31; @@ -1213,9 +1211,7 @@ s32 act_falling_death_exit(struct MarioState *m) { #else play_sound(SOUND_MARIO_OOOF2, m->marioObj->header.gfx.cameraToObject); #endif -#ifdef VERSION_SH queue_rumble_data(5, 80); -#endif m->numLives--; // restore 7.75 units of health m->healCounter = 31; @@ -1260,9 +1256,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 queue_rumble_data(5, 80); -#endif m->numLives--; m->healCounter = 31; } @@ -1346,9 +1340,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 queue_rumble_data(15, 80); -#endif m->actionState = 4; } if (m->actionState == 2) { @@ -1414,12 +1406,10 @@ 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 (m->actionTimer == 0) { queue_rumble_data(30, 70); func_sh_8024C89C(2); } -#endif m->flags |= MARIO_TELEPORTING; @@ -1440,12 +1430,10 @@ 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 (m->actionTimer == 0) { queue_rumble_data(30, 70); func_sh_8024C89C(2); } -#endif if (m->actionTimer < 32) { m->flags |= MARIO_TELEPORTING; @@ -1534,9 +1522,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 EU. vec3f_set(m->marioObj->header.gfx.scale, 1.8, 0.05f, 1.8f); -#ifdef VERSION_SH queue_rumble_data(10, 80); -#endif m->actionState = 1; } break; @@ -1638,9 +1624,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 queue_rumble_data(5, 80); -#endif play_sound_and_spawn_particles(m, SOUND_ACTION_UNSTUCK_FROM_GROUND, 1); } else if (animFrame == target2 || animFrame == target3) { play_mario_landing_sound(m, SOUND_ACTION_TERRAIN_LANDING); diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 5b4dbb80..f7d517b1 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -1252,9 +1252,8 @@ s32 act_riding_shell_ground(struct MarioState *m) { } adjust_sound_for_speed(m); -#ifdef VERSION_SH + reset_rumble_timers(); -#endif return FALSE; } @@ -1358,9 +1357,8 @@ s32 act_burning_ground(struct MarioState *m) { } m->marioBodyState->eyeState = MARIO_EYES_DEAD; -#ifdef VERSION_SH + reset_rumble_timers(); -#endif return FALSE; } @@ -1376,9 +1374,7 @@ void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 vec3f_copy(val14, m->pos); play_sound(SOUND_MOVING_TERRAIN_SLIDE + m->terrainSoundAddend, m->marioObj->header.gfx.cameraToObject); -#ifdef VERSION_SH reset_rumble_timers(); -#endif adjust_sound_for_speed(m); @@ -1502,9 +1498,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 queue_rumble_data(5, 80); -#endif return set_jumping_action(m, ACT_FORWARD_ROLLOUT, 0); } @@ -1534,9 +1528,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 queue_rumble_data(5, 80); -#endif return drop_and_set_mario_action( m, m->forwardVel >= 0.0f ? ACT_FORWARD_ROLLOUT : ACT_BACKWARD_ROLLOUT, 0); } @@ -1570,9 +1562,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 queue_rumble_data(5, 80); -#endif return set_mario_action(m, m->forwardVel > 0.0f ? ACT_FORWARD_ROLLOUT : ACT_BACKWARD_ROLLOUT, 0); } @@ -1857,13 +1847,14 @@ s32 act_hold_freefall_land(struct MarioState *m) { } s32 act_long_jump_land(struct MarioState *m) { -#ifdef VERSION_SH - // BLJ (Backwards Long Jump) speed build up fix, crushing SimpleFlips's dreams since July 1997 - if (m->forwardVel < 0.0f) { - m->forwardVel = 0.0f; + // Stop right there criminal scum! + if (Cheats.EnableCheats == TRUE && Cheats.DisableBLJ == TRUE) { + // BLJ (Backwards Long Jump) speed build up fix, crushing SimpleFlips's dreams since July 1997 + if (m->forwardVel < 0.0f) { + m->forwardVel = 0.0f; + } } -#endif - + if (!(m->input & INPUT_Z_DOWN)) { m->input &= ~INPUT_A_PRESSED; } diff --git a/src/game/mario_actions_object.c b/src/game/mario_actions_object.c index 5c71e962..d01a6c67 100644 --- a/src/game/mario_actions_object.c +++ b/src/game/mario_actions_object.c @@ -265,9 +265,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 queue_rumble_data(3, 50); -#endif } animated_stationary_ground_step(m, MARIO_ANIM_GROUND_THROW, ACT_IDLE); @@ -287,9 +285,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 queue_rumble_data(3, 50); -#endif } animated_stationary_ground_step(m, MARIO_ANIM_HEAVY_THROW, ACT_IDLE); @@ -319,9 +315,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 queue_rumble_data(5, 80); -#endif play_sound(SOUND_MARIO_HRMM, m->marioObj->header.gfx.cameraToObject); } @@ -397,15 +391,11 @@ s32 act_holding_bowser(struct MarioState *m) { // play sound on overflow if (m->angleVel[1] <= -0x100 && spin < m->faceAngle[1]) { -#ifdef VERSION_SH 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 queue_rumble_data(4, 20); -#endif play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject); } @@ -422,14 +412,10 @@ 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 queue_rumble_data(4, 50); -#endif mario_throw_held_object(m); } else { -#ifdef VERSION_SH 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 33d2919d..e7ef3583 100644 --- a/src/game/mario_actions_stationary.c +++ b/src/game/mario_actions_stationary.c @@ -798,16 +798,12 @@ s32 act_shockwave_bounce(struct MarioState *m) { f32 sp18; if (m->marioObj->oInteractStatus & 0x10) { -#ifdef VERSION_SH queue_rumble_data(70, 40); -#endif return hurt_and_set_mario_action(m, ACT_SHOCKED, 0, 4); } if (m->actionTimer == 0) { -#ifdef VERSION_SH queue_rumble_data(70, 40); -#endif if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_UNK1) { return hurt_and_set_mario_action(m, ACT_BACKWARD_GROUND_KB, 0, 0xc); } diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index d563bd17..a2af592b 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -554,11 +554,9 @@ static s32 act_breaststroke(struct MarioState *m) { reset_float_globals(m); } -#ifdef VERSION_SH if (m->actionTimer < 6) { func_sh_8024CA04(); } -#endif set_mario_animation(m, MARIO_ANIM_SWIM_PART1); common_swimming_step(m, sSwimStrength); @@ -802,9 +800,7 @@ static s32 act_water_throw(struct MarioState *m) { if (m->actionTimer++ == 5) { mario_throw_held_object(m); -#ifdef VERSION_SH queue_rumble_data(3, 50); -#endif } if (is_anim_at_end(m)) { @@ -978,11 +974,9 @@ static s32 act_water_plunge(struct MarioState *m) { m->particleFlags |= PARTICLE_WATER_SPLASH; m->actionState = 1; -#ifdef VERSION_SH if (m->prevAction & ACT_FLAG_AIR) { queue_rumble_data(5, 80); } -#endif } if (stepResult == WATER_STEP_HIT_FLOOR || m->vel[1] >= endVSpeed || m->actionTimer > 20) { @@ -1087,10 +1081,8 @@ 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 + reset_rumble_timers(); -#endif - return FALSE; } diff --git a/src/game/save_file.c b/src/game/save_file.c index 9facaf3c..1b460bb8 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -104,14 +104,10 @@ static s32 read_eeprom_data(void *buffer, s32 size) { u32 offset = (u32)((u8 *) buffer - (u8 *) &gSaveBuffer) / 8; do { -#ifdef VERSION_SH block_until_rumble_pak_free(); -#endif triesLeft--; status = osEepromLongRead(&gSIEventMesgQueue, offset, buffer, size); -#ifdef VERSION_SH release_rumble_pak_control(); -#endif } while (triesLeft > 0 && status != 0); } @@ -132,14 +128,10 @@ static s32 write_eeprom_data(void *buffer, s32 size, const uintptr_t baseofs) { u32 offset = (u32)baseofs >> 3; do { -#ifdef VERSION_SH block_until_rumble_pak_free(); -#endif triesLeft--; status = osEepromLongWrite(&gSIEventMesgQueue, offset, buffer, size); -#ifdef VERSION_SH 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 ec5dfcbc..ce1042c4 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -153,11 +153,10 @@ void play_menu_sounds(s16 soundMenuFlags) { if (soundMenuFlags & 0x100) { play_menu_sounds_extra(20, NULL); } -#ifdef VERSION_SH + if ((soundMenuFlags & 0x20) != 0) { queue_rumble_data(10, 60); } -#endif } /** diff --git a/src/game/spawn_sound.c b/src/game/spawn_sound.c index c7812b25..d23be075 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 (soundMagic == SOUND_OBJ_BOWSER_WALK) { queue_rumble_data(3, 60); } @@ -78,7 +78,6 @@ void cur_obj_play_sound_2(s32 soundMagic) { if (soundMagic == SOUND_OBJ_WHOMP_LOWPRIO) { queue_rumble_data(5, 80); } -#endif } } diff --git a/src/game/thread6.c b/src/game/thread6.c index 40984407..f388cc5b 100644 --- a/src/game/thread6.c +++ b/src/game/thread6.c @@ -5,8 +5,6 @@ #include "main.h" #include "thread6.h" -#ifdef VERSION_SH - static s8 D_SH_8030CCB4; static s32 sUnusedDisableRumble; static s32 sRumblePakThreadActive; @@ -15,22 +13,18 @@ static s32 sRumblePakErrorCount; s32 gRumblePakTimer; // These void* are OSPfs* but we don't have that header +// And in general, it is not necessary =) extern s32 osMotorStop(void *); extern s32 osMotorStart(void *); extern u32 osMotorInit(OSMesgQueue *, void *, s32); void init_rumble_pak_scheduler_queue(void) { - osCreateMesgQueue(&gRumblePakSchedulerMesgQueue, gRumblePakSchedulerMesgBuf, 1); - osSendMesg(&gRumblePakSchedulerMesgQueue, (OSMesg) 0, OS_MESG_NOBLOCK); } void block_until_rumble_pak_free(void) { - OSMesg msg; - osRecvMesg(&gRumblePakSchedulerMesgQueue, &msg, OS_MESG_BLOCK); } void release_rumble_pak_control(void) { - osSendMesg(&gRumblePakSchedulerMesgQueue, (OSMesg) 0, OS_MESG_NOBLOCK); } static void start_rumble(void) { @@ -225,32 +219,21 @@ void func_sh_8024CA04(void) { gCurrRumbleSettings.unk0C = 4; } -static void thread6_rumble_loop(UNUSED void *a0) { - OSMesg msg; +void thread6_rumble_loop(UNUSED void *a0) { + update_rumble_data_queue(); + update_rumble_pak(); - cancel_rumble(); - - sRumblePakThreadActive = TRUE; - - while (TRUE) { - // Block until VI - osRecvMesg(&gRumbleThreadVIMesgQueue, &msg, OS_MESG_BLOCK); - - update_rumble_data_queue(); - update_rumble_pak(); - - if (sRumblePakActive) { - if (sRumblePakErrorCount >= 30) { - sRumblePakActive = FALSE; - } - } else if (gGlobalTimer % 60 == 0) { - sRumblePakActive = osMotorInit(&gSIEventMesgQueue, &gRumblePakPfs, gPlayer1Controller->port) < 1; - sRumblePakErrorCount = 0; + if (sRumblePakActive) { + if (sRumblePakErrorCount >= 30) { + sRumblePakActive = FALSE; } + } else if (gGlobalTimer % 60 == 0) { + sRumblePakActive = osMotorInit(&gSIEventMesgQueue, &gRumblePakPfs, gPlayer1Controller->port) < 1; + sRumblePakErrorCount = 0; + } - if (gRumblePakTimer > 0) { - gRumblePakTimer--; - } + if (gRumblePakTimer > 0) { + gRumblePakTimer--; } } @@ -272,17 +255,10 @@ void cancel_rumble(void) { } void create_thread_6(void) { - osCreateMesgQueue(&gRumbleThreadVIMesgQueue, gRumbleThreadVIMesgBuf, 1); - osCreateThread(&gRumblePakThread, 6, thread6_rumble_loop, NULL, gThread6Stack + 0x2000, 30); - osStartThread(&gRumblePakThread); } void rumble_thread_update_vi(void) { if (sRumblePakThreadActive == FALSE) { return; } - - osSendMesg(&gRumbleThreadVIMesgQueue, (OSMesg) 0x56525443, OS_MESG_NOBLOCK); -} - -#endif +} \ No newline at end of file diff --git a/src/game/thread6.h b/src/game/thread6.h index 92418635..06586e62 100644 --- a/src/game/thread6.h +++ b/src/game/thread6.h @@ -1,8 +1,6 @@ #ifndef _THREAD_6_H #define _THREAD_6_H -#ifdef VERSION_SH - extern s32 gRumblePakTimer; extern void init_rumble_pak_scheduler_queue(void); @@ -18,6 +16,4 @@ extern void cancel_rumble(void); extern void create_thread_6(void); extern void rumble_thread_update_vi(void); -#endif - -#endif +#endif // _THREAD_6_H \ No newline at end of file diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index c4162c32..a2960fd8 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -23,6 +23,9 @@ #include "configfile.h" #include "controller/controller_api.h" +#include "game/main.h" +#include "game/thread6.h" + OSMesg D_80339BEC; OSMesgQueue gSIEventMesgQueue; @@ -32,6 +35,10 @@ s8 gDebugLevelSelect; s8 gShowProfiler; s8 gShowDebugText; +s32 gRumblePakPfs; +struct RumbleData gRumbleDataQueue[3]; +struct StructSH8031D9B0 gCurrRumbleSettings; + static struct AudioAPI *audio_api; static struct GfxWindowManagerAPI *wm_api; static struct GfxRenderingAPI *rendering_api; @@ -60,6 +67,7 @@ void send_display_list(struct SPTask *spTask) { void produce_one_frame(void) { gfx_start_frame(); game_loop_one_iteration(); + thread6_rumble_loop(); int samples_left = audio_api->buffered(); u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? 544 : 528; @@ -162,7 +170,7 @@ void main_func(void) { sound_init(); thread5_game_loop(NULL); - + inited = true; #ifdef TARGET_WEB