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(); } }
public void export(string _filename, tiles_data _data, ImageList _tiles_imgs, ImageList _blocks_imgs) { if (RBtnTiles.Checked) { export_tiles_blocks_data(_data.get_first_free_tile_id(false), 32, _tiles_imgs, _filename); } else { export_tiles_blocks_data(_data.get_first_free_block_id(false), 16, _blocks_imgs, _filename); } }
public int get_tiles_cnt(int _bank_ind) { tiles_data data = m_data_mngr.get_tiles_data(_bank_ind); if (data != null) { return(data.get_first_free_tile_id(false)); } return(-1); }
int Tiles_optimization(tiles_data _data, bool _check) { int deleted_tiles_cnt = 0; int size = _data.get_first_free_tile_id(false); for (int tile_n = 0; tile_n < size; tile_n++) { if (check_screens_tile(tile_n, _data) == false) { if (_data.tiles[tile_n] != 0) { ++deleted_tiles_cnt; } if (_check == true) { continue; } // delete the useless tile Array.Copy(_data.tiles, tile_n + 1, _data.tiles, tile_n, platform_data.get_max_tiles_cnt() - tile_n - 1); // the last tile is an empty space _data.tiles[platform_data.get_max_tiles_cnt() - 1] = 0; _data.dec_screen_tiles(( ushort )tile_n); _data.dec_patterns_tiles(( ushort )tile_n); --tile_n; --size; } } return(deleted_tiles_cnt); }
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); }