Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
#64986 - 10/13/10 05:14 AM MC6847 (CoCo) colors: more accurate values?  
Joined: Jul 2009
Posts: 78
Ensjo Offline
Member
Ensjo  Offline
Member

Joined: Jul 2009
Posts: 78
Belém, PA, Brazil
Currently the colors of the MC6847 "Video Display Generator" chip used in CoCo and other machines are defined like this:
Code:
static const UINT32 default_palette[] =
{
    M6847_RGB(0x00, 0xff, 0x00),    /* GREEN */
    M6847_RGB(0xff, 0xff, 0x00),    /* YELLOW */
    M6847_RGB(0x00, 0x00, 0xff),    /* BLUE */
    M6847_RGB(0xff, 0x00, 0x00),    /* RED */
    M6847_RGB(0xff, 0xff, 0xff),    /* BUFF */
    M6847_RGB(0x00, 0xff, 0xff),    /* CYAN */
    M6847_RGB(0xff, 0x00, 0xff),    /* MAGENTA */
    M6847_RGB(0xff, 0x80, 0x00),    /* ORANGE */

    M6847_RGB(0x00, 0x00, 0x00),    /* BLACK */
    M6847_RGB(0x00, 0xff, 0x00),    /* GREEN */
    M6847_RGB(0x00, 0x00, 0x00),    /* BLACK */
    M6847_RGB(0xff, 0xff, 0xff),    /* BUFF */

    M6847_RGB(0x00, 0x40, 0x00),    /* ALPHANUMERIC DARK GREEN */
    M6847_RGB(0x00, 0xff, 0x00),    /* ALPHANUMERIC BRIGHT GREEN */
    M6847_RGB(0x40, 0x10, 0x00),    /* ALPHANUMERIC DARK ORANGE */
    M6847_RGB(0xff, 0xc4, 0x18)     /* ALPHANUMERIC BRIGHT ORANGE */
};

There are plenty of "pure" colors there. But are these the colors effectively generated by MC6847?

The MC6847 datasheet says that the colors are formed by the combination of three signals: Y, phiA and phiB, according to the Y'UV colorspace.

According to the table "DC (STATIC) CHARACTERISTICS" in the datasheet, when producing color, Y may assume one of these voltages: "Black" = 0.72V; "White Low" = 0.65V; "White Medium" = 0.54V; "White High" = 0.42V. phiA and phiB may be: "Output Low" = 1.0V; "R(eference?)" = 1.5V; "Input High" = 2.0V.

"FIGURE 10 - VIDEO AND CHROMINANCE OUTPUT WAVEFORM RELATIONSHIPS" shows the combinations of voltages used to produce each color.

Mapping the values of Y to a 0~255 range, we get "Black" = 0; "White Low" = 59; "White Medium" = 153; and "White High" = 255. phiA and phiB can be mapped to -128, 0, +128.

These values can then be converted to RGB according to the formulae (found in Wikipedia):
  • R = Y' + 1,13983 × U
  • G = Y' - 0,39465 × U - 0,58060 × V
  • B = Y' + 2,03211 × V

So we get:
  • GREEN = Y'UV(153,-128,-128) = RGB(7,277,-107) --> #07ff00
  • YELLOW = Y'UV(255,-128,0) = RGB(255,305,-5) --> #ffff00
  • BLUE = Y'UV(59,+128,0) = RGB(59,8,319) --> #3b08ff
  • RED: Y'UV(59,0,+128) = RGB(204,-15,59) --> #cc003b
  • WHITE: Y'UV(255,0,0) = RGB(255,255,255) --> #ffffff
  • CYAN: Y'UV(153,0,-128) = RGB(7,227,153) --> #07e399
  • MAGENTA: Y'UV(153,+128,+128) = RGB(298,28,413) --> #ff1cff
  • ORANGE: Y'UV(153,-128,+128) = RGB(298,129,-107) --> #ff8100
  • BLACK: Y'UV(0,0,0) = RGB(0,0,0) --> #000000
  • DARK GREEN: Y'UV(0,-128,-128) = RGB(-145,124,-260) --> #007c00
  • DARK ORANGE/RED: Y'UV(0,-128,+128) = RGB(145,-23,-260) --> #910000

