mirror of https://github.com/stella-emu/stella.git
fixed and enhanced audio frequency display in debugger
This commit is contained in:
parent
bfc59ddcc3
commit
bdabbf9aa0
|
@ -1007,20 +1007,33 @@ string TIADebug::colorSwatch(uInt8 c) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// FIXME - how does this work; is this even needed ??
|
string TIADebug::audFreq0()
|
||||||
// convert to stringstream, get rid of snprintf
|
|
||||||
string TIADebug::audFreq(uInt8 div)
|
|
||||||
{
|
{
|
||||||
string ret;
|
return audFreq(audC0(), audF0());
|
||||||
std::array<char, 10> buf;
|
}
|
||||||
|
|
||||||
double hz = 31400.0;
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
if(div) hz /= div;
|
string TIADebug::audFreq1()
|
||||||
std::snprintf(buf.data(), 9, "%5.1f", hz);
|
{
|
||||||
ret += buf.data();
|
return audFreq(audC1(), audF1());
|
||||||
ret += "Hz";
|
}
|
||||||
|
|
||||||
return ret;
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
string TIADebug::audFreq(uInt8 dist, uInt8 div)
|
||||||
|
{
|
||||||
|
uInt16 dist_div[16] = {
|
||||||
|
1, 15, 465, 465, 2, 2, 31, 31,
|
||||||
|
511, 31, 31, 1, 6, 6, 93, 93
|
||||||
|
};
|
||||||
|
const double hz =
|
||||||
|
(myConsole.timing() == ConsoleTiming::ntsc ? 31440.0 : 31200.0)
|
||||||
|
/ dist_div[dist] / (div + 1);
|
||||||
|
ostringstream buf;
|
||||||
|
|
||||||
|
buf.setf(std::ios_base::fixed, std::ios_base::floatfield);
|
||||||
|
buf << std::setw(7) << std::setprecision(1) << hz << "Hz";
|
||||||
|
|
||||||
|
return buf.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -1302,7 +1315,7 @@ string TIADebug::toString()
|
||||||
<< "AUDF0: "
|
<< "AUDF0: "
|
||||||
<< hexWithLabel("", int(audF0()),
|
<< hexWithLabel("", int(audF0()),
|
||||||
state.aud[0] != oldState.aud[0]) << "/"
|
state.aud[0] != oldState.aud[0]) << "/"
|
||||||
<< std::setw(11) << std::right << stringOnly(audFreq(audF0()),
|
<< std::setw(11) << std::right << stringOnly(audFreq0(),
|
||||||
state.aud[0] != oldState.aud[0]) << " "
|
state.aud[0] != oldState.aud[0]) << " "
|
||||||
<< "AUDC0: "
|
<< "AUDC0: "
|
||||||
<< hexWithLabel("", int(audC0()),
|
<< hexWithLabel("", int(audC0()),
|
||||||
|
@ -1314,7 +1327,7 @@ string TIADebug::toString()
|
||||||
<< "AUDF1: "
|
<< "AUDF1: "
|
||||||
<< hexWithLabel("", int(audF1()),
|
<< hexWithLabel("", int(audF1()),
|
||||||
state.aud[1] != oldState.aud[1]) << "/"
|
state.aud[1] != oldState.aud[1]) << "/"
|
||||||
<< std::setw(11) << std::right << stringOnly(audFreq(audF1()),
|
<< std::setw(11) << std::right << stringOnly(audFreq1(),
|
||||||
state.aud[1] != oldState.aud[1]) << " "
|
state.aud[1] != oldState.aud[1]) << " "
|
||||||
<< "AUDC1: "
|
<< "AUDC1: "
|
||||||
<< hexWithLabel("", int(audC1()),
|
<< hexWithLabel("", int(audC1()),
|
||||||
|
|
|
@ -106,6 +106,8 @@ class TIADebug : public DebuggerSystem
|
||||||
uInt8 audF1(int newVal = -1);
|
uInt8 audF1(int newVal = -1);
|
||||||
uInt8 audV0(int newVal = -1);
|
uInt8 audV0(int newVal = -1);
|
||||||
uInt8 audV1(int newVal = -1);
|
uInt8 audV1(int newVal = -1);
|
||||||
|
string audFreq0();
|
||||||
|
string audFreq1();
|
||||||
|
|
||||||
void setGRP0Old(uInt8 b);
|
void setGRP0Old(uInt8 b);
|
||||||
void setGRP1Old(uInt8 b);
|
void setGRP1Old(uInt8 b);
|
||||||
|
@ -185,7 +187,7 @@ class TIADebug : public DebuggerSystem
|
||||||
/** Display a color patch for color at given index in the palette */
|
/** Display a color patch for color at given index in the palette */
|
||||||
string colorSwatch(uInt8 c) const;
|
string colorSwatch(uInt8 c) const;
|
||||||
|
|
||||||
string audFreq(uInt8 div);
|
string audFreq(uInt8 dist, uInt8 div);
|
||||||
string stringOnly(string value, bool changed = false);
|
string stringOnly(string value, bool changed = false);
|
||||||
string decWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 3);
|
string decWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 3);
|
||||||
string hexWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 2);
|
string hexWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 2);
|
||||||
|
|
|
@ -49,6 +49,12 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||||
myAudF->setTarget(this);
|
myAudF->setTarget(this);
|
||||||
myAudF->setID(kAUDFID);
|
myAudF->setID(kAUDFID);
|
||||||
addFocusWidget(myAudF);
|
addFocusWidget(myAudF);
|
||||||
|
myAud0F = new StaticTextWidget(boss, lfont,
|
||||||
|
myAudF->getRight() + fontWidth, ypos + (lineHeight + 5)/ 2 + 2, " ");
|
||||||
|
new StaticTextWidget(boss, lfont,
|
||||||
|
myAud0F->getRight(), ypos + (lineHeight + 5)/ 2 + 2, "/");
|
||||||
|
myAud1F = new StaticTextWidget(boss, lfont,
|
||||||
|
myAud0F->getRight() + fontWidth, ypos + (lineHeight + 5)/ 2 + 2, " ");
|
||||||
|
|
||||||
for(int col = 0; col < 2; ++col)
|
for(int col = 0; col < 2; ++col)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +63,6 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||||
Common::Base::toString(col, Common::Base::Fmt::_16_1),
|
Common::Base::toString(col, Common::Base::Fmt::_16_1),
|
||||||
TextAlign::Left);
|
TextAlign::Left);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AudC registers
|
// AudC registers
|
||||||
xpos = 10; ypos += lineHeight + 5;
|
xpos = 10; ypos += lineHeight + 5;
|
||||||
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
|
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
|
||||||
|
@ -80,7 +85,8 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||||
myAudV->setID(kAUDVID);
|
myAudV->setID(kAUDVID);
|
||||||
addFocusWidget(myAudV);
|
addFocusWidget(myAudV);
|
||||||
|
|
||||||
myAudEffV = new StaticTextWidget(boss, lfont, myAudV->getRight() + fontWidth, myAudV->getTop() + 2,
|
myAudEffV = new StaticTextWidget(boss, lfont,
|
||||||
|
myAudV->getRight() + fontWidth * 2, myAudV->getTop() + 2,
|
||||||
"100% (eff. volume)");
|
"100% (eff. volume)");
|
||||||
|
|
||||||
setHelpAnchor("AudioTab", true);
|
setHelpAnchor("AudioTab", true);
|
||||||
|
@ -128,9 +134,18 @@ void AudioWidget::loadConfig()
|
||||||
}
|
}
|
||||||
myAudV->setList(alist, vlist, changed);
|
myAudV->setList(alist, vlist, changed);
|
||||||
|
|
||||||
|
handleFrequencies();
|
||||||
handleVolume();
|
handleVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void AudioWidget::handleFrequencies()
|
||||||
|
{
|
||||||
|
myAud0F->setLabel(instance().debugger().tiaDebug().audFreq0());
|
||||||
|
myAud1F->setLabel(instance().debugger().tiaDebug().audFreq1());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void AudioWidget::handleVolume()
|
void AudioWidget::handleVolume()
|
||||||
{
|
{
|
||||||
|
@ -185,6 +200,7 @@ void AudioWidget::changeFrequencyRegs()
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
handleFrequencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -206,6 +222,7 @@ void AudioWidget::changeControlRegs()
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
handleFrequencies();
|
||||||
handleVolume();
|
handleVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,11 @@ class AudioWidget : public Widget, public CommandSender
|
||||||
kAUDVID
|
kAUDVID
|
||||||
};
|
};
|
||||||
|
|
||||||
DataGridWidget* myAudF{nullptr};
|
DataGridWidget* myAudF{nullptr};
|
||||||
DataGridWidget* myAudC{nullptr};
|
StaticTextWidget* myAud0F{nullptr};
|
||||||
DataGridWidget* myAudV{nullptr};
|
StaticTextWidget* myAud1F{nullptr};
|
||||||
|
DataGridWidget* myAudC{nullptr};
|
||||||
|
DataGridWidget* myAudV{nullptr};
|
||||||
StaticTextWidget* myAudEffV{nullptr};
|
StaticTextWidget* myAudEffV{nullptr};
|
||||||
|
|
||||||
// Audio channels
|
// Audio channels
|
||||||
|
@ -59,6 +61,7 @@ class AudioWidget : public Widget, public CommandSender
|
||||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||||
void loadConfig() override;
|
void loadConfig() override;
|
||||||
|
|
||||||
|
void handleFrequencies();
|
||||||
void handleVolume();
|
void handleVolume();
|
||||||
uInt32 getEffectiveVolume();
|
uInt32 getEffectiveVolume();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue