Compare commits

..

33 Commits

Author SHA1 Message Date
gijs 0872cce98b Fix proper stack sizes
Add `DECLARE_STACK` and `STACK_START` macros
Fix addresses so `nuStackIdle` and `obStackMain` are 0x2000 in size
2023-10-22 00:07:08 +02:00
gijs b035cebc4f Add proper symbol for `nuStackSiMgrThread` 2023-10-21 23:24:00 +02:00
gijs ac627304f0 Add proper symbol for `obStackMain` 2023-10-21 22:05:37 +02:00
gijs 1a1dd9503f Add proper symbol for `nuStackIdle` 2023-10-21 21:23:37 +02:00
gijs a3f0f1a003 Correct `main` segment `bss` VRAM address 2023-10-21 21:23:11 +02:00
gijs 1c112a5db3 Rename `SWAP_BUFFER_FUNC_800A9E88` to `nuGfxTaskEndFunc` 2023-10-21 20:09:52 +02:00
gijs 7668b38b44 Rename `_ob_painful_roll` to `nugfxswapcfb` 2023-10-21 20:06:31 +02:00
gijs a30c8fe5d1 Decompile `nuSiCallBackRemove` 2023-10-21 20:04:51 +02:00
gijs 9ace1366f9 Decompile `nuSiCallBackAdd` 2023-10-21 20:04:22 +02:00
gijs 3fed6ce22a Rename `D_800A9EA0` to `nuSiCallBackList` 2023-10-21 20:01:52 +02:00
gijs ad75b6d5f3 Split `1B530`, remove `nuIdle` definition
Move `nuSiCallBackAdd` to `nusicallbackadd.c`
Move `nuSiCallBackRemove` to `nusicallbackremove.c`
2023-10-21 19:53:42 +02:00
gijs 0f70a6bf41 Change `UnpackProc` to take void * parameter 2023-10-21 19:39:54 +02:00
gijs d803e66638 Rename `MQ_800AF320` to `obUnpackQueue` 2023-10-21 19:28:24 +02:00
gijs 52c76621f6 Delete `lha.c`
Since all functions have been migrated, there's no use for this file anymore.
2023-10-21 19:27:19 +02:00
gijs 40e528eb4d Change signature of `Unpack` 2023-10-21 19:18:17 +02:00
gijs e5f075888a Rename `func_8008A6E0` to `nuContPakOpen` 2023-10-21 19:10:03 +02:00
gijs 1616b6a0b1 Rename `func_8008A730` to `nuContPakGetFree` 2023-10-21 19:08:09 +02:00
gijs 37d8a3185b Rename `func_8008A758` to `nuContPakFileReadWrite` 2023-10-21 19:06:12 +02:00
gijs 16339aaa7c Rename `func_8008A798` to `nuContPakFileOpen` 2023-10-21 19:04:59 +02:00
gijs 556034fa0f Rename `D_800AA014` to `nuContPakGameCode` 2023-10-21 18:19:20 +02:00
gijs 99404d3479 Rename `D_800AA010` to `nuContPakCompanyCode` 2023-10-21 18:18:44 +02:00
gijs f38c7a0f3e Rename `func_8008A850` to `nuContPakFileDelete` 2023-10-21 18:17:27 +02:00
gijs c62b4a3636 Rename `func_8008A8BC` to `nuContPakFileNum` 2023-10-21 18:15:56 +02:00
gijs ebf97965ae Rename `func_80096A90` to `osPfsNumFiles` 2023-10-21 18:15:02 +02:00
gijs 9c23db285b Rename `func_8008A890` to `nuContPakFileState` 2023-10-21 18:13:39 +02:00
gijs 32c7a5b95d Rename `func_8008A8E8` to `nuContPakRepairId` 2023-10-21 18:12:30 +02:00
gijs d4b40689b4 Rename `_ob_dull_silver.c` to `nucontpakmgr.c`
Rename `func_8008A6A0` to `nuContPakMgrInit`
Rename `func_8008A6C0` to `nuContPakMgrRemove`
Rename `D_800AA040` to `nuContPakCallBack`
2023-10-21 18:11:30 +02:00
gijs 30721ffd6c Clean up around `nuContRetrace`
Rename `__calls_read_controller_0` to `nuContRetrace`
Rename `D_800A9FE0` to `nuContReadFunc`
Rename `__set_fp_8008A660` to `nuContReadFuncSet`
Rename `_ob_proper_regret.c` to `nucontreadfuncset.c`
2023-10-21 18:05:22 +02:00
gijs 19551728c2 Split `_ob_classy_fold.c`
Rename `_ob_classy_fold.c` to `nucontmgr.c`
Rename `__GLOBAL_CONTROLLER_DATA` to `nuContData`
Rename `__copy_global_controller_data` to `nuContDataGetAll`
Split `nuContQueryRead` to it's own file
Split `nuContDataGetAll` to it's own file
2023-10-21 17:54:44 +02:00
gijs 3dab52ce7d Rename `_ob_silly_cactus.c` to `nucontdatalock.c` 2023-10-21 17:39:57 +02:00
gijs 37df9533bc Rename `D_800C4B30` to `nuContDataLockKey` 2023-10-21 17:39:09 +02:00
gijs a689d76967 Rename `func_8008A5A0` to `nuContDataLock` 2023-10-21 17:38:17 +02:00
gijs 24e91ef028 Rename `_ob_prized_reading.c` to `nucontmgr.c` 2023-10-21 17:37:13 +02:00
20 changed files with 205 additions and 320 deletions

