Refresh 15

This commit is contained in:
n64
2021-10-14 15:25:30 -04:00
parent f9982e0ef5
commit 1372ae1bb7
383 changed files with 7001 additions and 5730 deletions

View File

@@ -134,9 +134,9 @@ glabel rspF3DDataEnd
glabel rspF3DDataStart
#ifdef F3DZEX_GBI_2
.incbin "lib/PR/f3dex2/F3DZEX_NoN_data.bin"
#elseif F3DEX_GBI
#elif defined(F3DEX_GBI)
.incbin "lib/PR/f3dex/F3DEX_data.bin"
#elseif F3DEX_GBI_2
#elif defined(F3DEX_GBI_2)
.incbin "lib/PR/f3dex2/F3DEX2_data.bin"
#endif
glabel rspF3DDataEnd

View File

@@ -57,7 +57,7 @@ u32 D_802F4380() {
return 1;
}
sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize);
sp30->sectorNum += 1;
sp30->sectorNum++;
osEPiRawStartDma(__osDiskHandle, 1, 0x05000400, sp2c->dramAddr, sp2c->sectorSize);
return 1;
}
@@ -77,8 +77,7 @@ u32 D_802F4380() {
sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize);
}
sp34 = HW_REG(ASIC_BM_STATUS, u32);
if (((C1_SINGLE & sp34) && (C1_DOUBLE & sp34)) || (sp34 & MICRO_STATUS))
{
if (((C1_SINGLE & sp34) && (C1_DOUBLE & sp34)) || (sp34 & MICRO_STATUS)) {
if (sp2c->C1ErrNum > 3) {
if (sp30->transferMode != 3 || sp30->sectorNum > 0x52) {
sp30->errStatus = 17;
@@ -89,7 +88,7 @@ u32 D_802F4380() {
sp28 = sp2c->C1ErrNum;
sp2c->C1ErrSector[sp28] = sp30->sectorNum + 1;
}
sp2c->C1ErrNum += 1;
sp2c->C1ErrNum++;
}
if (sp3c & C2_TRANSFER) {
if (sp30->sectorNum != 87) {
@@ -123,7 +122,7 @@ u32 D_802F4380() {
sp30->errStatus = 0;
func_802F4B08();
}
sp30->sectorNum += 1;
sp30->sectorNum++;
if (sp3c & DATA_REQUEST) {
if (sp30->sectorNum > 0x54) {
sp30->errStatus = 6;

View File

@@ -1,14 +1,6 @@
#include "libultra_internal.h"
#include "hardware.h"
#ifdef VERSION_SH
extern s32 D_SH_80000300; // Potentially a TV type
#endif
#ifndef VERSION_JP
extern u32 osTvType;
#endif
OSViContext sViContexts[2] = { 0 };
OSViContext *__osViCurr = &sViContexts[0];
OSViContext *__osViNext = &sViContexts[1];
@@ -80,6 +72,7 @@ void __osViInit(void) {
osViClock = 0x02E6025C;
#endif
}
#endif
__osViNext->unk00 = 0x20;

View File

@@ -32,7 +32,7 @@ void func_802F4B08(void) {
}
sp24 = (sp28->first + sp28->validCount) % sp28->msgCount;
sp28->msg[sp24] = sp2c->msg;
sp28->validCount += 1;
sp28->validCount++;
if (sp28->mtqueue->next != NULL) {
s0 = __osPopThread(&sp28->mtqueue);
__osEnqueueThread(&D_80334898, s0);

View File

@@ -93,7 +93,7 @@ s32 __osLeoInterrupt() {
int errNum = blockInfo->C1ErrNum;
blockInfo->C1ErrSector[errNum] = info->sectorNum + 1;
}
blockInfo->C1ErrNum += 1;
blockInfo->C1ErrNum++;
}
if (stat & LEO_STATUS_C2_TRANSFER) {
if (info->sectorNum != 87) {

View File

@@ -13,8 +13,8 @@ static OSIoMesg viEventCounterMesg;
extern void __osTimerServicesInit(void);
extern void __osTimerInterrupt(void);
extern OSTime _osCurrentTime;
extern u32 D_80365DA8;
extern OSTime __osCurrentTime;
extern u32 __osBaseCounter;
extern u32 __osViIntrCount;
void viMgrMain(void *);
@@ -92,13 +92,13 @@ void viMgrMain(void *vargs) {
__osViIntrCount++;
if (sp28) {
sp24 = osGetCount();
_osCurrentTime = sp24;
__osCurrentTime = sp24;
sp28 = 0;
}
sp24 = D_80365DA8;
D_80365DA8 = osGetCount();
sp24 = D_80365DA8 - sp24;
_osCurrentTime = _osCurrentTime + sp24;
sp24 = __osBaseCounter;
__osBaseCounter = osGetCount();
sp24 = __osBaseCounter - sp24;
__osCurrentTime = __osCurrentTime + sp24;
break;
case 14:

View File

@@ -20,7 +20,7 @@ s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
}
nbytes -= 8;
address += 1;
address++;
buffer += 8;
osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff);
osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK);

View File

@@ -21,7 +21,7 @@ s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) {
}
nbytes -= 8;
address += 1;
address++;
buffer += 8;
osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff);
osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK);

View File

@@ -1,17 +1,18 @@
#include "libultra_internal.h"
extern OSTime _osCurrentTime;
extern u32 D_80365DA8;
extern OSTime __osCurrentTime;
extern u32 __osBaseCounter;
OSTime osGetTime() {
u32 sp34;
u32 sp30;
OSTime sp28;
register u32 int_disabled;
int_disabled = __osDisableInt();
sp34 = osGetCount();
sp30 = sp34 - D_80365DA8;
sp28 = _osCurrentTime;
__osRestoreInt(int_disabled);
return sp28 + sp30;
u32 tmpTime;
u32 elapseCount;
OSTime currentCount;
register u32 saveMask;
saveMask = __osDisableInt();
tmpTime = osGetCount();
elapseCount = tmpTime - __osBaseCounter;
currentCount = __osCurrentTime;
__osRestoreInt(saveMask);
return currentCount + elapseCount;
}

View File

@@ -1,7 +1,7 @@
#include "libultra_internal.h"
extern OSTime _osCurrentTime;
extern OSTime __osCurrentTime;
void osSetTime(OSTime time) {
_osCurrentTime = time;
__osCurrentTime = time;
}

View File

@@ -1,23 +1,23 @@
#include "libultra_internal.h"
extern OSTimer *D_80334830;
extern OSTimer *__osTimerList;
extern u64 __osInsertTimer(OSTimer *);
u32 osSetTimer(OSTimer *a0, OSTime a1, u64 a2, OSMesgQueue *a3, OSMesg a4) {
u64 sp18;
a0->next = NULL;
a0->prev = NULL;
a0->interval = a2;
if (a1 != 0) {
a0->remaining = a1;
u32 osSetTimer(OSTimer *t, OSTime countdown, OSTime interval, OSMesgQueue *mq, OSMesg msg) {
OSTime time;
t->next = NULL;
t->prev = NULL;
t->interval = interval;
if (countdown != 0) {
t->remaining = countdown;
} else {
a0->remaining = a2;
t->remaining = interval;
}
a0->mq = a3;
a0->msg = a4;
sp18 = __osInsertTimer(a0);
if (D_80334830->next == a0) {
__osSetTimerIntr(sp18);
t->mq = mq;
t->msg = msg;
time = __osInsertTimer(t);
if (__osTimerList->next == t) {
__osSetTimerIntr(time);
}
return 0;
}

View File

@@ -1,88 +1,90 @@
#include "libultra_internal.h"
// TODO: document
OSTimer D_80365D80;
OSTimer *D_80334830 = &D_80365D80;
OSTime _osCurrentTime;
u32 D_80365DA8;
OSTimer __osBaseTimer;
OSTimer *__osTimerList = &__osBaseTimer;
OSTime __osCurrentTime;
u32 __osBaseCounter;
u32 __osViIntrCount;
u32 D_80365DB0;
u32 __osTimerCounter;
void __osTimerServicesInit(void) {
_osCurrentTime = 0;
D_80365DA8 = 0;
__osCurrentTime = 0;
__osBaseCounter = 0;
__osViIntrCount = 0;
D_80334830->prev = D_80334830;
D_80334830->next = D_80334830->prev;
D_80334830->remaining = 0;
D_80334830->interval = D_80334830->remaining;
D_80334830->mq = NULL;
D_80334830->msg = NULL;
__osTimerList->prev = __osTimerList;
__osTimerList->next = __osTimerList->prev;
__osTimerList->remaining = 0;
__osTimerList->interval = __osTimerList->remaining;
__osTimerList->mq = NULL;
__osTimerList->msg = NULL;
}
void __osTimerInterrupt(void) {
OSTimer *sp24;
u32 sp20;
u32 sp1c;
if (D_80334830->next == D_80334830) {
OSTimer *t;
u32 count;
u32 elapsedCycles;
if (__osTimerList->next == __osTimerList) {
return;
}
while (TRUE) {
sp24 = D_80334830->next;
if (sp24 == D_80334830) {
t = __osTimerList->next;
if (t == __osTimerList) {
__osSetCompare(0);
D_80365DB0 = 0;
__osTimerCounter = 0;
break;
}
sp20 = osGetCount();
sp1c = sp20 - D_80365DB0;
D_80365DB0 = sp20;
if (sp1c < sp24->remaining) {
sp24->remaining -= sp1c;
__osSetTimerIntr(sp24->remaining);
count = osGetCount();
elapsedCycles = count - __osTimerCounter;
__osTimerCounter = count;
if (elapsedCycles < t->remaining) {
t->remaining -= elapsedCycles;
__osSetTimerIntr(t->remaining);
return;
} else {
sp24->prev->next = sp24->next;
sp24->next->prev = sp24->prev;
sp24->next = NULL;
sp24->prev = NULL;
if (sp24->mq != NULL) {
osSendMesg(sp24->mq, sp24->msg, OS_MESG_NOBLOCK);
t->prev->next = t->next;
t->next->prev = t->prev;
t->next = NULL;
t->prev = NULL;
if (t->mq != NULL) {
osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK);
}
if (sp24->interval != 0) {
sp24->remaining = sp24->interval;
__osInsertTimer(sp24);
if (t->interval != 0) {
t->remaining = t->interval;
__osInsertTimer(t);
}
}
}
}
void __osSetTimerIntr(u64 a0) {
u64 tmp;
s32 intDisabled = __osDisableInt();
D_80365DB0 = osGetCount();
tmp = a0 + D_80365DB0;
__osSetCompare(tmp);
__osRestoreInt(intDisabled);
void __osSetTimerIntr(OSTime time) {
OSTime newTime;
s32 savedMask = __osDisableInt();
__osTimerCounter = osGetCount();
newTime = time + __osTimerCounter;
__osSetCompare(newTime);
__osRestoreInt(savedMask);
}
u64 __osInsertTimer(OSTimer *a0) {
OSTimer *sp34;
u64 sp28;
s32 intDisabled;
intDisabled = __osDisableInt();
for (sp34 = D_80334830->next, sp28 = a0->remaining; sp34 != D_80334830 && sp28 > sp34->remaining;
sp28 -= sp34->remaining, sp34 = sp34->next) {
OSTime __osInsertTimer(OSTimer *t) {
OSTimer *timep;
OSTime time;
s32 savedMask;
savedMask = __osDisableInt();
for (timep = __osTimerList->next, time = t->remaining; timep != __osTimerList && time > timep->remaining;
time -= timep->remaining, timep = timep->next) {
;
}
a0->remaining = sp28;
if (sp34 != D_80334830) {
sp34->remaining -= sp28;
t->remaining = time;
if (timep != __osTimerList) {
timep->remaining -= time;
}
a0->next = sp34;
a0->prev = sp34->prev;
sp34->prev->next = a0;
sp34->prev = a0;
__osRestoreInt(intDisabled);
return sp28;
t->next = timep;
t->prev = timep->prev;
timep->prev->next = t;
timep->prev = t;
__osRestoreInt(savedMask);
return time;
}