Refresh 10

This commit is contained in:
n64
2020-06-02 12:44:34 -04:00
parent 749df0d2ed
commit df7897da28
444 changed files with 30163 additions and 7628 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
// an array of pointers to functions taking no arguments and returning u32...
// this is only referenced in the exception handler and here. this function is called with a0=1 and
// then the same memory address is loaded. it's definitely an array access though..
extern u32 (*D_80334920[8])() ;
extern u32 (*D_80334920[8])(void) ;
void EU_D_802f4330(u32 a0, u32 a1(void)) {
register u32 int_disabled = __osDisableInt();
+3 -3
View File
@@ -6,13 +6,13 @@ OSMesg osPiMesgBuff[PIAccessQueueSize];
OSMesgQueue gOsPiMessageQueue;
u32 gOsPiAccessQueueCreated = 0;
void __osPiCreateAccessQueue() {
void __osPiCreateAccessQueue(void) {
gOsPiAccessQueueCreated = 1;
osCreateMesgQueue(&gOsPiMessageQueue, &osPiMesgBuff[0], PIAccessQueueSize - 1);
osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK);
}
void __osPiGetAccess() {
void __osPiGetAccess(void) {
OSMesg sp1c;
if (!gOsPiAccessQueueCreated) {
__osPiCreateAccessQueue();
@@ -20,6 +20,6 @@ void __osPiGetAccess() {
osRecvMesg(&gOsPiMessageQueue, &sp1c, OS_MESG_BLOCK);
}
void __osPiRelAccess() {
void __osPiRelAccess(void) {
osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK);
}
+1 -1
View File
@@ -57,7 +57,7 @@ static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table) {
// Force adding another jr $ra. Has to be called or it doesn't get put in the
// right place.
static void unused() {
static void unused(void) {
}
void alBnkfNew(ALBankFile *f, u8 *table) {
+3 -134
View File
@@ -1,82 +1,16 @@
#include "new_func.h"
void func_802F4A20() {
void func_802F4A20(void) {
__OSTranxInfo *sp1c;
volatile u32 sp18;
// lui $t6, %hi(__osDiskHandle) # $t6, 0x8033
// lw $t6, %lo(__osDiskHandle)($t6)
// addiu $sp, $sp, -0x20
// sw $ra, 0x14($sp)
// addiu $t7, $t6, 0x14
// sw $t7, 0x1c($sp)
sp1c = &__osDiskHandle->transferInfo;
// lui $t8, %hi(PI_STATUS_REG) # $t8, 0xa460
// lw $t9, %lo(PI_STATUS_REG)($t8)
// sw $t9, 0x18($sp)
// sp18 = HW_REG(PI_STATUS_REG, u32);
// while(sp18 & 0x2) sp18 = HW_REG(PI_STATUS_REG, u32);
WAIT_ON_IOBUSY(sp18);
// lw $t0, 0x18($sp)
// andi $t1, $t0, 2
// beqz $t1, .L802F4A70
// nop
// L802F4A54:
// lui $t2, %hi(PI_STATUS_REG) # $t2, 0xa460
// lw $t3, %lo(PI_STATUS_REG)($t2)
// sw $t3, 0x18($sp)
// lw $t4, 0x18($sp)
// andi $t5, $t4, 2
// bnez $t5, .L802F4A54
// nop
// L802F4A70:
// lw $t6, 0x1c($sp)
// lui $at, 0x1000
// lui $t9, %hi(D_A5000510) # $t9, 0xa500
// lw $t7, 0x14($t6)
// lui $t0, %hi(PI_STATUS_REG) # $t0, 0xa460
// or $t8, $t7, $at
// sw $t8, %lo(D_A5000510)($t9)
HW_REG(ASIC_BM_CTL, u32) = BUFFER_MANAGER_RESET | sp1c->bmCtlShadow; //should be unk10??
// lw $t1, %lo(PI_STATUS_REG)($t0)
// sw $t1, 0x18($sp)
// lw $t2, 0x18($sp)
// andi $t3, $t2, 2
// beqz $t3, .L802F4AC0
// nop
WAIT_ON_IOBUSY(sp18);
// L802F4AA4:
// lui $t4, %hi(PI_STATUS_REG) # $t4, 0xa460
// lw $t5, %lo(PI_STATUS_REG)($t4)
// sw $t5, 0x18($sp)
// lw $t6, 0x18($sp)
// andi $t7, $t6, 2
// bnez $t7, .L802F4AA4
// nop
// L802F4AC0:
// lw $t8, 0x1c($sp)
// lui $t0, %hi(D_A5000510) # $t0, 0xa500
// lw $t9, 0x14($t8)
// jal func_802F4B08
// sw $t9, %lo(D_A5000510)($t0)
HW_REG(ASIC_BM_CTL, u32) = sp1c->bmCtlShadow;
func_802F4B08();
// li $t1, 2
// lui $t2, %hi(PI_STATUS_REG) # $t2, 0xa460
// sw $t1, %lo(PI_STATUS_REG)($t2)
HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR;
// lui $t3, %hi(D_8030208C) # $t3, 0x8030
// lw $t3, %lo(D_8030208C)($t3)
// lui $at, (0x00100401 >> 16) # lui $at, 0x10
// lw $ra, 0x14($sp)
// ori $at, (0x00100401 & 0xFFFF) # ori $at, $at, 0x401
// or $t4, $t3, $at
// lui $at, %hi(D_8030208C) # $at, 0x8030
// sw $t4, %lo(D_8030208C)($at)
D_8030208C |= 0x00100401; //TODO: fix magic numbers
// jr $ra
// addiu $sp, $sp, 0x20
}
typedef struct OSEventMessageStruct_0_s {
@@ -85,86 +19,21 @@ typedef struct OSEventMessageStruct_0_s {
} OSEventMessageStruct_0;
extern OSEventMessageStruct_0 D_80363830[16]; // should be OS_NUM_EVENTS + 1 I think
void func_802F4B08() {
void func_802F4B08(void) {
OSEventMessageStruct_0 *sp2c;
OSMesgQueue *sp28;
u32 sp24;
register OSThread *s0;
// addiu $sp, $sp, -0x30
// lui $t6, %hi(D_80363830) # $t6, 0x8033
// addiu $t6, %lo(D_80363830) # addiu $t6, $t6, 0x36d0
// addiu $t7, $t6, 0x40
// sw $ra, 0x1c($sp)
// sw $s0, 0x18($sp)
// sw $t7, 0x2c($sp)
sp2c = &D_80363830[OS_EVENT_PI];
// lw $t8, 0x40($t6)
// beqz $t8, .L802F4BE0
// sw $t8, 0x28($sp)
sp28 = sp2c->queue;
// lw $t9, 8($t8)
// lw $t0, 0x10($t8)
// slt $at, $t9, $t0
// beqz $at, .L802F4BE0
// nop
if (!sp28 || sp28->validCount >= sp28->msgCount)
return;
// lw $t1, 0x28($sp)
// lw $t6, 0x2c($sp)
// lw $t2, 0xc($t1)
// lw $t3, 8($t1)
// lw $t5, 0x10($t1)
// addu $t4, $t2, $t3
// div $zero, $t4, $t5
// mfhi $t7
// sw $t7, 0x24($sp)
sp24 = (sp28->first + sp28->validCount) % sp28->msgCount;
// lw $t0, 0x14($t1)
// lw $t8, 4($t6)
// sll $t9, $t7, 2
// addu $t2, $t0, $t9
// sw $t8, ($t2)
sp28->msg[sp24] = sp2c->msg;
// lw $t3, 0x28($sp)
// bnez $t5, .L802F4B8C
// nop
// break 7
// L802F4B8C:
// li $at, -1
// bne $t5, $at, .L802F4BA4
// lui $at, 0x8000
// bne $t4, $at, .L802F4BA4
// nop
// break 6
// L802F4BA4:
// lw $t4, 8($t3)
// addiu $t5, $t4, 1
// sw $t5, 8($t3)
sp28->validCount += 1;
// lw $t6, 0x28($sp)
// lw $t7, ($t6)
// lw $t1, ($t7)
// beqz $t1, .L802F4BE0
// nop
// jal __osPopThread
// move $a0, $t6
if (sp28->mtqueue->next != NULL) {
s0 = __osPopThread(&sp28->mtqueue);
// move $s0, $v0
// lui $a0, %hi(D_80334898) # $a0, 0x8030
// addiu $a0, %lo(D_80334898) # addiu $a0, $a0, 0x2ef8
// jal __osEnqueueThread
// move $a1, $s0
__osEnqueueThread(&D_80334898, s0);
}
// L802F4BE0:
// lw $ra, 0x1c($sp)
// lw $s0, 0x18($sp)
// addiu $sp, $sp, 0x30
// jr $ra
// nop
// nop
// nop
// nop
}
+2 -24
View File
@@ -1,31 +1,9 @@
#include "libultra_internal.h"
extern u32 D_8030208C;
#include "new_func.h"
void func_802F7140(u32 a0) {
register u32 s0;
s0 = __osDisableInt();
D_8030208C &= ~(-0x402 & a0);
__osRestoreInt(s0);
}
/*
/ 0B6940 802F7140 27BDFFD8 / addiu $sp, $sp, -0x28
/ 0B6944 802F7144 AFBF001C / sw $ra, 0x1c($sp)
/ 0B6948 802F7148 AFA40028 / sw $a0, 0x28($sp)
/ 0B694C 802F714C 0C0BD400 / jal __osDisableInt
/ 0B6950 802F7150 AFB00018 / sw $s0, 0x18($sp)
/ 0B6954 802F7154 8FAF0028 / lw $t7, 0x28($sp)
/ 0B6958 802F7158 3C0E8030 / lui $t6, %hi(D_8030208C) # $t6, 0x8030
/ 0B695C 802F715C 8DCE208C / lw $t6, %lo(D_8030208C)($t6)
/ 0B6960 802F7160 2401FBFE / li $at, -1026
/ 0B6964 802F7164 01E1C024 / and $t8, $t7, $at
/ 0B6968 802F7168 0300C827 / not $t9, $t8
/ 0B696C 802F716C 00408025 / move $s0, $v0
/ 0B6970 802F7170 3C018030 / lui $at, %hi(D_8030208C) # $at, 0x8030
/ 0B6974 802F7174 01D94024 / and $t0, $t6, $t9
/ 0B6978 802F7178 AC28208C / sw $t0, %lo(D_8030208C)($at)
/ 0B697C 802F717C 0C0BD408 / jal __osRestoreInt
/ 0B6980 802F7180 02002025 / move $a0, $s0
/ 0B6984 802F7184 8FBF001C / lw $ra, 0x1c($sp)
/ 0B6988 802F7188 8FB00018 / lw $s0, 0x18($sp)
/ 0B698C 802F718C 27BD0028 / addiu $sp, $sp, 0x28
/ 0B6990 802F7190 03E00008 / jr $ra
/ 0B6994 802F7194 00000000 / nop */
+1 -24
View File
@@ -1,31 +1,8 @@
#include "libultra_internal.h"
void func_802F71F0() {
void func_802F71F0(void) {
register u32 s0 = __osDisableInt();
D_803348A0->state = OS_STATE_RUNNABLE;
__osEnqueueAndYield(&D_80334898);
__osRestoreInt(s0);
}
/*
/ 0B69F0 802F71F0 27BDFFD8 / addiu $sp, $sp, -0x28
/ 0B69F4 802F71F4 AFBF001C / sw $ra, 0x1c($sp)
/ 0B69F8 802F71F8 0C0BD400 / jal __osDisableInt
/ 0B69FC 802F71FC AFB00018 / sw $s0, 0x18($sp)
/ 0B6A00 802F7200 3C0F8030 / lui $t7, %hi(D_803348A0) # $t7, 0x8030
/ 0B6A04 802F7204 8DEF2F00 / lw $t7, %lo(D_803348A0)($t7)
/ 0B6A08 802F7208 240E0002 / li $t6, 2
/ 0B6A0C 802F720C 3C048030 / lui $a0, %hi(D_80334898) # $a0, 0x8030
/ 0B6A10 802F7210 00408025 / move $s0, $v0
/ 0B6A14 802F7214 24842EF8 / addiu $a0, %lo(D_80334898) # addiu $a0, $a0, 0x2ef8
/ 0B6A18 802F7218 0C0BCFC3 / jal __osEnqueueAndYield
/ 0B6A1C 802F721C A5EE0010 / sh $t6, 0x10($t7)
/ 0B6A20 802F7220 0C0BD408 / jal __osRestoreInt
/ 0B6A24 802F7224 02002025 / move $a0, $s0
/ 0B6A28 802F7228 8FBF001C / lw $ra, 0x1c($sp)
/ 0B6A2C 802F722C 8FB00018 / lw $s0, 0x18($sp)
/ 0B6A30 802F7230 27BD0028 / addiu $sp, $sp, 0x28
/ 0B6A34 802F7234 03E00008 / jr $ra
/ 0B6A38 802F7238 00000000 / nop
/ 0B6A3C 802F723C 00000000 / nop */
+13
View File
@@ -1,5 +1,9 @@
#include "libultra_internal.h"
#ifdef GBI_FLOATS
#include <string.h>
#endif
#ifndef GBI_FLOATS
void guMtxF2L(float mf[4][4], Mtx *m) {
int r, c;
s32 tmp1;
@@ -35,6 +39,11 @@ void guMtxL2F(float mf[4][4], Mtx *m) {
}
}
}
#else
void guMtxF2L(float mf[4][4], Mtx *m) {
memcpy(m, mf, sizeof(Mtx));
}
#endif
void guMtxIdentF(float mf[4][4]) {
int r, c;
@@ -49,7 +58,11 @@ void guMtxIdentF(float mf[4][4]) {
}
}
void guMtxIdent(Mtx *m) {
#ifndef GBI_FLOATS
float mf[4][4];
guMtxIdentF(mf);
guMtxF2L(mf, m);
#else
guMtxIdentF(m->m);
#endif
}
+4 -2
View File
@@ -68,14 +68,16 @@ void send(u8 *buff, s32 len) {
send_packet(&buff[end], rem);
}
}
void process_command_memory() {
void process_command_memory(void) {
u32 sp1c;
u32 sp18;
sp1c = string_to_u32(&D_80365E40[1]);
sp18 = string_to_u32(&D_80365E40[5]);
send((u8 *) (uintptr_t) sp1c, sp18);
}
void process_command_register() {
void process_command_register(void) {
send((u8 *) &gInterruptedThread.context, sizeof(__OSThreadContext));
}
+17 -17
View File
@@ -60,40 +60,40 @@ typedef struct {
#endif
} OSMgrArgs;
s32 __osDisableInt();
s32 __osDisableInt(void);
void __osRestoreInt(s32);
void __osEnqueueAndYield(OSThread **);
void __osDequeueThread(OSThread **, OSThread *);
void __osEnqueueThread(OSThread **, OSThread *);
OSThread *__osPopThread(OSThread **);
s32 __osSiRawStartDma(s32, void *);
void __osSiCreateAccessQueue();
void __osSiGetAccess();
void __osSiRelAccess();
void __osSiCreateAccessQueue(void);
void __osSiGetAccess(void);
void __osSiRelAccess(void);
u32 __osProbeTLB(void *);
void __osPiCreateAccessQueue();
void __osPiGetAccess();
void __osPiCreateAccessQueue(void);
void __osPiGetAccess(void);
void __osSetSR(u32);
u32 __osGetSR();
u32 __osGetSR(void);
void __osSetFpcCsr(u32);
s32 __osSiRawReadIo(void *, u32 *);
s32 __osSiRawWriteIo(void *, u32);
s32 osPiRawReadIo(u32 a0, u32 *a1);
void __osSpSetStatus(u32);
u32 __osSpGetStatus();
u32 __osSpGetStatus(void);
s32 __osSpSetPc(void *);
s32 __osSpDeviceBusy();
s32 __osSiDeviceBusy();
s32 __osSpDeviceBusy(void);
s32 __osSiDeviceBusy(void);
s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size);
void __osViInit();
OSViContext *__osViGetCurrentContext();
OSViContext *__osViGetCurrentContext2();
void __osViSwapContext();
void __osViInit(void);
OSViContext *__osViGetCurrentContext(void);
OSViContext *__osViGetCurrentContext2(void);
void __osViSwapContext(void);
void __osSetTimerIntr(u64);
u64 __osInsertTimer(OSTimer *);
void __osSetCompare(u32);
s32 __osAiDeviceBusy();
void __osDispatchThread();
u32 __osGetCause();
s32 __osAiDeviceBusy(void);
void __osDispatchThread(void);
u32 __osGetCause(void);
s32 __osAtomicDec(u32 *);
#endif
+5 -3
View File
@@ -1,5 +1,6 @@
#ifndef NEW_FUNC_H
#define NEW_FUNC_H
#include "libultra_internal.h"
#include "hardware.h"
@@ -14,9 +15,10 @@ extern OSPiHandle *__osDiskHandle; //possibly __osPiTable
extern volatile u32 D_8030208C;
s32 osEPiRawStartDma(OSPiHandle *arg0, s32 dir, u32 cart_addr, void *dram_addr, u32 size);
void func_802F4B08();
void func_802F4A20();
void func_802F4B08(void);
void func_802F4A20(void);
void func_802F7140(u32);
void func_802F71A0(OSPiHandle*, u32, u32); //osEPi something
void func_802F71F0();
void func_802F71F0(void);
#endif
+48 -48
View File
@@ -4,96 +4,96 @@
void __osPackRequestData(u8);
void __osContGetInitData(u8 *, OSContStatus *);
u32 D_80334810 = 0; // probably initialized
u32 _osContInitialized = 0; // probably initialized
extern u64 osClockRate;
// these probably belong in EEPROMlongread or something
u8 D_80365D20;
u8 _osCont_numControllers;
OSTimer D_80365D28; // some kind of buffer, or maybe an as yet unknown struct
u8 _osLastSentSiCmd;
u8 _osContNumControllers;
OSTimer D_80365D28;
OSMesgQueue _osContMesgQueue;
OSMesg _osContMesgBuff[4];
s32 osContInit(OSMesgQueue *mq, u8 *a1, OSContStatus *status) {
s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) {
OSMesg mesg;
u32 sp78 = 0;
u32 ret = 0;
OSTime currentTime;
OSTimer sp50;
OSMesgQueue sp38;
OSTimer timer;
OSMesgQueue timerMesgQueue;
if (D_80334810) {
if (_osContInitialized) {
return 0;
}
D_80334810 = 1;
_osContInitialized = 1;
currentTime = osGetTime();
if (500000 * osClockRate / 1000000 > currentTime) {
osCreateMesgQueue(&sp38, &mesg, 1);
osSetTimer(&sp50, 500000 * osClockRate / 1000000 - currentTime, 0, &sp38, &mesg);
osRecvMesg(&sp38, &mesg, OS_MESG_BLOCK);
osCreateMesgQueue(&timerMesgQueue, &mesg, 1);
osSetTimer(&timer, 500000 * osClockRate / 1000000 - currentTime, 0, &timerMesgQueue, &mesg);
osRecvMesg(&timerMesgQueue, &mesg, OS_MESG_BLOCK);
}
_osCont_numControllers = 4; // TODO: figure out what it means
_osContNumControllers = 4; // TODO: figure out what it means
#ifdef VERSION_EU
__osPackRequestData(0);
#else
__osPackRequestData(255);
#endif
sp78 = __osSiRawStartDma(1, D_80365CE0);
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
sp78 = __osSiRawStartDma(0, D_80365CE0);
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
osRecvMesg(mq, &mesg, OS_MESG_BLOCK);
__osContGetInitData(a1, status);
__osContGetInitData(bitpattern, status);
#ifdef VERSION_EU
D_80365D20 = 0;
_osLastSentSiCmd = 0;
#else
D_80365D20 = 255;
_osLastSentSiCmd = 255;
#endif
__osSiCreateAccessQueue();
osCreateMesgQueue(&_osContMesgQueue, _osContMesgBuff, 1);
return sp78;
return ret;
}
void __osContGetInitData(u8 *a0, OSContStatus *status) {
OSContPackedRequest *sp14;
OSContPackedRequest spc;
void __osContGetInitData(u8 *bitpattern, OSContStatus *status) {
OSContPackedRequest *cmdBufPtr;
OSContPackedRequest response;
s32 i;
u8 sp7;
sp7 = 0;
sp14 = &(D_80365CE0[0].request);
for (i = 0; i < _osCont_numControllers; i++, sp14++, status++) {
spc = *(OSContPackedRequest *) sp14;
status->errno = (spc.unk02 & 0xc0) >> 4;
if (status->errno == 0) {
status->type = spc.unk05 << 8 | spc.unk04;
status->status = spc.unk06;
cmdBufPtr = &(_osContCmdBuf[0].request);
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) {
response = *(OSContPackedRequest *) cmdBufPtr;
status->errnum = (response.rxLen & 0xc0) >> 4;
if (status->errnum == 0) {
status->type = response.data2 << 8 | response.data1;
status->status = response.data3;
sp7 |= 1 << i;
}
}
*a0 = sp7;
*bitpattern = sp7;
}
void __osPackRequestData(u8 a0) {
OSContPackedRequest *spc;
OSContPackedRequest sp4;
void __osPackRequestData(u8 command) {
OSContPackedRequest *cmdBufPtr;
OSContPackedRequest request;
s32 i;
// some kind of weird zeroing code
for (i = 0; i < 0x10; i++) {
*((u32 *) &D_80365CE0 + i) = 0;
*((u32 *) &_osContCmdBuf + i) = 0;
}
D_80365D1C = 1;
spc = &D_80365CE0[0].request;
sp4.unk00 = 255;
sp4.unk01 = 1;
sp4.unk02 = 3;
sp4.unk03 = a0;
sp4.unk04 = 255;
sp4.unk05 = 255;
sp4.unk06 = 255;
sp4.unk07 = 255;
_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;
for (i = 0; i < _osCont_numControllers; i++) {
*spc++ = sp4;
for (i = 0; i < _osContNumControllers; i++) {
*cmdBufPtr++ = request;
}
spc->unk00 = 254;
cmdBufPtr->padOrEnd = 254;
}
+16 -16
View File
@@ -3,10 +3,10 @@
#include <types.h>
typedef struct
{
u8 unk00; //unknown, set to 255 a lot
u8 unk01;
u8 unk02; //probably status
u8 unk03; //maybe errno
u8 padOrEnd;
u8 txLen;
u8 rxLen; //includes errno
u8 command;
u16 button;
s8 rawStickX;
s8 rawStickY;
@@ -14,14 +14,14 @@ typedef struct
typedef struct
{
u8 unk00; //unknown, set to 255 a lot
u8 unk01;
u8 unk02; //probably status
u8 unk03; //maybe errno
u8 unk04;
u8 unk05;
u8 unk06;
u8 unk07;
u8 padOrEnd;
u8 txLen;
u8 rxLen;
u8 command;
u8 data1;
u8 data2;
u8 data3;
u8 data4;
} OSContPackedRequest;
typedef union {
@@ -32,14 +32,14 @@ typedef union {
#ifdef AVOID_UB
// Fix the OSContPackedStruct array
extern OSContPackedStruct D_80365CE0[8];
extern OSContPackedStruct _osContCmdBuf[8];
// And fix the last element
#define D_80365D1C D_80365CE0[7].as_raw[1]
#define _osContPifCtrl _osContCmdBuf[7].as_raw[1]
#else
// Original OSContPackedStruct definitions
extern OSContPackedStruct D_80365CE0[7];
extern u32 D_80365D1C;
extern OSContPackedStruct _osContCmdBuf[7];
extern u32 _osContPifCtrl;
#endif
#endif
+36 -36
View File
@@ -3,71 +3,71 @@
#include <macros.h>
#ifndef AVOID_UB
OSContPackedStruct D_80365CE0[7];
ALIGNED8 OSContPackedStruct _osContCmdBuf[7];
UNUSED static u32 unused; // padding between these two variables
u32 D_80365D1C;
u32 _osContPifCtrl;
#else
// Reordered gcc vars above will disturb the aliasing done to access all 8 members of this array, hence AVOID_UB.
OSContPackedStruct D_80365CE0[8];
ALIGNED8 OSContPackedStruct _osContCmdBuf[8];
#endif
extern u8 D_80365D20;
extern u8 _osCont_numControllers;
extern u8 _osLastSentSiCmd;
extern u8 _osContNumControllers;
void __osPackReadData(void);
s32 osContStartReadData(OSMesgQueue *mesg) {
s32 ret = 0;
s32 i;
__osSiGetAccess();
if (D_80365D20 != 1) {
if (_osLastSentSiCmd != 1) {
__osPackReadData();
ret = __osSiRawStartDma(1, D_80365CE0);
ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf);
osRecvMesg(mesg, NULL, OS_MESG_BLOCK);
}
for (i = 0; i < 0x10; i++) {
*((u32 *) &D_80365CE0 + i) = 255;
*((u32 *) &_osContCmdBuf + i) = 255;
}
D_80365D1C = 0;
ret = __osSiRawStartDma(0, &D_80365CE0);
D_80365D20 = 1;
_osContPifCtrl = 0;
ret = __osSiRawStartDma(OS_READ, _osContCmdBuf);
_osLastSentSiCmd = 1;
__osSiRelAccess();
return ret;
}
void osContGetReadData(OSContPad *pad) {
OSContPackedRead *spc;
OSContPackedRead sp4;
OSContPackedRead *cmdBufPtr;
OSContPackedRead response;
s32 i;
spc = &D_80365CE0[0].read;
for (i = 0; i < _osCont_numControllers; i++, spc++, pad++) {
sp4 = *spc;
pad->errno = (sp4.unk02 & 0xc0) >> 4;
if (pad->errno == 0) {
pad->button = sp4.button;
pad->stick_x = sp4.rawStickX;
pad->stick_y = sp4.rawStickY;
cmdBufPtr = &_osContCmdBuf[0].read;
for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) {
response = *cmdBufPtr;
pad->errnum = (response.rxLen & 0xc0) >> 4;
if (pad->errnum == 0) {
pad->button = response.button;
pad->stick_x = response.rawStickX;
pad->stick_y = response.rawStickY;
}
};
}
void __osPackReadData() {
OSContPackedRead *spc;
OSContPackedRead sp4;
OSContPackedRead *cmdBufPtr;
OSContPackedRead request;
s32 i;
spc = &D_80365CE0[0].read;
cmdBufPtr = &_osContCmdBuf[0].read;
for (i = 0; i < 0x10; i++) {
*((u32 *) &D_80365CE0 + i) = 0;
*((u32 *) &_osContCmdBuf + i) = 0;
}
D_80365D1C = 1;
sp4.unk00 = 255;
sp4.unk01 = 1;
sp4.unk02 = 4;
sp4.unk03 = 1;
sp4.button = 65535;
sp4.rawStickX = -1;
sp4.rawStickY = -1;
for (i = 0; i < _osCont_numControllers; i++) {
*spc++ = sp4;
_osContPifCtrl = 1;
request.padOrEnd = 255;
request.txLen = 1;
request.rxLen = 4;
request.command = 1;
request.button = 65535;
request.rawStickX = -1;
request.rawStickY = -1;
for (i = 0; i < _osContNumControllers; i++) {
*cmdBufPtr++ = request;
}
spc->unk00 = 254;
cmdBufPtr->padOrEnd = 254;
}
+1 -1
View File
@@ -2,7 +2,7 @@
extern u64 osClockRate;
extern u8 D_80365D20;
extern u8 _osCont_numControllers;
extern u8 _osContNumControllers;
extern OSTimer D_80365D28; // not sure what this is yet
extern OSMesgQueue _osContMesgQueue;
extern OSMesg _osContMesgBuff[4];
+1 -1
View File
@@ -2,7 +2,7 @@
extern u64 osClockRate;
extern u8 D_80365D20;
extern u8 _osCont_numControllers;
extern u8 _osContNumControllers;
extern OSTimer D_80365D28;
extern OSMesgQueue _osContMesgQueue;
extern OSMesg _osContMesgBuff[4];
+2 -2
View File
@@ -1,6 +1,6 @@
#include "libultra_internal.h"
extern u8 D_80365D20;
extern u8 _osLastSentSiCmd;
typedef struct {
u16 unk00;
@@ -58,7 +58,7 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) {
}
D_80365E3C = 0;
sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
D_80365D20 = 4;
_osLastSentSiCmd = 4;
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
for (sp30 = 0; sp30 < 4; sp30++) {
sp2c++;
+5 -5
View File
@@ -2,14 +2,14 @@
#include "osContInternal.h"
#ifndef AVOID_UB
u32 D_80365E00[15];
ALIGNED8 u32 D_80365E00[15];
u32 D_80365E3C;
#else
// Certain code accesses the 16th element (D_80365E3C) in this array, making a seperate
// definition UB when gcc rearranges those.
u32 D_80365E00[16];
ALIGNED8 u32 D_80365E00[16];
#endif
extern u8 D_80365D20;
extern u8 _osLastSentSiCmd;
typedef struct {
u16 unk00;
@@ -73,7 +73,7 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) {
D_80365E3C = 0;
sp34 = __osSiRawStartDma(OS_READ, D_80365E00);
D_80365D20 = 5;
_osLastSentSiCmd = 5;
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
for (sp30 = 0; sp30 < 4; sp30++) {
@@ -142,7 +142,7 @@ s32 __osEepStatus(OSMesgQueue *a0, unkStruct *a1) {
sp2c = __osSiRawStartDma(OS_WRITE, D_80365E00);
osRecvMesg(a0, NULL, OS_MESG_BLOCK);
D_80365D20 = 5;
_osLastSentSiCmd = 5;
sp2c = __osSiRawStartDma(OS_READ, D_80365E00);
osRecvMesg(a0, NULL, OS_MESG_BLOCK);
+3 -1
View File
@@ -1,5 +1,6 @@
#include "libultra_internal.h"
#include "hardware.h"
// this file must include some globally referenced data because it is not called anywhere
// data, comes shortly before _Ldtob I think, before crash_screen
@@ -7,8 +8,9 @@ extern OSPiHandle *D_80302DFC;
// bss
OSPiHandle LeoDiskHandle;
OSPiHandle *__osDiskHandle;
// some kind of piHandle init function, maybe osDriveRomInit or osCartRomInit
OSPiHandle *osLeoDiskInit() {
OSPiHandle *osLeoDiskInit(void) {
s32 sp1c;
LeoDiskHandle.type = 2;
LeoDiskHandle.baseAddress = (0xa0000000 | 0x05000000);
+3 -2
View File
@@ -8,7 +8,8 @@ OSTime _osCurrentTime;
u32 D_80365DA8;
u32 __osViIntrCount;
u32 D_80365DB0;
void __osTimerServicesInit() {
void __osTimerServicesInit(void) {
_osCurrentTime = 0;
D_80365DA8 = 0;
__osViIntrCount = 0;
@@ -20,7 +21,7 @@ void __osTimerServicesInit() {
D_80334830->msg = NULL;
}
void __osTimerInterrupt() {
void __osTimerInterrupt(void) {
OSTimer *sp24;
u32 sp20;
u32 sp1c;
-10
View File
@@ -1,10 +0,0 @@
#include <math.h>
#ifndef __GNUC__
#pragma intrinsic(sqrtf)
#define __builtin_sqrtf sqrtf
#endif
float sqrtf(float f) {
return __builtin_sqrtf(f);
}