Skip to content

Commit

Permalink
Merge pull request #2 from Kagamiin/bugfix/ch17-18-triggering
Browse files Browse the repository at this point in the history
Fix bug where channels 17 and 18 wouldn't trigger properly
  • Loading branch information
Kagamiin authored Oct 7, 2023
2 parents 58dff87 + 3394266 commit 92b58e2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions esfm_registers.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ ESFM_write_reg_native (esfm_chip *chip, uint16_t address, uint8_t data)
else if (address < KEY_ON_REGS_START + 20)
{
// Key-on channels 17 and 18 (each half)
size_t channel_idx = 16 + (address & 0x01);
bool second_half = address & 0x03;
size_t channel_idx = 16 + ((address & 0x02) >> 1);
bool second_half = address & 0x01;
esfm_channel *channel = &chip->channels[channel_idx];
if (second_half)
{
Expand Down Expand Up @@ -516,7 +516,7 @@ ESFM_readback_reg_native (esfm_chip *chip, uint16_t address)
else if (address < KEY_ON_REGS_START + 20)
{
// Key-on channels 17 and 18 (each half)
size_t channel_idx = 16 + (address & 0x03);
size_t channel_idx = 16 + ((address & 0x02) >> 1);
bool second_half = address & 0x01;
esfm_channel *channel = &chip->channels[channel_idx];
if (second_half)
Expand Down Expand Up @@ -801,11 +801,9 @@ ESFM_write_reg_buffered (esfm_chip *chip, uint16_t address, uint8_t data)
void
ESFM_write_reg_buffered_fast (esfm_chip *chip, uint16_t address, uint8_t data)
{
uint64_t timestamp;
esfm_write_buf *new_entry, *last_entry;
esfm_write_buf *new_entry;

new_entry = &chip->write_buf[chip->write_buf_end];
last_entry = &chip->write_buf[(chip->write_buf_end - 1) % ESFM_WRITEBUF_SIZE];

if (new_entry->valid) {
ESFM_write_reg(chip, new_entry->address, new_entry->data);
Expand Down

0 comments on commit 92b58e2

Please sign in to comment.