Work on nuSched

This commit is contained in:
JoshDuMan 2020-09-27 22:42:51 -04:00
parent 7e632e3ceb
commit 55dfeef1c8
14 changed files with 135 additions and 217 deletions

View File

@ -1,33 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel nuScEventBroadcast
/* 03A4C0 8005F0C0 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 03A4C4 8005F0C4 AFB00010 */ sw $s0, 0x10($sp)
/* 03A4C8 8005F0C8 3C10800E */ lui $s0, 0x800e
/* 03A4CC 8005F0CC 8E10AAA8 */ lw $s0, -0x5558($s0)
/* 03A4D0 8005F0D0 AFB10014 */ sw $s1, 0x14($sp)
/* 03A4D4 8005F0D4 0080882D */ daddu $s1, $a0, $zero
/* 03A4D8 8005F0D8 1200000C */ beqz $s0, .L8005F10C
/* 03A4DC 8005F0DC AFBF0018 */ sw $ra, 0x18($sp)
.L8005F0E0:
/* 03A4E0 8005F0E0 96020008 */ lhu $v0, 8($s0)
/* 03A4E4 8005F0E4 96230000 */ lhu $v1, ($s1)
/* 03A4E8 8005F0E8 00431024 */ and $v0, $v0, $v1
/* 03A4EC 8005F0EC 10400004 */ beqz $v0, .L8005F100
/* 03A4F0 8005F0F0 0220282D */ daddu $a1, $s1, $zero
/* 03A4F4 8005F0F4 8E040004 */ lw $a0, 4($s0)
/* 03A4F8 8005F0F8 0C019608 */ jal osSendMesg
/* 03A4FC 8005F0FC 0000302D */ daddu $a2, $zero, $zero
.L8005F100:
/* 03A500 8005F100 8E100000 */ lw $s0, ($s0)
/* 03A504 8005F104 1600FFF6 */ bnez $s0, .L8005F0E0
/* 03A508 8005F108 00000000 */ nop
.L8005F10C:
/* 03A50C 8005F10C 8FBF0018 */ lw $ra, 0x18($sp)
/* 03A510 8005F110 8FB10014 */ lw $s1, 0x14($sp)
/* 03A514 8005F114 8FB00010 */ lw $s0, 0x10($sp)
/* 03A518 8005F118 03E00008 */ jr $ra
/* 03A51C 8005F11C 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,43 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel nuScRemoveClient
/* 03A2BC 8005EEBC 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 03A2C0 8005EEC0 AFB00010 */ sw $s0, 0x10($sp)
/* 03A2C4 8005EEC4 0080802D */ daddu $s0, $a0, $zero
/* 03A2C8 8005EEC8 AFBF0014 */ sw $ra, 0x14($sp)
/* 03A2CC 8005EECC 0C018250 */ jal osSetIntMask
/* 03A2D0 8005EED0 24040001 */ addiu $a0, $zero, 1
/* 03A2D4 8005EED4 3C06800E */ lui $a2, 0x800e
/* 03A2D8 8005EED8 24C6AAA8 */ addiu $a2, $a2, -0x5558
/* 03A2DC 8005EEDC 0000282D */ daddu $a1, $zero, $zero
/* 03A2E0 8005EEE0 8CC30000 */ lw $v1, ($a2)
/* 03A2E4 8005EEE4 1060000E */ beqz $v1, .L8005EF20
/* 03A2E8 8005EEE8 0040202D */ daddu $a0, $v0, $zero
.L8005EEEC:
/* 03A2EC 8005EEEC 54700009 */ bnel $v1, $s0, .L8005EF14
/* 03A2F0 8005EEF0 0060282D */ daddu $a1, $v1, $zero
/* 03A2F4 8005EEF4 10A00004 */ beqz $a1, .L8005EF08
/* 03A2F8 8005EEF8 00000000 */ nop
/* 03A2FC 8005EEFC 8C620000 */ lw $v0, ($v1)
/* 03A300 8005EF00 08017BC8 */ j .L8005EF20
/* 03A304 8005EF04 ACA20000 */ sw $v0, ($a1)
.L8005EF08:
/* 03A308 8005EF08 8C620000 */ lw $v0, ($v1)
/* 03A30C 8005EF0C 08017BC8 */ j .L8005EF20
/* 03A310 8005EF10 ACC20000 */ sw $v0, ($a2)
.L8005EF14:
/* 03A314 8005EF14 8C630000 */ lw $v1, ($v1)
/* 03A318 8005EF18 1460FFF4 */ bnez $v1, .L8005EEEC
/* 03A31C 8005EF1C 00000000 */ nop
.L8005EF20:
/* 03A320 8005EF20 0C018250 */ jal osSetIntMask
/* 03A324 8005EF24 00000000 */ nop
/* 03A328 8005EF28 8FBF0014 */ lw $ra, 0x14($sp)
/* 03A32C 8005EF2C 8FB00010 */ lw $s0, 0x10($sp)
/* 03A330 8005EF30 03E00008 */ jr $ra
/* 03A334 8005EF34 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,22 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel nuScResetClientMesgType
/* 03A338 8005EF38 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 03A33C 8005EF3C AFB10014 */ sw $s1, 0x14($sp)
/* 03A340 8005EF40 0080882D */ daddu $s1, $a0, $zero
/* 03A344 8005EF44 AFB00010 */ sw $s0, 0x10($sp)
/* 03A348 8005EF48 00A0802D */ daddu $s0, $a1, $zero
/* 03A34C 8005EF4C AFBF0018 */ sw $ra, 0x18($sp)
/* 03A350 8005EF50 0C018250 */ jal osSetIntMask
/* 03A354 8005EF54 24040001 */ addiu $a0, $zero, 1
/* 03A358 8005EF58 0040202D */ daddu $a0, $v0, $zero
/* 03A35C 8005EF5C 0C018250 */ jal osSetIntMask
/* 03A360 8005EF60 A6300008 */ sh $s0, 8($s1)
/* 03A364 8005EF64 8FBF0018 */ lw $ra, 0x18($sp)
/* 03A368 8005EF68 8FB10014 */ lw $s1, 0x14($sp)
/* 03A36C 8005EF6C 8FB00010 */ lw $s0, 0x10($sp)
/* 03A370 8005EF70 03E00008 */ jr $ra
/* 03A374 8005EF74 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,51 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel nuContRmbCheck
/* 03B2F0 8005FEF0 27BDFFD0 */ addiu $sp, $sp, -0x30
/* 03B2F4 8005FEF4 AFB00020 */ sw $s0, 0x20($sp)
/* 03B2F8 8005FEF8 0080802D */ daddu $s0, $a0, $zero
/* 03B2FC 8005FEFC 24040301 */ addiu $a0, $zero, 0x301
/* 03B300 8005FF00 27A50010 */ addiu $a1, $sp, 0x10
/* 03B304 8005FF04 AFBF0028 */ sw $ra, 0x28($sp)
/* 03B308 8005FF08 AFB10024 */ sw $s1, 0x24($sp)
/* 03B30C 8005FF0C 0C00B3CA */ jal nuSiSendMesg
/* 03B310 8005FF10 A3B00010 */ sb $s0, 0x10($sp)
/* 03B314 8005FF14 24040001 */ addiu $a0, $zero, 1
/* 03B318 8005FF18 0C018250 */ jal osSetIntMask
/* 03B31C 8005FF1C 0040882D */ daddu $s1, $v0, $zero
/* 03B320 8005FF20 1620000A */ bnez $s1, .L8005FF4C
/* 03B324 8005FF24 0040202D */ daddu $a0, $v0, $zero
/* 03B328 8005FF28 00101080 */ sll $v0, $s0, 2
/* 03B32C 8005FF2C 00501021 */ addu $v0, $v0, $s0
/* 03B330 8005FF30 00021040 */ sll $v0, $v0, 1
/* 03B334 8005FF34 24030002 */ addiu $v1, $zero, 2
/* 03B338 8005FF38 3C01800B */ lui $at, 0x800b
/* 03B33C 8005FF3C 00220821 */ addu $at, $at, $v0
/* 03B340 8005FF40 A0231D49 */ sb $v1, 0x1d49($at)
/* 03B344 8005FF44 08017FD9 */ j .L8005FF64
/* 03B348 8005FF48 00000000 */ nop
.L8005FF4C:
/* 03B34C 8005FF4C 00101080 */ sll $v0, $s0, 2
/* 03B350 8005FF50 00501021 */ addu $v0, $v0, $s0
/* 03B354 8005FF54 00021040 */ sll $v0, $v0, 1
/* 03B358 8005FF58 3C01800B */ lui $at, 0x800b
/* 03B35C 8005FF5C 00220821 */ addu $at, $at, $v0
/* 03B360 8005FF60 A0201D49 */ sb $zero, 0x1d49($at)
.L8005FF64:
/* 03B364 8005FF64 0C018250 */ jal osSetIntMask
/* 03B368 8005FF68 00000000 */ nop
/* 03B36C 8005FF6C 0220102D */ daddu $v0, $s1, $zero
/* 03B370 8005FF70 8FBF0028 */ lw $ra, 0x28($sp)
/* 03B374 8005FF74 8FB10024 */ lw $s1, 0x24($sp)
/* 03B378 8005FF78 8FB00020 */ lw $s0, 0x20($sp)
/* 03B37C 8005FF7C 03E00008 */ jr $ra
/* 03B380 8005FF80 27BD0030 */ addiu $sp, $sp, 0x30
/* 03B384 8005FF84 00000000 */ nop
/* 03B388 8005FF88 00000000 */ nop
/* 03B38C 8005FF8C 00000000 */ nop