View File

@ -75,6 +75,10 @@ typedef u8 bool;
#define SCREEN_WIDTH_MAX 640
#define SCREEN_HEIGHT_MAX 480
#define DECLARE_STACK(name, size) u64 name[size / sizeof(u64)]
// Stacks grow backwards (towards smaller addresses)
#define STACK_START(stack) ((u8*)(&stack) + sizeof(stack))
#include "character.h"
typedef struct {
@ -130,20 +134,13 @@ extern void* D_800B1828;
extern s32 D_800E8B14;
extern s32 D_A9EF0;
extern s32 D_800C4B30;
extern OSPiHandle* CART_HANDLE;
extern OSMesgQueue MQ_800E7988;
extern s32 D_800C4B30;
extern void (*D_800A9FE0)(s16);
extern OSContPad __GLOBAL_CONTROLLER_DATA[MAXCONTROLLERS];
extern OSContPad __GLOBAL_CONTROLLER_DATA_COPY[MAXCONTROLLERS];
extern u8 D_800AA040;
extern void (*SWAP_BUFFER_FUNC_800A9E8C)(void** buffers);
extern u8 SP_THREAD_800BE1C0[1];
@ -165,7 +162,6 @@ extern void __osViSwapBuffer_3(void** buffers);
extern s32 __read_controller(OSContPad* data, u32 flags);
extern s32 __real_read_controller(void);
extern s32 __calls_read_controller_0(s16* arg0);
extern void func_8008A354();
extern void func_8008A37C();
@ -297,12 +293,9 @@ extern void AddHeap(void* start, u32 length);
extern void __some_logging(const char* format, ...);
extern void nuBoot(void);
extern void (*nuIdleFunc)();
extern void obMain(void*);
extern OSThread obThreadMain;
extern OverlaySomething __OVERLAY_INFO_resets_menu_timer;
extern void* D_8018FB0C[];
extern OverlaySomething __OVERLAY_INFO_8018FAF8;
@ -561,16 +554,15 @@ extern void __inc_compared_osTvType(u8 arg0);
extern s32 func_80173B60(s32);
extern s32 D_800AF0B0;
extern void Unpack(s32, s32);
extern OSMesgQueue MQ_800AF320;
extern void Unpack(u8* buffer, u32 size);
typedef struct {
/* 0x00 */ s32 field_0x0;
/* 0x04 */ OSMesgQueue* queue;
/* 0x08 */ u8 format;
/* 0x09 */ u8 field_0x9[3];
/* 0x0C */ s32 field_0xc;
/* 0x10 */ s32 field_0x10;
/* 0x0C */ s32 size;
/* 0x10 */ u8* buffer;
} OBUnpackMesg;
extern u32 obCurrentTime;

View File

@ -25,9 +25,9 @@ rdpstateinit_dl = 0x800A9EF0; // rom:0x3A2F0
nuGfxDisplay = 0x800C4BD8;
nuSiMesgQ = 0x800E9B88;
nuSiMesgBuf = 0x800BBE60;
siMgrThread = 0x800BBE80;
siMgrThread = 0x800BBE80; // size:0x1B0
nuThreadIdle = 0x800AF440;
nuStackIdle = 0x800B17A0;
nuStackIdle = 0x800AF7A0; // size:0x2000
nuPiCartHandle = 0x800E7A20;
nuPiMgrMesgQ = 0x800BE030;
nuPiMesgBuf = 0x800BE048;
@ -38,6 +38,15 @@ nuContDataMutexBuf = 0x800BE194;
nuContCallBack = 0x800A9FF8;
nuContStatus = 0x800C4B38; // size:0x10 type:u32
nuContNum = 0x800C6D60;
nuContDataLockKey = 0x800C4B30;
nuContData = 0x0800C4BF0; // size:0x18
nuContReadFunc = 0x800A9FE0;
nuContPakCallBack = 0x800AA040;
nuContPakCompanyCode = 0x800AA010;
nuContPakGameCode = 0x800AA014;
nuSiCallBackList = 0x800A9EA0;
nuGfxTaskEndFunc = 0x800A9E88;
nuStackSiMgrThread = 0x800BC030;
nuBoot = 0x8007F880;
nuScCreateScheduler = 0x80088C50; // rom:0x19050
@ -78,11 +87,25 @@ nuPiReadRom = 0x80089F80;
nuContQueryRead = 0x8008A640;
nuContMgrInit = 0x8008A260;
nuContDataUnLock = 0x8008A5D0;
func_8008A5A0 = 0x8008A5A0;
nuSiCallBackAdd = 0x8008B130;
nuContMgrRemove = 0x8008A334;
nuSiCallBackRemove = 0x8008B1D0;
nuContDataClose = 0x8008A354;
nuContDataOpen = 0x8008A37C;
nuContDataGetAll = 0x8008A600;
nuContRetrace = 0x8008A47C;
nuContReadFuncSet = 0x8008A660;
nuContPakMgrInit = 0x8008A6A0;
nuContPakMgrRemove = 0x8008A6C0;
nuContPakRepairId = 0x8008A8E8;
nuContPakFileState = 0x8008A890;
nuContPakFileNum = 0x8008A8BC;
nuContPakFileDelete = 0x8008A850;
nuContPakFileOpen = 0x8008A798;
nuContPakFileReadWrite = 0x8008A758;
nuContPakGetFree = 0x8008A730;
nuContPakOpen = 0x8008A6E0;
obCurrentTime = 0x800C47D0;
@ -113,6 +136,7 @@ osPfsDeleteFile = 0x80095FC0; // rom:0x263C0
__osPfsReleasePages = 0x8009616C; // rom:0x2656C
osPfsFileState = 0x80096620; // rom:0x26A20
osPfsReadWriteFile = 0x800961E0; // rom:0x265E0
osPfsNumFiles = 0x80096A90; // rom:0x26E90
osAiSetNextBuffer = 0x8008C550; // rom:0x1C950
__osAiDeviceBusy = 0x80099BC0; // rom:0x29FC0
@ -778,7 +802,6 @@ __MENU_INDEX = 0x801BA94C;
__GLOBAL_WITH__inc_menu_timer = 0x8018FB20;
__set_fp_8008A660 = 0x8008A660;
__osSetTimerIntr = 0x80094F70;
__osInsertTimer = 0x80094FD0;
@ -926,7 +949,7 @@ __MUS_MEM_800B1868 = 0x800B1868;
MQ_SWAP_BUFFER = 0x800E9BA8;
MQ_800E7988 = 0x800E7988;
MQ_800C35A0 = 0x800C35A0;
MQ_800AF320 = 0x800AF320;
obUnpackQueue = 0x800AF320;
MQ_800B1880 = 0x800B1880;
MQ_800E79C8 = 0x800E79C8;
MQ_800C49E8 = 0x800C49E8;
@ -969,7 +992,6 @@ __initialize_song_mem = 0x80073FD4;
STR_INVALID_HEADER_LHA_FILE = 0x800AE108;
SWAP_BUFFER_FUNC_800A9E88 = 0x800A9E88;
SWAP_BUFFER_FUNC_800A9E8C = 0x800A9E8C;
set_swap_buffer_func_800A9E8C = 0x8008AFA0;
@ -987,13 +1009,10 @@ __ROM_0_to_8000 = 0x800A83B8; // rom:0x387B8
romCopy_256 = 0x80074CF0; // rom:0x50F0
__GLOBAL_CONTROLLER_DATA = 0x0800C4BF0; // size:0x18
__GLOBAL_CONTROLLER_DATA_COPY = 0x0800AEE78; // size:0x18
__calls_copy_controller_data = 0x8007297C;
__copy_global_controller_data = 0x8008A600;
__read_controller = 0x8008A3A4;
__calls_read_controller_0 = 0x8008A47C;
__calls_read_controller_1 = 0x8008A508;
__calls_read_controller_2 = 0x8008A528;
@ -1009,12 +1028,9 @@ __ERROR_BAD_TABLE = 0x800AE338;
__VIRTUAL_MEMORY_EXHAUSTED = 0x800AE35C;
__virtual_mem_alloc = 0x80070F30;
obMain = 0x80071EB0;
obThreadMain = 0x800AF5F0;
obThreadMain = 0x800AF5F0; // size:0x1B0
obStackMain = 0x800C4D60; // size:0x2000
entry = 0x80070C00;

View File

@ -126,10 +126,12 @@ segments:
- [0x1A380, c, "nu/nupireadrom"]
- [0x1A4F0, c, "rom_copy"]
- [0x1A5B0, c, "nu/nugfxinit"]
- [0x1A660, c, "_ob_prized_reading"]
- [0x1A9A0, c, "_ob_silly_cactus"]
- [0x1AA00, c, "_ob_classy_fold"]
- [0x1AAA0, c, "_ob_dull_silver"]
- [0x1A660, c, "nu/nucontmgr"]
- [0x1A9A0, c, "nu/nucontdatalock"]
- [0x1AA00, c, "nu/nucontdatagetall"]
- [0x1AA40, c, "nu/nucontqueryread"]
- [0x1AA60, c, "nu/nucontreadfuncset"]
- [0x1AAA0, c, "nu/nucontpakmgr"]
- [0x1AD10, asm]
- [0x1AFD0, asm]
- [0x1B030, asm]
@ -142,8 +144,9 @@ segments:
- [0x1B360, asm]
- [0x1B3A0, c, "_ob_electric_zephyr"]
- [0x1B3E0, c, "nu/nugfxthread"]
- [0x1B510, c, "_ob_painful_roll"]
- [0x1B530, asm]
- [0x1B510, c, "nu/nugfxswapcfb"]
- [0x1B530, c, "nu/nusicallbackadd"]
- [0x1B5D0, c, "nu/nusicallbackremove"]
- [0x1B650, asm]
- [0x1B7A0, asm]
- [0x1B940, asm]
@ -368,7 +371,7 @@ segments:
- [0x3F170, rodata, "2D680"]
- [0x3F180, rodata, "2D7F0"]
- { start: 0x3F1B0, type: bss, vram: 0x800E9C20 }
- { start: 0x3F1B0, type: bss, vram: 0x800AEDB0 }
- type: code
name: segment_song

View File

@ -1,22 +0,0 @@
#include "common.h"
#include "nu/nusys.h"
void __copy_global_controller_data(OSContPad* arg0) {
nuContDataClose();
bcopy(&__GLOBAL_CONTROLLER_DATA, arg0, 0x18);
nuContDataOpen();
}
void nuContQueryRead(void) {
nuSiSendMesg(NU_CONT_QUERY_MSG, NULL);
}
void __set_fp_8008A660(void(*arg0)(s16)) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
D_800A9FE0 = arg0;
osSetIntMask(mask);
}

