1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-18 13:54:46 +00:00

[iQue] Match remaining libultra/io files (#2411)

* [iQue] Match remaining libultra/io files

* Match osSpTaskYielded

* Fix bss, remove double space in controller.h

* Fix BSS
This commit is contained in:
Tharo 2025-01-10 00:31:11 +00:00 committed by GitHub
parent 8b5813c86c
commit a57d449196
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 149 additions and 20 deletions

View file

@ -15,7 +15,11 @@ s32 osContStartQuery(OSMesgQueue* mq) {
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
}
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
#ifdef BBPLAYER
__osContLastCmd = CONT_CMD_CHANNEL_RESET;
#else
__osContLastCmd = CONT_CMD_REQUEST_STATUS;
#endif
__osSiRelAccess();
return ret;
}

View file

@ -2,9 +2,12 @@
#define BLOCKSIZE 32
#ifndef BBPLAYER
s32 __osPfsLastChannel = -1;
#endif
s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
#ifndef BBPLAYER
s32 ret;
s32 i;
u8* ptr;
@ -60,4 +63,26 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
__osSiRelAccess();
return ret;
#else
s32 ret;
__osSiGetAccess();
ret = 0;
if (__osBbPakAddress[channel] != 0) {
if (__osBbPakSize - 0x20 >= addr * 0x20) {
s32 i;
for (i = 0; i < 0x20; i++) {
data[i] = *(u8*)(__osBbPakAddress[channel] + addr * 0x20 + i);
}
}
} else {
ret = PFS_ERR_NOPACK;
}
__osSiRelAccess();
return ret;
#endif
}

View file

@ -2,6 +2,7 @@
#include "global.h"
s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force) {
#ifndef BBPLAYER
s32 ret = 0;
s32 i;
u8* ptr;
@ -65,4 +66,28 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32
__osSiRelAccess();
return ret;
#else
s32 ret = 0;
if ((force != true) && (address < PFS_LABEL_AREA) && (address != 0)) {
return 0;
}
__osSiGetAccess();
if (__osBbPakAddress[channel] != 0) {
if (__osBbPakSize - 0x20 >= address * 0x20) {
s32 i;
for (i = 0; i < 0x20; i++) {
*(u8*)(__osBbPakAddress[channel] + address * 0x20 + i) = buffer[i];
}
}
} else {
ret = 1;
}
__osSiRelAccess();
return ret;
#endif
}

View file

