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:
Anghelo Carvajal
2022-06-29 22:08:03 +01:00
committed by GitHub
co-authored by Derek Hensley engineer124 Dragorn421 EllipticEllipsis EllipticEllipsis
parent 158d1b26b0
commit 45eed680d6
56 changed files with 509 additions and 204 deletions
+8 -20
View File
@@ -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
View File
@@ -1,5 +1,5 @@
#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#ifndef GLOBAL_H
#define GLOBAL_H
#include "z64.h"
#include "regs.h"
+1 -6
View File
@@ -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;
+3 -3
View File
@@ -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
+2 -2
View File
@@ -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) }
/**
+46
View File
@@ -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