diff --git a/include/functions.h b/include/functions.h index ad01b7a82c..ced71293c1 100644 --- a/include/functions.h +++ b/include/functions.h @@ -276,9 +276,7 @@ void __osDequeueThread(OSThread** param_1, OSThread* param_2); void osDestroyThread(OSThread* puParm1); // void __osVoiceCheckResult(void); void bzero(void* begin, s32 length); -s32 osSetRumble(OSPfs* pfs, u32 vibrate); -// void osSetUpMempakWrite(void); -// void osProbeRumblePak(void); + void __osSiCreateAccessQueue(void); void __osSiGetAccess(void); void __osSiRelAccess(void); diff --git a/include/io/controller.h b/include/io/controller.h index 50add3561f..91cbd51f8b 100644 --- a/include/io/controller.h +++ b/include/io/controller.h @@ -145,5 +145,11 @@ typedef struct { /* 0x26 */ u8 datacrc; } __OSContRamReadFormat; +extern OSPifRam __osContPifRam; +// extern UNK_TYPE1 D_8009CF0C; +extern u8 __osContLastCmd; +extern u8 __osMaxControllers; +// extern OSMesgQueue D_8009CF38; +// extern OSMesg D_8009CF50; #endif diff --git a/include/ultra64/motor.h b/include/ultra64/motor.h new file mode 100644 index 0000000000..ad68281324 --- /dev/null +++ b/include/ultra64/motor.h @@ -0,0 +1,17 @@ +#ifndef ULTRA64_MOTOR_H +#define ULTRA64_MOTOR_H + +#include "PR/ultratypes.h" +#include "PR/pfs.h" +#include "ultra64/message.h" + +#define MOTOR_START 1 +#define MOTOR_STOP 0 + +#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); + +#endif diff --git a/include/variables.h b/include/variables.h index c880ed1368..6b5fbe620e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -325,15 +325,10 @@ extern FaultDrawer sFaultDrawerStruct; extern u32 sRandFloat; // extern UNK_TYPE4 sArenaLockMsg; extern OSTask tmp_task; -extern OSPifRam osPifBuffers[4]; + extern OSMesg siAccessBuf[1]; extern OSMesgQueue __osSiAccessQueue; -extern OSPifRam __osContPifRam; -// extern UNK_TYPE1 D_8009CF0C; -extern u8 __osContLastCmd; -extern u8 __osMaxControllers; -// extern OSMesgQueue D_8009CF38; -// extern OSMesg D_8009CF50; + extern UNK_TYPE1 D_8009CF60; // extern UNK_TYPE4 D_8009CF70; extern OSThread __osThreadSave; diff --git a/spec b/spec index 2350931e9f..a605ba93a7 100644 --- a/spec +++ b/spec @@ -74,8 +74,7 @@ beginseg include "build/src/libultra/os/destroythread.o" include "build/src/libultra/voice/voicecheckresult.o" include "build/asm/boot/bzero.text.o" - include "build/src/libultra/io/rumblepak.o" - include "build/data/boot/rumblepak.bss.o" + include "build/src/libultra/io/motor.o" include "build/src/libultra/io/siacs.o" include "build/src/libultra/io/controller.o" include "build/src/libultra/os/createthread.o" diff --git a/src/boot_O1/viextendvstart.c b/src/boot_O1/viextendvstart.c deleted file mode 100644 index ce9f718d01..0000000000 --- a/src/boot_O1/viextendvstart.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "global.h" - -void osViExtendVStart(u32 a0) { - __additional_scanline = a0; -} diff --git a/src/code/padmgr.c b/src/code/padmgr.c index a8ef1db158..0d539126a1 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -1,4 +1,5 @@ #include "global.h" +#include "ultra64/motor.h" #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetControllerBitmask.s") diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index 25254c61b4..4c0bfb67a1 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -1,12 +1,16 @@ -#include "ultra64.h" -#include "global.h" +#include "ultra64/motor.h" + +#include "io/controller.h" +#include "functions.h" #define BANK_ADDR 0x400 #define MOTOR_ID 0x80 +OSPifRam osPifBuffers[MAXCONTROLLERS]; + s32 __osPfsSelectBank(OSPfs* pfs, u8 bank); -s32 osSetRumble(OSPfs* pfs, u32 vibrate) { +s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { s32 i; s32 ret; u8* buf = (u8*)&osPifBuffers[pfs->channel]; @@ -45,10 +49,11 @@ s32 osSetRumble(OSPfs* pfs, u32 vibrate) { return ret; } -void osSetUpMempakWrite(u32 channel, OSPifRam* buf) { + +void _MakeMotorData(s32 channel, OSPifRam* buf) { u8* bufptr = (u8*)buf; __OSContRamReadFormat mempakwr; - u32 i; + s32 i; mempakwr.dummy = 0xFF; mempakwr.txsize = 0x23; @@ -68,7 +73,7 @@ void osSetUpMempakWrite(u32 channel, OSPifRam* buf) { *bufptr = 0xFE; } -s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) { +s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel) { s32 ret; u8 sp24[BLOCKSIZE]; @@ -111,8 +116,8 @@ s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) { if (sp24[BLOCKSIZE - 1] != MOTOR_ID) { return 0xB; } - if ((pfs->status & PFS_MOTOR_INITIALIZED) == 0) { - osSetUpMempakWrite(channel, &osPifBuffers[channel]); + if (!(pfs->status & PFS_MOTOR_INITIALIZED)) { + _MakeMotorData(channel, &osPifBuffers[channel]); } pfs->status = PFS_MOTOR_INITIALIZED; diff --git a/src/libultra/io/rumblepak.c b/src/libultra/io/rumblepak.c deleted file mode 100644 index 3353059da5..0000000000 --- a/src/libultra/io/rumblepak.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/boot/rumblepak/osSetRumble.s") - -#pragma GLOBAL_ASM("asm/non_matchings/boot/rumblepak/osSetUpMempakWrite.s") - -#pragma GLOBAL_ASM("asm/non_matchings/boot/rumblepak/osProbeRumblePak.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index c67027a734..b9a7a0dfdc 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -86,7 +86,7 @@ 0x80089470 : "destroythread", 0x80089580 : "voicecheckresult", 0x80089630 : "bzero", - 0x800896D0 : "rumblepak", + 0x800896D0 : "motor", 0x80089AA0 : "siacs", 0x80089B60 : "controller", 0x80089E40 : "createthread", @@ -321,7 +321,7 @@ 0x8009CD50 : "rand", 0x8009CD60 : "__osMalloc", 0x8009CD70 : "sptask", - 0x8009CDB0 : "rumblepak", + 0x8009CDB0 : "motor", 0x8009CEB0 : "siacs", 0x8009CED0 : "controller", 0x8009CF60 : "voicegetreaddata", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7e30deb3ed..60dc19acae 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -280,9 +280,9 @@ 0x80089470:("osDestroyThread",), 0x80089580:("__osVoiceCheckResult",), 0x80089630:("bzero",), - 0x800896D0:("osSetRumble",), - 0x80089838:("osSetUpMempakWrite",), - 0x80089944:("osProbeRumblePak",), + 0x800896D0:("__osMotorAccess",), + 0x80089838:("_MakeMotorData",), + 0x80089944:("osMotorInit",), 0x80089AA0:("__osSiCreateAccessQueue",), 0x80089AF0:("__osSiGetAccess",), 0x80089B34:("__osSiRelAccess",), diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 9d9b2d8b0d..46e57b75c8 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -277,9 +277,9 @@ asm/non_matchings/boot/thread/__osDequeueThread.s,__osDequeueThread,0x80089430,0 asm/non_matchings/boot/destroythread/osDestroyThread.s,osDestroyThread,0x80089470,0x44 asm/non_matchings/boot/voicecheckresult/__osVoiceCheckResult.s,__osVoiceCheckResult,0x80089580,0x2C asm/non_matchings/boot/bzero/bzero.s,bzero,0x80089630,0x28 -asm/non_matchings/boot/rumblepak/osSetRumble.s,osSetRumble,0x800896D0,0x5A -asm/non_matchings/boot/rumblepak/osSetUpMempakWrite.s,osSetUpMempakWrite,0x80089838,0x43 -asm/non_matchings/boot/rumblepak/osProbeRumblePak.s,osProbeRumblePak,0x80089944,0x57 +asm/non_matchings/boot/rumblepak/__osMotorAccess.s,__osMotorAccess,0x800896D0,0x5A +asm/non_matchings/boot/rumblepak/_MakeMotorData.s,_MakeMotorData,0x80089838,0x43 +asm/non_matchings/boot/rumblepak/osMotorInit.s,osMotorInit,0x80089944,0x57 asm/non_matchings/boot/siacs/__osSiCreateAccessQueue.s,__osSiCreateAccessQueue,0x80089AA0,0x14 asm/non_matchings/boot/siacs/__osSiGetAccess.s,__osSiGetAccess,0x80089AF0,0x11 asm/non_matchings/boot/siacs/__osSiRelAccess.s,__osSiRelAccess,0x80089B34,0xB