mirror of https://github.com/n64decomp/mk64.git
Fix some libultra struct types (#677)
This commit is contained in:
parent
c9b9c2d7c8
commit
3f353d7b69
18
Makefile
18
Makefile
|
|
@ -279,14 +279,20 @@ GLOBAL_ASM_RACING_O_FILES = $(foreach file,$(GLOBAL_ASM_RACING_C_FILES),$(BUILD_
|
|||
|
||||
# detect prefix for MIPS toolchain
|
||||
ifneq ($(CROSS),)
|
||||
else ifneq ($(call find-command,mips-linux-gnu-ld),)
|
||||
CROSS := mips-linux-gnu-
|
||||
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
|
||||
CROSS := mips64-linux-gnu-
|
||||
else ifneq ($(call find-command,mips64-elf-ld),)
|
||||
CROSS := mips64-elf-
|
||||
CROSS := mips64-elf-
|
||||
# else ifneq ($(call find-command,mips-n64-ld),)
|
||||
# CROSS := mips-n64-
|
||||
else ifneq ($(call find-command,mips64-ld),)
|
||||
CROSS := mips64-
|
||||
else ifneq ($(call find-command,mips-linux-gnu-ld),)
|
||||
CROSS := mips-linux-gnu-
|
||||
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
|
||||
CROSS := mips64-linux-gnu-
|
||||
else ifneq ($(call find-command,mips-ld),)
|
||||
CROSS := mips-
|
||||
else
|
||||
$(error Unable to detect a suitable MIPS toolchain installed)
|
||||
$(error Unable to detect a suitable MIPS toolchain installed)
|
||||
endif
|
||||
|
||||
AS := $(CROSS)as
|
||||
|
|
|
|||
2
mk64.ld
2
mk64.ld
|
|
@ -356,7 +356,7 @@ SECTIONS
|
|||
BUILD_DIR/src/os/osContInit.o(.bss*);
|
||||
BUILD_DIR/src/os/osPfsIsPlug.o(.bss*);
|
||||
BUILD_DIR/src/os/guRotateF.o(.bss*);
|
||||
BUILD_DIR/src/os/leointerrupt.o(.bss*);
|
||||
BUILD_DIR/src/os/__osLeoInterrupt.o(.bss*);
|
||||
BUILD_DIR/src/os/osTimer.o(.bss*);
|
||||
BUILD_DIR/src/os/__osPiCreateAccessQueue.o(.bss*);
|
||||
BUILD_DIR/src/os/__osSiCreateAccessQueue.o(.bss*);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,24 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
NO_REORDER OSThread* __osThreadTail = NULL;
|
||||
NO_REORDER u32 __osTest = -1;
|
||||
NO_REORDER OSThread* __osRunQueue = (OSThread*) &__osThreadTail;
|
||||
NO_REORDER OSThread* __osActiveQueue = (OSThread*) &__osThreadTail;
|
||||
OSThread* __osRunningThread = NULL;
|
||||
OSThread* __osFaultedThread = NULL;
|
||||
struct __osThreadTail __osThreadTail = { NULL, -1 };
|
||||
OSThread *__osRunQueue = (OSThread *) &__osThreadTail;
|
||||
OSThread *__osActiveQueue = (OSThread *) &__osThreadTail;
|
||||
OSThread *__osRunningThread = { 0 };
|
||||
OSThread *__osFaultedThread = { 0 };
|
||||
|
||||
void __osDequeueThread(OSThread** queue, OSThread* thread) {
|
||||
register OSThread** a2;
|
||||
register OSThread* a3;
|
||||
a2 = queue;
|
||||
a3 = *a2;
|
||||
while (a3 != NULL) {
|
||||
if (a3 == thread) {
|
||||
*a2 = thread->next;
|
||||
void __osDequeueThread(register OSThread **queue, register OSThread *t) {
|
||||
register OSThread *pred;
|
||||
register OSThread *succ;
|
||||
|
||||
pred = (OSThread *) queue;
|
||||
succ = pred->next;
|
||||
|
||||
while (succ != NULL) {
|
||||
if (succ == t) {
|
||||
pred->next = t->next;
|
||||
return;
|
||||
}
|
||||
a2 = &a3->next;
|
||||
a3 = *a2;
|
||||
pred = succ;
|
||||
succ = pred->next;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
static void __osLeoResume(void);
|
||||
static void __osLeoAbnormalResume(void);
|
||||
extern u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_STACKSIZE or something..
|
||||
|
||||
extern u32 D_800EA5F0;
|
||||
|
||||
u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_STACKSIZE or something..
|
||||
|
||||
s32 __osLeoInterrupt() {
|
||||
u32 stat;
|
||||
volatile u32 pistat;
|
||||
|
|
|
|||
|
|
@ -1,185 +0,0 @@
|
|||
#include "libultra_internal.h"
|
||||
#include <PR/rcp.h>
|
||||
#include "bstring.h"
|
||||
#include "piint.h"
|
||||
#include "osint.h"
|
||||
|
||||
u8 leoDiskStack[OS_PIM_STACKSIZE]; // technically should have a OS_LEO_STACKSIZE or something..
|
||||
|
||||
#ifdef VERSION_SH
|
||||
|
||||
//! @todo so many magic constants :'(
|
||||
static void __osLeoResume(void);
|
||||
static void __osLeoAbnormalResume(void);
|
||||
|
||||
s32 __osLeoInterrupt() {
|
||||
u32 stat;
|
||||
volatile u32 pi_stat;
|
||||
u32 bm_stat;
|
||||
__OSTranxInfo* info;
|
||||
__OSBlockInfo* blockInfo;
|
||||
stat = 0;
|
||||
info = &__osDiskHandle->transferInfo;
|
||||
blockInfo = &info->block[info->blockNum];
|
||||
pi_stat = IO_READ(PI_STATUS_REG);
|
||||
if (pi_stat & PI_STATUS_DMA_BUSY) {
|
||||
__OSGlobalIntMask = __OSGlobalIntMask & ~SR_IBIT4; // cartridge interrupt
|
||||
blockInfo->errStatus = LEO_ERROR_29;
|
||||
__osLeoResume();
|
||||
return 1;
|
||||
}
|
||||
WAIT_ON_IOBUSY(pi_stat);
|
||||
stat = IO_READ(LEO_STATUS);
|
||||
if (stat & LEO_STATUS_MECHANIC_INTERRUPT) {
|
||||
WAIT_ON_IOBUSY(pi_stat);
|
||||
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
return 0;
|
||||
}
|
||||
if (info->cmdType == LEO_CMD_TYPE_2) {
|
||||
return 1;
|
||||
}
|
||||
if (stat & LEO_STATUS_BUFFER_MANAGER_ERROR) {
|
||||
WAIT_ON_IOBUSY(pi_stat);
|
||||
stat = IO_READ(LEO_STATUS);
|
||||
blockInfo->errStatus = LEO_ERROR_22;
|
||||
__osLeoResume();
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
return 1;
|
||||
}
|
||||
if (info->cmdType == LEO_CMD_TYPE_1) {
|
||||
if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
|
||||
if (info->sectorNum + 1 != info->transferMode * 85) {
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
__osLeoResume();
|
||||
return 1;
|
||||
}
|
||||
blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr + blockInfo->sectorSize);
|
||||
info->sectorNum++;
|
||||
osEPiRawStartDma(__osDiskHandle, OS_WRITE, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
|
||||
return 1;
|
||||
}
|
||||
if (info->cmdType == LEO_CMD_TYPE_0) {
|
||||
if (info->transferMode == LEO_SECTOR_MODE) {
|
||||
if ((s32) blockInfo->C1ErrNum + 17 < info->sectorNum) {
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
if ((stat & LEO_STATUS_DATA_REQUEST) == 0) {
|
||||
blockInfo->errStatus = LEO_ERROR_23;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
blockInfo->dramAddr = (void*) ((u32) blockInfo->dramAddr + blockInfo->sectorSize);
|
||||
}
|
||||
bm_stat = IO_READ(LEO_BM_STATUS);
|
||||
if ((bm_stat & LEO_BM_STATUS_C1SINGLE && bm_stat & LEO_BM_STATUS_C1DOUBLE) || bm_stat & LEO_BM_STATUS_MICRO) {
|
||||
if (blockInfo->C1ErrNum > 3) {
|
||||
if (info->transferMode != LEO_SECTOR_MODE || info->sectorNum > 0x52) {
|
||||
blockInfo->errStatus = LEO_ERROR_23;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
int errNum = blockInfo->C1ErrNum;
|
||||
blockInfo->C1ErrSector[errNum] = info->sectorNum + 1;
|
||||
}
|
||||
blockInfo->C1ErrNum++;
|
||||
}
|
||||
if (stat & LEO_STATUS_C2_TRANSFER) {
|
||||
if (info->sectorNum != 87) {
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
__osLeoAbnormalResume();
|
||||
}
|
||||
if (info->transferMode == LEO_TRACK_MODE && info->blockNum == 0) {
|
||||
info->blockNum = 1;
|
||||
info->sectorNum = -1;
|
||||
info->block[1].dramAddr = (void*) ((u32) info->block[1].dramAddr - info->block[1].sectorSize);
|
||||
|
||||
blockInfo->errStatus = LEO_ERROR_22;
|
||||
} else {
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
info->cmdType = LEO_CMD_TYPE_2;
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, OS_READ, LEO_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (info->sectorNum == -1 && info->transferMode == LEO_TRACK_MODE && info->blockNum == 1) {
|
||||
__OSBlockInfo* bptr = &info->block[0];
|
||||
if (bptr->C1ErrNum == 0) {
|
||||
if (((u32*) bptr->C2Addr)[0] | ((u32*) bptr->C2Addr)[1] | ((u32*) bptr->C2Addr)[2] |
|
||||
((u32*) bptr->C2Addr)[3]) {
|
||||
bptr->errStatus = LEO_ERROR_24;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
bptr->errStatus = 0;
|
||||
__osLeoResume();
|
||||
}
|
||||
info->sectorNum++;
|
||||
if (stat & LEO_STATUS_DATA_REQUEST) {
|
||||
if (info->sectorNum > 0x54) {
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
osEPiRawStartDma(__osDiskHandle, 0, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize);
|
||||
blockInfo->errStatus = LEO_ERROR_GOOD;
|
||||
return 1;
|
||||
}
|
||||
if (info->sectorNum <= 0x54) {
|
||||
blockInfo->errStatus = LEO_ERROR_24;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
blockInfo->errStatus = LEO_ERROR_4;
|
||||
__osLeoAbnormalResume();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void __osLeoAbnormalResume(void) {
|
||||
__OSTranxInfo* info;
|
||||
u32 pi_stat;
|
||||
info = &__osDiskHandle->transferInfo;
|
||||
WAIT_ON_IOBUSY(pi_stat);
|
||||
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET);
|
||||
WAIT_ON_IOBUSY(pi_stat);
|
||||
IO_WRITE(LEO_BM_CTL, info->bmCtlShadow);
|
||||
__osLeoResume();
|
||||
IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR);
|
||||
__OSGlobalIntMask |= OS_IM_PI;
|
||||
}
|
||||
|
||||
static void __osLeoResume(void) {
|
||||
__OSEventState* es;
|
||||
OSMesgQueue* mq;
|
||||
s32 last;
|
||||
es = &__osEventStateTab[OS_EVENT_PI];
|
||||
mq = es->messageQueue;
|
||||
if (mq == NULL || MQ_IS_FULL(mq)) {
|
||||
return;
|
||||
}
|
||||
last = (mq->first + mq->validCount) % mq->msgCount;
|
||||
mq->msg[last] = es->message;
|
||||
mq->validCount++;
|
||||
if (mq->mtqueue->next != NULL) {
|
||||
__osEnqueueThread(&D_80334898, __osPopThread(&mq->mtqueue));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -9,14 +9,11 @@ typedef struct __OSEventState {
|
|||
OSMesg message;
|
||||
} __OSEventState;
|
||||
|
||||
typedef struct // __osThreadTail
|
||||
extern struct __osThreadTail
|
||||
{
|
||||
/* 0x00 */ OSThread* next;
|
||||
/* 0x04 */ OSPri priority;
|
||||
/* 0x08 */ OSThread* queue;
|
||||
/* 0x0c */ OSThread* tlnext;
|
||||
|
||||
} OSThreadTail;
|
||||
OSThread *next;
|
||||
OSPri priority;
|
||||
} __osThreadTail;
|
||||
|
||||
/*
|
||||
* This define is needed because the original definitions in __osDequeueThread.c are declared
|
||||
|
|
@ -34,10 +31,10 @@ typedef struct {
|
|||
} OSThread_ListHead;
|
||||
|
||||
// Original OSThread_ListHead definitions
|
||||
extern OSThread* __osThreadTail;
|
||||
extern OSThread* __osActiveQueue;
|
||||
extern OSThread* __osRunQueue;
|
||||
extern OSThread* __osRunningThread;
|
||||
extern OSThread *__osRunningThread;
|
||||
extern OSThread *__osActiveQueue;
|
||||
extern OSThread *__osFaultedThread;
|
||||
extern OSThread *__osRunQueue;
|
||||
|
||||
// Original EEPROM definitions
|
||||
extern u32 D_80365E00[15];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include "controller.h"
|
||||
|
||||
void __osPackRequestData(u8);
|
||||
void __osContGetInitData(u8*, OSContStatus*);
|
||||
|
|
@ -9,6 +9,7 @@ u32 _osContInitialized = 0;
|
|||
extern u64 osClockRate;
|
||||
|
||||
// these probably belong in EEPROMlongread or something
|
||||
ALIGNED16 OSPifRam __osContPifRam;
|
||||
u8 __osContLastCmd;
|
||||
u8 _osContNumControllers;
|
||||
OSTimer D_80196548;
|
||||
|
|
@ -34,9 +35,9 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* status) {
|
|||
//! @todo figure out what it means
|
||||
_osContNumControllers = 4;
|
||||
__osPackRequestData(0);
|
||||
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
|
||||
ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
|
||||
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
|
||||
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
|
||||
ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
|
||||
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
|
||||
__osContGetInitData(bitpattern, status);
|
||||
__osContLastCmd = 0;
|
||||
|
|
@ -45,48 +46,49 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* status) {
|
|||
return ret;
|
||||
}
|
||||
void __osContGetInitData(u8* bitpattern, OSContStatus* status) {
|
||||
OSContPackedRequest* cmdBufPtr;
|
||||
OSContPackedRequest response;
|
||||
u8 *ptr;
|
||||
__OSContRequesFormat response;
|
||||
s32 i;
|
||||
u8 sp7;
|
||||
u8 bits;
|
||||
|
||||
sp7 = 0;
|
||||
cmdBufPtr = &(_osContCmdBuf[0].request);
|
||||
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) {
|
||||
response = *(OSContPackedRequest*) cmdBufPtr;
|
||||
status->errnum = (response.rxLen & 0xc0) >> 4;
|
||||
bits = 0;
|
||||
ptr = (u8 *) __osContPifRam.ramarray;
|
||||
for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(response), status++) {
|
||||
response = *((__OSContRequesFormat*)(ptr));
|
||||
status->errnum = CHNL_ERR(response);
|
||||
if (status->errnum == 0) {
|
||||
status->type = response.data2 << 8 | response.data1;
|
||||
status->status = response.data3;
|
||||
status->type = response.typel << 8 | response.typeh;
|
||||
status->status = response.status;
|
||||
|
||||
sp7 |= 1 << i;
|
||||
bits |= 1 << i;
|
||||
}
|
||||
}
|
||||
*bitpattern = sp7;
|
||||
|
||||
*bitpattern = bits;
|
||||
}
|
||||
void __osPackRequestData(u8 command) {
|
||||
OSContPackedRequest* cmdBufPtr;
|
||||
OSContPackedRequest request;
|
||||
u8* ptr;
|
||||
__OSContRequesFormat requestHeader;
|
||||
s32 i;
|
||||
|
||||
// some kind of weird zeroing code
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
*((u32*) &_osContCmdBuf + i) = 0;
|
||||
for (i = 0; i < ARRLEN(__osContPifRam.ramarray) + 1; i++) {
|
||||
__osContPifRam.ramarray[i] = 0;
|
||||
}
|
||||
|
||||
_osContPifCtrl = 1;
|
||||
cmdBufPtr = &_osContCmdBuf[0].request;
|
||||
request.padOrEnd = 255;
|
||||
request.txLen = 1;
|
||||
request.rxLen = 3;
|
||||
request.command = command;
|
||||
request.data1 = 255;
|
||||
request.data2 = 255;
|
||||
request.data3 = 255;
|
||||
request.data4 = 255;
|
||||
__osContPifRam.pifstatus = CONT_CMD_EXE;
|
||||
ptr = (u8*)__osContPifRam.ramarray;
|
||||
requestHeader.dummy = CONT_CMD_NOP;
|
||||
requestHeader.txsize = CONT_CMD_RESET_TX;
|
||||
requestHeader.rxsize = CONT_CMD_RESET_RX;
|
||||
requestHeader.cmd = command;
|
||||
requestHeader.typeh = CONT_CMD_NOP;
|
||||
requestHeader.typel = CONT_CMD_NOP;
|
||||
requestHeader.status = CONT_CMD_NOP;
|
||||
requestHeader.dummy1 = CONT_CMD_NOP;
|
||||
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
*cmdBufPtr++ = request;
|
||||
*(__OSContRequesFormat*)ptr = requestHeader;
|
||||
ptr += sizeof(requestHeader);
|
||||
}
|
||||
cmdBufPtr->padOrEnd = 254;
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef _ULTRA64_CONTROLLER_INTERNAL_H_
|
||||
#define _ULTRA64_CONTROLLER_INTERNAL_H_
|
||||
|
||||
typedef struct {
|
||||
u8 padOrEnd;
|
||||
u8 txLen;
|
||||
u8 rxLen; // includes errno
|
||||
u8 command;
|
||||
u16 button;
|
||||
s8 rawStickX;
|
||||
s8 rawStickY;
|
||||
} OSContPackedRead;
|
||||
|
||||
typedef struct {
|
||||
u8 padOrEnd;
|
||||
u8 txLen;
|
||||
u8 rxLen;
|
||||
u8 command;
|
||||
u8 data1;
|
||||
u8 data2;
|
||||
u8 data3;
|
||||
u8 data4;
|
||||
} OSContPackedRequest;
|
||||
|
||||
typedef union {
|
||||
OSContPackedRead read;
|
||||
OSContPackedRequest request;
|
||||
u32 as_raw[2];
|
||||
} OSContPackedStruct;
|
||||
|
||||
#ifdef AVOID_UB
|
||||
// Fix the OSContPackedStruct array
|
||||
extern OSContPackedStruct _osContCmdBuf[8];
|
||||
|
||||
// And fix the last element
|
||||
#define _osContPifCtrl _osContCmdBuf[7].as_raw[1]
|
||||
#else
|
||||
// Original OSContPackedStruct definitions
|
||||
extern OSContPackedStruct _osContCmdBuf[7];
|
||||
extern u32 _osContPifCtrl;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,16 +1,7 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include "controller.h"
|
||||
#include <macros.h>
|
||||
|
||||
#ifndef AVOID_UB
|
||||
ALIGNED8 OSContPackedStruct _osContCmdBuf[7];
|
||||
UNUSED static u32 unused; // padding between these two variables
|
||||
u32 _osContPifCtrl;
|
||||
#else
|
||||
// Reordered gcc vars above will disturb the aliasing done to access all 8 members of this array, hence AVOID_UB.
|
||||
ALIGNED8 OSContPackedStruct _osContCmdBuf[8];
|
||||
#endif
|
||||
|
||||
extern u8 __osContLastCmd;
|
||||
extern u8 _osContNumControllers;
|
||||
|
||||
|
|
@ -18,56 +9,66 @@ void __osPackReadData(void);
|
|||
s32 osContStartReadData(OSMesgQueue* mesg) {
|
||||
s32 ret = 0;
|
||||
s32 i;
|
||||
|
||||
__osSiGetAccess();
|
||||
if (__osContLastCmd != 1) {
|
||||
|
||||
if (__osContLastCmd != CONT_CMD_READ_BUTTON) {
|
||||
__osPackReadData();
|
||||
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
|
||||
ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
|
||||
osRecvMesg(mesg, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
*((u32*) &_osContCmdBuf + i) = 255;
|
||||
|
||||
for (i = 0; i < ARRLEN(__osContPifRam.ramarray) + 1; i++) {
|
||||
__osContPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
|
||||
_osContPifCtrl = 0;
|
||||
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
|
||||
__osContLastCmd = 1;
|
||||
__osContPifRam.pifstatus = 0;
|
||||
ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
|
||||
__osContLastCmd = CONT_CMD_READ_BUTTON;
|
||||
|
||||
__osSiRelAccess();
|
||||
|
||||
return ret;
|
||||
}
|
||||
void osContGetReadData(OSContPad* pad) {
|
||||
OSContPackedRead* cmdBufPtr;
|
||||
OSContPackedRead response;
|
||||
u8 *ptr = (u8 *) __osContPifRam.ramarray;
|
||||
__OSContReadFormat readformat;
|
||||
s32 i;
|
||||
cmdBufPtr = &_osContCmdBuf[0].read;
|
||||
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) {
|
||||
response = *cmdBufPtr;
|
||||
pad->errno = (response.rxLen & 0xc0) >> 4;
|
||||
if (pad->errno == 0) {
|
||||
pad->button = response.button;
|
||||
pad->stick_x = response.rawStickX;
|
||||
pad->stick_y = response.rawStickY;
|
||||
|
||||
for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(readformat), pad++) {
|
||||
readformat = * (__OSContReadFormat *) ptr;
|
||||
pad->errno = CHNL_ERR(readformat);
|
||||
|
||||
if (pad->errno != 0) {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
pad->button = readformat.button;
|
||||
pad->stick_x = readformat.stick_x;
|
||||
pad->stick_y = readformat.stick_y;
|
||||
}
|
||||
}
|
||||
void __osPackReadData() {
|
||||
OSContPackedRead* cmdBufPtr;
|
||||
OSContPackedRead request;
|
||||
u8 *ptr = (u8 *) __osContPifRam.ramarray;
|
||||
__OSContReadFormat readformat;
|
||||
s32 i;
|
||||
cmdBufPtr = &_osContCmdBuf[0].read;
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
*((u32*) &_osContCmdBuf + i) = 0;
|
||||
|
||||
for (i = 0; i < ARRLEN(__osContPifRam.ramarray) + 1; i++) {
|
||||
__osContPifRam.ramarray[i] = 0;
|
||||
}
|
||||
|
||||
_osContPifCtrl = 1;
|
||||
request.padOrEnd = 255;
|
||||
request.txLen = 1;
|
||||
request.rxLen = 4;
|
||||
request.command = 1;
|
||||
request.button = 65535;
|
||||
request.rawStickX = -1;
|
||||
request.rawStickY = -1;
|
||||
__osContPifRam.pifstatus = CONT_CMD_EXE;
|
||||
readformat.dummy = CONT_CMD_NOP;
|
||||
readformat.txsize = CONT_CMD_READ_BUTTON_TX;
|
||||
readformat.rxsize = CONT_CMD_READ_BUTTON_RX;
|
||||
readformat.cmd = CONT_CMD_READ_BUTTON;
|
||||
readformat.button = 0xFFFF;
|
||||
readformat.stick_x = -1;
|
||||
readformat.stick_y = -1;
|
||||
|
||||
for (i = 0; i < _osContNumControllers; i++) {
|
||||
*cmdBufPtr++ = request;
|
||||
* (__OSContReadFormat *) ptr = readformat;
|
||||
ptr += sizeof(readformat);
|
||||
}
|
||||
cmdBufPtr->padOrEnd = 254;
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msgBuf, s32 count) {
|
||||
mq->mtqueue = (OSThread*) &__osThreadTail; //?
|
||||
mq->fullqueue = (OSThread*) &__osThreadTail;
|
||||
mq->mtqueue = (OSThread *) &__osThreadTail.next;
|
||||
mq->fullqueue = (OSThread *) &__osThreadTail.next;
|
||||
mq->validCount = 0;
|
||||
mq->first = 0;
|
||||
mq->msgCount = count;
|
||||
mq->msg = msgBuf;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ s32 osEepromRead(OSMesgQueue* mq, u8 address, u8* buffer) {
|
|||
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
|
||||
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
__osEepPifRam.pifstatus = 0;
|
||||
|
|
@ -66,7 +66,7 @@ void __osPackEepReadData(u8 address) {
|
|||
__OSContEepromFormat eepromformat;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
|
||||
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
__osEepPifRam.pifstatus = CONT_CMD_EXE;
|
||||
|
|
@ -75,7 +75,7 @@ void __osPackEepReadData(u8 address) {
|
|||
eepromformat.rxsize = CONT_CMD_READ_EEPROM_RX;
|
||||
eepromformat.cmd = CONT_CMD_READ_EEPROM;
|
||||
eepromformat.address = address;
|
||||
for (i = 0; i < ARRAY_COUNT(eepromformat.data); i++) {
|
||||
for (i = 0; i < ARRLEN(eepromformat.data); i++) {
|
||||
eepromformat.data[i] = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "libultra_internal.h"
|
||||
#include "osContInternal.h"
|
||||
#include "controller.h"
|
||||
#include "macros.h"
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
|
|||
ret = __osSiRawStartDma(OS_WRITE, &__osEepPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
|
||||
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +60,7 @@ void __osPackEepWriteData(u8 address, u8* buffer) {
|
|||
__OSContEepromFormat eepromformat;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
|
||||
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
|
||||
__osEepPifRam.ramarray[i] = CONT_CMD_NOP;
|
||||
}
|
||||
__osEepPifRam.pifstatus = CONT_CMD_EXE;
|
||||
|
|
@ -71,7 +70,7 @@ void __osPackEepWriteData(u8 address, u8* buffer) {
|
|||
eepromformat.cmd = CONT_CMD_WRITE_EEPROM;
|
||||
eepromformat.address = address;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(eepromformat.data); i++) {
|
||||
for (i = 0; i < ARRLEN(eepromformat.data); i++) {
|
||||
eepromformat.data[i] = *buffer++;
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +88,7 @@ s32 __osEepStatus(OSMesgQueue* mq, OSContStatus* data) {
|
|||
u8* ptr = (u8*) __osEepPifRam.ramarray;
|
||||
__OSContRequesFormat requestformat;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osEepPifRam.ramarray) + 1; i++) {
|
||||
for (i = 0; i < ARRLEN(__osEepPifRam.ramarray) + 1; i++) {
|
||||
__osEepPifRam.ramarray[i] = 0;
|
||||
}
|
||||
__osEepPifRam.pifstatus = CONT_CMD_EXE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue