From 2e34ab9d4ae7226e585ea4d1bd58350f21d20ea5 Mon Sep 17 00:00:00 2001 From: rhargreaves Date: Wed, 14 Nov 2018 23:38:03 +0000 Subject: [PATCH] Write OP Total Levels to FM chip --- src/synth.c | 1 + tests/test_main.c | 3 ++- tests/test_synth.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/synth.c b/src/synth.c index 7268b687..6a8b8c04 100644 --- a/src/synth.c +++ b/src/synth.c @@ -87,4 +87,5 @@ void synth_algorithm(u8 channel, u8 algorithm) void synth_operatorTotalLevel(u8 channel, u8 op, u8 totalLevel) { + synth_writeFm(channel, 0x40 + (op * 4), totalLevel); } diff --git a/tests/test_main.c b/tests/test_main.c index a429f4c7..bdfe77ce 100644 --- a/tests/test_main.c +++ b/tests/test_main.c @@ -46,7 +46,8 @@ int main(void) cmocka_unit_test(test_psg_chip_sets_attenuation), cmocka_unit_test(test_psg_chip_sets_note_on_psg_with_attenuation), cmocka_unit_test(test_interface_sets_fm_algorithm), - cmocka_unit_test(test_interface_sets_operator_total_level) + cmocka_unit_test(test_interface_sets_operator_total_level), + cmocka_unit_test(test_synth_sets_operator_total_level) }; return cmocka_run_group_tests(tests, NULL, NULL); diff --git a/tests/test_synth.c b/tests/test_synth.c index 27400b87..e4fc55a1 100644 --- a/tests/test_synth.c +++ b/tests/test_synth.c @@ -12,6 +12,7 @@ extern void __real_synth_pitch(u8 channel, u8 octave, u16 freqNumber); extern void __real_synth_totalLevel(u8 channel, u8 totalLevel); extern void __real_synth_stereo(u8 channel, u8 stereo); extern void __real_synth_algorithm(u8 channel, u8 algorithm); +extern void __real_synth_operatorTotalLevel(u8 channel, u8 op, u8 totalLevel); static void test_synth_init_sets_initial_registers(void** state) { @@ -124,3 +125,19 @@ static void test_synth_sets_algorithm(void** state) __real_synth_algorithm(chan, algorithm); } } + +static void test_synth_sets_operator_total_level(void** state) +{ + u8 totalLevel = 50; + for (u8 chan = 0; chan < 6; chan++) { + u8 regOffset = chan % 3; + u8 regPart = chan < 3 ? 0 : 1; + for (u8 op = 0; op < 4; op++) { + expect_value(__wrap_YM2612_writeReg, part, regPart); + expect_value(__wrap_YM2612_writeReg, reg, 0x40 + regOffset + (op * 4)); + expect_value(__wrap_YM2612_writeReg, data, totalLevel); + + __real_synth_operatorTotalLevel(chan, op, totalLevel); + } + } +}