@ -10,7 +10,11 @@ s32 osContStartReadData(OSMesgQueue* mq) {
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
}
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
#ifdef BBPLAYER
__osContLastCmd = CONT_CMD_CHANNEL_RESET;
#else
__osContLastCmd = CONT_CMD_READ_BUTTON;
#endif
__osSiRelAccess();
return ret;
}
@ -29,7 +33,18 @@ void osContGetReadData(OSContPad* contData) {
contData->stick_x = read.joyX;
contData->stick_y = read.joyY;
}
};
}
#ifdef BBPLAYER
if (__osBbIsBb && __osBbHackFlags != 0) {
OSContPad tmp;
contData -= __osMaxControllers;
tmp = contData[0];
contData[0] = contData[__osBbHackFlags];
contData[__osBbHackFlags] = tmp;
}
#endif
}
void __osPackReadData(void) {

View file

@ -41,7 +41,11 @@ s32 osContInit(OSMesgQueue* mq, u8* ctlBitfield, OSContStatus* status) {
osRecvMesg(mq, &msg, OS_MESG_BLOCK);
__osContGetInitData(ctlBitfield, status);
#ifdef BBPLAYER
__osContLastCmd = CONT_CMD_CHANNEL_RESET;
#else
__osContLastCmd = CONT_CMD_REQUEST_STATUS;
#endif
__osSiCreateAccessQueue();
osCreateMesgQueue(&__osEepromTimerMsgQueue, &__osEepromTimerMsg, 1);
@ -52,7 +56,7 @@ void __osContGetInitData(u8* ctlBitfield, OSContStatus* data) {
u8* ptr;
__OSContRequesFormat req;
s32 i;
u8 bitfieldTemp = 0;
u8 bits = 0;
ptr = (u8*)&__osContPifRam;
@ -63,10 +67,30 @@ void __osContGetInitData(u8* ctlBitfield, OSContStatus* data) {
continue;
}
data->type = req.typel << 8 | req.typeh;
#ifdef BBPLAYER
data->status = __osBbPakAddress[i] != 0;
#else
data->status = req.status;
bitfieldTemp |= 1 << i;
#endif
bits |= 1 << i;
}
*ctlBitfield = bitfieldTemp;
#ifdef BBPLAYER
if (__osBbIsBb && __osBbHackFlags != 0) {
OSContStatus tmp;
bits = (bits & ~((1 << __osBbHackFlags) | 1)) | ((bits & 1) << __osBbHackFlags) |
((bits & (1 << __osBbHackFlags)) >> __osBbHackFlags);
data -= __osMaxControllers;
tmp = data[0];
data[0] = data[__osBbHackFlags];
data[__osBbHackFlags] = tmp;
}
#endif
*ctlBitfield = bits;
}
void __osPackRequestData(u8 poll) {

View file

@ -2,6 +2,7 @@
#include "global.h"
s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel) {
#ifndef BBPLAYER
s32 ret = 0;
OSMesg msg;
OSContStatus data;
@ -24,6 +25,12 @@ s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel) {
return PFS_ERR_CONTRFAIL;
}
return ret;
#else
if (__osBbPakAddress[channel] != 0) {
return 0;
}
return PFS_ERR_NOPACK;
#endif
}
void __osPfsRequestOneChannel(s32 channel, u8 cmd) {

View file

@ -88,8 +88,28 @@ void __osPfsGetInitData(u8* pattern, OSContStatus* contData) {
}
contData->type = ((req.typel << 8) | req.typeh);
#ifdef BBPLAYER
contData->status = __osBbPakAddress[i] != 0;
#else
contData->status = req.status;
#endif
bits |= (1 << i);
}
#ifdef BBPLAYER
if (__osBbIsBb && __osBbHackFlags != 0) {
OSContStatus tmp;
bits = (bits & ~((1 << __osBbHackFlags) | 1)) | ((bits & 1) << __osBbHackFlags) |
((bits & (1 << __osBbHackFlags)) >> __osBbHackFlags);
contData -= __osMaxControllers;
tmp = contData[0];
contData[0] = contData[__osBbHackFlags];
contData[__osBbHackFlags] = tmp;
}
#endif
*pattern = bits;
}

View file

@ -1,4 +1,5 @@
#include "global.h"
#include "ultra64/bbskapi.h"
#define PIF_RAM_SIZE (PIF_RAM_END + 1 - PIF_RAM_START)
@ -11,6 +12,13 @@ s32 __osSiRawStartDma(s32 dir, void* addr) {
}
IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(addr));
if (dir == OS_READ) {
#ifdef BBPLAYER
if (__osBbIsBb) {
register u32 mask = __osDisableInt();
skKeepAlive();
__osRestoreInt(mask);
}
#endif
IO_WRITE(SI_PIF_ADDR_RD64B_REG, PIF_RAM_START);
} else {
IO_WRITE(SI_PIF_ADDR_WR64B_REG, PIF_RAM_START);

View file

@ -2,18 +2,13 @@
u32 osSpTaskYielded(OSTask* task) {
u32 status = __osSpGetStatus();
u32 ret;
u32 result;
if (status & SP_STATUS_YIELDED) {
ret = OS_TASK_YIELDED;
} else {
ret = 0;
}
result = (status & SP_STATUS_YIELDED) ? OS_TASK_YIELDED : 0;
if (status & SP_STATUS_YIELD) {
task->t.flags |= ret;
task->t.flags |= result;
task->t.flags &= ~OS_TASK_DP_WAIT;
}
return ret;
return result;
}