21#ifndef SPU_REVERB_HELPERS_DEFINED
22#define SPU_REVERB_HELPERS_DEFINED
24#define SPU_REVERB_ROOM_SIZE 0x26c0u
25#define SPU_REVERB_ROOM_BASE (0x80000u - SPU_REVERB_ROOM_SIZE)
26#define SPU_REVERB_ROOM_BASE_REG (SPU_REVERB_ROOM_BASE >> 3)
28#define SPU_REVERB_INPUT_IMPULSE 1u
29#define SPU_REVERB_INPUT_STEADY_SINE 2u
30#define SPU_REVERB_PRESET_ROOM 1u
36static const uint8_t kAdpcmImpulseThenSilence[64]
__attribute__((aligned(4))) = {
37 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58static const uint16_t kReverbRoomPreset[32] = {
59 0x007d, 0x005b, 0x6d80, 0x54b8, 0xbed0, 0x0000, 0x0000, 0xba80,
60 0x5800, 0x5300, 0x04d6, 0x0333, 0x03f0, 0x0227, 0x0374, 0x01ef,
61 0x0334, 0x01b5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
62 0x0000, 0x0000, 0x01b4, 0x0136, 0x00b8, 0x005c, 0x8000, 0x8000,
65static void spu_reverb_apply_room_preset(
void) {
66 volatile uint16_t *regs = (
volatile uint16_t *)
SPU_REVERB;
67 for (
unsigned i = 0;
i < 32;
i++) regs[
i] = kReverbRoomPreset[
i];
70static void spu_zero_reverb_work_area(
void) {
73 if (chunk >
sizeof(s_reverb_work)) chunk =
sizeof(s_reverb_work);
74 for (
unsigned i = 0;
i < chunk;
i++) s_reverb_work[
i] = 0;
79static void spu_wait_reverb_windows(
unsigned windows) {
80 for (
unsigned i = 0;
i < windows;
i++) spu_wait_status_bit11_flip();
83static void run_reverb_room_work_area(
const uint8_t *sample64,
uint32_t inputKind,
unsigned syncWindows) {
87 for (
int i = 0;
i < 64;
i++) s_upload[
i] = sample64[
i];
88 for (
int i = 64;
i < 128;
i++) s_upload[
i] = 0xaa;
93 spu_zero_reverb_work_area();
95 spu_reverb_apply_room_preset();
108 SPU_CTRL = 0x8000 | 0x4000 | 0x0080;
113 spu_wait_status_bit11_flip();
115 spu_wait_reverb_windows(syncWindows);
132 s_reverb_hdr.
magic = 0x52564552u;
135 s_reverb_hdr.input = inputKind;
139 s_reverb_hdr.reserved = 0;
140 if (!is_pcdrv_init) {
144 int fd = PCcreat(name, 0);
146 PCwrite(fd, &s_reverb_hdr,
sizeof(s_reverb_hdr));
150#define SPU_ASSERT_REVERB_GOLDEN(NAME, INPUT, WINDOWS) spu_dump_reverb(#NAME ".test.rev", INPUT, WINDOWS)
152static int spu_compare_reverb_golden(
const char *name,
const void *capture,
const uint8_t *goldenFile,
155 const uint8_t *expected = goldenFile + hdr->
length;
163 const uint8_t *got = (
const uint8_t *)capture;
165 if (got[
i] != expected[
i]) {
167 name,
i, got[
i], expected[
i]);
175#ifdef SPU_REVERB_GOLDENS_AVAILABLE
176#define INCLUDE_REVERB_GOLDEN(NAME) \
178 ".pushsection .rodata\n" \
179 ".global " #NAME "\n" \
182 ".incbin \"" #NAME ".test.rev\"\n" \
184 extern const uint8_t NAME[]
186INCLUDE_REVERB_GOLDEN(room_impulse);
187INCLUDE_REVERB_GOLDEN(room_steady_sine);
188#define SPU_ASSERT_REVERB_GOLDEN(NAME, INPUT, WINDOWS) \
189 cester_assert_int_eq(0, spu_compare_reverb_golden(#NAME, s_reverb_work, NAME, INPUT, WINDOWS))
190#define SPU_REVERB_TEST CESTER_TEST
191#elif defined(SPU_DUMP)
192#define SPU_REVERB_TEST CESTER_TEST
194#define SPU_ASSERT_REVERB_GOLDEN(NAME, INPUT, WINDOWS) ((void)0)
195#define SPU_REVERB_TEST CESTER_SKIP_TEST
__attribute__((weak))
Definition clz.c:56
#define SPU_VOICES
Definition spu.h:42
#define SPU_REVERB_EN_HIGH
Definition spu.h:97
#define SPU_VOL_MAIN_LEFT
Definition spu.h:84
#define SPU_REVERB_ADDR
Definition spu.h:98
#define SPU_REVERB_RIGHT
Definition spu.h:87
#define SPU_KEY_OFF_LOW
Definition spu.h:90
#define SPU_KEY_OFF_HIGH
Definition spu.h:91
#define SPU_CTRL
Definition spu.h:104
#define SPU_VOL_MAIN_RIGHT
Definition spu.h:85
#define SPU_REVERB_EN_LOW
Definition spu.h:96
#define SPU_REVERB
Definition spu.h:82
#define SPU_REVERB_LEFT
Definition spu.h:86
ramsyscall_printf("=== e01_kseg1_reads_no_fill ===\n")
int i
Definition gte-regio.c:297
int off
Definition mkimage.py:49
spu_tests
Definition spu-adpcm-edge.c:189
#define SPU_UPLOAD_ADDR
Definition spu-capamp.c:31
#define SPU_REVERB_INPUT_IMPULSE
Definition spu-reverb.c:28
#define SPU_REVERB_ROOM_BASE_REG
Definition spu-reverb.c:26
#define SPU_REVERB_INPUT_STEADY_SINE
Definition spu-reverb.c:29
#define SPU_REVERB_ROOM_BASE
Definition spu-reverb.c:25
#define SPU_REVERB_ROOM_SIZE
Definition spu-reverb.c:24
#define SPU_REVERB_TEST
Definition spu-reverb.c:195
#define SPU_REVERB_PRESET_ROOM
Definition spu-reverb.c:30
#define SPU_ASSERT_REVERB_GOLDEN(NAME, INPUT, WINDOWS)
Definition spu-reverb.c:194
spu_write_sync(0x1000, s_upload, 128)
spu_read_sync(0x1000, s_readback, 0x80)
void uint32_t(classId, spec)