Exemple #1
0
        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);
        }
Exemple #2
0
        int Blocks_optimization(tiles_data _data, bool _check)
        {
            int deleted_blocks_cnt = 0;

            uint sum;
            int  block_offset;

            int size = _data.get_first_free_block_id(false);

            for (int block_n = 0; block_n < size; block_n++)
            {
                if (check_tiles_block(block_n, _data) == false)
                {
                    sum = 0;

                    block_offset = block_n << 2;

                    for (int i = 0; i < utils.CONST_BLOCK_SIZE; i++)
                    {
                        sum += _data.blocks[block_offset + i];
                    }

                    if (sum != 0)
                    {
                        ++deleted_blocks_cnt;
                    }

                    if (_check == true)
                    {
                        continue;
                    }

                    // delete the useless block
                    {
                        Array.Copy(_data.blocks, block_offset + utils.CONST_BLOCK_SIZE, _data.blocks, block_offset, (platform_data.get_max_blocks_cnt() << 2) /* * utils.CONST_BLOCK_SIZE*/ - (block_offset + utils.CONST_BLOCK_SIZE));
                    }

                    // the last block is an empty space
                    {
                        int last_block_ind = platform_data.get_max_blocks_cnt() << 2;

                        _data.blocks[last_block_ind - 1] = 0;
                        _data.blocks[last_block_ind - 2] = 0;
                        _data.blocks[last_block_ind - 3] = 0;
                        _data.blocks[last_block_ind - 4] = 0;
                    }

                    if (m_data_sets.screen_data_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4)
                    {
                        shift_tiles_data(block_n, _data);
                    }
                    else
                    {
                        _data.dec_screen_tiles(( ushort )block_n);
                        _data.dec_patterns_tiles(( ushort )block_n);
                    }

                    --block_n;
                    --size;
                }
            }

            return(deleted_blocks_cnt);
        }