コード例 #1
0
        public palette_group(PictureBox _main_plt,
                             PictureBox _plt0,
                             PictureBox _plt1,
                             PictureBox _plt2,
                             PictureBox _plt3) : base(_main_plt)
        {
            instance = this;

            m_plt_arr = new palette_small[utils.CONST_NUM_SMALL_PALETTES] {
                new palette_small(0, _plt0),
                new palette_small(1, _plt1),
                new palette_small(2, _plt2),
                new palette_small(3, _plt3)
            };
            int i;

            for (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);

            m_main_palette = platform_data.get_palette_by_platform_type(platform_data.get_platform_type());

            update();
        }
コード例 #2
0
        public bool fill_with_color_spr()
        {
            palette_group plt = palette_group.Instance;

            if (plt.active_palette >= 0)
            {
                if (m_data != null)
                {
                    if (m_sel_ind >= 0)
                    {
#if DEF_NES
                        m_data.fill_CHR_bank_spr8x8_by_color_ind(m_sel_ind, plt.get_palettes_arr()[plt.active_palette].get_color_slot());
#else
                        m_data.fill_CHR_bank_spr8x8_by_color_ind(m_sel_ind, plt.active_palette * utils.CONST_NUM_SMALL_PALETTES + plt.get_palettes_arr()[plt.active_palette].get_color_slot());
#endif

                        MainForm.set_status_msg(String.Format("CHR Bank: Sprite #{0:X2} is filled with a palette slot index: {1}", m_sel_ind, plt.get_palettes_arr()[plt.active_palette].get_color_slot()));

                        update();
                    }
                    else
                    {
                        MainForm.message_box("Please, select a CHR!", "Fill CHR With Color", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                dispatch_event_need_gfx_update();
                dispatch_event_data_changed();

                return(true);
            }

            return(false);
        }
コード例 #3
0
        public void subscribe_event(palette_group _plt)
        {
#if !DEF_ZX
            _plt.UpdateColor += new EventHandler(update_color);
#endif
            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
        public tiles_processor(PictureBox _PBoxCHRBank,
                               GroupBox _CHRBankGrpBox,
                               PictureBox _PBoxBlockEditor,
                               PictureBox _PBoxTilePreview,
                               PictureBox _plt_main,
                               PictureBox _plt0,
                               PictureBox _plt1,
                               PictureBox _plt2,
                               PictureBox _plt3,
                               data_sets_manager _data_mngr)
        {
            m_palette_grp     = new palette_group(_plt_main, _plt0, _plt1, _plt2, _plt3);
            m_CHR_bank_viewer = new CHR_bank_viewer(_PBoxCHRBank, _CHRBankGrpBox);
            m_block_editor    = new block_editor(_PBoxBlockEditor);
            m_tile_editor     = new tile_editor(_PBoxTilePreview);

            m_CHR_bank_viewer.subscribe_event(m_block_editor);
            m_CHR_bank_viewer.subscribe_event(_data_mngr);
            m_block_editor.subscribe_event(_data_mngr);
            m_tile_editor.subscribe_event(_data_mngr);
            m_palette_grp.subscribe_event(_data_mngr);

            m_CHR_bank_viewer.subscribe_event(m_palette_grp);

            m_block_editor.subscribe_event(m_CHR_bank_viewer);
            m_block_editor.subscribe_event(m_tile_editor);
            m_tile_editor.subscribe_event(m_block_editor);

            m_CHR_bank_viewer.NeedGFXUpdate += new EventHandler(need_gfx_update_event);
            m_block_editor.NeedGFXUpdate    += new EventHandler(need_gfx_update_event);
            m_tile_editor.NeedGFXUpdate     += new EventHandler(need_gfx_update_event);
            m_palette_grp.NeedGFXUpdate     += new EventHandler(need_gfx_update_event);
#if DEF_PALETTE16_PER_CHR
            m_block_editor.UpdatePaletteListPos += new EventHandler(update_palette_list_pos);
#endif
            m_CHR_bank_viewer.subscribe_event(this);
            m_block_editor.subscribe_event(this);
            m_tile_editor.subscribe_event(this);
        }
コード例 #5
0
        private void update_data(object sender, EventArgs e)
        {
            if (m_sel_block_id >= 0 && palette_group.Instance.active_palette >= 0)
            {
#if DEF_NES
                int chr_data_ind;

                if (palette_per_CHR_mode)
                {
                    // palette per CHR8x8
                    chr_data_ind = (m_sel_block_id << 2) + m_sel_quad_ind;

                    m_data.blocks[chr_data_ind] = tiles_data.set_block_flags_palette(palette_group.Instance.active_palette, m_data.blocks[chr_data_ind]);
                }
                else
                {
                    for (int i = 0; i < utils.CONST_BLOCK_SIZE; i++)
                    {
                        chr_data_ind = (m_sel_block_id << 2) + i;

                        m_data.blocks[chr_data_ind] = tiles_data.set_block_flags_palette(palette_group.Instance.active_palette, m_data.blocks[chr_data_ind]);
                    }
                }
#elif DEF_ZX
                palette_group plt = palette_group.Instance;

                byte ink_clr_slot   = ( byte )((plt.active_palette * utils.CONST_PALETTE_SMALL_NUM_COLORS) + plt.get_palettes_arr()[plt.active_palette].get_color_slot());
                byte paper_clr_slot = ( byte )((plt.paper_active_palette * utils.CONST_PALETTE_SMALL_NUM_COLORS) + plt.get_palettes_arr()[plt.paper_active_palette].get_color_slot());

                // apply paper/ink color
                m_data.update_ink_paper_colors(get_selected_quad_CHR_id(), ink_clr_slot, paper_clr_slot);
#endif
                dispatch_event_data_changed();
                dispatch_event_need_gfx_update();
            }

            update();
        }
コード例 #6
0
        private void set_active_palette()
        {
            if (m_sel_quad_ind >= 0 && m_sel_block_id >= 0)
            {
#if DEF_NES
                palette_group.Instance.active_palette = tiles_data.get_block_flags_palette(m_data.blocks[(m_sel_block_id << 2) + m_sel_quad_ind]);
#elif DEF_PALETTE16_PER_CHR
                update_palette_list_pos();
#endif

#if DEF_ZX
                byte ink_clr   = 0xff;
                byte paper_clr = 0xff;

                m_data.get_ink_paper_colors(get_selected_quad_CHR_id(), ref ink_clr, ref paper_clr);

                palette_group plt = palette_group.Instance;

                if (ink_clr != 0xff)
                {
                    plt.active_palette = ink_clr >> 2;
                    plt.get_palettes_arr()[plt.active_palette].set_color_slot(ink_clr & 0x03, false);
                }

                if (paper_clr != 0xff)
                {
                    plt.active_palette = paper_clr >> 2;
                    plt.get_palettes_arr()[plt.paper_active_palette].set_color_slot(paper_clr & 0x03, false);
                }
#endif
            }
            else
            {
                palette_group.Instance.active_palette = -1;
            }
        }
コード例 #7
0
        private void sel_quad_and_draw(int _x, int _y, bool _need_draw)
        {
            int last_sel_quad_ind = m_sel_quad_ind;

            m_sel_quad_ind = (_x >> 7) + ((_y >> 7) << 1);
#if DEF_NES
            if (palette_per_CHR_mode)
#endif
            {
                if (last_sel_quad_ind != m_sel_quad_ind)
                {
                    set_active_palette();
                }
            }

            if (last_sel_quad_ind != m_sel_quad_ind)
            {
                dispatch_event_quad_selected();
            }

            if (_need_draw && m_data != null && palette_group.Instance.active_palette != -1)
            {
                int x = _x >> 4;
                int y = _y >> 4;

                int local_x = (m_sel_quad_ind == 1 || m_sel_quad_ind == 3) ? (x - 8):x;
                int local_y = (m_sel_quad_ind == 2 || m_sel_quad_ind == 3) ? (y - 8):y;

                if (local_x >= 0 && local_y >= 0 && local_x < utils.CONST_SPR8x8_SIDE_PIXELS_CNT && local_y < utils.CONST_SPR8x8_SIDE_PIXELS_CNT)
                {
                    uint block_data = m_data.blocks[(m_sel_block_id << 2) + m_sel_quad_ind];

                    int chr_id = tiles_data.get_block_CHR_id(block_data);

                    int chr_x = chr_id % 16;
                    int chr_y = chr_id >> 4;

                    palette_group plt = palette_group.Instance;
#if DEF_NES
                    byte clr_slot = (byte)plt.get_palettes_arr()[plt.active_palette].get_color_slot();
#else
                    byte clr_slot = (byte)((plt.active_palette * utils.CONST_PALETTE_SMALL_NUM_COLORS) + plt.get_palettes_arr()[plt.active_palette].get_color_slot());
#endif

#if DEF_ZX
                    // paper color
                    byte paper_clr_slot = (byte)((plt.paper_active_palette * utils.CONST_PALETTE_SMALL_NUM_COLORS) + plt.get_palettes_arr()[plt.paper_active_palette].get_color_slot());

                    // apply paper/ink color
                    m_data.update_ink_paper_colors(get_selected_quad_CHR_id(), clr_slot, paper_clr_slot);

                    if (m_data.CHR_bank[((chr_x << 3) + local_x) + (((chr_y * utils.CONST_CHR_BANK_PAGE_SIDE) << 3) + local_y * utils.CONST_CHR_BANK_PAGE_SIDE)] == clr_slot)
                    {
                        clr_slot = paper_clr_slot;
                    }
#endif

#if DEF_FLIP_BLOCKS_SPR_BY_FLAGS
                    byte flip_flags = tiles_data.get_block_flags_flip(block_data);

                    if ((flip_flags & utils.CONST_CHR_ATTR_FLAG_HFLIP) == utils.CONST_CHR_ATTR_FLAG_HFLIP)
                    {
                        local_x = utils.CONST_SPR8x8_SIDE_PIXELS_CNT - local_x - 1;
                    }

                    if ((flip_flags & utils.CONST_CHR_ATTR_FLAG_VFLIP) == utils.CONST_CHR_ATTR_FLAG_VFLIP)
                    {
                        local_y = utils.CONST_SPR8x8_SIDE_PIXELS_CNT - local_y - 1;
                    }
#endif
                    int pix_offset = ((chr_x << 3) + local_x) + (((chr_y * utils.CONST_CHR_BANK_PAGE_SIDE) << 3) + local_y * utils.CONST_CHR_BANK_PAGE_SIDE);

                    if (pix_offset == m_CHR_pix_offset)
                    {
                        return;
                    }
                    else
                    {
                        m_data.CHR_bank[pix_offset] = clr_slot;

                        m_CHR_pix_offset = pix_offset;
                    }

                    m_need_data_update = true;
                }
            }

#if DEF_PALETTE16_PER_CHR
            if (_need_draw)
            {
                update_sel_CHR_palette();
            }
#endif
            update();

            update_status_bar();
        }