Fix monochrome RGB colors

This commit is contained in:
michaelangel007 2015-01-01 09:59:58 -08:00
parent 28cd63fc84
commit 1087f738d5
3 changed files with 73 additions and 73 deletions

View File

@ -119,6 +119,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
static unsigned char g_aNTSCMonoTelevision [NTSC_NUM_SEQUENCES][NUM_COLOR_CHANNELS]; static unsigned char g_aNTSCMonoTelevision [NTSC_NUM_SEQUENCES][NUM_COLOR_CHANNELS];
static unsigned char g_aNTSCColorTelevision[NTSC_NUM_PHASES][NTSC_NUM_SEQUENCES][NUM_COLOR_CHANNELS]; static unsigned char g_aNTSCColorTelevision[NTSC_NUM_PHASES][NTSC_NUM_SEQUENCES][NUM_COLOR_CHANNELS];
// g_aNTSCMonoMonitor * g_nMonochromeRGB -> g_aNTSCMonoMonitorCustom
// g_aNTSCMonoTelevision * g_nMonochromeRGB -> g_aNTSCMonoTelevisionCustom
static unsigned char g_aNTSCMonoMonitorCustom [NTSC_NUM_SEQUENCES][NUM_COLOR_CHANNELS];
static unsigned char g_aNTSCMonoTelevisionCustom [NTSC_NUM_SEQUENCES][NUM_COLOR_CHANNELS];
#define NUM_SIGZEROS 2 #define NUM_SIGZEROS 2
#define NUM_SIGPOLES 2 #define NUM_SIGPOLES 2
#define SIGGAIN 7.614490548f #define SIGGAIN 7.614490548f
@ -280,6 +285,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
void init_chroma_phase_table(); void init_chroma_phase_table();
void updateColorPhase(); void updateColorPhase();
void updateVideoHorzEOL(); void updateVideoHorzEOL();
void updateMonochromeColor( uint16_t r, uint16_t g, uint16_t b );
//=========================================================================== //===========================================================================
inline float clampZeroOne( const float & x ) inline float clampZeroOne( const float & x )
@ -522,6 +528,7 @@ void NTSC_VideoInit( uint8_t* pFramebuffer ) // wsVideoInit
make_csbits(); make_csbits();
init_video_tables(); init_video_tables();
init_chroma_phase_table(); init_chroma_phase_table();
updateMonochromeColor( 0xFF, 0xFF, 0xFF );
for (int y = 0; y < 384; y++) for (int y = 0; y < 384; y++)
g_NTSC_Lines[y] = g_pFramebufferbits + 4 * FRAMEBUFFER_W * ((FRAMEBUFFER_H - 1) - y - 18) + 80; g_NTSC_Lines[y] = g_pFramebufferbits + 4 * FRAMEBUFFER_W * ((FRAMEBUFFER_H - 1) - y - 18) + 80;
@ -625,12 +632,12 @@ void NTSC_VideoInit( uint8_t* pFramebuffer ) // wsVideoInit
static void ntscMonoSinglePixel (int compositeSignal) static void ntscMonoSinglePixel (int compositeSignal)
{ {
SINGLEPIXEL(compositeSignal, g_aNTSCMonoMonitor); SINGLEPIXEL(compositeSignal, g_aNTSCMonoMonitorCustom);
} }
static void ntscMonoDoublePixel (int compositeSignal) static void ntscMonoDoublePixel (int compositeSignal)
{ {
DOUBLEPIXEL(compositeSignal, g_aNTSCMonoMonitor); DOUBLEPIXEL(compositeSignal, g_aNTSCMonoMonitorCustom);
} }
static void ntscColorSinglePixel (int compositeSignal) static void ntscColorSinglePixel (int compositeSignal)
@ -648,12 +655,12 @@ static void ntscColorDoublePixel (int compositeSignal)
static void ntscMonoTVSinglePixel (int compositeSignal) static void ntscMonoTVSinglePixel (int compositeSignal)
{ {
SINGLETVPIXEL(compositeSignal, g_aNTSCMonoTelevision); SINGLETVPIXEL(compositeSignal, g_aNTSCMonoTelevisionCustom);
} }
static void ntscMonoTVDoublePixel (int compositeSignal) static void ntscMonoTVDoublePixel (int compositeSignal)
{ {
DOUBLETVPIXEL(compositeSignal, g_aNTSCMonoTelevision); DOUBLETVPIXEL(compositeSignal, g_aNTSCMonoTelevisionCustom);
} }
static void ntscColorTVSinglePixel (int compositeSignal) static void ntscColorTVSinglePixel (int compositeSignal)
@ -671,11 +678,30 @@ static void ntscColorTVDoublePixel (int compositeSignal)
static void (*ntscMonoPixel)(int) = ntscMonoSinglePixel; static void (*ntscMonoPixel)(int) = ntscMonoSinglePixel;
static void (*ntscColorPixel)(int) = ntscColorSinglePixel; static void (*ntscColorPixel)(int) = ntscColorSinglePixel;
//===========================================================================
void updateMonochromeColor( uint16_t r, uint16_t g, uint16_t b )
{
for( int iSample = 0; iSample < NTSC_NUM_SEQUENCES; iSample++ )
{
g_aNTSCMonoMonitorCustom[ iSample ][ _B ] = (g_aNTSCMonoMonitor[ iSample ][_B] * b) >> 8;
g_aNTSCMonoMonitorCustom[ iSample ][ _G ] = (g_aNTSCMonoMonitor[ iSample ][_G] * g) >> 8;
g_aNTSCMonoMonitorCustom[ iSample ][ _R ] = (g_aNTSCMonoMonitor[ iSample ][_R] * r) >> 8;
g_aNTSCMonoMonitorCustom[ iSample ][ _A ] = 0xFF;
g_aNTSCMonoTelevisionCustom[ iSample ][ _B ] = (g_aNTSCMonoTelevision[ iSample ][_B] * b) >> 8;
g_aNTSCMonoTelevisionCustom[ iSample ][ _G ] = (g_aNTSCMonoTelevision[ iSample ][_G] * g) >> 8;
g_aNTSCMonoTelevisionCustom[ iSample ][ _B ] = (g_aNTSCMonoTelevision[ iSample ][_R] * r) >> 8;
g_aNTSCMonoTelevisionCustom[ iSample ][ _A ] = 0xFF;
}
}
//=========================================================================== //===========================================================================
void NTSC_SetVideoStyle() // (int v, int s) void NTSC_SetVideoStyle() // (int v, int s)
{ {
int v = g_eVideoType; int v = g_eVideoType;
int s = g_uHalfScanLines; int s = g_uHalfScanLines;
uint8_t r, g, b;
switch (v) switch (v)
{ {
@ -712,10 +738,35 @@ void NTSC_SetVideoStyle() // (int v, int s)
break; break;
// case VT_MONO_WHITE: //VT_MONO_MONITOR: //3: // case VT_MONO_WHITE: //VT_MONO_MONITOR: //3:
case VT_MONO_AMBER: // RGB(0xFF,0x80,0x00) case VT_MONO_AMBER:
case VT_MONO_GREEN: // RGB(0x00,0xC0,0x00) r = 0xFF;
case VT_MONO_WHITE: // RGB(0xFF,0xFF,0xFF) g = 0x80;
b = 0x00;
goto _mono;
case VT_MONO_GREEN:
r = 0x00;
g = 0xC0;
b = 0x00;
goto _mono;
case VT_MONO_WHITE:
r = 0xFF;
g = 0xFF;
b = 0xFF;
goto _mono;
case VT_MONO_HALFPIXEL_REAL: case VT_MONO_HALFPIXEL_REAL:
// From WinGDI.h
// #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
//#define GetRValue(rgb) (LOBYTE(rgb))
//#define GetGValue(rgb) (LOBYTE(((WORD)(rgb)) >> 8))
//#define GetBValue(rgb) (LOBYTE((rgb)>>16))
r = (g_nMonochromeRGB >> 0) & 0xFF;
g = (g_nMonochromeRGB >> 8) & 0xFF;
b = (g_nMonochromeRGB >> 16) & 0xFF;
_mono:
updateMonochromeColor( r, g, b ); // Custom Monochrome color
if (s) { if (s) {
ntscMonoPixel = ntscColorPixel = ntscMonoSinglePixel; ntscMonoPixel = ntscColorPixel = ntscMonoSinglePixel;
} }

View File

@ -262,9 +262,9 @@ static bool g_bVideoUpdatedThisFrame = false;
static LPBYTE framebufferaddr = (LPBYTE)0; static LPBYTE framebufferaddr = (LPBYTE)0;
static LONG g_nFrameBufferPitch = 0; static LONG g_nFrameBufferPitch = 0;
COLORREF monochrome = RGB(0xC0,0xC0,0xC0); COLORREF g_nMonochromeRGB = RGB(0xC0,0xC0,0xC0);
static BOOL rebuiltsource = 0; static BOOL rebuiltsource = 0;
static LPBYTE vidlastmem = NULL; static LPBYTE vidlastmem = NULL;
static UINT g_uVideoMode = VF_TEXT; static UINT g_uVideoMode = VF_TEXT;
@ -324,7 +324,6 @@ static bool bVideoScannerNTSC = true; // NTSC video scanning (or PAL)
void V_CreateIdentityPalette (); void V_CreateIdentityPalette ();
void V_CreateDIBSections (); void V_CreateDIBSections ();
HBRUSH V_CreateCustomBrush (COLORREF nColor);
/** Our BitBlit() / VRAM_Copy() /** Our BitBlit() / VRAM_Copy()
@param dx Dst X @param dx Dst X
@ -379,6 +378,7 @@ void VideoInitialize ()
g_pFramebufferinfo->bmiHeader.biClrUsed = 0; g_pFramebufferinfo->bmiHeader.biClrUsed = 0;
NTSC_VideoCreateDIBSection(); NTSC_VideoCreateDIBSection();
// VideoReinitialize(); // Can't call here since Config_Video_Load() hasn't been called yet
} }
//=========================================================================== //===========================================================================
@ -439,15 +439,15 @@ void V_CreateIdentityPalette ()
SETFRAMECOLOR(HGR_PINK, 0xFF,0x32,0xB5); // 0xD0,0x40,0xA0 -> 0xFF,0x32,0xB5 SETFRAMECOLOR(HGR_PINK, 0xFF,0x32,0xB5); // 0xD0,0x40,0xA0 -> 0xFF,0x32,0xB5
SETFRAMECOLOR( MONOCHROME_CUSTOM SETFRAMECOLOR( MONOCHROME_CUSTOM
, GetRValue(monochrome) , GetRValue(g_nMonochromeRGB)
, GetGValue(monochrome) , GetGValue(g_nMonochromeRGB)
, GetBValue(monochrome) , GetBValue(g_nMonochromeRGB)
); );
SETFRAMECOLOR( MONOCHROME_CUSTOM_50 SETFRAMECOLOR( MONOCHROME_CUSTOM_50
, ((GetRValue(monochrome)/2) & 0xFF) , ((GetRValue(g_nMonochromeRGB)/2) & 0xFF)
, ((GetGValue(monochrome)/2) & 0xFF) , ((GetGValue(g_nMonochromeRGB)/2) & 0xFF)
, ((GetBValue(monochrome)/2) & 0xFF) , ((GetBValue(g_nMonochromeRGB)/2) & 0xFF)
); );
SETFRAMECOLOR( MONOCHROME_AMBER , 0xFF,0x80,0x01); // Used for Monochrome Hi-Res graphics not text! SETFRAMECOLOR( MONOCHROME_AMBER , 0xFF,0x80,0x01); // Used for Monochrome Hi-Res graphics not text!
@ -620,57 +620,6 @@ struct BRUSHBMP
BYTE bBits[64]; BYTE bBits[64];
}; };
HBRUSH V_CreateCustomBrush(COLORREF nColor)
{
BRUSHBMP brbmp;
BYTE *pBytes;
int i;
//DWORD dwBits[6][2] =
//{
// {0x000000ff,0x00000000}, // HS_HORIZONTAL 0 /* ----- */
// {0x10101010,0x10101010}, // HS_VERTICAL 1 /* ||||| */
// {0x01020408,0x10204080}, // HS_FDIAGONAL 2 /* \\\\\ */
// {0x80402010,0x08040201}, // HS_BDIAGONAL 3 /* ///// */
// {0x101010ff,0x10101010}, // HS_CROSS 4 /* +++++ */
// {0x81422418,0x18244281}, // HS_DIAGCROSS 5 /* xxxxx */
//};
// if ((HatchStyle < 0) || (HatchStyle > 6))
// return 0;
int HatchStyle = 0;
DWORD dwBits[1][2] =
{
// {0xff00ff00,0xff00ff00} // every other scan line
{0xFFFFFFFF,0xFFFFFFFF}
};
memset (&brbmp, 0, sizeof (brbmp));
brbmp.bmi.biSize = sizeof (BITMAPINFOHEADER);
brbmp.bmi.biWidth = 8;
brbmp.bmi.biHeight = 8;
brbmp.bmi.biPlanes = 1;
brbmp.bmi.biBitCount = 1;
brbmp.bmi.biClrUsed = 2;
brbmp.bmi.biClrImportant = 2;
// Initialize the palette of the bitmap.
brbmp.dwPal[0] = PALETTERGB(0x00,0x00,0x00);
brbmp.dwPal[1] = PALETTERGB(
(BYTE)((nColor >> 16) & 0xff),
(BYTE)((nColor >> 8) & 0xff),
(BYTE)((nColor >> 0) & 0xff));
// Write the hatch data to the bitmap.
pBytes = (BYTE *)&dwBits[HatchStyle];
for (i = 0; i < 8; i++)
brbmp.bBits[i*4] = *pBytes++;
// Return the handle of the brush created.
return CreateDIBPatternBrushPt (&brbmp, DIB_RGB_COLORS);
}
//=========================================================================== //===========================================================================
static void CreateLookup_TextCommon(HDC hDstDC, DWORD rop) static void CreateLookup_TextCommon(HDC hDstDC, DWORD rop)
@ -1043,12 +992,12 @@ void VideoChooseMonochromeColor ()
ZeroMemory(&cc,sizeof(CHOOSECOLOR)); ZeroMemory(&cc,sizeof(CHOOSECOLOR));
cc.lStructSize = sizeof(CHOOSECOLOR); cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = g_hFrameWindow; cc.hwndOwner = g_hFrameWindow;
cc.rgbResult = monochrome; cc.rgbResult = g_nMonochromeRGB;
cc.lpCustColors = customcolors + 1; cc.lpCustColors = customcolors + 1;
cc.Flags = CC_RGBINIT | CC_SOLIDCOLOR; cc.Flags = CC_RGBINIT | CC_SOLIDCOLOR;
if (ChooseColor(&cc)) if (ChooseColor(&cc))
{ {
monochrome = cc.rgbResult; g_nMonochromeRGB = cc.rgbResult;
VideoReinitialize(); VideoReinitialize();
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
{ {
@ -1933,7 +1882,7 @@ void Config_Load_Video()
{ {
REGLOAD(TEXT(REGVALUE_VIDEO_MODE ),&g_eVideoType); REGLOAD(TEXT(REGVALUE_VIDEO_MODE ),&g_eVideoType);
REGLOAD(TEXT(REGVALUE_VIDEO_HALF_SCAN_LINES),&g_uHalfScanLines); REGLOAD(TEXT(REGVALUE_VIDEO_HALF_SCAN_LINES),&g_uHalfScanLines);
REGLOAD(TEXT(REGVALUE_VIDEO_MONO_COLOR ),&monochrome); REGLOAD(TEXT(REGVALUE_VIDEO_MONO_COLOR ),&g_nMonochromeRGB);
if (g_eVideoType >= NUM_VIDEO_MODES) if (g_eVideoType >= NUM_VIDEO_MODES)
g_eVideoType = VT_COLOR_STANDARD; // Old default: VT_COLOR_TVEMU g_eVideoType = VT_COLOR_STANDARD; // Old default: VT_COLOR_TVEMU
@ -1943,7 +1892,7 @@ void Config_Save_Video()
{ {
REGSAVE(TEXT(REGVALUE_VIDEO_MODE ),g_eVideoType); REGSAVE(TEXT(REGVALUE_VIDEO_MODE ),g_eVideoType);
REGSAVE(TEXT(REGVALUE_VIDEO_HALF_SCAN_LINES),g_uHalfScanLines); REGSAVE(TEXT(REGVALUE_VIDEO_HALF_SCAN_LINES),g_uHalfScanLines);
REGSAVE(TEXT(REGVALUE_VIDEO_MONO_COLOR ),monochrome); REGSAVE(TEXT(REGVALUE_VIDEO_MONO_COLOR ),g_nMonochromeRGB);
} }
// ____________________________________________________________________ // ____________________________________________________________________

View File

@ -57,7 +57,7 @@
extern HBITMAP g_hLogoBitmap; extern HBITMAP g_hLogoBitmap;
extern COLORREF monochrome; // saved extern COLORREF g_nMonochromeRGB; // saved
extern DWORD g_eVideoType; // saved extern DWORD g_eVideoType; // saved
extern DWORD g_uHalfScanLines; // saved extern DWORD g_uHalfScanLines; // saved
extern uint8_t *g_pFramebufferbits; extern uint8_t *g_pFramebufferbits;