Skip to content

Commit

Permalink
Change frequency expectations to single 16-bit value
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Feb 19, 2025
1 parent f244a18 commit b0c7538
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
7 changes: 3 additions & 4 deletions tests/mocks/mock_ym2612.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ void _expect_ym2612_note_off(u8 chan, const char* const file, const int line)
_expect_ym2612_write_reg(0, YM_KEY_ON_OFF, KEY_ON_OFF_CH_INDEX(chan), file, line);
}

void _expect_ym2612_write_frequency(
u8 chan, u16 msb, u16 lsb, const char* const file, const int line)
void _expect_ym2612_write_frequency(u8 chan, u16 freqNumBlk, const char* const file, const int line)
{
_expect_ym2612_write_channel(chan, YM_BASE_FREQ_MSB_BLK, msb, file, line);
_expect_ym2612_write_channel(chan, YM_BASE_FREQ_LSB, lsb, file, line);
_expect_ym2612_write_channel(chan, YM_BASE_FREQ_MSB_BLK, (freqNumBlk >> 8), file, line);
_expect_ym2612_write_channel(chan, YM_BASE_FREQ_LSB, (freqNumBlk & 0xFF), file, line);
}

void _expect_ym2612_write_frequency_any_data(u8 chan, const char* const file, const int line)
Expand Down
6 changes: 3 additions & 3 deletions tests/mocks/mock_ym2612.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void _expect_ym2612_write_all_operators_any_data(
void _expect_ym2612_note_on(u8 chan, const char* const file, const int line);
void _expect_ym2612_note_off(u8 chan, const char* const file, const int line);
void _expect_ym2612_write_frequency(
u8 chan, u16 msb, u16 lsb, const char* const file, const int line);
u8 chan, u16 freqNumBlk, const char* const file, const int line);
void _expect_ym2612_write_frequency_any_data(u8 chan, const char* const file, const int line);
void _expect_ym2612_write_operator_volumes(
u8 chan, const u8* volumes, u8 count, const char* const file, const int line);
Expand All @@ -49,8 +49,8 @@ void _expect_ym2612_write_operator_volumes(
_expect_ym2612_write_all_operators_any_data(chan, baseReg, __FILE__, __LINE__)
#define expect_ym2612_note_on(chan) _expect_ym2612_note_on(chan, __FILE__, __LINE__)
#define expect_ym2612_note_off(chan) _expect_ym2612_note_off(chan, __FILE__, __LINE__)
#define expect_ym2612_write_frequency(chan, msb, lsb) \
_expect_ym2612_write_frequency(chan, msb, lsb, __FILE__, __LINE__)
#define expect_ym2612_write_frequency(chan, freqNumBlk) \
_expect_ym2612_write_frequency(chan, freqNumBlk, __FILE__, __LINE__)
#define expect_ym2612_write_frequency_any_data(chan) \
_expect_ym2612_write_frequency_any_data(chan, __FILE__, __LINE__)
#define expect_ym2612_write_operator_volumes(chan, volumes, count) \
Expand Down
34 changes: 17 additions & 17 deletions tests/system/test_e2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void test_midi_note_on_event_sent_to_ym2612(void** state)
{
stub_everdrive_as_present();
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, 127);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();
}
Expand All @@ -69,12 +69,12 @@ void test_polyphonic_midi_sent_to_separate_ym2612_channels(void** state)
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, TEST_VELOCITY_MAX);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 49, TEST_VELOCITY_MAX);
expect_ym2612_write_frequency(1, 0x1A, 0xA9);
expect_ym2612_write_frequency(1, 0x1AA9);
expect_ym2612_note_on(1);
midi_receiver_read();
}
Expand Down Expand Up @@ -103,7 +103,7 @@ void test_general_midi_reset_sysex_stops_all_notes(void** state)

// FM note
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, noteOnKey, TEST_VELOCITY_MAX);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();

