Esempio n. 1
0
        bool check_tiles_block(int _block_id, tiles_data _data)
        {
            if (m_data_sets.screen_data_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4)
            {
                int tile_n;
                int i;

                int _block_id_offset = _block_id << 2;
                int block_n_offset;

                // check duplicate(s)
                for (int block_n = 0; block_n < _block_id; block_n++)
                {
                    block_n_offset = block_n << 2;

                    for (i = 0; i < utils.CONST_BLOCK_SIZE; i++)
                    {
                        if (_data.blocks[block_n_offset + i] != _data.blocks[_block_id_offset + i])
                        {
                            break;
                        }
                    }

                    if (i == utils.CONST_BLOCK_SIZE)
                    {
                        // duplicate found
                        for (tile_n = 0; tile_n < platform_data.get_max_tiles_cnt(); tile_n++)
                        {
                            for (i = 0; i < utils.CONST_TILE_SIZE; i++)
                            {
                                if (_block_id == _data.get_tile_block(tile_n, i))
                                {
                                    // replace _block_id with block_n
                                    _data.set_tile_block(tile_n, i, ( ushort )block_n);
                                }
                            }
                        }
                    }
                }

                for (tile_n = 0; tile_n < platform_data.get_max_tiles_cnt(); tile_n++)
                {
                    for (i = 0; i < utils.CONST_TILE_SIZE; i++)
                    {
                        if (_block_id == _data.get_tile_block(tile_n, i))
                        {
                            return(true);
                        }
                    }
                }
            }
            else
            {
                return(check_screens_block(_block_id, _data));
            }

            return(false);
        }
Esempio n. 2
0
        public void set_selected_block(int _block_id, tiles_data _data)
        {
            if (m_locked == false && _data != null && m_selected_tile_id >= 0)
            {
                _data.set_tile_block(m_selected_tile_id, m_selected_quad_ind, ( ushort )_block_id);

                dispatch_event_need_gfx_update();

                update_status_bar();

                update();
            }
        }
Esempio n. 3
0
        void shift_tiles_data(int _block_id, tiles_data _data)
        {
            int tile_block_id;

            for (int tile_n = 0; tile_n < platform_data.get_max_tiles_cnt(); tile_n++)
            {
                for (int i = 0; i < utils.CONST_TILE_SIZE; i++)
                {
                    tile_block_id = _data.get_tile_block(tile_n, i);

                    if (tile_block_id >= _block_id)
                    {
                        _data.set_tile_block(tile_n, i, ( ushort )(tile_block_id - 1));
                    }
                }
            }
        }
Esempio n. 4
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);
        }