View File

@ -1,28 +0,0 @@
#include "common.h"
#include "nu/nusys.h"
void func_8008A6A0(void) {
nuSiCallBackAdd(&D_800AA040);
}
void func_8008A6C0(void) {
nuSiCallBackRemove(&D_800AA040);
}
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A6E0);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A730);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A758);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A798);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A850);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A890);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A8BC);
INCLUDE_ASM(const s32, "_ob_dull_silver", func_8008A8E8);

View File

@ -58,6 +58,8 @@ extern void* D_800C47F0[4];
extern void func_8007819C();
extern s32 func_80173B60(s32);
extern OSMesgQueue obUnpackQueue;
INCLUDE_ASM(const s32, "_ob_rabid_jar", __calls_loads_overlay_array);
INCLUDE_ASM(const s32, "_ob_rabid_jar", func_80076150);
@ -450,19 +452,19 @@ INCLUDE_ASM(const s32, "_ob_rabid_jar", func_8007AB30);
/* AF7C 8007AB7C */
void obSendUnpackMesg(OBUnpackMesg* msg) {
msg->format = 1;
osSendMesg(&MQ_800AF320, msg, 1);
osSendMesg(&obUnpackQueue, msg, OS_MESG_BLOCK);
}
INCLUDE_ASM(const s32, "_ob_rabid_jar", func_8007ABAC);
/* B030 8007AC30 */
void UnpackProc(void) {
void UnpackProc(void* __unused) {
OBUnpackMesg *msg = NULL;
while(1) {
osRecvMesg(&MQ_800AF320, (OSMesg)&msg, 1);
osRecvMesg(&obUnpackQueue, (OSMesg)&msg, 1);
if (msg->format == 1) {
Unpack(msg->field_0x10, msg->field_0xc);
Unpack(msg->buffer, msg->size);
osSendMesg(msg->queue, msg, OS_MESG_BLOCK);
} else {
osSyncPrintf("UnpackProc: no supported format %d\n", msg->format);

View File

@ -1,18 +0,0 @@
#include "common.h"
void func_8008A5A0(void) {
s32 temp_v0;
temp_v0 = osSetIntMask(OS_IM_NONE);
D_800C4B30 = 1;
osSetIntMask(temp_v0);
}
void nuContDataUnLock(void) {
s32 temp_v0;
temp_v0 = osSetIntMask(OS_IM_NONE);
D_800C4B30 = 0;
osSetIntMask(temp_v0);
}

View File

@ -2,14 +2,21 @@
#include "nu/nusys.h"
#define OB_MAIN_STACK_SIZE 0x2070
extern OSThread nuThreadIdle;
extern u64 nuStackIdle[];
extern DECLARE_STACK(nuStackIdle, NU_IDLE_STACK_SIZE);
extern OSThread obThreadMain;
extern DECLARE_STACK(obStackMain, NU_MAIN_STACK_SIZE);
const int test = sizeof(obThreadMain);
void nuIdle(void* arg);
void nuBoot(void) {
osInitialize();
osCreateThread(&nuThreadIdle, NU_IDLE_THREAD_ID, nuIdle, NULL, nuStackIdle, NU_MAIN_THREAD_PRI);
osCreateThread(&nuThreadIdle, NU_IDLE_THREAD_ID, nuIdle, NULL, STACK_START(nuStackIdle), NU_MAIN_THREAD_PRI);
osStartThread(&nuThreadIdle);
}
@ -21,7 +28,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, STACK_START(obStackMain), NU_MAIN_THREAD_PRI);
osStartThread(&obThreadMain);
osSetThreadPri(&nuThreadIdle, NU_IDLE_THREAD_PRI);

191
src/lha.c
View File

@ -1,191 +0,0 @@
#include "common.h"
// char* STR_Invalid_header_LHarc_file_ = "Invalid header (LHarc file ?)";
// char* STR_INVALID_HEADER_LHA_FILE = "Invalid header (LHa file ?)";
const u32 STR_FILE_NOT_FOUND[] = {
0x83478389,
0x815B94AD,
0x90B68149,
0x8140966B,
0x90EC82DC,
0x82C59841,
0x978D82B5,
0x82C489BA,
0x82B382A2,
0x81420A00
};
const char STR_LHa___s_s__s[] = "LHa: %s%s %s\n";
const char STR_Error[] = "Error: ";
const char STR_Fatal_error[] = "Fatal error:";
const char STR_EMPTY[] = "";
void Unpack(s32, s32);
INCLUDE_ASM(const s32, "lha", func_80079F70);
INCLUDE_ASM(const s32, "lha", func_8007A070);
INCLUDE_ASM(const s32, "lha", Unpack);
/* ABE0 8007A7E0 */
u32 __read_u32_le(u8* arg0) {
return (arg0[0] << 24) | (arg0[1] << 16) | (arg0[2] << 8) | arg0[3];
}
INCLUDE_ASM(const s32, "lha", func_8007A80C);
INCLUDE_ASM(const s32, "lha", func_8007AB30);
INCLUDE_ASM(const s32, "lha", func_8007AB7C);
INCLUDE_ASM(const s32, "lha", func_8007ABAC);
extern char STR_UNPACK_ERROR_UNSUPPORTED_FORMAT[];
extern OSMesgQueue MQ_800AF320;
/* B030 8007AC30 */
void UnpackProc(void) {
struct {
/* 0x00 */ s32 field_0x0;
/* 0x04 */ OSMesgQueue* field_0x4;
/* 0x08 */ u8 field_0x8;
/* 0x09 */ u8 field_0x9[3];
/* 0x0C */ s32 field_0xc;
/* 0x10 */ s32 field_0x10;
} *sp10;
sp10 = NULL;
while(1) {
osRecvMesg(&MQ_800AF320, &sp10, 1);
if (sp10->field_0x8 == 1) {
Unpack(sp10->field_0x10, sp10->field_0xc);
osSendMesg(sp10->field_0x4, sp10, 1);
} else {
__some_logging(STR_UNPACK_ERROR_UNSUPPORTED_FORMAT, sp10->field_0x8);
}
}
}
INCLUDE_ASM(const s32, "lha", func_8007ACB0);
INCLUDE_ASM(const s32, "lha", func_8007AE9C);
INCLUDE_ASM(const s32, "lha", func_8007AF3C);
INCLUDE_ASM(const s32, "lha", func_8007AFE4);
INCLUDE_ASM(const s32, "lha", func_8007B710);
INCLUDE_ASM(const s32, "lha", func_8007B744);
INCLUDE_ASM(const s32, "lha", func_8007B7A8);
INCLUDE_ASM(const s32, "lha", func_8007B83C);
INCLUDE_ASM(const s32, "lha", can_log_crc_error);
INCLUDE_ASM(const s32, "lha", func_8007BA98);
INCLUDE_ASM(const s32, "lha", func_8007BB48);
/* BF90 8007BB90 */
void __log_lha_error(unsigned char* arg0, unsigned char* arg1) {
__some_logging(STR_LHa___s_s__s, STR_Error, arg0, arg1);
}
/* BFC0 8007BBC0 */
void __log_fatal_error_desc(char* arg0) {
__some_logging(STR_LHa___s_s__s, STR_Fatal_error, &STR_EMPTY, arg0);
}
/* BFF4 8007BBF4 */
void __log_fatal_error(char* arg0, char* arg1) {
__some_logging(STR_LHa___s_s__s, STR_Fatal_error, arg0, arg1);
}
INCLUDE_ASM(const s32, "lha", func_8007BC24);
INCLUDE_ASM(const s32, "lha", func_8007BF10);
INCLUDE_ASM(const s32, "lha", func_8007C204);
INCLUDE_ASM(const s32, "lha", func_8007C25C);
INCLUDE_ASM(const s32, "lha", func_8007C378);
INCLUDE_ASM(const s32, "lha", func_8007C438);
INCLUDE_ASM(const s32, "lha", func_8007C538);
INCLUDE_ASM(const s32, "lha", __logs_read_error);
INCLUDE_ASM(const s32, "lha", func_8007C74C);
INCLUDE_ASM(const s32, "lha", func_8007CAB8);
INCLUDE_ASM(const s32, "lha", func_8007CE48);
INCLUDE_ASM(const s32, "lha", func_8007D200);
INCLUDE_ASM(const s32, "lha", func_8007D594);
INCLUDE_ASM(const s32, "lha", func_8007D5B8);
INCLUDE_ASM(const s32, "lha", func_8007D7BC);
INCLUDE_ASM(const s32, "lha", func_8007D8A8);
INCLUDE_ASM(const s32, "lha", func_8007DBF4);
INCLUDE_ASM(const s32, "lha", func_8007DDF0);
INCLUDE_ASM(const s32, "lha", func_8007DFF0);
INCLUDE_ASM(const s32, "lha", func_8007E2F8);
INCLUDE_ASM(const s32, "lha", func_8007E698);
INCLUDE_ASM(const s32, "lha", func_8007E6DC);
INCLUDE_ASM(const s32, "lha", func_8007E800);
INCLUDE_ASM(const s32, "lha", func_8007E8F0);
INCLUDE_ASM(const s32, "lha", func_8007EE2C);
INCLUDE_ASM(const s32, "lha", func_8007F1A0);
INCLUDE_ASM(const s32, "lha", func_8007F1F8);
INCLUDE_ASM(const s32, "lha", func_8007F218);
INCLUDE_ASM(const s32, "lha", func_8007F234);
INCLUDE_ASM(const s32, "lha", func_8007F314);
INCLUDE_ASM(const s32, "lha", func_8007F334);
INCLUDE_ASM(const s32, "lha", func_8007F408);
INCLUDE_ASM(const s32, "lha", func_8007F450);
INCLUDE_ASM(const s32, "lha", func_8007F47C);
INCLUDE_ASM(const s32, "lha", func_8007F4B0);
INCLUDE_ASM(const s32, "lha", func_8007F4E4);
INCLUDE_ASM(const s32, "lha", __file_read);
INCLUDE_ASM(const s32, "lha", __file_write);
void func_8007F640(void) { }
INCLUDE_ASM(const s32, "lha", func_8007F648);
INCLUDE_ASM(const s32, "lha", func_8007F844);

View File

@ -19,7 +19,6 @@ void __calls_copy_controller_data(); /* extern */
void __calls_loads_overlay_array(); /* extern */
void __calls_osViSwapBuffer_8007307C(void**); /* extern */
void __initialize_song_mem(); /* extern */
void __set_fp_8008A660(void(*)(u16)); /* extern */
void __set_obPtrPtrDisplayList(Gfx**); /* extern */
void func_80070C60(s32*, s32); /* extern */
void func_80072710(); /* extern */
@ -220,11 +219,11 @@ void func_8007284C(u16 __unused) {
if ((D_800AEF9A & 1) && !(D_800AEF9A & 4)) {
if (D_800AEF9A & 2) {
if (__GLOBAL_CONTROLLER_DATA[0].button == 0) {
if (nuContData[0].button == 0) {
D_800AEF9A = D_800AEF9A & 0xFD;
}
} else if (__GLOBAL_CONTROLLER_DATA[0].button == pattern_a ||
__GLOBAL_CONTROLLER_DATA[0].button == pattern_b) {
} else if (nuContData[0].button == pattern_a ||
nuContData[0].button == pattern_b) {
D_800AEF9A = D_800AEF9A | 6;
}
}

View File

@ -0,0 +1,9 @@
#include "common.h"
#include "nu/nusys.h"
void nuContDataGetAll(OSContPad* contdata) {
nuContDataClose();
bcopy(&nuContData, contdata, 0x18);
nuContDataOpen();
}

20
src/nu/nucontdatalock.c Normal file
View File

@ -0,0 +1,20 @@
#include "common.h"
#include "nu/nusys.h"
void nuContDataLock(void) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
nuContDataLockKey = 1;
osSetIntMask(mask);
}
void nuContDataUnLock(void) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
nuContDataLockKey = 0;
osSetIntMask(mask);
}

View File

@ -53,7 +53,7 @@ s32 __read_controller(OSContPad* data, u32 flags) {
return res;
osRecvMesg(&nuSiMesgQ, NULL, OS_MESG_BLOCK);
if (!(flags & D_800C4B30)) {
if (!(flags & nuContDataLockKey)) {
func_8008A354();
osContGetReadData(data);
func_8008A37C();
@ -76,17 +76,22 @@ s32 __real_read_controller(void) {
}
}
s32 nuContRetrace(NUSiCommonMesg* mesg) {
if(nuContDataLockKey) {
return NU_SI_CALLBACK_CONTINUE;
}
s32 __calls_read_controller_0(s16* arg0) {
if (D_800C4B30 == 0) {
osRecvMesg(&nuContWaitMesgQ, NULL, 0);
__read_controller(__GLOBAL_CONTROLLER_DATA, 1);
if (D_800A9FE0 != NULL) {
D_800A9FE0(*arg0);
osRecvMesg(&nuContWaitMesgQ, NULL, OS_MESG_NOBLOCK);
__read_controller(nuContData, 1);
if(nuContReadFunc != NULL) {
nuContReadFunc(mesg->mesg);
}
osSendMesg(&nuContWaitMesgQ, NULL, 0);
}
return 0;
osSendMesg(&nuContWaitMesgQ, NULL, OS_MESG_NOBLOCK);
return NU_SI_CALLBACK_CONTINUE;
}
typedef struct {
@ -102,10 +107,10 @@ s32 __calls_read_controller_2(s16* arg0) {
s32 var_v0;
osRecvMesg(&nuContWaitMesgQ, NULL, 0);
var_v0 = __read_controller(__GLOBAL_CONTROLLER_DATA, 0);
var_v0 = __read_controller(nuContData, 0);
if (var_v0 == 0) {
if (D_800A9FE0 != NULL) {
D_800A9FE0(*arg0);
if (nuContReadFunc != NULL) {
nuContReadFunc(*arg0);
}
return 0;
} else {

28
src/nu/nucontpakmgr.c Normal file
View File

@ -0,0 +1,28 @@
#include "common.h"
#include "nu/nusys.h"
void nuContPakMgrInit(void) {
nuSiCallBackAdd(&nuContPakCallBack);
}
void nuContPakMgrRemove(void) {
nuSiCallBackRemove(&nuContPakCallBack);
}
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakOpen);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakGetFree);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakFileReadWrite);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakFileOpen);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakFileDelete);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakFileState);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakFileNum);
INCLUDE_ASM(const s32, "nu/nucontpakmgr", nuContPakRepairId);

7
src/nu/nucontqueryread.c Normal file
View File

@ -0,0 +1,7 @@
#include "common.h"
#include "nu/nusys.h"
void nuContQueryRead(void) {
nuSiSendMesg(NU_CONT_QUERY_MSG, NULL);
}

View File

@ -0,0 +1,11 @@
#include "common.h"
#include "nu/nusys.h"
void nuContReadFuncSet(NUContReadFunc func) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
nuContReadFunc = func;
osSetIntMask(mask);
}

24
src/nu/nusicallbackadd.c Normal file
View File

@ -0,0 +1,24 @@
#include "common.h"
#include "nu/nusys.h"
void nuSiCallBackAdd(NUCallBackList* list) {
OSIntMask mask;
NUCallBackList** siCallBackListPtr = &nuSiCallBackList;
u32 i;
while (*siCallBackListPtr != NULL) {
if ((*siCallBackListPtr)->majorNo == list->majorNo) {
return;
}
siCallBackListPtr = &(*siCallBackListPtr)->next;
}
for (i = 1; list->func[i] != NULL; i++);
mask = osSetIntMask(OS_IM_NONE);
*siCallBackListPtr = list;
list->next = NULL;
list->funcNum = i;
osSetIntMask(mask);
}

View File

@ -0,0 +1,19 @@
#include "common.h"
#include "nu/nusys.h"
void nuSiCallBackRemove(NUCallBackList* list) {
OSIntMask mask;
NUCallBackList** siCallBackListPtr = &nuSiCallBackList;
while (*siCallBackListPtr) {
if ((*siCallBackListPtr)->next == list) {
mask = osSetIntMask(OS_IM_NONE);
(*siCallBackListPtr)->next = list->next;
list->next = NULL;
osSetIntMask(mask);
break;
}
siCallBackListPtr = &(*siCallBackListPtr)->next;
}
}

View File

@ -5,6 +5,8 @@
void nuSiMgrThread(void* arg);
extern DECLARE_STACK(nuStackSiMgrThread, 0x2000);
/* 1A060 80089C60 */
u8 nuSiMgrInit(void) {
u8 pattern;
@ -15,7 +17,7 @@ u8 nuSiMgrInit(void) {
osContInit(&nuSiMesgQ, &pattern, status);
osCreateThread(&siMgrThread, 5, nuSiMgrThread, NULL, &nuPiMgrMesgQ, NU_SI_THREAD_PRI);
osCreateThread(&siMgrThread, 5, nuSiMgrThread, NULL, STACK_START(nuStackSiMgrThread), NU_SI_THREAD_PRI);
osStartThread(&siMgrThread);
return pattern;