`motor.c` OK (#397)

* use motor in the spec

* import bss

* Delete viextendvstart.c

* rename functions

* move stuff and format

* remove globals.h and ultra64.h

* Update src/libultra/io/motor.c

Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>

* add motor.h to padmgr

* fix

Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com>
This commit is contained in:
Anghelo Carvajal 2021-11-06 00:29:56 -03:00 committed by GitHub
parent e70a8fbb99
commit 278ff4a4b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 40 deletions

View File

@ -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);

View File

@ -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

17
include/ultra64/motor.h Normal file
View File

@ -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

View File

@ -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;

3
spec
View File

@ -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"

View File

@ -1,5 +0,0 @@
#include "global.h"
void osViExtendVStart(u32 a0) {
__additional_scanline = a0;
}

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "ultra64/motor.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetControllerBitmask.s")

View File

@ -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;

View File

@ -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")

View File

@ -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",

View File

@ -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",),

View File

@ -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

1 asm/non_matchings/boot/boot_main/bootproc.s bootproc 0x80080060 0x3C
277 asm/non_matchings/boot/destroythread/osDestroyThread.s osDestroyThread 0x80089470 0x44
278 asm/non_matchings/boot/voicecheckresult/__osVoiceCheckResult.s __osVoiceCheckResult 0x80089580 0x2C
279 asm/non_matchings/boot/bzero/bzero.s bzero 0x80089630 0x28
280 asm/non_matchings/boot/rumblepak/osSetRumble.s asm/non_matchings/boot/rumblepak/__osMotorAccess.s osSetRumble __osMotorAccess 0x800896D0 0x5A
281 asm/non_matchings/boot/rumblepak/osSetUpMempakWrite.s asm/non_matchings/boot/rumblepak/_MakeMotorData.s osSetUpMempakWrite _MakeMotorData 0x80089838 0x43
282 asm/non_matchings/boot/rumblepak/osProbeRumblePak.s asm/non_matchings/boot/rumblepak/osMotorInit.s osProbeRumblePak osMotorInit 0x80089944 0x57
283 asm/non_matchings/boot/siacs/__osSiCreateAccessQueue.s __osSiCreateAccessQueue 0x80089AA0 0x14
284 asm/non_matchings/boot/siacs/__osSiGetAccess.s __osSiGetAccess 0x80089AF0 0x11
285 asm/non_matchings/boot/siacs/__osSiRelAccess.s __osSiRelAccess 0x80089B34 0xB