many changes
This commit is contained in:
parent
72d04777c0
commit
21d1dfefa1
|
@ -80,9 +80,8 @@ void DivPlatformC140::tick(bool sysTick) {
|
||||||
chan[i].std.next();
|
chan[i].std.next();
|
||||||
if (chan[i].std.vol.had) {
|
if (chan[i].std.vol.had) {
|
||||||
chan[i].outVol=(chan[i].vol*MIN(chan[i].macroVolMul,chan[i].std.vol.val))/chan[i].macroVolMul;
|
chan[i].outVol=(chan[i].vol*MIN(chan[i].macroVolMul,chan[i].std.vol.val))/chan[i].macroVolMul;
|
||||||
if (!isMuted[i]) {
|
chan[i].volChangedL=true;
|
||||||
chan[i].volumeChanged.changed=0xff;
|
chan[i].volChangedR=true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (NEW_ARP_STRAT) {
|
if (NEW_ARP_STRAT) {
|
||||||
chan[i].handleArp();
|
chan[i].handleArp();
|
||||||
|
@ -103,16 +102,12 @@ void DivPlatformC140::tick(bool sysTick) {
|
||||||
}
|
}
|
||||||
if (chan[i].std.panL.had) {
|
if (chan[i].std.panL.had) {
|
||||||
chan[i].chPanL=chan[i].std.panL.val&255;
|
chan[i].chPanL=chan[i].std.panL.val&255;
|
||||||
if (!isMuted[i]) {
|
chan[i].volChangedL=true;
|
||||||
chan[i].volumeChanged.left=1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.panR.had) {
|
if (chan[i].std.panR.had) {
|
||||||
chan[i].chPanR=chan[i].std.panR.val&255;
|
chan[i].chPanR=chan[i].std.panR.val&255;
|
||||||
if (!isMuted[i]) {
|
chan[i].volChangedR=true;
|
||||||
chan[i].volumeChanged.right=1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chan[i].std.phaseReset.had) {
|
if (chan[i].std.phaseReset.had) {
|
||||||
|
@ -121,24 +116,15 @@ void DivPlatformC140::tick(bool sysTick) {
|
||||||
chan[i].setPos=true;
|
chan[i].setPos=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chan[i].volumeChanged.changed) {
|
if (chan[i].volChangedL) {
|
||||||
if (chan[i].volumeChanged.left) {
|
chan[i].chVolL=(chan[i].outVol*chan[i].chPanL)/255;
|
||||||
if (isMuted[i]) {
|
rWrite(1+(i<<4),chan[i].chVolL);
|
||||||
chan[i].chVolL=0;
|
chan[i].volChangedL=false;
|
||||||
} else {
|
}
|
||||||
chan[i].chVolL=(chan[i].outVol*chan[i].chPanL)/255;
|
if (chan[i].volChangedR) {
|
||||||
}
|
chan[i].chVolR=(chan[i].outVol*chan[i].chPanR)/255;
|
||||||
rWrite(1+(i<<4),chan[i].chVolL);
|
rWrite(0+(i<<4),chan[i].chVolR);
|
||||||
}
|
chan[i].volChangedR=false;
|
||||||
if (chan[i].volumeChanged.right) {
|
|
||||||
if (isMuted[i]) {
|
|
||||||
chan[i].chVolR=0;
|
|
||||||
} else {
|
|
||||||
chan[i].chVolR=(chan[i].outVol*chan[i].chPanR)/255;
|
|
||||||
}
|
|
||||||
rWrite(0+(i<<4),chan[i].chVolR);
|
|
||||||
}
|
|
||||||
chan[i].volumeChanged.changed=0;
|
|
||||||
}
|
}
|
||||||
if (chan[i].setPos) {
|
if (chan[i].setPos) {
|
||||||
// force keyon
|
// force keyon
|
||||||
|
@ -178,9 +164,8 @@ void DivPlatformC140::tick(bool sysTick) {
|
||||||
rWrite(0x0b+(i<<4),loop&0xff);
|
rWrite(0x0b+(i<<4),loop&0xff);
|
||||||
if (!chan[i].std.vol.had) {
|
if (!chan[i].std.vol.had) {
|
||||||
chan[i].outVol=chan[i].vol;
|
chan[i].outVol=chan[i].vol;
|
||||||
if (!isMuted[i]) {
|
chan[i].volChangedL=true;
|
||||||
chan[i].volumeChanged.changed=0xff;
|
chan[i].volChangedR=true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
chan[i].keyOn=false;
|
chan[i].keyOn=false;
|
||||||
}
|
}
|
||||||
|
@ -221,9 +206,8 @@ int DivPlatformC140::dispatch(DivCommand c) {
|
||||||
chan[c.chan].macroInit(ins);
|
chan[c.chan].macroInit(ins);
|
||||||
if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
|
if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
|
||||||
chan[c.chan].outVol=chan[c.chan].vol;
|
chan[c.chan].outVol=chan[c.chan].vol;
|
||||||
if (!isMuted[c.chan]) {
|
chan[c.chan].volChangedL=true;
|
||||||
chan[c.chan].volumeChanged.changed=0xff;
|
chan[c.chan].volChangedR=true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -247,9 +231,8 @@ int DivPlatformC140::dispatch(DivCommand c) {
|
||||||
if (!chan[c.chan].std.vol.has) {
|
if (!chan[c.chan].std.vol.has) {
|
||||||
chan[c.chan].outVol=c.value;
|
chan[c.chan].outVol=c.value;
|
||||||
}
|
}
|
||||||
if (!isMuted[c.chan]) {
|
chan[c.chan].volChangedL=true;
|
||||||
chan[c.chan].volumeChanged.changed=0xff;
|
chan[c.chan].volChangedR=true;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_GET_VOLUME:
|
case DIV_CMD_GET_VOLUME:
|
||||||
if (chan[c.chan].std.vol.has) {
|
if (chan[c.chan].std.vol.has) {
|
||||||
|
@ -260,9 +243,8 @@ int DivPlatformC140::dispatch(DivCommand c) {
|
||||||
case DIV_CMD_PANNING:
|
case DIV_CMD_PANNING:
|
||||||
chan[c.chan].chPanL=c.value;
|
chan[c.chan].chPanL=c.value;
|
||||||
chan[c.chan].chPanR=c.value2;
|
chan[c.chan].chPanR=c.value2;
|
||||||
if (!isMuted[c.chan]) {
|
chan[c.chan].volChangedL=true;
|
||||||
chan[c.chan].volumeChanged.changed=0xff;
|
chan[c.chan].volChangedR=true;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_PITCH:
|
case DIV_CMD_PITCH:
|
||||||
chan[c.chan].pitch=c.value;
|
chan[c.chan].pitch=c.value;
|
||||||
|
@ -328,14 +310,15 @@ int DivPlatformC140::dispatch(DivCommand c) {
|
||||||
|
|
||||||
void DivPlatformC140::muteChannel(int ch, bool mute) {
|
void DivPlatformC140::muteChannel(int ch, bool mute) {
|
||||||
isMuted[ch]=mute;
|
isMuted[ch]=mute;
|
||||||
chan[ch].volumeChanged.changed=0xff;
|
c140.voice[ch].muted=mute;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformC140::forceIns() {
|
void DivPlatformC140::forceIns() {
|
||||||
for (int i=0; i<24; i++) {
|
for (int i=0; i<24; i++) {
|
||||||
chan[i].insChanged=true;
|
chan[i].insChanged=true;
|
||||||
chan[i].freqChanged=true;
|
chan[i].freqChanged=true;
|
||||||
chan[i].volumeChanged.changed=0xff;
|
chan[i].volChangedL=true;
|
||||||
|
chan[i].volChangedR=true;
|
||||||
chan[i].sample=-1;
|
chan[i].sample=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -480,7 +463,7 @@ int DivPlatformC140::init(DivEngine* p, int channels, int sugRate, const DivConf
|
||||||
isMuted[i]=false;
|
isMuted[i]=false;
|
||||||
oscBuf[i]=new DivDispatchOscBuffer;
|
oscBuf[i]=new DivDispatchOscBuffer;
|
||||||
}
|
}
|
||||||
sampleMem=new signed short[getSampleMemCapacity()/sizeof(short)];
|
sampleMem=new short[getSampleMemCapacity()>>1];
|
||||||
sampleMemLen=0;
|
sampleMemLen=0;
|
||||||
c140_init(&c140);
|
c140_init(&c140);
|
||||||
c140.sample_mem=sampleMem;
|
c140.sample_mem=sampleMem;
|
||||||
|
|
|
@ -26,33 +26,20 @@
|
||||||
|
|
||||||
class DivPlatformC140: public DivDispatch {
|
class DivPlatformC140: public DivDispatch {
|
||||||
struct Channel: public SharedChannel<int> {
|
struct Channel: public SharedChannel<int> {
|
||||||
struct VolumeUpdate {
|
|
||||||
union { // pack flag bits in single byte
|
|
||||||
struct { // flag bits
|
|
||||||
unsigned char left : 1; // left volume
|
|
||||||
unsigned char right : 1; // right volume
|
|
||||||
unsigned char reserved : 6;
|
|
||||||
};
|
|
||||||
unsigned char changed = 0; // Packed flags are stored here
|
|
||||||
};
|
|
||||||
|
|
||||||
VolumeUpdate():
|
|
||||||
changed(0) {}
|
|
||||||
} volumeChanged;
|
|
||||||
|
|
||||||
unsigned int audPos;
|
unsigned int audPos;
|
||||||
int sample, wave;
|
int sample, wave;
|
||||||
bool setPos;
|
bool setPos, volChangedL, volChangedR;
|
||||||
int chPanL, chPanR;
|
int chPanL, chPanR;
|
||||||
int chVolL, chVolR;
|
int chVolL, chVolR;
|
||||||
int macroVolMul;
|
int macroVolMul;
|
||||||
Channel():
|
Channel():
|
||||||
SharedChannel<int>(255),
|
SharedChannel<int>(255),
|
||||||
volumeChanged(VolumeUpdate()),
|
|
||||||
audPos(0),
|
audPos(0),
|
||||||
sample(-1),
|
sample(-1),
|
||||||
wave(-1),
|
wave(-1),
|
||||||
setPos(false),
|
setPos(false),
|
||||||
|
volChangedL(false),
|
||||||
|
volChangedR(false),
|
||||||
chPanL(255),
|
chPanL(255),
|
||||||
chPanR(255),
|
chPanR(255),
|
||||||
chVolL(255),
|
chVolL(255),
|
||||||
|
|
|
@ -52,8 +52,10 @@ void c140_tick(struct c140_t *c140, const int cycle)
|
||||||
for (int i = 0; i < 24; i++)
|
for (int i = 0; i < 24; i++)
|
||||||
{
|
{
|
||||||
c140_voice_tick(c140, i, cycle);
|
c140_voice_tick(c140, i, cycle);
|
||||||
c140->lout += c140->voice[i].lout;
|
if (!c140->voice[i].muted) {
|
||||||
c140->rout += c140->voice[i].rout;
|
c140->lout += c140->voice[i].lout;
|
||||||
|
c140->rout += c140->voice[i].rout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// scale as 16bit
|
// scale as 16bit
|
||||||
c140->lout >>= 10;
|
c140->lout >>= 10;
|
||||||
|
@ -131,6 +133,10 @@ void c140_init(struct c140_t *c140)
|
||||||
<< (exponent ? exponent - 1 : 0));
|
<< (exponent ? exponent - 1 : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < 24; i++)
|
||||||
|
{
|
||||||
|
c140->voice[i].muted = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void c140_reset(struct c140_t *c140)
|
void c140_reset(struct c140_t *c140)
|
||||||
|
@ -186,4 +192,4 @@ void c140_write(struct c140_t *c140, const unsigned short addr, const unsigned c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Timer
|
// Timer
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
============================================================================
|
============================================================================
|
||||||
|
|
||||||
Namco C140 sound emulator
|
MODIFIED Namco C140 sound emulator - MODIFIED VERSION
|
||||||
by cam900
|
by cam900
|
||||||
|
|
||||||
|
MODIFICATION by tildearrow - adds muting function
|
||||||
|
THIS IS NOT THE ORIGINAL VERSION - you can find the original one in
|
||||||
|
commit 72d04777c013988ed8cf6da27c62a9d784a59dff
|
||||||
|
|
||||||
This file is licensed under zlib license.
|
This file is licensed under zlib license.
|
||||||
|
|
||||||
============================================================================
|
============================================================================
|
||||||
|
@ -49,6 +53,7 @@ extern "C"
|
||||||
|
|
||||||
struct c140_voice_t
|
struct c140_voice_t
|
||||||
{
|
{
|
||||||
|
bool muted; // muted - can be set by user
|
||||||
bool busy; // busy flag
|
bool busy; // busy flag
|
||||||
bool keyon; // key on flag
|
bool keyon; // key on flag
|
||||||
unsigned short freq; // sample frequency
|
unsigned short freq; // sample frequency
|
||||||
|
|
|
@ -1106,8 +1106,6 @@ void putDispatchChan(void* data, int chanNum, int type) {
|
||||||
ImGui::Text("- chVolR: %.2x",ch->chVolR);
|
ImGui::Text("- chVolR: %.2x",ch->chVolR);
|
||||||
ImGui::Text("- macroVolMul: %.2x",ch->macroVolMul);
|
ImGui::Text("- macroVolMul: %.2x",ch->macroVolMul);
|
||||||
COMMON_CHAN_DEBUG_BOOL;
|
COMMON_CHAN_DEBUG_BOOL;
|
||||||
ImGui::TextColored(ch->volumeChanged.left?colorOn:colorOff,">> VolumeChangedLeft");
|
|
||||||
ImGui::TextColored(ch->volumeChanged.right?colorOn:colorOff,">> VolumeChangedRight");
|
|
||||||
ImGui::TextColored(ch->setPos?colorOn:colorOff,">> SetPos");
|
ImGui::TextColored(ch->setPos?colorOn:colorOff,">> SetPos");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue