Пример #1
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();
        }