From 1d2cdcec20ad3aa0a9359b4b1d561be61767919f Mon Sep 17 00:00:00 2001 From: AloXado320 Date: Wed, 12 May 2021 13:17:35 -0500 Subject: [PATCH] some rumble diffs --- include/types.h | 6 +++++- src/buffers/buffers.c | 2 +- src/buffers/buffers.h | 2 +- src/game/game_init.c | 11 ++++++++--- src/game/main.c | 2 +- src/game/main.h | 2 +- src/game/mario_actions_airborne.c | 5 +++-- src/game/rumble_init.h | 4 ++-- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/types.h b/include/types.h index c1802f7..8277b9f 100644 --- a/include/types.h +++ b/include/types.h @@ -30,9 +30,13 @@ struct Controller /*0x12*/ u16 buttonPressed; /*0x14*/ OSContStatus *statusData; /*0x18*/ OSContPad *controllerData; - /*0x1C*/ int port; +#ifdef RUMBLE_FEEDBACK + /*0x1C*/ s32 port; +#endif +#ifndef TARGET_N64 /*ext */ s16 extStickX; // additional (right) stick values /*ext */ s16 extStickY; +#endif }; typedef f32 Vec2f[2]; diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c index 23a144f..f2c09fd 100644 --- a/src/buffers/buffers.c +++ b/src/buffers/buffers.c @@ -11,7 +11,7 @@ ALIGNED8 u8 gThread3Stack[0x2000]; ALIGNED8 u8 gThread4Stack[0x2000]; ALIGNED8 u8 gThread5Stack[0x2000]; -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK ALIGNED8 u8 gThread6Stack[0x2000]; #endif // 0x400 bytes diff --git a/src/buffers/buffers.h b/src/buffers/buffers.h index c61e5dd..793b2d0 100644 --- a/src/buffers/buffers.h +++ b/src/buffers/buffers.h @@ -16,7 +16,7 @@ extern u8 gIdleThreadStack[]; extern u8 gThread3Stack[]; extern u8 gThread4Stack[]; extern u8 gThread5Stack[]; -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK extern u8 gThread6Stack[]; #endif diff --git a/src/game/game_init.c b/src/game/game_init.c index 4255cb0..0d98074 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -537,6 +537,9 @@ void read_controller_inputs(void) { if (gControllerBits) { osRecvMesg(&gSIEventMesgQueue, &D_80339BEC, OS_MESG_BLOCK); osContGetReadData(&gControllerPads[0]); +#if RUMBLE_FEEDBACK + release_rumble_pak_control(); +#endif } run_demo_inputs(); @@ -622,7 +625,9 @@ 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 RUMBLE_FEEDBACK gControllers[cont].port = port; +#endif gControllers[cont].statusData = &gControllerStatuses[port]; gControllers[cont++].controllerData = &gControllerPads[port]; } @@ -657,11 +662,11 @@ static struct LevelCommand *levelCommandAddr; void thread5_game_loop(UNUSED void *arg) { setup_game_memory(); -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK init_rumble_pak_scheduler_queue(); #endif init_controllers(); -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK create_thread_6(); #endif save_file_load_all(); @@ -701,7 +706,7 @@ void game_loop_one_iteration(void) { // if any controllers are plugged in, start read the data for when // read_controller_inputs is called later. if (gControllerBits) { -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK block_until_rumble_pak_free(); #endif osContStartReadData(&gSIEventMesgQueue); diff --git a/src/game/main.c b/src/game/main.c index 3971080..f274eee 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -265,7 +265,7 @@ void handle_vblank(void) { start_sptask(M_GFXTASK); } } -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK rumble_thread_update_vi(); #endif // Notify the game loop about the vblank. diff --git a/src/game/main.h b/src/game/main.h index 16955c7..b29e811 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -39,7 +39,7 @@ extern OSMesg D_80339BEC; extern OSMesgQueue gDmaMesgQueue; extern OSMesgQueue gSIEventMesgQueue; -#ifdef VERSION_SH +#ifdef RUMBLE_FEEDBACK extern OSThread gRumblePakThread; extern OSMesg gRumblePakSchedulerMesgBuf[1]; extern OSMesg gRumbleThreadVIMesgBuf[1]; diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 9371282..0bd96de 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1515,13 +1515,14 @@ s32 act_hold_butt_slide_air(struct MarioState *m) { } s32 act_lava_boost(struct MarioState *m) { +#ifdef RUMBLE_FEEDBACK if (!(m->flags & MARIO_MARIO_SOUND_PLAYED)) { +#endif play_sound_if_no_flag(m, SOUND_MARIO_ON_FIRE, MARIO_MARIO_SOUND_PLAYED); #ifdef RUMBLE_FEEDBACK queue_rumble_data(5, 80); -#endif } - 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); diff --git a/src/game/rumble_init.h b/src/game/rumble_init.h index 18d8c3a..4683825 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 -#if defined(VERSION_SH) || defined(RUMBLE_FEEDBACK) +#ifdef RUMBLE_FEEDBACK extern s32 gRumblePakTimer; @@ -19,6 +19,6 @@ void create_thread_6(void); void rumble_thread_update_vi(void); void thread6_rumble_loop(void *a0); -#endif // VERSION_SH +#endif // RUMBLE_FEEDBACK #endif // RUMBLE_INIT_H