Compare commits

...

13 Commits

Author SHA1 Message Date
gijs 6dde5925bc Decompile `nuGfxSetCfb` 2023-10-20 12:45:21 +02:00
gijs c23bc3a884 Identify more `nuGfx` variables 2023-10-20 12:44:32 +02:00
gijs 7c5ef2df8e Identify `nuGfxCfb` 2023-10-20 12:42:19 +02:00
gijs c711ee9ea7 Split `nuGfxSetCfb` to C 2023-10-20 12:40:44 +02:00
gijs b41fadc833 Rename `func_80089AB0` to `nuGfxSetCfb` 2023-10-20 12:38:46 +02:00
gijs 0f740013fc Decompile `nuScEventHandler` 2023-10-20 12:30:33 +02:00
gijs 05b93a6faa Decompile `nuScWaitTaskReady` 2023-10-20 12:25:45 +02:00
gijs ad4a954aab Rename `func_8008949C` to `nuScWaitTaskReady` 2023-10-20 12:25:29 +02:00
gijs edec5a8ec0 Decompile `nuScResetClientMesgType` 2023-10-20 12:21:58 +02:00
gijs a0e093a589 Rename `func_800890E4` to `nuScResetClientMesgType` 2023-10-20 12:21:30 +02:00
gijs 19ad06ddec Decompile `nuScEventBroadcast` 2023-10-20 12:19:04 +02:00
gijs 34c7cfa70d Decompile `nuScRemoveClient` 2023-10-20 12:18:28 +02:00
gijs 774f762631 Decompile `nuScAddClient` 2023-10-20 12:16:24 +02:00
7 changed files with 158 additions and 50 deletions

View File

@ -199,7 +199,6 @@ extern void __start_thread_800BE1C0();
extern void __something_display_list(Gfx*, s32, s32, s32);
extern void func_80089A10();
extern void func_80089AB0(s32*, s32);
extern void __osViSwapBuffer_3(void** buffers);
extern void set_swap_buffer_func(void (*arg0)(void**));
@ -223,7 +222,6 @@ extern void func_8008B1D0(u8*);
extern void __start_thread_800BE1C0(void);
extern void __thread_8008AFE0(void*);
extern void func_8008949C(void** buffers);
extern void func_8008350C();
extern void func_8008B1D0(u8*);

View File

@ -2,6 +2,10 @@ nusched = 0x800E8B10; // size:0x680
nuScRetraceCounter = 0x800C4BCC;
nuScPreNMIFlag = 0x800C4800;
nuScPreNMIFunc = 0x800A9E60;
nuGfxCfb = 0x800E8290;
nuGfxCfbNum = 0x800A9E80;
nuGfxCfbCounter = 0x800C4BC4;
nuGfxCfb_ptr = 0x800E8210;
nuBoot = 0x8007F880;
nuScCreateScheduler = 0x80088C50; // rom:0x19050
@ -17,6 +21,9 @@ nuScAddClient = 0x80089054;
nuScRemoveClient = 0x80089124;
nuScSetFrameBufferNum = 0x80089528;
nuGfxRetraceWait = 0x80089A30;
nuScResetClientMesgType = 0x800890E4;
nuScWaitTaskReady = 0x8008949C;
nuGfxSetCfb = 0x80089AB0;
obCurrentTime = 0x800C47D0;
obSetCurrentTime = 0x8009C7C0; // rom:0x2CBC0

View File

@ -116,7 +116,7 @@ segments:
- [0x19DD0, c, "_ob_questionable_glass"]
- [0x19E10, asm]
- [0x19E30, c, "nu/nugfxretracewait"]
- [0x19EB0, asm]
- [0x19EB0, c, "nu/nugfxsetcfb"]
- [0x19FC0, c, "black"]
- [0x1A050, c, "_ob_icy_coast"]
- [0x1A4F0, c, "rom_copy"]

View File

