コード例 #1
0
        public bool CHR_fill_with_color()
        {
            palette_group plt = palette_group.Instance;

            if (plt.active_palette >= 0)
            {
                if (m_selected_ind >= 0 && get_data() != null)
                {
#if DEF_NES
                    byte color_ind = ( byte )plt.get_palettes_arr()[plt.active_palette].color_slot;
#elif DEF_SMS || DEF_PCE
                    byte color_ind = ( byte )(plt.active_palette * utils.CONST_NUM_SMALL_PALETTES + plt.get_palettes_arr()[plt.active_palette].color_slot);
#endif
                    get_data()[m_selected_ind].fill(color_ind);

                    if (m_mode8x16 && m_selected_ind + 1 < get_data().Count)
                    {
                        get_data()[m_selected_ind + 1].fill(color_ind);
                    }

                    update();

                    if (UpdatePixel != null)
                    {
                        UpdatePixel(this, null);
                    }

                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        private Color get_color(int _ind)
        {
            palette_group plt_grp = palette_group.Instance;

            palette_small[] sm_plts_arr = plt_grp.get_palettes_arr();

            return(Color.FromArgb(plt_grp.main_palette[sm_plts_arr[_ind >> 2].get_color_inds()[_ind & 0x03]]));
        }
コード例 #3
0
        public void subscribe_event(palette_group _plt)
        {
            _plt.UpdateColor += new EventHandler(update_color);

            m_palette_group = _plt;

            palette_small[] plt_arr = _plt.get_palettes_arr();

            plt_arr[0].ActivePalette += new EventHandler(update_color);
            plt_arr[1].ActivePalette += new EventHandler(update_color);
            plt_arr[2].ActivePalette += new EventHandler(update_color);
            plt_arr[3].ActivePalette += new EventHandler(update_color);
        }
コード例 #4
0
        private void update()
        {
            if (m_sprites_arr != null)
            {
                int clr;

                palette_group   plt_grp     = palette_group.Instance;
                palette_small[] sm_plts_arr = plt_grp.get_palettes_arr();

                for (int i = 0; i < utils.CONST_NUM_SMALL_PALETTES * utils.CONST_PALETTE_SMALL_NUM_COLORS; i++)
                {
                    clr = palette_group.Instance.main_palette[sm_plts_arr[i >> 2].get_color_inds()[i & 0x03]];

                    utils.brush.Color = Color.FromArgb((clr & 0xff0000) >> 16, (clr & 0xff00) >> 8, clr & 0xff);
                    m_main_gfx.FillRectangle(utils.brush, (i << 4) + 1, 1, 16, 16);
                }

                if (CheckBoxColorA.Checked || CheckBoxColorB.Checked)
                {
                    m_pen.Color = CONST_COLOR_PALETTE_SWAP_COLOR_ACTIVE_BORDER;
                    m_pen.Width = 2;

                    m_main_gfx.DrawRectangle(m_pen, 1, 1, PixBoxPalette.Width - 2, PixBoxPalette.Height - 2);
                }
                else
                {
                    m_pen.Color = CONST_COLOR_PALETTE_SWAP_COLOR_INACTIVE_BORDER;
                    m_pen.Width = 1;

                    m_main_gfx.DrawRectangle(m_pen, 0, 0, PixBoxPalette.Width - 1, PixBoxPalette.Height - 1);
                }
            }

            if (m_color_A >= 0)
            {
                draw_sel_border(m_color_A);
            }

            if (m_color_B >= 0)
            {
                draw_sel_border(m_color_B);
            }

            PixBoxPalette.Invalidate();
        }
コード例 #5
0
        public sprite_processor(PictureBox _spr_layout,
                                Label _spr_layout_label,
                                GroupBox _spr_layout_grp_box,
                                PictureBox _chr_bank,
                                Label _chr_bank_label,
                                PictureBox _plt_main,
                                PictureBox _plt0,
                                PictureBox _plt1,
                                PictureBox _plt2,
                                PictureBox _plt3)
        {
            m_sprite_layout_viewer = new sprite_layout_viewer(_spr_layout, _spr_layout_label, _spr_layout_grp_box);
            m_CHR_bank_viewer      = new CHR_bank_viewer(_chr_bank, _chr_bank_label);
            m_CHR_data_storage     = new CHR_data_storage();
            m_palette_grp          = new palette_group(_plt_main, _plt0, _plt1, _plt2, _plt3);

            m_CHR_bank_viewer.subscribe_event(m_palette_grp);
            m_CHR_bank_viewer.subscribe_event(m_sprite_layout_viewer);
            m_sprite_layout_viewer.subscribe_event(m_palette_grp);
            m_sprite_layout_viewer.subscribe_event(m_CHR_bank_viewer);
        }
コード例 #6
0
        public palette_group(PictureBox _main_plt,
                             PictureBox _plt0,
                             PictureBox _plt1,
                             PictureBox _plt2,
                             PictureBox _plt3) : base(_main_plt)
        {
            instance = this;
#if DEF_PCE
            m_main_palette = new int[utils.CONST_PALETTE_MAIN_NUM_COLORS];

            int r, g, b;

            for (int i = 0; i < utils.CONST_PALETTE_MAIN_NUM_COLORS; i++)
            {
                b = 36 * (i & 0x007);
                r = 36 * ((i & 0x038) >> 3);
                g = 36 * ((i & 0x1c0) >> 6);

                m_main_palette[i] = (r << 16) | (g << 8) | b;
            }
#endif
            m_plt_arr = new palette_small[utils.CONST_NUM_SMALL_PALETTES] {
                new palette_small(0, _plt0, 1),
                new palette_small(1, _plt1, 4),
                new palette_small(2, _plt2, 7),
                new palette_small(3, _plt3, 10)
            };

            for (int i = 0; i < utils.CONST_NUM_SMALL_PALETTES; i++)
            {
                m_plt_arr[i].ActivePalette += new EventHandler(update_palettes);
            }

            m_pix_box.MouseDown  += new MouseEventHandler(this.Palette_MouseDown);
            m_pix_box.MouseMove  += new MouseEventHandler(this.Palette_MouseMove);
            m_pix_box.MouseUp    += new MouseEventHandler(this.Palette_MouseUp);
            m_pix_box.MouseClick += new MouseEventHandler(this.Palette_MouseClick);

            update();
        }
コード例 #7
0
        void BtnOkClick_Event(object sender, EventArgs e)
        {
            if (m_color_A >= 0 && m_color_B >= 0)
            {
                uint     chr_key;
                CHR_data chr_data;

#if DEF_FIXED_LEN_PALETTE16_ARR
                palettes_array plts_arr = palettes_array.Instance;
#endif
                SortedSet <uint> used_CHR_data = new SortedSet <uint>();

                foreach (sprite_data spr in m_sprites_arr)
                {
                    foreach (CHR_data_attr attr in spr.get_CHR_attr())
                    {
#if DEF_FIXED_LEN_PALETTE16_ARR
                        if (attr.palette_ind == plts_arr.palette_index)
                        {
#endif
                        chr_key = ( uint )(((spr.get_CHR_data().id & 0x0000ffff) << 16) | (attr.CHR_ind & 0x0000ffff));

                        if (!used_CHR_data.Contains(chr_key))
                        {
                            chr_data = spr.get_CHR_data().get_data()[attr.CHR_ind];

                            for (int pix_n = 0; pix_n < utils.CONST_CHR_TOTAL_PIXELS_CNT; pix_n++)
                            {
                                if (chr_data.get_data()[pix_n] == m_color_A)
                                {
                                    chr_data.get_data()[pix_n] = ( byte )m_color_B;
                                }
                                else
                                if (chr_data.get_data()[pix_n] == m_color_B)
                                {
                                    chr_data.get_data()[pix_n] = ( byte )m_color_A;
                                }
                            }

                            used_CHR_data.Add(chr_key);
                        }
#if DEF_FIXED_LEN_PALETTE16_ARR
                    }
#endif
                    }
                }

#if DEF_FIXED_LEN_PALETTE16_ARR
                plts_arr.swap_colors(m_color_A, m_color_B);
                plts_arr.update_palette();
#else
                palette_group plt_grp       = palette_group.Instance;
                palette_small[] sm_plts_arr = plt_grp.get_palettes_arr();

                int ind_A = sm_plts_arr[m_color_A >> 2].get_color_inds()[m_color_A & 0x03];
                int ind_B = sm_plts_arr[m_color_B >> 2].get_color_inds()[m_color_B & 0x03];

                sm_plts_arr[m_color_A >> 2].get_color_inds()[m_color_A & 0x03] = ind_B;
                sm_plts_arr[m_color_B >> 2].get_color_inds()[m_color_B & 0x03] = ind_A;

                for (int j = 0; j < utils.CONST_NUM_SMALL_PALETTES; j++)
                {
                    sm_plts_arr[j].update();
                }
#endif
            }
            else
            {
                MainForm.message_box("Please, select both Color A and Color B!", "Colors Swapping Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }