Ejemplo n.º 1
0
        private void remap_color_inds(CHR_data _chr_data, int _start_clr_ind, byte[] _remap_arr)
        {
            int  j;
            byte clr_ind;

            for (j = 0; j < utils.CONST_CHR_TOTAL_PIXELS_CNT; j++)
            {
                clr_ind = _chr_data.get_data()[j];

                clr_ind = _remap_arr[_start_clr_ind + clr_ind];

                _chr_data.get_data()[j] = clr_ind;
            }
        }
        public static void save_CHR(BinaryWriter _bw, CHR_data _chr_data)
        {
            int j;
            int x;
            int y;
            int val;

            ushort data;

            for (j = 0; j < 4; j++)
            {
                for (y = 0; y < utils.CONST_CHR_SIDE_PIXELS_CNT; y++)
                {
                    data = 0;

                    for (x = 0; x < utils.CONST_CHR_SIDE_PIXELS_CNT; x++)
                    {
                        val = _chr_data.get_data()[(y << utils.CONST_CHR_SIDE_PIXELS_CNT_POW_BITS) + ((utils.CONST_CHR_SIDE_PIXELS_CNT - 1) - x)];

                        data |= ( ushort )(((val >> j) & 0x01) << x);
                    }

                    _bw.Write(data);
                }
            }
        }
Ejemplo n.º 3
0
        private static void fill_CHR_bmp_data(IntPtr _data_ptr, int _data_offset, CHR_data _chr_data, CHR_data_attr _attr, bool _alpha, int _plt_ind, palette_small[] _plt_arr)
        {
            unsafe
            {
                int *img_buff = ( int * )(_data_ptr + _data_offset);

#if DEF_NES
                bool  apply_palette = (_plt_arr != null && _plt_ind >= 0);
                int[] clr_inds      = apply_palette ? _plt_arr[_plt_ind].get_color_inds():null;
                int   alpha;
#endif
                int clr = 0;
                int pix_ind;

                for (int p = 0; p < CONST_CHR_TOTAL_PIXELS_CNT; p++)
                {
                    pix_ind = _chr_data.get_data()[p];

#if DEF_NES
                    if (apply_palette)
#endif
                    {
#if DEF_NES
                        clr = palette_group.Instance.main_palette[clr_inds[pix_ind]];
#elif DEF_SMS
                        clr = palette_group.Instance.main_palette[palette_group.Instance.get_palettes_arr()[pix_ind / CONST_NUM_SMALL_PALETTES].get_color_inds()[pix_ind % CONST_NUM_SMALL_PALETTES]];
#endif

#if DEF_FIXED_LEN_PALETTE16_ARR
                        if (_attr != null)
                        {
                            clr = palette_group.Instance.main_palette[palettes_array.Instance.get_color((_attr.palette_ind < 0 ? 0:_attr.palette_ind), pix_ind)];
                        }
                        else
                        {
                            clr = palette_group.Instance.main_palette[palette_group.Instance.get_palettes_arr()[pix_ind / CONST_NUM_SMALL_PALETTES].get_color_inds()[pix_ind % CONST_NUM_SMALL_PALETTES]];
                        }
#endif
                        if ((pix_ind != 0 && _alpha == true) || _alpha == false)
                        {
                            clr |= 0xFF << 24;
                        }
                    }
#if DEF_NES
                    else
                    {
                        alpha = (pix_ind == 0) ? (_alpha ? 0x00:0xFF):0xFF;

                        pix_ind <<= 6;
                        clr       = alpha << 24 | pix_ind << 16 | pix_ind << 8 | pix_ind;
                    }
#endif
                    img_buff[p] = clr;
                }
            }
        }
Ejemplo n.º 4
0
        public bool equals(CHR_data _obj)
        {
            for (int i = 0; i < utils.CONST_CHR_TOTAL_PIXELS_CNT; i++)
            {
                if (get_data()[i] != _obj.get_data()[i])
                {
                    return(false);
                }
            }

            return(true);
        }