void create_palette(palette_device palette) { ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); int i; for (i = 0; i < 256; i++) { int bit0; int bit1; int bit2; int bit3; /* red component */ bit0 = (color_prom[i + 0 * 256] >> 0) & 0x01; bit1 = (color_prom[i + 0 * 256] >> 1) & 0x01; bit2 = (color_prom[i + 0 * 256] >> 2) & 0x01; bit3 = (color_prom[i + 0 * 256] >> 3) & 0x01; int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; /* green component */ bit0 = (color_prom[i + 1 * 256] >> 0) & 0x01; bit1 = (color_prom[i + 1 * 256] >> 1) & 0x01; bit2 = (color_prom[i + 1 * 256] >> 2) & 0x01; bit3 = (color_prom[i + 1 * 256] >> 3) & 0x01; int g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; /* blue component */ bit0 = (color_prom[i + 2 * 256] >> 0) & 0x01; bit1 = (color_prom[i + 2 * 256] >> 1) & 0x01; bit2 = (color_prom[i + 2 * 256] >> 2) & 0x01; bit3 = (color_prom[i + 2 * 256] >> 3) & 0x01; int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; palette.palette_interface.set_indirect_color(i, new rgb_t((u8)r, (u8)g, (u8)b)); } }
public void dkong2b_palette(palette_device palette) { ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); std.vector <rgb_t> rgb; compute_res_net_all(out rgb, color_prom, dkong_decode_info, dkong_net_info); palette.palette_interface.set_pen_colors(0, rgb); // Now treat tri-state black background generation for (int i = 0; i < 256; i++) { if ((i & 0x03) == 0x00) // NOR => CS=1 => Tristate => real black { int r = compute_res_net(1, 0, dkong_net_bck_info); int g = compute_res_net(1, 1, dkong_net_bck_info); int b = compute_res_net(1, 2, dkong_net_bck_info); palette.palette_interface.set_pen_color((pen_t)i, (u8)r, (u8)g, (u8)b); } } palette.device_palette_interface.palette().normalize_range(0, 255); color_prom += 512; // color_prom now points to the beginning of the character color codes m_color_codes = color_prom; // we'll need it later }
void _1942_palette(palette_device palette) { create_palette(palette); /* characters use palette entries 128-143 */ int colorbase = 0; Pointer <uint8_t> charlut_prom = new Pointer <uint8_t>(memregion("charprom").base_()); //const uint8_t *charlut_prom = memregion("charprom")->base(); for (int i = 0; i < 64 * 4; i++) { palette.set_pen_indirect((pen_t)(colorbase + i), (indirect_pen_t)(0x80 | charlut_prom[i])); } // background tiles use palette entries 0-63 in four banks colorbase += 64 * 4; Pointer <uint8_t> tilelut_prom = new Pointer <uint8_t>(memregion("tileprom").base_()); //const uint8_t *tilelut_prom = memregion("tileprom")->base(); for (int i = 0; i < 32 * 8; i++) { palette.set_pen_indirect((pen_t)(colorbase + 0 * 32 * 8 + i), (indirect_pen_t)(0x00 | tilelut_prom[i])); palette.set_pen_indirect((pen_t)(colorbase + 1 * 32 * 8 + i), (indirect_pen_t)(0x10 | tilelut_prom[i])); palette.set_pen_indirect((pen_t)(colorbase + 2 * 32 * 8 + i), (indirect_pen_t)(0x20 | tilelut_prom[i])); palette.set_pen_indirect((pen_t)(colorbase + 3 * 32 * 8 + i), (indirect_pen_t)(0x30 | tilelut_prom[i])); } // sprites use palette entries 64-79 colorbase += 4 * 32 * 8; Pointer <uint8_t> sprlut_prom = new Pointer <uint8_t>(memregion("sprprom").base_()); //const uint8_t *sprlut_prom = memregion("sprprom")->base(); for (int i = 0; i < 16 * 16; i++) { palette.set_pen_indirect((pen_t)(colorbase + i), (indirect_pen_t)(0x40 | sprlut_prom[i])); } }
void create_palette(palette_device palette) { Pointer <uint8_t> color_prom = new Pointer <uint8_t>(memregion("palproms").base_()); //const uint8_t *color_prom = memregion("palproms")->base(); for (int i = 0; i < 256; i++) { /* red component */ int bit0 = BIT(color_prom[i + 0 * 256], 0); int bit1 = BIT(color_prom[i + 0 * 256], 1); int bit2 = BIT(color_prom[i + 0 * 256], 2); int bit3 = BIT(color_prom[i + 0 * 256], 3); int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; /* green component */ bit0 = BIT(color_prom[i + 1 * 256], 0); bit1 = BIT(color_prom[i + 1 * 256], 1); bit2 = BIT(color_prom[i + 1 * 256], 2); bit3 = BIT(color_prom[i + 1 * 256], 3); int gr = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; /* blue component */ bit0 = BIT(color_prom[i + 2 * 256], 0); bit1 = BIT(color_prom[i + 2 * 256], 1); bit2 = BIT(color_prom[i + 2 * 256], 2); bit3 = BIT(color_prom[i + 2 * 256], 3); int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; palette.set_indirect_color(i, new rgb_t((u8)r, (u8)gr, (u8)b)); } }
/*************************************************************************** * * Convert the color PROMs. * * digdug has one 32x8 palette PROM and two 256x4 color lookup table PROMs * (one for characters, one for sprites). * The palette PROM is connected to the RGB output this way: * * bit 7 -- 220 ohm resistor -- BLUE * -- 470 ohm resistor -- BLUE * -- 220 ohm resistor -- GREEN * -- 470 ohm resistor -- GREEN * -- 1 kohm resistor -- GREEN * -- 220 ohm resistor -- RED * -- 470 ohm resistor -- RED * bit 0 -- 1 kohm resistor -- RED * ***************************************************************************/ void digdug_palette(palette_device palette) { Pointer <uint8_t> color_prom = new Pointer <uint8_t>(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); for (int i = 0; i < 32; i++) { int bit0; int bit1; int bit2; bit0 = BIT(color_prom.op, 0); bit1 = BIT(color_prom.op, 1); bit2 = BIT(color_prom.op, 2); int r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = BIT(color_prom.op, 3); bit1 = BIT(color_prom.op, 4); bit2 = BIT(color_prom.op, 5); int gr = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = 0; bit1 = BIT(color_prom.op, 6); bit2 = BIT(color_prom.op, 7); int b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; palette.set_indirect_color(i, new rgb_t((u8)r, (u8)gr, (u8)b)); color_prom++; } // characters - direct mapping for (int i = 0; i < 16; i++) { palette.set_pen_indirect((pen_t)((i << 1) | 0), 0); palette.set_pen_indirect((pen_t)((i << 1) | 1), (indirect_pen_t)i); } // sprites for (int i = 0; i < 0x100; i++) { palette.set_pen_indirect((pen_t)(16 * 2 + i), (indirect_pen_t)((color_prom.op & 0x0f) | 0x10)); color_prom++; } // bg_select for (int i = 0; i < 0x100; i++) { palette.set_pen_indirect((pen_t)(16 * 2 + 256 + i), (indirect_pen_t)(color_prom.op & 0x0f)); color_prom++; } }
/*************************************************************************** * * Convert the color PROMs. * * digdug has one 32x8 palette PROM and two 256x4 color lookup table PROMs * (one for characters, one for sprites). * The palette PROM is connected to the RGB output this way: * * bit 7 -- 220 ohm resistor -- BLUE * -- 470 ohm resistor -- BLUE * -- 220 ohm resistor -- GREEN * -- 470 ohm resistor -- GREEN * -- 1 kohm resistor -- GREEN * -- 220 ohm resistor -- RED * -- 470 ohm resistor -- RED * bit 0 -- 1 kohm resistor -- RED * ***************************************************************************/ public void digdug_palette(palette_device palette) { ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); for (int i = 0; i < 32; i++) { int bit0; int bit1; int bit2; bit0 = BIT(color_prom[0], 0); bit1 = BIT(color_prom[0], 1); bit2 = BIT(color_prom[0], 2); int r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = BIT(color_prom[0], 3); bit1 = BIT(color_prom[0], 4); bit2 = BIT(color_prom[0], 5); int g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = 0; bit1 = BIT(color_prom[0], 6); bit2 = BIT(color_prom[0], 7); int b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; palette.palette_interface.set_indirect_color(i, new rgb_t((byte)r, (byte)g, (byte)b)); color_prom++; } // characters - direct mapping for (int i = 0; i < 16; i++) { palette.palette_interface.set_pen_indirect((pen_t)((i << 1) | 0), 0); palette.palette_interface.set_pen_indirect((pen_t)((i << 1) | 1), (UInt16)i); } // sprites for (int i = 0; i < 0x100; i++) { palette.palette_interface.set_pen_indirect((pen_t)(16 * 2 + i), (UInt16)((color_prom[0] & 0x0f) | 0x10)); color_prom++; } // bg_select for (int i = 0; i < 0x100; i++) { palette.palette_interface.set_pen_indirect((pen_t)(16 * 2 + 256 + i), (UInt16)(color_prom[0] & 0x0f)); color_prom++; } }
public void _1942_palette(palette_device palette) { create_palette(palette); ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); color_prom += 3 * 256; // color_prom now points to the beginning of the lookup table /* characters use palette entries 128-143 */ int colorbase = 0; for (int i = 0; i < 64 * 4; i++) { palette.palette_interface.set_pen_indirect((pen_t)(colorbase + i), (indirect_pen_t)(0x80 | color_prom[0])); //*color_prom++); color_prom++; } // background tiles use palette entries 0-63 in four banks colorbase += 64 * 4; for (int i = 0; i < 32 * 8; i++) { palette.palette_interface.set_pen_indirect((pen_t)(colorbase + 0 * 32 * 8 + i), (indirect_pen_t)(0x00 | color_prom[0])); //*color_prom); palette.palette_interface.set_pen_indirect((pen_t)(colorbase + 1 * 32 * 8 + i), (indirect_pen_t)(0x10 | color_prom[0])); palette.palette_interface.set_pen_indirect((pen_t)(colorbase + 2 * 32 * 8 + i), (indirect_pen_t)(0x20 | color_prom[0])); palette.palette_interface.set_pen_indirect((pen_t)(colorbase + 3 * 32 * 8 + i), (indirect_pen_t)(0x30 | color_prom[0])); color_prom++; } // sprites use palette entries 64-79 colorbase += 4 * 32 * 8; for (int i = 0; i < 16 * 16; i++) { palette.palette_interface.set_pen_indirect((pen_t)(colorbase + i), (indirect_pen_t)(0x40 | color_prom[0])); //*color_prom++); color_prom++; } }
public void radarscp_palette(palette_device palette) { ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); for (int i = 0; i < 256; i++) { // red component int r = compute_res_net((color_prom[256] >> 1) & 0x07, 0, radarscp_net_info); // green component int g = compute_res_net(((color_prom[256] << 2) & 0x04) | ((color_prom[0] >> 2) & 0x03), 1, radarscp_net_info); // blue component int b = compute_res_net((color_prom[0] >> 0) & 0x03, 2, radarscp_net_info); palette.palette_interface.set_pen_color((pen_t)i, (u8)r, (u8)g, (u8)b); color_prom++; } // Now treat tri-state black background generation for (int i = 0; i < 256; i++) { if ((m_vidhw != DKONG_RADARSCP_CONVERSION) && ((i & 0x03) == 0x00)) // NOR => CS=1 => Tristate => real black { int r = compute_res_net(1, 0, radarscp_net_bck_info); int g = compute_res_net(1, 1, radarscp_net_bck_info); int b = compute_res_net(1, 2, radarscp_net_bck_info); palette.palette_interface.set_pen_color((pen_t)i, (u8)r, (u8)g, (u8)b); } } // Star color palette.palette_interface.set_pen_color(RADARSCP_STAR_COL, (u8)compute_res_net(1, 0, radarscp_stars_net_info), (u8)compute_res_net(0, 1, radarscp_stars_net_info), (u8)compute_res_net(0, 2, radarscp_stars_net_info)); // Oscillating background for (int i = 0; i < 256; i++) { int r = compute_res_net(0, 0, radarscp_blue_net_info); int g = compute_res_net(0, 1, radarscp_blue_net_info); int b = compute_res_net(i, 2, radarscp_blue_net_info); palette.palette_interface.set_pen_color(RADARSCP_BCK_COL_OFFSET + (pen_t)i, (u8)r, (u8)g, (u8)b); } // Grid for (int i = 0; i < 8; i++) { int r = compute_res_net(BIT(i, 0), 0, radarscp_grid_net_info); int g = compute_res_net(BIT(i, 1), 1, radarscp_grid_net_info); int b = compute_res_net(BIT(i, 2), 2, radarscp_grid_net_info); palette.palette_interface.set_pen_color(RADARSCP_GRID_COL_OFFSET + (pen_t)i, (u8)r, (u8)g, (u8)b); } palette.device_palette_interface.palette().normalize_range(0, RADARSCP_GRID_COL_OFFSET + 7); color_prom += 256; // color_prom now points to the beginning of the character color codes m_color_codes = color_prom; // we'll need it later }
/************************************* * * Palette setup * *************************************/ void galaxian_palette(palette_device palette) { Pointer <uint8_t> color_prom = new Pointer <uint8_t>(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); int [] rgb_resistances3 = new int [3] { 1000, 470, 220 }; int [] rgb_resistances2 = new int [2] { 470, 220 }; /* * Sprite/tilemap colors are mapped through a color PROM as follows: * * bit 7 -- 220 ohm resistor -- BLUE * -- 470 ohm resistor -- BLUE * -- 220 ohm resistor -- GREEN * -- 470 ohm resistor -- GREEN * -- 1 kohm resistor -- GREEN * -- 220 ohm resistor -- RED * -- 470 ohm resistor -- RED * bit 0 -- 1 kohm resistor -- RED * * Note that not all boards have this configuration. Namco PCBs may * have 330 ohm resistors instead of 220, but the default setup has * also been used by Namco. * * In parallel with these resistors are a pair of 150 ohm and 100 ohm * resistors on each R,G,B component that are connected to the star * generator. * * And in parallel with the whole mess are a set of 100 ohm resistors * on each R,G,B component that are enabled when a shell/missile is * enabled. * * When computing weights, we use RGB_MAXIMUM as the maximum to give * headroom for stars and shells/missiles. This is not fully accurate, * but if we included all possible sources in parallel, the brightness * of the main game would be very low to allow for all the oversaturation * of the stars and shells/missiles. */ double [] rweights = new double[3]; double [] gweights = new double[3]; double [] bweights = new double[2]; compute_resistor_weights(0, RGB_MAXIMUM, -1.0, 3, rgb_resistances3, out rweights, 470, 0, 3, rgb_resistances3, out gweights, 470, 0, 2, rgb_resistances2, out bweights, 470, 0); // decode the palette first int len = (int)memregion("proms").bytes(); for (int i = 0; i < len; i++) { uint8_t bit0; uint8_t bit1; uint8_t bit2; /* red component */ bit0 = (uint8_t)BIT(color_prom[i], 0); bit1 = (uint8_t)BIT(color_prom[i], 1); bit2 = (uint8_t)BIT(color_prom[i], 2); int r = combine_weights(rweights, bit0, bit1, bit2); /* green component */ bit0 = (uint8_t)BIT(color_prom[i], 3); bit1 = (uint8_t)BIT(color_prom[i], 4); bit2 = (uint8_t)BIT(color_prom[i], 5); int gr = combine_weights(gweights, bit0, bit1, bit2); /* blue component */ bit0 = (uint8_t)BIT(color_prom[i], 6); bit1 = (uint8_t)BIT(color_prom[i], 7); int b = combine_weights(bweights, bit0, bit1); palette.set_pen_color((pen_t)i, new rgb_t((uint8_t)r, (uint8_t)gr, (uint8_t)b)); } /* * The maximum sprite/tilemap resistance is ~130 Ohms with all RGB * outputs enabled (1/(1/1000 + 1/470 + 1/220)). Since we normalized * to RGB_MAXIMUM, this maps RGB_MAXIMUM -> 130 Ohms. * * The stars are at 150 Ohms for the LSB, and 100 Ohms for the MSB. * This means the 3 potential values are: * * 150 Ohms -> RGB_MAXIMUM * 130 / 150 * 100 Ohms -> RGB_MAXIMUM * 130 / 100 * 60 Ohms -> RGB_MAXIMUM * 130 / 60 * * Since we can't saturate that high, we instead approximate this * by compressing the values proportionally into the 194->255 range. */ int minval = RGB_MAXIMUM * 130 / 150; int midval = RGB_MAXIMUM * 130 / 100; int maxval = RGB_MAXIMUM * 130 / 60; // compute the values for each of 4 possible star values uint8_t [] starmap = new uint8_t [4] { 0, (uint8_t)minval, (uint8_t)(minval + (255 - minval) * (midval - minval) / (maxval - minval)), 255 }; // generate the colors for the stars for (int i = 0; i < 64; i++) { uint8_t bit0; uint8_t bit1; // bit 5 = red @ 150 Ohm, bit 4 = red @ 100 Ohm bit0 = (uint8_t)BIT(i, 5); bit1 = (uint8_t)BIT(i, 4); int r = starmap[(bit1 << 1) | bit0]; // bit 3 = green @ 150 Ohm, bit 2 = green @ 100 Ohm bit0 = (uint8_t)BIT(i, 3); bit1 = (uint8_t)BIT(i, 2); int gr = starmap[(bit1 << 1) | bit0]; // bit 1 = blue @ 150 Ohm, bit 0 = blue @ 100 Ohm bit0 = (uint8_t)BIT(i, 1); bit1 = (uint8_t)BIT(i, 0); int b = starmap[(bit1 << 1) | bit0]; // set the RGB color m_star_color[i] = new rgb_t((uint8_t)r, (uint8_t)gr, (uint8_t)b); } // default bullet colors are white for the first 7, and yellow for the last one for (int i = 0; i < 7; i++) { m_bullet_color[i] = new rgb_t(0xff, 0xff, 0xff); } m_bullet_color[7] = new rgb_t(0xff, 0xff, 0x00); }
public device_palette_interface_palette_device(machine_config mconfig, palette_device palette_device) : base(mconfig, palette_device) { m_palette_device = palette_device; }
/*************************************************************************** * * Convert the color PROMs. * * Galaga has one 32x8 palette PROM and two 256x4 color lookup table PROMs * (one for characters, one for sprites). Only the first 128 bytes of the * lookup tables seem to be used. * The palette PROM is connected to the RGB output this way: * * bit 7 -- 220 ohm resistor -- BLUE * -- 470 ohm resistor -- BLUE * -- 220 ohm resistor -- GREEN * -- 470 ohm resistor -- GREEN * -- 1 kohm resistor -- GREEN * -- 220 ohm resistor -- RED * -- 470 ohm resistor -- RED * bit 0 -- 1 kohm resistor -- RED * ***************************************************************************/ void galaga_palette(palette_device palette) { Pointer <uint8_t> color_prom = new Pointer <uint8_t>(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); // core palette for (int i = 0; i < 32; i++) { int bit0; int bit1; int bit2; bit0 = BIT(color_prom.op, 0); bit1 = BIT(color_prom.op, 1); bit2 = BIT(color_prom.op, 2); int r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = BIT(color_prom.op, 3); bit1 = BIT(color_prom.op, 4); bit2 = BIT(color_prom.op, 5); int gr = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; bit0 = 0; bit1 = BIT(color_prom.op, 6); bit2 = BIT(color_prom.op, 7); int b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; palette.set_indirect_color(i, new rgb_t((u8)r, (u8)gr, (u8)b)); color_prom++; } // palette for the stars for (int i = 0; i < 64; i++) { int [] map = new int[4] { 0x00, 0x47, 0x97, 0xde }; int r = map[(i >> 0) & 0x03]; int g = map[(i >> 2) & 0x03]; int b = map[(i >> 4) & 0x03]; palette.set_indirect_color(32 + i, new rgb_t((u8)r, (u8)g, (u8)b)); } // characters for (int i = 0; i < 64 * 4; i++) { palette.set_pen_indirect((pen_t)i, (indirect_pen_t)((color_prom.op & 0x0f) | 0x10)); color_prom++; } // sprites for (int i = 0; i < 64 * 4; i++) { palette.set_pen_indirect((pen_t)(64 * 4 + i), (indirect_pen_t)((color_prom.op & 0x0f))); color_prom++; } // now the stars for (int i = 0; i < 64; i++) { palette.set_pen_indirect((pen_t)(64 * 4 + 64 * 4 + i), (indirect_pen_t)(32 + i)); } }
/*************************************************************************** * * Convert the color PROMs into a more useable format. * * Xevious has three 256x4 palette PROMs (one per gun) and four 512x4 lookup * table PROMs (two for sprites, two for background tiles; foreground * characters map directly to a palette color without using a PROM). * The palette PROMs are connected to the RGB output this way: * * bit 3 -- 220 ohm resistor -- RED/GREEN/BLUE * -- 470 ohm resistor -- RED/GREEN/BLUE * -- 1 kohm resistor -- RED/GREEN/BLUE * bit 0 -- 2.2kohm resistor -- RED/GREEN/BLUE * ***************************************************************************/ void xevious_palette(palette_device palette) { Pointer <uint8_t> color_prom = new Pointer <uint8_t>(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); Func <int, int> TOTAL_COLORS = (int gfxn) => { return((int)(m_gfxdecode.op0.gfx(gfxn).colors() * m_gfxdecode.op0.gfx(gfxn).granularity())); }; for (int i = 0; i < 128; i++) { int bit0; int bit1; int bit2; int bit3; // red component bit0 = BIT(color_prom[0], 0); bit1 = BIT(color_prom[0], 1); bit2 = BIT(color_prom[0], 2); bit3 = BIT(color_prom[0], 3); int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; // green component bit0 = BIT(color_prom[256], 0); bit1 = BIT(color_prom[256], 1); bit2 = BIT(color_prom[256], 2); bit3 = BIT(color_prom[256], 3); int gr = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; // blue component bit0 = BIT(color_prom[2 * 256], 0); bit1 = BIT(color_prom[2 * 256], 1); bit2 = BIT(color_prom[2 * 256], 2); bit3 = BIT(color_prom[2 * 256], 3); int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; palette.set_indirect_color(i, new rgb_t((u8)r, (u8)gr, (u8)b)); color_prom++; } // color 0x80 is used by sprites to mark transparency palette.set_indirect_color(0x80, new rgb_t(0, 0, 0)); color_prom += 128; // the bottom part of the PROM is unused color_prom += 2 * 256; // color_prom now points to the beginning of the lookup table // background tiles for (int i = 0; i < TOTAL_COLORS(1); i++) { palette.set_pen_indirect( (pen_t)(m_gfxdecode.op0.gfx(1).colorbase() + i), (indirect_pen_t)((color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(1)] & 0x0f) << 4))); color_prom++; } color_prom += TOTAL_COLORS(1); // sprites for (int i = 0; i < TOTAL_COLORS(2); i++) { int c = (color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(2)] & 0x0f) << 4); palette.set_pen_indirect( (pen_t)(m_gfxdecode.op0.gfx(2).colorbase() + i), (c & 0x80) != 0 ? (indirect_pen_t)(c & 0x7f) : (indirect_pen_t)0x80); color_prom++; } color_prom += TOTAL_COLORS(2); // foreground characters for (int i = 0; i < TOTAL_COLORS(0); i++) { palette.set_pen_indirect( (pen_t)(m_gfxdecode.op0.gfx(0).colorbase() + i), BIT(i, 0) != 0 ? (indirect_pen_t)(i >> 1) : (indirect_pen_t)0x80); } }
/************************************************************************* * * Namco Pac Man * ************************************************************************** * * This file is used by the Pac Man, Pengo & Jr Pac Man drivers. * * Pengo & Pac Man are almost identical, the only differences being the * extra gfx bank in Pengo, and the need to compensate for an hardware * sprite positioning "bug" in Pac Man. * * Jr Pac Man has the same sprite hardware as Pac Man, the extra bank * from Pengo and a scrolling playfield at the expense of one color per row * for the playfield so it can fit in the same amount of ram. * **************************************************************************/ /*************************************************************************** * * Convert the color PROMs into a more useable format. * * * Pac Man has a 32x8 palette PROM and a 256x4 color lookup table PROM. * * Pengo has a 32x8 palette PROM and a 1024x4 color lookup table PROM. * * The palette PROM is connected to the RGB output this way: * * bit 7 -- 220 ohm resistor -- BLUE * -- 470 ohm resistor -- BLUE * -- 220 ohm resistor -- GREEN * -- 470 ohm resistor -- GREEN * -- 1 kohm resistor -- GREEN * -- 220 ohm resistor -- RED * -- 470 ohm resistor -- RED * bit 0 -- 1 kohm resistor -- RED * * * Jr. Pac Man has two 256x4 palette PROMs (the three msb of the address are * grounded, so the effective colors are only 32) and one 256x4 color lookup * table PROM. * * The palette PROMs are connected to the RGB output this way: * * bit 3 -- 220 ohm resistor -- BLUE * -- 470 ohm resistor -- BLUE * -- 220 ohm resistor -- GREEN * bit 0 -- 470 ohm resistor -- GREEN * * bit 3 -- 1 kohm resistor -- GREEN * -- 220 ohm resistor -- RED * -- 470 ohm resistor -- RED * bit 0 -- 1 kohm resistor -- RED * ***************************************************************************/ public void pacman_palette(palette_device palette) { ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); int [] resistances3 = new int [3] { 1000, 470, 220 }; int [] resistances2 = new int [2] { 470, 220 }; // compute the color output resistor weights double [] rweights = new double[3]; double [] gweights = new double[3]; double [] bweights = new double[2]; compute_resistor_weights(0, 255, -1.0, 3, resistances3, out rweights, 0, 0, 3, resistances3, out gweights, 0, 0, 2, resistances2, out bweights, 0, 0); // create a lookup table for the palette for (int i = 0; i < 32; i++) { int bit0; int bit1; int bit2; // red component bit0 = BIT(color_prom[i], 0); bit1 = BIT(color_prom[i], 1); bit2 = BIT(color_prom[i], 2); int r = combine_3_weights(rweights, bit0, bit1, bit2); // green component bit0 = BIT(color_prom[i], 3); bit1 = BIT(color_prom[i], 4); bit2 = BIT(color_prom[i], 5); int g = combine_3_weights(gweights, bit0, bit1, bit2); // blue component bit0 = BIT(color_prom[i], 6); bit1 = BIT(color_prom[i], 7); int b = combine_2_weights(bweights, bit0, bit1); palette.palette_interface.set_indirect_color(i, new rgb_t((byte)r, (byte)g, (byte)b)); } // color_prom now points to the beginning of the lookup table color_prom += 32; // allocate the colortable for (int i = 0; i < 64 * 4; i++) { uint8_t ctabentry = (uint8_t)(color_prom[i] & 0x0f); // first palette bank palette.palette_interface.set_pen_indirect((UInt32)i, ctabentry); // second palette bank palette.palette_interface.set_pen_indirect((UInt32)(i + 64 * 4), (UInt16)(0x10 + ctabentry)); } }
public void xevious_palette(palette_device palette) { ListBytesPointer color_prom = new ListBytesPointer(memregion("proms").base_()); //const uint8_t *color_prom = memregion("proms")->base(); for (int i = 0; i < 128; i++) { int bit0; int bit1; int bit2; int bit3; // red component bit0 = BIT(color_prom[0], 0); bit1 = BIT(color_prom[0], 1); bit2 = BIT(color_prom[0], 2); bit3 = BIT(color_prom[0], 3); int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; // green component bit0 = BIT(color_prom[256], 0); bit1 = BIT(color_prom[256], 1); bit2 = BIT(color_prom[256], 2); bit3 = BIT(color_prom[256], 3); int g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; // blue component bit0 = BIT(color_prom[2 * 256], 0); bit1 = BIT(color_prom[2 * 256], 1); bit2 = BIT(color_prom[2 * 256], 2); bit3 = BIT(color_prom[2 * 256], 3); int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; palette.palette_interface.set_indirect_color(i, new rgb_t((byte)r, (byte)g, (byte)b)); color_prom++; } // color 0x80 is used by sprites to mark transparency palette.palette_interface.set_indirect_color(0x80, new rgb_t(0, 0, 0)); color_prom += 128; // the bottom part of the PROM is unused color_prom += 2 * 256; // color_prom now points to the beginning of the lookup table // background tiles for (int i = 0; i < TOTAL_COLORS(1); i++) { palette.palette_interface.set_pen_indirect( (pen_t)(gfxdecode.target.digfx.gfx(1).colorbase() + i), (UInt16)((color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(1)] & 0x0f) << 4))); color_prom++; } color_prom += TOTAL_COLORS(1); // sprites for (int i = 0; i < TOTAL_COLORS(2); i++) { int c = (color_prom[0] & 0x0f) | ((color_prom[TOTAL_COLORS(2)] & 0x0f) << 4); palette.palette_interface.set_pen_indirect( (pen_t)(gfxdecode.target.digfx.gfx(2).colorbase() + i), (c & 0x80) != 0 ? (UInt16)(c & 0x7f) : (UInt16)0x80); color_prom++; } color_prom += TOTAL_COLORS(2); // foreground characters for (int i = 0; i < TOTAL_COLORS(0); i++) { palette.palette_interface.set_pen_indirect( (pen_t)(gfxdecode.target.digfx.gfx(0).colorbase() + i), BIT(i, 0) != 0 ? (UInt16)(i >> 1) : (UInt16)0x80); } }