View File

@ -1,31 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel nuContRmbStart
/* 03B290 8005FE90 00041080 */ sll $v0, $a0, 2
/* 03B294 8005FE94 00441021 */ addu $v0, $v0, $a0
/* 03B298 8005FE98 00021040 */ sll $v0, $v0, 1
/* 03B29C 8005FE9C 3C01800B */ lui $at, 0x800b
/* 03B2A0 8005FEA0 00220821 */ addu $at, $at, $v0
/* 03B2A4 8005FEA4 90221D47 */ lbu $v0, 0x1d47($at)
/* 03B2A8 8005FEA8 27BDFFC8 */ addiu $sp, $sp, -0x38
/* 03B2AC 8005FEAC 30420080 */ andi $v0, $v0, 0x80
/* 03B2B0 8005FEB0 1440000B */ bnez $v0, .L8005FEE0
/* 03B2B4 8005FEB4 AFBF0030 */ sw $ra, 0x30($sp)
/* 03B2B8 8005FEB8 24020003 */ addiu $v0, $zero, 3
/* 03B2BC 8005FEBC A3A20016 */ sb $v0, 0x16($sp)
/* 03B2C0 8005FEC0 27A20010 */ addiu $v0, $sp, 0x10
/* 03B2C4 8005FEC4 A3A40020 */ sb $a0, 0x20($sp)
/* 03B2C8 8005FEC8 24040302 */ addiu $a0, $zero, 0x302
/* 03B2CC 8005FECC A7A50010 */ sh $a1, 0x10($sp)
/* 03B2D0 8005FED0 27A50020 */ addiu $a1, $sp, 0x20
/* 03B2D4 8005FED4 A7A60012 */ sh $a2, 0x12($sp)
/* 03B2D8 8005FED8 0C00B3CA */ jal nuSiSendMesg
/* 03B2DC 8005FEDC AFA20028 */ sw $v0, 0x28($sp)
.L8005FEE0:
/* 03B2E0 8005FEE0 8FBF0030 */ lw $ra, 0x30($sp)
/* 03B2E4 8005FEE4 03E00008 */ jr $ra
/* 03B2E8 8005FEE8 27BD0038 */ addiu $sp, $sp, 0x38
/* 03B2EC 8005FEEC 00000000 */ nop

