From cd3927a77f918a02430d5cb2d77484e374b0fd4d Mon Sep 17 00:00:00 2001 From: silv3rwing07 Date: Fri, 3 Apr 2020 19:58:50 -0700 Subject: [PATCH] Adjusted some volatile --- include/padmgr.h | 6 +++--- src/code/padmgr.c | 24 +++++++----------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/include/padmgr.h b/include/padmgr.h index a7fa391f75..737feef902 100644 --- a/include/padmgr.h +++ b/include/padmgr.h @@ -25,12 +25,12 @@ typedef struct { /* 0x02A9 */ u8 ncontrollers; /* 0x02AA */ u8 Key_switch[4]; //means the controller is connected /* 0x02AE */ u8 pak_type[4]; //1 if vibration pack, 2 if (maybe controller pack)? - /* 0x02B2 */ u8 rumble_enable[4]; + /* 0x02B2 */ volatile u8 rumble_enable[4]; /* 0x02B6 */ u8 rumble_counter[4]; //not clear exact meaning /* 0x02BA */ char unk_2BA[0x02]; //probably padding /* 0x02BC */ unk_controller_t unk_controller[4]; - /* 0x045C */ u8 rumble_off_frames; - /* 0x045D */ u8 rumble_on_frames; + /* 0x045C */ volatile u8 rumble_off_frames; + /* 0x045D */ volatile u8 rumble_on_frames; /* 0x045E */ u8 prenmi_shutdown; /* 0x045F */ u8 unk_45F; /* 0x0460 */ void (*unk_460)(void* padmgr, u32 unk464); diff --git a/src/code/padmgr.c b/src/code/padmgr.c index a93859220e..6ea946989d 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -209,15 +209,11 @@ void padmgr_RumbleSetSingle(PadMgr* padmgr, u32 ctrlr, u32 rumble) { // 800A23CC in 1.0 void padmgr_RumbleSet(PadMgr* padmgr, u8* ctrlr_rumbles) { - //This volatile nonsense is probably not what they wrote-- - //padmgr_RumbleSetSingle above is never called and its symbol isn't exported, - //so it looks like that was probably inlined. But we couldn't get any of that - //to work or match. This, however, does match. s32 i; for(i=0; i<4; ++i){ - *(volatile u8*)&padmgr->rumble_enable[i] = ctrlr_rumbles[i]; + padmgr->rumble_enable[i] = ctrlr_rumbles[i]; } - *(volatile u8*)&padmgr->rumble_on_frames = 0xF0; + padmgr->rumble_on_frames = 0xF0; } #if 0 @@ -312,7 +308,7 @@ void padmgr_HandleRetraceMsg(PadMgr *padmgr) { queue = padmgr_LockSerialMesgQ(padmgr); osContStartReadData(queue); - if (padmgr->unk_460 != NULL){ + if (padmgr->unk_460){ padmgr->unk_460(padmgr, padmgr->unk_464); } osRecvMesg(queue, NULL, OS_MESG_BLOCK); @@ -343,18 +339,12 @@ void padmgr_HandleRetraceMsg(PadMgr *padmgr) { if (gFaultStruct.msgId){ padmgr_RumbleStop(padmgr); - return; - } - if ((s32)(padmgr->rumble_off_frames) > 0){ - padmgr->rumble_off_frames = *(volatile u8*)&padmgr->rumble_off_frames - 1; + }else if (padmgr->rumble_off_frames > 0){ + --padmgr->rumble_off_frames; padmgr_RumbleStop(padmgr); - return; - } - if (padmgr->rumble_on_frames == 0){ + }else if (padmgr->rumble_on_frames == 0){ padmgr_RumbleStop(padmgr); - return; - } - if (!padmgr->prenmi_shutdown){ + }else if (!padmgr->prenmi_shutdown){ padmgr_RumbleControl(padmgr); --padmgr->rumble_on_frames; }