Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
8.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**
  2. * @file
  3. * Common definitions for libsd on the EE and IOP
  4. */
  5. #ifndef __LIBSD_COMMON_H__
  6. #define __LIBSD_COMMON_H__
  7. #include <tamtypes.h>
  8. #define SD_VOICE(_core,_v) ((_core)|((_v)<<1))
  9. /* Macros to set ADSR: i=increment, d=decrement */
  10. #define SD_ADSR_AR_LINEARi 0
  11. #define SD_ADSR_AR_EXPi 1
  12. #define SD_ADSR_SR_LINEARi 0
  13. #define SD_ADSR_SR_LINEARd 2
  14. #define SD_ADSR_SR_EXPi 4
  15. #define SD_ADSR_SR_EXPd 6
  16. #define SD_ADSR_RR_LINEARd 0
  17. #define SD_ADSR_RR_EXPd 1
  18. #define SD_SET_ADSR1(_arm, _ar, _dr, _sl) ((((_arm)&1)<<15) | (((_ar)&0x7f)<<8) | (((_dr)&0xf)<<4) | ((_sl)&0xf))
  19. #define SD_SET_ADSR2(_srm, _sr, _rrm, _rr) ((((_srm)&7)<<13) | (((_sr)&0x7f)<<6) | (((_rrm)&1)<<5) | ((_rr)&0x1f))
  20. /* Parameters */
  21. #define SD_VPARAM_VOLL (0x00<<8)
  22. #define SD_VPARAM_VOLR (0x01<<8)
  23. #define SD_VPARAM_PITCH (0x02<<8)
  24. #define SD_VPARAM_ADSR1 (0x03<<8)
  25. #define SD_VPARAM_ADSR2 (0x04<<8)
  26. #define SD_VPARAM_ENVX (0x05<<8)
  27. #define SD_VPARAM_VOLXL (0x06<<8)
  28. #define SD_VPARAM_VOLXR (0x07<<8)
  29. #define SD_PARAM_MMIX (0x08<<8)
  30. #define SD_PARAM_MVOLL ((0x09<<8)|0x80)
  31. #define SD_PARAM_MVOLR ((0x0A<<8)|0x80)
  32. #define SD_PARAM_EVOLL ((0x0B<<8)|0x80)
  33. #define SD_PARAM_EVOLR ((0x0C<<8)|0x80)
  34. #define SD_PARAM_AVOLL ((0x0D<<8)|0x80)
  35. #define SD_PARAM_AVOLR ((0x0E<<8)|0x80)
  36. #define SD_PARAM_BVOLL ((0x0F<<8)|0x80)
  37. #define SD_PARAM_BVOLR ((0x10<<8)|0x80)
  38. #define SD_PARAM_MVOLXL ((0x11<<8)|0x80)
  39. #define SD_PARAM_MVOLXR ((0x12<<8)|0x80)
  40. /* Transfer modes */
  41. #define SD_TRANS_WRITE 0
  42. #define SD_TRANS_READ 1
  43. #define SD_TRANS_STOP 2
  44. #define SD_TRANS_WRITE_FROM 3 /* only for block */
  45. #define SD_TRANS_LOOP 0x10 /* only for block*/
  46. #define SD_TRANS_MODE_DMA 0
  47. #define SD_TRANS_MODE_IO 8
  48. // Reverb
  49. #define SD_EFFECT_MODE_OFF 0x0
  50. #define SD_EFFECT_MODE_ROOM 0x1
  51. #define SD_EFFECT_MODE_STUDIO_1 0x2
  52. #define SD_EFFECT_MODE_STUDIO_2 0x3
  53. #define SD_EFFECT_MODE_STUDIO_3 0x4
  54. #define SD_EFFECT_MODE_HALL 0x5
  55. #define SD_EFFECT_MODE_SPACE 0x6
  56. #define SD_EFFECT_MODE_ECHO 0x7
  57. #define SD_EFFECT_MODE_DELAY 0x8
  58. #define SD_EFFECT_MODE_PIPE 0x9
  59. #define SD_EFFECT_MODE_CLEAR 0x100
  60. // CoreAttr
  61. #define SD_CORE_EFFECT_ENABLE 0x2
  62. #define SD_CORE_IRQ_ENABLE 0x4
  63. #define SD_CORE_MUTE_ENABLE 0x6
  64. #define SD_CORE_NOISE_CLK 0x8
  65. #define SD_CORE_SPDIF_MODE 0xA
  66. /* Switches */
  67. #define SD_SWITCH_PMON (0x13<<8)
  68. #define SD_SWITCH_NON (0x14<<8)
  69. #define SD_SWITCH_KON (0x15<<8)
  70. #define SD_SWITCH_KEYDOWN SD_SWITCH_KON //For backward-compatibility
  71. #define SD_SWITCH_KOFF (0x16<<8)
  72. #define SD_SWITCH_KEYUP SD_SWITCH_KOFF //For backward-compatibility
  73. #define SD_SWITCH_ENDX (0x17<<8)
  74. #define SD_SWITCH_VMIXL (0x18<<8)
  75. #define SD_SWITCH_VMIXEL (0x19<<8)
  76. #define SD_SWITCH_VMIXR (0x1A<<8)
  77. #define SD_SWITCH_VMIXER (0x1B<<8)
  78. /* Addresses */
  79. #define SD_ADDR_ESA (0x1C<<8)
  80. #define SD_ADDR_EEA (0x1D<<8)
  81. #define SD_ADDR_TSA (0x1E<<8)
  82. #define SD_ADDR_IRQA (0x1F<<8)
  83. #define SD_VADDR_SSA (0x20<<8)
  84. #define SD_VADDR_LSAX (0x21<<8)
  85. #define SD_VADDR_NAX (0x22<<8)
  86. // SD_CORE_ATTR Macros
  87. #define SD_SPU2_ON (1 << 15)
  88. #define SD_MUTE (1 << 14)
  89. #define SD_NOISE_CLOCK(c) ((c & 0x1F) << 8) // Bits 8..13 is noise clock
  90. #define SD_ENABLE_EFFECTS (1 << 7)
  91. #define SD_ENABLE_IRQ (1 << 6)
  92. #define SD_DMA_IO (1 << 4)
  93. #define SD_DMA_WRITE (2 << 4)
  94. #define SD_DMA_READ (3 << 4)
  95. #define SD_DMA_IN_PROCESS (3 << 4) // If either of the DMA bits are set, the DMA channel is occupied.
  96. #define SD_CORE_DMA (3 << 4)
  97. #define SD_ENABLE_EX_INPUT (1 << 0) // Enable external input, Not sure.
  98. // SD_C_STATX
  99. #define SD_IO_IN_PROCESS (1 << 10)
  100. // Batch
  101. #define SD_BATCH_SETPARAM 0x1
  102. #define SD_BATCH_SETSWITCH 0x2
  103. #define SD_BATCH_SETADDR 0x3
  104. #define SD_BATCH_SETCORE 0x4
  105. #define SD_BATCH_WRITEIOP 0x5
  106. #define SD_BATCH_WRITEEE 0x6
  107. #define SD_BATCH_EERETURN 0x7
  108. #define SD_BATCH_GETPARAM 0x10
  109. #define SD_BATCH_GETSWITCH 0x12
  110. #define SD_BATCH_GETADDR 0x13
  111. #define SD_BATCH_GETCORE 0x14
  112. #define ADPCM_LOOP_START 4 /* Set on first block of looped data */
  113. #define ADPCM_LOOP 2 /* Set on all blocks (?that are inside the loop?) */
  114. #define ADPCM_LOOP_END 1 /* Set on last block to loop */
  115. typedef struct
  116. {
  117. u16 func;
  118. u16 entry;
  119. u32 value;
  120. } sceSdBatch;
  121. typedef struct
  122. {
  123. int core;
  124. int mode;
  125. short depth_L;
  126. short depth_R;
  127. int delay;
  128. int feedback;
  129. } sceSdEffectAttr;
  130. typedef int (*sceSdSpu2IntrHandler)(int, void *);
  131. typedef int (*sceSdTransIntrHandler)(int, void *);
  132. typedef int (*SdIntrCallback)(void *data);
  133. #ifdef __cplusplus
  134. extern "C" {
  135. #endif
  136. int sceSdQuit();
  137. int sceSdInit(int flag);
  138. SdIntrCallback sceSdSetIRQCallback(SdIntrCallback cb);
  139. SdIntrCallback sceSdSetTransCallback(s32 core, SdIntrCallback cb);
  140. void sceSdSetParam(u16 entry, u16 value);
  141. u16 sceSdGetParam(u16 entry);
  142. void sceSdSetCoreAttr(u16 entry, u16 value );
  143. u16 sceSdGetCoreAttr(u16 entry );
  144. int sceSdClearEffectWorkArea (int core, int channel, int effect_mode);
  145. void sceSdSetAddr(u16 entry, u32 value);
  146. u32 sceSdGetAddr(u16 entry );
  147. void sceSdSetSwitch(u16 entry, u32 value);
  148. u32 sceSdGetSwitch(u16 entry );
  149. u16 sceSdNote2Pitch (u16 center_note, u16 center_fine, u16 note, s16 fine);
  150. u16 sceSdPitch2Note (u16 center_note, u16 center_fine, u16 pitch);
  151. int sceSdSetEffectAttr (int core, sceSdEffectAttr *attr );
  152. void sceSdGetEffectAttr (int core, sceSdEffectAttr *attr );
  153. int sceSdProcBatch(sceSdBatch *batch, u32 *rets, u32 num);
  154. int sceSdProcBatchEx(sceSdBatch *batch, u32 *rets, u32 num, u32 voice);
  155. int sceSdVoiceTrans(s16 chan, u16 mode, u8 *iopaddr, u32 *spuaddr, u32 size);
  156. int sceSdBlockTrans(s16 chan, u16 mode, u8 *iopaddr, u32 size, ...);
  157. u32 sceSdVoiceTransStatus (s16 channel, s16 flag);
  158. u32 sceSdBlockTransStatus (s16 channel, s16 flag);
  159. sceSdTransIntrHandler sceSdSetTransIntrHandler(int channel, sceSdTransIntrHandler func, void *arg);
  160. sceSdSpu2IntrHandler sceSdSetSpu2IntrHandler(sceSdSpu2IntrHandler func, void *arg);
  161. void *sceSdGetTransIntrHandlerArgument(int arg);
  162. void *sceSdGetSpu2IntrHandlerArgument();
  163. int sceSdStopTrans(int channel);
  164. int sceSdCleanEffectWorkArea(int core, int channel, int effect_mode);
  165. int sceSdSetEffectMode(int core, sceSdEffectAttr *param);
  166. int sceSdSetEffectModeParams(int core, sceSdEffectAttr *attr);
  167. #ifdef __cplusplus
  168. }
  169. #endif
  170. //Backwards compatibility definitions
  171. #define BATCH_SETPARAM SD_BATCH_SETPARAM
  172. #define BATCH_SETSWITCH SD_BATCH_SETSWITCH
  173. #define BATCH_SETADDR SD_BATCH_SETADDR
  174. #define BATCH_SETCORE SD_BATCH_SETCORE
  175. #define BATCH_WRITEIOP SD_BATCH_WRITEIOP
  176. #define BATCH_WRITEEE SD_BATCH_WRITEEE
  177. #define BATCH_EERETURN SD_BATCH_EERETURN
  178. #define BATCH_GETPARAM SD_BATCH_GETPARAM
  179. #define BATCH_GETSWITCH SD_BATCH_GETSWITCH
  180. #define BATCH_GETADDR SD_BATCH_GETADDR
  181. #define BATCH_GETCORE SD_BATCH_GETCORE
  182. #define SD_BLOCK_TRANS_WRITE SD_TRANS_WRITE
  183. #define SD_BLOCK_TRANS_READ SD_TRANS_READ
  184. #define SD_BLOCK_TRANS_STOP SD_TRANS_STOP
  185. #define SD_BLOCK_TRANS_WRITE_FROM SD_TRANS_WRITE_FROM
  186. #define SD_BLOCK_TRANS_LOOP SD_TRANS_LOOP
  187. #define SD_VOICE_TRANS_WRITE SD_TRANS_WRITE
  188. #define SD_VOICE_TRANS_READ SD_TRANS_READ
  189. #define SD_VOICE_TRANS_STOP SD_TRANS_STOP
  190. #define SD_VOICE_TRANS_MODE_DMA SD_TRANS_MODE_DMA
  191. #define SD_VOICE_TRANS_MODE_IO SD_TRANS_MODE_IO
  192. #define SdBatch sceSdBatch
  193. #define SdEffectAttr sceSdEffectAttr
  194. #define SdSpu2IntrHandler sceSdSpu2IntrHandler
  195. #define SdTransIntrHandler sceSdTransIntrHandler
  196. #define IntrCallback SdIntrCallback
  197. #define SdQuit sceSdQuit
  198. #define SdInit sceSdInit
  199. #define SdSetIRQCallback sceSdSetIRQCallback
  200. #define SdSetTransCallback sceSdSetTransCallback
  201. #define SdSetParam sceSdSetParam
  202. #define SdGetParam sceSdGetParam
  203. #define SdSetCoreAttr sceSdSetCoreAttr
  204. #define SdGetCoreAttr sceSdGetCoreAttr
  205. #define SdClearEffectWorkArea sceSdClearEffectWorkArea
  206. #define SdSetAddr sceSdSetAddr
  207. #define SdGetAddr sceSdGetAddr
  208. #define SdSetSwitch sceSdSetSwitch
  209. #define SdGetSwitch sceSdGetSwitch
  210. #define SdNote2Pitch sceSdNote2Pitch
  211. #define SdPitch2Note sceSdPitch2Note
  212. #define SdSetEffectAttr sceSdSetEffectAttr
  213. #define SdGetEffectAttr sceSdGetEffectAttr
  214. #define SdProcBatch sceSdProcBatch
  215. #define SdProcBatchEx sceSdProcBatchEx
  216. #define SdVoiceTrans sceSdVoiceTrans
  217. #define SdBlockTrans sceSdBlockTrans
  218. #define SdVoiceTransStatus sceSdVoiceTransStatus
  219. #define SdBlockTransStatus sceSdBlockTransStatus
  220. #define SdSetTransIntrHandler sceSdSetTransIntrHandler
  221. #define SdSetSpu2IntrHandler sceSdSetSpu2IntrHandler
  222. #define SdGetTransIntrHandlerArgument sceSdGetTransIntrHandlerArgument
  223. #define SdGetSpu2IntrHandlerArgument sceSdGetSpu2IntrHandlerArgument
  224. #define SdStopTrans sceSdStopTrans
  225. #define SdCleanEffectWorkArea sceSdCleanEffectWorkArea
  226. #define SdSetEffectMode sceSdSetEffectMode
  227. #define SdSetEffectModeParams sceSdSetEffectModeParams
  228. #endif /* __LIBSD_COMMON_H__ */