View File

@ -51,7 +51,7 @@ SECTIONS
build/src/code_362a0_len_2f70.o(.text);
build/src/code_39210_len_aa0.o(.text);
build/src/os/code_39cb0_len_100.o(.text);
build/src/os/code_39db0_len_8a0.o(.text);
build/src/os/nusys/nuSched.o(.text);
build/src/os/nusys/nuGfxFuncSet.o(.text);
build/src/os/nusys/nuGfxPreNMIFuncSet.o(.text);
build/src/os/nusys/nuGfxTaskAllEndWait.o(.text);
@ -65,7 +65,8 @@ SECTIONS
build/src/os/nusys/nuContDataGet.o(.text);
build/src/os/nusys/nuContPakMgr.o(.text);
build/src/os/nusys/nuContRmbMgr.o(.text);
build/src/os/code_3b290_len_100.o(.text);
build/src/os/nusys/nuContRmbStart.o(.text);
build/src/os/nusys/nuContRmbCheck.o(.text);
build/src/os/code_3b390_len_110.o(.text);
build/src/os/code_3b4a0_len_270.o(.text);
build/src/os/code_3b710_len_40.o(.text);

View File

@ -1,27 +0,0 @@
#include "common.h"
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScCreateScheduler);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScExecuteAudio);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScExecuteGraphics);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScAddClient);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScRemoveClient);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScResetClientMesgType);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScGetGfxMQ);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScGetAudioMQ);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScSetFrameBufferNum);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScGetFrameRate);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScEventHandler);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScEventBroadcast);
INCLUDE_API_ASM("os/code_39db0_len_8a0", nuScWaitTaskReady);

