Nuked: wrbuf -> writebuf

This commit is contained in:
Jasmine Iwanek
2024-07-14 14:48:43 -04:00
parent e654d01bd0
commit 8056c1bc9a
2 changed files with 34 additions and 34 deletions

View File

@@ -24,8 +24,8 @@
#define OPL_ENABLE_STEREOEXT 0 #define OPL_ENABLE_STEREOEXT 0
#endif #endif
#define WRBUF_SIZE 1024 #define OPL_WRITEBUF_SIZE 1024
#define WRBUF_DELAY 1 #define OPL_WRITEBUF_DELAY 2
struct chan; struct chan;
struct chip; struct chip;
@@ -85,11 +85,11 @@ typedef struct chan {
uint8_t ch_num; uint8_t ch_num;
} opl3_channel; } opl3_channel;
typedef struct wrbuf { typedef struct _opl3_writebuf {
uint64_t time; uint64_t time;
uint16_t reg; uint16_t reg;
uint8_t data; uint8_t data;
} wrbuf_t; } opl3_writebuf;
typedef struct chip { typedef struct chip {
opl3_channel channel[18]; opl3_channel channel[18];
@@ -128,11 +128,11 @@ typedef struct chip {
int32_t oldsamples[4]; int32_t oldsamples[4];
int32_t samples[4]; int32_t samples[4];
uint64_t wrbuf_samplecnt; uint64_t writebuf_samplecnt;
uint32_t wrbuf_cur; uint32_t writebuf_cur;
uint32_t wrbuf_last; uint32_t writebuf_last;
uint64_t wrbuf_lasttime; uint64_t writebuf_lasttime;
wrbuf_t wrbuf[WRBUF_SIZE]; opl3_writebuf writebuf[OPL_WRITEBUF_SIZE];
} opl3_chip; } opl3_chip;
typedef struct { typedef struct {

View File

@@ -1060,7 +1060,7 @@ nuked_generate_4ch(void *priv, int32_t *buf4)
{ {
opl3_chip *chip = (opl3_chip *) priv; opl3_chip *chip = (opl3_chip *) priv;
opl3_channel *channel; opl3_channel *channel;
wrbuf_t *writebuf; opl3_writebuf *writebuf;
int16_t **out; int16_t **out;
int32_t mix[2]; int32_t mix[2];
int16_t accm; int16_t accm;
@@ -1166,7 +1166,7 @@ nuked_generate_4ch(void *priv, int32_t *buf4)
chip->eg_state ^= 1; chip->eg_state ^= 1;
while (writebuf = &chip->wrbuf[chip->wrbuf_cur], writebuf->time <= chip->wrbuf_samplecnt) { while (writebuf = &chip->writebuf[chip->writebuf_cur], writebuf->time <= chip->writebuf_samplecnt) {
if (!(writebuf->reg & 0x200)) if (!(writebuf->reg & 0x200))
break; break;
@@ -1174,10 +1174,10 @@ nuked_generate_4ch(void *priv, int32_t *buf4)
nuked_write_reg(chip, writebuf->reg, writebuf->data); nuked_write_reg(chip, writebuf->reg, writebuf->data);
chip->wrbuf_cur = (chip->wrbuf_cur + 1) % WRBUF_SIZE; chip->writebuf_cur = (chip->writebuf_cur + 1) % OPL_WRITEBUF_SIZE;
} }
chip->wrbuf_samplecnt++; chip->writebuf_samplecnt++;
} }
void void
@@ -1422,30 +1422,30 @@ nuked_write_reg_buffered(void *priv, uint16_t reg, uint8_t val)
opl3_chip *chip = (opl3_chip *) priv; opl3_chip *chip = (opl3_chip *) priv;
uint64_t time1; uint64_t time1;
uint64_t time2; uint64_t time2;
wrbuf_t *writebuf; opl3_writebuf *writebuf;
uint32_t writebuf_last; uint32_t writebuf_last;
writebuf_last = chip->wrbuf_last; writebuf_last = chip->writebuf_last;
writebuf = &chip->wrbuf[writebuf_last]; writebuf = &chip->writebuf[writebuf_last];
if (writebuf->reg & 0x0200) { if (writebuf->reg & 0x0200) {
nuked_write_reg(chip, writebuf->reg & 0x01ff, writebuf->data); nuked_write_reg(chip, writebuf->reg & 0x01ff, writebuf->data);
chip->wrbuf_cur = (writebuf_last + 1) % WRBUF_SIZE; chip->writebuf_cur = (writebuf_last + 1) % OPL_WRITEBUF_SIZE;
chip->wrbuf_samplecnt = writebuf->time; chip->writebuf_samplecnt = writebuf->time;
} }
writebuf->reg = reg | 0x0200; writebuf->reg = reg | 0x0200;
writebuf->data = val; writebuf->data = val;
time1 = chip->wrbuf_lasttime + WRBUF_DELAY; time1 = chip->writebuf_lasttime + OPL_WRITEBUF_DELAY;
time2 = chip->wrbuf_samplecnt; time2 = chip->writebuf_samplecnt;
if (time1 < time2) if (time1 < time2)
time1 = time2; time1 = time2;
writebuf->time = time1; writebuf->time = time1;
chip->wrbuf_lasttime = time1; chip->writebuf_lasttime = time1;
chip->wrbuf_last = (writebuf_last + 1) % WRBUF_SIZE; chip->writebuf_last = (writebuf_last + 1) % OPL_WRITEBUF_SIZE;
} }
void void