@@ -1810,11 +1810,6 @@ static CString NoteToStr(int Note)
1810
1810
return str;
1811
1811
}
1812
1812
1813
- static const COLORREF DECAY_COLOR[CRegisterState::DECAY_RATE + 1 ] = { // // //
1814
- 0xFFFF80 , 0xE6F993 , 0xCCF3A6 , 0xB3ECB9 , 0x99E6CC , 0x80E0E0 , 0x80D9E3 , 0x80D3E6 ,
1815
- 0x80CCE9 , 0x80C6EC , 0x80C0F0 , 0x80B9F3 , 0x80B3F6 , 0x80ACF9 , 0x80A6FC , 0x80A0FF ,
1816
- }; // BLEND has lower precision
1817
-
1818
1813
void CPatternEditor::DrawRegisters (CDC *pDC)
1819
1814
{
1820
1815
if (!m_pDocument || !pDC) return ; // // //
@@ -1848,34 +1843,58 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
1848
1843
m_pDocument->ExpansionEnabled (SNDCHIP_S5B) * 8 ); // // //
1849
1844
int vis_line = 0 ;
1850
1845
1846
+ // TODO: custom regview palettes
1847
+
1848
+ static const COLORREF DECAY_COLOR[CRegisterState::DECAY_RATE + 1 ] = { // // //
1849
+ 0xFFFF80 , 0xE6F993 , 0xCCF3A6 , 0xB3ECB9 , 0x99E6CC , 0x80E0E0 , 0x80D9E3 , 0x80D3E6 ,
1850
+ 0x80CCE9 , 0x80C6EC , 0x80C0F0 , 0x80B9F3 , 0x80B3F6 , 0x80ACF9 , 0x80A6FC , 0x80A0FF ,
1851
+ }; // BLEND has lower precision
1852
+
1853
+ // !! !!
1854
+ static const COLORREF UPDATE_STALE_COLOR = 0xC0C0C0 ;
1855
+ static const COLORREF UPDATE_FRESH_COLOR = 0xFFAFAF ;
1856
+ static const COLORREF BORDER_COLOR = 0x808080 ;
1857
+ static const COLORREF SUBBORDER_COLOR = 0x303030 ;
1858
+
1859
+ // Note color tints
1860
+ static const float CTINT_FDS_MOD[3 ] = { 1 , 0 , 0 };
1861
+ static const float CTINT_FDS[3 ] = { 0 , 1 , 1 };
1862
+ static const float CTINT_PNOISE[3 ] = { 0 .587f , 0 .676f , 1 .0f };
1863
+ static const float CTINT_S5B_T[3 ] = { 0 , 1 , 1 };
1864
+ static const float CTINT_S5B_N[3 ] = { 1 , 0 , 1 };
1865
+ static const float CTINT_S5B_E[3 ] = { 1 , 1 , 0 };
1866
+
1867
+ bool PrecisePitch = theApp.GetSettings ()->GUI .bPreciseRegPitch ;
1868
+
1851
1869
const auto DrawHeaderFunc = [&] (CString Text) {
1852
1870
line += 2 ; y += LINE_HEIGHT * 2 ;
1853
1871
pDC->MoveTo (x, y);
1854
1872
pDC->SetBkColor (m_colEmptyBg);
1855
- pDC->SetTextColor (0xFFAFAF );
1873
+ pDC->SetTextColor (UPDATE_FRESH_COLOR );
1856
1874
pDC->TextOut (x, y, Text + _T (" registers" ));
1857
1875
};
1858
1876
1859
1877
const auto DrawRegFunc = [&] (CString Header, int Count) {
1860
1878
++line; y += LINE_HEIGHT;
1861
1879
pDC->SetBkColor (m_colEmptyBg);
1862
- pDC->SetTextColor (0xFFAFAF );
1880
+ pDC->SetTextColor (UPDATE_FRESH_COLOR );
1863
1881
pDC->SetTextAlign (TA_UPDATECP);
1864
1882
pDC->MoveTo (x, y);
1865
1883
pDC->TextOut (0 , 0 , Header);
1866
1884
for (int j = 0 ; j < Count; j++) {
1867
1885
CString str;
1868
1886
str.Format (_T (" $%02X" ), reg[j]);
1869
- pDC->SetTextColor (BLEND (0xC0C0C0 , DECAY_COLOR[update[j] >> 4 ], 100 * (update[j] & 0x0F ) / CRegisterState::DECAY_RATE));
1887
+ pDC->SetTextColor (BLEND (UPDATE_STALE_COLOR , DECAY_COLOR[update[j] >> 4 ], 100 * (update[j] & 0x0F ) / CRegisterState::DECAY_RATE));
1870
1888
pDC->TextOut (0 , 0 , str);
1871
1889
}
1872
1890
};
1873
1891
1874
1892
const auto DrawVolBar = [&]() {
1875
- pDC->FillSolidRect (x - 1 , BAR_OFFSET + vis_line * 10 - 1 , 6 * 108 + 3 , 9 , 0x808080 );
1893
+ pDC->FillSolidRect (x - 1 , BAR_OFFSET + vis_line * 10 - 1 , 6 * 108 + 3 , 9 , BORDER_COLOR );
1876
1894
pDC->FillSolidRect (x, BAR_OFFSET + vis_line * 10 , 6 * 108 + 1 , 7 , 0 );
1895
+ // C note indicators
1877
1896
for (int i = 0 ; i < 10 ; i++)
1878
- pDC->SetPixelV (x + 72 * i, BAR_OFFSET + vis_line * 10 + 3 , i == 4 ? 0x808080 : 0x303030 );
1897
+ pDC->SetPixelV (x + 72 * i, BAR_OFFSET + vis_line * 10 + 3 , i == 4 ? BORDER_COLOR : SUBBORDER_COLOR );
1879
1898
};
1880
1899
1881
1900
const auto DrawVolNote = [&](const double note, BYTE Volume, float r = 1 .f , float g = 1 .f , float b = 1 .f ) {
@@ -1887,6 +1906,11 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
1887
1906
);
1888
1907
};
1889
1908
1909
+ // // !! apply OETF gamma 2.2 so we can see lower values better
1910
+ const auto OETF_gamma_vol = [&](const double Volume) -> BYTE {
1911
+ return BYTE (max (min (pow (Volume, (1 / 2.2 )), 1.0 ), 0.0 ) * 255 );
1912
+ };
1913
+
1890
1914
const auto DrawVolFunc = [&] (double Freq, double Volume, int Range=0 , int Period=0 , bool IsLength = true , float r=1 .f , float g=1 .f , float b=1 .f ) {
1891
1915
DrawVolBar ();
1892
1916
double note = 0 ;
@@ -1896,13 +1920,9 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
1896
1920
note = NoteFromFreq (Freq);
1897
1921
const int note_conv = note >= 0 ? int (note + 0.5 ) : int (note - 0.5 );
1898
1922
1899
- // // !! apply OETF gamma 2.2 so we can see lower values better
1900
- BYTE vol_scaled = BYTE (max (min (pow (Volume, (1 / 2.2 )), 1.0 ), 0.0 ) * 255 );
1923
+ BYTE vol_scaled = OETF_gamma_vol (Volume);
1901
1924
if (note_conv >= -12 && note_conv <= 96 && vol_scaled) { // // //
1902
- if (theApp.GetSettings ()->GUI .bPreciseRegPitch || Range != 0 )
1903
- DrawVolNote (note, vol_scaled, r, g, b);
1904
- else
1905
- DrawVolNote (note_conv, vol_scaled, r, g, b);
1925
+ DrawVolNote ((PrecisePitch || Range != 0 ) ? note : note_conv, vol_scaled, r, g, b);
1906
1926
}
1907
1927
++vis_line;
1908
1928
};
@@ -1915,29 +1935,22 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
1915
1935
const double outnote = NoteFromFreq (OutFreq);
1916
1936
const int outnote_conv = outnote >= 0 ? int (outnote + 0.5 ) : int (outnote - 0.5 );
1917
1937
1918
- // // !! apply OETF gamma 2.2 so we can see lower values better
1919
- BYTE vol_scaled = BYTE (max (min (pow (Volume, (1 / 2.2 )), 1.0 ), 0.0 ) * 255 );
1938
+ BYTE vol_scaled = OETF_gamma_vol (Volume);
1920
1939
1921
1940
// TODO: do something with Depth
1922
1941
// if (Depth > 0xFF) Depth = 0xFF;
1923
1942
1924
1943
if (note_conv >= -12 && note_conv <= 96 && vol_scaled) { // // //
1925
- if (Depth!= 0 )
1944
+ if (Depth != 0 ) {
1926
1945
// modulated note
1927
- if (theApp.GetSettings ()->GUI .bPreciseRegPitch ) {
1928
- DrawVolNote (outnote, vol_scaled, 1 , 0 , 0 );
1929
- DrawVolNote (note, vol_scaled, 0 , 1 , 1 );
1930
- }
1931
- else {
1932
- DrawVolNote (outnote_conv, vol_scaled, 1 , 0 , 0 );
1933
- DrawVolNote (note_conv, vol_scaled, 0 , 1 , 1 );
1934
- }
1946
+ DrawVolNote (PrecisePitch ? outnote : outnote_conv, vol_scaled,
1947
+ CTINT_FDS_MOD[0 ], CTINT_FDS_MOD[1 ], CTINT_FDS_MOD[2 ]);
1948
+ DrawVolNote (PrecisePitch ? note : note_conv, vol_scaled,
1949
+ CTINT_FDS[0 ], CTINT_FDS[1 ], CTINT_FDS[2 ]);
1950
+ }
1935
1951
else
1936
1952
// unmodulated note
1937
- if (theApp.GetSettings ()->GUI .bPreciseRegPitch )
1938
- DrawVolNote (note, vol_scaled);
1939
- else
1940
- DrawVolNote (note_conv, vol_scaled);
1953
+ DrawVolNote (PrecisePitch ? note : note_conv, vol_scaled);
1941
1954
}
1942
1955
++vis_line;
1943
1956
};
@@ -1948,32 +1961,34 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
1948
1961
1949
1962
// 3db per step
1950
1963
const double vol = envelope_enable ? 1 : (std::pow (10.0 , (((Volume + 1.0 ) * 3.0 ) / 20.0 )) / 251.18864315095801110850320677993 );
1951
- // // !! apply OETF gamma 2.2 so we can see lower values better
1952
- const BYTE vol_scaled = BYTE ( max ( min ( pow (vol, ( 1 / 2.2 )), 1.0 ), 0.0 ) * 255 );
1964
+
1965
+ const BYTE vol_scaled = OETF_gamma_vol (Volume );
1953
1966
1954
1967
const double note = NoteFromFreq (Freq);
1955
1968
const double note_envelope = NoteFromFreq (EnvelopeFreq);
1956
1969
const double note_noise = ((108.0 / double (0x1F )) * double (0x1F - NoisePeriod)) - 12.0 ;
1957
1970
const int note_conv = note >= 0 ? int (note + 0.5 ) : int (note - 0.5 );
1958
1971
1959
1972
1960
- if (note_conv >= -12 && note_conv <= 96 && (vol_scaled || envelope_enable)) { // // //
1961
- if (theApp.GetSettings ()->GUI .bPreciseRegPitch ) {
1962
- DrawVolNote (note, vol_scaled);
1963
- }
1964
- else {
1965
- DrawVolNote (note_conv, vol_scaled);
1966
- }
1967
- }
1973
+ if (note_conv >= -12 && note_conv <= 96 && (vol_scaled || envelope_enable)) // // //
1974
+ if (noise_enable || envelope_enable)
1975
+ DrawVolNote (PrecisePitch ? note : note_conv, vol_scaled, // !! !!
1976
+ CTINT_S5B_T[0 ], CTINT_S5B_T[1 ], CTINT_S5B_T[2 ]);
1977
+ else
1978
+ DrawVolNote (PrecisePitch ? note : note_conv, vol_scaled);
1979
+
1968
1980
if (note_noise >= -12.0 && note_noise <= 96.0 && noise_enable)
1969
- DrawVolNote (note_noise, vol_scaled, 1 , 0 , 1 );
1981
+ DrawVolNote (note_noise, vol_scaled,
1982
+ CTINT_S5B_N[0 ], CTINT_S5B_N[1 ], CTINT_S5B_N[2 ]);
1983
+
1970
1984
if (note_envelope >= -12.0 && note_envelope <= 96.0 && envelope_enable)
1971
- DrawVolNote (note_envelope, vol_scaled, 1 , 1 , 0 );
1985
+ DrawVolNote (note_envelope, vol_scaled,
1986
+ CTINT_S5B_E[0 ], CTINT_S5B_E[1 ], CTINT_S5B_E[2 ]);
1972
1987
++vis_line;
1973
1988
};
1974
1989
1975
1990
const auto DrawTextFunc = [&] (int xOffsNoDPI, CString text) {
1976
- pDC->SetTextColor (0x808080 );
1991
+ pDC->SetTextColor (BORDER_COLOR );
1977
1992
pDC->SetTextAlign (TA_NOUPDATECP);
1978
1993
pDC->TextOut (x + DPI::SX (xOffsNoDPI), y, text);
1979
1994
};
@@ -2070,7 +2085,8 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
2070
2085
DrawVolFunc (freq, (double )vol/ (double )0xF ); break ;
2071
2086
case 3 :
2072
2087
if (reg[2 ] >> 7 == 1 )
2073
- DrawVolFunc (freq, (double )vol/(double )0x0F , 0 , 0 , false , 0 , 0.5 , 1 );
2088
+ DrawVolFunc (freq, (double )vol/(double )0x0F , 0 , 0 , false ,
2089
+ CTINT_PNOISE[0 ], CTINT_PNOISE[1 ], CTINT_PNOISE[2 ]);
2074
2090
else
2075
2091
DrawVolFunc (0 , (double )vol/(double )0x0F , 0x0F , period, true );
2076
2092
break ;
@@ -2134,14 +2150,14 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
2134
2150
const int Length = 0x80 - 8 * N163_CHANS;
2135
2151
2136
2152
y += 18 ;
2137
- pDC->FillSolidRect (wave_x - 1 , y - 1 , 2 * Length + 2 , 17 , 0x808080 );
2153
+ pDC->FillSolidRect (wave_x - 1 , y - 1 , 2 * Length + 2 , 17 , BORDER_COLOR );
2138
2154
pDC->FillSolidRect (wave_x, y, 2 * Length, 15 , 0 );
2139
2155
for (int i = 0 ; i < Length; i++) {
2140
2156
auto pState = pSoundGen->GetRegState (SNDCHIP_N163, i);
2141
2157
const int Hi = (pState->GetValue () >> 4 ) & 0x0F ;
2142
2158
const int Lo = pState->GetValue () & 0x0F ;
2143
2159
COLORREF Col = BLEND (
2144
- 0xC0C0C0 , DECAY_COLOR[pState->GetNewValueTime ()], 100 * pState->GetLastUpdatedTime () / CRegisterState::DECAY_RATE
2160
+ UPDATE_STALE_COLOR , DECAY_COLOR[pState->GetNewValueTime ()], 100 * pState->GetLastUpdatedTime () / CRegisterState::DECAY_RATE
2145
2161
);
2146
2162
pDC->FillSolidRect (wave_x + i * 2 , y + 15 - Lo, 1 , Lo, Col);
2147
2163
pDC->FillSolidRect (wave_x + i * 2 + 1 , y + 15 - Hi, 1 , Hi, Col);
@@ -2155,7 +2171,7 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
2155
2171
const int UpdateTime = std::min (pPosState->GetLastUpdatedTime (), pLenState->GetLastUpdatedTime ());
2156
2172
pDC->FillSolidRect (wave_x, y + 20 + i * 5 , Length * 2 , 3 , 0 );
2157
2173
pDC->FillSolidRect (wave_x + WavePos, y + 20 + i * 5 , WaveLen, 3 ,
2158
- BLEND (0xC0C0C0 , DECAY_COLOR[NewTime], 100 * UpdateTime / CRegisterState::DECAY_RATE));
2174
+ BLEND (UPDATE_STALE_COLOR , DECAY_COLOR[NewTime], 100 * UpdateTime / CRegisterState::DECAY_RATE));
2159
2175
}
2160
2176
y -= 18 ;
2161
2177
@@ -2196,7 +2212,7 @@ void CPatternEditor::DrawRegisters(CDC *pDC)
2196
2212
2197
2213
y += 18 ;
2198
2214
2199
- pDC->FillSolidRect (wave_x-1 , y-1 , wave_width+2 , wave_height+2 , 0x808080 ); // draw box
2215
+ pDC->FillSolidRect (wave_x-1 , y-1 , wave_width+2 , wave_height+2 , BORDER_COLOR ); // draw box
2200
2216
pDC->FillSolidRect (wave_x, y, wave_width, wave_height-1 , 0 ); // fill box
2201
2217
for (int i = 0 ; i < wave_width; i++) {
2202
2218
// get register state
0 commit comments