Exemple #1
0
        private void new_data_set(object sender, EventArgs e)
        {
            data_sets_manager data_mngr = sender as data_sets_manager;

            tiles_data data = data_mngr.get_tiles_data(data_mngr.tiles_data_pos);

            m_data = data;

            m_sel_ind        = -1;
            m_sel_block_CHRs = 0;

            m_active_page = 0;

            if (m_data != null)
            {
                if (platform_data.get_CHR_bank_pages_cnt() > 1)
                {
                    update_active_page_text();
                }
            }
            else
            {
                m_CHR_bank_grp_box.Text = "CHR Bank:";
            }

            update();
        }
Exemple #2
0
        private void update_data(object sender, EventArgs e)
        {
            data_sets_manager data_mngr = sender as data_sets_manager;

            tiles_data data = data_mngr.get_tiles_data(data_mngr.tiles_data_pos);

            set_palette(data);

            dispatch_event_update_color();

            update();
        }
Exemple #3
0
        public reorder_CHR_banks_form(data_sets_manager _data_manager)
        {
            m_data_manager = _data_manager;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            m_blocks_preview = new image_preview(PBoxBlocks2x2);
            m_blocks_preview.enable_smoothing_mode(false);
        }
Exemple #4
0
        public statistics_form(data_sets_manager _data_manager)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
            m_data_manager = _data_manager;
        }
Exemple #5
0
        public optimization_form(data_sets_manager _data_sets, Action <bool, string, bool> _show_progress_wnd)
        {
            m_data_sets         = _data_sets;
            m_show_progress_wnd = _show_progress_wnd;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            NumUpDownMatcingPercent.Value = 90;
        }
        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);
        }
        public virtual void palettes_processing(byte _ver, platform_data.EPlatformType _prj_platform, bool _convert_colors, data_sets_manager _data_mngr, int[] _plt_main)
        {
            int          i;
            int          plt_n;
            int          data_n;
            tiles_data   data;
            List <int[]> palettes = null;

            int plt_clrs_cnt = platform_data.get_main_palette_colors_cnt();

            for (data_n = 0; data_n < _data_mngr.tiles_data_cnt; data_n++)
            {
                data = _data_mngr.get_tiles_data(data_n);

                for (plt_n = 0; plt_n < data.palettes_arr.Count; plt_n++)
                {
                    palettes = data.palettes_arr[plt_n].subpalettes;

                    for (i = 0; i < utils.CONST_NUM_SMALL_PALETTES * utils.CONST_PALETTE_SMALL_NUM_COLORS; i++)
                    {
                        if (_convert_colors)
                        {
                            palettes[i >> 2][i & 0x03] = utils.find_nearest_color_ind(_plt_main[palettes[i >> 2][i & 0x03]]);
                        }
                        else
                        {
                            palettes[i >> 2][i & 0x03] = palettes[i >> 2][i & 0x03] & (plt_clrs_cnt - 1);
                        }
                    }
                }
            }
        }
