aboutsummaryrefslogtreecommitdiff
path: root/src/chips/nuked
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2023-11-13 03:54:19 +0300
committerWohlstand <admin@wohlnet.ru>2023-11-13 03:54:19 +0300
commit91fc43f186f4775f09c8d97239b9713d25da9603 (patch)
treed6e5b7d60cb75348bb3d4a6afe26eee386ee0082 /src/chips/nuked
parent9bc7b8c0f4c423fd957c63a5f486ac626844662e (diff)
downloadlibADLMIDI-91fc43f186f4775f09c8d97239b9713d25da9603.tar.gz
libADLMIDI-91fc43f186f4775f09c8d97239b9713d25da9603.tar.bz2
libADLMIDI-91fc43f186f4775f09c8d97239b9713d25da9603.zip
Synchronized updates of Nuked OPL3 emulator from OPL3BE
Diffstat (limited to 'src/chips/nuked')
-rw-r--r--src/chips/nuked/nukedopl3.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/chips/nuked/nukedopl3.c b/src/chips/nuked/nukedopl3.c
index af4285c..55cf8bb 100644
--- a/src/chips/nuked/nukedopl3.c
+++ b/src/chips/nuked/nukedopl3.c
@@ -353,7 +353,7 @@ static int16_t OPL3_EnvelopeCalcExp(uint32_t level)
{
level = 0x1fff;
}
- return (exprom[level & 0xff] << 1) >> (level >> 8);
+ return (exprom[level & 0xffu] << 1) >> (level >> 8);
}
static int16_t OPL3_EnvelopeCalcSin0(uint16_t phase, uint16_t envelope)
@@ -367,11 +367,11 @@ static int16_t OPL3_EnvelopeCalcSin0(uint16_t phase, uint16_t envelope)
}
if (phase & 0x100)
{
- out = logsinrom[(phase & 0xff) ^ 0xff];
+ out = logsinrom[(phase & 0xffu) ^ 0xffu];
}
else
{
- out = logsinrom[phase & 0xff];
+ out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3)) ^ neg;
}
@@ -386,11 +386,11 @@ static int16_t OPL3_EnvelopeCalcSin1(uint16_t phase, uint16_t envelope)
}
else if (phase & 0x100)
{
- out = logsinrom[(phase & 0xff) ^ 0xff];
+ out = logsinrom[(phase & 0xffu) ^ 0xffu];
}
else
{
- out = logsinrom[phase & 0xff];
+ out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
@@ -401,11 +401,11 @@ static int16_t OPL3_EnvelopeCalcSin2(uint16_t phase, uint16_t envelope)
phase &= 0x3ff;
if (phase & 0x100)
{
- out = logsinrom[(phase & 0xff) ^ 0xff];
+ out = logsinrom[(phase & 0xffu) ^ 0xffu];
}
else
{
- out = logsinrom[phase & 0xff];
+ out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
@@ -420,7 +420,7 @@ static int16_t OPL3_EnvelopeCalcSin3(uint16_t phase, uint16_t envelope)
}
else
{
- out = logsinrom[phase & 0xff];
+ out = logsinrom[phase & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
@@ -440,11 +440,11 @@ static int16_t OPL3_EnvelopeCalcSin4(uint16_t phase, uint16_t envelope)
}
else if (phase & 0x80)
{
- out = logsinrom[((phase ^ 0xff) << 1) & 0xff];
+ out = logsinrom[((phase ^ 0xffu) << 1u) & 0xffu];
}
else
{
- out = logsinrom[(phase << 1) & 0xff];
+ out = logsinrom[(phase << 1u) & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3)) ^ neg;
}
@@ -459,11 +459,11 @@ static int16_t OPL3_EnvelopeCalcSin5(uint16_t phase, uint16_t envelope)
}
else if (phase & 0x80)
{
- out = logsinrom[((phase ^ 0xff) << 1) & 0xff];
+ out = logsinrom[((phase ^ 0xffu) << 1u) & 0xffu];
}
else
{
- out = logsinrom[(phase << 1) & 0xff];
+ out = logsinrom[(phase << 1u) & 0xffu];
}
return OPL3_EnvelopeCalcExp(out + (envelope << 3));
}
@@ -515,7 +515,7 @@ enum envelope_gen_num
static void OPL3_EnvelopeUpdateKSL(opl3_slot *slot)
{
- int16_t ksl = (kslrom[slot->channel->f_num >> 6] << 2)
+ int16_t ksl = (kslrom[slot->channel->f_num >> 6u] << 2)
- ((0x08 - slot->channel->block) << 5);
if (ksl < 0)
{
@@ -610,7 +610,7 @@ static void OPL3_EnvelopeCalc(opl3_slot *slot)
}
else
{
- shift = (rate_hi & 0x03) + eg_incstep[rate_lo][slot->chip->timer & 0x03];
+ shift = (rate_hi & 0x03) + eg_incstep[rate_lo][slot->chip->timer & 0x03u];
if (shift & 0x04)
{
shift = 0x03;
@@ -1235,7 +1235,7 @@ static void OPL3_ChannelWriteD0(opl3_channel* channel, uint8_t data)
{
if (channel->chip->stereoext)
{
- channel->leftpan = panpot_lut[data ^ 0xff];
+ channel->leftpan = panpot_lut[data ^ 0xffu];
channel->rightpan = panpot_lut[data];
}
}
@@ -1303,15 +1303,15 @@ static void OPL3_ChannelSet4Op(opl3_chip *chip, uint8_t data)
if ((data >> bit) & 0x01)
{
chip->channel[chnum].chtype = ch_4op;
- chip->channel[chnum + 3].chtype = ch_4op2;
+ chip->channel[chnum + 3u].chtype = ch_4op2;
OPL3_ChannelUpdateAlg(&chip->channel[chnum]);
}
else
{
chip->channel[chnum].chtype = ch_2op;
- chip->channel[chnum + 3].chtype = ch_2op;
+ chip->channel[chnum + 3u].chtype = ch_2op;
OPL3_ChannelUpdateAlg(&chip->channel[chnum]);
- OPL3_ChannelUpdateAlg(&chip->channel[chnum+3]);
+ OPL3_ChannelUpdateAlg(&chip->channel[chnum + 3u]);
}
}
}
@@ -1337,7 +1337,7 @@ static void OPL3_ProcessSlot(opl3_slot *slot)
OPL3_SlotGenerate(slot);
}
-void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4)
+inline void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4)
{
opl3_channel *channel;
opl3_writebuf *writebuf;
@@ -1551,16 +1551,16 @@ void OPL3_Reset(opl3_chip *chip, uint32_t samplerate)
channel = &chip->channel[channum];
local_ch_slot = ch_slot[channum];
channel->slotz[0] = &chip->slot[local_ch_slot];
- channel->slotz[1] = &chip->slot[local_ch_slot + 3];
+ channel->slotz[1] = &chip->slot[local_ch_slot + 3u];
chip->slot[local_ch_slot].channel = channel;
- chip->slot[local_ch_slot + 3].channel = channel;
+ chip->slot[local_ch_slot + 3u].channel = channel;
if ((channum % 9) < 3)
{
- channel->pair = &chip->channel[channum + 3];
+ channel->pair = &chip->channel[channum + 3u];
}
else if ((channum % 9) < 6)
{
- channel->pair = &chip->channel[channum - 3];
+ channel->pair = &chip->channel[channum - 3u];
}
channel->chip = chip;
channel->out[0] = &chip->zeromod;
@@ -1644,43 +1644,43 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v)
break;
case 0x20:
case 0x30:
- if (ad_slot[regm & 0x1f] >= 0)
+ if (ad_slot[regm & 0x1fu] >= 0)
{
- OPL3_SlotWrite20(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
+ OPL3_SlotWrite20(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0x40:
case 0x50:
- if (ad_slot[regm & 0x1f] >= 0)
+ if (ad_slot[regm & 0x1fu] >= 0)
{
- OPL3_SlotWrite40(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
+ OPL3_SlotWrite40(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0x60:
case 0x70:
- if (ad_slot[regm & 0x1f] >= 0)
+ if (ad_slot[regm & 0x1fu] >= 0)
{
- OPL3_SlotWrite60(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
+ OPL3_SlotWrite60(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0x80:
case 0x90:
- if (ad_slot[regm & 0x1f] >= 0)
+ if (ad_slot[regm & 0x1fu] >= 0)
{
- OPL3_SlotWrite80(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
+ OPL3_SlotWrite80(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0xe0:
case 0xf0:
- if (ad_slot[regm & 0x1f] >= 0)
+ if (ad_slot[regm & 0x1fu] >= 0)
{
- OPL3_SlotWriteE0(&chip->slot[18 * high + ad_slot[regm & 0x1f]], v);
+ OPL3_SlotWriteE0(&chip->slot[18u * high + ad_slot[regm & 0x1fu]], v);
}
break;
case 0xa0:
if ((regm & 0x0f) < 9)
{
- OPL3_ChannelWriteA0(&chip->channel[9 * high + (regm & 0x0f)], v);
+ OPL3_ChannelWriteA0(&chip->channel[9u * high + (regm & 0x0fu)], v);
}
break;
case 0xb0:
@@ -1692,28 +1692,28 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v)
}
else if ((regm & 0x0f) < 9)
{
- OPL3_ChannelWriteB0(&chip->channel[9 * high + (regm & 0x0f)], v);
+ OPL3_ChannelWriteB0(&chip->channel[9u * high + (regm & 0x0fu)], v);
if (v & 0x20)
{
- OPL3_ChannelKeyOn(&chip->channel[9 * high + (regm & 0x0f)]);
+ OPL3_ChannelKeyOn(&chip->channel[9u * high + (regm & 0x0fu)]);
}
else
{
- OPL3_ChannelKeyOff(&chip->channel[9 * high + (regm & 0x0f)]);
+ OPL3_ChannelKeyOff(&chip->channel[9u * high + (regm & 0x0fu)]);
}
}
break;
case 0xc0:
if ((regm & 0x0f) < 9)
{
- OPL3_ChannelWriteC0(&chip->channel[9 * high + (regm & 0x0f)], v);
+ OPL3_ChannelWriteC0(&chip->channel[9u * high + (regm & 0x0fu)], v);
}
break;
#if OPL_ENABLE_STEREOEXT
case 0xd0:
if ((regm & 0x0f) < 9)
{
- OPL3_ChannelWriteD0(&chip->channel[9 * high + (regm & 0x0f)], v);
+ OPL3_ChannelWriteD0(&chip->channel[9u * high + (regm & 0x0fu)], v);
}
break;
#endif