Example #1
0
        private void update_bank_GFX()
        {
            tiles_data data = m_data_manager.get_tiles_data(ListBoxCHRBanks.SelectedIndex);

            int img_size      = utils.CONST_BLOCKS_IMG_SIZE;
            int half_img_size = img_size >> 1;
            int side          = 5;
            int size          = side * side;

            Bitmap   bmp = new Bitmap(img_size, img_size);
            Graphics gfx = Graphics.FromImage(bmp);

            gfx.SmoothingMode     = SmoothingMode.HighSpeed;
            gfx.InterpolationMode = InterpolationMode.NearestNeighbor;
//			gfx.PixelOffsetMode		= PixelOffsetMode.HighQuality;

            for (int i = 0; i < size; i++)
            {
                utils.update_block_gfx(i, data, gfx, half_img_size, half_img_size, 0, 0, 0);

                m_blocks_preview.update(bmp, img_size, img_size, (i % side) * img_size, (i / side) * img_size, i == (size - 1), i == 0);
            }

            gfx.Dispose();
            bmp.Dispose();

            // update info
            {
                LabelCHRs.Text      = data.get_first_free_spr8x8_id(false).ToString();
                LabelBlocks2x2.Text = data.get_first_free_block_id(false).ToString();
                LabelTiles4x4.Text  = data.get_first_free_tile_id(false).ToString();
                LabelScreens.Text   = data.screen_data_cnt().ToString();
                LabelPalettes.Text  = data.palettes_arr.Count.ToString();
            }
        }
