Commit 63ae2eba authored by Richard Gobeille's avatar Richard Gobeille
Browse files

audiolib: optimize modulo operations out of a few common OPL3 emulator functions

parent 56db3701
......@@ -37,17 +37,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef OPL_OPL3_H
#define OPL_OPL3_H
#include "compat.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
#ifndef OPL_ENABLE_STEREOEXT
#define OPL_ENABLE_STEREOEXT 1
#endif
#define OPL_WRITEBUF_SIZE 1024
EDUKE32_STATIC_ASSERT(isPow2(OPL_WRITEBUF_SIZE));
#define OPL_WRITEBUF_DELAY 2
typedef struct _opl3_slot opl3_slot;
......
......@@ -1233,7 +1233,7 @@ void OPL3_Generate(opl3_chip *chip, int16_t *buf)
}
writebuf->reg &= 0x1ff;
OPL3_WriteReg(chip, writebuf->reg, writebuf->data);
chip->writebuf_cur = (chip->writebuf_cur + 1) % OPL_WRITEBUF_SIZE;
chip->writebuf_cur = (chip->writebuf_cur + 1) & (OPL_WRITEBUF_SIZE - 1);
}
chip->writebuf_samplecnt++;
}
......@@ -1446,7 +1446,7 @@ void OPL3_WriteRegBuffered(opl3_chip *chip, uint16_t reg, uint8_t v)
{
OPL3_WriteReg(chip, writebuf->reg & 0x1ff, writebuf->data);
chip->writebuf_cur = (writebuf_last + 1) % OPL_WRITEBUF_SIZE;
chip->writebuf_cur = (writebuf_last + 1) & (OPL_WRITEBUF_SIZE - 1);
chip->writebuf_samplecnt = writebuf->time;
}
......@@ -1462,7 +1462,7 @@ void OPL3_WriteRegBuffered(opl3_chip *chip, uint16_t reg, uint8_t v)
writebuf->time = time1;
chip->writebuf_lasttime = time1;
chip->writebuf_last = (writebuf_last + 1) % OPL_WRITEBUF_SIZE;
chip->writebuf_last = (writebuf_last + 1) & (OPL_WRITEBUF_SIZE - 1);
}
void OPL3_GenerateStream(opl3_chip *chip, int16_t *sndptr, uint32_t numsamples)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment