limit volume macro to system maximum

fixes #71
This commit is contained in:
tildearrow 2022-01-30 12:31:50 -05:00
parent de5327d89a
commit 822d542350
12 changed files with 16 additions and 16 deletions

View file

@ -53,7 +53,7 @@ void DivPlatformAmiga::tick() {
for (int i=0; i<4; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=((chan[i].vol%65)*chan[i].std.vol)>>6;
chan[i].outVol=((chan[i].vol%65)*MIN(64,chan[i].std.vol))>>6;
}
if (chan[i].std.hadArp) {
if (!chan[i].inPorta) {
@ -263,4 +263,4 @@ int DivPlatformAmiga::init(DivEngine* p, int channels, int sugRate, unsigned int
}
void DivPlatformAmiga::quit() {
}
}

View file

@ -187,7 +187,7 @@ void DivPlatformArcade::tick() {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=(chan[i].vol*chan[i].std.vol)/127;
chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127;
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];

View file

@ -47,7 +47,7 @@ void DivPlatformAY8910::tick() {
for (int i=0; i<3; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=chan[i].std.vol-(15-(chan[i].vol&15));
chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15));
if (chan[i].outVol<0) chan[i].outVol=0;
if (isMuted[i]) {
rWrite(0x08+i,0);

View file

@ -63,7 +63,7 @@ void DivPlatformAY8930::tick() {
for (int i=0; i<3; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=chan[i].std.vol-(31-(chan[i].vol&31));
chan[i].outVol=MIN(31,chan[i].std.vol)-(31-(chan[i].vol&31));
if (chan[i].outVol<0) chan[i].outVol=0;
if (isMuted[i]) {
rWrite(0x08+i,0);

View file

@ -27,7 +27,7 @@ void DivPlatformC64::tick() {
DivInstrument* ins=parent->getIns(chan[i].ins);
if (ins->c64.volIsCutoff) {
if (ins->c64.filterIsAbs) {
filtCut=chan[i].std.vol;
filtCut=MIN(2047,chan[i].std.vol);
} else {
filtCut-=((signed char)chan[i].std.vol-18)*7;
if (filtCut>2047) filtCut=2047;
@ -35,7 +35,7 @@ void DivPlatformC64::tick() {
}
updateFilter();
} else {
vol=chan[i].std.vol;
vol=MIN(15,chan[i].std.vol);
updateFilter();
}
}

View file

@ -91,7 +91,7 @@ void DivPlatformGenesis::tick() {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=(chan[i].vol*chan[i].std.vol)/127;
chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127;
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];

View file

@ -75,7 +75,7 @@ void DivPlatformNES::tick() {
chan[i].std.next();
if (chan[i].std.hadVol) {
// ok, why are the volumes like that?
chan[i].outVol=chan[i].std.vol-(15-(chan[i].vol&15));
chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15));
if (chan[i].outVol<0) chan[i].outVol=0;
if (i==2) { // triangle
rWrite(0x4000+i*4,(chan[i].outVol==0)?0:255);

View file

@ -99,7 +99,7 @@ void DivPlatformPCE::tick() {
for (int i=0; i<6; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=((chan[i].vol&31)*chan[i].std.vol)>>5;
chan[i].outVol=((chan[i].vol&31)*MIN(31,chan[i].std.vol))>>5;
if (chan[i].furnaceDac) {
// ignore for now
} else {

View file

@ -37,7 +37,7 @@ void DivPlatformSAA1099::tick() {
for (int i=0; i<6; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=chan[i].std.vol-(15-(chan[i].vol&15));
chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15));
if (chan[i].outVol<0) chan[i].outVol=0;
if (isMuted[i]) {
rWrite(i,0);

View file

@ -20,7 +20,7 @@ void DivPlatformSMS::tick() {
for (int i=0; i<4; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=((chan[i].vol&15)*chan[i].std.vol)>>4;
chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol))>>4;
rWrite(0x90|(i<<5)|(isMuted[i]?15:(15-(chan[i].outVol&15))));
}
if (chan[i].std.hadArp) {

View file

@ -45,7 +45,7 @@ void DivPlatformTIA::tick() {
for (int i=0; i<2; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=chan[i].std.vol-(15-(chan[i].vol&15));
chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15));
if (chan[i].outVol<0) chan[i].outVol=0;
if (isMuted[i]) {
rWrite(0x19+i,0);

View file

@ -48,7 +48,7 @@ void DivPlatformYM2610::tick() {
for (int i=4; i<7; i++) {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=chan[i].std.vol-(15-(chan[i].vol&15));
chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15));
if (chan[i].outVol<0) chan[i].outVol=0;
if (isMuted[i]) {
rWrite(0x04+i,0);
@ -152,7 +152,7 @@ void DivPlatformYM2610::tick() {
chan[i].std.next();
if (chan[i].std.hadVol) {
chan[i].outVol=(chan[i].vol*chan[i].std.vol)/127;
chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127;
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
@ -810,4 +810,4 @@ void DivPlatformYM2610::quit() {
}
DivPlatformYM2610::~DivPlatformYM2610() {
}
}