[Coco] My Vcc project update.
Robert Gault
robert.gault at att.net
Wed Jul 11 21:51:09 EDT 2018
Walter,
I think that John Kowalski developed the MAME artifacting code but in any case you should look at
the source code in Devices/Video/mc6847.cpp . At least that was the code for the 1.86 version.
Here is the section and note the commentary about "this code sucks."
//**************************************************************************
// ARTIFACTING
//**************************************************************************
INPUT_PORTS_START(mc6847_artifacting)
PORT_START(ARTIFACTING_TAG)
PORT_CONFNAME( 0x03, 0x01, "Artifacting" )
PORT_CONFSETTING( 0x00, DEF_STR( Off ) )
PORT_CONFSETTING( 0x01, DEF_STR( Standard ) )
PORT_CONFSETTING( 0x02, DEF_STR( Reverse ) )
INPUT_PORTS_END
ioport_constructor mc6847_base_device::device_input_ports() const
{
return INPUT_PORTS_NAME(mc6847_artifacting);
}
//-------------------------------------------------
// ctor
//-------------------------------------------------
mc6847_base_device::artifacter::artifacter()
{
m_config = nullptr;
m_artifacting = 0;
m_saved_artifacting = 0;
m_saved_c0 = 0;
m_saved_c1 = 0;
memset(m_expanded_colors, 0, sizeof(m_expanded_colors));
}
//-------------------------------------------------
// artifacter::setup_config
//-------------------------------------------------
void mc6847_base_device::artifacter::setup_config(device_t *device)
{
char port_name[32];
snprintf(port_name, ARRAY_LENGTH(port_name), "%s:%s", device->tag(), ARTIFACTING_TAG);
m_config = device->ioport(port_name);
}
//-------------------------------------------------
// artifacter::update_colors
//-------------------------------------------------
void mc6847_base_device::artifacter::update_colors(pixel_t c0, pixel_t c1)
{
/* Boy this code sucks; this code was adapted from the old M6847
* artifacting implmentation. The only reason that it didn't look as
* horrible was because the code around it sucked as well. Now that I
* have cleaned everything up, the ugliness is much more prominent.
*
* Hopefully we will have a generic artifacting algorithm that plugs into
* the MESS/MAME core directly so we can chuck this hack */
static const double artifact_colors[14*3] =
{
0.157, 0.000, 0.157, /* [ 1] - dk purple (reverse 2) */
0.000, 0.157, 0.000, /* [ 2] - dk green (reverse 1) */
1.000, 0.824, 1.000, /* [ 3] - lt purple (reverse 4) */
0.824, 1.000, 0.824, /* [ 4] - lt green (reverse 3) */
0.706, 0.236, 0.118, /* [ 5] - dk blue (reverse 6) */
0.000, 0.197, 0.471, /* [ 6] - dk red (reverse 5) */
1.000, 0.550, 0.393, /* [ 7] - lt blue (reverse 8) */
0.275, 0.785, 1.000, /* [ 8] - lt red (reverse 7) */
0.000, 0.500, 1.000, /* [ 9] - red (reverse 10) */
1.000, 0.500, 0.000, /* [10] - blue (reverse 9) */
1.000, 0.942, 0.785, /* [11] - cyan (reverse 12) */
0.393, 0.942, 1.000, /* [12] - yellow (reverse 11) */
0.236, 0.000, 0.000, /* [13] - black-blue (reverse 14) */
0.000, 0.000, 0.236 /* [14] - black-red (reverse 13) */
};
static const uint8_t artifact_correction[128] =
{
0, 0, 0, 0, 0, 6, 0, 2,
5, 7, 5, 7, 1, 3, 1, 11,
8, 6, 8, 14, 8, 9, 8, 9,
4, 4, 4, 15, 12, 12, 12, 15,
5, 13, 5, 13, 13, 0, 13, 2,
10, 10, 10, 10, 10, 15, 10, 11,
3, 1, 3, 1, 15, 9, 15, 9,
11, 11, 11, 11, 15, 15, 15, 15,
14, 0, 14, 0, 14, 6, 14, 2,
0, 7, 0, 7, 1, 3, 1, 11,
9, 6, 9, 14, 9, 9, 9, 9,
15, 4, 15, 15, 12, 12, 12, 15,
2, 13, 2, 13, 2, 0, 2, 2,
10, 10, 10, 10, 10, 15, 10, 11,
12, 1, 12, 1, 12, 9, 12, 9,
15, 11, 15, 11, 15, 15, 15, 15
};
pixel_t colors[16];
int i;
/* do we need to update our artifact colors table? */
if ((m_artifacting != m_saved_artifacting) || (c0 != m_saved_c0) || (c1 != m_saved_c1))
{
m_saved_artifacting = m_artifacting;
m_saved_c0 = colors[0] = c0;
m_saved_c1 = colors[15] = c1;
/* mix the other colors */
for (i = 1; i <= 14; i++)
{
const double *factors = &artifact_colors[((i - 1) ^ (m_artifacting & 0x01)) * 3];
colors[i] = (mix_color(factors[0], c0 >> 16, c1 >> 16) << 16)
| (mix_color(factors[1], c0 >> 8, c1 >> 8) << 8)
| (mix_color(factors[2], c0 >> 0, c1 >> 0) << 0);
}
for (i = 0; i < 128; i++)
{
m_expanded_colors[i] = colors[artifact_correction[i]];
}
}
}
//-------------------------------------------------
// artifacter::update
//-------------------------------------------------
mc6847_base_device::pixel_t mc6847_base_device::artifacter::mix_color(double factor, uint8_t c0,
uint8_t c1)
{
return (uint32_t) (uint8_t) ((c0 * (1.0 - factor)) + (c1 * (0.0 + factor)) + 0.5);
}
Walter wrote:
> Artifacting may be tricky for me because I only have a PAL CoCo III.
>
> From memory artifacting changes depending on PAL or NTSC versions.
>
> But if I look at the MAME code that might help!!!
> <snip>
More information about the Coco
mailing list