@ -2,9 +2,10 @@
#include "nu/nusys.h"
void nuScEventBroadcast(NUScMsg* msg);
INCLUDE_ASM(const s32, "_ob_past_brick", nuScCreateScheduler);
/* 192F0 80088EF0*/
OSMesgQueue* nuScGetAudioMQ() {
return &nusched.audioRequestMQ;
}
@ -13,34 +14,107 @@ OSMesgQueue* nuScGetGfxMQ() {
return &nusched.graphicsRequestMQ;
}
INCLUDE_ASM(const s32, "_ob_past_brick", nuScEventHandler);
void nuScEventHandler(void) {
OSMesg msg;
s32 beforeResetFrame;
INCLUDE_ASM(const s32, "_ob_past_brick", nuScAddClient);
nuScRetraceCounter = 0;
/* 19454 80089054 */
// void nuScAddClient(Stack__dma_load_loop* arg0, OSMesgQueue* mq, s16 flags)
// {
// s32 mask = osSetIntMask(OS_IM_NONE);
while (TRUE) {
osRecvMesg(&nusched.retraceMQ, &msg, OS_MESG_BLOCK);
// arg0->mq = mq;
// arg0->next = D_800E9178[0];
// arg0->flags = flags;
switch ((s32) msg) {
case 666:
nuScRetraceCounter++;
// D_800E9178[0] = arg0;
nuScEventBroadcast(&nusched.retraceMsg);
// if ((flags & 2) && (nuScPreNMIFlag != 0)) {
// osSendMesg(mq, (u8*)(&D_800E9178) - 0x666, OS_MESG_NOBLOCK);
// }
if (nuScPreNMIFlag){
if (beforeResetFrame){
beforeResetFrame--;
} else {
nuScPreNMIFlag |= NU_SC_BEFORE_RESET;
osAfterPreNMI();
osViSetYScale(1.0);
__calls_osViBlack(TRUE);
}
}
break;
// osSetIntMask(mask);
// }
case 669:
nuScPreNMIFlag = NU_SC_PRENMI_GET;
nuScEventBroadcast(&nusched.prenmiMsg);
if (nuScPreNMIFunc != NULL){
(*nuScPreNMIFunc)();
}
INCLUDE_ASM(const s32, "_ob_past_brick", func_800890E4);
beforeResetFrame = (nusched.frameRate / 2) / nusched.retraceCount - 3;
break;
INCLUDE_ASM(const s32, "_ob_past_brick", nuScRemoveClient);
default:
break;
}
}
}
INCLUDE_ASM(const s32, "_ob_past_brick", nuScEventBroadcast);
void nuScAddClient(NUScClient* client, OSMesgQueue* queue, NUScMsg type) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
client->msgQ = queue;
client->next = nusched.clientList;
client->msgType = type;
nusched.clientList = client;
if ((type & NU_SC_PRENMI_MSG) && nuScPreNMIFlag) {
osSendMesg(queue, &nusched.prenmiMsg, OS_MESG_NOBLOCK);
}
osSetIntMask(mask);
}
void nuScResetClientMesgType(NUScClient* client, NUScMsg msgType) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
client->msgType = msgType;
osSetIntMask(mask);
}
void nuScRemoveClient(NUScClient* client) {
s32 mask = osSetIntMask(OS_IM_NONE);
NUScClient* clientList = nusched.clientList;
NUScClient* prev = NULL;
while (clientList != NULL) {
if (clientList == client) {
if (prev != NULL) {
prev->next = clientList->next;
} else {
nusched.clientList = clientList->next;
}
break;
}
prev = clientList;
clientList = clientList->next;
}
osSetIntMask(mask);
}
void nuScEventBroadcast(NUScMsg* msg) {
NUScClient* clientList = nusched.clientList;
while (clientList != NULL) {
if (clientList->msgType & *msg) {
osSendMesg(clientList->msgQ, msg, OS_MESG_NOBLOCK);
}
clientList = clientList->next;
}
}
INCLUDE_ASM(const s32, "_ob_past_brick", nuScExecuteAudio);
@ -63,7 +137,7 @@ INCLUDE_ASM(const s32, "_ob_past_brick", nuScExecuteGraphics);
// while(1) {
// osRecvMesg(&MQ_800E8B4C.field_0x0, &sp10, 1);
// if (!(nuScPreNMIFlag & 2)) {
// func_8008949C(sp10);
// nuScWaitTaskReady(sp10);
// osWritebackDCacheAll();
// osSendMesg(&MQ_800B9C40, sp10, OS_MESG_BLOCK);
@ -77,30 +151,20 @@ INCLUDE_ASM(const s32, "_ob_past_brick", nuScExecuteGraphics);
// }
// }
// extern struct {
// OSMesgQueue mq;
// u8 padding[0x549];
// u8 b;
// } D_800E8C2C;
void nuScWaitTaskReady(NUScTask* task) {
NUScClient client;
void* fb = task->framebuffer;
INCLUDE_ASM(const s32, "_ob_past_brick", func_8008949C);
if(nusched.frameBufferNum == 1) {
return;
}
/* 1989C 8008949C */
// void func_8008949C(void** buffers)
// {
// Stack__dma_load_loop sp10;
// void* temp_s0 = buffers[3];
// if (D_800E8C2C.b != 1)
// {
// while(osViGetNextFramebuffer() == temp_s0 || osViGetCurrentFramebuffer() == temp_s0)
// {
// nuScAddClient(&sp10, &D_800E8C2C.mq, 1);
// osRecvMesg(&D_800E8C2C.mq, NULL, 1);
// nuScRemoveClient(&sp10);
// }
// }
// }
while (osViGetNextFramebuffer() == fb || osViGetCurrentFramebuffer() == fb) {
nuScAddClient(&client, &nusched.waitMQ, NU_SC_RETRACE_MSG);
osRecvMesg(&nusched.waitMQ, NULL, OS_MESG_BLOCK);
nuScRemoveClient(&client);
}
}
INCLUDE_ASM(const s32, "_ob_past_brick", nuScSetFrameBufferNum);

