Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/mips/tests/spu/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
TARGET = spu
USE_FUNCTION_SECTIONS = false
TYPE = ps-exe

SRCS = \
../uC-sdk-glue/BoardConsole.c \
../uC-sdk-glue/BoardInit.c \
../uC-sdk-glue/init.c \
\
../../../../third_party/uC-sdk/libc/src/cxx-glue.c \
../../../../third_party/uC-sdk/libc/src/errno.c \
../../../../third_party/uC-sdk/libc/src/initfini.c \
../../../../third_party/uC-sdk/libc/src/malloc.c \
../../../../third_party/uC-sdk/libc/src/qsort.c \
../../../../third_party/uC-sdk/libc/src/rand.c \
../../../../third_party/uC-sdk/libc/src/reent.c \
../../../../third_party/uC-sdk/libc/src/stdio.c \
../../../../third_party/uC-sdk/libc/src/string.c \
../../../../third_party/uC-sdk/libc/src/strto.c \
../../../../third_party/uC-sdk/libc/src/unistd.c \
../../../../third_party/uC-sdk/libc/src/xprintf.c \
../../../../third_party/uC-sdk/libc/src/xscanf.c \
../../../../third_party/uC-sdk/libc/src/yscanf.c \
../../../../third_party/uC-sdk/os/src/devfs.c \
../../../../third_party/uC-sdk/os/src/filesystem.c \
../../../../third_party/uC-sdk/os/src/fio.c \
../../../../third_party/uC-sdk/os/src/hash-djb2.c \
../../../../third_party/uC-sdk/os/src/init.c \
../../../../third_party/uC-sdk/os/src/osdebug.c \
../../../../third_party/uC-sdk/os/src/romfs.c \
../../../../third_party/uC-sdk/os/src/sbrk.c \


CPPFLAGS = -DNOFLOATINGPOINT
CPPFLAGS += -I.
CPPFLAGS += -I../../../../third_party/uC-sdk/libc/include
CPPFLAGS += -I../../../../third_party/uC-sdk/os/include
CPPFLAGS += -I../../../../third_party/libcester/include
CPPFLAGS += -I../../openbios/uC-sdk-glue

ifeq ($(PCSX_TESTS),true)
CPPFLAGS += -DPCSX_TESTS=1
endif

ifeq ($(SPU_DUMP),true)
CPPFLAGS += -DSPU_DUMP=1
endif

SRCS += \
../../common/syscalls/printf.s \
../../common/crt0/uC-sdk-crt0.s \
spu.c \

include ../../common.mk

# generate .test.pcm samples instead of running assertion
.PHONY: spu_dump
spu_dump:
$(MAKE) clean
$(MAKE) SPU_DUMP=true

Binary file added src/mips/tests/spu/loop_t0.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/loop_t1.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/silent.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/sine.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/sine_high.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/sine_low.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/sine_pitch_0800.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/sine_pitch_2000.test.pcm
Binary file not shown.
Binary file added src/mips/tests/spu/sine_pitch_3000.test.pcm
Binary file not shown.
53 changes: 53 additions & 0 deletions src/mips/tests/spu/spu-adpcm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ==========================================================================
// Validate ADPCM decoding, filtering, loop and carry-over
// ==========================================================================

CESTER_TEST(adpcm_decode_silent, spu_tests,
run_voice1_with_sample(kAdpcmSilent, 0x1000);
SPU_ASSERT_GOLDEN(silent);
)

CESTER_TEST(adpcm_decode_sinewave, spu_tests,
run_voice1_with_sample(kAdpcmSine, 0x1000);
SPU_ASSERT_GOLDEN(sine);
)

CESTER_TEST(adpcm_decode_sinewave_lowpitch, spu_tests,
run_voice1_with_sample(kAdpcmSine394Hz, 0x1000);
SPU_ASSERT_GOLDEN(sine_low);
)

CESTER_TEST(adpcm_decode_sinewave_highpitch, spu_tests,
run_voice1_with_sample(kAdpcmSine5512Hz, 0x1000);
SPU_ASSERT_GOLDEN(sine_high);
)

CESTER_TEST(adpcm_decode_tranglewave, spu_tests,
run_voice1_with_sample(kAdpcmTriangle, 0x1000);
SPU_ASSERT_GOLDEN(triangle);
)

CESTER_TEST(adpcm_decode_squarewave, spu_tests,
run_voice1_with_sample(kAdpcmSquare, 0x1000);
SPU_ASSERT_GOLDEN(square);
)

CESTER_TEST(adpcm_decode_with_loop, spu_tests,
run_voice1_with_sample(kAdpcmTriangle, 0x1000);
SPU_ASSERT_GOLDEN(loop_t0);

SPU_CTRL = 0x8000 | 0x4000;
SPU_VOL_MAIN_LEFT = 0x3fff; SPU_VOL_MAIN_RIGHT = 0x3fff;
SPU_KEY_OFF_LOW = 0xffff; SPU_KEY_OFF_HIGH = 0xffff;
spu_busy_wait(800000);
spu_wait_status_bit11_flip();

spu_voice1_keyon(SPU_UPLOAD_ADDR, 0x1000);
spu_busy_wait(15000000); // ~440 ms, the 112-sample buffer lasts ~5 ms
spu_wait_status_bit11_flip();
spu_read_sync(0x0800, s_capture, 1024);
SPU_ASSERT_GOLDEN(loop_t1);

SPU_KEY_OFF_LOW = 0xffff; SPU_KEY_OFF_HIGH = 0xffff;
muteSpu();
)
Loading
Loading