Exemple #8
0
 public void subscribe_event(data_sets_manager _data_mngr)
 {
     _data_mngr.SetTilesData += new EventHandler(new_data_set);
 }
        public int block_reserve_CHRs(int _block_ind, data_sets_manager _data_manager)
        {
            int CHR_pos = 0;

            ushort block_data = 0;

            if (_block_ind >= 0)
            {
                tiles_data data = _data_manager.get_tiles_data(_data_manager.tiles_data_pos);

                if (data.block_sum(_block_ind) != 0)
                {
                    if (MainForm.message_box("All the block's CHR links will be replaced!", "Reserve CHRs", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                    {
                        return(-1);
                    }
                }

                // reset block's links
                for (int i = 0; i < utils.CONST_BLOCK_SIZE; i++)
                {
                    data.blocks[(_block_ind << 2) + i] = 0;
                }

                int ff_block_ind = data.get_first_free_block_id(false) << 2;
                ff_block_ind = ff_block_ind < 4 ? 4:ff_block_ind;

                int block_n;

                for (int CHR_n = 1; CHR_n < platform_data.get_CHR_bank_max_sprites_cnt(); CHR_n++)
                {
                    if (data.spr8x8_sum(CHR_n) == 0)
                    {
                        for (block_n = 4; block_n < ff_block_ind; block_n++)
                        {
                            if (tiles_data.get_block_CHR_id(data.blocks[block_n]) == CHR_n)
                            {
                                break;
                            }
                        }

                        if (block_n == ff_block_ind || ff_block_ind == 4)
                        {
                            data.blocks[(_block_ind << 2) + CHR_pos++] = tiles_data.set_block_CHR_id(CHR_n, block_data);

                            if (CHR_pos == utils.CONST_BLOCK_SIZE)
                            {
                                m_block_editor.set_selected_block(_block_ind, data);

                                MainForm.set_status_msg(String.Format("Block Editor: Block #{0:X2} data reserved", _block_ind));

                                return(1);
                            }
                        }
                    }
                }

                MainForm.message_box("Block Editor: CHR bank is full!", "Reserve Blocks", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(-1);
        }
        public int tile_reserve_blocks(data_sets_manager _data_manager)
        {
            int block_pos = 0;
            int sel_tile  = get_selected_tile();

            if (sel_tile >= 0)
            {
                tiles_data data = _data_manager.get_tiles_data(_data_manager.tiles_data_pos);

                if (data.tiles[sel_tile] != 0)
                {
                    if (MainForm.message_box("All the tile's block links will be replaced!", "Reserve Blocks", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                    {
                        return(-1);
                    }
                }

                bool reserve_blocks_CHRs = false;

                if (MainForm.message_box("Reserve CHRs?", "Reserve Blocks", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    reserve_blocks_CHRs = true;
                }

                // reset tile's links
                if (reserve_blocks_CHRs)
                {
                    int block_data_offs;

                    for (int i = 0; i < utils.CONST_BLOCK_SIZE; i++)
                    {
                        block_data_offs = data.get_tile_block(sel_tile, i) << 2;

                        data.blocks[block_data_offs]     = 0;
                        data.blocks[block_data_offs + 1] = 0;
                        data.blocks[block_data_offs + 2] = 0;
                        data.blocks[block_data_offs + 3] = 0;
                    }
                }

                data.tiles[sel_tile] = 0;

                int ff_tile_ind = data.get_first_free_tile_id(false);
                int tile_n;
                int block_pos_n;

                for (int block_n = 1; block_n < platform_data.get_max_blocks_cnt(); block_n++)
                {
                    if (data.block_sum(block_n) == 0)
                    {
                        // check if 'zero' block is busy
                        for (tile_n = 1; tile_n < ff_tile_ind; tile_n++)
                        {
                            for (block_pos_n = 0; block_pos_n < utils.CONST_TILE_SIZE; block_pos_n++)
                            {
                                if (data.get_tile_block(tile_n, block_pos_n) == block_n)
                                {
                                    // 'zero' block is busy
                                    break;
                                }
                            }

                            if (block_pos_n != utils.CONST_TILE_SIZE)
                            {
                                // 'zero' block is busy
                                break;
                            }
                        }

                        // 'zero' block isn't in use OR tiles list is empty
                        if (tile_n == ff_tile_ind || ff_tile_ind == 0)
                        {
                            data.set_tile_block(sel_tile, block_pos++, ( ushort )block_n);

                            if (reserve_blocks_CHRs)
                            {
                                block_reserve_CHRs(block_n, _data_manager);
                            }

                            if (block_pos == utils.CONST_TILE_SIZE)
                            {
                                m_tile_editor.set_selected_tile(sel_tile, data);

                                MainForm.set_status_msg(String.Format("Tile Editor: Tile #{0:X2} data reserved", sel_tile));

                                return(data.get_tile_block(sel_tile, m_tile_editor.get_selected_block_pos()));
                            }
                        }
                    }
                }

                MainForm.message_box("Tile Editor: Block list is full!", "Reserve Blocks", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(-1);
        }
Exemple #11
0
 public py_api(data_sets_manager _data_mngr) : base()
 {
     m_data_mngr = _data_mngr;
 }
Exemple #12
0
 public void deinit()
 {
     m_data_mngr = null;
 }