Example #2
0
        public void update_stats()
        {
            int CHR_bank_n;

            richTextBox.Text  = "Platform: " + platform_data.CONST_PLATFORM_DESC;
            richTextBox.Text += "\n---------------------------";

            richTextBox.Text += "\nScreen: " + platform_data.get_screen_width_pixels() + "x" + platform_data.get_screen_height_pixels() + " pix / Native: " + platform_data.get_screen_width_pixels(true) + "x" + platform_data.get_screen_height_pixels(true) + " pix\nScreen Tiles (2x2): " + (platform_data.get_screen_width_pixels() / 16.0f) + "x" + (platform_data.get_screen_height_pixels() / 16.0f) + "\nScreen Tiles (4x4): " + (platform_data.get_screen_width_pixels() / 32.0f) + "x" + (platform_data.get_screen_height_pixels() / 32.0f);
            richTextBox.Text += "\n\nCHR bank: " + (platform_data.get_CHR_bank_max_sprites_cnt() * platform_data.get_native_CHR_size_bytes()) / 1024 + " KB (Max: " + platform_data.get_CHR_bank_max_sprites_cnt() + " CHRs)";
            richTextBox.Text += "\nCHR size: " + platform_data.get_native_CHR_size_bytes() + " Bytes";
            richTextBox.Text += "\n\nTiles (4x4): " + platform_data.get_max_tiles_cnt();
            richTextBox.Text += "\nBlocks (2x2): " + platform_data.get_max_blocks_cnt();

            richTextBox.Text += "\n---------------------------\nProject:";
            richTextBox.Text += "\nLayouts: " + m_data_manager.layouts_data_cnt + " (Max: " + utils.CONST_LAYOUT_MAX_CNT + ")";

            // calc project screens count
            {
                int screens_cnt = 0;

                for (CHR_bank_n = 0; CHR_bank_n < m_data_manager.tiles_data_cnt; CHR_bank_n++)
                {
                    screens_cnt += m_data_manager.get_tiles_data()[CHR_bank_n].screen_data_cnt();
                }

                richTextBox.Text += "\nScreens: " + screens_cnt + " (Max: " + utils.CONST_SCREEN_MAX_CNT + ")";
            }

            richTextBox.Text += "\nCHR banks: " + m_data_manager.tiles_data_cnt + " (Max: " + utils.CONST_CHR_BANK_MAX_CNT + ")";

            // run through CHR banks
            {
                int ff_CHR;
                int ff_block;
                int ff_tile;

                tiles_data data;

                for (CHR_bank_n = 0; CHR_bank_n < m_data_manager.tiles_data_cnt; CHR_bank_n++)
                {
                    data = m_data_manager.get_tiles_data()[CHR_bank_n];

                    richTextBox.Text += "\n\n*** CHR bank " + CHR_bank_n + ": ***";

                    ff_CHR   = data.get_first_free_spr8x8_id(false);
                    ff_block = data.get_first_free_block_id(false);
                    ff_tile  = data.get_first_free_tile_id(false);

                    richTextBox.Text += "\nCHRs: " + ff_CHR + " / Blocks(2x2): " + ff_block + " / Tiles(4x4): " + ff_tile;
                    richTextBox.Text += "\nScreens: " + data.screen_data_cnt();
                    richTextBox.Text += "\nPalettes: " + data.palettes_arr.Count;
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        void BtnOkClick_event(object sender, EventArgs e)
        {
            Close();

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

            if (data != null)
            {
                if (CheckBoxOptimizeScreens.Checked || CheckBoxOptimizeTiles.Checked || CheckBoxOptimizeBlocks.Checked || CheckBoxOptimizeCHRs.Checked)
                {
                    int stat_screens = 0;
                    int stat_tiles   = 0;
                    int stat_blocks  = 0;
                    int stat_CHRs    = 0;

                    m_need_update_screen_list = false;

                    m_show_progress_wnd(true, "Data checking...", false);

                    if (CheckBoxGlobalOptimization.Checked)
                    {
                        m_data_sets.get_tiles_data().ForEach(delegate(tiles_data _data)
                        {
                            optimization(true, _data, ref stat_screens, ref stat_tiles, ref stat_blocks, ref stat_CHRs);
                        });
                    }
                    else
                    {
                        optimization(true, data, ref stat_screens, ref stat_tiles, ref stat_blocks, ref stat_CHRs);
                    }

                    m_show_progress_wnd(false, "", true);

                    if (MainForm.message_box(String.Format("As a result of the optimization the following data will be deleted:\n\nScreens: ~{0} \\ Tiles: ~{1} \\ Blocks: ~{2} \\ CHRs: ~{3}\n\nConfirm to continue...", stat_screens, stat_tiles, stat_blocks, stat_CHRs), "Confirm The Optimization Results", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        MainForm.set_status_msg("Optimization canceled!");
                        return;
                    }

                    stat_screens = 0;
                    stat_tiles   = 0;
                    stat_blocks  = 0;
                    stat_CHRs    = 0;

                    m_show_progress_wnd(true, "Optimization...", false);

                    if (CheckBoxGlobalOptimization.Checked)
                    {
                        m_data_sets.get_tiles_data().ForEach(delegate(tiles_data _data)
                        {
                            optimization(false, _data, ref stat_screens, ref stat_tiles, ref stat_blocks, ref stat_CHRs);
                        });
                    }
                    else
                    {
                        optimization(false, data, ref stat_screens, ref stat_tiles, ref stat_blocks, ref stat_CHRs);
                    }

                    m_show_progress_wnd(false, "", true);

                    m_need_update_screen_list = (stat_screens > 0);

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

                    MainForm.set_status_msg(String.Format("Optimization stats: Screens: {0} \\ Tiles: {1} \\ Blocks: {2} \\ CHRs: {3}", stat_screens, stat_tiles, stat_blocks, stat_CHRs));
                }
                else
                {
                    MainForm.set_status_msg("Optimization status: no options selected!");
                }
            }
        }
Example #9
0
        public int num_screens(int _bank_ind)
        {
            tiles_data data = m_data_mngr.get_tiles_data(_bank_ind);

            if (data != null)
            {
                return(data.screen_data_cnt());
            }

            return(-1);
        }