コード例 #1
0
        /***************************************************************************
        *
        *  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++;
            }
        }
コード例 #2
0
        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]));
            }
        }
コード例 #3
0
        /***************************************************************************
        *
        *  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));
            }
        }
コード例 #4
0
        /***************************************************************************
        *
        *  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);
            }
        }
コード例 #5
0
        /*************************************************************************
         *
         *  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
        *
        ***************************************************************************/
        void pacman_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 [] 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_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 gr = combine_weights(gweights, bit0, bit1, bit2);

                // blue component
                bit0 = BIT(color_prom[i], 6);
                bit1 = BIT(color_prom[i], 7);
                int b = combine_weights(bweights, bit0, bit1);

                palette.set_indirect_color(i, new rgb_t((uint8_t)r, (uint8_t)gr, (uint8_t)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.set_pen_indirect((pen_t)i, ctabentry);

                // second palette bank
                palette.set_pen_indirect((pen_t)(i + 64 * 4), (indirect_pen_t)(0x10 + ctabentry));
            }
        }