コード例 #1
0
        void dkong2b_palette(palette_device palette)
        {
            Pointer <uint8_t> color_prom = new Pointer <uint8_t>(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.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 gr = compute_res_net(1, 1, dkong_net_bck_info);
                    int b  = compute_res_net(1, 2, dkong_net_bck_info);
                    palette.set_pen_color((pen_t)i, (u8)r, (u8)gr, (u8)b);
                }
            }

            palette.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
        }
コード例 #2
0
        /*************************************
        *
        *  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);
        }
コード例 #3
0
        void radarscp_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 < 256; i++)
            {
                // red component
                int r = compute_res_net((color_prom[256] >> 1) & 0x07, 0, radarscp_net_info);
                // green component
                int gr = 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.set_pen_color((pen_t)i, (u8)r, (u8)gr, (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 gr = compute_res_net(1, 1, radarscp_net_bck_info);
                    int b  = compute_res_net(1, 2, radarscp_net_bck_info);
                    palette.set_pen_color((pen_t)i, (u8)r, (u8)gr, (u8)b);
                }
            }

            // Star color
            palette.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 gr = compute_res_net(0, 1, radarscp_blue_net_info);
                int b  = compute_res_net(i, 2, radarscp_blue_net_info);

                palette.set_pen_color(RADARSCP_BCK_COL_OFFSET + (pen_t)i, (u8)r, (u8)gr, (u8)b);
            }

            // Grid
            for (int i = 0; i < 8; i++)
            {
                int r  = compute_res_net(BIT(i, 0), 0, radarscp_grid_net_info);
                int gr = 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.set_pen_color(RADARSCP_GRID_COL_OFFSET + (pen_t)i, (u8)r, (u8)gr, (u8)b);
            }

            palette.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
        }