Nugget
spu.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2019 PCSX-Redux authors
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 
27 #pragma once
28 
29 #include "hwregs.h"
30 
31 struct SPUVoice {
32  uint16_t volumeLeft;
33  uint16_t volumeRight;
34  uint16_t sampleRate;
35  uint16_t sampleStartAddr;
36  uint16_t ad;
37  uint16_t sr;
38  uint16_t currentVolume;
39  uint16_t sampleRepeatAddr;
40 };
41 
42 #define SPU_VOICES ((volatile struct SPUVoice *)0x1f801c00)
43 
44 #define SPU_VOL_MAIN_LEFT HW_U16(0x1f801d80)
45 #define SPU_VOL_MAIN_RIGHT HW_U16(0x1f801d82)
46 #define SPU_REVERB_LEFT HW_U16(0x1f801d84)
47 #define SPU_REVERB_RIGHT HW_U16(0x1f801d86)
48 #define SPU_KEY_ON_LOW HW_U16(0x1f801d88)
49 #define SPU_KEY_ON_HIGH HW_U16(0x1f801d8a)
50 #define SPU_KEY_OFF_LOW HW_U16(0x1f801d8c)
51 #define SPU_KEY_OFF_HIGH HW_U16(0x1f801d8e)
52 #define SPU_PITCH_MOD_LOW HW_U16(0x1f801d90)
53 #define SPU_PITCH_MOD_HIGH HW_U16(0x1f801d92)
54 #define SPU_NOISE_EN_LOW HW_U16(0x1f801d94)
55 #define SPU_NOISE_EN_HIGH HW_U16(0x1f801d96)
56 #define SPU_REVERB_EN_LOW HW_U16(0x1f801d98)
57 #define SPU_REVERB_EN_HIGH HW_U16(0x1f801d9a)
58 
59 #define SPU_RAM_DTA HW_U16(0x1f801da6)
60 #define SPU_CTRL HW_U16(0x1f801daa)
61 #define SPU_RAM_DTC HW_U16(0x1f801dac)
62 #define SPU_STATUS HW_U16(0x1f801dae)
63 #define SPU_VOL_CD_LEFT HW_U16(0x1f801db0)
64 #define SPU_VOL_CD_RIGHT HW_U16(0x1f801db2)
65 #define SPU_VOL_EXT_LEFT HW_U16(0x1f801db4)
66 #define SPU_VOL_EXT_RIGHT HW_U16(0x1f801db6)
67 
68 static __inline__ void muteSpu() {
69  SPU_REVERB_RIGHT = 0;
70  SPU_REVERB_LEFT = 0;
71  SPU_VOL_MAIN_RIGHT = 0;
72  SPU_VOL_MAIN_LEFT = 0;
73 }
Definition: spu.h:31