View File

@ -1,5 +0,0 @@
#include "common.h"
INCLUDE_API_ASM("os/code_3b290_len_100", nuContRmbStart);
INCLUDE_API_ASM("os/code_3b290_len_100", nuContRmbCheck);

View File

@ -0,0 +1,21 @@
#include "common.h"
#include "nu/nusys.h"
s32 nuContRmbCheck(u32 contNo) {
NUContRmbMesg mesg;
s32 err;
OSIntMask mask;
mesg.contNo = contNo;
err = nuSiSendMesg(NU_CONT_RMB_CHECK_MSG, &mesg);
mask = osSetIntMask(1);
if (err == 0) {
nuContRmbCtl[contNo].type = NU_CONT_PAK_TYPE_RUMBLE;
} else {
nuContRmbCtl[contNo].type = NU_CONT_PAK_TYPE_NONE;
}
osSetIntMask(mask);
return err;
}

View File

@ -151,7 +151,7 @@ static s32 contRmbForceStopMesg(NUSiCommonMesg* mesg) {
return 0;
}
static s32 contRmbForceStopEndMesg(NUSiCommonMesg* mesg) {
s32 contRmbForceStopEndMesg(NUSiCommonMesg* mesg) {
u32 i;
for (i = 0; i < NU_CONT_MAXCONTROLLERS; i++) {

View File

@ -0,0 +1,16 @@
#include "common.h"
#include "nu/nusys.h"
void nuContRmbStart(u32 contNo, u16 freq, u16 frame) {
NUContRmbCtl ctl;
NUContRmbMesg mesg;
if (!(nuContRmbCtl[contNo].mode & NU_CONT_RMB_MODE_PAUSE)) {
ctl.state = NU_CONT_RMB_STATE_RUN;
ctl.freq = freq;
ctl.frame = frame;
mesg.data = &ctl;
mesg.contNo = contNo;
nuSiSendMesg(NU_CONT_RMB_START_MSG, &mesg);
}
}

90
src/os/nusys/nuSched.c Normal file
View File

@ -0,0 +1,90 @@
#include "common.h"
#include "nu/nusys.h"
void INCLUDE_ASM("os/code_39db0_len_8a0", nuScCreateScheduler, u8 videoMode, u8 numFields);
INCLUDE_ASM("os/code_39db0_len_8a0", nuScExecuteAudio);
INCLUDE_ASM("os/code_39db0_len_8a0", nuScExecuteGraphics);
void INCLUDE_ASM("os/code_39db0_len_8a0", nuScAddClient, NUScClient *c, OSMesgQueue *mq, NUScMsg msgType);
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 nuScResetClientMesgType(NUScClient* client, NUScMsg msgType) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
client->msgType = msgType;
osSetIntMask(mask);
}
#ifdef NON_MATCHING
// This should match when data is decompiled.
OSMesgQueue* nuScGetGfxMQ(void) {
return &nusched.graphicsRequestMQ;
}
#else
OSMesgQueue* INCLUDE_ASM("os/code_39db0_len_8a0", nuScGetGfxMQ, void);
#endif
#ifdef NON_MATCHING
// This should match when data is decompiled.
OSMesgQueue* nuScGetAudioMQ(void) {
return &nusched.audioRequestMQ;
}
#else
OSMesgQueue* INCLUDE_ASM("os/code_39db0_len_8a0", nuScGetAudioMQ, void);
#endif
#ifdef NON_MATCHING
// This should match when data is decompiled.
void nuScSetFrameBufferNum(u8 frameBufferNum) {
nusched.frameBufferNum = frameBufferNum;
}
#else
void INCLUDE_ASM("os/code_39db0_len_8a0", nuScSetFrameBufferNum, u8 frameBufferNum);
#endif
#ifdef NON_MATCHING
// This should match when data is decompiled.
s32 nuScGetFrameRate(void) {
return nusched.frameRate;
}
#else
s32 INCLUDE_ASM("os/code_39db0_len_8a0", nuScGetFrameRate, void);
#endif
INCLUDE_ASM("os/code_39db0_len_8a0", nuScEventHandler);
static 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("os/code_39db0_len_8a0", nuScWaitTaskReady);

View File

@ -58,7 +58,7 @@ segments:
- [0x362a0, "c", "code_362a0_len_2f70"]
- [0x39210, "c", "code_39210_len_aa0"]
- [0x39cb0, "c", "os/code_39cb0_len_100"]
- [0x39db0, "c", "os/code_39db0_len_8a0"]
- [0x39db0, "c", "os/nusys/nuSched"]
- [0x3a650, "c", "os/nusys/nuGfxFuncSet"]
- [0x3a690, "c", "os/nusys/nuGfxPreNMIFuncSet"]
- [0x3a6d0, "c", "os/nusys/nuGfxTaskAllEndWait"]
@ -72,7 +72,8 @@ segments:
- [0x3aa50, "c", "os/nusys/nuContDataGet"]
- [0x3aab0, "c", "os/nusys/nuContPakMgr"]
- [0x3af10, "c", "os/nusys/nuContRmbMgr"]
- [0x3b290, "c", "os/code_3b290_len_100"]
- [0x3b290, "c", "os/nusys/nuContRmbStart"]
- [0x3b2f0, "c", "os/nusys/nuContRmbCheck"]
- [0x3b390, "c", "os/code_3b390_len_110"]
- [0x3b4a0, "c", "os/code_3b4a0_len_270"]
- [0x3b710, "c", "os/code_3b710_len_40"]

View File

@ -71,6 +71,7 @@ gCurrentEncounter = 0x800B0F10;
nuContRmbCtl = 0x800B1d40;
nuContData = 0x800B1D68;
gCameras = 0x800B1D80;
nusched = 0x800DA440;
nuContPfs = 0x800DAAD8;
nuSiMesgQ = 0x800DAC78;
D_800DC500 = 0x800DC500;