MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / Draw

Method Draw

Source/RegisterDisplay.cpp:66–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void CRegisterDisplay::Draw() {
67 dc_.SetBkMode(TRANSPARENT); // // //
68
69 const CSoundGen *pSoundGen = FTEnv.GetSoundGenerator();
70
71 const int BAR_OFFSET = LINE_HEIGHT * (3 +
72 pSoundGen->IsExpansionEnabled(sound_chip_t::APU) * 8 +
73 pSoundGen->IsExpansionEnabled(sound_chip_t::VRC6) * 5 +
74 pSoundGen->IsExpansionEnabled(sound_chip_t::MMC5) * 4 +
75 pSoundGen->IsExpansionEnabled(sound_chip_t::N163) * 18 +
76 pSoundGen->IsExpansionEnabled(sound_chip_t::FDS) * 13 +
77 pSoundGen->IsExpansionEnabled(sound_chip_t::VRC7) * 9 +
78 pSoundGen->IsExpansionEnabled(sound_chip_t::S5B) * 8); // // //
79 int vis_line = 0;
80
81 const auto DrawVolFunc = [&] (double Freq, int Volume) {
82 dc_.FillSolidRect(x - 1, BAR_OFFSET + vis_line * 10 - 1, 6 * 108 + 3, 9, 0x808080);
83 dc_.FillSolidRect(x, BAR_OFFSET + vis_line * 10, 6 * 108 + 1, 7, 0);
84 for (int i = 0; i < 10; ++i)
85 dc_.SetPixelV(x + 72 * i, BAR_OFFSET + vis_line * 10 + 3, i == 4 ? 0x808080 : 0x303030);
86
87 const double note = NoteFromFreq(Freq);
88 const int note_conv = note >= 0 ? int(note + 0.5) : int(note - 0.5);
89 if (Volume > 0xFF) Volume = 0xFF;
90 if (note_conv >= -12 && note_conv <= 96 && Volume) // // //
91 dc_.FillSolidRect(29 + 6 * (note_conv + 12), BAR_OFFSET + vis_line * 10, 3, 7, GREY(Volume));
92 ++vis_line;
93 };
94
95 // 2A03 / 2A07
96 if (pSoundGen->IsExpansionEnabled(sound_chip_t::APU)) {
97 DrawHeader("2A03 registers"); // // //
98
99 for (int i = 0; i < MAX_CHANNELS_2A03; ++i) {
100 GetRegs(sound_chip_t::APU, [&] (int x) { return 0x4000 + i * 4 + x; }, 4);
101 DrawReg(FormattedA("$%04X:", 0x4000 + i * 4), 4);
102
103 int period = 0, vol = 0;
104 double freq = pSoundGen->GetChannelFrequency(sound_chip_t::APU, i); // // //
105// dc.FillSolidRect(x + 200, y, x + 400, y + 18, m_colEmptyBg);
106
107 CStringA text;
108 switch (i) {
109 case 0: case 1:
110 period = reg[2] | ((reg[3] & 7) << 8);
111 vol = reg[0] & 0x0F;
112 text = FormattedA("%s, vol = %02i, duty = %i", (LPCSTR)GetPitchText(3, period, freq), vol, reg[0] >> 6); break;
113 case 2:
114 period = reg[2] | ((reg[3] & 7) << 8);
115 vol = reg[0] ? 15 : 0;
116 text = FormattedA("%s", (LPCSTR)GetPitchText(3, period, freq)); break;
117 case 3:
118 period = reg[2] & 0x0F;
119 vol = reg[0] & 0x0F;
120 text = FormattedA("pitch = $%01X, vol = %02i, mode = %i", period, vol, reg[2] >> 7);
121 period = (period << 4) | ((reg[2] & 0x80) >> 4);
122 freq /= 16; break; // for display
123 case 4:

Callers

nothing calls this directly

Calls 15

NoteFromFreqFunction · 0.85
GREYFunction · 0.85
FormattedAFunction · 0.85
GetPitchTextFunction · 0.85
AppendFormatAFunction · 0.85
BLENDFunction · 0.85
IsExpansionEnabledMethod · 0.80
GetChannelFrequencyMethod · 0.80
PreviewDoneMethod · 0.80
GetDPCMStateMethod · 0.80
GetNamcoChannelCountMethod · 0.80
GetNewValueTimeMethod · 0.80

Tested by

no test coverage detected