Beispiel #1
0
        public sprite_data copy(string _name, CHR_data_group _chr_data_group, List <CHR_data_attr> _chr_attrs)
        {
            sprite_params spr_params;

            spr_params.m_CHR_data = (_chr_data_group != null) ? _chr_data_group:m_CHR_data;
            spr_params.m_offset_x = m_offset_x;
            spr_params.m_offset_y = m_offset_y;
            spr_params.m_size_x   = m_size_x;
            spr_params.m_size_y   = m_size_y;
            spr_params.m_CHR_attr = new List <CHR_data_attr>(m_CHR_attr.Count);

            if (_chr_attrs == null)
            {
                m_CHR_attr.ForEach(delegate(CHR_data_attr _attr) { spr_params.m_CHR_attr.Add(_attr.copy()); });
            }
            else
            {
                spr_params.m_CHR_attr = _chr_attrs;
            }

            sprite_data spr = new sprite_data(_name);

            spr.setup(spr_params);

            return(spr);
        }
Beispiel #2
0
        public bool split_CHR(bool _mode8x16)
        {
            // create a new bank and transfer all sprite data from the common bank to it
            CHR_data_group new_chr_data = new CHR_data_group();

            CHR_data_attr attr;

            int size = m_CHR_attr.Count;

            for (int i = 0; i < size; i++)
            {
                attr = m_CHR_attr[i];

                new_chr_data.get_data().Add(m_CHR_data.get_data()[attr.CHR_ind].copy());

                if (_mode8x16 && attr.CHR_ind + 1 < m_CHR_data.get_data().Count)
                {
                    new_chr_data.get_data().Add(m_CHR_data.get_data()[attr.CHR_ind + 1].copy());

                    attr.CHR_ind = i << 1;
                }
                else
                {
                    attr.CHR_ind = i;
                }
            }

            set_CHR_data(new_chr_data);

            return(true);
        }
Beispiel #3
0
        public bool merge_CHR(sprite_data _spr, SPReD.CHR_data_group.ECHRPackingType _packing_type, bool _mode8x16)
        {
            // check if data were already packed
            if (_spr.is_packed(_mode8x16))
            {
                return(false);
            }

            int last_CHR_cnt = get_CHR_data().get_data().Count;

            CHR_data_group spr_chr_data = _spr.get_CHR_data();

            get_CHR_data().add_data_range(spr_chr_data);

            int i;
            int size = _spr.get_CHR_attr().Count;

            for (i = 0; i < size; i++)
            {
                _spr.get_CHR_attr()[i].CHR_ind += last_CHR_cnt;
            }

            _spr.set_CHR_data(this.get_CHR_data());

            return(true);
        }
        public sprite_params create(Bitmap _bmp, bool _apply_palette, int _palette_slot)
        {
            CHR_data_group chr_data = new CHR_data_group();

            add(chr_data);

            return(chr_data.setup(_bmp, _apply_palette, _palette_slot));
        }
        public sprite_params create(PngReader _png_reader, bool _apply_palette, bool _crop_image, int _palette_slot)
        {
            CHR_data_group chr_data = new CHR_data_group();

            add(chr_data);

            return(chr_data.setup(_png_reader, _apply_palette, _crop_image, _palette_slot));
        }
        public sprite_params create()
        {
            CHR_data_group chr_data = new CHR_data_group();

            add(chr_data);

            return(new sprite_params(chr_data));
        }
Beispiel #7
0
        public void set_CHR_data(CHR_data_group _new_data)
        {
            m_CHR_data.unlink();

            m_CHR_data = _new_data;

            m_CHR_data.link();
        }
Beispiel #8
0
        public void reset()
        {
            name = null;

            m_CHR_data.unlink();
            m_CHR_data = null;

            m_CHR_attr.Clear();
            m_CHR_attr = null;
        }
Beispiel #9
0
        public bool relink_CHR_data(CHR_data_group _chr_data, int _old_chr_id)
        {
            if (_old_chr_id == get_CHR_data().id)
            {
                set_CHR_data(_chr_data);

                return(true);
            }

            return(false);
        }
Beispiel #10
0
        public void setup(sprite_params _params)
        {
            m_offset_x = _params.m_offset_x;
            m_offset_y = _params.m_offset_y;
            m_size_x   = _params.m_size_x;
            m_size_y   = _params.m_size_y;
            m_CHR_data = _params.m_CHR_data;
            m_CHR_attr = _params.m_CHR_attr;

            m_CHR_data.link();
        }
Beispiel #11
0
        public sprite_params(CHR_data_group _CHR_data)
        {
            m_CHR_attr = new List <CHR_data_attr>(100);

            m_CHR_data = _CHR_data;

            m_offset_x = 0;
            m_offset_y = 0;
            m_size_x   = -1;
            m_size_y   = -1;
        }
        public void reset()
        {
            {
                m_sprite_layout_viewer.reset();

                sprite_data spr = null;
                m_sprite_layout_viewer.init(spr);
            }
            {
                m_CHR_bank_viewer.reset();
            }

            m_CHR_data_storage.reset();

            CHR_data_group.reset_ids_cnt();
        }
        public bool remove(CHR_data_group _data)
        {
            if (_data.get_link_cnt() <= 0)
            {
                int size = m_data.Count;

                for (int i = 0; i < size; i++)
                {
                    if (m_data[i] == _data)
                    {
                        m_data.Remove(_data);

                        return(true);
                    }
                }
            }

            return(false);
        }
 public void add(CHR_data_group _chr_data)
 {
     m_data.Add(_chr_data);
 }
Beispiel #15
0
        public static bool can_merge(CHR_data_group _data1, CHR_data_group _data2, ECHRPackingType _packing_type)
        {
            if (_data1.id == _data2.id)
            {
                return(false);
            }

            int total_size = _data1.get_size_bytes() + _data2.get_size_bytes();
            int max_size   = 0;

            switch (_packing_type)
            {
            case CHR_data_group.ECHRPackingType.pt_1KB:
            {
                max_size = 1024;
            }
            break;

            case CHR_data_group.ECHRPackingType.pt_2KB:
            {
                max_size = 2048;
            }
            break;

            case CHR_data_group.ECHRPackingType.pt_4KB:
            {
                max_size = 4096;
            }
            break;

#if DEF_SMS
            case CHR_data_group.ECHRPackingType.pt_8KB:
            {
                max_size = 8192;
            }
            break;
#elif DEF_PCE
            case CHR_data_group.ECHRPackingType.pt_8KB:
            {
                max_size = 8192;
            }
            break;

            case CHR_data_group.ECHRPackingType.pt_16KB:
            {
                max_size = 16384;
            }
            break;

            case CHR_data_group.ECHRPackingType.pt_32KB:
            {
                max_size = 32768;
            }
            break;
#endif
            default:
            {
                throw new Exception("Unexpected data packing type detected!");
            }
            }

            return(total_size <= max_size ? true:false);
        }
Beispiel #16
0
 public void add_data_range(CHR_data_group _chr_data)
 {
     m_CHR_arr.InsertRange(m_CHR_arr.Count, _chr_data.get_data());
 }