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; }
public CtrSwizzle(SwizzlePreparationContext context, CtrTransformation transform = CtrTransformation.None) { _transform = transform; var stride = _transform == CtrTransformation.None || _transform == CtrTransformation.YFlip ? context.Size.Width : context.Size.Height; _swizzle = new MasterSwizzle(stride, new Point(0, 0), new[] { (1, 0), (0, 1), (2, 0), (0, 2), (4, 0), (0, 4) });
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) });
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); } }
public VitaSwizzle(SwizzlePreparationContext context) { Width = (context.Size.Width + 3) & ~3; Height = (context.Size.Height + 3) & ~3; // TODO: To remove with prepend swizzle var isBlockEncoding = context.EncodingInfo.ColorsPerValue > 1; var bitField = new List <(int, int)>(); var bitStart = isBlockEncoding ? 4 : 1; if (isBlockEncoding) { bitField.AddRange(new List <(int, int)> { (1, 0), (2, 0), (0, 1), (0, 2) });
public Ps2Swizzle(SwizzlePreparationContext context) { Width = 2 << (int)Math.Log(context.Size.Width - 1, 2); Height = (context.Size.Height + 7) & ~7; switch (context.EncodingInfo.BitDepth) { case 4: case 16: throw new InvalidOperationException($"Unsupported PS2 swizzle for bit depth {context.EncodingInfo.BitDepth}"); case 8: var seq = new List <(int, int)> { (4, 2), (8, 0), (1, 0), (2, 0), (4, 0) }; for (var i = 16; i < Width; i *= 2) { seq.Add((i, 0)); } seq.AddRange(new[] { (0, 1), (4, 4) });
public NitroSwizzle(SwizzlePreparationContext context) { _swizzle = new MasterSwizzle(context.Size.Width, new Point(0, 0), new[] { (1, 0), (2, 0), (4, 0), (0, 1), (0, 2), (0, 4) });
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) });
public IImageSwizzle Build(SwizzlePreparationContext context) { ContractAssertions.IsNotNull(_func, nameof(_func)); return(_func.Invoke(context)); }