View File

@ -1,12 +1,14 @@
#include "common.h"
#include "nu/nusys.h"
/* 1A5B0 8008A1B0 */
void func_8008A1B0(void) {
Gfx list[257];
Gfx* ptr = list;
__start_thread_800BE1C0();
func_80089AB0(&__SOMETHING_FRAMEBUFFERS, 3);
nuGfxSetCfb(&__SOMETHING_FRAMEBUFFERS, 3);
D_800C4B20 = BOOT_ADDRESS_ULTRA;
set_swap_buffer_func(__osViSwapBuffer_3);
D_800C4CE0 = &D_800A9EB0;

View File

@ -435,7 +435,7 @@ void func_8007382C(void) {
gDPPipeSync(obPtrDisplayList++);
gDPSetRenderMode(obPtrDisplayList++, G_RM_NOOP, G_RM_NOOP2);
gDPSetColorImage(obPtrDisplayList++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, osVirtualToPhysical(D_800E8210));
gDPSetColorImage(obPtrDisplayList++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, osVirtualToPhysical(nuGfxCfb_ptr));
gDPSetFillColor(obPtrDisplayList++, 0x00010001);
gDPPipeSync(obPtrDisplayList++);

37
src/nu/nugfxsetcfb.c Normal file
View File

@ -0,0 +1,37 @@
#include "common.h"
#include "nu/nusys.h"
void nuGfxSetCfb(u16** framebuf, u32 framebufnum) {
u32 i;
nuGfxCfb = framebuf;
nuGfxCfbNum = framebufnum;
nuGfxCfbCounter = 0;
nuGfxCfb_ptr = nuGfxCfb[0];
nuGfxRetraceWait(1);
nuScSetFrameBufferNum(framebufnum);
if (framebufnum > 1) {
s32 i;
for (i = 0; i < framebufnum - 1; i++) {
if (nuGfxCfb[i] != nuGfxCfb[i+1]) {
break;
}
}
if (i == framebufnum - 1) {
nuScSetFrameBufferNum(1);
} else {
for (i = 0; i < framebufnum; i++) {
if (osViGetNextFramebuffer() != nuGfxCfb[i]) {
nuGfxCfbCounter = i;
nuGfxCfb_ptr = nuGfxCfb[i];
break;
}
}
}
}
}