Since these values are based on what MC6847 actually does, I suppose they are more accurate than the "pure" green (#00ff00), red (#ff0000), etc. that are currently being used.

Last edited by Ensjo; 10/13/10 05:24 AM.
#64989 - 10/13/10 02:59 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Ensjo]  
Joined: Feb 2005
Posts: 448
Curt Coder Offline
Senior Member
Curt Coder  Offline
Senior Member

Joined: Feb 2005
Posts: 448
Finland
Now in svn.

#64990 - 10/13/10 03:44 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Curt Coder]  
Joined: Aug 2009
Posts: 1,132
Kale Offline
Very Senior Member
Kale  Offline
Very Senior Member

Joined: Aug 2009
Posts: 1,132
Naples, Italy
PC-6001VW vs. MESS MC6847 color comparision:





Still somewhat wrong there for sure, but at least they matches more than before, or perhaps MESS is right and PC-6001VW is wrong ... but how to test it out? smirk

#64992 - 10/13/10 04:28 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Kale]  
Joined: May 2004
Posts: 1,398
Haze Offline
Very Senior Member
Haze  Offline
Very Senior Member

Joined: May 2004
Posts: 1,398
doesn't MAME have YUV conversion stuff, or is it only for the LDs?

#64993 - 10/13/10 04:39 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Haze]  
Joined: Mar 2001
Posts: 15,753
R. Belmont Offline
R. Belmont  Offline

Very Senior Member

Joined: Mar 2001
Posts: 15,753
USA
It does, but it's overkill for this type of case. The usual thing to do (as per e.g. NES) is to have PALETTE_INIT actually calculate the palette from the YUV values so it's documented where they come from.

#64996 - 10/13/10 06:05 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: R. Belmont]  
Joined: Dec 2007
Posts: 301
Robert Gault Offline
Senior Member
Robert Gault  Offline
Senior Member

Joined: Dec 2007
Posts: 301
Michigan
Well as this thread started as MC6847 (CoCo), smile I just ran a side-by-side test of MESS SVN Coco3 vs a real Coco3. Monitor on PC is SyncMaster 204B and on Coco3 a Magnavox Professional RGB 8CM873. MESS is set for a raster effect so the screens look the same as the Magnavox.

Expecting identical colors from these two monitors may be asking too much, but the CLS CoCo colors are pretty darn close with proper adjustment of the Magnavox monitor brightness and contrast.
The most noticeable difference is CLS4 "red" which is quite red on MESS but has some orange content on the Coco3. CLS2 "yellow" seems to have a slight greenish tint on the Coco3 compared to MESS.
The other colors are essentially identical. The MESS colors seem very slightly more saturated but that is probably monitor differences.

#64998 - 10/13/10 10:26 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Robert Gault]  
Joined: May 2004
Posts: 832
Duke Offline
Senior Member
Duke  Offline
Senior Member

Joined: May 2004
Posts: 832
Germany
Note that the Coco uses coco6847.c, so it hasn't actually been updated yet.

#65008 - 10/14/10 02:15 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Kale]  
Joined: Jul 2009
Posts: 78
Ensjo Offline
Member
Ensjo  Offline
Member

Joined: Jul 2009
Posts: 78
Belém, PA, Brazil
Originally Posted By Curt Coder
Now in svn.

Great, Curt. smile But it would be good to document the origin of the values. What do you think of Belmont's ideia?

Originally Posted By R. Belmont
The usual thing to do (as per e.g. NES) is to have PALETTE_INIT actually calculate the palette from the YUV values so it's documented where they come from.

By the way, Curt, there's also the fact that although the MC6847's specs (TABLE 3 — DETAILED DESCRIPTION OF VDG MODES) says its Resolution Graphics modes' background is BLACK for both values of the CSS pin, in fact it is DARK GREEN when the pin CSS = 0 (i.e. when the foreground color is GREEN).

Check out the videos, taken from a real MC-1000:
  • Alternating between Resolution Graphics 6 mode with MC6847's pin CSS=0 ("BLACK"/GREEN) and CSS=1 (BLACK/BUFF). The change in background color is perceivable.
    http://www.ensjo.net/mc-1000/MVI_1261.AVI
  • Alternating of Resolution Graphics 6 mode with CSS=0 and Alphanumerics Internal mode with CSS=0 (GREEN text, not ORANGE) and INV=0 (bright chars on dark background). No change in background color is observed.
    http://www.ensjo.net/mc-1000/MVI_1262.AVI

So on mc6847.c, instead of:
Code:
    M6847_RGB(0x00, 0x00, 0x00),    /* BLACK */
    M6847_RGB(0x00, 0x7c, 0x00),    /* GREEN */

we should have:
Code:
    M6847_RGB(0x00, 0x7c, 0x00),    /* DARK GREEN */
    M6847_RGB(0x07, 0xff, 0x00),    /* GREEN */

(Note that the GREEN color was wrong here.)

Originally Posted By Kale
PC-6001VW vs. MESS MC6847 color comparision:




Well... ORANGE in PC-6001W is so whitish, almost pink... And DARK ORANGE is just plain orange there. That simply is NOT what I see on my real-life MC-1000.

[whiner]Oh... Green and orange text, normal and inverse, on the same screen... Damned MC-1000 designers, didn't wire MC6847 smartly to mix its screen modes. Since its BASIC is similar to Apple II's, probably they wanted to make it visually similar to Apple II on screen too (and that explains why the default text is bright on dark), so we have no block characters, no color, only inverse. So boring, booohooohoooo... :'(

[/whiner]

#65285 - 10/27/10 02:49 AM Re: MC6847 (CoCo) colors: more accurate values? [Re: Ensjo]  
Joined: Jul 2009
Posts: 78
Ensjo Offline
Member
Ensjo  Offline
Member

Joined: Jul 2009
Posts: 78
Belém, PA, Brazil
Originally Posted By Ensjo
it would be good to document the origin of the values.

I added comments to explain the RGB colors.
SVN diff:
Code:
Index: src/mess/video/m6847.c
===================================================================
--- src/mess/video/m6847.c	(revision 9454)
+++ src/mess/video/m6847.c	(working copy)
@@ -966,6 +966,60 @@
 
 #define ATTOTIME_STRING_PRECISION	9
 
+/* MC6847 video output pins: Y, phiA, phiB (Y'UV color space).
+ *
+ * Y voltage levels:
+ * VB ("Black") = 0.72V; VWL ("White Low") = 0.65V; VWM ("White Medium") = 0.54V;
+ * VWH ("White High") = 0.42V.
+ *
+ * phiA and phiB voltage levels:
+ * VOL ("Output Low") = 1.0V; VR ("Reference"?) = 1.5V; VIH ("Input High") = 2.0V.
+ *
+ * Color composition:
+ * 
+ * COLOR       |  Y  | phiA | phiB
+ * ------------+-----+------+------
+ * GREEN       | VWM | VOL  | VOL
+ * YELLOW      | VWH | VOL  | VR
+ * BLUE        | VWL | VIH  | VR
+ * RED         | VWL | VR   | VIH
+ * WHITE       | VWH | VR   | VR
+ * CYAN        | VWM | VR   | VOL
+ * MAGENTA     | VWM | VIH  | VIH
+ * ORANGE      | VWM | VOL  | VIH
+ * BLACK       | VB  | VR   | VR
+ * DARK GREEN  | VB  | VOL  | VOL
+ * DARK ORANGE | VB  | VOL  | VIH
+ *
+ *
+ * Mapping voltages to a 0~255 range:
+ *
+ * Y values:
+ * VB = 0; VWL = 59; VWM = 153; VWH = 255.
+ *
+ * phiA and phiB values:
+ * VOL = -128; VR = 0; VIH = +128.
+ *
+ *
+ * Y'UV to RGB convertion:
+ * R = Y' + 1.13983 x U
+ * G = Y' - 0.39465 x U - 0.58060 x V
+ * B = Y' + 2.03211 x V
+ * 
+ * So we get:
+ * GREEN = Y'UV(153,-128,-128) = RGB(7,277,-107) --> #07ff00
+ * YELLOW = Y'UV(255,-128,0) = RGB(255,305,-5) --> #ffff00
+ * BLUE = Y'UV(59,+128,0) = RGB(59,8,319) --> #3b08ff
+ * RED: Y'UV(59,0,+128) = RGB(204,-15,59) --> #cc003b
+ * WHITE: Y'UV(255,0,0) = RGB(255,255,255) --> #ffffff
+ * CYAN: Y'UV(153,0,-128) = RGB(7,227,153) --> #07e399
+ * MAGENTA: Y'UV(153,+128,+128) = RGB(298,28,413) --> #ff1cff
+ * ORANGE: Y'UV(153,-128,+128) = RGB(298,129,-107) --> #ff8100
+ * BLACK: Y'UV(0,0,0) = RGB(0,0,0) --> #000000
+ * DARK GREEN: Y'UV(0,-128,-128) = RGB(-145,124,-260) --> #007c00
+ * DARK ORANGE: Y'UV(0,-128,+128) = RGB(145,-23,-260) --> #910000
+ */
+
 #define M6847_RGB(r,g,b)	((r << 16) | (g << 8) | (b << 0))
 
 
@@ -980,9 +1034,9 @@
 	M6847_RGB(0xff, 0x1c, 0xff),	/* MAGENTA */
 	M6847_RGB(0xff, 0x81, 0x00),	/* ORANGE */
 
+	M6847_RGB(0x00, 0x7c, 0x00),	/* DARK GREEN */
+	M6847_RGB(0x07, 0xff, 0x00),	/* GREEN */
 	M6847_RGB(0x00, 0x00, 0x00),	/* BLACK */
-	M6847_RGB(0x00, 0x7c, 0x00),	/* GREEN */
-	M6847_RGB(0x00, 0x00, 0x00),	/* BLACK */
 	M6847_RGB(0xff, 0xff, 0xff),	/* BUFF */
 
 	M6847_RGB(0x00, 0x7c, 0x00),	/* ALPHANUMERIC DARK GREEN */


#65295 - 10/27/10 05:54 PM Re: MC6847 (CoCo) colors: more accurate values? [Re: Ensjo]  
Joined: Jul 2009
Posts: 78
Ensjo Offline
Member
Ensjo  Offline
Member

Joined: Jul 2009
Posts: 78
Belém, PA, Brazil
CORRECTION!!! As I changed one of the two blacks in the default_palette[] array to dark green in the diff above, the text and semigraphic modes got their border and/or background color changed to dark green as well. A little fix and now they use the real black that remained. Please use this new diff instead of the one above:
Code:
Index: src/mess/video/m6847.c
===================================================================
--- src/mess/video/m6847.c	(revision 9454)
+++ src/mess/video/m6847.c	(working copy)
@@ -955,7 +955,7 @@
 	GREEN, YELLOW, BLUE, RED,		/*  0 -  3 */
 	BUFF, CYAN, MAGENTA, ORANGE,	/*  4 -  7 */
 
-	BLACK,							/*  8 */
+	BLACK = 10,						/* 10 */
 
 	DKGREEN = 12, LTGREEN = 13,		/* 12 - 13 */
 	DKORANGE = 14, LTORANGE = 15,	/* 14 - 15 */
@@ -966,6 +966,60 @@
 
 #define ATTOTIME_STRING_PRECISION	9
 
+/* MC6847 video output pins: Y, phiA, phiB (Y'UV color space).
+ *
+ * Y voltage levels:
+ * VB ("Black") = 0.72V; VWL ("White Low") = 0.65V; VWM ("White Medium") = 0.54V;
+ * VWH ("White High") = 0.42V.
+ *
+ * phiA and phiB voltage levels:
+ * VOL ("Output Low") = 1.0V; VR ("Reference"?) = 1.5V; VIH ("Input High") = 2.0V.
+ *
+ * Color composition:
+ * 
+ * COLOR       |  Y  | phiA | phiB
+ * ------------+-----+------+------
+ * GREEN       | VWM | VOL  | VOL
+ * YELLOW      | VWH | VOL  | VR
+ * BLUE        | VWL | VIH  | VR
+ * RED         | VWL | VR   | VIH
+ * WHITE       | VWH | VR   | VR
+ * CYAN        | VWM | VR   | VOL
+ * MAGENTA     | VWM | VIH  | VIH
+ * ORANGE      | VWM | VOL  | VIH
+ * BLACK       | VB  | VR   | VR
+ * DARK GREEN  | VB  | VOL  | VOL
+ * DARK ORANGE | VB  | VOL  | VIH
+ *
+ *
+ * Mapping voltages to a 0~255 range:
+ *
+ * Y values:
+ * VB = 0; VWL = 59; VWM = 153; VWH = 255.
+ *
+ * phiA and phiB values:
+ * VOL = -128; VR = 0; VIH = +128.
+ *
+ *
+ * Y'UV to RGB convertion:
+ * R = Y' + 1.13983 x U
+ * G = Y' - 0.39465 x U - 0.58060 x V
+ * B = Y' + 2.03211 x V
+ * 
+ * So we get:
+ * GREEN = Y'UV(153,-128,-128) = RGB(7,277,-107) --> #07ff00
+ * YELLOW = Y'UV(255,-128,0) = RGB(255,305,-5) --> #ffff00
+ * BLUE = Y'UV(59,+128,0) = RGB(59,8,319) --> #3b08ff
+ * RED: Y'UV(59,0,+128) = RGB(204,-15,59) --> #cc003b
+ * WHITE: Y'UV(255,0,0) = RGB(255,255,255) --> #ffffff
+ * CYAN: Y'UV(153,0,-128) = RGB(7,227,153) --> #07e399
+ * MAGENTA: Y'UV(153,+128,+128) = RGB(298,28,413) --> #ff1cff
+ * ORANGE: Y'UV(153,-128,+128) = RGB(298,129,-107) --> #ff8100
+ * BLACK: Y'UV(0,0,0) = RGB(0,0,0) --> #000000
+ * DARK GREEN: Y'UV(0,-128,-128) = RGB(-145,124,-260) --> #007c00
+ * DARK ORANGE: Y'UV(0,-128,+128) = RGB(145,-23,-260) --> #910000
+ */
+
 #define M6847_RGB(r,g,b)	((r << 16) | (g << 8) | (b << 0))
 
 
@@ -980,9 +1034,9 @@
 	M6847_RGB(0xff, 0x1c, 0xff),	/* MAGENTA */
 	M6847_RGB(0xff, 0x81, 0x00),	/* ORANGE */
 
+	M6847_RGB(0x00, 0x7c, 0x00),	/* DARK GREEN */
+	M6847_RGB(0x07, 0xff, 0x00),	/* GREEN */
 	M6847_RGB(0x00, 0x00, 0x00),	/* BLACK */
-	M6847_RGB(0x00, 0x7c, 0x00),	/* GREEN */
-	M6847_RGB(0x00, 0x00, 0x00),	/* BLACK */
 	M6847_RGB(0xff, 0xff, 0xff),	/* BUFF */
 
 	M6847_RGB(0x00, 0x7c, 0x00),	/* ALPHANUMERIC DARK GREEN */

Page 1 of 2 1 2

Who's Online Now
1 registered members (Reznor007), 15 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Shout Box
Forum Statistics
Forums9
Topics8,436
Posts109,400
Members4,766
Most Online225
May 26th, 2014
Powered by UBB.threads™ PHP Forum Software 7.6.0
Page Time: 0.095s Queries: 15 (0.051s) Memory: 5.0285 MB (Peak: 5.2525 MB) Zlib enabled. Server Time: 2017-11-22 03:32:38 UTC