Skip to content

Commit

Permalink
Write OP Total Levels to FM chip
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Nov 14, 2018
1 parent 1ea6734 commit 2e34ab9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion tests/test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions tests/test_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 2e34ab9

Please sign in to comment.