mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
Decompile padmgr.c (#1246)
* Decompile padmgr.c * Format * Enum names * Update namefixer * Suggested changes Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> * Suggested changes, improve motor.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> * Further suggested changes * Format * Fix `controller.h` comment Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --------- Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
This commit is contained in:
co-authored by
Anghelo Carvajal
Derek Hensley
engineer124
parent
22af2bb8fe
commit
6d20839ab0
+2
-30
@@ -328,7 +328,7 @@ OSTime osGetTime(void);
|
||||
void guRotateF(float m[4][4], f32 a, f32 x, f32 y, f32 z);
|
||||
void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z);
|
||||
void __osSetGlobalIntMask(u32 mask);
|
||||
// void osVoiceInit(void);
|
||||
s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* handle, s32 channel);
|
||||
s32 __osContChannelReset(OSMesgQueue* mq, s32 channel);
|
||||
// void __osVoiceSetADConverter(void);
|
||||
s32 osAiSetFrequency(u32 frequency);
|
||||
@@ -2098,34 +2098,6 @@ ListAlloc* ListAlloc_Init(ListAlloc* this);
|
||||
// void ListAlloc_Free(void);
|
||||
void ListAlloc_FreeAll(ListAlloc* this);
|
||||
void Main(void* arg);
|
||||
u32 Padmgr_GetControllerBitmask(void);
|
||||
void func_80174F24(void (*arg0)(void*), void* arg1);
|
||||
void func_80174F44(void (*arg0)(void*), void* arg1);
|
||||
void func_80174F7C(void (*arg0)(s32), void* arg1);
|
||||
void func_80174F9C(void (*arg0)(s32), void* arg1);
|
||||
// OSMesgQueue* Padmgr_GetEventCallback(void);
|
||||
// void func_80175008(void);
|
||||
void Padmgr_SetEventCallback(OSMesg pvParm1);
|
||||
// void func_8017506C(void);
|
||||
// void Padmgr_Lock(void);
|
||||
// void Padmgr_Unlock(void);
|
||||
// void func_801750FC(void);
|
||||
// void func_80175364(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);
|
||||
// void func_80175AE0(void);
|
||||
// void Padmgr_Update(void);
|
||||
// void Padmgr_Stop(void);
|
||||
void func_80175E68(Input* input, s32 param_2);
|
||||
void Padmgr_GetInput(Input* input, s32 param_2);
|
||||
void Padmgr_GetInput2(Input* input, s32 param_2);
|
||||
void Padmgr_ThreadEntry(PadMgr* padmgr);
|
||||
void PadMgr_Init(OSMesgQueue* siEventCallbackQueue, IrqMgr* irqmgr, OSId threadId, OSPri threadPri, void* stack);
|
||||
void Sched_SwapFramebuffer(CfbInfo* cfbInfo);
|
||||
void Sched_RetraceUpdateFramebuffer(SchedContext* sched, CfbInfo* cfbInfo);
|
||||
void Sched_HandleReset(SchedContext* sched);
|
||||
@@ -2614,7 +2586,7 @@ void Audio_ResetForAudioHeapStep3(void);
|
||||
void Audio_ResetForAudioHeapStep2(void);
|
||||
void Audio_ResetForAudioHeapStep1(s32 specId);
|
||||
|
||||
// void func_801A4EB0(void);
|
||||
void func_801A4EB0(void);
|
||||
// void func_801A4EB8(void);
|
||||
void func_801A4FD8(void);
|
||||
void func_801A5080(u16 arg0);
|
||||
|
||||
+69
-11
@@ -35,10 +35,6 @@
|
||||
#define CONT_CMD_WRITE_EEPROM_RX 1
|
||||
#define CONT_CMD_RESET_RX 3
|
||||
|
||||
#define CONT_CMD_NOP 0xFF
|
||||
#define CONT_CMD_END 0xFE // Indicates end of a command
|
||||
#define CONT_CMD_EXE 1 // Set pif ram status byte to this to do a command
|
||||
|
||||
#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */
|
||||
#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */
|
||||
#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */
|
||||
@@ -48,6 +44,52 @@
|
||||
#define CONT_ERR_VOICE_WORD 14
|
||||
#define CONT_ERR_VOICE_NO_RESPONSE 15
|
||||
|
||||
// Joybus commands
|
||||
#define CONT_CMD_REQUEST_STATUS 0
|
||||
#define CONT_CMD_READ_BUTTON 1
|
||||
#define CONT_CMD_READ_PAK 2
|
||||
#define CONT_CMD_WRITE_PAK 3
|
||||
#define CONT_CMD_READ_EEPROM 4
|
||||
#define CONT_CMD_WRITE_EEPROM 5
|
||||
#define CONT_CMD_READ36_VOICE 9
|
||||
#define CONT_CMD_WRITE20_VOICE 10
|
||||
#define CONT_CMD_READ2_VOICE 11
|
||||
#define CONT_CMD_WRITE4_VOICE 12
|
||||
#define CONT_CMD_SWRITE_VOICE 13
|
||||
#define CONT_CMD_CHANNEL_RESET 0xFD
|
||||
#define CONT_CMD_RESET 0xFF
|
||||
|
||||
// Bytes transmitted for each joybus command
|
||||
#define CONT_CMD_REQUEST_STATUS_TX 1
|
||||
#define CONT_CMD_READ_BUTTON_TX 1
|
||||
#define CONT_CMD_READ_PAK_TX 3
|
||||
#define CONT_CMD_WRITE_PAK_TX 35
|
||||
#define CONT_CMD_READ_EEPROM_TX 2
|
||||
#define CONT_CMD_WRITE_EEPROM_TX 10
|
||||
#define CONT_CMD_READ36_VOICE_TX 3
|
||||
#define CONT_CMD_WRITE20_VOICE_TX 23
|
||||
#define CONT_CMD_READ2_VOICE_TX 3
|
||||
#define CONT_CMD_WRITE4_VOICE_TX 7
|
||||
#define CONT_CMD_SWRITE_VOICE_TX 3
|
||||
#define CONT_CMD_RESET_TX 1
|
||||
|
||||
// Bytes received for each joybus command
|
||||
#define CONT_CMD_REQUEST_STATUS_RX 3
|
||||
#define CONT_CMD_READ_BUTTON_RX 4
|
||||
#define CONT_CMD_READ_PAK_RX 33
|
||||
#define CONT_CMD_WRITE_PAK_RX 1
|
||||
#define CONT_CMD_READ_EEPROM_RX 8
|
||||
#define CONT_CMD_WRITE_EEPROM_RX 1
|
||||
#define CONT_CMD_READ36_VOICE_RX 37
|
||||
#define CONT_CMD_WRITE20_VOICE_RX 1
|
||||
#define CONT_CMD_READ2_VOICE_RX 3
|
||||
#define CONT_CMD_WRITE4_VOICE_RX 1
|
||||
#define CONT_CMD_SWRITE_VOICE_RX 1
|
||||
#define CONT_CMD_RESET_RX 3
|
||||
|
||||
#define CONT_CMD_NOP 0xFF
|
||||
#define CONT_CMD_END 0xFE // Indicates end of a command
|
||||
#define CONT_CMD_EXE 1 // Set pif ram status byte to this to do a command
|
||||
|
||||
#define DIR_STATUS_EMPTY 0
|
||||
#define DIR_STATUS_UNKNOWN 1
|
||||
@@ -81,6 +123,26 @@
|
||||
#define CONT_ADDR_CRC_ER 0x04
|
||||
#define CONT_EEPROM_BUSY 0x80
|
||||
|
||||
// Accessory detection
|
||||
#define CONT_ADDR_DETECT 0x8000
|
||||
// Rumble
|
||||
#define CONT_ADDR_RUMBLE 0xC000
|
||||
// Controller Pak
|
||||
// Transfer Pak
|
||||
#define CONT_ADDR_GB_POWER 0x8000 // Same as the detection address, but semantically different
|
||||
#define CONT_ADDR_GB_BANK 0xA000
|
||||
#define CONT_ADDR_GB_STATUS 0xB000
|
||||
|
||||
// Addresses sent to controller accessories are in blocks, not bytes
|
||||
#define CONT_BLOCKS(x) ((x) / BLOCKSIZE)
|
||||
|
||||
// Block addresses of the above
|
||||
#define CONT_BLOCK_DETECT CONT_BLOCKS(CONT_ADDR_DETECT)
|
||||
#define CONT_BLOCK_RUMBLE CONT_BLOCKS(CONT_ADDR_RUMBLE)
|
||||
#define CONT_BLOCK_GB_POWER CONT_BLOCKS(CONT_ADDR_GB_POWER)
|
||||
#define CONT_BLOCK_GB_BANK CONT_BLOCKS(CONT_ADDR_GB_BANK)
|
||||
#define CONT_BLOCK_GB_STATUS CONT_BLOCKS(CONT_ADDR_GB_STATUS)
|
||||
|
||||
/* Buttons */
|
||||
#define BTN_CRIGHT 0x0001
|
||||
#define BTN_CLEFT 0x0002
|
||||
@@ -88,6 +150,7 @@
|
||||
#define BTN_CUP 0x0008
|
||||
#define BTN_R 0x0010
|
||||
#define BTN_L 0x0020
|
||||
#define BTN_RESET 0x0080
|
||||
#define BTN_DRIGHT 0x0100
|
||||
#define BTN_DLEFT 0x0200
|
||||
#define BTN_DDOWN 0x0400
|
||||
@@ -146,6 +209,8 @@ typedef struct {
|
||||
/* 0x26 */ u8 datacrc;
|
||||
} __OSContRamReadFormat;
|
||||
|
||||
#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr))
|
||||
|
||||
extern OSPifRam __osContPifRam;
|
||||
// extern UNK_TYPE1 D_8009CF0C;
|
||||
extern u8 __osContLastPoll;
|
||||
@@ -153,11 +218,4 @@ extern u8 __osMaxControllers;
|
||||
// extern OSMesgQueue D_8009CF38;
|
||||
// extern OSMesg D_8009CF50;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ OSContPad cur;
|
||||
/* 0x06 */ OSContPad prev;
|
||||
/* 0x0C */ OSContPad press; // X/Y store delta from last frame
|
||||
/* 0x12 */ OSContPad rel; // X/Y store adjusted
|
||||
} Input; // size = 0x18
|
||||
|
||||
#endif
|
||||
|
||||
+7
-2
@@ -1,9 +1,14 @@
|
||||
#ifndef IRQMGR_H
|
||||
#define IRQMGR_H
|
||||
|
||||
#include "PR/ultratypes.h"
|
||||
#include "PR/sched.h"
|
||||
#include "ultra64/message.h"
|
||||
#include "os.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
#define OS_SC_RETRACE_MSG 1
|
||||
#define OS_SC_DONE_MSG 2
|
||||
#define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c
|
||||
#define OS_SC_PRE_NMI_MSG 4
|
||||
|
||||
typedef struct IrqMgrClient {
|
||||
/* 0x0 */ struct IrqMgrClient* next;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#ifndef PADMGR_H
|
||||
#define PADMGR_H
|
||||
|
||||
#include "libc/stdbool.h"
|
||||
#include "io/controller.h"
|
||||
#include "irqmgr.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ OSContPad cur;
|
||||
/* 0x06 */ OSContPad prev;
|
||||
/* 0x0C */ OSContPad press; // X/Y store delta from last frame
|
||||
/* 0x12 */ OSContPad rel; // X/Y store adjusted
|
||||
} Input; // size = 0x18
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ PADMGR_CONT_NONE,
|
||||
/* 1 */ PADMGR_CONT_NORMAL,
|
||||
/* 3 */ PADMGR_CONT_MOUSE = 3,
|
||||
/* 4 */ PADMGR_CONT_VOICE_PLUGGED, // VRU plugged but not initialized
|
||||
/* 5 */ PADMGR_CONT_VOICE,
|
||||
/* -1 */ PADMGR_CONT_UNK = 0xFF
|
||||
} ControllerDeviceType;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ CONT_PAK_NONE,
|
||||
/* 1 */ CONT_PAK_RUMBLE,
|
||||
/* 2 */ CONT_PAK_OTHER
|
||||
} ControllerPakType;
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ u8 validCtrlrsMask;
|
||||
/* 0x004 */ void (*rumbleRetraceCallback)(void*);
|
||||
/* 0x008 */ void* rumbleRetraceArg;
|
||||
/* 0x00C */ void (*inputRetraceCallback)(void*);
|
||||
/* 0x010 */ void* inputRetraceArg;
|
||||
/* 0x014 */ OSContStatus padStatus[MAXCONTROLLERS];
|
||||
/* 0x024 */ OSMesg serialMsg;
|
||||
/* 0x028 */ OSMesg lockMsg;
|
||||
/* 0x02C */ OSMesg interruptMsgBuf[8];
|
||||
/* 0x04C */ OSMesgQueue serialLockQueue;
|
||||
/* 0x064 */ OSMesgQueue lockQueue;
|
||||
/* 0x07C */ OSMesgQueue interruptQueue;
|
||||
/* 0x094 */ IrqMgrClient irqClient;
|
||||
/* 0x09C */ IrqMgr* irqMgr;
|
||||
/* 0x0A0 */ OSThread thread;
|
||||
/* 0x250 */ Input inputs[MAXCONTROLLERS];
|
||||
/* 0x2B0 */ OSContPad pads[MAXCONTROLLERS];
|
||||
/* 0x2C8 */ u8 nControllers;
|
||||
/* 0x2C9 */ u8 ctrlrType[MAXCONTROLLERS]; // type of controller currently connected to each port
|
||||
/* 0x2CD */ u8 pakType[MAXCONTROLLERS]; // type of controller pak for each port (if applicable)
|
||||
/* 0x2D1 */ u8 rumbleEnable[MAXCONTROLLERS]; // whether rumble is active for each port
|
||||
/* 0x2D5 */ u8 rumbleTimer[MAXCONTROLLERS];
|
||||
/* 0x2DC */ OSPfs rumblePfs[MAXCONTROLLERS];
|
||||
/* 0x47C */ vu8 rumbleOffTimer; // amount of VI retraces to not rumble for, takes priority over rumbleOnTimer
|
||||
/* 0x47D */ vu8 rumbleOnTimer; // amount of VI retraces to rumble for
|
||||
/* 0x47E */ u8 isResetting;
|
||||
} PadMgr; // size = 0x480
|
||||
|
||||
extern PadMgr gPadMgr;
|
||||
|
||||
// Initialization
|
||||
|
||||
s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status);
|
||||
void PadMgr_Init(OSMesgQueue* siEvtQ, IrqMgr* irqMgr, OSId threadId, OSPri pri, void* stack);
|
||||
|
||||
// Fetching inputs
|
||||
|
||||
void PadMgr_GetInputNoLock(Input* inputs, s32 gameRequest);
|
||||
void PadMgr_GetInput(Input* inputs, s32 gameRequest);
|
||||
void PadMgr_GetInput2(Input* inputs, s32 gameRequest);
|
||||
|
||||
// Callbacks
|
||||
|
||||
void PadMgr_SetRumbleRetraceCallback(void (*callback)(void*), void* arg);
|
||||
void PadMgr_UnsetRumbleRetraceCallback(void (*callback)(void*), void* arg);
|
||||
|
||||
void PadMgr_SetInputRetraceCallback(void (*callback)(void*), void* arg);
|
||||
void PadMgr_UnsetInputRetraceCallback(void (*callback)(void*), void* arg);
|
||||
|
||||
// Valid controllers
|
||||
|
||||
u8 PadMgr_GetValidControllersMask(void);
|
||||
|
||||
// Voice queue
|
||||
|
||||
OSMesgQueue* PadMgr_VoiceAcquireSerialEventQueue(void);
|
||||
void PadMgr_VoiceReleaseSerialEventQueue(OSMesgQueue* serialEventQueue);
|
||||
|
||||
// Rumble
|
||||
|
||||
void PadMgr_RumbleStop(void);
|
||||
void PadMgr_RumblePause(void);
|
||||
void PadMgr_RumbleSetSingle(s32 port, s32 enable);
|
||||
void PadMgr_RumbleSet(u8 enable[MAXCONTROLLERS]);
|
||||
s32 PadMgr_ControllerHasRumblePak(s32 port);
|
||||
|
||||
#endif
|
||||
@@ -5,13 +5,14 @@
|
||||
#include "PR/pfs.h"
|
||||
#include "ultra64/message.h"
|
||||
|
||||
#define MOTOR_START 1
|
||||
#define MOTOR_STOP 0
|
||||
#define MOTOR_START 1
|
||||
#define MOTOR_STOP 0
|
||||
|
||||
#define osMotorStart(x) __osMotorAccess((x), MOTOR_START)
|
||||
#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP)
|
||||
#define osMotorStart(x) __osMotorAccess((x), MOTOR_START)
|
||||
#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP)
|
||||
|
||||
s32 __osMotorAccess(OSPfs* pfs, u32 vibrate);
|
||||
s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel);
|
||||
s32 __osMotorAccess(OSPfs* pfs, s32 flag);
|
||||
|
||||
s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, s32 channel);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,4 +11,12 @@
|
||||
#define DEVICE_TYPE_SRAM 3 /* SRAM */
|
||||
#define DEVICE_TYPE_INIT 7 /* initial value */
|
||||
|
||||
|
||||
#define CHNL_ERR_NORESP 0x80 /* Bit 7 (Rx): No response error */
|
||||
#define CHNL_ERR_OVERRUN 0x40 /* Bit 6 (Rx): Overrun error */
|
||||
#define CHNL_ERR_FRAME 0x80 /* Bit 7 (Tx): Frame error */
|
||||
#define CHNL_ERR_COLLISION 0x40 /* Bit 6 (Tx): Collision error */
|
||||
|
||||
#define CHNL_ERR_MASK 0xC0 /* Bit 6-7: channel errors */
|
||||
|
||||
#endif
|
||||
|
||||
+1
-5
@@ -795,9 +795,6 @@ extern u32 cfbIdx[3];
|
||||
extern s32 gScreenWidth;
|
||||
extern s32 gScreenHeight;
|
||||
extern u32 startHeapSize;
|
||||
extern PadMgr* padmgrContext;
|
||||
// extern UNK_TYPE4 controllerInputsCaptured;
|
||||
// extern UNK_TYPE4 D_801D1538;
|
||||
extern UNK_PTR D_801D1540;
|
||||
// extern f32 sFactorialTbl[13];
|
||||
extern Vec3f gZeroVec3f;
|
||||
@@ -2410,7 +2407,6 @@ extern u32 gSegments[NUM_SEGMENTS];
|
||||
extern SchedContext gSchedContext;
|
||||
|
||||
extern OSThread gGraphThread;
|
||||
extern PadMgr gPadMgr;
|
||||
|
||||
extern FaultClient sSchedFaultClient;
|
||||
extern OSTime sRSPGFXStartTime;
|
||||
@@ -2616,7 +2612,7 @@ extern s32 D_801FD120;
|
||||
// extern UNK_TYPE1 D_801FD598;
|
||||
// extern UNK_TYPE1 D_801FD5A0;
|
||||
// extern UNK_TYPE1 D_801FD5A4;
|
||||
// extern UNK_TYPE1 D_801FD5B8;
|
||||
extern OSVoiceHandle gVoiceHandle;
|
||||
// extern UNK_TYPE1 D_801FD5C4;
|
||||
// extern UNK_TYPE1 D_801FD5C8;
|
||||
// extern UNK_TYPE1 D_801FD5E8;
|
||||
|
||||
+3
-30
@@ -14,6 +14,7 @@
|
||||
#include "osint.h"
|
||||
#include "os.h"
|
||||
#include "irqmgr.h"
|
||||
#include "padmgr.h"
|
||||
#include "scheduler.h"
|
||||
#include "xstdio.h"
|
||||
|
||||
@@ -481,7 +482,7 @@ typedef struct {
|
||||
/* 0x7D8 */ FaultClient* clients;
|
||||
/* 0x7DC */ FaultAddrConvClient* addrConvClients;
|
||||
/* 0x7E0 */ UNK_TYPE1 pad7E0[0x4];
|
||||
/* 0x7E4 */ Input padInput[4];
|
||||
/* 0x7E4 */ Input padInput[MAXCONTROLLERS];
|
||||
/* 0x844 */ void* fb;
|
||||
} FaultThreadStruct; // size = 0x848
|
||||
|
||||
@@ -522,7 +523,7 @@ typedef struct GameState {
|
||||
/* 0x08 */ GameStateFunc destroy;
|
||||
/* 0x0C */ GameStateFunc init; // Usually the current game state's init, though after stopping, the graph thread will look here to determine the next game state to load.
|
||||
/* 0x10 */ size_t size;
|
||||
/* 0x14 */ Input input[4];
|
||||
/* 0x14 */ Input input[MAXCONTROLLERS];
|
||||
/* 0x74 */ TwoHeadArena heap;
|
||||
/* 0x84 */ GameAlloc alloc;
|
||||
/* 0x98 */ UNK_TYPE1 pad98[0x3];
|
||||
@@ -541,34 +542,6 @@ typedef void (*ColChkApplyFunc)(struct PlayState*, CollisionCheckContext*, Colli
|
||||
typedef void (*ColChkVsFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Collider*);
|
||||
typedef s32 (*ColChkLineFunc)(struct PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*);
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc.
|
||||
/* 0x001 */ UNK_TYPE1 pad1[0x13];
|
||||
/* 0x014 */ OSContStatus statuses[4];
|
||||
/* 0x024 */ UNK_TYPE4 unk24;
|
||||
/* 0x028 */ OSMesg lockMesg[1];
|
||||
/* 0x02C */ OSMesg interrupts[8];
|
||||
/* 0x04C */ OSMesgQueue sSiIntMsgQ;
|
||||
/* 0x064 */ OSMesgQueue lock;
|
||||
/* 0x07C */ OSMesgQueue irqmgrCallbackQueue;
|
||||
/* 0x094 */ IrqMgrClient irqmgrCallbackQueueNode;
|
||||
/* 0x09C */ IrqMgr* irqmgr;
|
||||
/* 0x0A0 */ OSThread thread;
|
||||
/* 0x250 */ Input input[4];
|
||||
/* 0x2B0 */ OSContPad controllerState1[4];
|
||||
/* 0x2C8 */ u8 maxNumControllers;
|
||||
/* 0x2C9 */ UNK_TYPE1 pad2C9[0x1B3];
|
||||
/* 0x47C */ u8 unk47C;
|
||||
/* 0x47D */ u8 unk47D;
|
||||
/* 0x47E */ u8 hasStopped;
|
||||
/* 0x47F */ UNK_TYPE1 pad47F[0x1];
|
||||
} PadMgr; // size = 0x480
|
||||
|
||||
#define OS_SC_RETRACE_MSG 1
|
||||
#define OS_SC_DONE_MSG 2
|
||||
#define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c
|
||||
#define OS_SC_PRE_NMI_MSG 4
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ IrqMgr* irqMgr;
|
||||
/* 0x004 */ SchedContext* sched;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#ifndef Z64FRAMEADVANCE_H
|
||||
#define Z64FRAMEADVANCE_H
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "io/controller.h"
|
||||
#include "padmgr.h"
|
||||
|
||||
typedef struct FrameAdvanceContext {
|
||||
/* 0x0 */ s32 enabled;
|
||||
|
||||
@@ -567,7 +567,6 @@ beginseg
|
||||
include "build/data/code/main.data.o"
|
||||
include "build/data/code/main.bss.o"
|
||||
include "build/src/code/padmgr.o"
|
||||
include "build/data/code/padmgr.data.o"
|
||||
include "build/src/code/sched.o"
|
||||
include "build/src/code/speed_meter.o"
|
||||
include "build/data/code/speed_meter.data.o"
|
||||
|
||||
@@ -2058,11 +2058,11 @@ const char sAudioOcarinaUnusedText6[] = "last key step is too short !!! %d:%d %d
|
||||
const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n";
|
||||
|
||||
void AudioOcarina_ReadControllerInput(void) {
|
||||
Input inputs[4];
|
||||
Input inputs[MAXCONTROLLERS];
|
||||
Input* input = &inputs[0];
|
||||
u32 ocarinaInputButtonPrev = sOcarinaInputButtonCur;
|
||||
|
||||
Padmgr_GetInput2(inputs, 0);
|
||||
PadMgr_GetInput2(inputs, false);
|
||||
sOcarinaInputButtonCur = input->cur.button;
|
||||
sOcarinaInputButtonPrev = ocarinaInputButtonPrev;
|
||||
sOcarinaInputStickRel.x = input->rel.stick_x;
|
||||
|
||||
@@ -204,7 +204,7 @@ void Fault_Sleep(u32 duration) {
|
||||
}
|
||||
|
||||
void Fault_PadCallback(Input* input) {
|
||||
Padmgr_GetInput2(input, 0);
|
||||
PadMgr_GetInput2(input, false);
|
||||
}
|
||||
|
||||
void Fault_UpdatePadImpl() {
|
||||
@@ -474,7 +474,7 @@ void Fault_WaitForButtonCombo(void) {
|
||||
do {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
} while (!CHECK_BTN_ALL(input->press.button, 0x80));
|
||||
} while (!CHECK_BTN_ALL(input->press.button, BTN_RESET));
|
||||
} while (!CHECK_BTN_ALL(input->cur.button, BTN_DLEFT | BTN_L | BTN_R | BTN_CRIGHT));
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ void Fault_SetOptionsFromController3(void) {
|
||||
u32 graphRA;
|
||||
u32 graphSP;
|
||||
|
||||
if (CHECK_BTN_ALL(input3->press.button, 0x80)) {
|
||||
if (CHECK_BTN_ALL(input3->press.button, BTN_RESET)) {
|
||||
faultCustomOptions = !faultCustomOptions;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ void func_801736DC(GraphicsContext* gfxCtx) {
|
||||
}
|
||||
|
||||
void Game_UpdateInput(GameState* gameState) {
|
||||
Padmgr_GetInput(gameState->input, 1);
|
||||
PadMgr_GetInput(gameState->input, true);
|
||||
}
|
||||
|
||||
void Game_Update(GameState* gameState) {
|
||||
|
||||
@@ -26,7 +26,6 @@ extern StackEntry sSchedStackInfo;
|
||||
extern StackEntry sAudioStackInfo;
|
||||
extern StackEntry sPadMgrStackInfo;
|
||||
extern AudioMgr sAudioMgr;
|
||||
extern PadMgr gPadMgr;
|
||||
|
||||
void Main(void* arg) {
|
||||
intptr_t fb;
|
||||
|
||||
+767
-28
File diff suppressed because it is too large
Load Diff
@@ -24,12 +24,12 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) {
|
||||
|
||||
if (D_801D1E70) {
|
||||
for (i = 0; i < MAXCONTROLLERS; i++) {
|
||||
func_8017544C(i, false);
|
||||
PadMgr_RumbleSetSingle(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
D_801D1E70 = rumbleMgr->updateEnabled;
|
||||
func_80175434();
|
||||
PadMgr_RumblePause();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) {
|
||||
// Start up the manager by wiping old requests
|
||||
if (rumbleMgr->state == RUMBLEMANAGER_STATE_INITIAL) {
|
||||
for (i = 0; i < MAXCONTROLLERS; i++) {
|
||||
func_8017544C(i, false);
|
||||
PadMgr_RumbleSetSingle(i, false);
|
||||
}
|
||||
|
||||
for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
|
||||
@@ -59,7 +59,7 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) {
|
||||
|
||||
rumbleMgr->state = RUMBLEMANAGER_STATE_RUNNING;
|
||||
|
||||
func_80175434();
|
||||
PadMgr_RumblePause();
|
||||
}
|
||||
|
||||
if (rumbleMgr->state != RUMBLEMANAGER_STATE_WIPE) {
|
||||
@@ -146,7 +146,7 @@ void RumbleManager_Update(RumbleManager* rumbleMgr) {
|
||||
rumbleMgr->overrideDecayStep = 0;
|
||||
rumbleMgr->overrideAccumulator = 0;
|
||||
|
||||
func_80175434();
|
||||
PadMgr_RumblePause();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct {
|
||||
/* 0x03 */ u8 flags3;
|
||||
} RestrictionFlags;
|
||||
|
||||
Input sPostmanTimerInput[4];
|
||||
Input sPostmanTimerInput[MAXCONTROLLERS];
|
||||
|
||||
#define RESTRICTIONS_TABLE_END 0xFF
|
||||
|
||||
@@ -887,10 +887,10 @@ void Interface_SetVertices(PlayState* play) {
|
||||
|
||||
s32 sPostmanTimerInputBtnAPressed = false;
|
||||
|
||||
void Interface_PostmanTimerCallback(s32 arg0) {
|
||||
void Interface_PostmanTimerCallback(void* arg) {
|
||||
s32 btnAPressed;
|
||||
|
||||
func_80175E68(&sPostmanTimerInput[0], 0);
|
||||
PadMgr_GetInputNoLock(sPostmanTimerInput, false);
|
||||
btnAPressed = CHECK_BTN_ALL(sPostmanTimerInput[0].cur.button, BTN_A);
|
||||
if ((btnAPressed != sPostmanTimerInputBtnAPressed) && btnAPressed) {
|
||||
gSaveContext.postmanTimerStopOsTime = osGetTime();
|
||||
@@ -5654,7 +5654,7 @@ void Interface_DrawTimers(PlayState* play) {
|
||||
}
|
||||
gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_COUNTING;
|
||||
sPostmanTimerInputBtnAPressed = true;
|
||||
func_80174F7C(Interface_PostmanTimerCallback, NULL);
|
||||
PadMgr_SetInputRetraceCallback(Interface_PostmanTimerCallback, NULL);
|
||||
break;
|
||||
|
||||
case TIMER_STATE_POSTMAN_STOP:
|
||||
@@ -5663,7 +5663,7 @@ void Interface_DrawTimers(PlayState* play) {
|
||||
postmanTimerStopOsTime - ((void)0, gSaveContext.timerStartOsTimes[TIMER_ID_POSTMAN]) -
|
||||
((void)0, gSaveContext.timerPausedOsTimes[TIMER_ID_POSTMAN]));
|
||||
gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_END;
|
||||
func_80174F9C(Interface_PostmanTimerCallback, NULL);
|
||||
PadMgr_UnsetInputRetraceCallback(Interface_PostmanTimerCallback, NULL);
|
||||
break;
|
||||
|
||||
case TIMER_STATE_POSTMAN_COUNTING:
|
||||
@@ -7211,7 +7211,7 @@ void Interface_Update(PlayState* play) {
|
||||
|
||||
void Interface_Destroy(PlayState* play) {
|
||||
Map_Destroy(play);
|
||||
func_80174F9C(Interface_PostmanTimerCallback, NULL);
|
||||
PadMgr_UnsetInputRetraceCallback(Interface_PostmanTimerCallback, NULL);
|
||||
}
|
||||
|
||||
void Interface_Init(PlayState* play) {
|
||||
|
||||
+2
-2
@@ -68,11 +68,11 @@ void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep)
|
||||
|
||||
void Rumble_Init(void) {
|
||||
RumbleManager_Init(&gRumbleMgr);
|
||||
func_80174F24(Rumble_Update, NULL);
|
||||
PadMgr_SetRumbleRetraceCallback(Rumble_Update, NULL);
|
||||
}
|
||||
|
||||
void Rumble_Destroy(void) {
|
||||
func_80174F44(Rumble_Update, NULL);
|
||||
PadMgr_UnsetRumbleRetraceCallback(Rumble_Update, NULL);
|
||||
RumbleManager_Destroy(&gRumbleMgr);
|
||||
}
|
||||
|
||||
|
||||
+44
-45
@@ -6,40 +6,40 @@
|
||||
#define BANK_ADDR 0x400
|
||||
#define MOTOR_ID 0x80
|
||||
|
||||
OSPifRam osPifBuffers[MAXCONTROLLERS];
|
||||
OSPifRam __MotorDataBuf[MAXCONTROLLERS];
|
||||
|
||||
s32 __osPfsSelectBank(OSPfs* pfs, u8 bank);
|
||||
|
||||
s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) {
|
||||
s32 __osMotorAccess(OSPfs* pfs, s32 flag) {
|
||||
s32 i;
|
||||
s32 ret;
|
||||
u8* buf = (u8*)&osPifBuffers[pfs->channel];
|
||||
u8* ptr = (u8*)&__MotorDataBuf[pfs->channel];
|
||||
|
||||
if (!(pfs->status & 8)) {
|
||||
return 5;
|
||||
if (!(pfs->status & PFS_MOTOR_INITIALIZED)) {
|
||||
return PFS_ERR_INVALID;
|
||||
}
|
||||
|
||||
__osSiGetAccess();
|
||||
osPifBuffers[pfs->channel].status = 1;
|
||||
buf += pfs->channel;
|
||||
__MotorDataBuf[pfs->channel].status = CONT_CMD_EXE;
|
||||
ptr += pfs->channel;
|
||||
for (i = 0; i < BLOCKSIZE; i++) {
|
||||
((__OSContRamReadFormat*)buf)->data[i] = vibrate;
|
||||
READFORMAT(ptr)->data[i] = flag;
|
||||
}
|
||||
|
||||
__osContLastPoll = CONT_CMD_END;
|
||||
__osSiRawStartDma(OS_WRITE, &osPifBuffers[pfs->channel]);
|
||||
__osSiRawStartDma(OS_WRITE, &__MotorDataBuf[pfs->channel]);
|
||||
osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK);
|
||||
__osSiRawStartDma(OS_READ, &osPifBuffers[pfs->channel]);
|
||||
__osSiRawStartDma(OS_READ, &__MotorDataBuf[pfs->channel]);
|
||||
osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK);
|
||||
|
||||
ret = ((__OSContRamReadFormat*)buf)->rxsize & 0xC0;
|
||||
ret = READFORMAT(ptr)->rxsize & CHNL_ERR_MASK;
|
||||
if (!ret) {
|
||||
if (!vibrate) {
|
||||
if (((__OSContRamReadFormat*)buf)->datacrc != 0) {
|
||||
if (!flag) {
|
||||
if (READFORMAT(ptr)->datacrc != 0) {
|
||||
ret = PFS_ERR_CONTRFAIL;
|
||||
}
|
||||
} else {
|
||||
if (((__OSContRamReadFormat*)buf)->datacrc != 0xEB) {
|
||||
if (READFORMAT(ptr)->datacrc != 0xEB) {
|
||||
ret = PFS_ERR_CONTRFAIL;
|
||||
}
|
||||
}
|
||||
@@ -50,76 +50,75 @@ s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void _MakeMotorData(s32 channel, OSPifRam* buf) {
|
||||
u8* bufptr = (u8*)buf;
|
||||
__OSContRamReadFormat mempakwr;
|
||||
void _MakeMotorData(s32 channel, OSPifRam* mdata) {
|
||||
u8* ptr = (u8*)mdata->ramarray;
|
||||
__OSContRamReadFormat ramreadformat;
|
||||
s32 i;
|
||||
|
||||
mempakwr.dummy = 0xFF;
|
||||
mempakwr.txsize = 0x23;
|
||||
mempakwr.rxsize = 1;
|
||||
mempakwr.cmd = 3; // write mempak
|
||||
mempakwr.hi = 0x600 >> 3;
|
||||
mempakwr.lo = (u8)(__osContAddressCrc(0x600) | (0x600 << 5));
|
||||
ramreadformat.dummy = CONT_CMD_NOP;
|
||||
ramreadformat.txsize = CONT_CMD_WRITE_PAK_TX;
|
||||
ramreadformat.rxsize = CONT_CMD_WRITE_PAK_RX;
|
||||
ramreadformat.cmd = CONT_CMD_WRITE_PAK;
|
||||
ramreadformat.hi = CONT_BLOCK_RUMBLE >> 3;
|
||||
ramreadformat.lo = (u8)(__osContAddressCrc(CONT_BLOCK_RUMBLE) | (CONT_BLOCK_RUMBLE << 5));
|
||||
|
||||
if (channel != 0) {
|
||||
for (i = 0; i < channel; i++) {
|
||||
*bufptr++ = 0;
|
||||
*ptr++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
*(__OSContRamReadFormat*)bufptr = mempakwr;
|
||||
bufptr += sizeof(mempakwr);
|
||||
*bufptr = 0xFE;
|
||||
*READFORMAT(ptr) = ramreadformat;
|
||||
ptr += sizeof(ramreadformat);
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
||||
s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) {
|
||||
s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, s32 channel) {
|
||||
s32 ret;
|
||||
u8 sp24[BLOCKSIZE];
|
||||
u8 temp[BLOCKSIZE];
|
||||
|
||||
pfs->queue = ctrlrqueue;
|
||||
pfs->queue = mq;
|
||||
pfs->channel = channel;
|
||||
pfs->activebank = 0xFF;
|
||||
pfs->status = 0;
|
||||
|
||||
ret = __osPfsSelectBank(pfs, 0xFE);
|
||||
if (ret == 2) {
|
||||
if (ret == PFS_ERR_NEW_PACK) {
|
||||
ret = __osPfsSelectBank(pfs, MOTOR_ID);
|
||||
}
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = __osContRamRead(ctrlrqueue, channel, 0x400, sp24);
|
||||
if (ret == 2) {
|
||||
ret = 4; // "Controller pack communication error"
|
||||
ret = __osContRamRead(mq, channel, CONT_BLOCK_DETECT, temp);
|
||||
if (ret == PFS_ERR_NEW_PACK) {
|
||||
ret = PFS_ERR_CONTRFAIL;
|
||||
}
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (sp24[BLOCKSIZE - 1] == 0xFE) {
|
||||
return 0xB;
|
||||
if (temp[BLOCKSIZE - 1] == 0xFE) {
|
||||
return PFS_ERR_DEVICE;
|
||||
}
|
||||
ret = __osPfsSelectBank(pfs, MOTOR_ID);
|
||||
if (ret == 2) {
|
||||
ret = 4; // "Controller pack communication error"
|
||||
ret = PFS_ERR_CONTRFAIL;
|
||||
}
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = __osContRamRead(ctrlrqueue, channel, BANK_ADDR, sp24);
|
||||
if (ret == 2) {
|
||||
ret = 4; // "Controller pack communication error"
|
||||
ret = __osContRamRead(mq, channel, BANK_ADDR, temp);
|
||||
if (ret == PFS_ERR_NEW_PACK) {
|
||||
ret = PFS_ERR_CONTRFAIL;
|
||||
}
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (sp24[BLOCKSIZE - 1] != MOTOR_ID) {
|
||||
return 0xB;
|
||||
if (temp[BLOCKSIZE - 1] != MOTOR_ID) {
|
||||
return PFS_ERR_DEVICE;
|
||||
}
|
||||
if (!(pfs->status & PFS_MOTOR_INITIALIZED)) {
|
||||
_MakeMotorData(channel, &osPifBuffers[channel]);
|
||||
_MakeMotorData(channel, &__MotorDataBuf[channel]);
|
||||
}
|
||||
pfs->status = PFS_MOTOR_INITIALIZED;
|
||||
|
||||
return 0; // "Recognized rumble pak"
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ void ConsoleLogo_Init(GameState* thisx) {
|
||||
this->state.destroy = ConsoleLogo_Destroy;
|
||||
this->exit = false;
|
||||
|
||||
if (!(Padmgr_GetControllerBitmask() & 1)) {
|
||||
if (!(PadMgr_GetValidControllersMask() & 1)) {
|
||||
gSaveContext.fileNum = 0xFEDC;
|
||||
} else {
|
||||
gSaveContext.fileNum = 0xFF;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user