Skip to content

Commit

Permalink
Write FM feedback to YM2612. Overwrites Algorithm!
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Nov 16, 2018
1 parent d8f68a5 commit e47e44d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ void synth_algorithm(u8 channel, u8 algorithm)
synth_writeFm(channel, 0xB0, algorithm);
}

void synth_feedback(u8 channel, u8 feedback) {
void synth_feedback(u8 channel, u8 feedback)
{
synth_writeFm(channel, 0xB0, feedback << 3);
}

void synth_operatorTotalLevel(u8 channel, u8 op, u8 totalLevel)
Expand Down
1 change: 1 addition & 0 deletions tests/test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int main(void)
cmocka_unit_test(test_synth_sets_total_level_reg_chan),
cmocka_unit_test(test_synth_sets_stereo_reg_chan),
cmocka_unit_test(test_synth_sets_algorithm),
cmocka_unit_test(test_synth_sets_feedback),
cmocka_unit_test(test_synth_sets_operator_total_level),

cmocka_unit_test(test_psg_chip_sets_note_on_psg),
Expand Down
15 changes: 15 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_feedback(u8 channel, u8 feedback);
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 @@ -126,6 +127,20 @@ static void test_synth_sets_algorithm(void** state)
}
}

static void test_synth_sets_feedback(void** state)
{
u8 feedback = 1;
for (u8 chan = 0; chan < 6; chan++) {
u8 regOffset = chan % 3;
u8 regPart = chan < 3 ? 0 : 1;
expect_value(__wrap_YM2612_writeReg, part, regPart);
expect_value(__wrap_YM2612_writeReg, reg, 0xB0 + regOffset);
expect_value(__wrap_YM2612_writeReg, data, feedback << 3);

__real_synth_feedback(chan, feedback);
}
}

static void test_synth_sets_operator_total_level(void** state)
{
u8 totalLevel = 50;
Expand Down

0 comments on commit e47e44d

Please sign in to comment.