Expand Down Expand Up @@ -294,17 +294,17 @@ void test_midi_last_note_played_priority_respected_on_fm(void** state)
{
stub_everdrive_as_present();
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, 127);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 50, 127);
expect_ym2612_write_frequency(0, 0x1A, 0xD2);
expect_ym2612_write_frequency(0, 0x1AD2);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_off(TEST_MIDI_CHANNEL_1, 50);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();
}
Expand All @@ -315,17 +315,17 @@ void test_midi_last_note_played_remembers_velocity_on_fm(void** state)
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, 100);
const u8 volumes[] = { 0x27, 0x04, 0x24, 0x04 };
expect_ym2612_write_operator_volumes(0, volumes, 4);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 50, 100);
expect_ym2612_write_frequency(0, 0x1A, 0xD2);
expect_ym2612_write_frequency(0, 0x1AD2);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_off(TEST_MIDI_CHANNEL_1, 50);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();
}
Expand All @@ -334,12 +334,12 @@ void test_midi_last_note_played_cleared_when_released_on_fm(void** state)
{
stub_everdrive_as_present();
stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, 127);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 50, 127);
expect_ym2612_write_frequency(0, 0x1A, 0xD2);
expect_ym2612_write_frequency(0, 0x1AD2);
expect_ym2612_note_on(0);
midi_receiver_read();

Expand Down Expand Up @@ -421,21 +421,21 @@ void test_midi_changing_program_retains_volume(void** state)
expect_ym2612_write_channel_any_data(chan, 0x68);
expect_ym2612_write_channel_any_data(chan, 0x78);
expect_ym2612_write_channel_any_data(chan, 0x88);
expect_ym2612_write_channel(chan, 0x48, 0x7F); // output operator mute
expect_ym2612_write_channel(chan, 0x48, YM_TOTAL_LEVEL_SILENCE);
expect_ym2612_write_channel_any_data(chan, 0x98);
expect_ym2612_write_channel_any_data(chan, 0x34);
expect_ym2612_write_channel_any_data(chan, 0x54);
expect_ym2612_write_channel_any_data(chan, 0x64);
expect_ym2612_write_channel_any_data(chan, 0x74);
expect_ym2612_write_channel_any_data(chan, 0x84);
expect_ym2612_write_channel(chan, 0x44, 0x7f); // output operator mute
expect_ym2612_write_channel(chan, 0x44, YM_TOTAL_LEVEL_SILENCE);
expect_ym2612_write_channel_any_data(chan, 0x94);
expect_ym2612_write_channel_any_data(chan, 0x3C);
expect_ym2612_write_channel_any_data(chan, 0x5C);
expect_ym2612_write_channel_any_data(chan, 0x6C);
expect_ym2612_write_channel_any_data(chan, 0x7C);
expect_ym2612_write_channel_any_data(chan, 0x8C);
expect_ym2612_write_channel(chan, 0x4C, 0x7f); // output operator mute
expect_ym2612_write_channel(chan, 0x4C, YM_TOTAL_LEVEL_SILENCE);
expect_ym2612_write_channel_any_data(chan, 0x9C);
midi_receiver_read();
}
Expand All @@ -450,14 +450,14 @@ void test_midi_portamento_glides_note(void** state)
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 48, 127);
expect_ym2612_write_frequency(0, 0x1A, 0x84);
expect_ym2612_write_frequency(0, 0x1A84);
expect_ym2612_note_on(0);
midi_receiver_read();

stub_usb_receive_note_on(TEST_MIDI_CHANNEL_1, 58, 127);
midi_receiver_read();

expect_ym2612_write_frequency(0, 0x1A, 0x87);
expect_ym2612_write_frequency(0, 0x1A87);
scheduler_vsync();
scheduler_tick();
for (u16 i = 0; i < 99; i++) {
Expand Down

0 comments on commit b0c7538

Please sign in to comment.