mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
code_8013EC10 and code_80182CE0 (z_rumble and sys_rumble) (#763)
* First pass * import bss * cleanup warnings * PadMgr_ControllerHasRumblePak * z64rumble.h * rename file to z_rumble.c * format * Update src/code/z_rumble.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * Update src/code/z_rumble.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * name a temp * minor cleaning * bss * match code_80182CE0 * import data and cleanups * Rename RumbleManager struct and sys_rumble file * Rename functions from sys_rumble * Rename parameter to distSq Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * more notes and a bit of cleaning * Name Rumble_Add and Rumble_AddForced * some extra notes * Rename Rumble_Override and Rumble_Request * document states * minor renames * actorfixer * format * very minor docs * whoops * remove redundant prevent_bss_reordering * Update src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/overlays/actors/ovl_Bg_Iknin_Susceil/z_bg_iknin_susceil.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * namefixer * Update src/code/sys_rumble.c Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * fix * Elliptic review Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * minor cleanups * Update include/z64rumble.h Co-authored-by: EllipticEllipsis <elliptic.ellipsis@gmail.com> * review Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * Update src/code/sys_rumble.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_rumble.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * review Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: EllipticEllipsis <elliptic.ellipsis@gmail.com>
This commit is contained in:
co-authored by
Derek Hensley
engineer124
Dragorn421
EllipticEllipsis
EllipticEllipsis
parent
158d1b26b0
commit
45eed680d6
+8
-20
@@ -1,5 +1,5 @@
|
||||
#ifndef _FUNCTIONS_H_
|
||||
#define _FUNCTIONS_H_
|
||||
#ifndef FUNCTIONS_H
|
||||
#define FUNCTIONS_H
|
||||
|
||||
#include "z64.h"
|
||||
|
||||
@@ -2392,16 +2392,7 @@ void func_8013A46C(s32 flag);
|
||||
u32 func_8013A4C4(s32 flag);
|
||||
s16 func_8013A504(s16 val);
|
||||
s32 func_8013A530(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError);
|
||||
// void func_8013EC10(void);
|
||||
|
||||
void func_8013EC44(f32 a, u8 b, u8 c, u8 d);
|
||||
void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3);
|
||||
void func_8013ED9C(void);
|
||||
void func_8013EDD0(void);
|
||||
u32 func_8013EE04(void);
|
||||
void func_8013EE24(void);
|
||||
// void func_8013EE38(void);
|
||||
// void func_8013EE48(void);
|
||||
void View_ViewportToVp(Vp* dest, Viewport* src);
|
||||
void View_Init(View* view, GraphicsContext* gfxCtx);
|
||||
void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up);
|
||||
@@ -2807,8 +2798,8 @@ ListAlloc* ListAlloc_Init(ListAlloc* this);
|
||||
void ListAlloc_FreeAll(ListAlloc* this);
|
||||
void Main(void* arg);
|
||||
u32 Padmgr_GetControllerBitmask(void);
|
||||
// void func_80174F24(void);
|
||||
// void func_80174F44(void);
|
||||
void func_80174F24(void (*arg0)(void*), void* arg1);
|
||||
void func_80174F44(void (*arg0)(void*), void* arg1);
|
||||
// void func_80174F7C(void);
|
||||
// void func_80174F9C(void);
|
||||
// OSMesgQueue* Padmgr_GetEventCallback(void);
|
||||
@@ -2819,10 +2810,10 @@ void Padmgr_SetEventCallback(OSMesg pvParm1);
|
||||
// void Padmgr_Unlock(void);
|
||||
// void func_801750FC(void);
|
||||
// void func_80175364(void);
|
||||
// void func_80175434(void);
|
||||
// void func_8017544C(void);
|
||||
// void func_80175474(void);
|
||||
// void func_801754C0(void);
|
||||
void func_80175434(void);
|
||||
void func_8017544C(s32 port, s32 rumbleOn);
|
||||
void PadMgr_RumbleSet(u8 rumbleEnabled[MAXCONTROLLERS]);
|
||||
s32 PadMgr_ControllerHasRumblePak(s32 port);
|
||||
void Padmgr_CalcStickEdges(Input* input);
|
||||
// void Padmgr_ParseState(void);
|
||||
// void func_801759BC(void);
|
||||
@@ -3002,9 +2993,6 @@ size_t SysUcode_GetUCodeBootSize(void);
|
||||
u64* SysUcode_GetUCode(void);
|
||||
u64* SysUcode_GetUCodeData(void);
|
||||
|
||||
// void func_80182CE0(void);
|
||||
// void func_80183020(void);
|
||||
// void func_80183058(void);
|
||||
void func_80183070(void);
|
||||
// void func_801830A0(void);
|
||||
// void func_801830C8(void);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#ifndef _GLOBAL_H_
|
||||
#define _GLOBAL_H_
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include "z64.h"
|
||||
#include "regs.h"
|
||||
|
||||
+1
-6
@@ -1574,7 +1574,7 @@ extern UNK_PTR D_801D1540;
|
||||
// extern f32 sFactorialTbl[13];
|
||||
extern Vec3f gZeroVec3f;
|
||||
extern Vec3s gZeroVec3s;
|
||||
// extern UNK_TYPE1 D_801D1E70;
|
||||
|
||||
extern s16 gLowPassFilterData[];
|
||||
extern s16 gHighPassFilterData[];
|
||||
extern s16 gBandStopFilterData[];
|
||||
@@ -3216,11 +3216,6 @@ extern s16 D_801F4E7A;
|
||||
// extern UNK_TYPE1 D_801F59F0;
|
||||
// extern UNK_TYPE1 D_801F59F4;
|
||||
// extern UNK_TYPE1 D_801F59F8;
|
||||
// extern UNK_TYPE1 D_801F69D0;
|
||||
// extern UNK_TYPE1 D_801F6A10;
|
||||
// extern UNK_TYPE1 D_801F6AD4;
|
||||
// extern UNK_TYPE1 D_801F6AD5;
|
||||
// extern UNK_TYPE1 D_801F6ADA;
|
||||
// extern UNK_TYPE1 sSkyboxDrawMatrix;
|
||||
// extern UNK_TYPE1 D_801F6AF0;
|
||||
// extern UNK_TYPE1 D_801F6AF2;
|
||||
|
||||
@@ -99,9 +99,9 @@ typedef struct {
|
||||
/* 0x0 */ u16 type;
|
||||
/* 0x2 */ u16 startFrame;
|
||||
/* 0x4 */ u16 endFrame;
|
||||
/* 0x6 */ u8 unk6;
|
||||
/* 0x7 */ u8 unk7;
|
||||
/* 0x8 */ u8 unk8;
|
||||
/* 0x6 */ u8 intensity;
|
||||
/* 0x7 */ u8 decayTimer;
|
||||
/* 0x8 */ u8 decayStep;
|
||||
/* 0x9 */ UNK_TYPE1 pad9[0x3];
|
||||
} CsCmdRumble; // size = 0xC
|
||||
|
||||
|
||||
@@ -548,8 +548,8 @@
|
||||
* mmmmssss eeeeUUUU
|
||||
* size = 0x08
|
||||
*/
|
||||
#define CS_RUMBLE(base, startFrame, endFrame, unk6, unk7, unk8) \
|
||||
{ CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, unk6, unk7) }, { CMD_BBBB(unk8, 0, 0, 0) }
|
||||
#define CS_RUMBLE(base, startFrame, endFrame, intensity, decayTimer, decayStep) \
|
||||
{ CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, intensity, decayTimer) }, { CMD_BBBB(decayStep, 0, 0, 0) }
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef Z64RUMBLE_H
|
||||
#define Z64RUMBLE_H
|
||||
|
||||
#include "PR/ultratypes.h"
|
||||
#include "io/controller.h"
|
||||
|
||||
typedef enum RumbleManagerState {
|
||||
/* 0 */ RUMBLEMANAGER_STATE_WIPE, // Disables the request processing and wipes every request. It can be either set manually or automatically by the system as fail-safe in case the Rumble Pak has been vibrating for 2 minutes
|
||||
/* 1 */ RUMBLEMANAGER_STATE_RUNNING, // Normal execution and updating
|
||||
/* 2 */ RUMBLEMANAGER_STATE_INITIAL // Indicates initialization and cleanup must be done before processing the rumble requests. All the old requests on are wiped on this state. Then it proceeds to RUMBLEMANAGER_STATE_RUNNING
|
||||
} RumbleManagerState;
|
||||
|
||||
#define RUMBLE_REQUEST_BUFFER_SIZE 0x40
|
||||
|
||||
typedef struct RumbleManager {
|
||||
/* 0x000 */ u8 rumbleEnabled[MAXCONTROLLERS];
|
||||
/* 0x004 */ u8 requestIntensities[RUMBLE_REQUEST_BUFFER_SIZE]; // seems to have two purposes: act as a priority value over the other rumble requests and to contribute to requestAccumulators on each tick
|
||||
/* 0x044 */ u8 requestDecayTimers[RUMBLE_REQUEST_BUFFER_SIZE]; // amount of ticks this request will run before requestIntensities starts decreasing
|
||||
/* 0x084 */ u8 requestDecaySteps[RUMBLE_REQUEST_BUFFER_SIZE]; // used to decrease requestIntensities by this amount each tick after requestDecayTimers runs out
|
||||
/* 0x0C4 */ u8 requestAccumulators[RUMBLE_REQUEST_BUFFER_SIZE]; // the value contained here plus requestIntensities must meet a certain threshold to start rumbling this tick
|
||||
/* 0x104 */ u8 state;
|
||||
/* 0x105 */ u8 updateEnabled; // boolean value which controls if the Update function should be run. Unlike RUMBLEMANAGER_STATE_WIPE, disabling this does not wipe the state of the requests
|
||||
/* 0x106 */ u16 rumblingDuration; // amount of "ticks" updates the Rumble Pak has been rumbling without pause. It is restarted after 5 ticks of not rumbling
|
||||
/* 0x108 */ u16 downTime; // small counter/timer used to restart rumblingDuration
|
||||
/* 0x10A */ u8 overrideIntensity; // "override" counterpart for requestIntensities
|
||||
/* 0x10B */ u8 overrideDecayTimer;
|
||||
/* 0x10C */ u8 overrideDecayStep;
|
||||
/* 0x10D */ u8 overrideAccumulator;
|
||||
} RumbleManager; // size = 0x10E
|
||||
|
||||
extern RumbleManager gRumbleMgr;
|
||||
|
||||
void Rumble_Override(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep);
|
||||
void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep);
|
||||
void Rumble_Init(void);
|
||||
void Rumble_Destroy(void);
|
||||
s32 Rumble_ControllerOneHasRumblePak(void);
|
||||
void Rumble_StateReset(void);
|
||||
void Rumble_StateWipeRequests(void);
|
||||
void Rumble_SetUpdateEnabled(s32 updateEnabled);
|
||||
|
||||
void RumbleManager_Update(RumbleManager* rumbleMgr);
|
||||
void RumbleManager_Init(RumbleManager* rumbleMgr);
|
||||
void RumbleManager_Destroy(RumbleManager* rumbleMgr);
|
||||
|
||||
#endif
|
||||
@@ -529,8 +529,7 @@ beginseg
|
||||
include "build/src/code/z_snap.o"
|
||||
include "build/src/code/z_sub_s.o"
|
||||
include "build/data/code/code_801DE890.rodata.o"
|
||||
include "build/src/code/code_8013EC10.o"
|
||||
include "build/data/code/code_8013EC10.bss.o"
|
||||
include "build/src/code/z_rumble.o"
|
||||
include "build/src/code/z_view.o"
|
||||
include "build/src/code/z_vimode.o"
|
||||
include "build/data/code/z_vimode.data.o"
|
||||
@@ -598,8 +597,8 @@ beginseg
|
||||
include "build/src/code/sys_math_atan.o"
|
||||
include "build/src/code/sys_matrix.o"
|
||||
include "build/src/code/sys_ucode.o"
|
||||
include "build/src/code/code_80182CE0.o"
|
||||
include "build/data/code/code_801D1E70.data.o"
|
||||
include "build/src/code/sys_rumble.o"
|
||||
include "build/data/code/code_801D1E80.data.o"
|
||||
include "build/src/code/code_80183070.o"
|
||||
include "build/src/code/c_keyframe.o"
|
||||
include "build/src/code/sys_slowly.o"
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EC10.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EC44.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013ECE0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013ED9C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EDD0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE04.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE24.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE38.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE48.s")
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80182CE0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183020.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183058.s")
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
#include "z64rumble.h"
|
||||
|
||||
s32 gFramerateDivisor = 1;
|
||||
f32 gFramerateDivisorF = 1.0f;
|
||||
@@ -216,7 +217,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
||||
VisMono_Init(&sMonoColors);
|
||||
func_80140898(&D_801F8048);
|
||||
func_801773A0(&D_801F7FF0);
|
||||
func_8013ED9C();
|
||||
Rumble_Init();
|
||||
|
||||
osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
@@ -231,7 +232,7 @@ void GameState_Destroy(GameState* gameState) {
|
||||
gameState->destroy(gameState);
|
||||
}
|
||||
|
||||
func_8013EDD0();
|
||||
Rumble_Destroy();
|
||||
func_801773C4(&D_801F7FF0);
|
||||
func_80140D04(&D_801F8010);
|
||||
func_801420F4(&D_801F8020);
|
||||
|
||||
+2
-2
@@ -31,9 +31,9 @@
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017544C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175474.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_RumbleSet.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_801754C0.s")
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_ControllerHasRumblePak.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_CalcStickEdges.s")
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* File: sys_rumble.c
|
||||
* Description: Internal scheduler system for rumble requests
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "z64rumble.h"
|
||||
|
||||
// sRumbleWasEnabledOnLastTick/sWillDisableRumble? Probably name it after updateEnabled
|
||||
u8 D_801D1E70 = true;
|
||||
|
||||
void RumbleManager_Update(RumbleManager* rumbleMgr) {
|
||||
s32 strongestIndex = -1;
|
||||
s32 i;
|
||||
s32 temp;
|
||||
|
||||
// Turn rumbling off for all controllers
|
||||
for (i = 0; i < ARRAY_COUNT(rumbleMgr->rumbleEnabled); i++) {
|
||||
rumbleMgr->rumbleEnabled[i] = false;
|
||||
}
|
||||
|
||||
if (!rumbleMgr->updateEnabled) {
|
||||
// Rumbling update is disabled
|
||||
|
||||
if (D_801D1E70) {
|
||||
for (i = 0; i < MAXCONTROLLERS; i++) {
|
||||
func_8017544C(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
D_801D1E70 = rumbleMgr->updateEnabled;
|
||||
func_80175434();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
D_801D1E70 = rumbleMgr->updateEnabled;
|
||||
|
||||
// Start up the manager by wiping old requests
|
||||
if (rumbleMgr->state == RUMBLEMANAGER_STATE_INITIAL) {
|
||||
for (i = 0; i < MAXCONTROLLERS; i++) {
|
||||
func_8017544C(i, false);
|
||||
}
|
||||
|
||||
for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
|
||||
rumbleMgr->requestIntensities[i] = 0;
|
||||
rumbleMgr->requestDecayTimers[i] = 0;
|
||||
rumbleMgr->requestDecaySteps[i] = 0;
|
||||
rumbleMgr->requestAccumulators[i] = 0;
|
||||
}
|
||||
|
||||
rumbleMgr->rumblingDuration = 0;
|
||||
rumbleMgr->downTime = 0;
|
||||
|
||||
rumbleMgr->overrideIntensity = 0;
|
||||
rumbleMgr->overrideDecayTimer = 0;
|
||||
rumbleMgr->overrideDecayStep = 0;
|
||||
rumbleMgr->overrideAccumulator = 0;
|
||||
|
||||
rumbleMgr->state = RUMBLEMANAGER_STATE_RUNNING;
|
||||
|
||||
func_80175434();
|
||||
}
|
||||
|
||||
if (rumbleMgr->state != RUMBLEMANAGER_STATE_WIPE) {
|
||||
// Process arrays of rumble requests
|
||||
for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
|
||||
if (rumbleMgr->requestIntensities[i] != 0) { // This entry has a non-empty rumble request
|
||||
if (rumbleMgr->requestDecayTimers[i] > 0) {
|
||||
rumbleMgr->requestDecayTimers[i]--;
|
||||
} else {
|
||||
temp = rumbleMgr->requestIntensities[i] - rumbleMgr->requestDecaySteps[i];
|
||||
if (temp > 0) {
|
||||
rumbleMgr->requestIntensities[i] = temp;
|
||||
} else {
|
||||
rumbleMgr->requestIntensities[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
temp = rumbleMgr->requestAccumulators[i] + rumbleMgr->requestIntensities[i];
|
||||
rumbleMgr->requestAccumulators[i] = temp; // overflows
|
||||
if (strongestIndex == -1) {
|
||||
strongestIndex = i;
|
||||
rumbleMgr->rumbleEnabled[0] = (temp >= 0x100);
|
||||
} else if (rumbleMgr->requestIntensities[strongestIndex] < rumbleMgr->requestIntensities[i]) {
|
||||
strongestIndex = i;
|
||||
rumbleMgr->rumbleEnabled[0] = (temp >= 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process Override request. Note it takes priority over the values set by the request arrays
|
||||
if (rumbleMgr->overrideIntensity != 0) {
|
||||
if (rumbleMgr->overrideDecayTimer > 0) {
|
||||
rumbleMgr->overrideDecayTimer--;
|
||||
} else {
|
||||
temp = rumbleMgr->overrideIntensity - rumbleMgr->overrideDecayStep;
|
||||
if (temp > 0) {
|
||||
rumbleMgr->overrideIntensity = temp;
|
||||
} else {
|
||||
rumbleMgr->overrideIntensity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
temp = rumbleMgr->overrideAccumulator + rumbleMgr->overrideIntensity;
|
||||
rumbleMgr->overrideAccumulator = temp; // overflows
|
||||
rumbleMgr->rumbleEnabled[0] = (temp >= 0x100);
|
||||
}
|
||||
|
||||
if (rumbleMgr->overrideIntensity != 0) {
|
||||
temp = rumbleMgr->overrideIntensity;
|
||||
} else if (strongestIndex == -1) {
|
||||
temp = 0;
|
||||
} else {
|
||||
temp = rumbleMgr->requestIntensities[strongestIndex];
|
||||
}
|
||||
|
||||
// Keep track of how long this have been rumbling (almost) nonstop
|
||||
if (temp == 0) {
|
||||
rumbleMgr->downTime++;
|
||||
if (rumbleMgr->downTime > 5) {
|
||||
rumbleMgr->rumblingDuration = 0;
|
||||
rumbleMgr->downTime = 5;
|
||||
}
|
||||
} else {
|
||||
rumbleMgr->downTime = 0;
|
||||
rumbleMgr->rumblingDuration++;
|
||||
if (rumbleMgr->rumblingDuration > 2 * 60 * 60) { // 2 minutes
|
||||
// Rumbling has lasted too long, clear system
|
||||
rumbleMgr->state = RUMBLEMANAGER_STATE_WIPE;
|
||||
}
|
||||
}
|
||||
} else { // RUMBLEMANAGER_STATE_WIPE
|
||||
for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
|
||||
rumbleMgr->requestIntensities[i] = 0;
|
||||
rumbleMgr->requestDecayTimers[i] = 0;
|
||||
rumbleMgr->requestDecaySteps[i] = 0;
|
||||
rumbleMgr->requestAccumulators[i] = 0;
|
||||
}
|
||||
|
||||
rumbleMgr->rumblingDuration = 0;
|
||||
rumbleMgr->downTime = 0;
|
||||
|
||||
rumbleMgr->overrideIntensity = 0;
|
||||
rumbleMgr->overrideDecayTimer = 0;
|
||||
rumbleMgr->overrideDecayStep = 0;
|
||||
rumbleMgr->overrideAccumulator = 0;
|
||||
|
||||
func_80175434();
|
||||
}
|
||||
}
|
||||
|
||||
void RumbleManager_Init(RumbleManager* rumbleMgr) {
|
||||
bzero(rumbleMgr, sizeof(RumbleManager));
|
||||
rumbleMgr->state = RUMBLEMANAGER_STATE_INITIAL;
|
||||
rumbleMgr->updateEnabled = true;
|
||||
}
|
||||
|
||||
void RumbleManager_Destroy(RumbleManager* rumbleMgr) {
|
||||
}
|
||||
+4
-2
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "z64load.h"
|
||||
#include "z64rumble.h"
|
||||
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
|
||||
#include "overlays/actors/ovl_En_Part/z_en_part.h"
|
||||
#include "overlays/actors/ovl_En_Box/z_en_box.h"
|
||||
@@ -3793,11 +3794,12 @@ void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed) {
|
||||
Quake_SetCountdown(idx, countdown);
|
||||
}
|
||||
|
||||
// Actor_RequestRumble?
|
||||
void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) {
|
||||
if (y >= 5) {
|
||||
func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150);
|
||||
Rumble_Request(actor->xyzDistToPlayerSq, 255, 20, 150);
|
||||
} else {
|
||||
func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100);
|
||||
Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100);
|
||||
}
|
||||
func_800BC770(play, y, countdown);
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "z64rumble.h"
|
||||
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
|
||||
|
||||
void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx);
|
||||
@@ -505,14 +506,14 @@ void Cutscene_Command_Rumble(PlayState* play, CutsceneContext* csCtx, CsCmdRumbl
|
||||
switch (cmd->type) {
|
||||
case 1:
|
||||
if (csCtx->frames == cmd->startFrame) {
|
||||
func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8);
|
||||
Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) {
|
||||
if ((csCtx->frames == cmd->startFrame) || (play->state.frames % 64 == 0)) {
|
||||
func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8);
|
||||
Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "z64rumble.h"
|
||||
|
||||
void GameOver_Init(PlayState* play) {
|
||||
play->gameOverCtx.state = GAMEOVER_INACTIVE;
|
||||
@@ -62,7 +63,7 @@ void GameOver_Update(PlayState* play) {
|
||||
gSaveContext.unk_3F24 = 0;
|
||||
Kankyo_InitGameOverLights(play);
|
||||
sGameOverTimer = 20;
|
||||
func_8013ECE0(0.0f, 126, 124, 63);
|
||||
Rumble_Request(0.0f, 126, 124, 63);
|
||||
gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND;
|
||||
break;
|
||||
case GAMEOVER_DEATH_FADE_OUT:
|
||||
@@ -78,7 +79,7 @@ void GameOver_Update(PlayState* play) {
|
||||
gSaveContext.save.playerForm = PLAYER_FORM_HUMAN;
|
||||
gSaveContext.save.equippedMask = PLAYER_MASK_NONE;
|
||||
}
|
||||
func_8013EE24();
|
||||
Rumble_StateReset();
|
||||
}
|
||||
break;
|
||||
case GAMEOVER_REVIVE_START:
|
||||
@@ -90,7 +91,7 @@ void GameOver_Update(PlayState* play) {
|
||||
case GAMEOVER_REVIVE_RUMBLE:
|
||||
sGameOverTimer = 50;
|
||||
gameOverCtx->state++;
|
||||
func_8013ECE0(0.0f, 126, 124, 63);
|
||||
Rumble_Request(0.0f, 126, 124, 63);
|
||||
break;
|
||||
case GAMEOVER_REVIVE_WAIT_GROUND:
|
||||
sGameOverTimer--;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "z64rumble.h"
|
||||
#include "overlays/gamestates/ovl_file_choose/z_file_choose.h"
|
||||
|
||||
s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 };
|
||||
@@ -9,7 +10,7 @@ void func_800F4A10(PlayState* play) {
|
||||
PauseContext* pauseCtx = &play->pauseCtx;
|
||||
s16 i;
|
||||
|
||||
func_8013EE24();
|
||||
Rumble_StateReset();
|
||||
|
||||
pauseCtx->unk_206 = 0;
|
||||
pauseCtx->unk_200 = 1;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "interface/parameter_static/parameter_static.h"
|
||||
#include "prevent_bss_reordering.h"
|
||||
|
||||
s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } };
|
||||
s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } };
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* File: z_rumble.c
|
||||
* Description: Rumble request system
|
||||
*
|
||||
* Provides a simple interface to allow scheduling up to RUMBLE_REQUEST_BUFFER_SIZE rumble requests to the RumblePak.
|
||||
* There's an additional Override type of rumble request for requests which should take priorities over any other
|
||||
* scheduled request.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "z64rumble.h"
|
||||
|
||||
RumbleManager gRumbleMgr;
|
||||
|
||||
void Rumble_Update(void* arg0) {
|
||||
RumbleManager_Update(&gRumbleMgr);
|
||||
PadMgr_RumbleSet(gRumbleMgr.rumbleEnabled);
|
||||
}
|
||||
|
||||
// Used by some bosses (and fishing)
|
||||
void Rumble_Override(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) {
|
||||
s32 intensity;
|
||||
s32 distance;
|
||||
|
||||
if (SQ(1000.0f) < distSq) {
|
||||
distance = 1000;
|
||||
} else {
|
||||
distance = sqrtf(distSq);
|
||||
}
|
||||
|
||||
if ((distance < 1000) && (sourceIntensity != 0) && (decayStep != 0)) {
|
||||
intensity = sourceIntensity - (distance * 255) / 1000;
|
||||
|
||||
if (intensity > 0) {
|
||||
gRumbleMgr.overrideIntensity = intensity;
|
||||
gRumbleMgr.overrideDecayTimer = decayTimer;
|
||||
gRumbleMgr.overrideDecayStep = decayStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) {
|
||||
s32 intensity;
|
||||
s32 distance;
|
||||
s32 i;
|
||||
|
||||
if (SQ(1000.0f) < distSq) {
|
||||
distance = 1000;
|
||||
} else {
|
||||
distance = sqrtf(distSq);
|
||||
}
|
||||
|
||||
if ((distance < 1000) && (sourceIntensity != 0) && (decayStep != 0)) {
|
||||
intensity = sourceIntensity - (distance * 255) / 1000;
|
||||
|
||||
for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
|
||||
if (gRumbleMgr.requestIntensities[i] == 0) {
|
||||
if (intensity > 0) {
|
||||
gRumbleMgr.requestIntensities[i] = intensity;
|
||||
gRumbleMgr.requestDecayTimers[i] = decayTimer;
|
||||
gRumbleMgr.requestDecaySteps[i] = decayStep;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rumble_Init(void) {
|
||||
RumbleManager_Init(&gRumbleMgr);
|
||||
func_80174F24(Rumble_Update, NULL);
|
||||
}
|
||||
|
||||
void Rumble_Destroy(void) {
|
||||
func_80174F44(Rumble_Update, NULL);
|
||||
RumbleManager_Destroy(&gRumbleMgr);
|
||||
}
|
||||
|
||||
s32 Rumble_ControllerOneHasRumblePak(void) {
|
||||
return PadMgr_ControllerHasRumblePak(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wipes every old request for a fresh start, then proceeds to process them as normal
|
||||
*/
|
||||
void Rumble_StateReset(void) {
|
||||
gRumbleMgr.state = RUMBLEMANAGER_STATE_INITIAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the state of the manager to WIPE
|
||||
*
|
||||
* In this state, every request is deleted
|
||||
*/
|
||||
void Rumble_StateWipeRequests(void) {
|
||||
gRumbleMgr.state = RUMBLEMANAGER_STATE_WIPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request processing is paused if updateEnabled is set to false
|
||||
*/
|
||||
void Rumble_SetUpdateEnabled(s32 updateEnabled) {
|
||||
gRumbleMgr.updateEnabled = !!updateEnabled;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "z_bg_f40_switch.h"
|
||||
#include "z64rumble.h"
|
||||
#include "objects/object_f40_switch/object_f40_switch.h"
|
||||
|
||||
#define FLAGS (ACTOR_FLAG_10)
|
||||
@@ -144,7 +145,7 @@ void BgF40Switch_Press(BgF40Switch* this, PlayState* play) {
|
||||
this->dyna.actor.scale.y -= 0.0495f;
|
||||
if (this->dyna.actor.scale.y <= 0.0165f) {
|
||||
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH);
|
||||
func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10);
|
||||
Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10);
|
||||
if (this->isInitiator) {
|
||||
ActorCutscene_Stop(this->dyna.actor.cutscene);
|
||||
this->isInitiator = false;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "z_bg_hakugin_post.h"
|
||||
#include "z64rumble.h"
|
||||
#include "objects/object_hakugin_obj/object_hakugin_obj.h"
|
||||
#include "prevent_bss_reordering.h"
|
||||
|
||||
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)
|
||||
|
||||
@@ -519,7 +519,7 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct*
|
||||
sp44.x = this->dyna.actor.home.pos.x + unkStruct1->unk_14.x;
|
||||
sp44.y = this->unk_16C + unkStruct1->unk_14.y;
|
||||
sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z;
|
||||
func_8013ECE0(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150);
|
||||
Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150);
|
||||
quake = Quake_Add(GET_ACTIVE_CAM(play), 3);
|
||||
Quake_SetSpeed(quake, 20000);
|
||||
Quake_SetQuakeValues(quake, 7, 0, 0, 0);
|
||||
@@ -540,9 +540,9 @@ void func_80A9C18C(BgHakuginPost* this, PlayState* play) {
|
||||
Camera* activeCam = GET_ACTIVE_CAM(play);
|
||||
s16 quake;
|
||||
|
||||
func_8013ECE0(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z,
|
||||
this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z),
|
||||
255, 20, 150);
|
||||
Rumble_Request(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z,
|
||||
this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z),
|
||||
255, 20, 150);
|
||||
quake = Quake_Add(activeCam, 3);
|
||||
Quake_SetSpeed(quake, 17232);
|
||||
Quake_SetQuakeValues(quake, 6, 0, 0, 0);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user