1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-02-14 19:14:50 +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

@ -17,6 +17,7 @@
#define CONT_CMD_WRITE_MEMPACK 3
#define CONT_CMD_READ_EEPROM 4
#define CONT_CMD_WRITE_EEPROM 5
#define CONT_CMD_CHANNEL_RESET 0xFD
#define CONT_CMD_RESET 0xFF
#define CONT_CMD_REQUEST_STATUS_TX 1

View file

@ -15,6 +15,9 @@ extern u32 osMemSize;
extern u8 osAppNMIBuffer[0x40];
extern u32 __osBbIsBb;
extern u32 __osBbHackFlags;
extern u32 __osBbPakAddress[4];
extern u32 __osBbPakSize;
extern s8 D_80009430;
extern vu8 gViConfigBlack;

1
spec
View file

@ -808,6 +808,7 @@ beginseg
include "$(BUILD_DIR)/src/libultra/gu/perspective.o"
include "$(BUILD_DIR)/src/libultra/io/sprawdma.o"
include "$(BUILD_DIR)/src/libultra/io/sirawdma.o"
include "$(BUILD_DIR)/src/libultra/bb/sk/skapi.o" // TODO temporary
include "$(BUILD_DIR)/src/libultra/io/sptaskyield.o"
#if DEBUG_FEATURES
include "$(BUILD_DIR)/src/libultra/io/pfsreadwritefile.o"

View file

@ -28,7 +28,7 @@
#endif
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ntsc-1.2:82 pal-1.0:80 pal-1.1:80"
"ntsc-1.2:78 pal-1.0:76 pal-1.1:76"
StackEntry sDmaMgrStackInfo;
OSMesgQueue sDmaMgrMsgQueue;

View file

@ -24,7 +24,7 @@ extern struct IrqMgr gIrqMgr;
#endif
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \
"ntsc-1.0:141 ntsc-1.1:141 ntsc-1.2:141 pal-1.0:139 pal-1.1:139"
"ntsc-1.0:138 ntsc-1.1:138 ntsc-1.2:138 pal-1.0:136 pal-1.1:136"
extern u8 _buffersSegmentEnd[];

View file

@ -2,7 +2,7 @@
#include "terminal.h"
#include "line_numbers.h"
#pragma increment_block_number "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128"
#pragma increment_block_number "ntsc-1.0:120 ntsc-1.1:120 ntsc-1.2:120"
u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList);
void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector);

View file

@ -3639,7 +3639,7 @@ s32 Camera_KeepOn3(Camera* camera) {
}
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ntsc-1.0:144 ntsc-1.1:144 ntsc-1.2:144 pal-1.0:142 pal-1.1:142"
"ntsc-1.0:141 ntsc-1.1:141 ntsc-1.2:141 pal-1.0:139 pal-1.1:139"
s32 Camera_KeepOn4(Camera* camera) {
static Vec3f D_8015BD50;

View file

@ -1,5 +1,5 @@
#pragma increment_block_number "gc-eu:232 gc-eu-mq:232 gc-jp:212 gc-jp-ce:212 gc-jp-mq:212 gc-us:212 gc-us-mq:212" \
"ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:240 pal-1.1:240"
#pragma increment_block_number "gc-eu:228 gc-eu-mq:228 gc-jp:212 gc-jp-ce:212 gc-jp-mq:212 gc-us:212 gc-us-mq:212" \
"ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:236 pal-1.1:236"
#include "global.h"
#include "ultra64.h"

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

View file

@ -143,7 +143,8 @@ static EnPoFieldInfo sPoFieldInfo[2] = {
static Vec3f D_80AD714C = { 0.0f, 1400.0f, 0.0f };
#pragma increment_block_number "gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128 ntsc-1.2:128"
#pragma increment_block_number "gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128 ntsc-1.2:128 pal-1.0:128" \
"pal-1.1:128"
static Vec3s sSpawnPositions[10];
static u8 sSpawnSwitchFlags[10];