1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-13 02:10:57 +00:00

Fix most compiler warnings in the boot and code segments (#674)

* Less warnings in boot & code segments

* few more warnings gone

* Ran formatter

* z_view warning gone

* -> 1

* f31 -> 31

* Remove function casts

* Few more small improvements

* Separate declaration and assignment in func_80091738 and Item_Give

Co-authored-by: Thar0 <maximilianc64@gmail.com>
This commit is contained in:
Tharo 2021-02-14 00:49:40 +00:00 committed by GitHub
parent d615ec4f31
commit f9d96d9f73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
208 changed files with 1702 additions and 1846 deletions

View file

@ -17,10 +17,8 @@ u8 __osContAddressCrc(u16 addr) {
} else {
++ret;
}
} else {
if (ret & 0x20) {
ret ^= 0x15;
}
} else if (ret & 0x20) {
ret ^= 0x15;
}
}
for (i = 0; i < 5; ++i) {
@ -29,15 +27,15 @@ u8 __osContAddressCrc(u16 addr) {
ret ^= 0x15;
}
}
return ret & 0x1f;
}
u8 __osContDataCrc(u8* data) {
s32 ret;
s32 ret = 0;
u32 bit;
u32 byte;
ret = 0;
for (byte = 0x20; byte; --byte, ++data) {
for (bit = 0x80; bit; bit >>= 1) {
ret <<= 1;
@ -47,10 +45,8 @@ u8 __osContDataCrc(u8* data) {
} else {
++ret;
}
} else {
if (ret & 0x100) {
ret ^= 0x85;
}
} else if (ret & 0x100) {
ret ^= 0x85;
}
}
}
@ -61,5 +57,6 @@ u8 __osContDataCrc(u8* data) {
}
++byte;
} while (byte < 8U);
return ret;
}

View file

@ -12,15 +12,15 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
__osSiGetAccess();
do {
bufptr = &pifMempakBuf;
if ((__osContLastPoll != 2) || (__osPfsLastChannel != channel)) {
bufptr = (u8*)&gPifMempakBuf;
if ((__osContLastPoll != 2) || (__osPfsLastChannel != channel)) {
__osContLastPoll = 2;
__osPfsLastChannel = channel;
// clang-format off
for (i = 0; i < channel; i++) { *bufptr++ = 0; }
// clang-format on
pifMempakBuf.status = 1;
gPifMempakBuf.status = 1;
((__OSContRamHeader*)bufptr)->unk_00 = 0xFF;
((__OSContRamHeader*)bufptr)->txsize = 3;
((__OSContRamHeader*)bufptr)->rxsize = 0x21;
@ -31,12 +31,14 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
} else {
bufptr += channel;
}
((__OSContRamHeader*)bufptr)->hi = addr >> 3; // send byte 1
((__OSContRamHeader*)bufptr)->lo = (s8)(__osContAddressCrc(addr) | (addr << 5)); // send byte 2
__osSiRawStartDma(OS_WRITE, &pifMempakBuf);
__osSiRawStartDma(OS_WRITE, &gPifMempakBuf);
osRecvMesg(ctrlrqueue, NULL, OS_MESG_BLOCK);
__osSiRawStartDma(OS_READ, &pifMempakBuf);
__osSiRawStartDma(OS_READ, &gPifMempakBuf);
osRecvMesg(ctrlrqueue, NULL, OS_MESG_BLOCK);
ret = (((__OSContRamHeader*)bufptr)->rxsize & 0xC0) >> 4;
if (!ret) {
if (((__OSContRamHeader*)bufptr)->datacrc != __osContDataCrc(bufptr + 6)) {
@ -56,5 +58,6 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
}
} while (0 <= retryCount--);
__osSiRelAccess();
return ret;
}

View file

@ -15,7 +15,7 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32
__osSiGetAccess();
do {
ptr = (u8*)(&pifMempakBuf);
ptr = (u8*)(&gPifMempakBuf);
if (__osContLastPoll != CONT_CMD_WRITE_MEMPACK || __osPfsLastChannel != channel) {
__osContLastPoll = CONT_CMD_WRITE_MEMPACK;
@ -25,7 +25,7 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32
for (i = 0; i < channel; i++) { *ptr++ = 0; }
// clang-format on
pifMempakBuf.status = 1;
gPifMempakBuf.status = 1;
((__OSContRamHeader*)ptr)->unk_00 = 0xff;
((__OSContRamHeader*)ptr)->txsize = 35;
@ -42,11 +42,11 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32
bcopy(buffer, ((__OSContRamHeader*)ptr)->data, BLOCKSIZE);
ret = __osSiRawStartDma(OS_WRITE, &pifMempakBuf);
ret = __osSiRawStartDma(OS_WRITE, &gPifMempakBuf);
crc = __osContDataCrc(buffer);
osRecvMesg(mq, (OSMesg*)NULL, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &pifMempakBuf);
ret = __osSiRawStartDma(OS_READ, &gPifMempakBuf);
osRecvMesg(mq, (OSMesg*)NULL, OS_MESG_BLOCK);
ret = ((((__OSContRamHeader*)ptr)->rxsize & 0xC0) >> 4);
@ -63,5 +63,6 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32
}
} while ((ret == PFS_ERR_CONTRFAIL) && (retry-- >= 0));
__osSiRelAccess();
return ret;
}

View file

@ -1,5 +1,5 @@
#include "global.h"
OSThread* __osGetActiveQueue() {
OSThread* __osGetActiveQueue(void) {
return __osActiveQueue;
}

View file

@ -1,5 +1,5 @@
#include "global.h"
OSThread* __osGetCurrFaultedThread() {
OSThread* __osGetCurrFaultedThread(void) {
return __osFaultedThread;
}

View file

@ -1,7 +1,7 @@
#include "ultra64.h"
#include "global.h"
OSPifRam pifMempakBuf;
OSPifRam gPifMempakBuf;
s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel) {
s32 ret = 0;
@ -11,10 +11,10 @@ s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel) {
__osPfsInodeCacheBank = 250;
__osPfsRequestOneChannel(channel, CONT_CMD_REQUEST_STATUS);
ret = __osSiRawStartDma(OS_WRITE, &pifMempakBuf);
ret = __osSiRawStartDma(OS_WRITE, &gPifMempakBuf);
osRecvMesg(queue, &msg, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &pifMempakBuf);
ret = __osSiRawStartDma(OS_READ, &gPifMempakBuf);
osRecvMesg(queue, &msg, OS_MESG_BLOCK);
__osPfsGetOneChannelData(channel, &data);
@ -34,10 +34,9 @@ void __osPfsRequestOneChannel(s32 channel, u8 poll) {
s32 idx;
__osContLastPoll = CONT_CMD_END;
gPifMempakBuf.status = CONT_CMD_READ_BUTTON;
pifMempakBuf.status = CONT_CMD_READ_BUTTON;
bufptr = &pifMempakBuf;
bufptr = (u8*)&gPifMempakBuf;
req.txsize = 1;
req.rxsize = 3;
@ -56,12 +55,10 @@ void __osPfsRequestOneChannel(s32 channel, u8 poll) {
}
void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData) {
u8* bufptr;
u8* bufptr = (u8*)&gPifMempakBuf;
__OSContRequestHeaderAligned req;
s32 idx;
bufptr = &pifMempakBuf;
for (idx = 0; idx < channel; idx++) {
bufptr++;
}

View file

@ -4,20 +4,21 @@ OSMesg osSiMesgBuff[SIAccessQueueSize];
OSMesgQueue gOSSiMessageQueue;
u32 gOSSiAccessQueueCreated = 0;
void __osSiCreateAccessQueue() {
void __osSiCreateAccessQueue(void) {
gOSSiAccessQueueCreated = 1;
osCreateMesgQueue(&gOSSiMessageQueue, &osSiMesgBuff[0], SIAccessQueueSize - 1);
osSendMesg(&gOSSiMessageQueue, NULL, OS_MESG_NOBLOCK);
}
void __osSiGetAccess() {
OSMesg sp1c;
void __osSiGetAccess(void) {
OSMesg mesg;
if (!gOSSiAccessQueueCreated) {
__osSiCreateAccessQueue();
}
osRecvMesg(&gOSSiMessageQueue, &sp1c, OS_MESG_BLOCK);
osRecvMesg(&gOSSiMessageQueue, &mesg, OS_MESG_BLOCK);
}
void __osSiRelAccess() {
void __osSiRelAccess(void) {
osSendMesg(&gOSSiMessageQueue, NULL, OS_MESG_NOBLOCK);
}

View file

@ -1,5 +1,5 @@
#include "global.h"
u32 __osSpGetStatus() {
u32 __osSpGetStatus(void) {
return HW_REG(SP_STATUS_REG, u32);
}

View file

@ -1,5 +1,5 @@
#include "global.h"
void __osSpSetStatus(u32 a0) {
HW_REG(SP_STATUS_REG, u32) = a0;
void __osSpSetStatus(u32 status) {
HW_REG(SP_STATUS_REG, u32) = status;
}

View file

@ -8,9 +8,8 @@ u8 __osPfsInodeCacheBank = 250;
u16 __osSumcalc(u8* ptr, s32 length) {
s32 i;
u32 sum = 0;
u8* temp;
u8* temp = ptr;
temp = ptr;
for (i = 0; i < length; i++) {
sum += *temp++;
}
@ -18,7 +17,6 @@ u16 __osSumcalc(u8* ptr, s32 length) {
}
s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum) {
u16 data = 0;
u32 i;
@ -99,14 +97,14 @@ s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) {
newid->deviceid = (badid->deviceid & 0xFFFE) | mask;
newid->banks = j;
newid->version = badid->version;
__osIdCheckSum(newid, &newid->checksum, &newid->invertedChecksum);
__osIdCheckSum((u16*)newid, &newid->checksum, &newid->invertedChecksum);
index[0] = PFS_ID_0AREA;
index[1] = PFS_ID_1AREA;
index[2] = PFS_ID_2AREA;
index[3] = PFS_ID_3AREA;
for (i = 0; i < 4; i++) {
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, index[i], newid, PFS_FORCE)) != 0) {
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, PFS_FORCE)) != 0) {
return ret;
}
}
@ -121,8 +119,7 @@ s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid) {
return 0;
}
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp) {
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check) {
u16 index[4];
s32 ret = 0;
u16 sum;
@ -139,11 +136,11 @@ s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp) {
index[2] = PFS_ID_2AREA;
index[3] = PFS_ID_3AREA;
for (i = 1; i < 4; i++) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, index[i], temp)) != 0) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, index[i], (u8*)check)) != 0) {
return ret;
}
__osIdCheckSum(temp, &sum, &idSum);
if ((temp->checksum == sum) && (temp->invertedChecksum == idSum)) {
__osIdCheckSum((u16*)check, &sum, &idSum);
if ((check->checksum == sum) && (check->invertedChecksum == idSum)) {
break;
}
}
@ -153,7 +150,7 @@ s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp) {
for (j = 0; j < 4; j++) {
if (j != i) {
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, index[j], temp, PFS_FORCE)) != 0) {
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)check, PFS_FORCE)) != 0) {
return ret;
}
}
@ -274,7 +271,7 @@ s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) {
if (flag == PFS_WRITE) {
inode->inodePage[0].inode_t.page =
__osSumcalc(inode->inodePage + offset, (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
__osSumcalc((u8*)(inode->inodePage + offset), (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
}
for (j = 0; j < PFS_ONE_PAGE; j++) {
@ -297,7 +294,7 @@ s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) {
addr = (u8*)(((u8*)inode) + (j * BLOCKSIZE));
ret = __osContRamRead(pfs->queue, pfs->channel, pfs->minode_table + (bank * PFS_ONE_PAGE) + j, addr);
}
sum = __osSumcalc(inode->inodePage + offset, (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
sum = __osSumcalc((u8*)(inode->inodePage + offset), (PFS_INODE_SIZE_PER_PAGE - offset) * 2);
if (sum != inode->inodePage[0].inode_t.page) {
return PFS_ERR_INCONSISTENT;
}
@ -310,5 +307,6 @@ s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank) {
__osPfsInodeCacheBank = bank;
bcopy(inode, &__osPfsInodeCache, sizeof(__OSInode));
__osPfsInodeCacheChannel = pfs->channel;
return 0;
}

View file

@ -4,11 +4,9 @@
* osContStartQuery:
* Starts to read the values for SI device status and type which are connected to the controller port and joyport
* connector.
**/
*/
s32 osContStartQuery(OSMesgQueue* mq) {
s32 ret;
ret = 0;
s32 ret = 0;
__osSiGetAccess();
if (__osContLastPoll != CONT_CMD_REQUEST_STATUS) {
@ -25,7 +23,7 @@ s32 osContStartQuery(OSMesgQueue* mq) {
/**
* osContGetQuery:
* Returns the values from osContStartQuery to status. Both functions must be paired for use.
**/
*/
void osContGetQuery(OSContStatus* data) {
u8 pattern;
__osContGetInitData(&pattern, data);

View file

@ -22,16 +22,13 @@ f32 cosf(f32 x) {
f64 dn;
s32 n;
f64 result;
s32 ix, xpt;
s32 ix = *(s32*)&x;
s32 xpt = (ix >> 22);
ix = *(s32*)&x;
xpt = (ix >> 22);
xpt &= 0x1FF;
if (xpt < 0x136) {
absx = (x > 0) ? x : -x;
dx = absx;
dn = dx * rpi.d + 0.5;
@ -52,10 +49,8 @@ f32 cosf(f32 x) {
if (!(n & 1)) {
return (f32)result;
}
return -(f32)result;
}
if (x != x) {
return __libm_qnan_f;
}

View file

@ -2,8 +2,12 @@
void guLookAtF(f32 mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp) {
f32 length;
f32 xLook, yLook, zLook;
f32 xRight, yRight, zRight;
f32 xLook;
f32 yLook;
f32 zLook;
f32 xRight;
f32 yRight;
f32 zRight;
guMtxIdentF(mf);
@ -57,5 +61,5 @@ void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f
guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp);
guMtxF2L(mf, m);
guMtxF2L((MtxF*)mf, m);
}

View file

@ -11,7 +11,16 @@ void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32
f32 xl2, f32 yl2, f32 zl2, /* light 2 direction */
s32 hiliteWidth, s32 hiliteHeight) /* size of hilite texture */
{
f32 length, xLook, yLook, zLook, xRight, yRight, zRight, xHilite, yHilite, zHilite;
f32 length;
f32 xLook;
f32 yLook;
f32 zLook;
f32 xRight;
f32 yRight;
f32 zRight;
f32 xHilite;
f32 yHilite;
f32 zHilite;
guMtxIdentF(mf);
@ -148,5 +157,5 @@ void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye,
guLookAtHiliteF(mf, l, h, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp, xl1, yl1, zl1, xl2, yl2, zl2, hiliteWidth,
hiliteHeight);
guMtxF2L(mf, m);
guMtxF2L((MtxF*)mf, m);
}

View file

@ -4,7 +4,9 @@ void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near
f32 yscale;
s32 row;
s32 col;
guMtxIdentF(mf);
fovy *= GU_PI / 180.0;
yscale = cosf(fovy / 2) / sinf(fovy / 2);
mf[0][0] = yscale / aspect;
@ -13,11 +15,13 @@ void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near
mf[2][3] = -1;
mf[3][2] = 2 * near * far / (near - far);
mf[3][3] = 0.0f;
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
mf[row][col] *= scale;
}
}
if (perspNorm != NULL) {
if (near + far <= 2.0) {
*perspNorm = 65535;
@ -30,7 +34,8 @@ void guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near
}
}
void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale) {
f32 mat[4][4];
guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale);
guMtxF2L(mat, m);
f32 mf[4][4];
guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale);
guMtxF2L((MtxF*)mf, m);
}

View file

@ -3,8 +3,7 @@
/**
* guPositionF
* Creates a rotation/parallel translation modeling matrix (floating point)
**/
*/
void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z) {
static f32 D_80134D00 = M_PI / 180.0;
f32 sinr, sinp, sinh;
@ -51,5 +50,5 @@ void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f3
guPositionF(mf, rot, pitch, yaw, scale, x, y, z);
guMtxF2L(mf, m);
guMtxF2L((MtxF*)mf, m);
}

View file

@ -1,13 +1,10 @@
#include "global.h"
void guS2DInitBg(uObjBg* bg) {
u16 shift;
u32 size;
s32 tmem;
s32 tmem = (bg->b.imageFmt == G_IM_FMT_CI) ? 0x100 : 0x200;
u16 shift = (6 - bg->b.imageSiz);
tmem = (bg->b.imageFmt == G_IM_FMT_CI) ? 0x100 : 0x200;
shift = (6 - bg->b.imageSiz);
if (bg->b.imageLoad == G_BGLT_LOADBLOCK) {
bg->b.tmemW = bg->b.imageW >> shift;
bg->b.tmemH = (tmem / bg->b.tmemW) * 4;

View file

@ -21,9 +21,9 @@ void guOrthoF(f32 mf[4][4], f32 left, f32 right, f32 bottom, f32 top, f32 near,
}
void guOrtho(Mtx* mtx, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far, f32 scale) {
MtxF_t mf;
f32 mf[4][4];
guOrthoF(mf, left, right, bottom, top, near, far, scale);
guMtxF2L(mf, mtx);
guMtxF2L((MtxF*)mf, mtx);
}

View file

@ -1,5 +1,5 @@
#include "global.h"
u32 osAiGetLength() {
u32 osAiGetLength(void) {
return HW_REG(AI_LEN_REG, u32);
}

View file

@ -1,12 +1,9 @@
#include "global.h"
s32 osAiSetFrequency(u32 frequency) {
u32 dacRate;
u8 bitrate;
f32 dacRateF;
dacRateF = ((f32)osViClock / frequency) + 0.5f;
dacRate = dacRateF;
f32 dacRateF = ((f32)osViClock / frequency) + 0.5f;
u32 dacRate = dacRateF;
if (dacRate < 132) {
return -1;

View file

@ -11,6 +11,7 @@ OSMesg __osEepromTimerMsg;
u32 gOSContInitialized = 0;
#define HALF_SECOND OS_USEC_TO_CYCLES(500000)
s32 osContInit(OSMesgQueue* mq, u8* ctlBitfield, OSContStatus* status) {
OSMesg mesg;
s32 ret = 0;
@ -21,6 +22,7 @@ s32 osContInit(OSMesgQueue* mq, u8* ctlBitfield, OSContStatus* status) {
if (gOSContInitialized) {
return 0;
}
gOSContInitialized = 1;
currentTime = osGetTime();
if (HALF_SECOND > currentTime) {
@ -38,6 +40,7 @@ s32 osContInit(OSMesgQueue* mq, u8* ctlBitfield, OSContStatus* status) {
__osContLastPoll = CONT_CMD_REQUEST_STATUS;
__osSiCreateAccessQueue();
osCreateMesgQueue(&__osEepromTimerMsgQ, &__osEepromTimerMsg, 1);
return ret;
}
@ -46,7 +49,9 @@ void __osContGetInitData(u8* ctlBitfield, OSContStatus* status) {
__OSContRequestHeader req;
s32 i;
u8 bitfieldTemp = 0;
bufptr = (u8*)(&__osPifInternalBuff);
for (i = 0; i < __osMaxControllers; i++, bufptr += sizeof(req), status++) {
req = *((__OSContRequestHeader*)bufptr);
status->errno = (req.rxsize & 0xC0) >> 4;
@ -64,12 +69,13 @@ void __osPackRequestData(u8 poll) {
u8* bufptr;
__OSContRequestHeader req;
s32 i;
for (i = 0; i < 0xF; i++) {
__osPifInternalBuff.ram[i] = 0;
}
__osPifInternalBuff.status = 1;
bufptr = &__osPifInternalBuff;
bufptr = (u8*)(&__osPifInternalBuff);
req.align = 0xFF;
req.txsize = 1;

View file

@ -4,8 +4,7 @@
* osContStartQuery:
* Starts to read the values for SI device status and type which are connected to the controller port and joyport
* connector.
**/
*/
s32 osContStartQuery(OSMesgQueue* mq) {
s32 ret;
ret = 0;
@ -25,7 +24,7 @@ s32 osContStartQuery(OSMesgQueue* mq) {
/**
* osContGetQuery:
* Returns the values from osContStartQuery to status. Both functions must be paired for use.
**/
*/
void osContGetQuery(OSContStatus* data) {
u8 pattern;
__osContGetInitData(&pattern, data);

View file

@ -2,6 +2,7 @@
s32 osContStartReadData(OSMesgQueue* mq) {
s32 ret;
__osSiGetAccess();
if (__osContLastPoll != 1) {
__osPackReadData();
@ -15,10 +16,10 @@ s32 osContStartReadData(OSMesgQueue* mq) {
}
void osContGetReadData(OSContPad* contData) {
u8* bufptr;
u8* bufptr = (u8*)(&__osPifInternalBuff);
__OSContReadHeader read;
s32 i;
bufptr = (u8*)(&__osPifInternalBuff);
for (i = 0; i < __osMaxControllers; i++, bufptr += sizeof(read), contData++) {
read = *((__OSContReadHeader*)bufptr);
contData->errno = (read.rxsize & 0xC0) >> 4;
@ -30,11 +31,11 @@ void osContGetReadData(OSContPad* contData) {
};
}
void __osPackReadData() {
u8* bufptr;
void __osPackReadData(void) {
u8* bufptr = (u8*)(&__osPifInternalBuff);
__OSContReadHeader read;
s32 i;
bufptr = (u8*)(&__osPifInternalBuff);
for (i = 0; i < 0xF; i++) {
__osPifInternalBuff.ram[i] = 0;
}

View file

@ -2,7 +2,6 @@
#include "global.h"
s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName) {
s32 file_no;
s32 ret;
__OSInode inode;
@ -24,6 +23,7 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8*
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir)) != 0) {
return ret;
}
startpage = dir.start_page.inode_t.page;
for (bank = dir.start_page.inode_t.bank; bank < pfs->banks;) {
if ((ret = __osPfsRWInode(pfs, &inode, PFS_READ, bank)) != 0) {
@ -48,6 +48,7 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8*
bzero(&dir, sizeof(__OSDir));
ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, 0);
return ret;
}

View file

@ -21,7 +21,7 @@ s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state) {
if (pfs->activebank != 0 && (ret = __osPfsSelectBank(pfs, 0)) != 0) {
return ret;
}
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, &dir)) != 0) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir)) != 0) {
return ret;
}
if (dir.company_code == 0 || dir.game_code == 0) {
@ -53,5 +53,6 @@ s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state) {
state->game_code = dir.game_code;
bcopy(&dir.game_name, state->game_name, PFS_FILE_NAME_LEN);
bcopy(&dir.ext_name, state->ext_name, PFS_FILE_EXT_LEN);
return __osPfsGetStatus(pfs->queue, pfs->channel);
}

View file

@ -17,7 +17,7 @@ s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* e
}
for (j = 0; j < pfs->dir_size; j++) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, &dir)) != 0) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir)) != 0) {
return ret;
}
if ((ret = __osPfsGetStatus(pfs->queue, pfs->channel)) != 0) {

View file

@ -13,7 +13,6 @@ s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes) {
if (!(pfs->status & PFS_INITIALIZED)) {
return (PFS_ERR_INVALID);
}
if ((ret = __osCheckId(pfs)) != 0) {
return ret;
}

View file

@ -15,10 +15,10 @@ s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern) {
do {
__osPfsRequestData(CONT_CMD_REQUEST_STATUS);
ret = __osSiRawStartDma(OS_WRITE, &pifMempakBuf);
ret = __osSiRawStartDma(OS_WRITE, &gPifMempakBuf);
osRecvMesg(mq, &msg, OS_MESG_BLOCK);
ret = __osSiRawStartDma(OS_READ, &pifMempakBuf);
ret = __osSiRawStartDma(OS_READ, &gPifMempakBuf);
osRecvMesg(mq, &msg, OS_MESG_BLOCK);
__osPfsGetInitData(&bitpattern, &contData[0]);
@ -45,13 +45,13 @@ s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern) {
}
void __osPfsRequestData(u8 poll) {
u8* bufPtr = &pifMempakBuf;
u8* bufPtr = (u8*)&gPifMempakBuf;
__OSContRequestHeader req;
s32 i;
__osContLastPoll = poll;
pifMempakBuf.status = 1;
gPifMempakBuf.status = 1;
req.align = 0xFF;
req.txsize = 1;
@ -75,7 +75,7 @@ void __osPfsGetInitData(u8* pattern, OSContStatus* contData) {
s32 i;
u8 bits = 0;
bufptr = &pifMempakBuf;
bufptr = (u8*)&gPifMempakBuf;
for (i = 0; i < __osMaxControllers; i++, bufptr += sizeof(req), contData++) {
req = *((__OSContRequestHeader*)bufptr);

View file

@ -11,8 +11,10 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
s32 retryCount = 2;
__osSiGetAccess();
do {
bufptr = &pifMempakBuf;
bufptr = (u8*)&gPifMempakBuf;
if ((__osContLastPoll != 2) || (__osPfsLastChannel != channel)) {
__osContLastPoll = 2;
@ -20,7 +22,7 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
// clang-format off
for (i = 0; i < channel; i++) { *bufptr++ = 0; }
// clang-format on
pifMempakBuf.status = 1;
gPifMempakBuf.status = 1;
((__OSContRamHeader*)bufptr)->unk_00 = 0xFF;
((__OSContRamHeader*)bufptr)->txsize = 3;
((__OSContRamHeader*)bufptr)->rxsize = 0x21;
@ -31,12 +33,14 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
} else {
bufptr += channel;
}
((__OSContRamHeader*)bufptr)->hi = addr >> 3; // send byte 1
((__OSContRamHeader*)bufptr)->lo = (s8)(__osContAddressCrc(addr) | (addr << 5)); // send byte 2
__osSiRawStartDma(OS_WRITE, &pifMempakBuf);
__osSiRawStartDma(OS_WRITE, &gPifMempakBuf);
osRecvMesg(ctrlrqueue, NULL, OS_MESG_BLOCK);
__osSiRawStartDma(OS_READ, &pifMempakBuf);
__osSiRawStartDma(OS_READ, &gPifMempakBuf);
osRecvMesg(ctrlrqueue, NULL, OS_MESG_BLOCK);
ret = (((__OSContRamHeader*)bufptr)->rxsize & 0xC0) >> 4;
if (!ret) {
if (((__OSContRamHeader*)bufptr)->datacrc != __osContDataCrc(bufptr + 6)) {
@ -55,6 +59,8 @@ s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) {
break;
}
} while (0 <= retryCount--);
__osSiRelAccess();
return ret;
}

View file

@ -5,16 +5,15 @@
OSPifRam osPifBuffers[MAXCONTROLLERS];
// func_800CF990 in 1.0
s32 osSetRumble(OSPfs* pfs, u32 vibrate) {
s32 i;
s32 ret;
u8* buf;
u8* buf = (u8*)&osPifBuffers[pfs->channel];
buf = (u8*)&osPifBuffers[pfs->channel];
if (!(pfs->status & 8)) {
return 5;
}
__osSiGetAccess();
osPifBuffers[pfs->channel].status = 1;
buf += pfs->channel;
@ -27,6 +26,7 @@ s32 osSetRumble(OSPfs* pfs, u32 vibrate) {
osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK);
__osSiRawStartDma(OS_READ, &osPifBuffers[pfs->channel]);
osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK);
ret = ((__OSContRamHeader*)buf)->rxsize & 0xC0;
if (!ret) {
if (!vibrate) {
@ -39,7 +39,9 @@ s32 osSetRumble(OSPfs* pfs, u32 vibrate) {
}
}
}
__osSiRelAccess();
return ret;
}
@ -47,17 +49,20 @@ void osSetUpMempakWrite(s32 channel, OSPifRam* buf) {
u8* bufptr = (u8*)buf;
__OSContRamHeader mempakwr;
s32 i;
mempakwr.unk_00 = 0xFF;
mempakwr.txsize = 0x23;
mempakwr.rxsize = 1;
mempakwr.poll = 3; // write mempak
mempakwr.hi = 0x600 >> 3;
mempakwr.lo = (u8)(__osContAddressCrc(0x600) | (0x600 << 5));
if (channel != 0) {
for (i = 0; i < channel; ++i) {
*bufptr++ = 0;
}
}
*(__OSContRamHeader*)bufptr = mempakwr;
bufptr += sizeof(mempakwr);
*bufptr = 0xFE;
@ -80,7 +85,6 @@ s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) {
return ret;
}
ret = __osContRamRead(ctrlrqueue, channel, BANK_ADDR, sp24);
ret = ret;
if (ret == 2) {
ret = 4; // "Controller pack communication error"
}
@ -111,5 +115,6 @@ s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, OSPfs* pfs, u32 channel) {
osSetUpMempakWrite(channel, &osPifBuffers[channel]);
}
pfs->status = PFS_MOTOR_INITIALIZED;
return 0; // "Recognized rumble pak"
}

View file

@ -1,5 +1,5 @@
#include "global.h"
void osSpTaskYield() {
void osSpTaskYield(void) {
__osSpSetStatus(SP_STATUS_SIG3);
}

View file

@ -2,9 +2,7 @@
u32 osSpTaskYielded(OSTask* task) {
u32 ret;
u32 status;
status = __osSpGetStatus();
u32 status = __osSpGetStatus();
if (status & SP_STATUS_YIELDED) {
ret = OS_TASK_YIELDED;

View file

@ -1,12 +1,10 @@
#include "global.h"
u32* osViGetCurrentFramebuffer() {
register u32 sMask = __osDisableInt();
u32* var1;
u32* osViGetCurrentFramebuffer(void) {
register u32 prevInt = __osDisableInt();
u32* var1 = __osViCurr->buffer;
var1 = __osViCurr->buffer;
__osRestoreInt(sMask);
__osRestoreInt(prevInt);
return var1;
}

View file

@ -3,10 +3,11 @@
extern OSViContext* __osViNext;
void osViSetEvent(OSMesgQueue* mq, OSMesg msg, u32 retraceCount) {
register u32 saveMask;
saveMask = __osDisableInt();
register u32 prevInt = __osDisableInt();
__osViNext->mq = mq;
__osViNext->msg = msg;
__osViNext->retraceCount = retraceCount;
__osRestoreInt(saveMask);
__osRestoreInt(prevInt);
}

View file

@ -3,11 +3,14 @@
#include "ultra64/pfs.h"
s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo) {
s32 startPage, decleared, prevPage;
s32 startPage;
s32 decleared;
s32 prevPage;
s32 oldPrevPage = 0;
s32 ret = 0;
s32 fileSizeInPages;
__OSInode inode, backup_inode;
__OSInode inode;
__OSInode backupInode;
__OSDir dir;
u8 bank;
u8 prevBank = 0;
@ -58,14 +61,14 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u
fpage.inode_t.page = (u8)startPage;
fpage.inode_t.bank = bank;
} else { /* Writing previous bank inode */
backup_inode.inodePage[oldPrevPage].inode_t.bank = bank;
backup_inode.inodePage[oldPrevPage].inode_t.page = (u8)startPage;
if ((ret = __osPfsRWInode(pfs, &backup_inode, PFS_WRITE, prevBank)) != 0) {
backupInode.inodePage[oldPrevPage].inode_t.bank = bank;
backupInode.inodePage[oldPrevPage].inode_t.page = (u8)startPage;
if ((ret = __osPfsRWInode(pfs, &backupInode, PFS_WRITE, prevBank)) != 0) {
return ret;
}
}
if (fileSizeInPages > decleared) {
bcopy(&inode, &backup_inode, sizeof(__OSInode));
bcopy(&inode, &backupInode, sizeof(__OSInode));
oldPrevPage = prevPage;
prevBank = bank;
fileSizeInPages -= decleared;
@ -91,8 +94,7 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u
bcopy(gameName, dir.game_name, PFS_FILE_NAME_LEN);
bcopy(extName, dir.ext_name, PFS_FILE_EXT_LEN);
ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + *fileNo, &dir, 0);
return ret;
return __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + *fileNo, (u8*)&dir, 0);
}
s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared,
@ -100,9 +102,8 @@ s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* s
s32 j;
s32 spage, prevPage;
s32 ret = 0;
s32 offset;
s32 offset = ((bank > PFS_ID_BANK_256K) ? 1 : pfs->inodeStartPage);
offset = ((bank > PFS_ID_BANK_256K) ? 1 : pfs->inodeStartPage);
for (j = offset; j < PFS_INODE_SIZE_PER_PAGE; j++) {
if (inode->inodePage[j].ipage == PFS_PAGE_NOT_USED) {
break;
@ -126,6 +127,7 @@ s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* s
}
j++;
}
*startPage = spage;
if ((j == (PFS_INODE_SIZE_PER_PAGE)) && (fileSizeInPages > *decleared)) {
*finalPage = prevPage;

View file

@ -14,39 +14,32 @@ s32 osPfsChecker(OSPfs* pfs) {
__OSInode tempInode;
__OSDir tempDir;
__OSInodeUnit nextNodeInFile[16];
__OSInodeCache cache;
s32 fixed = 0;
u8 bank, prevBank = 254;
s32 cc, cl;
s32 offset;
ret = __osCheckId(pfs);
if (ret == PFS_ERR_NEW_PACK) {
ret = __osGetId(pfs);
}
if (ret) {
return ret;
}
if ((ret = func_80105788(pfs, &cache)) != 0) {
return ret;
}
for (j = 0; j < pfs->dir_size; j++) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, &tempDir)) != 0) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tempDir)) != 0) {
return ret;
}
if ((tempDir.company_code != 0) || (tempDir.game_code != 0)) {
if ((tempDir.company_code == 0) || (tempDir.game_code == 0)) {
cc = -1;
} else {
next = tempDir.start_page;
cl = cc = 0;
bank = 255;
@ -57,21 +50,17 @@ s32 osPfsChecker(OSPfs* pfs) {
ret = __osPfsRWInode(pfs, &tempInode, PFS_READ, bank);
prevBank = bank;
}
if ((ret != 0) && (ret != PFS_ERR_INCONSISTENT)) {
return ret;
}
}
if ((cc = func_80105A60(pfs, next, &cache) - cl) != 0) {
break;
}
cl = 1;
next = tempInode.inodePage[next.inode_t.page];
}
}
if ((cc != 0) || (next.ipage != PFS_EOF)) {
bzero(&tempDir, sizeof(__OSDir));
if (pfs->activebank != 0) {
@ -79,7 +68,7 @@ s32 osPfsChecker(OSPfs* pfs) {
return ret;
}
}
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, &tempDir, 0)) != 0) {
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tempDir, 0)) != 0) {
return ret;
}
@ -87,8 +76,9 @@ s32 osPfsChecker(OSPfs* pfs) {
}
}
}
for (j = 0; j < pfs->dir_size; j++) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, &tempDir)) != 0) {
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tempDir)) != 0) {
return ret;
}
@ -184,7 +174,7 @@ s32 func_80105A60(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache) {
if ((bank == fpage.inode_t.bank) || (cache->map[n] & (1 << (bank % PFS_BANK_LAPPED_BY))) != 0) {
if (bank != cache->bank) {
ret = __osPfsRWInode(pfs, &(cache->inode), PFS_READ, bank);
if ((ret) && (ret != PFS_ERR_INCONSISTENT)) {
if (ret && (ret != PFS_ERR_INCONSISTENT)) {
return ret;
}
cache->bank = bank;

View file

@ -26,11 +26,9 @@ s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, s32 channel) {
if ((ret = __osPfsCheckRamArea(pfs)) != 0) {
return ret;
}
if ((ret = __osPfsSelectBank(pfs, 0)) != 0) {
return ret;
}
if ((ret = __osContRamRead(pfs->queue, pfs->channel, PFS_ID_0AREA, temp)) != 0) {
return (ret);
}
@ -60,7 +58,7 @@ s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, s32 channel) {
bcopy(id, pfs->id, BLOCKSIZE);
if (0) {}
if (1) {}
pfs->version = id->version;
pfs->banks = id->banks;
@ -90,9 +88,8 @@ s32 __osPfsCheckRamArea(OSPfs* pfs) {
if ((ret = __osPfsSelectBank(pfs, PFS_ID_BANK_256K)) != 0) {
return ret;
}
if ((ret = __osContRamRead(pfs->queue, pfs->channel, 0, saveReg)) != 0) {
return (ret);
return ret;
}
for (i = 0; i < BLOCKSIZE; i++) {
temp1[i] = i;
@ -106,7 +103,5 @@ s32 __osPfsCheckRamArea(OSPfs* pfs) {
if (bcmp(temp1, temp2, BLOCKSIZE) != 0) {
return PFS_ERR_DEVICE;
}
ret = __osContRamWrite(pfs->queue, pfs->channel, 0, saveReg, 0);
return ret;
return __osContRamWrite(pfs->queue, pfs->channel, 0, saveReg, 0);
}

View file

@ -50,37 +50,29 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8
if (!(pfs->status & PFS_INITIALIZED)) {
return PFS_ERR_INVALID;
}
if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) {
return PFS_ERR_NEW_PACK;
}
if (pfs->activebank != 0) {
if ((ret = __osPfsSelectBank(pfs, 0)) != 0) {
return ret;
}
}
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, &dir)) != 0) {
if (pfs->activebank != 0 && (ret = __osPfsSelectBank(pfs, 0)) != 0) {
return ret;
}
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir)) != 0) {
return ret;
}
if ((dir.company_code == 0) || (dir.game_code == 0)) {
return PFS_ERR_INVALID;
}
if (!CHECK_IPAGE(dir.start_page, *pfs)) {
if (dir.start_page.ipage == PFS_EOF) {
return PFS_ERR_INVALID;
}
return PFS_ERR_INCONSISTENT;
}
if ((flag == PFS_READ) && ((dir.status & PFS_WRITTEN) == 0)) {
return PFS_ERR_BAD_DATA;
}
bank = 255;
curBlock = offset / BLOCKSIZE;
curPage = dir.start_page;
@ -101,11 +93,8 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8
}
curBlock = 0;
}
if (pfs->activebank != curPage.inode_t.bank) {
if ((ret = __osPfsSelectBank(pfs, curPage.inode_t.bank)) != 0) {
return ret;
}
if (pfs->activebank != curPage.inode_t.bank && (ret = __osPfsSelectBank(pfs, curPage.inode_t.bank)) != 0) {
return ret;
}
blockno = curPage.inode_t.page * PFS_ONE_PAGE + curBlock;
@ -125,16 +114,13 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8
if (flag == PFS_WRITE && !(dir.status & PFS_WRITTEN)) {
dir.status |= PFS_WRITTEN;
if (pfs->activebank != 0) {
if ((ret = __osPfsSelectBank(pfs, 0)) != 0) {
return ret;
}
if (pfs->activebank != 0 && (ret = __osPfsSelectBank(pfs, 0)) != 0) {
return ret;
}
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + fileNo, &dir, 0)) != 0) {
if ((ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + fileNo, (u8*)&dir, 0)) != 0) {
return ret;
}
}
ret = __osPfsGetStatus(pfs->queue, pfs->channel);
return ret;
return __osPfsGetStatus(pfs->queue, pfs->channel);
}

