예제 #1
0
        public Linear(int widthStride)
        {
            Width  = widthStride;
            Height = 0;

            _linear = new MasterSwizzle(widthStride, new Point(0, 0), Enumerable.Empty <(int, int)>());
        }
예제 #2
0
        private IImageSwizzle CreateSwizzle(Size size, IEncodingInfo encoding)
        {
            switch (SelectedSwizzleExtension.Name)
            {
            case "NDS":
                return(new NitroSwizzle(size.Width, size.Height));

            case "3DS":
                return(new CTRSwizzle(size.Width, size.Height, CtrTransformation.None, true));

            case "WiiU":
                var swizzleTileMode = SelectedSwizzleExtension.GetParameterValue <byte>("SwizzleTileMode");
                return(new CafeSwizzle(swizzleTileMode, encoding.BitsPerValue > 32, encoding.BitDepth, size.Width, size.Height));

            case "Custom":
                var swizzleText        = SelectedSwizzleExtension.GetParameterValue <string>("BitMapping");
                var escapedSwizzleText = swizzleText.Replace(" ", "");

                var pointStrings = escapedSwizzleText.Substring(1, escapedSwizzleText.Length - 2)
                                   .Split(new[] { "},{" }, StringSplitOptions.None);
                var finalPoints = pointStrings.Select(x => x.Split(','))
                                  .Select(x => (int.Parse(x[0]), int.Parse(x[1])));

                var masterSwizzle = new MasterSwizzle(size.Width, Point.Empty, finalPoints.ToArray());
                return(new CustomSwizzle(size.Width, size.Height, masterSwizzle));

            default:
                return(null);
            }
        }
예제 #3
0
            public CustomSwizzle(int width, int height, MasterSwizzle swizzle)
            {
                Width  = width;
                Height = height;

                _swizzle = swizzle;
            }
예제 #4
0
        public CTRSwizzle(int width, int height, byte orientation = 0, bool toPowerOf2 = true)
        {
            Width  = (toPowerOf2) ? 2 << (int)Math.Log(width - 1, 2) : width;
            Height = (toPowerOf2) ? 2 << (int)Math.Log(height - 1, 2) : height;

            _orientation = orientation;
            _zorder      = new MasterSwizzle(orientation == 0 ? Width : Height, new Point(0, 0), new[] { (1, 0), (0, 1), (2, 0), (0, 2), (4, 0), (0, 4) });
예제 #5
0
        public CustomSwizzle(SwizzlePreparationContext context, MasterSwizzle swizzle)
        {
            _swizzle = swizzle;

            Width  = (context.Size.Width + _swizzle.MacroTileWidth - 1) & -_swizzle.MacroTileWidth;
            Height = (context.Size.Height + _swizzle.MacroTileHeight - 1) & -_swizzle.MacroTileHeight;
        }
예제 #6
0
        public CTRSwizzle(int width, int height, byte orientation = 0)
        {
            Width  = 2 << (int)Math.Log(width - 1, 2);
            Height = 2 << (int)Math.Log(height - 1, 2);

            _orientation = orientation;
            _zorder      = new MasterSwizzle(orientation == 0 ? Width : Height, new Point(0, 0), new[] { (1, 0), (0, 1), (2, 0), (0, 2), (4, 0), (0, 4) });
예제 #7
0
        public CTRSwizzle(int width, int height, byte orientation = 0, bool toPowerOf2 = true)
        {
            Width  = (toPowerOf2) ? 2 << (int)Math.Log(width - 1, 2) : width;
            Height = (toPowerOf2) ? 2 << (int)Math.Log(height - 1, 2) : height;

            _orientation = orientation;
            //the orientation check was "orientation == 0 ? Width : Height"; based on commit 8c5e0bed for G1Ts newest changes it seems to be only Width as a stride
            _zorder = new MasterSwizzle(orientation == 0 || orientation == 2 ? Width : Height, new Point(0, 0), new[] { (1, 0), (0, 1), (2, 0), (0, 2), (4, 0), (0, 4) });
예제 #8
0
        public ImgxSwizzle(SwizzlePreparationContext context, string magic)
        {
            Width  = (context.Size.Width + 7) & ~7;
            Height = (context.Size.Height + 7) & ~7;

            switch (magic)
            {
            case "IMGC":
                _swizzle = new MasterSwizzle(Width, Point.Empty, new[] { (0, 1), (1, 0), (0, 2), (2, 0), (0, 4), (4, 0) });
예제 #9
0
        private IImageSwizzle CreateSwizzle(SwizzlePreparationContext context)
        {
            switch (SelectedSwizzleExtension.Name)
            {
            case "Bc":
                return(new BcSwizzle(context));

            case "NDS":
                return(new NitroSwizzle(context));

            case "3DS":
                return(new CtrSwizzle(context));

            case "WiiU":
                var swizzleTileMode = SelectedSwizzleExtension.GetParameterValue <byte>("SwizzleTileMode");
                return(new CafeSwizzle(context, swizzleTileMode));

            case "Switch":
                var swizzleMode = SelectedSwizzleExtension.GetParameterValue <int>("SwizzleMode");
                return(new NxSwizzle(context, swizzleMode));

            case "PS2":
                return(new Ps2Swizzle(context));

            case "Vita":
                return(new VitaSwizzle(context));

            case "Custom":
                var pointSequenceRegex = new Regex(@"\{([\d]+),([\d]+)\}[,]?");

                // Bit mapping
                var mappingText   = SelectedSwizzleExtension.GetParameterValue <string>("BitMapping").Replace(" ", "");
                var mappingPoints = pointSequenceRegex.Matches(mappingText).Select(m => (int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)));

                // Init point
                var initPointText  = SelectedSwizzleExtension.GetParameterValue <string>("InitPoint").Replace(" ", "");
                var initPointMatch = pointSequenceRegex.Match(initPointText);
                var finalInitPoint = new System.Drawing.Point(int.Parse(initPointMatch.Groups[1].Value), int.Parse(initPointMatch.Groups[2].Value));

                // Y Transform
                var transformText   = SelectedSwizzleExtension.GetParameterValue <string>("YTransform").Replace(" ", "");
                var transformPoints = pointSequenceRegex.Matches(transformText).Select(m => (int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)));

                var masterSwizzle = new MasterSwizzle(context.Size.Width, finalInitPoint, mappingPoints.ToArray(), transformPoints.ToArray());
                return(new CustomSwizzle(context, masterSwizzle));

            default:
                return(null);
            }
        }
예제 #10
0
        public Linear(int widthStride, int heightStride)
        {
            Width  = widthStride;
            Height = heightStride;

            List <(int, int)> bitField = new List <(int, int)>();

            for (int i = 1; i < widthStride; i *= 2)
            {
                bitField.Add((i, 0));
            }
            for (int i = 1; i < heightStride; i *= 2)
            {
                bitField.Add((0, i));
            }
            _linear = new MasterSwizzle(widthStride, new Point(0, 0), bitField);
        }
예제 #11
0
        public BlockSwizzle(int width, int height)
        {
            Width  = (width + 3) & ~3;
            Height = (height + 3) & ~3;

            _swizzle = new MasterSwizzle(Width, new Point(0, 0), new[] { (1, 0), (2, 0), (0, 1), (0, 2) });
예제 #12
0
        public ImgcSwizzle(int width, int height)
        {
            Width  = (width + 0x7) & ~0x7;
            Height = (height + 0x7) & ~0x7;

            _zorderTrans = new MasterSwizzle(Width, new Point(0, 0), new[] { (0, 1), (1, 0), (0, 2), (2, 0), (0, 4), (4, 0) });
예제 #13
0
        public ImgcSwizzle(SwizzlePreparationContext context)
        {
            Width  = (context.Size.Width + 0x7) & ~0x7;
            Height = (context.Size.Height + 0x7) & ~0x7;

            _zOrder = new MasterSwizzle(Width, Point.Empty, new[] { (0, 1), (1, 0), (0, 2), (2, 0), (0, 4), (4, 0) });
예제 #14
0
            public GCSwizzle(int width, int height)
            {
                Width  = width;
                Height = height;

                _tiler = new MasterSwizzle(Width, new Point(0, 0), new[] { (1, 0), (2, 0), (0, 1), (0, 2) });
예제 #15
0
        public AIFSwizzle(int width, int height)
        {
            Width  = 2 << (int)Math.Log(width - 1, 2);
            Height = 2 << (int)Math.Log(height - 1, 2);

            _zorder = new MasterSwizzle(Width, new Point(0, 0), new[] { (1, 0), (0, 1), (2, 0), (0, 2), (4, 0), (0, 4) });