Compare commits

..

No commits in common. "f03558ef4827d41aba48c629d42b03172f8e5248" and "b136e35f4a496e50161c4ef66812cc1fb60e8fba" have entirely different histories.

15 changed files with 163 additions and 160 deletions

View File

@ -137,8 +137,12 @@ extern OSPiHandle* CART_HANDLE;
extern OSMesgQueue MQ_800E7988;
extern s32 D_800C4B30;
extern OSMesgQueue MQ_800E9BF0;
extern u8 D_800A9FF8;
extern OSContStatus __GLOBAL_CONT_STATUS[MAXCONTROLLERS];
extern void (*D_800A9FE0)(s16);
extern OSMesgQueue MQ_800C4A00;
extern OSContPad __GLOBAL_CONTROLLER_DATA[MAXCONTROLLERS];
extern OSContPad __GLOBAL_CONTROLLER_DATA_COPY[MAXCONTROLLERS];
@ -163,6 +167,9 @@ extern void __calls_osViBlack(bool black);
extern void __osViSwapBuffer_3(void** buffers);
extern void __start_copy_global_controller_data(void);
extern void __end_copy_global_controller_data(void);
extern s32 __read_controller(OSContPad* data, u32 flags);
extern s32 __real_read_controller(void);
extern s32 __calls_read_controller_0(s16* arg0);
@ -170,7 +177,11 @@ extern s32 __calls_read_controller_0(s16* arg0);
extern void func_8008A354();
extern void func_8008A37C();
extern void func_8008B130(u8*);
extern void func_8008B1D0(u8*);
extern void func_8008350C();
extern void func_8008B1D0(u8*);
extern void __set_vi_mode(s32);

View File

@ -687,9 +687,6 @@ extern OSContPad nuContData[];
extern u32 nuContNum; /* Number of controllers connected */
extern u32 nuContDataLockKey; /* Lock Controller data. */
extern OSMesgQueue nuContWaitMesgQ; /* Wait for Controller read */
extern OSMesg nuContWaitMesgBuf;
extern OSMesgQueue nuContDataMutexQ;
extern OSMesg nuContDataMutexBuf;
extern OSPfs nuContPfs[];
extern NUCallBackList nuContCallBack;
extern u16 nuContPakCompanyCode; /* Company code */

View File

@ -31,13 +31,6 @@ nuStackIdle = 0x800B17A0;
nuPiCartHandle = 0x800E7A20;
nuPiMgrMesgQ = 0x800BE030;
nuPiMesgBuf = 0x800BE048;
nuContWaitMesgQ = 0x800C4A00;
nuContWaitMesgBuf = 0x800BE190;
nuContDataMutexQ = 0x800E9BF0;
nuContDataMutexBuf = 0x800BE194;
nuContCallBack = 0x800A9FF8;
nuContStatus = 0x800C4B38; // size:0x10 type:u32
nuContNum = 0x800C6D60;
nuBoot = 0x8007F880;
nuScCreateScheduler = 0x80088C50; // rom:0x19050
@ -75,14 +68,6 @@ nuSiMgrStop = 0x80089D5C;
nuSiMgrRestart = 0x80089D7C;
nuIdle = 0x8007F8E4;
nuPiReadRom = 0x80089F80;
nuContQueryRead = 0x8008A640;
nuContMgrInit = 0x8008A260;
nuContDataUnLock = 0x8008A5D0;
nuSiCallBackAdd = 0x8008B130;
nuContMgrRemove = 0x8008A334;
nuSiCallBackRemove = 0x8008B1D0;
nuContDataClose = 0x8008A354;
nuContDataOpen = 0x8008A37C;
obCurrentTime = 0x800C47D0;
@ -777,6 +762,7 @@ __MENU_INDEX = 0x801BA94C;
__GLOBAL_WITH__inc_menu_timer = 0x8018FB20;
__GLOBAL_CONT_STATUS = 0x800C4B38; // size:0x10 type:u32
__set_fp_8008A660 = 0x8008A660;
@ -925,12 +911,16 @@ __MUS_MEM_800B1868 = 0x800B1868;
MQ_SWAP_BUFFER = 0x800E9BA8;
MQ_800E7988 = 0x800E7988;
MQ_800C4A00 = 0x800C4A00;
MQ_800E9BF0 = 0x800E9BF0;
MQ_800C35A0 = 0x800C35A0;
MQ_800AF320 = 0x800AF320;
MQ_800B1880 = 0x800B1880;
MQ_800E79C8 = 0x800E79C8;
MQ_800C49E8 = 0x800C49E8;
OSMESG_800BE190 = 0x800BE190;
OSMESG_800BE194 = 0x800BE194;
OSMESG_800B1870 = 0x800B1870;
OSMESG_800B17D0 = 0x800B17D0;
OSMESG_800B17E0 = 0x800B17E0;
@ -992,6 +982,8 @@ __GLOBAL_CONTROLLER_DATA_COPY = 0x0800AEE78; // size:0x18
__calls_copy_controller_data = 0x8007297C;
__copy_global_controller_data = 0x8008A600;
__start_copy_global_controller_data = 0x8008A354;
__end_copy_global_controller_data = 0x8008A37C;
__read_controller = 0x8008A3A4;
__calls_read_controller_0 = 0x8008A47C;
__calls_read_controller_1 = 0x8008A508;
@ -1015,6 +1007,7 @@ __virtual_mem_alloc = 0x80070F30;
obMain = 0x80071EB0;
obThreadMain = 0x800AF5F0;
obStackMain = 0x800C6D60;
entry = 0x80070C00;

View File

@ -121,9 +121,7 @@ segments:
- [0x19EB0, c, "nu/nugfxsetcfb"]
- [0x19FC0, c, "nu/nugfxdisplayoff"]
- [0x1A050, c, "nu/nugfxdisplayon"]
- [0x1A060, c, "nu/nusimgr"]
- [0x1A340, c, "nu/nupiinit"]
- [0x1A380, c, "nu/nupireadrom"]
- [0x1A060, c, "_ob_icy_coast"]
- [0x1A4F0, c, "rom_copy"]
- [0x1A5B0, c, "nu/nugfxinit"]
- [0x1A660, c, "_ob_prized_reading"]
@ -141,7 +139,7 @@ segments:
- [0x1B320, asm]
- [0x1B360, asm]
- [0x1B3A0, c, "_ob_electric_zephyr"]
- [0x1B3E0, c, "nu/nugfxthread"]
- [0x1B3E0, c, "_ob_grumpy_island"]
- [0x1B510, c, "_ob_painful_roll"]
- [0x1B530, asm]
- [0x1B650, asm]

View File

@ -3,13 +3,13 @@
#include "nu/nusys.h"
void __copy_global_controller_data(OSContPad* arg0) {
nuContDataClose();
__start_copy_global_controller_data();
bcopy(&__GLOBAL_CONTROLLER_DATA, arg0, 0x18);
nuContDataOpen();
__end_copy_global_controller_data();
}
void nuContQueryRead(void) {
nuSiSendMesg(NU_CONT_QUERY_MSG, NULL);
void func_8008A640(void) {
nuSiSendMesg(0x103, 0);
}
void __set_fp_8008A660(void(*arg0)(s16)) {

View File

@ -1,14 +1,12 @@
#include "common.h"
#include "nu/nusys.h"
void func_8008A6A0(void) {
nuSiCallBackAdd(&D_800AA040);
func_8008B130(&D_800AA040);
}
void func_8008A6C0(void) {
nuSiCallBackRemove(&D_800AA040);
func_8008B1D0(&D_800AA040);
}
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A6E0);

88
src/_ob_icy_coast.c Normal file
View File

@ -0,0 +1,88 @@
#include "common.h"
#include "nu/nusys.h"
#include "os_pi.h"
void nuSiMgrThread(void* arg);
/* 1A060 80089C60 */
u8 nuSiMgrInit(void) {
u8 pattern;
OSContStatus status[NU_CONT_MAXCONTROLLERS];
osCreateMesgQueue(&nuSiMesgQ, nuSiMesgBuf, NU_SC_MAX_MESGS);
osSetEventMesg(OS_EVENT_SI, &nuSiMesgQ, NULL);
osContInit(&nuSiMesgQ, &pattern, status);
osCreateThread(&siMgrThread, 5, nuSiMgrThread, NULL, &nuPiMgrMesgQ, NU_SI_THREAD_PRI);
osStartThread(&siMgrThread);
return pattern;
}
s32 nuSiSendMesg(NUScMsg mesg, void* dataPtr) {
OSMesgQueue rtnMesgQ;
NUSiCommonMesg siCommonMesg;
OSMesg sp38; // maybe this is part of the struct?
siCommonMesg.mesg = mesg;
siCommonMesg.dataPtr = dataPtr;
siCommonMesg.rtnMesgQ = &rtnMesgQ;
osCreateMesgQueue(&rtnMesgQ, &sp38, 1);
osSendMesg(&MQ_800E7988, &siCommonMesg, OS_MESG_BLOCK);
osRecvMesg(&rtnMesgQ, NULL, OS_MESG_BLOCK);
return siCommonMesg.error;
}
void nuSiMgrStop(void) {
nuSiSendMesg(NU_SI_STOP_MGR_MSG, NULL);
}
void nuSiMgrRestart(void) {
osStartThread(&siMgrThread);
}
INCLUDE_ASM(const s32, "_ob_icy_coast", nuSiMgrThread);
void nuPiInit(void) {
osCreatePiManager(OS_PRIORITY_PIMGR, &nuPiMgrMesgQ, nuPiMesgBuf, NU_PI_MESG_NUM);
nuPiCartHandle = osCartRomInit();
}
/* 1A380 80089F80 */
void nuPiReadRom(void *src, void *dst, u32 size) {
OSIoMesg ioMesg;
OSMesg mesg;
OSMesgQueue queue;
u32 mesgSize;
osCreateMesgQueue(&queue, &mesg, 1);
ioMesg.hdr.pri = 0;
ioMesg.hdr.retQueue = &queue;
osInvalDCache(dst, size);
while (size != 0) {
mesgSize = size;
if (mesgSize > MAX_BYTES_TO_READ) {
mesgSize = MAX_BYTES_TO_READ;
}
ioMesg.devAddr = (u32)src;
ioMesg.dramAddr = dst;
ioMesg.size = mesgSize;
// Start the DMA transfer
osEPiStartDma(nuPiCartHandle, &ioMesg, OS_READ);
// Wait for the DMA transfer to complete
osRecvMesg(&queue, &mesg, OS_MESG_BLOCK);
src += mesgSize;
dst += mesgSize;
size -= mesgSize;
}
}
INCLUDE_ASM(const s32, "_ob_icy_coast", func_8008A040);

View File

@ -2,47 +2,55 @@
#include "nu/nusys.h"
void func_8008A5D0();
void func_8008A640();
extern OSMesg OSMESG_800BE190;
extern OSMesg OSMESG_800BE194;
extern u32 obStackMain;
/* 1A660 8008A260 */
u8 nuContMgrInit(void) {
s32 i;
u8 pattern;
u8 bitmask;
u8 func_8008A260(void) {
s32 var_a0;
s32 var_a1;
s32 var_v1;
nuContDataUnLock();
osCreateMesgQueue(&nuContWaitMesgQ, &nuContWaitMesgBuf, 1);
osCreateMesgQueue(&nuContDataMutexQ, &nuContDataMutexBuf, 1);
nuSiCallBackAdd(&nuContCallBack);
nuContQueryRead();
nuContNum = 0;
bitmask = 1;
pattern = 0;
for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) {
if (nuContStatus[i].errno != 0) {
continue;
func_8008A5D0();
osCreateMesgQueue(&MQ_800C4A00, &OSMESG_800BE190, 1);
osCreateMesgQueue(&MQ_800E9BF0, &OSMESG_800BE194, 1);
func_8008B130(&D_800A9FF8);
func_8008A640();
var_a0 = 1;
var_a1 = 0;
var_v1 = 0;
obStackMain = 0;
for(; var_v1 < MAXCONTROLLERS; var_v1++) {
if (__GLOBAL_CONT_STATUS[var_v1].errno == 0) {
if ((__GLOBAL_CONT_STATUS[var_v1].type & CONT_TYPE_MASK) == CONT_TYPE_NORMAL) {
var_a1 |= var_a0;
obStackMain += 1;
}
var_a0 *= 2;
}
if ((nuContStatus[i].type & CONT_TYPE_MASK) == CONT_TYPE_NORMAL) {
nuContNum++;
pattern |= bitmask;
}
bitmask <<= 1;
}
return pattern;
return var_a1;
}
void nuContMgrRemove(void) {
nuSiCallBackRemove(&nuContCallBack);
void func_8008A334(void) {
func_8008B1D0(&D_800A9FF8);
}
void nuContDataClose(void) {
osSendMesg(&nuContDataMutexQ, NULL, OS_MESG_BLOCK);
void __start_copy_global_controller_data(void) {
osSendMesg(&MQ_800E9BF0, NULL, OS_MESG_BLOCK);
}
void nuContDataOpen(void) {
osRecvMesg(&nuContDataMutexQ, NULL, OS_MESG_BLOCK);
void __end_copy_global_controller_data(void) {
osRecvMesg(&MQ_800E9BF0, NULL, OS_MESG_BLOCK);
}
s32 __read_controller(OSContPad* data, u32 flags) {
@ -69,7 +77,7 @@ s32 __real_read_controller(void) {
var_v0 = osContStartQuery(&nuSiMesgQ);
if (var_v0 == 0) {
osRecvMesg(&nuSiMesgQ, NULL, OS_MESG_BLOCK);
osContGetQuery(nuContStatus);
osContGetQuery(__GLOBAL_CONT_STATUS);
return 0;
} else {
return var_v0;
@ -79,12 +87,12 @@ s32 __real_read_controller(void) {
s32 __calls_read_controller_0(s16* arg0) {
if (D_800C4B30 == 0) {
osRecvMesg(&nuContWaitMesgQ, NULL, 0);
osRecvMesg(&MQ_800C4A00, NULL, 0);
__read_controller(__GLOBAL_CONTROLLER_DATA, 1);
if (D_800A9FE0 != NULL) {
D_800A9FE0(*arg0);
}
osSendMesg(&nuContWaitMesgQ, NULL, 0);
osSendMesg(&MQ_800C4A00, NULL, 0);
}
return 0;
}
@ -101,7 +109,7 @@ void __calls_read_controller_1(Arg___calls_read_controller_1* arg) {
s32 __calls_read_controller_2(s16* arg0) {
s32 var_v0;
osRecvMesg(&nuContWaitMesgQ, NULL, 0);
osRecvMesg(&MQ_800C4A00, NULL, 0);
var_v0 = __read_controller(__GLOBAL_CONTROLLER_DATA, 0);
if (var_v0 == 0) {
if (D_800A9FE0 != NULL) {

View File

@ -8,7 +8,7 @@ void func_8008A5A0(void) {
osSetIntMask(temp_v0);
}
void nuContDataUnLock(void) {
void func_8008A5D0(void) {
s32 temp_v0;
temp_v0 = osSetIntMask(OS_IM_NONE);

View File

@ -5,6 +5,8 @@
extern OSThread nuThreadIdle;
extern u64 nuStackIdle[];
extern u8 obStackMain[];
void nuIdle(void* arg);
void nuBoot(void) {
@ -21,7 +23,7 @@ void nuIdle(void* arg) {
osViSetSpecialFeatures(OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF);
osCreateThread(&obThreadMain, NU_MAIN_THREAD_ID, obMain, NULL, &nuContNum, NU_MAIN_THREAD_PRI);
osCreateThread(&obThreadMain, NU_MAIN_THREAD_ID, obMain, NULL, obStackMain, NU_MAIN_THREAD_PRI);
osStartThread(&obThreadMain);
osSetThreadPri(&nuThreadIdle, NU_IDLE_THREAD_PRI);

View File

@ -32,6 +32,7 @@ void func_800749C0(s32); /* extern */
void func_800764E0(); /* extern */
void func_80079380(); /* extern */
void func_8008A040(); /* extern */
s8 func_8008A260(); /* extern */
void func_8009DAEC(); /* extern */
void func_800E9CEC(); /* extern */
void func_800EA714(); /* extern */

View File

@ -1,8 +0,0 @@
#include "common.h"
#include "nu/nusys.h"
void nuPiInit(void) {
osCreatePiManager(OS_PRIORITY_PIMGR, &nuPiMgrMesgQ, nuPiMesgBuf, NU_PI_MESG_NUM);
nuPiCartHandle = osCartRomInit();
}

View File

@ -1,37 +0,0 @@
#include "common.h"
#include "nu/nusys.h"
/* 1A380 80089F80 */
void nuPiReadRom(void *src, void *dst, u32 size) {
OSIoMesg ioMesg;
OSMesg mesg;
OSMesgQueue queue;
u32 mesgSize;
osCreateMesgQueue(&queue, &mesg, 1);
ioMesg.hdr.pri = 0;
ioMesg.hdr.retQueue = &queue;
osInvalDCache(dst, size);
while (size != 0) {
mesgSize = size;
if (mesgSize > MAX_BYTES_TO_READ) {
mesgSize = MAX_BYTES_TO_READ;
}
ioMesg.devAddr = (u32)src;
ioMesg.dramAddr = dst;
ioMesg.size = mesgSize;
// Start the DMA transfer
osEPiStartDma(nuPiCartHandle, &ioMesg, OS_READ);
// Wait for the DMA transfer to complete
osRecvMesg(&queue, &mesg, OS_MESG_BLOCK);
src += mesgSize;
dst += mesgSize;
size -= mesgSize;
}
}
INCLUDE_ASM(const s32, "nu/nupireadrom", func_8008A040);

View File

@ -1,48 +0,0 @@
#include "common.h"
#include "nu/nusys.h"
#include "os_pi.h"
void nuSiMgrThread(void* arg);
/* 1A060 80089C60 */
u8 nuSiMgrInit(void) {
u8 pattern;
OSContStatus status[NU_CONT_MAXCONTROLLERS];
osCreateMesgQueue(&nuSiMesgQ, nuSiMesgBuf, NU_SC_MAX_MESGS);
osSetEventMesg(OS_EVENT_SI, &nuSiMesgQ, NULL);
osContInit(&nuSiMesgQ, &pattern, status);
osCreateThread(&siMgrThread, 5, nuSiMgrThread, NULL, &nuPiMgrMesgQ, NU_SI_THREAD_PRI);
osStartThread(&siMgrThread);
return pattern;
}
s32 nuSiSendMesg(NUScMsg mesg, void* dataPtr) {
OSMesgQueue rtnMesgQ;
NUSiCommonMesg siCommonMesg;
OSMesg sp38;
siCommonMesg.mesg = mesg;
siCommonMesg.dataPtr = dataPtr;
siCommonMesg.rtnMesgQ = &rtnMesgQ;
osCreateMesgQueue(&rtnMesgQ, &sp38, 1);
osSendMesg(&MQ_800E7988, &siCommonMesg, OS_MESG_BLOCK);
osRecvMesg(&rtnMesgQ, NULL, OS_MESG_BLOCK);
return siCommonMesg.error;
}
void nuSiMgrStop(void) {
nuSiSendMesg(NU_SI_STOP_MGR_MSG, NULL);
}
void nuSiMgrRestart(void) {
osStartThread(&siMgrThread);
}
INCLUDE_ASM(const s32, "nu/nusimgr", nuSiMgrThread);