View file

@ -45,6 +45,7 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z) {
f32 mf[4][4];
guRotateF(mf, a, x, y, z);
guMtxF2L(mf, m);
guMtxF2L((MtxF*)mf, m);
}

View file

@ -21,10 +21,9 @@ f32 sinf(f32 x) {
f64 dn;
s32 n;
f64 result;
s32 ix, xpt;
s32 ix = *(s32*)&x;
s32 xpt = (ix >> 22);
ix = *(s32*)&x;
xpt = (ix >> 22);
xpt &= 0x1FF;
if (xpt < 0xFF) {
@ -55,7 +54,6 @@ f32 sinf(f32 x) {
if (!(n & 1)) {
return (f32)result;
}
return -(f32)result;
}

View file

@ -1,11 +1,10 @@
#include "global.h"
u32 __osSpDeviceBusy() {
u32 __osSpDeviceBusy(void) {
register u32 status = HW_REG(SP_STATUS_REG, u32);
if (status & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) {
return 1;
}
return 0;
}

View file

@ -19,6 +19,7 @@ OSTask* _VirtualToPhysicalTask(OSTask* intp) {
_osVirtualToPhysical(tp->t.output_buff_size);
_osVirtualToPhysical(tp->t.data_ptr);
_osVirtualToPhysical(tp->t.yield_data_ptr);
return tp;
}
@ -29,34 +30,31 @@ void osSpTaskLoad(OSTask* intp) {
tp->t.ucode_data = tp->t.yield_data_ptr;
tp->t.ucode_data_size = tp->t.yield_data_size;
intp->t.flags &= ~OS_TASK_YIELDED;
if (tp->t.flags & OS_TASK_LOADABLE) {
tp->t.ucode = HW_REG((u32)intp->t.yield_data_ptr + OS_YIELD_DATA_SIZE - 4, u32);
}
}
osWritebackDCache(tp, sizeof(OSTask));
__osSpSetStatus(SP_CLR_SIG0 | SP_CLR_SIG1 | SP_CLR_SIG2 | SP_SET_INTR_BREAK);
while (__osSpSetPc((void*)SP_IMEM_START) == -1) {
;
}
while (__osSpRawStartDma(1, (void*)(SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) {
;
}
while (__osSpDeviceBusy()) {
;
}
while (__osSpRawStartDma(1, (void*)SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) {
;
}
}
void osSpTaskStartGo(OSTask* tp) {
while (__osSpDeviceBusy()) {
;
}
__osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT);
}

View file

@ -1,7 +1,6 @@
#include "global.h"
#ifndef __GNUC__
#pragma intrinsic(sqrtf)
#define __builtin_sqrtf sqrtf
#endif