From 8243e81b2eeea19de60e5a3f1cff84783690c7e2 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Thu, 10 Dec 2020 07:53:35 +0900 Subject: [PATCH] Audio header --- asm/data/code_1000_len_60.data.s | 2 +- .../code_25f00_len_940/func_8004AB00.s | 6 +- .../code_25f00_len_940/func_8004AE08.s | 20 +- include/nu/nualsgi.h | 346 +++ include/nu/nusys.h | 2198 ++++++++--------- src/code_25f00_len_940.c | 14 +- tools/symbol_addrs.txt | 2 + undefined_syms_auto.txt | 1 - 8 files changed, 1469 insertions(+), 1120 deletions(-) create mode 100644 include/nu/nualsgi.h diff --git a/asm/data/code_1000_len_60.data.s b/asm/data/code_1000_len_60.data.s index 1905f2ef4b..0073e0e497 100644 --- a/asm/data/code_1000_len_60.data.s +++ b/asm/data/code_1000_len_60.data.s @@ -260,7 +260,7 @@ glabel D_80078168 glabel D_80078170 .word 0x00000000 -glabel D_80078174 +glabel nuAuPreNMIFunc .word 0x00000000 glabel D_80078178 diff --git a/asm/nonmatchings/code_25f00_len_940/func_8004AB00.s b/asm/nonmatchings/code_25f00_len_940/func_8004AB00.s index 60ec8a0a65..50b0230b8e 100644 --- a/asm/nonmatchings/code_25f00_len_940/func_8004AB00.s +++ b/asm/nonmatchings/code_25f00_len_940/func_8004AB00.s @@ -158,13 +158,13 @@ glabel func_8004AB00 /* 26154 8004AD54 248491A0 */ addiu $a0, $a0, %lo(D_800B91A0) /* 26158 8004AD58 3C028005 */ lui $v0, %hi(D_8004B328) /* 2615C 8004AD5C 2442B328 */ addiu $v0, $v0, %lo(D_8004B328) -/* 26160 8004AD60 3C018008 */ lui $at, %hi(D_80078174) -/* 26164 8004AD64 AC228174 */ sw $v0, %lo(D_80078174)($at) +/* 26160 8004AD60 3C018008 */ lui $at, %hi(nuAuPreNMIFunc) +/* 26164 8004AD64 AC228174 */ sw $v0, %lo(nuAuPreNMIFunc)($at) /* 26168 8004AD68 0C015894 */ jal func_80056250 /* 2616C 8004AD6C 27A50018 */ addiu $a1, $sp, 0x18 /* 26170 8004AD70 8FA40020 */ lw $a0, 0x20($sp) /* 26174 8004AD74 0C014B97 */ jal func_80052E5C -/* 26178 8004AD78 00000000 */ nop +/* 26178 8004AD78 00000000 */ nop /* 2617C 8004AD7C 3C10800A */ lui $s0, %hi(D_800A0F58) /* 26180 8004AD80 26100F58 */ addiu $s0, $s0, %lo(D_800A0F58) /* 26184 8004AD84 0200202D */ daddu $a0, $s0, $zero diff --git a/asm/nonmatchings/code_25f00_len_940/func_8004AE08.s b/asm/nonmatchings/code_25f00_len_940/func_8004AE08.s index 490392cf5c..a1aa70a518 100644 --- a/asm/nonmatchings/code_25f00_len_940/func_8004AE08.s +++ b/asm/nonmatchings/code_25f00_len_940/func_8004AE08.s @@ -95,14 +95,14 @@ glabel func_8004AE08 /* 2635C 8004AF5C 0000902D */ daddu $s2, $zero, $zero .L8004AF60: /* 26360 8004AF60 0C018554 */ jal osAiGetStatus -/* 26364 8004AF64 00000000 */ nop +/* 26364 8004AF64 00000000 */ nop /* 26368 8004AF68 04410003 */ bgez $v0, .L8004AF78 -/* 2636C 8004AF6C 00000000 */ nop +/* 2636C 8004AF6C 00000000 */ nop /* 26370 8004AF70 08012BA8 */ j .L8004AEA0 /* 26374 8004AF74 0000B02D */ daddu $s6, $zero, $zero .L8004AF78: /* 26378 8004AF78 0C018550 */ jal osAiGetLength -/* 2637C 8004AF7C 00000000 */ nop +/* 2637C 8004AF7C 00000000 */ nop /* 26380 8004AF80 8FA30078 */ lw $v1, 0x78($sp) /* 26384 8004AF84 10600011 */ beqz $v1, .L8004AFCC /* 26388 8004AF88 00028082 */ srl $s0, $v0, 2 @@ -126,7 +126,7 @@ glabel func_8004AE08 /* 263CC 8004AFCC 2A0200B8 */ slti $v0, $s0, 0xb8 .L8004AFD0: /* 263D0 8004AFD0 14400003 */ bnez $v0, .L8004AFE0 -/* 263D4 8004AFD4 00000000 */ nop +/* 263D4 8004AFD4 00000000 */ nop /* 263D8 8004AFD8 12C00005 */ beqz $s6, .L8004AFF0 /* 263DC 8004AFDC 24160001 */ addiu $s6, $zero, 1 .L8004AFE0: @@ -145,8 +145,8 @@ glabel func_8004AE08 /* 26408 8004B008 0040302D */ daddu $a2, $v0, $zero /* 2640C 8004B00C 0C015970 */ jal alAudioFrame /* 26410 8004B010 02A0382D */ daddu $a3, $s5, $zero -/* 26414 8004B014 3C038008 */ lui $v1, %hi(D_80078174) -/* 26418 8004B018 8C638174 */ lw $v1, %lo(D_80078174)($v1) +/* 26414 8004B014 3C038008 */ lui $v1, %hi(nuAuPreNMIFunc) +/* 26418 8004B018 8C638174 */ lw $v1, %lo(nuAuPreNMIFunc)($v1) /* 2641C 8004B01C 1060FFA0 */ beqz $v1, .L8004AEA0 /* 26420 8004B020 AFA2007C */ sw $v0, 0x7c($sp) /* 26424 8004B024 92E20000 */ lbu $v0, ($s7) @@ -156,12 +156,12 @@ glabel func_8004AE08 /* 26434 8004B034 0060F809 */ jalr $v1 /* 26438 8004B038 24040001 */ addiu $a0, $zero, 1 /* 2643C 8004B03C 08012C19 */ j .L8004B064 -/* 26440 8004B040 00000000 */ nop +/* 26440 8004B040 00000000 */ nop .L8004B044: -/* 26444 8004B044 3C028008 */ lui $v0, %hi(D_80078174) -/* 26448 8004B048 8C428174 */ lw $v0, %lo(D_80078174)($v0) +/* 26444 8004B044 3C028008 */ lui $v0, %hi(nuAuPreNMIFunc) +/* 26448 8004B048 8C428174 */ lw $v0, %lo(nuAuPreNMIFunc)($v0) /* 2644C 8004B04C 10400005 */ beqz $v0, .L8004B064 -/* 26450 8004B050 00000000 */ nop +/* 26450 8004B050 00000000 */ nop /* 26454 8004B054 3C058008 */ lui $a1, %hi(D_80078170) /* 26458 8004B058 90A58170 */ lbu $a1, %lo(D_80078170)($a1) /* 2645C 8004B05C 0040F809 */ jalr $v0 diff --git a/include/nu/nualsgi.h b/include/nu/nualsgi.h new file mode 100644 index 0000000000..84030df1d9 --- /dev/null +++ b/include/nu/nualsgi.h @@ -0,0 +1,346 @@ +/*======================================================================*/ +/* NuSYS Audio Library for SGI Library & naudio */ +/* nualsgi.h */ +/* */ +/* Copyright (C) 1997, NINTENDO Co,Ltd. */ +/* */ +/* $Id: nualsgi.h,v 1.10 1999/01/14 05:45:36 ohki Exp ohki $ */ +/*======================================================================*/ +#ifndef _NUALSGI_H_ +#define _NUALSGI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* DEFINE */ +/*----------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* AUDIO MANAGER DEFINE */ +/*----------------------------------------------------------------------*/ +/* AUDIO HEAP calculation */ +/* */ +/* (1) alInit heap size */ +/* AUDIO HEAP calls the function alHeapAlloc to allocate heap memory when synthesizer, */ +/* sequence, or sound drivers are initialized. */ +/* The size of the alHeap area required is determined as follows. */ +/* */ +/* */ +/* 144 + maxPVoices * 432 + 32 * maxUPdates + FxType */ +/* */ +/* FxType varies with the type of effect and takes the following values. */ +/* AL_FX_NONE 0 */ +/* AL_FX_SMALLROOM 8192 */ +/* AL_FX_BIGROOM 8224 */ +/* AL_FX_ECHO 1640 */ +/* AL_FX_CHORUS 304 */ +/* AL_FX_FLANGE 304 */ +/* */ +/* (2) Heap size for alSeqpNew and alCSPNew */ +/* */ +/* maxChannels * 16 + maxVoices * 64 + maxEvents * 32 */ +/* */ +/* (3)Heap size for alSndpNew */ +/* */ +/* maxSounds * 48 + maxEvents * 32 */ +/* */ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* SYNTHE DEFINE */ +/*--------------------------------------*/ +#define NU_AU_SYN_VVOICE_MAX 64 /* Maximum number of virtual voices (Not actually used).*/ +#define NU_AU_SYN_PVOICE_MAX 32 /* Maximum number of physical voices. */ +#define NU_AU_SYN_UPDATE_MAX 128 /* Maximum number of synthesizer parameter updates*/ +#define NU_AU_SYN_HEAP_SIZE (144+NU_AU_SYN_PVOICE_MAX*432+32*NU_AU_SYN_UPDATE_MAX+0x2000) + +/*--------------------------------------*/ +/* SEQUENCE DEFINE */ +/*--------------------------------------*/ +#define NU_AU_SEQ_VOICE_MAX 24 /* Maximum number of voices*/ +#define NU_AU_SEQ_EVENT_MAX 48 /* Number of events */ +#define NU_AU_SEQ_CHANNEL_MAX 16 /* Number of MIDI channels (typically 16) */ +#define NU_AU_SEQ_HEAP_SIZE (16*NU_AU_CHANNEL_MAX+32*NU_AU_EVENT_MAX) +#define NU_AU_SEQ_PLAYER0 0 +#define NU_AU_SEQ_PLAYER1 1 +#define NU_AU_SEQ_MODE_FADEOUT 0x0001 +#define NU_AU_SEQ_MODE_PLAYPENDING 0x0002 + + +/*--------------------------------------*/ +/* SOUND DEFINE */ +/*--------------------------------------*/ +#define NU_AU_SND_SOUND_MAX 8 /* Maximum number of sounds*/ +#define NU_AU_SND_EVENT_MAX (NU_AU_SND_SOUND_MAX*2) /* Maximum number of events */ +#define NU_AU_SND_HEAP_SIZE (NU_AU_SND_SOUND_MAX*48+NU_AU_SND_EVENT*64) + +/*--------------------------------------*/ +/* AUDIO DMA DEFINE */ +/*--------------------------------------*/ +#define NU_AU_DMA_BUFFER_NUM 64 /* Number of DMA transfer buffers */ +#define NU_AU_DMA_BUFFER_SIZE 1024 /* Size of the DMA buffer */ +#define NU_AU_BUFFER_USE_FRAME 1 /* Frame interval for the cleared DMA buffer */ + +/*--------------------------------------*/ +/* SOUND DEFINE */ +/*--------------------------------------*/ +#define NU_AU_MGR_THREAD_PRI 70 +#define NU_AU_MGR_THREAD_ID 6 +#define NU_AU_STACK_SIZE 0x2000 +#define NU_AU_CLIST_LEN 0x800 +#define NU_AU_CLIST_SIZE (NU_AU_CLIST_LEN*sizeof(Acmd)) /* Buffer size for the command list */ + +#define NU_AU_BUFFER_MAX 0x1000 /* Size of the buffer for the synthesizer */ +#define NU_AU_OUTPUT_RATE 32000 /* Set the frequency. */ +#define NU_AU_MESG_MAX 8 +#define NU_AU_HEAP_MIN_SIZE (NU_AU_SND_HEAP_SIZE+NU_AU_SEQ_HEAP_SIZE+NU_AU_SYN_HEAP_SIZE+NU_AU_DMA_BUFFER_NUM*NU_AU_DMA_BUFFER_SIZE+NU_AU_CLIST_SIZE*2) +#define NU_AU_HEAP_SIZE 0x50000 /* Default HEAP size */ +#define NU_AU_HEAP_ADDR (NU_GFX_FRAMEBUFFER_ADDR - NU_AU_HEAP_SIZE) + +#ifdef N_AUDIO +#define NU_AU_AUDIO_SAMPLES 184 /* Sample number is a multiple of 16. */ +#else +#define NU_AU_AUDIO_SAMPLES 16 /* Sample number is a multiple of 16. */ +#endif /* N_AUDIO */ + +#define NU_AU_AUDIO_EXTRASMP 0 /* Number of extra samples */ + +#define NU_AU_TASK_STOP 0 /* Stop audio task execution. */ +#define NU_AU_TASK_RUN 1 /* Allow audio task execution. */ + +#define NU_AU_AI_FIFO_MSG 0x100 /* AI event message */ +#define NU_AU_AI_DEBUG_MSG 0x1000 /* For AI debugging */ + +#define NU_AU_FRAMERATE_NTSC 60 /* NTSC/MPAL */ +#define NU_AU_FRAMERATE_PAL 50 /* PAL */ + +/*--------------------------------------*/ +/* DEBUG & PERFORMANCE */ +/*--------------------------------------*/ +#define NU_AU_DEBUG_NORMAL 0x00000001 /* warning & error */ +#define NU_AU_DEBUG_DISABLEDMA 0x00010000 /* disable dma callback */ +#define NU_AU_DEBUG_DISABLEAI 0x00020000 /* disable set AI */ +#define NU_AU_DEBUG_DISABLETASK 0x00040000 /* disable task */ +#define NU_AU_DEBUG_FIFOOFF 0x00080000 /* FIFO EVENT OFF */ +#define NU_AU_DEBUG_RETRACEOFF 0x00100000 /* RETRACE EVENT OFF */ + +#define NU_AU_DEBUG_NODMABUF 0x00000001 /* No DMA Buffer */ +#define NU_AU_DEBUG_ACMDBUFOVER 0x00000002 /* Acmd buffer is small */ +#define NU_AU_DEBUG_DMABUFSIZE 0x00000004 /* dma buffer size is small */ +#define NU_AU_DEBUG_DMANOTCOMPLETE 0x00000008 /* dma not completed */ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +#include +#ifdef N_AUDIO +#include +#include +#else /* N_AUDIO */ +#include +#endif /* N_AUDIO */ + +/*--------------------------------------*/ +/* audio typedef */ +/*--------------------------------------*/ +/*--------------------------------------*/ +/* DMA BUFFER STRUCT */ +/*--------------------------------------*/ +typedef struct { + ALLink node; /* Pointer to the linked list*/ + s32 startAddr; /* Address in data ROM */ + s32 frameCnt; /* Buffer frame counter */ + char* ptr; /* Value of the pointer to buffer */ +} NUDMABuffer; +/*--------------------------------------*/ +/* DMA callback for the Sequence Player */ +/* DMA status used by the routines */ +/* Structure that stores the use status of the DMABuffer*/ +/*--------------------------------------*/ +typedef struct { + u8 initialized; /* Flag indicating whether the structure has been initialized */ + NUDMABuffer* firstUsed; /* Start of the DMA Buffer linked list being used */ + NUDMABuffer* firstFree; /* Start of the free DMA Buffer linked list */ +} NUDMAState; + +/* Sequence Display structure*/ +typedef struct st_Seqence{ + ALCSPlayer player; /* Sequence Display structure */ + ALCSeq sequence; + u8* data_ptr; /* Sequence data */ + s32 seqno; /* Sequence No. */ + u32 mode; /* Control extension */ + u16 counter; + u16 speed; +} NUAuSeqPlayer; + +typedef struct st_SndState { + ALSndId* Id; + u8 flag; +} NUAuSndId; + + +/*--------------------------------------*/ +/* CALL BACK Function typedef */ +/*--------------------------------------*/ +typedef void (*NUAuPreNMIFunc)(NUScMsg,u32); /* PRENMI callback function */ +typedef void (*NUAuMgrFunc)(void); /* Acmd callback function */ + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* extern variables */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* audio variables */ +/*--------------------------------------*/ +extern u64* nuAuMgrStack; +extern NUScTask nuAuTask; /* Audio task buffer*/ +extern s16* nuAuBuffer_ptr[]; /* Audio buffer */ +extern NUScClient nuAuClient; +extern OSThread nuAuMgrThread; +extern u32 nuAuFrameCounter; /* Frame counter */ +extern ALHeap nuAuHeap; /* Heap structure */ +extern NUAuSeqPlayer nuAuSeqPlayer[]; +extern u8* nuAuSeqData; +extern ALBankFile* nuAuSeqBank_ptr; +extern ALSeqFile* nuAuSeqFile_ptr; +extern ALSndPlayer nuAuSndPlayer; +extern ALBankFile* nuAuSndBank_ptr; +extern ALSndId* nuAuSndId; +extern ALSynConfig nuAuSynConfig; +extern ALSeqpConfig nuAuSeqpConfig; +extern ALSndpConfig nuAnSndpConfig; +extern u8 nuAuTaskStop; +extern u8 nuAuPreNMI; +extern NUAuPreNMIFunc nuAuPreNMIFunc; +extern NUAuMgrFunc nuAuMgrFunc; +extern OSMesgQueue nuAuMesgQ; /* Audio Manager queue */ +extern ALGlobals nuAuGlobal; +extern s16 nuAuDmaBufNum; +extern s16 nuAuDmaBufSize; +extern NUDMAState nuAuDmaState; +extern NUDMABuffer* nuAuDmaBuf; +extern Acmd* nuAuCmdListBuf; /* pointer of command list */ +extern u32 nuAuAcmdLen; +extern u8 nuAuRetraceCount; + + +extern u32 nuAuDebFlag; +extern u32 nuAuDebStatus; /* Status flag */ +extern u32 nuAuDebDmaCount; /* Total number of PI-DMAs */ +extern u32 nuAuDebDmaFrame; /* DMA counter */ +extern u32 nuAuDebDmaMax; /* Maximum number of PI-DMAs */ +extern u32 nuAuDebDmaBufMaxUse;/* Maximum number of DMA buffers used */ +extern u32 nuAuDebDmaCallbackCount;/* Total number of DMA callbacks */ +extern u32 nuAuDebDmaCallbackFrame;/* Number of DMA callbacks */ +extern u32 nuAuDebDmaCallbackMax; /* Maximum number of DMA callbacks*/ +extern u32 nuAuDebAcmdLenMax; /* Maximum length of the audio command list */ + +extern s16 nuAuFrameSampleSize; /* Number of samples created at one time */ +extern s16 nuAuExtraSampleSize; /* Number of extra samples */ +extern ALSynConfig nuAuSynConfig; +extern ALSeqpConfig nuAuSeqpConfig; +extern ALSndpConfig nuAuSndpConfig; + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Global Function */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* audio Manager function */ +/*--------------------------------------*/ +extern s32 nuAuInit(void); +extern s32 nuAuInitEx(void); +extern s32 nuAuMgrInit(void* heap_ptr, u32 size, ALSynConfig* synconfig); +extern s32 nuAuMgrInitEx(void* heap_ptr, u32 size, ALSynConfig* synConfig); + +extern void nuAuSeqPlayerInit(ALSeqpConfig* seqpconfig, u32 size, u32 player_no); +extern void nuAuSeqPlayerBankSet(u8* bank_addr, u32 bank_size, u8* table_addr); +extern void nuAuSeqPlayerPlay(u32 player_no); +extern void nuAuSeqPlayerSeqSet(u8* seq_addr); +extern void nuAuSeqPlayerSetNo(u32 player_no ,u32 seq_no); +extern void nuAuSeqPlayerFadeOut(u32 player_no ,u32 speed); +extern void nuAuSeqPlayerControl(void); + +extern void nuAuSndPlayerInit(ALSndpConfig* sndconfig); +extern void nuAuSndPlayerBankSet(u8* bank_addr, u32 bank_size, u8* table_addr); +extern ALSndId nuAuSndPlayerPlay(u32 sndNo); +extern void nuAuPreNMIFuncSet(NUAuPreNMIFunc func); +extern void nuAuPreNMIProc(NUScMsg mesg_type, u32 frameCounter); +extern void nuAuMgrFuncSet(NUAuMgrFunc func); +extern ALDMAproc nuAuDmaNew(NUDMAState **state); +extern void nuAuCleanDMABuffers(void); + +extern void nuAuHeapInit(ALHeap* hp, u8* base, s32 len); +extern void* nuAuHeapAlloc(s32 length); +extern s32 nuAuHeapGetFree(void); +extern s32 nuAuHeapGetUsed(void); + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* MACRO */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +/* Delete the callback function */ +#define nuAuPreNMIFuncRemove() nuAuPreNMIFuncSet(NULL) +#define nuAuMgrFuncRemove() nuAuMgrFuncSet(NULL) + +#define nuAuSeqPlayerGetChlVol(player_no, chan) \ + alCSPGetChlVol(&nuAuSeqPlayer[player_no].player, chan) +#define nuAuSeqPlayerGetChlFXMix(player_no, chan) \ + alCSPGetChlFXMix(&nuAuSeqPlayer[player_no].player, chan) +#define nuAuSeqPlayerGetChlPan(player_no, chan) \ + alCSPGetChlPan(&nuAuSeqPlayer[player_no].player, chan) +#define nuAuSeqPlayerGetChlPriority(player_no, chan) \ + alCSPGetChlPriority(&nuAuSeqPlayer[player_no].player, chan) +#define nuAuSeqPlayerGetChlProgram(player_no, chan) \ + alCSPGetChlProgram(&nuAuSeqPlayer[player_no].player, chan) +#define nuAuSeqPlayerGetSeq(player_no) \ + alCSPGetSeq(&nuAuSeqPlayer[player_no].player) +#define nuAuSeqPlayerGetSeqno(player_no) \ + nuAuSeqPlayer[player_no].seqno +#define nuAuSeqPlayerGetState(player_no) \ + alCSPGetState(&nuAuSeqPlayer[player_no].player) +#define nuAuSeqPlayerGetTempo(player_no) \ + alCSPGetTempo(&nuAuSeqPlayer[player_no].player) +#define nuAuSeqPlayerGetVol(player_no) \ + alCSPGetVol(&nuAuSeqPlayer[player_no].player) +#define nuAuSeqPlayerStop(player_no) \ + alCSPStop(&nuAuSeqPlayer[player_no].player) +#define nuAuSeqPlayerSetVol(player_no, vol) \ + alCSPSetVol(&nuAuSeqPlayer[player_no].player, vol) +#define nuAuSeqPlayerSetTempo(player_no, tempo) \ + alCSPSetTempo(&nuAuSeqPlayer[player_no].player, tempo) +#define nuAuSeqPlayerSetChlProgram(player_no, chan, prog) \ + alCSPSetChlProgram(&nuAuSeqPlayer[player_no].player, chan, prog) +#define nuAuSeqPlayerSetChlPriority(player_no, chan, priority) \ + alCSPSetChlPriority(&nuAuSeqPlayer[player_no].player, chan, priority) +#define nuAuSeqPlayerSetChlPan(player_no, chan, pan) \ + alCSPSetChlPan(&nuAuSeqPlayer[player_no].player, chan, pan) +#define nuAuSeqPlayerSetChlFXMix(player_no, chan, fxmix) \ + alCSPSetChlFXMix(&nuAuSeqPlayer[player_no].player, chan, fxmix) +#define nuAuSeqPlayerSetChlVol(player_no, chan, vol) \ + alCSPSetChlVol(&nuAuSeqPlayer[player_no].player, chan, vol) +#define nuAuSeqPlayerSendMidi(player_no, ticks, status, byte1, byte2) \ + alCSPSetPlayerSendMidi(&nuAuSeqPlayer[player_no].player, ticks, status, byte1, byte2) + +#define nuAuSndPlayerGetState() alSndpGetState(&nuAuSndPlayer) +#define nuAuSndPlayerPlayAt(delta) alSndpPlayAt(&nuAuSndPlayer,delta) +#define nuAuSndPlayerSetFXMix(mix) alSndpSetFXMix(&nuAuSndPlayer,mix) +#define nuAuSndPlayerSetPan(pan) alSndpSetPan(&nuAuSndPlayer,pan) +#define nuAuSndPlayerSetPitch(pitch) alSndpSetPitch(&nuAuSndPlayer,pitch) +#define nuAuSndPlayerSetPriority(id,priority) alSndpSetPriority(&nuAuSndPlayer,id,priority) +#define nuAuSndPlayerSetVol(vol) alSndpSetVol(&nuAuSndPlayer,vol) +#define nuAuSndPlayerStop() alSndpStop(&nuAuSndPlayer) +#define nuAuSndPlayerSetSound(SndId) alSndpSetSound(&nuAuSndPlayer,SndId) + + +/*----------------------------------------------------------------------*/ +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _NUALSGI_H_ */ diff --git a/include/nu/nusys.h b/include/nu/nusys.h index 6a3fe46df0..f7f43bd180 100644 --- a/include/nu/nusys.h +++ b/include/nu/nusys.h @@ -1,1099 +1,1099 @@ -/*======================================================================*/ -/* NuSYS */ -/* nusys.h */ -/* */ -/* Copyright (C) 1997, NINTENDO Co,Ltd. */ -/* */ -/*----------------------------------------------------------------------*/ -/* Ver 1.0 97/10/09 Created by Kensaku Ohki(SLANP) */ -/* Ver 1.2 98/07/12 Modified by Kensaku Ohki(SLANP) */ -/* Ver 2.0 90/01/23 Modified by Kensaku Ohki(SLANP) */ -/*----------------------------------------------------------------------*/ -/* $Id: nusys.h,v 1.26 1999/05/07 08:23:45 ohki Exp ohki $ */ -/*======================================================================*/ -#ifndef _NUSYS_H_ -#define _NUSYS_H_ - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -#ifndef F3DEX_GBI -#define F3DEX_GBI -#endif /* F3DEX_GBI */ - -#include -#include -#endif - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/* DEFINE */ -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -#define NU_VERSION "2.05" - -/*--------------------------------------*/ -/* NuSystem spec define */ -/*--------------------------------------*/ -#define NU_SPEC_BOOT_STACK_SIZE 0x2000 -#define NU_SPEC_BOOT_ADDR 0x80025c00 -#define NU_SPEC_BOOT_STACK nuMainStack + NU_SPEC_BOOT_STACK_SIZE - -/*--------------------------------------*/ -/* Thread ID for DEBUG (a precaution) */ -/*--------------------------------------*/ -#define NU_IDLE_THREAD_ID 1 -#define NU_RMON_THREAD_ID 2 /* no use */ -#define NU_MAIN_THREAD_ID 3 - - -/*--------------------------------------*/ -/* NuSYS Thread Priority */ -/*--------------------------------------*/ -#define NU_IDLE_THREAD_PRI OS_PRIORITY_IDLE /* Idle thread */ -#define NU_RMON_THREAD_PRI OS_PRIORITY_RMON /* no use */ -#define NU_MAIN_THREAD_PRI 10 /* main thread */ - -/*--------------------------------------*/ -/* NUSYS STACK SIZE */ -/*--------------------------------------*/ -#define NU_IDLE_STACK_SIZE 0x2000 /* Idle thread */ -#define NU_RMON_STACK_SIZE 0x2000 /* Rmon thread */ -#define NU_MAIN_STACK_SIZE NU_SPEC_BOOT_STACK_SIZE /* Main thread */ - - - - -/*----------------------------------------------------------------------*/ -/* SCHEDULER DEFINE */ -/*----------------------------------------------------------------------*/ -#define NU_SC_STACK_SIZE 0x2000 /* Thread stack size */ -#define NU_SC_NOSWAPBUFFER 0x0000 /* No swap */ -#define NU_SC_SWAPBUFFER 0x0001 /* Swap frame buffer */ -#define NU_SC_NORDP 0x0002 /* Do not wait for RDP finish */ -#define NU_SC_UCODE_XBUS 0x0004 /* XBUS Ucode */ -#define NU_SC_TASK_YIELDED (OS_TASK_YIELEDE<<16) -#define NU_SC_TASK_DP_WAIT (OS_TASK_DP_WAIT<<16) /* RDP WAIT */ -#define NU_SC_TASK_LODABLE (OS_TASK_LOADBLE<<16) /* LOADABLE */ -#define NU_SC_TASK_SP_ONLY (OS_TASK_SP_ONLY<<16) /* SP ONLY */ - - -#define NU_SC_RETRACE_MSG 0x0001 /* Retrace message */ -#define NU_SC_PRENMI_MSG 0x0002 /* NMI message */ -#define NU_SC_SWAPBUFFER_MSG 0x0004 /* Swap frame buffer message*/ -#define NU_SC_GTASKEND_MSG 0x0008 /* Task finished message */ -#define NU_SC_MAX_MESGS 8 /* Message buffer size */ - -#define NU_SC_HANDLER_PRI 120 /* EVENT HANDLER THREAD PRORITY */ -#define NU_SC_AUDIO_PRI 110 /* AUDIO DISPATCHER THREAD PRORITY */ -#define NU_SC_GRAPHICS_PRI 100 /* GFX DISPATCHER THREAD PRORITY */ -#define NU_SC_HANDLER_THREAD_ID 19 -#define NU_SC_AUDIO_THREAD_ID 18 -#define NU_SC_GRAPHICS_THREAD_ID 17 -#define NU_SC_PRENMI_YET 0 /* PRE NMI has not occurred. */ -#define NU_SC_PRENMI_GET 1 /* PRE NMI received flag */ -#define NU_SC_BEFORE_RESET 2 /* Pre-RESET flag for frame before reset */ -#define NU_SC_BEFORE_RESET_FRAME 2 /* Number of frames before reset where BEFORE_RESET flag is set. */ -/*----------------------------------------------------------------------*/ -/* GRAFIC THREAD DEFINE */ -/*----------------------------------------------------------------------*/ -#define NU_GFX_THREAD_ID 4 -#define NU_GFX_TASKMGR_THREAD_ID 5 -#define NU_GFX_STACK_SIZE 0x2000 /* Thread stack size */ -#define NU_GFX_MESGS 8 /* GFX message queue*/ -#define NU_GFX_TASKMGR_STACK_SIZE 0x2000 /* Stack size */ -#define NU_GFX_TASKMGR_MESGS 8 /*Task Manager queue*/ -#define NU_GFX_THREAD_PRI 50 /* GFX thread priority */ -#define NU_GFX_TASKMGR_THREAD_PRI 60 /* Task Manager priority */ - -/*----------------------------------------------------------------------*/ -/* GRAFIC MANEGER DEFINE */ -/*----------------------------------------------------------------------*/ -#ifdef F3DEX_GBI_2 -#define NU_GFX_UCODE_F3DEX2 0 /* F3DEX microcode */ -#define NU_GFX_UCODE_F3DEX2_NON 1 /* F3DEX.NoN microcode */ -#define NU_GFX_UCODE_F3DEX2_REJ 2 /* F3DEX.NoN microcode */ -#define NU_GFX_UCODE_F3DLX2_REJ 3 /* F3DEX.ReJ microcode */ -#define NU_GFX_UCODE_L3DEX2 4 /* L3DEX microcode */ -#define NU_GFX_UCODE_S2DEX2 5 /* S2DEX microcode */ - -#define NU_GFX_UCODE_F3DEX 0 /* For compatibility */ -#define NU_GFX_UCODE_F3DEX_NON 1 /* For compatibility */ -#define NU_GFX_UCODE_F3DLX 0 /* For compatibility */ -#define NU_GFX_UCODE_F3DLX_NON 1 /* For compatibility */ -#define NU_GFX_UCODE_F3DLX_REJ 4 /* For compatibility */ -#define NU_GFX_UCODE_F3DLP_REJ 3 /* For compatibility */ -#define NU_GFX_UCODE_L3DEX 4 /* For compatibility */ -#define NU_GFX_UCODE_S2DEX 5 /* For compatibility */ -#define NU_GFX_UCODE_S2DEX_D 5 /* For compatibility */ - -#else -#define NU_GFX_UCODE_F3DEX 0 /* F3DEX microcode */ -#define NU_GFX_UCODE_F3DEX_NON 1 /* F3DEX.NoN microcode */ -#define NU_GFX_UCODE_F3DLX 2 /* F3DLX microcode */ -#define NU_GFX_UCODE_F3DLX_NON 3 /* F3DLX.NoN microcode */ -#define NU_GFX_UCODE_F3DLX_REJ 4 /* F3DEX.ReJ microcode */ -#define NU_GFX_UCODE_F3DLP_REJ 5 /* F3DLP.Rej microcode */ -#define NU_GFX_UCODE_L3DEX 6 /* L3DEX microcode */ -#define NU_GFX_UCODE_S2DEX 7 /* S2DEX microcode */ -#define NU_GFX_UCODE_S2DEX_D 8 /* S2DEX microcode */ -#endif /* F3DEX_GBI_2 */ - - -/*----------------------------------------------*/ -/* The number of graphics task structures */ -/* should be set to a value at least as large as*/ -/* the Scheduler */ -/* message buffer size. */ -/* Otherwise, a task structure in use may */ -/* be used. */ -/*----------------------------------------------*/ -#define NU_GFX_TASK_NUM 10 /* Number of graphics task structures */ -#define NU_GFX_RDP_OUTPUTBUFF_SIZE 0x20000 /* fifo buffer size */ - -/*--------------------------------------*/ -/* Default frame buffer */ -/* The default frame buffer */ -/* is the 320x240 16-bit triple */ -/* xxbuffer in the high-order */ -/* area of RDRAM.xx */ -/*--------------------------------------*/ -#define NU_GFX_FRAMEBUFFER_NUM 3 -#define NU_GFX_FRAMEBUFFER_ADDR (0x80400000-320*240*2*3) -#define NU_GFX_FRAMEBUFFER0_ADDR (NU_GFX_FRAMEBUFFER_ADDR) -#define NU_GFX_FRAMEBUFFER1_ADDR (NU_GFX_FRAMEBUFFER0_ADDR+320*240*2) -#define NU_GFX_FRAMEBUFFER2_ADDR (NU_GFX_FRAMEBUFFER1_ADDR+320*240*2) - -#define NU_GFX_INIT_SCREEN_WD 320 -#define NU_GFX_INIT_SCREEN_HT 240 - -/*--------------------------------------*/ -/* Default Z -buffer is located in */ -/* xxlow-order memory.xx */ -/*--------------------------------------*/ -#define NU_GFX_ZBUFFER_ADDR 0x80000400 - -#define NU_GFX_DISPLAY_OFF 0 /* No display */ -#define NU_GFX_DISPLAY_ON 1 /* Display */ -#define NU_GFX_DISPLAY_ON_TRIGGER 0x80 /* Trigger */ - -#define NU_GFX_YIELD_BUF_SIZE (OS_YIELD_DATA_SIZE + 0x10) - -/*----------------------------------------------------------------------*/ -/* SI MANAGER DEFINE */ -/*----------------------------------------------------------------------*/ -#define NU_SI_STACK_SIZE NU_CONT_STACK_SIZE -#define NU_SI_THREAD_ID NU_CONT_THREAD_ID -#define NU_SI_THREAD_PRI NU_CONT_THREAD_PRI -#define NU_SI_MESG_MAX NU_CONT_MESG_MAX -#define NU_SI_CALLBACK_END 1 -#define NU_SI_CALLBACK_CONTINUE 0 -#define NU_SI_SC_MAJOR_NO 0x0000 -#define NU_SI_MSG_MAJOR_NO_MASK 0xff00 -#define NU_SI_MSG_MINOR_NO_MASK 0x00ff - -#define NU_SI_MAJOR_NO_CONT 0x0100 -#define NU_SI_MAJOR_NO_PAK 0x0200 -#define NU_SI_MAJOR_NO_RMB 0x0300 -#define NU_SI_MAJOR_NO_EEPROM 0x0400 -#define NU_SI_MAJOR_NO_GBPAK 0x0500 -#define NU_SI_MAJOR_NO_VRS 0x0600 -#define NU_SI_STOP_MGR_MSG 0x7F00 - -/*----------------------------------------------------------------------*/ -/* CONTROLLER MANEGER DEFINE */ -/*----------------------------------------------------------------------*/ -#define NU_CONT_MAXCONTROLLERS MAXCONTROLLERS -#define NU_CONT_STACK_SIZE 0x2000 -#define NU_CONT_MESG_MAX 8 -#define NU_CONT_THREAD_ID 6 -#define NU_CONT_THREAD_PRI 115 -#define NU_CONT_DATA_UNLOCK 0 -#define NU_CONT_DATA_LOCK 1 - - -/*----------------------------------------------------------------------*/ -/* Define messages sent to the Controller Manager */ -/*----------------------------------------------------------------------*/ -#define NU_CONT_MSG_BASE NU_SI_MAJOR_NO_CONT -#define NU_CONT_RETRACE_MSG (NU_CONT_MSG_BASE+0) -#define NU_CONT_READ_MSG (NU_CONT_MSG_BASE+1) -#define NU_CONT_READ_NW_MSG (NU_CONT_MSG_BASE+2) -#define NU_CONT_QUERY_MSG (NU_CONT_MSG_BASE+3) - - -#define NU_CONT_PAK_MSG_BASE NU_SI_MAJOR_NO_PAK -#define NU_CONT_PAK_RETRACE_MSG (NU_CONT_PAK_MSG_BASE+0) -#define NU_CONT_PAK_OPEN_MSG (NU_CONT_PAK_MSG_BASE+1) -#define NU_CONT_PAK_FREE_MSG (NU_CONT_PAK_MSG_BASE+2) -#define NU_CONT_PAK_FOPEN_MSG (NU_CONT_PAK_MSG_BASE+3) -#define NU_CONT_PAK_READWRITE_MSG (NU_CONT_PAK_MSG_BASE+4) -#define NU_CONT_PAK_FILEDELETE_MSG (NU_CONT_PAK_MSG_BASE+5) -#define NU_CONT_PAK_FILESTATE_MSG (NU_CONT_PAK_MSG_BASE+6) -#define NU_CONT_PAK_FILENUM_MSG (NU_CONT_PAK_MSG_BASE+7) -#define NU_CONT_PAK_REPAIRID_MSG (NU_CONT_PAK_MSG_BASE+8) - -#define NU_CONT_PAK_MODE_NOCREATE 0 -#define NU_CONT_PAK_MODE_CREATE 1 -#define NU_CONT_PAK_TYPE_NONE 0 -#define NU_CONT_PAK_TYPE_PAK 1 /* Controller Pak */ -#define NU_CONT_PAK_TYPE_RUMBLE 2 /* Rumble Pak */ -#define NU_CONT_PAK_TYPE_GBPAK 3 /* 64GB Pak */ -#define NU_CONT_PAK_READ PFS_READ -#define NU_CONT_PAK_WRITE PFS_WRITE - -/*----------------------------------------------------------------------*/ -/* Rumble Pak control */ -/*----------------------------------------------------------------------*/ -#define NU_CONT_RMB_STATE_STOP 0x00 -#define NU_CONT_RMB_STATE_STOPPING 0x01 -#define NU_CONT_RMB_STATE_STOPPED 0x02 -#define NU_CONT_RMB_STATE_RUN 0x03 -#define NU_CONT_RMB_STATE_FORCESTOP 0x04 -#define NU_CONT_RMB_MODE_DISABLE 0x00 -#define NU_CONT_RMB_MODE_ENABLE 0x01 -#define NU_CONT_RMB_MODE_AUTORUN 0x02 -#define NU_CONT_RMB_MODE_PAUSE 0x80 -#define NU_CONT_RMB_AUTO_SEARCH 0x00 -#define NU_CONT_RMB_AUTO_FIND 0x01 -#define NU_CONT_RMB_AUTO_SEARCHTIME (60*5) -#define NU_CONT_RMB_MSG_BASE NU_SI_MAJOR_NO_RMB -#define NU_CONT_RMB_RETRACE_MSG (NU_CONT_RMB_MSG_BASE+0) -#define NU_CONT_RMB_CHECK_MSG (NU_CONT_RMB_MSG_BASE+1) -#define NU_CONT_RMB_START_MSG (NU_CONT_RMB_MSG_BASE+2) -#define NU_CONT_RMB_STOP_MSG (NU_CONT_RMB_MSG_BASE+3) -#define NU_CONT_RMB_FORCESTOP_MSG (NU_CONT_RMB_MSG_BASE+4) -#define NU_CONT_RMB_FORCESTOPEND_MSG (NU_CONT_RMB_MSG_BASE+5) - -/*----------------------------------------------------------------------*/ -/* EEPROM */ -/*----------------------------------------------------------------------*/ -#define NU_EEPROM_MSG_BASE NU_SI_MAJOR_NO_EEPROM -#define NU_EEPROM_RETRACE_MSG (NU_EEPROM_MSG_BASE+0) -#define NU_EEPROM_CHECK_MSG (NU_EEPROM_MSG_BASE+1) -#define NU_EEPROM_READ_MSG (NU_EEPROM_MSG_BASE+2) -#define NU_EEPROM_WRITE_MSG (NU_EEPROM_MSG_BASE+3) - - -/*----------------------------------------------------------------------*/ -/* 64GB Pack Manager */ -/*----------------------------------------------------------------------*/ -#define NU_CONT_GBPAK_MSG_BASE NU_SI_MAJOR_NO_GBPAK -#define NU_CONT_GBPAK_RETRACE_MSG (NU_CONT_GBPAK_MSG_BASE+0) -#define NU_CONT_GBPAK_OPEN_MSG (NU_CONT_GBPAK_MSG_BASE+1) -#define NU_CONT_GBPAK_STATUS_MSG (NU_CONT_GBPAK_MSG_BASE+2) -#define NU_CONT_GBPAK_POWER_MSG (NU_CONT_GBPAK_MSG_BASE+3) -#define NU_CONT_GBPAK_READID_MSG (NU_CONT_GBPAK_MSG_BASE+4) -#define NU_CONT_GBPAK_READWRITE_MSG (NU_CONT_GBPAK_MSG_BASE+5) -#define NU_CONT_GBPAK_CHECKCONNECTOR_MSG (NU_CONT_GBPAK_MSG_BASE+6) - -#define NU_CONT_GBPAK_POWER_OFF OS_GBPAK_POWER_OFF -#define NU_CONT_GBPAK_POWER_ON OS_GBPAK_POWER_ON -#define NU_CONT_GBPAK_MBC_RAM_ENABLE_CODE 0x0a -#define NU_CONT_GBPAK_MBC_RAM_DISABLE_CODE 0x00 -#define NU_CONT_GBPAK_MBC_RAM_REG0_ADDR 0x0000 - -#define NU_CONT_GBPAK_MBC_REG0_ADDR 0x0000 /* Register 0 */ -#define NU_CONT_GBPAK_MBC_REG1_ADDR 0x2100 /* Register 1 */ -#define NU_CONT_GBPAK_MBC_REG2_ADDR 0x4000 /* Register 2 */ -#define NU_CONT_GBPAK_MBC_REG3_ADDR 0x6000 /* Register 3 */ - -/*----------------------------------------------------------------------*/ -/* Voice Recognition System Manager */ -/*----------------------------------------------------------------------*/ -#define NU_VRS_MSG_BASE NU_SI_MAJOR_NO_VRS -#define NU_VRS_RETRACE_MSG (NU_VRS_MSG_BASE+0) -#define NU_VRS_OPEN_MSG (NU_VRS_MSG_BASE+1) -#define NU_VRS_CLEAR_DICTIONARY_MSG (NU_VRS_MSG_BASE+2) -#define NU_VRS_SET_WORD_MSG (NU_VRS_MSG_BASE+3) -#define NU_VRS_MASK_DICTIONARY_MSG (NU_VRS_MSG_BASE+4) -#define NU_VRS_START_READ_DATA_MSG (NU_VRS_MSG_BASE+5) -#define NU_VRS_GET_READ_DATA_MSG (NU_VRS_MSG_BASE+6) -#define NU_VRS_STOP_READ_DATA_MSG (NU_VRS_MSG_BASE+7) -#define NU_VRS_CONTROL_GAIN_MSG (NU_VRS_MSG_BASE+8) - -/*----------------------------------------------------------------------*/ -/* PI DEFINE */ -/*----------------------------------------------------------------------*/ -#define NU_PI_MESG_NUM 50 /* PI message buffer size */ -#define NU_PI_CART_BLOCK_READ_SIZE 0x4000 /* cart read block size */ - -/*----------------------------------------------------------------------*/ -/* DEBUG */ -/*----------------------------------------------------------------------*/ -#define NU_DEB_PERF_BUF_NUM 3 -#define NU_DEB_PERF_GFXTASK_CNT 8 /* Graphics task count */ -#define NU_DEB_PERF_AUTASK_CNT 4 /* Audio task count */ -#define NU_DEB_PERF_RUNNING 0 /* Sampling */ -#define NU_DEB_PERF_STOP 1 /* Stop sampling */ -#define NU_DEB_PERF_START 2 /* Start sampling */ -#define NU_DEB_DP_CLOCK_CTR 0 /* RDP internal counter */ -#define NU_DEB_DP_CMD_CTR 1 /* CMD counter */ -#define NU_DEB_DP_PIPE_CTR 2 /* PIPE counter */ -#define NU_DEB_DP_TMEM_CTR 3 /* TMEM counter */ -#define NU_DEB_BAR_FRAME1 0 /* For the performance bar */ -#define NU_DEB_BAR_FRAME2 1 /* Maximum number displayed */ -#define NU_DEB_BAR_FRAME3 2 -#define NU_DEB_BAR_FRAME4 3 -#define NU_DEB_BAR_FRAME5 4 -#define NU_DEB_BAR_FRAME6 5 -#define NU_DEB_BAR_FRAME7 6 -#define NU_DEB_CON_ROW_MAX 40 /* Number of rows in console */ -#define NU_DEB_CON_COLUMN_MAX 30 /* Number of columns in console */ -#define NU_DEB_CON_TEXT_SIZE (NU_DEB_CON_ROW_MAX*NU_DEB_CON_COLUMN_MAX) -#define NU_DEB_CON_WIDTH 320 -#define NU_DEB_CON_WINDOW_NUM 4 -#define NU_DEB_CON_WINDOW0 0 -#define NU_DEB_CON_WINDOW1 1 -#define NU_DEB_CON_WINDOW2 2 -#define NU_DEB_CON_WINDOW3 3 -#define NU_DEB_CON_TEXT_BLACK 0 /* Black */ -#define NU_DEB_CON_TEXT_BLUE 1 /* Blue */ -#define NU_DEB_CON_TEXT_GREEN 2 /* Green */ -#define NU_DEB_CON_TEXT_CYAN 3 /* Cyan */ -#define NU_DEB_CON_TEXT_RED 4 /* Red */ -#define NU_DEB_CON_TEXT_MAGENTA 5 /* Magenta */ -#define NU_DEB_CON_TEXT_YELLOW 6 /* yellow */ -#define NU_DEB_CON_TEXT_WHITE 7 /* White */ -#define NU_DEB_CON_TEXT_LIGHTBLACK 8 /* Gray */ -#define NU_DEB_CON_TEXT_LIGHTBLUE 9 /* Bright Blue */ -#define NU_DEB_CON_TEXT_LIGTHBLUE 9 /* Bright Blue (misspelled) */ -#define NU_DEB_CON_TEXT_LIGHTGREEN 10 /* Bright Green */ -#define NU_DEB_CON_TEXT_LIGHTCYAN 11 /* Bright Cyan */ -#define NU_DEB_CON_TEXT_LIGHTRED 12 /* Bright Red */ -#define NU_DEB_CON_TEXT_LIGHTMAGENTA 13 /* Bright Magenta */ -#define NU_DEB_CON_TEXT_LIGHTYELLOW 14 /* Bright yellow */ -#define NU_DEB_CON_TEXT_LIGHTWHITE 15 /* White */ -#define NU_DEB_CON_ATTR_NORMAL 0x0 /* No attribute*/ -#define NU_DEB_CON_ATTR_BLINK 0x1 /* Blinking */ -#define NU_DEB_CON_ATTR_REVERSE 0x2 /* Highlight */ -#define NU_DEB_CON_SCROLL_ON 1 -#define NU_DEB_CON_SCROLL_OFF 0 -#define NU_DEB_CON_WINDOW_OFF 0 -#define NU_DEB_CON_WINDOW_ON 1 - -#define NU_DEB_MARKER_NUM 10 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/* structer define */ -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/*--------------------------------------*/ -/* Scheduler sturcter */ -/*--------------------------------------*/ -typedef short NUScMsg; /* Scheduler message type */ - -typedef struct st_SCClient { /* Client list structure */ - struct st_SCClient* next; /* Pointer to next client */ - OSMesgQueue* msgQ; /* Message sent to client */ - NUScMsg msgType; /* Type of message */ - /* NU_SC_RETRACE_MSG or*/ - /* NU_SC_PRENMI_MSG */ -} NUScClient; - -typedef struct st_SCTask { /* Task structure */ - struct st_SCTask *next; - u32 state; - u32 flags; - void *framebuffer; /* For graphics tasks */ - OSTask list; - OSMesgQueue *msgQ; - OSMesg msg; -} NUScTask; - -typedef struct st_Sched { /* Define the Scheduler structure. */ - - /* message */ - NUScMsg retraceMsg; - NUScMsg prenmiMsg; - - /* Define the Task request queue. */ - OSMesgQueue audioRequestMQ; - OSMesg audioRequestBuf[NU_SC_MAX_MESGS]; - OSMesgQueue graphicsRequestMQ; - OSMesg graphicsRequestBuf[NU_SC_MAX_MESGS]; - - /* Define the message queue. */ - OSMesgQueue retraceMQ; - OSMesg retraceMsgBuf[NU_SC_MAX_MESGS]; - OSMesgQueue rspMQ; - OSMesg rspMsgBuf[NU_SC_MAX_MESGS]; - OSMesgQueue rdpMQ; - OSMesg rdpMsgBuf[NU_SC_MAX_MESGS]; - - /* Implement wait for next retrace. */ - OSMesgQueue waitMQ; - OSMesg waitMsgBuf[NU_SC_MAX_MESGS]; - - /* Define threads.*/ - OSThread schedulerThread; /* Main thread */ - OSThread audioThread; /* Audio */ - OSThread graphicsThread; /* Graphics */ - - /* client list */ - NUScClient *clientList; - - /* The graphics task being executed. */ - NUScTask *curGraphicsTask; - NUScTask *curAudioTask; - NUScTask *graphicsTaskSuspended; - - u32 retraceCount; - u8 frameRate; - u8 frameBufferNum; /* Number of frame buffers */ - - -} NUSched; - - -/*--------------------------------------*/ -/* ucode structure */ -/*--------------------------------------*/ -typedef struct st_Ucode { - u64* ucode; - u64* ucode_data; -} NUUcode; - -/*--------------------------------------*/ -/* CALL BACK Function typedef */ -/*--------------------------------------*/ -typedef void (*NUIdleFunc)(void); /* Pointer to the idle callback function */ -typedef void (*NUScPreNMIFunc)(void); /* Pointer to PRENMI callback function */ -typedef void (*NUGfxFunc)(u32); /* Pointer to the GFX retrace callback function */ -typedef void (*NUGfxPreNMIFunc)(void); /* Pointer to the GFX PRENMI callback function */ - -typedef void (*NUGfxSwapCfbFunc)(void*);/* Pointer to the SWAPBUF callback function */ -typedef void (*NUGfxTaskEndFunc)(void*);/* Pointer to the TASKEND callback function */ -typedef void (*NUContReadFunc)(u32); /* Pointer to the Controller end-read */ - /* callback function */ -typedef void (*NUContPakFunc)(void*); /* Controller Pak control function callback */ -typedef void (*NUContRmbFunc)(void*); /* Rumble Pak control function callback */ -typedef s32 (*NUCallBackFunc)(void*); /* Callback function */ - - -/*--------------------------------------*/ -/* PI Common Message */ -/*--------------------------------------*/ -typedef struct st_PiOverlaySegment { - u8* romStart; /* Segment's ROM start offset */ - u8* romEnd; /* Segment's ROM end offset */ - u8* ramStart; /* Segment's CPU start address */ - u8* textStart; /* test attribute's DRAM start address */ - u8* textEnd; /* test attribute's DRAM end address */ - u8* dataStart; /* data attribute's DRAM start address */ - u8* dataEnd; /* data attribute's DRAM end address */ - u8* bssStart; /* bss attribute's DRAM start address */ - u8* bssEnd; /* bss attribute's DRAM start address */ -} NUPiOverlaySegment; - -/*--------------------------------------*/ -/* SI Common message */ -/*--------------------------------------*/ -typedef struct st_SiCommonMesg { - NUScMsg mesg; - OSMesgQueue* rtnMesgQ; - s32 error; - void* dataPtr; -} NUSiCommonMesg; - -/*--------------------------------------*/ -/* controller typedef */ -/*--------------------------------------*/ -typedef struct st_ContRead { - NUScMsg mesg; /* Type of message */ - OSMesgQueue* rtnMesgQ; - OSContPad* pad; -} NUContReadMesg; - -typedef struct st_ContData { - u16 button; /* A,B,C,Z,L,R,START,PAD ,button */ - s8 stick_x; /* Range acutally used: -61 <= stick X <= 61 */ - s8 stick_y; /* Range actually used: -63 <= stick Y <= 63 */ - u8 errno; /* Error */ - u16 trigger; /* Button trigger data */ -} NUContData; - -typedef struct st_ContQuery { - NUScMsg mesg; - OSMesgQueue* rtnMesgQ; -} NUContQueryMesg; - - -typedef struct st_ContPakFile { - OSPfs *pfs; - s32 file_no; - s32 error; - u32 type; -} NUContPakFile; - - -typedef struct st_ContPakFreeMesg { - NUContPakFile* file; - s32 size; -} NUContPakFreeMesg; - -typedef struct st_ContPakFileOpenMesg { - NUContPakFile* file; - u8* noteName; - u8* extName; - s32 size; - s32 mode; -} NUContPakFileOpenMesg; - -typedef struct st_ContPakFileRWMesg { - NUContPakFile* file; - s32 offset; - s32 size; - u8 mode; - u8* buf; -} NUContPakFileRWMesg; - -typedef struct st_ContPakFileStateMesg { - NUContPakFile* file; - OSPfsState* state; -} NUContPakFileStateMesg; - -typedef struct st_ContPakFileNumMesg { - NUContPakFile* file; - s32* max_files; - s32* used_files; -} NUContPakFileNumMesg; - -typedef struct st_ContPakIsPlugMesg { - NUScMsg mesg; - OSMesgQueue* rtnMesgQ; - s32 error; - u8 bitPattern; -} NUContPakIsPlugMesg; - -typedef struct st_ContRmbCtl { - u16 freq; /* Vibration frequency */ - u16 frame; - u16 counter; - u8 state; - u8 mode; - u8 autorun; - u8 type; -} NUContRmbCtl; - -typedef struct st_ContRmbMesg { - u8 contNo; - s32 error; - void* data; -} NUContRmbMesg; - -typedef struct st_CallBackList { - struct st_CallBackList* next; - s32 (**func)(NUSiCommonMesg*); - u16 majorNo; - u8 funcNum; -} NUCallBackList; - -typedef struct st_EepromMesg { - void* dataPtr; - s32 error; - u8 address; - u16 dataLen; -} NUEepromMesg; - -typedef struct st_ContGBPakMesg { - NUContPakFile* handle; - s32 data[4]; -} NUContGBPakMesg; - -typedef OSVoiceHandle NUVrsHandle; - -typedef OSVoiceData NUVrsData; - -typedef struct stVrsMesg { - NUVrsHandle* vrsHandle; - s32 data[2]; -} NUVrsMesg; - -/*--------------------------------------*/ -/* Debug */ -/*--------------------------------------*/ -typedef struct st_GfxTaskTime { - s64 rspStart; /* RSPTask start time */ - s64 rspEnd; /* RSPTask end time */ - s64 rdpEnd; /* RDP end time */ - u32 dpCnt[4]; /* RDP internal counter */ -} NUDebTaskTime; - -typedef struct st_DebTaskPerf { - s64 retraceTime; /* retrace event time*/ - s64 markerTime[NU_DEB_MARKER_NUM]; - u8 gfxTaskCnt; /* Number of graphics tasks */ - u8 auTaskCnt; /* Number of audio tasks */ - u8 gfxTaskStart; - NUDebTaskTime gfxTaskTime[NU_DEB_PERF_GFXTASK_CNT]; - NUDebTaskTime auTaskTime[NU_DEB_PERF_AUTASK_CNT]; -} NUDebTaskPerf; - -/* Console window structure */ -typedef struct st_DebConWindow { - u8 windowFlag; /* On/off flag for console window display */ - u16 scroll; /* Scroll value */ - u8 scrollFlag; /* Scrolling enabled/disabled */ - u8 textColor; /* Character color */ - u8 attribute; /* Attribute */ - u16 posX; /* Column position for write */ - u16 posY; /* Line position for write */ - u16 index; /* Position for character buffer write */ - u16 winX; /* x-coordinate of console window display */ - u16 winY; /* y-coordinate of console window display */ - u16 winW; /* Number of columns in console display */ - u16 winH; /* Number of rows in console display */ - u16 text[NU_DEB_CON_TEXT_SIZE]; /* Character buffer*/ -} NUDebConWindow; - -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/* extern variables */ -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ - -extern u8 nuRDPOutputBuf[]; -extern u8 nuDramStack[]; -extern u8 nuYieldBuf[]; -extern NUSched nusched; /* Scheduler structure */ -extern OSMesgQueue nuGfxMesgQ; /* Graphics thread queue */ -extern u32 nuScRetraceCounter; /* Retrace counter */ -extern u8 nuScPreNMIFlag; -/*--------------------------------------*/ -/* graphics variables */ -/*--------------------------------------*/ -extern NUUcode* nuGfxUcode; /* Pointer to GFX microcode structure */ -extern u16** nuGfxCfb; /* Pointer to array of pointers to frame buffers */ -extern u16* nuGfxCfb_ptr; /* Pointer to to frame buffer */ -extern u32 nuGfxCfbNum; /* Number of frame buffers */ -extern u16* nuGfxZBuffer; /* Pointer to the Z buffer */ -extern volatile u32 nuGfxTaskSpool; /* Number of tasks in queue */ -extern u32 nuGfxDisplay; /* Display on/off flag */ -extern u32 nuGfxCfbCounter; /* For frame buffer swapping */ -extern OSMesgQueue nuGfxMesgQ; -extern OSThread nuGfxThread; /* graphic thread */ - -/*--------------------------------------*/ -/* controller Manager variables */ -/*--------------------------------------*/ -extern OSContStatus nuContStatus[]; -extern OSContPad nuContData[]; -extern u32 nuContNum; /* Number of controllers connected */ -extern u32 nuContDataLockKey; /* Lock Controller data. */ -extern OSMesgQueue nuContWaitMesgQ; /* Wait for Controller read */ -extern OSPfs nuContPfs[]; -extern NUCallBackList nuContCallBack; -extern u16 nuContPakCompanyCode; /* Company code */ -extern u32 nuContPakGameCode; /* Game code */ -extern NUCallBackList nuContPakCallBack; - -/*--------------------------------------*/ -/* RUMBUL Manager variables */ -/*--------------------------------------*/ -extern NUContRmbCtl nuContRmbCtl[]; -extern u32 nuContRmbSearchTime; -extern NUCallBackList nuContRmbCallBack; - - -/*--------------------------------------*/ -/* EEPROM Manager variables */ -/*--------------------------------------*/ -extern NUCallBackList nuEepromCallBack; - -/*--------------------------------------*/ -/* 64GBPack Manager variables */ -/*--------------------------------------*/ -extern NUCallBackList nuContGBPakCallBack; - -/*--------------------------------------*/ -/* VRS Manager variables */ -/*--------------------------------------*/ -extern NUCallBackList nuVrsCallBack; - -/*--------------------------------------*/ -/* si variables */ -/*--------------------------------------*/ -extern OSMesgQueue nuSiMesgQ; /* SI event message queue */ -extern OSMesgQueue nuSiMgrMesgQ; /* SI Manager queue */ -extern NUCallBackList* nuSiCallBackList;/* Callback function list */ - -/*--------------------------------------*/ -/* pi variables */ -/*--------------------------------------*/ -extern OSPiHandle* nuPiCartHandle; -extern OSPiHandle* nuPiSramHandle; -extern OSPiHandle* nuPiDDRomHandle; - -/*--------------------------------------*/ -/* CALL BACK Function pointer */ -/*--------------------------------------*/ -extern NUIdleFunc nuIdleFunc; /* callback func pointer */ -extern NUScPreNMIFunc nuScPreNMIFunc; /* PRE NMI callback pointer */ -extern NUGfxSwapCfbFunc nuGfxSwapCfbFunc; /* swapbuf callback pointer */ -extern NUGfxFunc nuGfxFunc; /* callback pointer */ -extern NUGfxPreNMIFunc nuGfxPreNMIFunc; /* Callback pointer */ -extern NUGfxTaskEndFunc nuGfxTaskEndFunc; /* task end callback ptr */ -extern NUContReadFunc nuContReadFunc; /* When controller read ends */ - /* Callback function */ -/*--------------------------------------*/ -/* Debug */ -/*--------------------------------------*/ - -extern NUDebTaskPerf* nuDebTaskPerfPtr; -extern NUDebConWindow nuDebConWin[]; -extern NUDebTaskPerf nuDebTaskPerf[]; -extern u32 nuDebTaskPerfInterval; -extern volatile u32 nuDebTaskPerfCnt; -extern volatile u32 nuDebTaskPerfEnd; - - -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/* Global Function */ -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/*--------------------------------------*/ -/* Boot function */ -/*--------------------------------------*/ -extern void nuIdleFuncSet(void (*func)(void)); -extern void nuPreNMIFuncSet(NUScPreNMIFunc func); -/*--------------------------------------*/ -/* Scheduler function */ -/*--------------------------------------*/ -extern void nuScCreateScheduler(u8 videoMode, u8 numFields); -extern void nuScAddClient(NUScClient *c, OSMesgQueue *mq, NUScMsg msgType); -extern void nuScRemoveClient(NUScClient *client); -extern void nuScResetClientMesgType(NUScClient* client, NUScMsg msgType); -extern OSMesgQueue* nuScGetGfxMQ(void); -extern OSMesgQueue* nuScGetAudioMQ(void); -extern void nuScSetFrameBufferNum(u8 frameBufferNum); -extern s32 nuScGetFrameRate(void); - -/*--------------------------------------*/ -/* graphic(GFX) Manager function */ -/*--------------------------------------*/ -extern void nuGfxInit(void); -extern void nuGfxInitEX2(void); -extern void nuGfxThreadStart(void); -extern void nuGfxTaskMgrInit(void); -extern void nuGfxTaskStart(Gfx *gfxList_ptr, u32 gfxListSize, u32 ucode, u32 flag); -extern void nuGfxFuncSet(NUGfxFunc func); -extern void nuGfxPreNMIFuncSet(NUGfxPreNMIFunc func); -extern void nuGfxSwapCfbFuncSet(NUGfxSwapCfbFunc func); -extern void nuGfxSetCfb(u16** framebuf, u32 framebufnum); -extern void nuGfxSwapCfb(void* framebuffer); - -extern void nuGfxTaskEndFuncSet(NUGfxTaskEndFunc func); -extern void nuGfxTaskAllEndWait(void); -extern void nuGfxRetraceWait(u32 retrace_num); -extern void nuGfxDisplayOff(void); -extern void nuGfxDisplayOn(void); - -#ifdef F3DEX_GBI_2 -#define nuGfxInit() nuGfxInitEX2() -#endif /* F3DEX_GBI_2 */ -/*--------------------------------------*/ -/* controller Manager function */ -/*--------------------------------------*/ -extern u8 nuContInit(void); -extern s32 nuContMgr(void* mesg); -extern u8 nuContMgrInit(void); -extern void nuContMgrRemove(void); -extern void nuContDataLock(void); -extern void nuContDataUnLock(void); -extern void nuContDataRead(OSContPad* pad); -extern void nuContDataReadWait(void); -extern void nuContDataReadStart(void); -extern void nuContDataGet(OSContPad* contdata, u32 padno); -extern void nuContDataGetAll(OSContPad* contdata); -extern void nuContDataGetEx(NUContData *contdata, u32 padno); -extern void nuContDataGetExAll(NUContData *contdata); -extern void nuContReadFuncSet(NUContReadFunc func); -extern void nuContQueryRead(void); -extern void nuContDataClose(void); -extern void nuContDataOpen(void); - -/*--------------------------------------*/ -/* controller pak function */ -/*--------------------------------------*/ -extern s32 nuContPakMgr(void* mesg_type); -extern void nuContPakMgrInit(void); -extern void nuContPakMgrRemove(void); -extern void nuContPakJisToN64(u8* src, u8* dest, u32 len); -extern void nuContPakN64ToJis(u8* src, u8* dest, u32 len); -extern s32 nuContPakOpen(NUContPakFile *file, u32 contNo); -extern s32 nuContPakGetFree(NUContPakFile *file); -extern void nuContPakCodeSet(u8* companyCode, u8* gameCode); -extern s32 nuContPakRepairId(NUContPakFile *file); -extern s32 nuContPakFileOpen(NUContPakFile *file, - u8* noteName,u8* extName, u32 mode, s32 size); -extern s32 nuContPakFileOpenJis(NUContPakFile *file, - u8* noteName,u8* extName, u32 mode, s32 size); -extern s32 nuContPakFileReadWrite(NUContPakFile *file, - s32 offset, s32 size,u8* buf, u32 mode); -extern s32 nuContPakFileDelete(NUContPakFile *file, u8* noteName, u8* extName); -extern s32 nuContPakFileDeleteJis(NUContPakFile *file, u8* noteName, u8* extName); -extern s32 nuContPakFileState(NUContPakFile *file, OSPfsState* state); -extern s32 nuContPakFileNum(NUContPakFile *file, - s32 *max_files, s32 *used_files); -extern s32 nuContPakFileFread(NUContPakFile *file, s32 offset, s32 size, u8* buf); - -/*--------------------------------------*/ -/* rumbler pak functions */ -/*--------------------------------------*/ -extern void nuContRmbMgrInit(void); -extern s32 nuContRmbMgr(void* mesg); -extern void nuContRmbMgrRemove(void); -extern void nuContRmbStart(u32 contNo, u16 freq, u16 frame); -extern void nuContRmbStop(u32 contNo); -extern s32 nuContRmbCheck(u32 contNo); -extern void nuContRmbModeSet(u32 contNo, u8 mode); -extern void nuContRmbForceStop(void); -extern void nuContRmbForceStopEnd(void); -extern void nuContRmbSearchTimeSet(u32 frame); - -/*--------------------------------------*/ -/* 64GB Pack functions */ -/*--------------------------------------*/ -extern s32 nuContGBPakMgr(void* mesg); -extern void nuContGBPakMgrInit(void); -extern void nuContGBPakMgrRemove(void); -extern s32 nuContGBPakOpen(NUContPakFile* handle, s32 contNo); -extern s32 nuContGBPakGetStatus(NUContPakFile* handle, u8* status); -extern s32 nuContGBPakReadID(NUContPakFile* handle, OSGbpakId* id, u8* status); -extern s32 nuContGBPakReadWrite(NUContPakFile* handle, u16 flag , u16 address, u8* buffer, u16 size); -extern s32 nuContGBPakPower(NUContPakFile* handle, s32 flag); -extern s32 nuContGBPakCheckConnector(NUContPakFile* handle, u8* status); -extern s32 nuContGBPakFread(NUContPakFile* handle, u16 address, u8* buffer, u16 size); - -extern s32 nuContGBPakFwrite(NUContPakFile* handle, u16 address, u8* buffer, u16 size); -extern s32 nuContGBPakRegWrite(NUContPakFile* handle, u16 addr, u8 data); - -/*--------------------------------------*/ -/* eeprom functions */ -/*--------------------------------------*/ -extern void nuEepromMgrInit(void); -extern s32 nuEepromMgr(void* mesg); -extern s32 nuEepromCheck(void); -extern void nuEepromMgrRemove(void); -extern s32 nuEepromRead(u8 address, u8* buffer,u16 len); -extern s32 nuEepromWrite(u8 address, u8* buffer,u16 len); - - -/*--------------------------------------*/ -/* pi functions */ -/*--------------------------------------*/ -extern void nuPiInit(void); -extern void nuPiReadRom(u32 rom_addr, void* buf_ptr, u32 size); -extern void nuPiInitSram(void); -extern void nuPiInitDDrom(void); -extern void nuPiReadWriteSram(u32 addr, void* buf_ptr, u32 size, s32 flag); -extern void nuPiReadRomOverlay(NUPiOverlaySegment* segment); - -/*--------------------------------------*/ -/* si functions */ -/*--------------------------------------*/ -extern u8 nuSiMgrInit(void); -extern void nuSiCallBackAdd(NUCallBackList* list); -extern void nuSiCallBackRemove(NUCallBackList* list); -extern s32 nuSiSendMesg(NUScMsg mesg, void* dataPtr); -extern void nuSiSendMesgNW(NUScMsg mesg, void* dataPtr); -extern void nuSiMgrStop(void); -extern void nuSiMgrRestart(void); -/*--------------------------------------*/ -/* si functions */ -/*--------------------------------------*/ -extern s32 nuVrsMgr(void *mesg); -extern void nuVrsMgrInit(void); -extern s32 nuVrsOpen(NUVrsHandle* handle, s32 contNo); -extern s32 nuVrsClearDictionary(NUVrsHandle* handle, u8 words); -extern s32 nuVrsSetWord(NUVrsHandle* handle, u8* word); -extern s32 nuVrsStartReadData(NUVrsHandle* handle); -extern s32 nuVrsGetReadData(NUVrsHandle* handle, NUVrsData* data); -extern s32 nuVrsStopReadData(NUVrsHandle* handle); -extern s32 nuVrsControlGain(NUVrsHandle* handle, s32 analog, s32 digital); -extern s32 nuVrsMaskDictionary(NUVrsHandle* handle, u8* maskpattern, s32 size); - -/*--------------------------------------*/ -/* dubug functions */ -/*--------------------------------------*/ -#ifdef NDEBUG -#define nuDebTaskPerfBar0(EX0 ,EX1 ,EX2) ((void)0) -#define nuDebTaskPerfBar1(EX0 ,EX1 ,EX2) ((void)0) -#define nuDebTaskPerfBar0EX2(EX0 ,EX1 ,EX2) ((void)0) -#define nuDebTaskPerfBar1EX2(EX0 ,EX1 ,EX2) ((void)0) -#define nuDebPerfMarkSet(EX0) ((void)0) -#define nuDebTaskPerfIntervalSet(EX0) ((void)0) -#else -extern void nuDebTaskPerfBar0(u32 frameNum, u32 y, u32 flag); -extern void nuDebTaskPerfBar1(u32 frameNum, u32 y, u32 flag); -extern void nuDebTaskPerfBar0EX2(u32 frameNum, u32 y, u32 flag); -extern void nuDebTaskPerfBar1EX2(u32 frameNum, u32 y, u32 flag); -extern u32 nuDebPerfMarkSet(s32 markNo); -extern void nuDebTaskPerfIntervalSet(u32 interval); -#ifdef F3DEX_GBI_2 -#define nuDebTaskPerfBar0(a, b, c) nuDebTaskPerfBar0EX2(a, b, c) -#define nuDebTaskPerfBar1(a, b, c) nuDebTaskPerfBar1EX2(a, b, c) -#endif /* F3DEX_GBI_2 */ - -#endif /* NDEBUG */ - -extern void nuDebConDisp(u32 flag); -extern void nuDebConDispEX2(u32 flag); -extern void nuDebConCPuts(u32 wndNo, const char *s); -extern void nuDebConInc(NUDebConWindow* conWin); -extern void nuDebConRtn(NUDebConWindow* conWin); -extern void nuDebConEsc(NUDebConWindow* conWin, char esc); -extern void nuDebConWindowSet(u32 wndNo, u32 winX , u32 winY, u32 width, u32 height); -extern void nuDebConWindowSize(u32 wndNo, u32 width, u32 height); -extern void nuDebConWindowPos(u32 wndNo, u32 winX , u32 winY); -extern void nuDebConTextColor(u32 wndNo, u32 color); -extern void nuDebConTextAttr(u32 wndNo, u32 attr); -extern void nuDebConTextPos(u32 wndNo, u32 posX, u32 posY); -extern void nuDebConScroll(u32 wndNo, u32 flag); -extern void nuDebConWindowShow(u32 wndNo, u32 flag); -extern void nuDebConClear(u32 wndNo); -extern void nuDebConPutc(u32 wndNo, u32 c); -extern void nuDebTaskPerfLoad(void); -extern void nuDebConPrintf(u32 wndNo, const char* fmt, ...); - - -#ifdef F3DEX_GBI_2 -#define nuDebConDisp(flag) nuDebConDispEX2(flag) -#endif /* F3DEX_GBI_2 */ - -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ -/* MACRO */ -/*----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------*/ -/* Registers the graphics microcode */ -/* IN: Pointer to the graphics microcode NUUcode array */ -/*----------------------------------------------------------------------*/ -#define nuGfxSetUcode(ucode) \ -{ \ - nuGfxUcode = ucode; \ -} -/*----------------------------------------------------------------------*/ -/* Z buffer settings */ -/* IN: Pointer to the Z buffer */ -/*----------------------------------------------------------------------*/ -#define nuGfxSetZBuffer(ZBuf_p) \ -{ \ - nuGfxZBuffer = ZBuf_p; \ -} -/*----------------------------------------------------------------------*/ -/* Remove callback functions */ -/* IN: nothing */ -/*----------------------------------------------------------------------*/ -#define nuPreNmiFuncRemove() nuPreNmiFuncSet(NULL) -#define nuGfxFuncRemove() nuGfxFuncSet(NULL) -#define nuGfxPreNMIFuncRemove() nuGfxPreNMIFuncSet(NULL) -#define nuGfxSwapCfbFuncRemove() nuGfxSwapCfbFuncSet(NULL) -#define nuGfxTaskEndFuncRemove() nuGfxTaskEndFuncSet(NULL) -#define nuContReadFuncRemove() nuContReadFuncSet(NULL) - -/*----------------------------------------------------------------------*/ -/* nuContDataGet - Obtains Controller data */ -/* Obtains read data from the Controller Manager. */ -/* */ -/* IN: *contpad Pointer to the Controller structure */ -/* cont_no Controller number */ -/*----------------------------------------------------------------------*/ -#if 0 -#define nuContDataGet(contpad, cont_no) \ -{ \ - bcopy(&nuContData[cont_no], contpad, sizeof(OSContPad)); \ -} - -/*----------------------------------------------------------------------*/ -/* nuContDataGetAll - Obtains Controller data */ -/* Obtains read data from the Controller Manager. */ -/* Copies all 4 buffers. */ -/* IN: *contpad Pointer to the Controller structure */ -/* cont_no Controller number */ -/*----------------------------------------------------------------------*/ -#define nuContDataGetAll(contpad) \ -{ \ - bcopy(&nuContData[0], contpad, sizeof(OSContPad)*MAXCONTROLLERS);\ -} -#endif -/*----------------------------------------------------------------------*/ -/* nuContPakFileFind - Search node */ -/*----------------------------------------------------------------------*/ -#define nuContPakFileFind(file, nodeName, extName) \ - nuContPakFileOpen(file, nodeNname, extName, NU_CONT_PAK_NOCREAT, 0)\ - - -/*----------------------------------------------------------------------*/ -/* nuContPakFileFindJis - Search node */ -/*----------------------------------------------------------------------*/ -#define nuContPakFileFindJis(file, nodeName, extName) \ - nuContPakFileOpenJis(file, nodeNname, extName, NU_CONT_PAK_NOCREAT, 0)\ - -/*----------------------------------------------------------------------*/ -/* nuContPakFileRead - Read note */ -/*----------------------------------------------------------------------*/ -#define nuContPakFileRead(file, offset, size, buf) \ - nuContPakFileReadWrite(file, offset, size, buf, PFS_READ) \ - -/*----------------------------------------------------------------------*/ -/* nuContPakFileWrite - Read note */ -/*----------------------------------------------------------------------*/ -#define nuContPakFileWrite(file, offset, size, buf) \ - nuContPakFileReadWrite(file, offset, size, buf, PFS_WRITE) \ - -/*----------------------------------------------------------------------*/ -/* nuDebConPuts - String output (with newline) */ -/*----------------------------------------------------------------------*/ -#define nuDebConPuts(wndNo, s) \ -{ \ - nuDebConCPuts(wndNo, s); \ - nuDebConRtn(&nuDebConWin[wndNo]); \ -} - -/*----------------------------------------------------------------------*/ -/* nuContGBPakRead - Read from the GB cartridge */ -/*----------------------------------------------------------------------*/ -#define nuContGBPakRead(file, address, buf, size) \ - nuContGBPakReadWrite(file, OS_READ, address, buf, size) - -/*----------------------------------------------------------------------*/ -/* nuContGBPakWrite - Write to the GB cartridge */ -/*----------------------------------------------------------------------*/ -#define nuContGBPakWrite(file, address, buf, size) \ - nuContGBPakReadWrite(file, OS_WRITE, address, buf, size) - -/*----------------------------------------------------------------------*/ -/* nuPiReadSram - Read from SRAM */ -/*----------------------------------------------------------------------*/ -#define nuPiReadSram(addr, buf_ptr, size) \ - nuPiReadWriteSram(addr, buf_ptr, size, OS_READ) - -/*----------------------------------------------------------------------*/ -/* nuPiWriteSram - Write to SRAM */ -/*----------------------------------------------------------------------*/ -#define nuPiWriteSram(addr, buf_ptr, size) \ - nuPiReadWriteSram(addr, buf_ptr, size, OS_WRITE) - -/*----------------------------------------------------------------------*/ -/* Define voice recognition macros */ -/*----------------------------------------------------------------------*/ -#define nuVrsCheckWord osVoiceCheckWord -#define nuVrsCountSyllables osVoiceCountSyllables - - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif -#endif /* _NUSYS_H_ */ +/*======================================================================*/ +/* NuSYS */ +/* nusys.h */ +/* */ +/* Copyright (C) 1997, NINTENDO Co,Ltd. */ +/* */ +/*----------------------------------------------------------------------*/ +/* Ver 1.0 97/10/09 Created by Kensaku Ohki(SLANP) */ +/* Ver 1.2 98/07/12 Modified by Kensaku Ohki(SLANP) */ +/* Ver 2.0 90/01/23 Modified by Kensaku Ohki(SLANP) */ +/*----------------------------------------------------------------------*/ +/* $Id: nusys.h,v 1.26 1999/05/07 08:23:45 ohki Exp ohki $ */ +/*======================================================================*/ +#ifndef _NUSYS_H_ +#define _NUSYS_H_ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +#ifndef F3DEX_GBI +#define F3DEX_GBI +#endif /* F3DEX_GBI */ + +#include +#include +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* DEFINE */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +#define NU_VERSION "2.05" + +/*--------------------------------------*/ +/* NuSystem spec define */ +/*--------------------------------------*/ +#define NU_SPEC_BOOT_STACK_SIZE 0x2000 +#define NU_SPEC_BOOT_ADDR 0x80025c00 +#define NU_SPEC_BOOT_STACK nuMainStack + NU_SPEC_BOOT_STACK_SIZE + +/*--------------------------------------*/ +/* Thread ID for DEBUG (a precaution) */ +/*--------------------------------------*/ +#define NU_IDLE_THREAD_ID 1 +#define NU_RMON_THREAD_ID 2 /* no use */ +#define NU_MAIN_THREAD_ID 3 + + +/*--------------------------------------*/ +/* NuSYS Thread Priority */ +/*--------------------------------------*/ +#define NU_IDLE_THREAD_PRI OS_PRIORITY_IDLE /* Idle thread */ +#define NU_RMON_THREAD_PRI OS_PRIORITY_RMON /* no use */ +#define NU_MAIN_THREAD_PRI 10 /* main thread */ + +/*--------------------------------------*/ +/* NUSYS STACK SIZE */ +/*--------------------------------------*/ +#define NU_IDLE_STACK_SIZE 0x2000 /* Idle thread */ +#define NU_RMON_STACK_SIZE 0x2000 /* Rmon thread */ +#define NU_MAIN_STACK_SIZE NU_SPEC_BOOT_STACK_SIZE /* Main thread */ + + + + +/*----------------------------------------------------------------------*/ +/* SCHEDULER DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_SC_STACK_SIZE 0x2000 /* Thread stack size */ +#define NU_SC_NOSWAPBUFFER 0x0000 /* No swap */ +#define NU_SC_SWAPBUFFER 0x0001 /* Swap frame buffer */ +#define NU_SC_NORDP 0x0002 /* Do not wait for RDP finish */ +#define NU_SC_UCODE_XBUS 0x0004 /* XBUS Ucode */ +#define NU_SC_TASK_YIELDED (OS_TASK_YIELEDE<<16) +#define NU_SC_TASK_DP_WAIT (OS_TASK_DP_WAIT<<16) /* RDP WAIT */ +#define NU_SC_TASK_LODABLE (OS_TASK_LOADBLE<<16) /* LOADABLE */ +#define NU_SC_TASK_SP_ONLY (OS_TASK_SP_ONLY<<16) /* SP ONLY */ + + +#define NU_SC_RETRACE_MSG 0x0001 /* Retrace message */ +#define NU_SC_PRENMI_MSG 0x0002 /* NMI message */ +#define NU_SC_SWAPBUFFER_MSG 0x0004 /* Swap frame buffer message*/ +#define NU_SC_GTASKEND_MSG 0x0008 /* Task finished message */ +#define NU_SC_MAX_MESGS 8 /* Message buffer size */ + +#define NU_SC_HANDLER_PRI 120 /* EVENT HANDLER THREAD PRORITY */ +#define NU_SC_AUDIO_PRI 110 /* AUDIO DISPATCHER THREAD PRORITY */ +#define NU_SC_GRAPHICS_PRI 100 /* GFX DISPATCHER THREAD PRORITY */ +#define NU_SC_HANDLER_THREAD_ID 19 +#define NU_SC_AUDIO_THREAD_ID 18 +#define NU_SC_GRAPHICS_THREAD_ID 17 +#define NU_SC_PRENMI_YET 0 /* PRE NMI has not occurred. */ +#define NU_SC_PRENMI_GET 1 /* PRE NMI received flag */ +#define NU_SC_BEFORE_RESET 2 /* Pre-RESET flag for frame before reset */ +#define NU_SC_BEFORE_RESET_FRAME 2 /* Number of frames before reset where BEFORE_RESET flag is set. */ +/*----------------------------------------------------------------------*/ +/* GRAFIC THREAD DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_GFX_THREAD_ID 4 +#define NU_GFX_TASKMGR_THREAD_ID 5 +#define NU_GFX_STACK_SIZE 0x2000 /* Thread stack size */ +#define NU_GFX_MESGS 8 /* GFX message queue*/ +#define NU_GFX_TASKMGR_STACK_SIZE 0x2000 /* Stack size */ +#define NU_GFX_TASKMGR_MESGS 8 /*Task Manager queue*/ +#define NU_GFX_THREAD_PRI 50 /* GFX thread priority */ +#define NU_GFX_TASKMGR_THREAD_PRI 60 /* Task Manager priority */ + +/*----------------------------------------------------------------------*/ +/* GRAFIC MANEGER DEFINE */ +/*----------------------------------------------------------------------*/ +#ifdef F3DEX_GBI_2 +#define NU_GFX_UCODE_F3DEX2 0 /* F3DEX microcode */ +#define NU_GFX_UCODE_F3DEX2_NON 1 /* F3DEX.NoN microcode */ +#define NU_GFX_UCODE_F3DEX2_REJ 2 /* F3DEX.NoN microcode */ +#define NU_GFX_UCODE_F3DLX2_REJ 3 /* F3DEX.ReJ microcode */ +#define NU_GFX_UCODE_L3DEX2 4 /* L3DEX microcode */ +#define NU_GFX_UCODE_S2DEX2 5 /* S2DEX microcode */ + +#define NU_GFX_UCODE_F3DEX 0 /* For compatibility */ +#define NU_GFX_UCODE_F3DEX_NON 1 /* For compatibility */ +#define NU_GFX_UCODE_F3DLX 0 /* For compatibility */ +#define NU_GFX_UCODE_F3DLX_NON 1 /* For compatibility */ +#define NU_GFX_UCODE_F3DLX_REJ 4 /* For compatibility */ +#define NU_GFX_UCODE_F3DLP_REJ 3 /* For compatibility */ +#define NU_GFX_UCODE_L3DEX 4 /* For compatibility */ +#define NU_GFX_UCODE_S2DEX 5 /* For compatibility */ +#define NU_GFX_UCODE_S2DEX_D 5 /* For compatibility */ + +#else +#define NU_GFX_UCODE_F3DEX 0 /* F3DEX microcode */ +#define NU_GFX_UCODE_F3DEX_NON 1 /* F3DEX.NoN microcode */ +#define NU_GFX_UCODE_F3DLX 2 /* F3DLX microcode */ +#define NU_GFX_UCODE_F3DLX_NON 3 /* F3DLX.NoN microcode */ +#define NU_GFX_UCODE_F3DLX_REJ 4 /* F3DEX.ReJ microcode */ +#define NU_GFX_UCODE_F3DLP_REJ 5 /* F3DLP.Rej microcode */ +#define NU_GFX_UCODE_L3DEX 6 /* L3DEX microcode */ +#define NU_GFX_UCODE_S2DEX 7 /* S2DEX microcode */ +#define NU_GFX_UCODE_S2DEX_D 8 /* S2DEX microcode */ +#endif /* F3DEX_GBI_2 */ + + +/*----------------------------------------------*/ +/* The number of graphics task structures */ +/* should be set to a value at least as large as*/ +/* the Scheduler */ +/* message buffer size. */ +/* Otherwise, a task structure in use may */ +/* be used. */ +/*----------------------------------------------*/ +#define NU_GFX_TASK_NUM 10 /* Number of graphics task structures */ +#define NU_GFX_RDP_OUTPUTBUFF_SIZE 0x20000 /* fifo buffer size */ + +/*--------------------------------------*/ +/* Default frame buffer */ +/* The default frame buffer */ +/* is the 320x240 16-bit triple */ +/* xxbuffer in the high-order */ +/* area of RDRAM.xx */ +/*--------------------------------------*/ +#define NU_GFX_FRAMEBUFFER_NUM 3 +#define NU_GFX_FRAMEBUFFER_ADDR (0x80400000-320*240*2*3) +#define NU_GFX_FRAMEBUFFER0_ADDR (NU_GFX_FRAMEBUFFER_ADDR) +#define NU_GFX_FRAMEBUFFER1_ADDR (NU_GFX_FRAMEBUFFER0_ADDR+320*240*2) +#define NU_GFX_FRAMEBUFFER2_ADDR (NU_GFX_FRAMEBUFFER1_ADDR+320*240*2) + +#define NU_GFX_INIT_SCREEN_WD 320 +#define NU_GFX_INIT_SCREEN_HT 240 + +/*--------------------------------------*/ +/* Default Z -buffer is located in */ +/* xxlow-order memory.xx */ +/*--------------------------------------*/ +#define NU_GFX_ZBUFFER_ADDR 0x80000400 + +#define NU_GFX_DISPLAY_OFF 0 /* No display */ +#define NU_GFX_DISPLAY_ON 1 /* Display */ +#define NU_GFX_DISPLAY_ON_TRIGGER 0x80 /* Trigger */ + +#define NU_GFX_YIELD_BUF_SIZE (OS_YIELD_DATA_SIZE + 0x10) + +/*----------------------------------------------------------------------*/ +/* SI MANAGER DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_SI_STACK_SIZE NU_CONT_STACK_SIZE +#define NU_SI_THREAD_ID NU_CONT_THREAD_ID +#define NU_SI_THREAD_PRI NU_CONT_THREAD_PRI +#define NU_SI_MESG_MAX NU_CONT_MESG_MAX +#define NU_SI_CALLBACK_END 1 +#define NU_SI_CALLBACK_CONTINUE 0 +#define NU_SI_SC_MAJOR_NO 0x0000 +#define NU_SI_MSG_MAJOR_NO_MASK 0xff00 +#define NU_SI_MSG_MINOR_NO_MASK 0x00ff + +#define NU_SI_MAJOR_NO_CONT 0x0100 +#define NU_SI_MAJOR_NO_PAK 0x0200 +#define NU_SI_MAJOR_NO_RMB 0x0300 +#define NU_SI_MAJOR_NO_EEPROM 0x0400 +#define NU_SI_MAJOR_NO_GBPAK 0x0500 +#define NU_SI_MAJOR_NO_VRS 0x0600 +#define NU_SI_STOP_MGR_MSG 0x7F00 + +/*----------------------------------------------------------------------*/ +/* CONTROLLER MANEGER DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_MAXCONTROLLERS MAXCONTROLLERS +#define NU_CONT_STACK_SIZE 0x2000 +#define NU_CONT_MESG_MAX 8 +#define NU_CONT_THREAD_ID 6 +#define NU_CONT_THREAD_PRI 115 +#define NU_CONT_DATA_UNLOCK 0 +#define NU_CONT_DATA_LOCK 1 + + +/*----------------------------------------------------------------------*/ +/* Define messages sent to the Controller Manager */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_MSG_BASE NU_SI_MAJOR_NO_CONT +#define NU_CONT_RETRACE_MSG (NU_CONT_MSG_BASE+0) +#define NU_CONT_READ_MSG (NU_CONT_MSG_BASE+1) +#define NU_CONT_READ_NW_MSG (NU_CONT_MSG_BASE+2) +#define NU_CONT_QUERY_MSG (NU_CONT_MSG_BASE+3) + + +#define NU_CONT_PAK_MSG_BASE NU_SI_MAJOR_NO_PAK +#define NU_CONT_PAK_RETRACE_MSG (NU_CONT_PAK_MSG_BASE+0) +#define NU_CONT_PAK_OPEN_MSG (NU_CONT_PAK_MSG_BASE+1) +#define NU_CONT_PAK_FREE_MSG (NU_CONT_PAK_MSG_BASE+2) +#define NU_CONT_PAK_FOPEN_MSG (NU_CONT_PAK_MSG_BASE+3) +#define NU_CONT_PAK_READWRITE_MSG (NU_CONT_PAK_MSG_BASE+4) +#define NU_CONT_PAK_FILEDELETE_MSG (NU_CONT_PAK_MSG_BASE+5) +#define NU_CONT_PAK_FILESTATE_MSG (NU_CONT_PAK_MSG_BASE+6) +#define NU_CONT_PAK_FILENUM_MSG (NU_CONT_PAK_MSG_BASE+7) +#define NU_CONT_PAK_REPAIRID_MSG (NU_CONT_PAK_MSG_BASE+8) + +#define NU_CONT_PAK_MODE_NOCREATE 0 +#define NU_CONT_PAK_MODE_CREATE 1 +#define NU_CONT_PAK_TYPE_NONE 0 +#define NU_CONT_PAK_TYPE_PAK 1 /* Controller Pak */ +#define NU_CONT_PAK_TYPE_RUMBLE 2 /* Rumble Pak */ +#define NU_CONT_PAK_TYPE_GBPAK 3 /* 64GB Pak */ +#define NU_CONT_PAK_READ PFS_READ +#define NU_CONT_PAK_WRITE PFS_WRITE + +/*----------------------------------------------------------------------*/ +/* Rumble Pak control */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_RMB_STATE_STOP 0x00 +#define NU_CONT_RMB_STATE_STOPPING 0x01 +#define NU_CONT_RMB_STATE_STOPPED 0x02 +#define NU_CONT_RMB_STATE_RUN 0x03 +#define NU_CONT_RMB_STATE_FORCESTOP 0x04 +#define NU_CONT_RMB_MODE_DISABLE 0x00 +#define NU_CONT_RMB_MODE_ENABLE 0x01 +#define NU_CONT_RMB_MODE_AUTORUN 0x02 +#define NU_CONT_RMB_MODE_PAUSE 0x80 +#define NU_CONT_RMB_AUTO_SEARCH 0x00 +#define NU_CONT_RMB_AUTO_FIND 0x01 +#define NU_CONT_RMB_AUTO_SEARCHTIME (60*5) +#define NU_CONT_RMB_MSG_BASE NU_SI_MAJOR_NO_RMB +#define NU_CONT_RMB_RETRACE_MSG (NU_CONT_RMB_MSG_BASE+0) +#define NU_CONT_RMB_CHECK_MSG (NU_CONT_RMB_MSG_BASE+1) +#define NU_CONT_RMB_START_MSG (NU_CONT_RMB_MSG_BASE+2) +#define NU_CONT_RMB_STOP_MSG (NU_CONT_RMB_MSG_BASE+3) +#define NU_CONT_RMB_FORCESTOP_MSG (NU_CONT_RMB_MSG_BASE+4) +#define NU_CONT_RMB_FORCESTOPEND_MSG (NU_CONT_RMB_MSG_BASE+5) + +/*----------------------------------------------------------------------*/ +/* EEPROM */ +/*----------------------------------------------------------------------*/ +#define NU_EEPROM_MSG_BASE NU_SI_MAJOR_NO_EEPROM +#define NU_EEPROM_RETRACE_MSG (NU_EEPROM_MSG_BASE+0) +#define NU_EEPROM_CHECK_MSG (NU_EEPROM_MSG_BASE+1) +#define NU_EEPROM_READ_MSG (NU_EEPROM_MSG_BASE+2) +#define NU_EEPROM_WRITE_MSG (NU_EEPROM_MSG_BASE+3) + + +/*----------------------------------------------------------------------*/ +/* 64GB Pack Manager */ +/*----------------------------------------------------------------------*/ +#define NU_CONT_GBPAK_MSG_BASE NU_SI_MAJOR_NO_GBPAK +#define NU_CONT_GBPAK_RETRACE_MSG (NU_CONT_GBPAK_MSG_BASE+0) +#define NU_CONT_GBPAK_OPEN_MSG (NU_CONT_GBPAK_MSG_BASE+1) +#define NU_CONT_GBPAK_STATUS_MSG (NU_CONT_GBPAK_MSG_BASE+2) +#define NU_CONT_GBPAK_POWER_MSG (NU_CONT_GBPAK_MSG_BASE+3) +#define NU_CONT_GBPAK_READID_MSG (NU_CONT_GBPAK_MSG_BASE+4) +#define NU_CONT_GBPAK_READWRITE_MSG (NU_CONT_GBPAK_MSG_BASE+5) +#define NU_CONT_GBPAK_CHECKCONNECTOR_MSG (NU_CONT_GBPAK_MSG_BASE+6) + +#define NU_CONT_GBPAK_POWER_OFF OS_GBPAK_POWER_OFF +#define NU_CONT_GBPAK_POWER_ON OS_GBPAK_POWER_ON +#define NU_CONT_GBPAK_MBC_RAM_ENABLE_CODE 0x0a +#define NU_CONT_GBPAK_MBC_RAM_DISABLE_CODE 0x00 +#define NU_CONT_GBPAK_MBC_RAM_REG0_ADDR 0x0000 + +#define NU_CONT_GBPAK_MBC_REG0_ADDR 0x0000 /* Register 0 */ +#define NU_CONT_GBPAK_MBC_REG1_ADDR 0x2100 /* Register 1 */ +#define NU_CONT_GBPAK_MBC_REG2_ADDR 0x4000 /* Register 2 */ +#define NU_CONT_GBPAK_MBC_REG3_ADDR 0x6000 /* Register 3 */ + +/*----------------------------------------------------------------------*/ +/* Voice Recognition System Manager */ +/*----------------------------------------------------------------------*/ +#define NU_VRS_MSG_BASE NU_SI_MAJOR_NO_VRS +#define NU_VRS_RETRACE_MSG (NU_VRS_MSG_BASE+0) +#define NU_VRS_OPEN_MSG (NU_VRS_MSG_BASE+1) +#define NU_VRS_CLEAR_DICTIONARY_MSG (NU_VRS_MSG_BASE+2) +#define NU_VRS_SET_WORD_MSG (NU_VRS_MSG_BASE+3) +#define NU_VRS_MASK_DICTIONARY_MSG (NU_VRS_MSG_BASE+4) +#define NU_VRS_START_READ_DATA_MSG (NU_VRS_MSG_BASE+5) +#define NU_VRS_GET_READ_DATA_MSG (NU_VRS_MSG_BASE+6) +#define NU_VRS_STOP_READ_DATA_MSG (NU_VRS_MSG_BASE+7) +#define NU_VRS_CONTROL_GAIN_MSG (NU_VRS_MSG_BASE+8) + +/*----------------------------------------------------------------------*/ +/* PI DEFINE */ +/*----------------------------------------------------------------------*/ +#define NU_PI_MESG_NUM 50 /* PI message buffer size */ +#define NU_PI_CART_BLOCK_READ_SIZE 0x4000 /* cart read block size */ + +/*----------------------------------------------------------------------*/ +/* DEBUG */ +/*----------------------------------------------------------------------*/ +#define NU_DEB_PERF_BUF_NUM 3 +#define NU_DEB_PERF_GFXTASK_CNT 8 /* Graphics task count */ +#define NU_DEB_PERF_AUTASK_CNT 4 /* Audio task count */ +#define NU_DEB_PERF_RUNNING 0 /* Sampling */ +#define NU_DEB_PERF_STOP 1 /* Stop sampling */ +#define NU_DEB_PERF_START 2 /* Start sampling */ +#define NU_DEB_DP_CLOCK_CTR 0 /* RDP internal counter */ +#define NU_DEB_DP_CMD_CTR 1 /* CMD counter */ +#define NU_DEB_DP_PIPE_CTR 2 /* PIPE counter */ +#define NU_DEB_DP_TMEM_CTR 3 /* TMEM counter */ +#define NU_DEB_BAR_FRAME1 0 /* For the performance bar */ +#define NU_DEB_BAR_FRAME2 1 /* Maximum number displayed */ +#define NU_DEB_BAR_FRAME3 2 +#define NU_DEB_BAR_FRAME4 3 +#define NU_DEB_BAR_FRAME5 4 +#define NU_DEB_BAR_FRAME6 5 +#define NU_DEB_BAR_FRAME7 6 +#define NU_DEB_CON_ROW_MAX 40 /* Number of rows in console */ +#define NU_DEB_CON_COLUMN_MAX 30 /* Number of columns in console */ +#define NU_DEB_CON_TEXT_SIZE (NU_DEB_CON_ROW_MAX*NU_DEB_CON_COLUMN_MAX) +#define NU_DEB_CON_WIDTH 320 +#define NU_DEB_CON_WINDOW_NUM 4 +#define NU_DEB_CON_WINDOW0 0 +#define NU_DEB_CON_WINDOW1 1 +#define NU_DEB_CON_WINDOW2 2 +#define NU_DEB_CON_WINDOW3 3 +#define NU_DEB_CON_TEXT_BLACK 0 /* Black */ +#define NU_DEB_CON_TEXT_BLUE 1 /* Blue */ +#define NU_DEB_CON_TEXT_GREEN 2 /* Green */ +#define NU_DEB_CON_TEXT_CYAN 3 /* Cyan */ +#define NU_DEB_CON_TEXT_RED 4 /* Red */ +#define NU_DEB_CON_TEXT_MAGENTA 5 /* Magenta */ +#define NU_DEB_CON_TEXT_YELLOW 6 /* yellow */ +#define NU_DEB_CON_TEXT_WHITE 7 /* White */ +#define NU_DEB_CON_TEXT_LIGHTBLACK 8 /* Gray */ +#define NU_DEB_CON_TEXT_LIGHTBLUE 9 /* Bright Blue */ +#define NU_DEB_CON_TEXT_LIGTHBLUE 9 /* Bright Blue (misspelled) */ +#define NU_DEB_CON_TEXT_LIGHTGREEN 10 /* Bright Green */ +#define NU_DEB_CON_TEXT_LIGHTCYAN 11 /* Bright Cyan */ +#define NU_DEB_CON_TEXT_LIGHTRED 12 /* Bright Red */ +#define NU_DEB_CON_TEXT_LIGHTMAGENTA 13 /* Bright Magenta */ +#define NU_DEB_CON_TEXT_LIGHTYELLOW 14 /* Bright yellow */ +#define NU_DEB_CON_TEXT_LIGHTWHITE 15 /* White */ +#define NU_DEB_CON_ATTR_NORMAL 0x0 /* No attribute*/ +#define NU_DEB_CON_ATTR_BLINK 0x1 /* Blinking */ +#define NU_DEB_CON_ATTR_REVERSE 0x2 /* Highlight */ +#define NU_DEB_CON_SCROLL_ON 1 +#define NU_DEB_CON_SCROLL_OFF 0 +#define NU_DEB_CON_WINDOW_OFF 0 +#define NU_DEB_CON_WINDOW_ON 1 + +#define NU_DEB_MARKER_NUM 10 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* structer define */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* Scheduler sturcter */ +/*--------------------------------------*/ +typedef short NUScMsg; /* Scheduler message type */ + +typedef struct st_SCClient { /* Client list structure */ + struct st_SCClient* next; /* Pointer to next client */ + OSMesgQueue* msgQ; /* Message sent to client */ + NUScMsg msgType; /* Type of message */ + /* NU_SC_RETRACE_MSG or*/ + /* NU_SC_PRENMI_MSG */ +} NUScClient; + +typedef struct st_SCTask { /* Task structure */ + struct st_SCTask *next; + u32 state; + u32 flags; + void *framebuffer; /* For graphics tasks */ + OSTask list; + OSMesgQueue *msgQ; + OSMesg msg; +} NUScTask; + +typedef struct st_Sched { /* Define the Scheduler structure. */ + + /* message */ + NUScMsg retraceMsg; + NUScMsg prenmiMsg; + + /* Define the Task request queue. */ + OSMesgQueue audioRequestMQ; + OSMesg audioRequestBuf[NU_SC_MAX_MESGS]; + OSMesgQueue graphicsRequestMQ; + OSMesg graphicsRequestBuf[NU_SC_MAX_MESGS]; + + /* Define the message queue. */ + OSMesgQueue retraceMQ; + OSMesg retraceMsgBuf[NU_SC_MAX_MESGS]; + OSMesgQueue rspMQ; + OSMesg rspMsgBuf[NU_SC_MAX_MESGS]; + OSMesgQueue rdpMQ; + OSMesg rdpMsgBuf[NU_SC_MAX_MESGS]; + + /* Implement wait for next retrace. */ + OSMesgQueue waitMQ; + OSMesg waitMsgBuf[NU_SC_MAX_MESGS]; + + /* Define threads.*/ + OSThread schedulerThread; /* Main thread */ + OSThread audioThread; /* Audio */ + OSThread graphicsThread; /* Graphics */ + + /* client list */ + NUScClient *clientList; + + /* The graphics task being executed. */ + NUScTask *curGraphicsTask; + NUScTask *curAudioTask; + NUScTask *graphicsTaskSuspended; + + u32 retraceCount; + u8 frameRate; + u8 frameBufferNum; /* Number of frame buffers */ + + +} NUSched; + + +/*--------------------------------------*/ +/* ucode structure */ +/*--------------------------------------*/ +typedef struct st_Ucode { + u64* ucode; + u64* ucode_data; +} NUUcode; + +/*--------------------------------------*/ +/* CALL BACK Function typedef */ +/*--------------------------------------*/ +typedef void (*NUIdleFunc)(void); /* Pointer to the idle callback function */ +typedef void (*NUScPreNMIFunc)(void); /* Pointer to PRENMI callback function */ +typedef void (*NUGfxFunc)(u32); /* Pointer to the GFX retrace callback function */ +typedef void (*NUGfxPreNMIFunc)(void); /* Pointer to the GFX PRENMI callback function */ + +typedef void (*NUGfxSwapCfbFunc)(void*);/* Pointer to the SWAPBUF callback function */ +typedef void (*NUGfxTaskEndFunc)(void*);/* Pointer to the TASKEND callback function */ +typedef void (*NUContReadFunc)(u32); /* Pointer to the Controller end-read */ + /* callback function */ +typedef void (*NUContPakFunc)(void*); /* Controller Pak control function callback */ +typedef void (*NUContRmbFunc)(void*); /* Rumble Pak control function callback */ +typedef s32 (*NUCallBackFunc)(void*); /* Callback function */ + + +/*--------------------------------------*/ +/* PI Common Message */ +/*--------------------------------------*/ +typedef struct st_PiOverlaySegment { + u8* romStart; /* Segment's ROM start offset */ + u8* romEnd; /* Segment's ROM end offset */ + u8* ramStart; /* Segment's CPU start address */ + u8* textStart; /* test attribute's DRAM start address */ + u8* textEnd; /* test attribute's DRAM end address */ + u8* dataStart; /* data attribute's DRAM start address */ + u8* dataEnd; /* data attribute's DRAM end address */ + u8* bssStart; /* bss attribute's DRAM start address */ + u8* bssEnd; /* bss attribute's DRAM start address */ +} NUPiOverlaySegment; + +/*--------------------------------------*/ +/* SI Common message */ +/*--------------------------------------*/ +typedef struct st_SiCommonMesg { + NUScMsg mesg; + OSMesgQueue* rtnMesgQ; + s32 error; + void* dataPtr; +} NUSiCommonMesg; + +/*--------------------------------------*/ +/* controller typedef */ +/*--------------------------------------*/ +typedef struct st_ContRead { + NUScMsg mesg; /* Type of message */ + OSMesgQueue* rtnMesgQ; + OSContPad* pad; +} NUContReadMesg; + +typedef struct st_ContData { + u16 button; /* A,B,C,Z,L,R,START,PAD ,button */ + s8 stick_x; /* Range acutally used: -61 <= stick X <= 61 */ + s8 stick_y; /* Range actually used: -63 <= stick Y <= 63 */ + u8 errno; /* Error */ + u16 trigger; /* Button trigger data */ +} NUContData; + +typedef struct st_ContQuery { + NUScMsg mesg; + OSMesgQueue* rtnMesgQ; +} NUContQueryMesg; + + +typedef struct st_ContPakFile { + OSPfs *pfs; + s32 file_no; + s32 error; + u32 type; +} NUContPakFile; + + +typedef struct st_ContPakFreeMesg { + NUContPakFile* file; + s32 size; +} NUContPakFreeMesg; + +typedef struct st_ContPakFileOpenMesg { + NUContPakFile* file; + u8* noteName; + u8* extName; + s32 size; + s32 mode; +} NUContPakFileOpenMesg; + +typedef struct st_ContPakFileRWMesg { + NUContPakFile* file; + s32 offset; + s32 size; + u8 mode; + u8* buf; +} NUContPakFileRWMesg; + +typedef struct st_ContPakFileStateMesg { + NUContPakFile* file; + OSPfsState* state; +} NUContPakFileStateMesg; + +typedef struct st_ContPakFileNumMesg { + NUContPakFile* file; + s32* max_files; + s32* used_files; +} NUContPakFileNumMesg; + +typedef struct st_ContPakIsPlugMesg { + NUScMsg mesg; + OSMesgQueue* rtnMesgQ; + s32 error; + u8 bitPattern; +} NUContPakIsPlugMesg; + +typedef struct st_ContRmbCtl { + u16 freq; /* Vibration frequency */ + u16 frame; + u16 counter; + u8 state; + u8 mode; + u8 autorun; + u8 type; +} NUContRmbCtl; + +typedef struct st_ContRmbMesg { + u8 contNo; + s32 error; + void* data; +} NUContRmbMesg; + +typedef struct st_CallBackList { + struct st_CallBackList* next; + s32 (**func)(NUSiCommonMesg*); + u16 majorNo; + u8 funcNum; +} NUCallBackList; + +typedef struct st_EepromMesg { + void* dataPtr; + s32 error; + u8 address; + u16 dataLen; +} NUEepromMesg; + +typedef struct st_ContGBPakMesg { + NUContPakFile* handle; + s32 data[4]; +} NUContGBPakMesg; + +typedef OSVoiceHandle NUVrsHandle; + +typedef OSVoiceData NUVrsData; + +typedef struct stVrsMesg { + NUVrsHandle* vrsHandle; + s32 data[2]; +} NUVrsMesg; + +/*--------------------------------------*/ +/* Debug */ +/*--------------------------------------*/ +typedef struct st_GfxTaskTime { + s64 rspStart; /* RSPTask start time */ + s64 rspEnd; /* RSPTask end time */ + s64 rdpEnd; /* RDP end time */ + u32 dpCnt[4]; /* RDP internal counter */ +} NUDebTaskTime; + +typedef struct st_DebTaskPerf { + s64 retraceTime; /* retrace event time*/ + s64 markerTime[NU_DEB_MARKER_NUM]; + u8 gfxTaskCnt; /* Number of graphics tasks */ + u8 auTaskCnt; /* Number of audio tasks */ + u8 gfxTaskStart; + NUDebTaskTime gfxTaskTime[NU_DEB_PERF_GFXTASK_CNT]; + NUDebTaskTime auTaskTime[NU_DEB_PERF_AUTASK_CNT]; +} NUDebTaskPerf; + +/* Console window structure */ +typedef struct st_DebConWindow { + u8 windowFlag; /* On/off flag for console window display */ + u16 scroll; /* Scroll value */ + u8 scrollFlag; /* Scrolling enabled/disabled */ + u8 textColor; /* Character color */ + u8 attribute; /* Attribute */ + u16 posX; /* Column position for write */ + u16 posY; /* Line position for write */ + u16 index; /* Position for character buffer write */ + u16 winX; /* x-coordinate of console window display */ + u16 winY; /* y-coordinate of console window display */ + u16 winW; /* Number of columns in console display */ + u16 winH; /* Number of rows in console display */ + u16 text[NU_DEB_CON_TEXT_SIZE]; /* Character buffer*/ +} NUDebConWindow; + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* extern variables */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +extern u8 nuRDPOutputBuf[]; +extern u8 nuDramStack[]; +extern u8 nuYieldBuf[]; +extern NUSched nusched; /* Scheduler structure */ +extern OSMesgQueue nuGfxMesgQ; /* Graphics thread queue */ +extern u32 nuScRetraceCounter; /* Retrace counter */ +extern u8 nuScPreNMIFlag; +/*--------------------------------------*/ +/* graphics variables */ +/*--------------------------------------*/ +extern NUUcode* nuGfxUcode; /* Pointer to GFX microcode structure */ +extern u16** nuGfxCfb; /* Pointer to array of pointers to frame buffers */ +extern u16* nuGfxCfb_ptr; /* Pointer to to frame buffer */ +extern u32 nuGfxCfbNum; /* Number of frame buffers */ +extern u16* nuGfxZBuffer; /* Pointer to the Z buffer */ +extern volatile u32 nuGfxTaskSpool; /* Number of tasks in queue */ +extern u32 nuGfxDisplay; /* Display on/off flag */ +extern u32 nuGfxCfbCounter; /* For frame buffer swapping */ +extern OSMesgQueue nuGfxMesgQ; +extern OSThread nuGfxThread; /* graphic thread */ + +/*--------------------------------------*/ +/* controller Manager variables */ +/*--------------------------------------*/ +extern OSContStatus nuContStatus[]; +extern OSContPad nuContData[]; +extern u32 nuContNum; /* Number of controllers connected */ +extern u32 nuContDataLockKey; /* Lock Controller data. */ +extern OSMesgQueue nuContWaitMesgQ; /* Wait for Controller read */ +extern OSPfs nuContPfs[]; +extern NUCallBackList nuContCallBack; +extern u16 nuContPakCompanyCode; /* Company code */ +extern u32 nuContPakGameCode; /* Game code */ +extern NUCallBackList nuContPakCallBack; + +/*--------------------------------------*/ +/* RUMBUL Manager variables */ +/*--------------------------------------*/ +extern NUContRmbCtl nuContRmbCtl[]; +extern u32 nuContRmbSearchTime; +extern NUCallBackList nuContRmbCallBack; + + +/*--------------------------------------*/ +/* EEPROM Manager variables */ +/*--------------------------------------*/ +extern NUCallBackList nuEepromCallBack; + +/*--------------------------------------*/ +/* 64GBPack Manager variables */ +/*--------------------------------------*/ +extern NUCallBackList nuContGBPakCallBack; + +/*--------------------------------------*/ +/* VRS Manager variables */ +/*--------------------------------------*/ +extern NUCallBackList nuVrsCallBack; + +/*--------------------------------------*/ +/* si variables */ +/*--------------------------------------*/ +extern OSMesgQueue nuSiMesgQ; /* SI event message queue */ +extern OSMesgQueue nuSiMgrMesgQ; /* SI Manager queue */ +extern NUCallBackList* nuSiCallBackList;/* Callback function list */ + +/*--------------------------------------*/ +/* pi variables */ +/*--------------------------------------*/ +extern OSPiHandle* nuPiCartHandle; +extern OSPiHandle* nuPiSramHandle; +extern OSPiHandle* nuPiDDRomHandle; + +/*--------------------------------------*/ +/* CALL BACK Function pointer */ +/*--------------------------------------*/ +extern NUIdleFunc nuIdleFunc; /* callback func pointer */ +extern NUScPreNMIFunc nuScPreNMIFunc; /* PRE NMI callback pointer */ +extern NUGfxSwapCfbFunc nuGfxSwapCfbFunc; /* swapbuf callback pointer */ +extern NUGfxFunc nuGfxFunc; /* callback pointer */ +extern NUGfxPreNMIFunc nuGfxPreNMIFunc; /* Callback pointer */ +extern NUGfxTaskEndFunc nuGfxTaskEndFunc; /* task end callback ptr */ +extern NUContReadFunc nuContReadFunc; /* When controller read ends */ + /* Callback function */ +/*--------------------------------------*/ +/* Debug */ +/*--------------------------------------*/ + +extern NUDebTaskPerf* nuDebTaskPerfPtr; +extern NUDebConWindow nuDebConWin[]; +extern NUDebTaskPerf nuDebTaskPerf[]; +extern u32 nuDebTaskPerfInterval; +extern volatile u32 nuDebTaskPerfCnt; +extern volatile u32 nuDebTaskPerfEnd; + + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* Global Function */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*--------------------------------------*/ +/* Boot function */ +/*--------------------------------------*/ +extern void nuIdleFuncSet(void (*func)(void)); +extern void nuPreNMIFuncSet(NUScPreNMIFunc func); +/*--------------------------------------*/ +/* Scheduler function */ +/*--------------------------------------*/ +extern void nuScCreateScheduler(u8 videoMode, u8 numFields); +extern void nuScAddClient(NUScClient *c, OSMesgQueue *mq, NUScMsg msgType); +extern void nuScRemoveClient(NUScClient *client); +extern void nuScResetClientMesgType(NUScClient* client, NUScMsg msgType); +extern OSMesgQueue* nuScGetGfxMQ(void); +extern OSMesgQueue* nuScGetAudioMQ(void); +extern void nuScSetFrameBufferNum(u8 frameBufferNum); +extern s32 nuScGetFrameRate(void); + +/*--------------------------------------*/ +/* graphic(GFX) Manager function */ +/*--------------------------------------*/ +extern void nuGfxInit(void); +extern void nuGfxInitEX2(void); +extern void nuGfxThreadStart(void); +extern void nuGfxTaskMgrInit(void); +extern void nuGfxTaskStart(Gfx *gfxList_ptr, u32 gfxListSize, u32 ucode, u32 flag); +extern void nuGfxFuncSet(NUGfxFunc func); +extern void nuGfxPreNMIFuncSet(NUGfxPreNMIFunc func); +extern void nuGfxSwapCfbFuncSet(NUGfxSwapCfbFunc func); +extern void nuGfxSetCfb(u16** framebuf, u32 framebufnum); +extern void nuGfxSwapCfb(void* framebuffer); + +extern void nuGfxTaskEndFuncSet(NUGfxTaskEndFunc func); +extern void nuGfxTaskAllEndWait(void); +extern void nuGfxRetraceWait(u32 retrace_num); +extern void nuGfxDisplayOff(void); +extern void nuGfxDisplayOn(void); + +#ifdef F3DEX_GBI_2 +#define nuGfxInit() nuGfxInitEX2() +#endif /* F3DEX_GBI_2 */ +/*--------------------------------------*/ +/* controller Manager function */ +/*--------------------------------------*/ +extern u8 nuContInit(void); +extern s32 nuContMgr(void* mesg); +extern u8 nuContMgrInit(void); +extern void nuContMgrRemove(void); +extern void nuContDataLock(void); +extern void nuContDataUnLock(void); +extern void nuContDataRead(OSContPad* pad); +extern void nuContDataReadWait(void); +extern void nuContDataReadStart(void); +extern void nuContDataGet(OSContPad* contdata, u32 padno); +extern void nuContDataGetAll(OSContPad* contdata); +extern void nuContDataGetEx(NUContData *contdata, u32 padno); +extern void nuContDataGetExAll(NUContData *contdata); +extern void nuContReadFuncSet(NUContReadFunc func); +extern void nuContQueryRead(void); +extern void nuContDataClose(void); +extern void nuContDataOpen(void); + +/*--------------------------------------*/ +/* controller pak function */ +/*--------------------------------------*/ +extern s32 nuContPakMgr(void* mesg_type); +extern void nuContPakMgrInit(void); +extern void nuContPakMgrRemove(void); +extern void nuContPakJisToN64(u8* src, u8* dest, u32 len); +extern void nuContPakN64ToJis(u8* src, u8* dest, u32 len); +extern s32 nuContPakOpen(NUContPakFile *file, u32 contNo); +extern s32 nuContPakGetFree(NUContPakFile *file); +extern void nuContPakCodeSet(u8* companyCode, u8* gameCode); +extern s32 nuContPakRepairId(NUContPakFile *file); +extern s32 nuContPakFileOpen(NUContPakFile *file, + u8* noteName,u8* extName, u32 mode, s32 size); +extern s32 nuContPakFileOpenJis(NUContPakFile *file, + u8* noteName,u8* extName, u32 mode, s32 size); +extern s32 nuContPakFileReadWrite(NUContPakFile *file, + s32 offset, s32 size,u8* buf, u32 mode); +extern s32 nuContPakFileDelete(NUContPakFile *file, u8* noteName, u8* extName); +extern s32 nuContPakFileDeleteJis(NUContPakFile *file, u8* noteName, u8* extName); +extern s32 nuContPakFileState(NUContPakFile *file, OSPfsState* state); +extern s32 nuContPakFileNum(NUContPakFile *file, + s32 *max_files, s32 *used_files); +extern s32 nuContPakFileFread(NUContPakFile *file, s32 offset, s32 size, u8* buf); + +/*--------------------------------------*/ +/* rumbler pak functions */ +/*--------------------------------------*/ +extern void nuContRmbMgrInit(void); +extern s32 nuContRmbMgr(void* mesg); +extern void nuContRmbMgrRemove(void); +extern void nuContRmbStart(u32 contNo, u16 freq, u16 frame); +extern void nuContRmbStop(u32 contNo); +extern s32 nuContRmbCheck(u32 contNo); +extern void nuContRmbModeSet(u32 contNo, u8 mode); +extern void nuContRmbForceStop(void); +extern void nuContRmbForceStopEnd(void); +extern void nuContRmbSearchTimeSet(u32 frame); + +/*--------------------------------------*/ +/* 64GB Pack functions */ +/*--------------------------------------*/ +extern s32 nuContGBPakMgr(void* mesg); +extern void nuContGBPakMgrInit(void); +extern void nuContGBPakMgrRemove(void); +extern s32 nuContGBPakOpen(NUContPakFile* handle, s32 contNo); +extern s32 nuContGBPakGetStatus(NUContPakFile* handle, u8* status); +extern s32 nuContGBPakReadID(NUContPakFile* handle, OSGbpakId* id, u8* status); +extern s32 nuContGBPakReadWrite(NUContPakFile* handle, u16 flag , u16 address, u8* buffer, u16 size); +extern s32 nuContGBPakPower(NUContPakFile* handle, s32 flag); +extern s32 nuContGBPakCheckConnector(NUContPakFile* handle, u8* status); +extern s32 nuContGBPakFread(NUContPakFile* handle, u16 address, u8* buffer, u16 size); + +extern s32 nuContGBPakFwrite(NUContPakFile* handle, u16 address, u8* buffer, u16 size); +extern s32 nuContGBPakRegWrite(NUContPakFile* handle, u16 addr, u8 data); + +/*--------------------------------------*/ +/* eeprom functions */ +/*--------------------------------------*/ +extern void nuEepromMgrInit(void); +extern s32 nuEepromMgr(void* mesg); +extern s32 nuEepromCheck(void); +extern void nuEepromMgrRemove(void); +extern s32 nuEepromRead(u8 address, u8* buffer,u16 len); +extern s32 nuEepromWrite(u8 address, u8* buffer,u16 len); + + +/*--------------------------------------*/ +/* pi functions */ +/*--------------------------------------*/ +extern void nuPiInit(void); +extern void nuPiReadRom(u32 rom_addr, void* buf_ptr, u32 size); +extern void nuPiInitSram(void); +extern void nuPiInitDDrom(void); +extern void nuPiReadWriteSram(u32 addr, void* buf_ptr, u32 size, s32 flag); +extern void nuPiReadRomOverlay(NUPiOverlaySegment* segment); + +/*--------------------------------------*/ +/* si functions */ +/*--------------------------------------*/ +extern u8 nuSiMgrInit(void); +extern void nuSiCallBackAdd(NUCallBackList* list); +extern void nuSiCallBackRemove(NUCallBackList* list); +extern s32 nuSiSendMesg(NUScMsg mesg, void* dataPtr); +extern void nuSiSendMesgNW(NUScMsg mesg, void* dataPtr); +extern void nuSiMgrStop(void); +extern void nuSiMgrRestart(void); +/*--------------------------------------*/ +/* si functions */ +/*--------------------------------------*/ +extern s32 nuVrsMgr(void *mesg); +extern void nuVrsMgrInit(void); +extern s32 nuVrsOpen(NUVrsHandle* handle, s32 contNo); +extern s32 nuVrsClearDictionary(NUVrsHandle* handle, u8 words); +extern s32 nuVrsSetWord(NUVrsHandle* handle, u8* word); +extern s32 nuVrsStartReadData(NUVrsHandle* handle); +extern s32 nuVrsGetReadData(NUVrsHandle* handle, NUVrsData* data); +extern s32 nuVrsStopReadData(NUVrsHandle* handle); +extern s32 nuVrsControlGain(NUVrsHandle* handle, s32 analog, s32 digital); +extern s32 nuVrsMaskDictionary(NUVrsHandle* handle, u8* maskpattern, s32 size); + +/*--------------------------------------*/ +/* dubug functions */ +/*--------------------------------------*/ +#ifdef NDEBUG +#define nuDebTaskPerfBar0(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebTaskPerfBar1(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebTaskPerfBar0EX2(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebTaskPerfBar1EX2(EX0 ,EX1 ,EX2) ((void)0) +#define nuDebPerfMarkSet(EX0) ((void)0) +#define nuDebTaskPerfIntervalSet(EX0) ((void)0) +#else +extern void nuDebTaskPerfBar0(u32 frameNum, u32 y, u32 flag); +extern void nuDebTaskPerfBar1(u32 frameNum, u32 y, u32 flag); +extern void nuDebTaskPerfBar0EX2(u32 frameNum, u32 y, u32 flag); +extern void nuDebTaskPerfBar1EX2(u32 frameNum, u32 y, u32 flag); +extern u32 nuDebPerfMarkSet(s32 markNo); +extern void nuDebTaskPerfIntervalSet(u32 interval); +#ifdef F3DEX_GBI_2 +#define nuDebTaskPerfBar0(a, b, c) nuDebTaskPerfBar0EX2(a, b, c) +#define nuDebTaskPerfBar1(a, b, c) nuDebTaskPerfBar1EX2(a, b, c) +#endif /* F3DEX_GBI_2 */ + +#endif /* NDEBUG */ + +extern void nuDebConDisp(u32 flag); +extern void nuDebConDispEX2(u32 flag); +extern void nuDebConCPuts(u32 wndNo, const char *s); +extern void nuDebConInc(NUDebConWindow* conWin); +extern void nuDebConRtn(NUDebConWindow* conWin); +extern void nuDebConEsc(NUDebConWindow* conWin, char esc); +extern void nuDebConWindowSet(u32 wndNo, u32 winX , u32 winY, u32 width, u32 height); +extern void nuDebConWindowSize(u32 wndNo, u32 width, u32 height); +extern void nuDebConWindowPos(u32 wndNo, u32 winX , u32 winY); +extern void nuDebConTextColor(u32 wndNo, u32 color); +extern void nuDebConTextAttr(u32 wndNo, u32 attr); +extern void nuDebConTextPos(u32 wndNo, u32 posX, u32 posY); +extern void nuDebConScroll(u32 wndNo, u32 flag); +extern void nuDebConWindowShow(u32 wndNo, u32 flag); +extern void nuDebConClear(u32 wndNo); +extern void nuDebConPutc(u32 wndNo, u32 c); +extern void nuDebTaskPerfLoad(void); +extern void nuDebConPrintf(u32 wndNo, const char* fmt, ...); + + +#ifdef F3DEX_GBI_2 +#define nuDebConDisp(flag) nuDebConDispEX2(flag) +#endif /* F3DEX_GBI_2 */ + +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* MACRO */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------*/ +/* Registers the graphics microcode */ +/* IN: Pointer to the graphics microcode NUUcode array */ +/*----------------------------------------------------------------------*/ +#define nuGfxSetUcode(ucode) \ +{ \ + nuGfxUcode = ucode; \ +} +/*----------------------------------------------------------------------*/ +/* Z buffer settings */ +/* IN: Pointer to the Z buffer */ +/*----------------------------------------------------------------------*/ +#define nuGfxSetZBuffer(ZBuf_p) \ +{ \ + nuGfxZBuffer = ZBuf_p; \ +} +/*----------------------------------------------------------------------*/ +/* Remove callback functions */ +/* IN: nothing */ +/*----------------------------------------------------------------------*/ +#define nuPreNmiFuncRemove() nuPreNmiFuncSet(NULL) +#define nuGfxFuncRemove() nuGfxFuncSet(NULL) +#define nuGfxPreNMIFuncRemove() nuGfxPreNMIFuncSet(NULL) +#define nuGfxSwapCfbFuncRemove() nuGfxSwapCfbFuncSet(NULL) +#define nuGfxTaskEndFuncRemove() nuGfxTaskEndFuncSet(NULL) +#define nuContReadFuncRemove() nuContReadFuncSet(NULL) + +/*----------------------------------------------------------------------*/ +/* nuContDataGet - Obtains Controller data */ +/* Obtains read data from the Controller Manager. */ +/* */ +/* IN: *contpad Pointer to the Controller structure */ +/* cont_no Controller number */ +/*----------------------------------------------------------------------*/ +#if 0 +#define nuContDataGet(contpad, cont_no) \ +{ \ + bcopy(&nuContData[cont_no], contpad, sizeof(OSContPad)); \ +} + +/*----------------------------------------------------------------------*/ +/* nuContDataGetAll - Obtains Controller data */ +/* Obtains read data from the Controller Manager. */ +/* Copies all 4 buffers. */ +/* IN: *contpad Pointer to the Controller structure */ +/* cont_no Controller number */ +/*----------------------------------------------------------------------*/ +#define nuContDataGetAll(contpad) \ +{ \ + bcopy(&nuContData[0], contpad, sizeof(OSContPad)*MAXCONTROLLERS);\ +} +#endif +/*----------------------------------------------------------------------*/ +/* nuContPakFileFind - Search node */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileFind(file, nodeName, extName) \ + nuContPakFileOpen(file, nodeNname, extName, NU_CONT_PAK_NOCREAT, 0)\ + + +/*----------------------------------------------------------------------*/ +/* nuContPakFileFindJis - Search node */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileFindJis(file, nodeName, extName) \ + nuContPakFileOpenJis(file, nodeNname, extName, NU_CONT_PAK_NOCREAT, 0)\ + +/*----------------------------------------------------------------------*/ +/* nuContPakFileRead - Read note */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileRead(file, offset, size, buf) \ + nuContPakFileReadWrite(file, offset, size, buf, PFS_READ) \ + +/*----------------------------------------------------------------------*/ +/* nuContPakFileWrite - Read note */ +/*----------------------------------------------------------------------*/ +#define nuContPakFileWrite(file, offset, size, buf) \ + nuContPakFileReadWrite(file, offset, size, buf, PFS_WRITE) \ + +/*----------------------------------------------------------------------*/ +/* nuDebConPuts - String output (with newline) */ +/*----------------------------------------------------------------------*/ +#define nuDebConPuts(wndNo, s) \ +{ \ + nuDebConCPuts(wndNo, s); \ + nuDebConRtn(&nuDebConWin[wndNo]); \ +} + +/*----------------------------------------------------------------------*/ +/* nuContGBPakRead - Read from the GB cartridge */ +/*----------------------------------------------------------------------*/ +#define nuContGBPakRead(file, address, buf, size) \ + nuContGBPakReadWrite(file, OS_READ, address, buf, size) + +/*----------------------------------------------------------------------*/ +/* nuContGBPakWrite - Write to the GB cartridge */ +/*----------------------------------------------------------------------*/ +#define nuContGBPakWrite(file, address, buf, size) \ + nuContGBPakReadWrite(file, OS_WRITE, address, buf, size) + +/*----------------------------------------------------------------------*/ +/* nuPiReadSram - Read from SRAM */ +/*----------------------------------------------------------------------*/ +#define nuPiReadSram(addr, buf_ptr, size) \ + nuPiReadWriteSram(addr, buf_ptr, size, OS_READ) + +/*----------------------------------------------------------------------*/ +/* nuPiWriteSram - Write to SRAM */ +/*----------------------------------------------------------------------*/ +#define nuPiWriteSram(addr, buf_ptr, size) \ + nuPiReadWriteSram(addr, buf_ptr, size, OS_WRITE) + +/*----------------------------------------------------------------------*/ +/* Define voice recognition macros */ +/*----------------------------------------------------------------------*/ +#define nuVrsCheckWord osVoiceCheckWord +#define nuVrsCountSyllables osVoiceCountSyllables + + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _NUSYS_H_ */ diff --git a/src/code_25f00_len_940.c b/src/code_25f00_len_940.c index 1228a355e3..2647ce0b85 100644 --- a/src/code_25f00_len_940.c +++ b/src/code_25f00_len_940.c @@ -1,21 +1,23 @@ #include "common.h" +#include "nu/nusys.h" +#include "nu/nualsgi.h" INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AB00); -void func_8004ADD0(s32 arg0) { - OSIntMask osIntMask = osSetIntMask(OS_IM_NONE); +void nuAuPreNMIFuncSet(NUAuPreNMIFunc func) { + OSIntMask mask = osSetIntMask(OS_IM_NONE); - D_80078174 = arg0; - osSetIntMask(osIntMask); + nuAuPreNMIFunc = func; + osSetIntMask(mask); } INCLUDE_ASM(s32, "code_25f00_len_940", func_8004AE08); INCLUDE_ASM(s32, "code_25f00_len_940", nuAuDmaCallBack); -INCLUDE_ASM(s32, "code_25f00_len_940", nuAuDmaNew); +INCLUDE_ASM(ALDMAproc, "code_25f00_len_940", nuAuDmaNew, NUDMAState **state); -INCLUDE_ASM(s32, "code_25f00_len_940", nuAuCleanDMABuffers); +INCLUDE_ASM(void, "code_25f00_len_940", nuAuCleanDMABuffers); INCLUDE_ASM(s32, "code_25f00_len_940", func_8004B328); diff --git a/tools/symbol_addrs.txt b/tools/symbol_addrs.txt index 4020f96fef..9dab963800 100644 --- a/tools/symbol_addrs.txt +++ b/tools/symbol_addrs.txt @@ -222,6 +222,7 @@ spawn_drops = 0x80048280; get_coin_drop_amount = 0x80048D50; is_point_within_region = 0x80048FD4; DoBasicAI = 0x8004A47C; +nuAuPreNMIFuncSet = 0x8004ADD0; nuAuDmaCallBack = 0x8004B074; // ! nuAuDmaNew = 0x8004B224; nuAuCleanDMABuffers = 0x8004B268; @@ -561,6 +562,7 @@ setup_demo_player = 0x80072D2C; load_demo_battle = 0x80072E14; EnemyNpcHit = 0x80077F70; EnemyNpcDefeat = 0x8007809C; +nuAuPreNMIFunc = 0x80078174; D_80078DB0 = 0x80078DB0; D_80078DB4 = 0x80078DB4; gEffectTable = 0x8007F214; diff --git a/undefined_syms_auto.txt b/undefined_syms_auto.txt index fade50103d..7619b27f21 100644 --- a/undefined_syms_auto.txt +++ b/undefined_syms_auto.txt @@ -118,7 +118,6 @@ D_80078160 = 0x80078160; D_80078164 = 0x80078164; D_80078168 = 0x80078168; D_80078170 = 0x80078170; -D_80078174 = 0x80078174; D_80078178 = 0x80078178; D_8007817C = 0x8007817C; D_80078180 = 0x80078180;