public static void PerformObabo(Bitmap image, MirrorType mirrorType) { int width = image.Width; int height = image.Height; switch (mirrorType) { case MirrorType.LeftOntoRight: { for (int x = 0; x < width / 2; x++) { for (int y = 0; y < image.Height; y++) { Color c = image.GetPixel(x, y); image.SetPixel(width - 1 - x, y, c); } } break; } case MirrorType.RightOntoLeft: { for (int x = 0; x < width / 2; x++) { for (int y = 0; y < image.Height; y++) { Color c = image.GetPixel(width - 1 - x, y); image.SetPixel(x, y, c); } } break; } case MirrorType.TopOntoBottom: { for (int y = 0; y < height / 2; y++) { for (int x = 0; x < width; x++) { Color c = image.GetPixel(x, y); image.SetPixel(x, height - 1 - y, c); } } break; } case MirrorType.BottomOntoTop: { for (int y = 0; y < height / 2; y++) { for (int x = 0; x < width; x++) { Color c = image.GetPixel(x, height - 1 - y); image.SetPixel(x, y, c); } } break; } } }
public Command CreateCommand(SlateBotController controller, CommandFile file) { bool moduleParsed = Enum.TryParse(file.Module, out ModuleType module); if (!moduleParsed) { module = ModuleType.Image; } var dictionary = file.ExtraData; MirrorType mirrorType = MirrorType.LeftOntoRight; bool valid = dictionary.Any(); if (valid) { bool hasMirrorType = file.ExtraData.TryGetValue("MirrorType", out IEnumerable <string> mirrorTypeStr) > 0; if (hasMirrorType) { valid = Enum.TryParse(mirrorTypeStr.First(), out mirrorType); } else { valid = false; } } else { valid = false; } return(valid ? (new ObaboCommand(controller.ErrorLogger, controller.waitHandler, controller, controller.languageHandler, file.Aliases, file.Examples, file.Help, module, mirrorType)) : null); }
public Mapper_001(FileStream fs, MirrorType m, byte PRGSize, byte CHRSize) : base(fs, m) { this.PRGSize = PRGSize; this.CHRSize = CHRSize; if (CHRSize == 0) { // NesDev wiki (MMC1 Page): // MMC1 can do CHR banking in 4KB chunks. Known carts with CHR RAM have 8 KiB, so that makes 2 banks CHRRAMEnabled = true; this.CHRRAM = new byte[0x2000]; } this.PRGROM = new byte[this.PRGSize, 0x4000]; // 16KB banks this.CHRROM = new byte[this.CHRSize, 0x1000]; // 4KB banks this.ExpansionROM = new byte[0x8000 - 0x4020]; for (int i = 0; i < PRGSize; i++) { for (int j = 0; j < 0x4000; j++) { this.PRGROM[i, j] = (byte)fs.ReadByte(); } } for (int i = 0; i < CHRSize; i++) { for (int j = 0; j < 0x1000; j++) { this.CHRROM[i, j] = (byte)fs.ReadByte(); } } }
TerrainTile GetFlippedTerrainTile(MirrorType mirrorType) { switch (mirrorType) { case MirrorType.Horizontal: if (horizontalDictionary.ContainsKey(Tile.Type)) { return(new TerrainTile(horizontalDictionary[Tile.Type], Tile.Index)); } break; case MirrorType.Vertical: if (verticalDictionary.ContainsKey(Tile.Type)) { return(new TerrainTile(verticalDictionary[Tile.Type], Tile.Index)); } break; case MirrorType.HorizontalAndVertical: if (horizontalAndVerticalDictionary.ContainsKey(Tile.Type)) { return(new TerrainTile(horizontalAndVerticalDictionary[Tile.Type], Tile.Index)); } break; } return(Tile); }
/// <summary> /// Gets a database mirror. /// </summary> /// <returns>Whether mirror was found</returns> protected bool GetMirror(MirrorType type, out string mirror) { if (!mirrorsValid) { UpdatesMirrors(); } if (mirrorsValid) { // Randomly select mirror switch (type) { case MirrorType.Xml: mirror = xmlMirrors[(new Random()).Next(xmlMirrors.Count)]; return(true); case MirrorType.Zip: mirror = zipMirrors[(new Random()).Next(zipMirrors.Count)]; return(true); case MirrorType.Json: mirror = jsonMirrors[(new Random()).Next(jsonMirrors.Count)]; return(true); default: throw new Exception("Unknown mirror"); } } mirror = string.Empty; return(false); }
public Mapper_004(FileStream fs, MirrorType m, byte PRGSize, byte CHRSize, bool IgnoreMirrorControl) : base(fs, m) { this._Mirror = m; this.PRGSize = PRGSize; this.CHRSize = CHRSize; this.PRGROM = new byte[2 * this.PRGSize, 0x2000]; // 8KB banks this.CHRROM = new byte[8 * this.CHRSize, 0x400]; // 1KB banks (or 2KB, but smallest is 1KB) this.ExpansionROM = new byte[0x8000 - 0x4020]; this.IgnoreMirrorControl = IgnoreMirrorControl; this.MMC3Registers = new byte[8]; for (int i = 0; i < 2 * this.PRGSize; i++) { for (int j = 0; j < 0x2000; j++) { this.PRGROM[i, j] = (byte)fs.ReadByte(); } } for (int i = 0; i < 8 * this.CHRSize; i++) { for (int j = 0; j < 0x400; j++) { this.CHRROM[i, j] = (byte)fs.ReadByte(); } } }
public static void MirrorVertex(Rect rect, List <UIVertex> vertices, MirrorType mirrorType) { int count = vertices.Count; switch (mirrorType) { case MirrorType.HORIZONTAL: ExtendLength(vertices, count); MirrorVertex(rect, vertices, count, MirrorHorizontal); break; case MirrorType.VERTICAL: ExtendLength(vertices, count); MirrorVertex(rect, vertices, count, MirrorVertical); break; case MirrorType.ALL: ExtendLength(vertices, count * 3); MirrorVertex(rect, vertices, count, MirrorHorizontal); MirrorVertex(rect, vertices, count * 2, MirrorVertical); break; default: throw new ArgumentOutOfRangeException(nameof(mirrorType), mirrorType, null); } }
/// <summary> /// Updates local list of TheTvDb mirrors. /// </summary> public override void UpdatesMirrors() { // Set mirrors to invalid mirrorsValid = false; try { // Get string for mirrors xml WebClient webClient = new WebClient(); string mirrorsXmlStr = webClient.DownloadString("http://www.thetvdb.com/api/" + this.API_KEY + "/mirrors.xml"); // Create xml object with text from mirrors url XmlDocument mirrosDoc = new XmlDocument(); mirrosDoc.InnerXml = mirrorsXmlStr; // Get root element and children XmlElement root = mirrosDoc.DocumentElement; XmlNodeList rootNodes = root.ChildNodes; // Go through each node and get the url for all mirrors xmlMirrors = new List <string>(); zipMirrors = new List <string>(); foreach (XmlNode node in rootNodes) { MirrorType type = MirrorType.Xml; string value = string.Empty; XmlNodeList subNodes = node.ChildNodes; foreach (XmlNode subNode in subNodes) { if (subNode.Name.Equals("mirrorpath")) { value = subNode.InnerText; } else if (subNode.Name.Equals("typemask")) { int typeNumber; int.TryParse(subNode.InnerText, out typeNumber); type = (MirrorType)typeNumber; } } if ((type & MirrorType.Xml) > 0) { xmlMirrors.Add(value); } if ((type & MirrorType.Zip) > 0) { zipMirrors.Add(value); } } // No exceptions caught so mirrors must be good mirrorsValid = true; } catch { } }
internal ObaboCommand(IErrorLogger errorLogger, PleaseWaitHandler waitHandler, IAsyncResponder asyncResponder, LanguageHandler languageHandler, string[] aliases, string examples, string help, ModuleType module, MirrorType mirrorType) : base(CommandHandlerType.Obabo, aliases, examples, help, module) { this.errorLogger = errorLogger; this.waitHandler = waitHandler; this.asyncResponder = asyncResponder; this.languageHandler = languageHandler; this.mirrorType = mirrorType; }
private RightAngleMirrorRoom GetMirrorRoom(MirrorType mirrorType) { var coords = new GridCoordinates(1, 1); var mirror = new Mirror { Coordinates = coords, MirrorOrientation = MirrorOrientation.Right, MirrorType = mirrorType }; return(new RightAngleMirrorRoom(mirror)); }
private ReflectionStrategy SetStrategy(MirrorType type) { if (type == MirrorType.TwoWay) { return(new TwoWayReflection()); } else if (type == MirrorType.ReflectiveLeft) { return(new OneWayReflectiveLeft()); } else { return(new OneWayReflectiveRight()); } }
public static Bitmap Mirror(this Bitmap image, MirrorType type) { switch (type) { case MirrorType.Vertical: { image.RotateFlip(RotateFlipType.RotateNoneFlipY); break; } case MirrorType.Horizontal: { image.RotateFlip(RotateFlipType.RotateNoneFlipX); break; } } return(image); }
private static void InitializeSettings() { Console.Title = "Photo Transformer"; FileFormat = EnumHelper.GetFileFormat(Settings.Default.FileFormat); MirrorType = EnumHelper.GetMirrorType(Settings.Default.Transformation_MirrorType); if (Directory.Exists(DirectoryForPhotoTransforming)) { DirectoryForTransformedPhotos = $"{DirectoryForPhotoTransforming}/Transformed-{DateTime.Now.ToString("yyyyMMdd-HHmm")}"; PhotoLocations = Directory.GetFiles(DirectoryForPhotoTransforming, $"*.{FileFormat}", SearchOption.TopDirectoryOnly); } else { throw new Exception("Photo directory does not exist..."); } }
public Mirror BuildMirror(string mirrorDef) { Match location = _locationRegex.Match(mirrorDef); Match orientation = _orientationRegex.Match(mirrorDef); if (location.Groups.Count == 0 || location.Groups[0].Value.Length != 3) { throw new Exception("Invalid Mirror Definition. Please Check Definition file."); } int xLoc = Convert.ToInt32(location.Groups[0].Value.Substring(0, 1)); int yLoc = Convert.ToInt32(location.Groups[0].Value.Substring(2, 1)); Direction dir = GetDirection(orientation.Groups[0].Value.Substring(0, 1)); MirrorType type = GetMirrorType(orientation.Groups[0].Value); return(new Mirror(xLoc, yLoc, dir, type, SetStrategy(type))); }
public Mapper_007(FileStream fs, MirrorType m, byte PRGSize, byte CHRSize) : base(fs, m) { this.PRGSize = PRGSize; this.CHRSize = 1; this._Mirror = m; this.PRGROM = new byte[this.PRGSize >> 1, 0x8000]; // 32KB banks this.CHRRAM = new byte[this.CHRSize << 1, 0x1000]; // 4KB bank this.ExpansionROM = new byte[0x8000 - 0x4020]; for (int i = 0; i < PRGSize >> 1; i++) { for (int j = 0; j < 0x8000; j++) { this.PRGROM[i, j] = (byte)fs.ReadByte(); } } }
public Renderer(MirrorType mirrorType) { //BMP画像生成 gameScreen = new byte[245814]; using (MemoryStream memoryStream = new MemoryStream(gameScreen)) { using (BinaryWriter writer = new BinaryWriter(memoryStream)) { //BitmapFileHeader(14byte) writer.Write(new char[] { 'B', 'M' }); //シグネチャ writer.Write(245814); //ファイルサイズ writer.Write((short)0); //予約領域 writer.Write((short)0); //予約領域 writer.Write(HEADER_SIZE); //ピクセルまでのオフセット //BitmapInfoHeader(40byte) writer.Write(40); //ヘッダーサイズ writer.Write(256); //width writer.Write(-240); //height writer.Write((short)1); //プレーン数 writer.Write((short)32); //ピクセルあたりのビット数 writer.Write(0); //圧縮形式 writer.Write(245760); //画像サイズ writer.Write(0); //横方向の解像度 writer.Write(0); //縦方向の解像度 writer.Write(0); //色テーブルの色の数 writer.Write(0); //重要な色の数 } } IsSpriteVisible = true; IsBGVisible = true; SpriteSize = 8; Palette = new byte[0x20]; patternTable = new byte[0x2000]; nameTable = new byte[3840]; attrTable = new byte[3840]; screenOffset = HEADER_SIZE; oamTable = new Oam[0x40]; spriteRenderPosition = new Dictionary <int, Oam>(); spritePosition = new List <int> [0x40]; this.mirrorType = mirrorType; }
public Ppu(Nes nes, MirrorType mirrorType) : base(nes) { unitName = GetType().Name; ppuAddress = new byte[0x4000]; this.nes = nes; nmiInterrupt = false; oamDataWriteCount = 0; ppuWriteCount = 0; tempOamData = new byte[4]; ppuAddressInc = 0x01; RenderLine = 0; vBlank = false; renderer = new Renderer(mirrorType); renderer.Sprite = new byte[nes.CharacterRimSize / 16, 8, 8]; }
public Mapper_000(FileStream fs, MirrorType m, byte PRGSize, byte CHRSize) : base(fs, m) { this._Mirror = m; this.PRGSize = PRGSize; this.CHRSize = CHRSize; this.PRGROM = new byte[0x4000 * this.PRGSize]; this.CHRROM = new byte[0x2000 * this.CHRSize]; this.ExpansionROM = new byte[0x8000 - 0x4020]; for (int i = 0; i < this.PRGROM.Length; i++) { this.PRGROM[i] = (byte)fs.ReadByte(); } for (int i = 0; i < this.CHRROM.Length; i++) { this.CHRROM[i] = (byte)fs.ReadByte(); } }
public void SetMirroring(MirrorType type) { Mirroring = type; if (type == MirrorType.Horizontal) { NameAttributeTables[0] = NameAttributeTables[1] = Nametable1; NameAttributeTables[2] = NameAttributeTables[3] = Nametable2; } else if (type == MirrorType.Vertical) { NameAttributeTables[0] = NameAttributeTables[2] = Nametable1; NameAttributeTables[1] = NameAttributeTables[3] = Nametable2; } else if (type == MirrorType.FourScreen) { NameAttributeTables[0] = Nametable1; NameAttributeTables[1] = Nametable2; NameAttributeTables[2] = Nametable3; NameAttributeTables[3] = Nametable4; } else if (type == MirrorType.SingleScreenLower) { NameAttributeTables[0] = NameAttributeTables[1] = NameAttributeTables[2] = NameAttributeTables[3] = Nametable1; } else if (type == MirrorType.SingleScreenUpper) { NameAttributeTables[0] = NameAttributeTables[1] = NameAttributeTables[2] = NameAttributeTables[3] = Nametable2; } Console.WriteLine("Mirroring={0} ({1})", type, IdentifyBanks()); }
public Mapper_002(FileStream fs, MirrorType m, byte PRGSize, byte CHRSize) : base(fs, m) { this._Mirror = m; this.PRGSize = PRGSize; this.CHRSize = CHRSize; this.BankSelect = 0; this.PRGROM = new byte[this.PRGSize, 0x4000]; this.CHRROM = new byte[0x2000]; // No window this.ExpansionROM = new byte[0x8000 - 0x4020]; for (int i = 0; i < this.PRGSize; i++) { for (int j = 0; j < 0x4000; j++) { this.PRGROM[i, j] = (byte)fs.ReadByte(); } } for (int i = 0; i < this.CHRROM.Length; i++) { this.CHRROM[i] = (byte)fs.ReadByte(); } }
public Rom(string filename) { Console.WriteLine("Loading ROM: {0}", filename); using (BinaryReader r = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read))) { byte sig1, sig2, sig3, sig4; sig1 = r.ReadByte(); sig2 = r.ReadByte(); sig3 = r.ReadByte(); sig4 = r.ReadByte(); if (sig1 != 'N' || sig2 != 'E' || sig3 != 'S' || sig4 != 0x1A) throw new RomFormatException("Invalid ROM signature"); byte prgRomBanks = r.ReadByte(); byte vromBanks = r.ReadByte(); byte rcb1 = r.ReadByte(); byte rcb2 = r.ReadByte(); int mapper = (rcb1 >> 4) | (rcb2 & 0xF0); MapperNumber = mapper; byte ramBanks = r.ReadByte(); // Read reserved bytes for(int i=0; i<7; ++i) r.ReadByte(); Console.WriteLine("16KB PRG-ROM banks: {0}", prgRomBanks); Console.WriteLine("8KB CHR-ROM (VROM) banks: {0}", vromBanks); Console.WriteLine("ROM Ctrl Byte 1: 0x{0:X2}", rcb1); Console.WriteLine("ROM Ctrl Byte 2: 0x{0:X2}", rcb2); Console.WriteLine(" Mapper: {0}: {1}", mapper, GetMapperName(mapper)); Console.WriteLine(" Mirroring: {0}", (rcb1 & 0x01) != 0 ? "Vertical" : "Horizontal"); Console.WriteLine(" Battery-Backed RAM: {0}", (rcb1 & 0x02) != 0 ? "Yes" : "No"); Console.WriteLine(" 512-Byte Trainer: {0}", (rcb1 & 0x04) != 0 ? "Yes" : "No"); Console.WriteLine(" 4-Screen Mirroring: {0}", (rcb1 & 0x08) != 0 ? "Yes" : "No"); Console.WriteLine("8KB RAM banks: {0}", ramBanks); PrgRomBanks = new byte[prgRomBanks][]; ChrRomBanks = new byte[vromBanks][]; RamBanks = new byte[ramBanks][]; for (int i = 0; i < prgRomBanks; ++i) PrgRomBanks[i] = r.ReadBytes(16 * 1024); for (int i = 0; i < vromBanks; ++i) ChrRomBanks[i] = r.ReadBytes(8 * 1024); for (int i = 0; i < ramBanks; ++i) RamBanks[i] = r.ReadBytes(8 * 1024); Console.WriteLine("Loaded all banks."); if ((rcb1 & 0x08) != 0) MirrorType = MirrorType.FourScreen; else if ((rcb1 & 0x01) != 0) MirrorType = MirrorType.Vertical; else MirrorType = MirrorType.Horizontal; Console.WriteLine("ROM Mirroring={0}", MirrorType); } }
public void Init(MirrorType mirrorType, Image image) { _mirrorType = mirrorType; _image = image; }
public Rom(string filename) { Console.WriteLine("Loading ROM: {0}", filename); using (BinaryReader r = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read))) { byte sig1, sig2, sig3, sig4; sig1 = r.ReadByte(); sig2 = r.ReadByte(); sig3 = r.ReadByte(); sig4 = r.ReadByte(); if (sig1 != 'N' || sig2 != 'E' || sig3 != 'S' || sig4 != 0x1A) { throw new RomFormatException("Invalid ROM signature"); } byte prgRomBanks = r.ReadByte(); byte vromBanks = r.ReadByte(); byte rcb1 = r.ReadByte(); byte rcb2 = r.ReadByte(); int mapper = (rcb1 >> 4) | (rcb2 & 0xF0); MapperNumber = mapper; byte ramBanks = r.ReadByte(); // Read reserved bytes for (int i = 0; i < 7; ++i) { r.ReadByte(); } Console.WriteLine("16KB PRG-ROM banks: {0}", prgRomBanks); Console.WriteLine("8KB CHR-ROM (VROM) banks: {0}", vromBanks); Console.WriteLine("ROM Ctrl Byte 1: 0x{0:X2}", rcb1); Console.WriteLine("ROM Ctrl Byte 2: 0x{0:X2}", rcb2); Console.WriteLine(" Mapper: {0}: {1}", mapper, GetMapperName(mapper)); Console.WriteLine(" Mirroring: {0}", (rcb1 & 0x01) != 0 ? "Vertical" : "Horizontal"); Console.WriteLine(" Battery-Backed RAM: {0}", (rcb1 & 0x02) != 0 ? "Yes" : "No"); Console.WriteLine(" 512-Byte Trainer: {0}", (rcb1 & 0x04) != 0 ? "Yes" : "No"); Console.WriteLine(" 4-Screen Mirroring: {0}", (rcb1 & 0x08) != 0 ? "Yes" : "No"); Console.WriteLine("8KB RAM banks: {0}", ramBanks); PrgRomBanks = new byte[prgRomBanks][]; ChrRomBanks = new byte[vromBanks][]; RamBanks = new byte[ramBanks][]; for (int i = 0; i < prgRomBanks; ++i) { PrgRomBanks[i] = r.ReadBytes(16 * 1024); } for (int i = 0; i < vromBanks; ++i) { ChrRomBanks[i] = r.ReadBytes(8 * 1024); } for (int i = 0; i < ramBanks; ++i) { RamBanks[i] = r.ReadBytes(8 * 1024); } Console.WriteLine("Loaded all banks."); if ((rcb1 & 0x08) != 0) { MirrorType = MirrorType.FourScreen; } else if ((rcb1 & 0x01) != 0) { MirrorType = MirrorType.Vertical; } else { MirrorType = MirrorType.Horizontal; } Console.WriteLine("ROM Mirroring={0}", MirrorType); } }
public Mapper(FileStream fs, MirrorType m) { }
public MirrorEffect(IImageProvider source, MirrorType mirrorType = MirrorType.Horizontal) : base(source) { m_MirrorType = mirrorType; }
public Cartridge(string filename) { this.filename = filename; this.fs = File.OpenRead(filename); byte MapperNumber; // NES\n Header for (int i = 0; i < 4; i++) { fs.ReadByte(); } // Bytes 4 and 5 this.PRGSize = (byte)this.fs.ReadByte(); this.CHRSize = (byte)this.fs.ReadByte(); // Byte 6 byte Flags = (byte)this.fs.ReadByte(); this.IgnoreMirrorControl = (Flags & 0x08) > 0; // todo: ignore mirror control if ((Flags & 0x01) == 0) { this.Mirror = MirrorType.Horizontal; } else { this.Mirror = MirrorType.Vertical; } if (IgnoreMirrorControl) { this.Mirror = MirrorType.FourScreen; } this.BatteryPackedPRGRam = (Flags & 0x02) > 0; // todo: deal with trainer this.Trainer = (Flags & 0x04) > 0; MapperNumber = (byte)((Flags & 0xf0) >> 4); // Byte 7 Flags = (byte)this.fs.ReadByte(); this.VSUnisystem = (Flags & 0x01) > 0; this.PlayChoice10 = (Flags & 0x02) > 0; this.INES2 = (Flags & 0x0c) > 0; MapperNumber = (byte)(MapperNumber | (Flags & 0xf0)); // Byte 8 this.PRGRAMSize = (byte)fs.ReadByte(); // Byte 8-15, Not implemented for (int i = 0; i < 7; i++) { fs.ReadByte(); } switch (MapperNumber) { case 0: this.Mapper = new Mapper_000(fs, Mirror, PRGSize, CHRSize); break; case 1: this.Mapper = new Mapper_001(fs, Mirror, PRGSize, CHRSize); break; case 2: this.Mapper = new Mapper_002(fs, Mirror, PRGSize, CHRSize); break; case 3: this.Mapper = new Mapper_003(fs, Mirror, PRGSize, CHRSize); break; case 4: this.Mapper = new Mapper_004(fs, Mirror, PRGSize, CHRSize, IgnoreMirrorControl); break; case 7: this.Mapper = new Mapper_007(fs, Mirror, PRGSize, CHRSize); break; default: throw new Exception(string.Format("Mapper {0:d3} not implemented yet", MapperNumber)); } }
public override void CPUWrite(int index, byte value) { if (index < 0x8000) { if (PRGRAMChipEnable == 1 && PRGRAMWriteProtection == 0) { this.ExpansionROM[index - 0x4020] = value; } } else if (index < 0xa000) { if ((index & 0x01) == 0) // even { BankSelect = value; } else // odd { if (RegisterSelect == 6 || RegisterSelect == 7) { this.MMC3Registers[RegisterSelect] = (byte)(value & 0x3f); // ignore top 2 bits } else if (RegisterSelect == 0 || RegisterSelect == 1) { this.MMC3Registers[RegisterSelect] = (byte)(value & 0xfe); // ignore bottom bit } else { this.MMC3Registers[RegisterSelect] = value; } } } else if (index < 0xc000) { if ((index & 0x01) == 0) // even { if (!IgnoreMirrorControl) { this._Mirror = ((value & 0x01) == 0) ? MirrorType.Vertical : MirrorType.Horizontal; } } else // odd { PRGRAMProtect = value; } } else if (index < 0xe000) { if ((index & 0x01) == 0) // even { IRQLatch = value; } else // odd { IRQReload = true; } } else if (index < 0x10000) { if ((index & 0x01) == 0) // even { IRQEnabled = false; } else // odd { IRQEnabled = true; } } else { throw new Exception(string.Format("Index {0:x2} out of range for cpu: Mapper_004", index)); } }
public static extern ErrorCode SetVideoMirror(IntPtr handle, MirrorType mirrorType, bool enable);
public Mirror(Vector3 mirrorPoint, float mirrorSign, MirrorType type = MirrorType.Horizontal) { this.MirrorPoint = mirrorPoint; this.MirrorSign = mirrorSign; this.Type = type; }
public void SetVideoMirror(MirrorType mirrorType, bool enable) { Debug.Assert(_cardHandle != IntPtr.Zero); OfficalApi.SetVideoMirror(_cardHandle, mirrorType, enable); }
protected void Run(Utility utility, string[] args) { // HACK: The engine code assumes that Game.modData is set. Game.ModData = ModData = utility.ModData; var filename = args[1]; var flag = args[2]; if (string.IsNullOrWhiteSpace(flag)) { flag = "VH"; } bool flipHorizontal = flag.Contains("H"); bool flipVertical = flag.Contains("V"); MirrorType mirrorType = MirrorType.Horizontal; if (flipVertical) { mirrorType = MirrorType.Vertical; } if (flipHorizontal && flipVertical) { mirrorType = MirrorType.HorizontalAndVertical; } var targetPath = "..\\mods\\dr\\maps"; var package = new Folder(targetPath).OpenPackage(filename, ModData.ModFiles); if (package == null) { Console.WriteLine("Couldn't find map file: " + filename); return; } Map = new Map(ModData, package); var size = Map.MapSize; switch (mirrorType) { case MirrorType.Horizontal: size = size.WithX(size.X / 2); break; case MirrorType.Vertical: size = size.WithY(size.Y / 2); break; case MirrorType.HorizontalAndVertical: size = size / 2; break; } // Tiles for (int x = 0; x < size.X; x++) { for (int y = 0; y < size.Y; y++) { var pos = new CPos(x, y); var transformTile = new TileTransform() { Tile = Map.Tiles[pos], MirrorType = mirrorType, Position = pos }; foreach (var tt in transformTile.GetTransforms(Map)) { var newPos = tt.Position; Map.Tiles[newPos] = tt.Tile; } } } // Actors actorIndex = GetHighestActorIndex(); int multiCount = 0; var actorDefs = new List <ActorReference>(); var removeActors = new List <MiniYamlNode>(); foreach (var a in Map.ActorDefinitions) { var existing = new ActorReference(a.Value.Value, a.Value.ToDictionary()); var pos = existing.GetOrDefault <LocationInit>().Value; var owner = existing.Get <OwnerInit>(); if (pos.X < 0 || pos.X >= size.X || pos.Y < 0 || pos.Y >= size.Y) { removeActors.Add(a); continue; } var actor = new ActorTransform() { Actor = existing, Position = pos, MirrorType = mirrorType, }; if (actor.Actor.Type == "mpspawn") { multiCount++; } foreach (var at in actor.GetTransforms(Map)) { var ar = new ActorReference(actor.Actor.Type) { new LocationInit(at.Position), owner }; actorDefs.Add(ar); if (at.Actor.Type == "mpspawn") { multiCount++; } } } foreach (var a in actorDefs) { Map.ActorDefinitions.Add(new MiniYamlNode("Actor" + ++actorIndex, a.Save())); } foreach (var a in removeActors) { Map.ActorDefinitions.Remove(a); } if (multiCount > 0) { var mapPlayers = new MapPlayers(Map.Rules, multiCount); Map.PlayerDefinitions = mapPlayers.ToMiniYaml(); } // Resources for (int x = 0; x < size.X; x++) { for (int y = 0; y < size.Y; y++) { var pos = new CPos(x, y); var resource = new ResourceTransform() { Tile = Map.Resources[pos], MirrorType = mirrorType, Position = pos }; foreach (var rt in resource.GetTransforms(Map)) { var newPos = rt.Position; Map.Resources[newPos] = rt.Tile; } } } var dest = Path.Combine(targetPath, Path.GetFileNameWithoutExtension(filename) + ".oramap"); Map.Save(ZipFileLoader.Create(dest)); Console.WriteLine(dest + " saved."); }
/// <summary> /// Gets a database mirror. /// </summary> /// <returns>Whether mirror was found</returns> protected bool GetMirror(MirrorType type, out string mirror) { if (!mirrorsValid) UpdatesMirrors(); if (mirrorsValid) { // Randomly select mirror switch (type) { case MirrorType.Xml: mirror = xmlMirrors[(new Random()).Next(xmlMirrors.Count)]; return true; case MirrorType.Zip: mirror = zipMirrors[(new Random()).Next(zipMirrors.Count)]; return true; case MirrorType.Json: mirror = jsonMirrors[(new Random()).Next(jsonMirrors.Count)]; return true; default: throw new Exception("Unknown mirror"); } } mirror = string.Empty; return false; }