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