1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - include - snd - common 3 File: work.h 4 5 Copyright 2004-2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2008-09-18#$ 14 $Rev: 8573 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NITRO_SND_COMMON_WORK_H_ 19 #define NITRO_SND_COMMON_WORK_H_ 20 21 #include <nitro/snd/common/exchannel.h> 22 #include <nitro/snd/common/seq.h> 23 #include <nitro/snd/common/capture.h> 24 25 #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL)) 26 #include <nitro/snd/common/alarm.h> 27 #endif // SDK_FROM_TOOL 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /****************************************************************************** 34 macro definition 35 ******************************************************************************/ 36 37 #define SND_DEFAULT_VARIABLE -1 38 39 /****************************************************************************** 40 structure definition 41 ******************************************************************************/ 42 43 typedef struct SNDWork 44 { 45 SNDExChannel channel[SND_CHANNEL_NUM]; 46 SNDPlayer player[SND_PLAYER_NUM]; 47 SNDTrack track[SND_TRACK_NUM]; 48 #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL)) 49 SNDAlarm alarm[SND_ALARM_NUM]; 50 #endif // SDK_FROM_TOOL 51 } 52 SNDWork; // must be 32 byte boundary 53 54 typedef struct SNDSharedWork 55 { 56 vu32 finishCommandTag; 57 vu32 playerStatus; 58 vu16 channelStatus; 59 vu16 captureStatus; 60 vu32 padding[5]; 61 struct 62 { 63 vs16 variable[SND_PLAYER_VARIABLE_NUM]; 64 vu32 tickCounter; 65 } 66 player[SND_PLAYER_NUM]; 67 vs16 globalVariable[SND_GLOBAL_VARIABLE_NUM]; 68 } 69 SNDSharedWork; // must be 32 byte boundary 70 71 typedef struct SNDSpReg 72 { 73 u32 chCtrl[SND_CHANNEL_NUM]; 74 } 75 SNDSpReg; 76 77 typedef struct SNDDriverInfo 78 { 79 SNDWork work; 80 u32 chCtrl[SND_CHANNEL_NUM]; 81 SNDWork *workAddress; 82 u32 lockedChannels; 83 u32 padding[6]; 84 } 85 SNDDriverInfo; // must be 32 byte boundary 86 87 typedef struct SNDChannelInfo 88 { 89 BOOL activeFlag:1; 90 BOOL lockFlag:1; 91 92 u16 volume; 93 u8 pan; 94 u8 pad_; 95 96 SNDEnvStatus envStatus; 97 } 98 SNDChannelInfo; 99 100 typedef struct SNDPlayerInfo 101 { 102 BOOL activeFlag:1; 103 BOOL pauseFlag:1; 104 105 u16 trackBitMask; 106 u16 tempo; 107 u8 volume; 108 u8 pad_; 109 u16 pad2_; 110 } 111 SNDPlayerInfo; 112 113 typedef struct SNDTrackInfo 114 { 115 u16 prgNo; 116 u8 volume; 117 u8 volume2; 118 s8 pitchBend; 119 u8 bendRange; 120 u8 pan; 121 s8 transpose; 122 u8 pad_; 123 u8 chCount; 124 u8 channel[SND_CHANNEL_NUM]; 125 } 126 SNDTrackInfo; 127 128 /****************************************************************************** 129 private variable declaration 130 ******************************************************************************/ 131 132 extern SNDSharedWork *SNDi_SharedWork; 133 134 #ifdef SDK_ARM7 135 136 extern SNDWork SNDi_Work; 137 138 #endif /* SDK_ARM7 */ 139 140 /****************************************************************************** 141 public function declaration 142 ******************************************************************************/ 143 144 s16 SND_GetPlayerLocalVariable(int playerNo, int varNo); 145 s16 SND_GetPlayerGlobalVariable(int varNo); 146 u32 SND_GetPlayerTickCounter(int playerNo); 147 148 u32 SND_GetPlayerStatus(void); 149 u32 SND_GetChannelStatus(void); 150 u32 SND_GetCaptureStatus(void); 151 152 BOOL SND_ReadChannelInfo(const SNDDriverInfo * driverInfo, int chNo, SNDChannelInfo * chInfo); 153 BOOL SND_ReadPlayerInfo(const SNDDriverInfo * driverInfo, int playerNo, 154 SNDPlayerInfo * playerInfo); 155 BOOL SND_ReadTrackInfo(const SNDDriverInfo * driverInfo, int playerNo, int trackNo, 156 SNDTrackInfo * trackInfo); 157 158 #ifdef SDK_ARM7 159 160 void SND_SetPlayerLocalVariable(int playerNo, int varNo, s16 var); 161 void SND_SetPlayerGlobalVariable(int varNo, s16 var); 162 void SND_UpdateSharedWork(void); 163 164 #endif /* SDK_ARM7 */ 165 166 /****************************************************************************** 167 private function declaration 168 ******************************************************************************/ 169 170 u32 SNDi_GetFinishedCommandTag(void); 171 172 #ifdef SDK_ARM9 173 174 void SNDi_InitSharedWork(SNDSharedWork *work); 175 176 #endif /* SDK_ARM9 */ 177 178 #ifdef __cplusplus 179 } /* extern "C" */ 180 #endif 181 182 #endif /* NITRO_SND_COMMON_WORK_H_ */ 183