private void MainFrm_Load(object sender, EventArgs e) { // set position of form //base.Location = new Point(800, 150); // reader is our handle to the physical reader. //reader = new RFIDReader(this); handleTags = new WispHandleTags(); readerMgr = new ReaderManager(this, handleTags); log = new WispLoggingManager(); // init the saturn object. saturn = new Saturn(); // Setup axis labels for the various graphs. InitSOCGraph(); InitTempGraph(); // Other init code InitTagStats(); // Store initial sizes (for resize operation). formInitialSize = this.Size; pnlTagListInitialSize = pnlTagList.Size; // Init GUI operational mode to idle (disconnected) SetMode(ReaderManager.GuiModes.Idle); }
private void LoadSolarSystem() { _sun = new Sun(DVector2.Zero, DVector2.Zero); var mercury = new Mercury(); var venus = new Venus(); var earth = new Earth(); var moon = new Moon(earth.Position, earth.Velocity); var mars = new Mars(); var jupiter = new Jupiter(); var europa = new Europa(jupiter.Position + new DVector2(6.64862e8, 0), jupiter.Velocity + new DVector2(0, -13740)); var saturn = new Saturn(); _massiveBodies = new List <IMassiveBody> { _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn }; //_spaceCrafts = SpacecraftFactory.BuildFalconHeavy(earth, ProfileDirectory); //_spaceCrafts = SpacecraftFactory.BuildDragonV2Abort(earth, ProfileDirectory); _spaceCrafts = SpacecraftFactory.BuildDragonV2Entry(earth, ProfileDirectory); //_spaceCrafts = SpacecraftFactory.BuildF9(earth, ProfileDirectory); //_spaceCrafts = SpacecraftFactory.BuildF9Dragon(earth, ProfileDirectory); // Initialize the spacecraft controllers foreach (ISpaceCraft spaceCraft in _spaceCrafts) { spaceCraft.InitializeController(ProfileDirectory, _eventManager); } // Start at nearly -Math.Pi / 2 _strongback = new Strongback(-1.5707947, _spaceCrafts[0].TotalHeight * 0.05, earth); // Start downrange at ~300km var asds = new ASDS(-1.62026, 20, earth); _gravitationalBodies = new List <IGravitationalBody> { _sun, mercury, venus, earth }; foreach (ISpaceCraft spaceCraft in _spaceCrafts) { _gravitationalBodies.Add(spaceCraft); } _structures = new List <StructureBase> { _strongback, //asds }; _gravitationalBodies.Add(moon); _gravitationalBodies.Add(mars); _gravitationalBodies.Add(jupiter); _gravitationalBodies.Add(europa); _gravitationalBodies.Add(saturn); // Target the spacecraft _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault()); }
void Update() { Sun.Rotate(Vector3.up * Time.deltaTime * 5); Mercury.RotateAround(Sun.position, new Vector3(0.1f, 1, 0), 60 * Time.deltaTime); Mercury.Rotate(Vector3.up * 10000 / 58 * Time.deltaTime); Venus.RotateAround(Sun.position, new Vector3(0, 1, -0.1f), 55 * Time.deltaTime); Venus.Rotate(Vector3.up * 10000 / 243 * Time.deltaTime); Earth.RotateAround(Sun.position, Vector3.up, 50 * Time.deltaTime); Earth.Rotate(Vector3.up * 10000 * Time.deltaTime); Moon.RotateAround(Earth.position, Vector3.up, 5 * Time.deltaTime); Moon.Rotate(Vector3.up * 10000 / 27 * Time.deltaTime); Mars.RotateAround(Sun.position, new Vector3(0.2f, 1, 0), 45 * Time.deltaTime); Mars.Rotate(Vector3.up * 10000 * Time.deltaTime); Jupiter.RotateAround(Sun.position, new Vector3(-0.1f, 2, 0), 38 * Time.deltaTime); Jupiter.Rotate(Vector3.up * 10000 / 0.3f * Time.deltaTime); Saturn.RotateAround(Sun.position, new Vector3(0, 1, 0.2f), 36 * Time.deltaTime); Saturn.Rotate(Vector3.up * 10000 / 0.4f * Time.deltaTime); Uranus.RotateAround(Sun.position, new Vector3(0, 2, 0.1f), 35 * Time.deltaTime); Uranus.Rotate(Vector3.up * 10000 / 0.6f * Time.deltaTime); Neptune.RotateAround(Sun.position, new Vector3(-0.1f, 1, -0.1f), 33 * Time.deltaTime); Neptune.Rotate(Vector3.up * 10000 / 0.7f * Time.deltaTime); }
public IActionResult Index() { DateTime birthday = new DateTime(1991, 6, 5, 8, 26, 00); Equator equator = Sun.EquatorialCoordinate(birthday); Ecliptic mooquator = Moon.EclipticalCoordinate(birthday); Ecliptic merquator = Mercury.EclipticalCoordinate(birthday); Ecliptic vequator = Venus.EclipticalCoordinate(birthday); Ecliptic mequator = Mars.EclipticalCoordinate(birthday); Ecliptic jequator = Jupiter.EclipticalCoordinate(birthday); Ecliptic sequator = Saturn.EclipticalCoordinate(birthday); Ecliptic urquator = Uranus.EclipticalCoordinate(birthday); Ecliptic nequator = Neptune.EclipticalCoordinate(DateTime.Now); Ecliptic ecliptic = CoordinateSystem.Equatorial2Ecliptic(equator); Debug.WriteLine(DateTime.Now); Debug.WriteLine("SUN" + ecliptic.Longitude); Debug.WriteLine("Moon" + mooquator.Longitude); Debug.WriteLine("MERC: " + merquator.Longitude); Debug.WriteLine("VENUS" + vequator.Longitude); Debug.WriteLine("Mars" + mequator.Longitude); Debug.WriteLine("Jup: " + jequator.Longitude); Debug.WriteLine("Saturn: " + sequator.Longitude); Debug.WriteLine("Urnuas: " + urquator.Longitude); Debug.WriteLine("Neptune: " + nequator.Longitude); return(View()); }
private void image5_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (i == 1) { Saturn.Begin(); i = 2; PresentTheAttributes(5); } }
private void LoadSolarSystem() { _sun = new Sun(DVector2.Zero, DVector2.Zero); var mercury = new Mercury(); var venus = new Venus(); var earth = new Earth(); _strongback = new Strongback(new DVector2(10, -earth.SurfaceRadius + 38), earth); var moon = new Moon(earth.Position, earth.Velocity); var mars = new Mars(); var jupiter = new Jupiter(); var europa = new Europa(jupiter.Position + new DVector2(6.64862e8, 0), jupiter.Velocity + new DVector2(0, -13740)); var saturn = new Saturn(); _massiveBodies = new List <IMassiveBody> { _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn }; _structures = new List <StructureBase> { _strongback }; _spaceCrafts = SpacecraftFactory.BuildFalconHeavy(earth, ProfileDirectory); _gravitationalBodies = new List <IGravitationalBody> { _sun, mercury, venus, earth }; foreach (ISpaceCraft spaceCraft in _spaceCrafts) { _gravitationalBodies.Add(spaceCraft); } _gravitationalBodies.Add(moon); _gravitationalBodies.Add(mars); _gravitationalBodies.Add(jupiter); _gravitationalBodies.Add(europa); _gravitationalBodies.Add(saturn); // Target the spacecraft _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault()); }
void Start() { Mercury.AddComponent <Planet>().speed = 47.89f; Venus.AddComponent <Planet>().speed = 35.03f; Earth.AddComponent <Planet>().speed = 30f; Mars.AddComponent <Planet>().speed = 24.13f; Jupiter.AddComponent <Planet>().speed = 13.06f; Saturn.AddComponent <Planet>().speed = 9.64f; Uranus.AddComponent <Planet>().speed = 6.81f; Neptune.AddComponent <Planet>().speed = 5.43f; Moon.AddComponent <Moon>().speed = 300f; gs = new GUIStyle { fontSize = 35 }; gs.normal.textColor = new Color(1, 0, 0); gs.fontStyle = FontStyle.Italic; }
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding) { Encoding = encoding ?? Encoding.ASCII; information = ""; StringBuilder isoMetadata = new StringBuilder(); byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" string bootSpec = ""; PrimaryVolumeDescriptor?pvd = null; PrimaryVolumeDescriptor?jolietvd = null; BootRecord?bvd = null; HighSierraPrimaryVolumeDescriptor?hsvd = null; FileStructureVolumeDescriptor? fsvd = null; ElToritoBootRecord?torito = null; // ISO9660 is designed for 2048 bytes/sector devices if (imagePlugin.Info.SectorSize < 2048) { return; } // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. if (partition.End < 16) { return; } ulong counter = 0; byte[] vdSector = imagePlugin.ReadSector(16 + counter + partition.Start); int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); bool highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; int hsOff = 0; if (highSierra) { hsOff = 8; } bool cdi = false; while (true) { DicConsole.DebugWriteLine("ISO9660 plugin", "Processing VD loop no. {0}", counter); // Seek to Volume Descriptor DicConsole.DebugWriteLine("ISO9660 plugin", "Reading sector {0}", 16 + counter + partition.Start); byte[] vdSectorTmp = imagePlugin.ReadSector(16 + counter + partition.Start); vdSector = new byte[vdSectorTmp.Length - xaOff]; Array.Copy(vdSectorTmp, xaOff, vdSector, 0, vdSector.Length); byte vdType = vdSector[0 + hsOff]; // Volume Descriptor Type, should be 1 or 2. DicConsole.DebugWriteLine("ISO9660 plugin", "VDType = {0}", vdType); if (vdType == 255) // Supposedly we are in the PVD. { if (counter == 0) { return; } break; } Array.Copy(vdSector, 0x001, vdMagic, 0, 5); Array.Copy(vdSector, 0x009, hsMagic, 0, 5); if (Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && Encoding.GetString(vdMagic) != CDI_MAGIC ) // Recognized, it is an ISO9660, now check for rest of data. { if (counter == 0) { return; } break; } cdi |= Encoding.GetString(vdMagic) == CDI_MAGIC; switch (vdType) { case 0: { IntPtr ptr = Marshal.AllocHGlobal(2048); Marshal.Copy(vdSector, hsOff, ptr, 2048 - hsOff); bvd = (BootRecord)Marshal.PtrToStructure(ptr, typeof(BootRecord)); Marshal.FreeHGlobal(ptr); bootSpec = "Unknown"; if (Encoding.GetString(bvd.Value.system_id).Substring(0, 23) == "EL TORITO SPECIFICATION") { bootSpec = "El Torito"; ptr = Marshal.AllocHGlobal(2048); Marshal.Copy(vdSector, hsOff, ptr, 2048 - hsOff); torito = (ElToritoBootRecord)Marshal.PtrToStructure(ptr, typeof(ElToritoBootRecord)); Marshal.FreeHGlobal(ptr); } break; } case 1: { if (highSierra) { IntPtr ptr = Marshal.AllocHGlobal(2048); Marshal.Copy(vdSector, 0, ptr, 2048); hsvd = (HighSierraPrimaryVolumeDescriptor) Marshal.PtrToStructure(ptr, typeof(HighSierraPrimaryVolumeDescriptor)); Marshal.FreeHGlobal(ptr); } else if (cdi) { fsvd = BigEndianMarshal.ByteArrayToStructureBigEndian <FileStructureVolumeDescriptor>(vdSector); } else { IntPtr ptr = Marshal.AllocHGlobal(2048); Marshal.Copy(vdSector, 0, ptr, 2048); pvd = (PrimaryVolumeDescriptor)Marshal.PtrToStructure(ptr, typeof(PrimaryVolumeDescriptor)); Marshal.FreeHGlobal(ptr); } break; } case 2: { IntPtr ptr = Marshal.AllocHGlobal(2048); Marshal.Copy(vdSector, 0, ptr, 2048); PrimaryVolumeDescriptor svd = (PrimaryVolumeDescriptor)Marshal.PtrToStructure(ptr, typeof(PrimaryVolumeDescriptor)); Marshal.FreeHGlobal(ptr); // Check if this is Joliet if (svd.escape_sequences[0] == '%' && svd.escape_sequences[1] == '/') { if (svd.escape_sequences[2] == '@' || svd.escape_sequences[2] == 'C' || svd.escape_sequences[2] == 'E') { jolietvd = svd; } else { DicConsole.WriteLine("ISO9660 plugin", "Found unknown supplementary volume descriptor"); } } break; } } counter++; } DecodedVolumeDescriptor decodedVd; DecodedVolumeDescriptor decodedJolietVd = new DecodedVolumeDescriptor(); XmlFsType = new FileSystemType(); if (pvd == null && hsvd == null && fsvd == null) { information = "ERROR: Could not find primary volume descriptor"; return; } if (highSierra) { decodedVd = DecodeVolumeDescriptor(hsvd.Value); } else if (cdi) { decodedVd = DecodeVolumeDescriptor(fsvd.Value); } else { decodedVd = DecodeVolumeDescriptor(pvd.Value); } if (jolietvd != null) { decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); } uint rootLocation = 0; uint rootSize = 0; // No need to read root on CD-i, as extensions are not supported... if (!cdi) { rootLocation = highSierra ? hsvd.Value.root_directory_record.extent : pvd.Value.root_directory_record.extent; if (highSierra) { rootSize = hsvd.Value.root_directory_record.size / hsvd.Value.logical_block_size; if (hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) { rootSize++; } } else { rootSize = pvd.Value.root_directory_record.size / pvd.Value.logical_block_size; if (pvd.Value.root_directory_record.size % pvd.Value.logical_block_size > 0) { rootSize++; } } } byte[] rootDir = new byte[0]; int rootOff = 0; bool xaExtensions = false; bool apple = false; bool susp = false; bool rrip = false; bool ziso = false; bool amiga = false; bool aaip = false; List <ContinuationArea> contareas = new List <ContinuationArea>(); List <byte[]> refareas = new List <byte[]>(); StringBuilder suspInformation = new StringBuilder(); if (rootLocation + rootSize < imagePlugin.Info.Sectors) { rootDir = imagePlugin.ReadSectors(rootLocation, rootSize); } BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; // Walk thru root directory to see system area extensions in use while (rootOff + Marshal.SizeOf(typeof(DirectoryRecord)) < rootDir.Length && !cdi) { DirectoryRecord record = new DirectoryRecord(); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(record)); Marshal.Copy(rootDir, rootOff, ptr, Marshal.SizeOf(record)); record = (DirectoryRecord)Marshal.PtrToStructure(ptr, typeof(DirectoryRecord)); Marshal.FreeHGlobal(ptr); int saOff = Marshal.SizeOf(record) + record.name_len; saOff += saOff % 2; int saLen = record.length - saOff; if (saLen > 0 && rootOff + saOff + saLen <= rootDir.Length) { byte[] sa = new byte[saLen]; Array.Copy(rootDir, rootOff + saOff, sa, 0, saLen); saOff = 0; while (saOff < saLen) { bool noneFound = true; if (Marshal.SizeOf(typeof(CdromXa)) + saOff <= saLen) { CdromXa xa = BigEndianMarshal.ByteArrayToStructureBigEndian <CdromXa>(sa); if (xa.signature == XA_MAGIC) { xaExtensions = true; saOff += Marshal.SizeOf(typeof(CdromXa)); noneFound = false; } } if (saOff + 2 >= saLen) { break; } ushort nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff); switch (nextSignature) { // Easy, contains size field case APPLE_MAGIC: apple = true; saOff += sa[saOff + 2]; noneFound = false; break; // Not easy, contains size field case APPLE_MAGIC_OLD: apple = true; AppleOldId appleId = (AppleOldId)sa[saOff + 2]; noneFound = false; switch (appleId) { case AppleOldId.ProDOS: saOff += Marshal.SizeOf(typeof(AppleProDOSOldSystemUse)); break; case AppleOldId.TypeCreator: case AppleOldId.TypeCreatorBundle: saOff += Marshal.SizeOf(typeof(AppleHFSTypeCreatorSystemUse)); break; case AppleOldId.TypeCreatorIcon: case AppleOldId.TypeCreatorIconBundle: saOff += Marshal.SizeOf(typeof(AppleHFSIconSystemUse)); break; case AppleOldId.HFS: saOff += Marshal.SizeOf(typeof(AppleHFSOldSystemUse)); break; } break; // IEEE-P1281 aka SUSP 1.12 case SUSP_INDICATOR: susp = true; saOff += sa[saOff + 2]; noneFound = false; while (saOff + 2 < saLen) { nextSignature = BigEndianBitConverter.ToUInt16(sa, saOff); switch (nextSignature) { case APPLE_MAGIC: if (sa[saOff + 3] == 1 && sa[saOff + 2] == 7) { apple = true; } else { apple |= sa[saOff + 3] != 1; } break; case SUSP_CONTINUATION when saOff + sa[saOff + 2] <= saLen: byte[] ce = new byte[sa[saOff + 2]]; Array.Copy(sa, saOff, ce, 0, ce.Length); ContinuationArea ca = BigEndianMarshal .ByteArrayToStructureBigEndian <ContinuationArea>(ce); contareas.Add(ca); break; case SUSP_REFERENCE when saOff + sa[saOff + 2] <= saLen: byte[] er = new byte[sa[saOff + 2]]; Array.Copy(sa, saOff, er, 0, er.Length); refareas.Add(er); break; } rrip |= nextSignature == RRIP_MAGIC || nextSignature == RRIP_POSIX_ATTRIBUTES || nextSignature == RRIP_POSIX_DEV_NO || nextSignature == RRIP_SYMLINK || nextSignature == RRIP_NAME || nextSignature == RRIP_CHILDLINK || nextSignature == RRIP_PARENTLINK || nextSignature == RRIP_RELOCATED_DIR || nextSignature == RRIP_TIMESTAMPS || nextSignature == RRIP_SPARSE; ziso |= nextSignature == ZISO_MAGIC; amiga |= nextSignature == AMIGA_MAGIC; aaip |= nextSignature == AAIP_MAGIC || nextSignature == AAIP_MAGIC_OLD && sa[saOff + 3] == 1 && sa[saOff + 2] >= 9; saOff += sa[saOff + 2]; if (nextSignature == SUSP_TERMINATOR) { break; } } break; } if (noneFound) { break; } } } rootOff += record.length; if (record.length == 0) { break; } } foreach (ContinuationArea ca in contareas) { uint caLen = (ca.ca_length_be + ca.offset_be) / (highSierra ? hsvd.Value.logical_block_size : pvd.Value.logical_block_size); if ((ca.ca_length_be + ca.offset_be) % (highSierra ? hsvd.Value.logical_block_size : pvd.Value.logical_block_size) > 0) { caLen++; } byte[] caSectors = imagePlugin.ReadSectors(ca.block_be, caLen); byte[] caData = new byte[ca.ca_length_be]; Array.Copy(caSectors, ca.offset_be, caData, 0, ca.ca_length_be); int caOff = 0; while (caOff < ca.ca_length_be) { ushort nextSignature = BigEndianBitConverter.ToUInt16(caData, caOff); switch (nextSignature) { // Apple never said to include its extensions inside a continuation area, but just in case case APPLE_MAGIC: if (caData[caOff + 3] == 1 && caData[caOff + 2] == 7) { apple = true; } else { apple |= caData[caOff + 3] != 1; } break; case SUSP_REFERENCE when caOff + caData[caOff + 2] <= ca.ca_length_be: byte[] er = new byte[caData[caOff + 2]]; Array.Copy(caData, caOff, er, 0, er.Length); refareas.Add(er); break; } rrip |= nextSignature == RRIP_MAGIC || nextSignature == RRIP_POSIX_ATTRIBUTES || nextSignature == RRIP_POSIX_DEV_NO || nextSignature == RRIP_SYMLINK || nextSignature == RRIP_NAME || nextSignature == RRIP_CHILDLINK || nextSignature == RRIP_PARENTLINK || nextSignature == RRIP_RELOCATED_DIR || nextSignature == RRIP_TIMESTAMPS || nextSignature == RRIP_SPARSE; ziso |= nextSignature == ZISO_MAGIC; amiga |= nextSignature == AMIGA_MAGIC; aaip |= nextSignature == AAIP_MAGIC || nextSignature == AAIP_MAGIC_OLD && caData[caOff + 3] == 1 && caData[caOff + 2] >= 9; caOff += caData[caOff + 2]; } } if (refareas.Count > 0) { suspInformation.AppendLine("----------------------------------------"); suspInformation.AppendLine("SYSTEM USE SHARING PROTOCOL INFORMATION:"); suspInformation.AppendLine("----------------------------------------"); counter = 1; foreach (byte[] erb in refareas) { ReferenceArea er = BigEndianMarshal.ByteArrayToStructureBigEndian <ReferenceArea>(erb); string extId = Encoding.GetString(erb, Marshal.SizeOf(er), er.id_len); string extDes = Encoding.GetString(erb, Marshal.SizeOf(er) + er.id_len, er.des_len); string extSrc = Encoding.GetString(erb, Marshal.SizeOf(er) + er.id_len + er.des_len, er.src_len); suspInformation.AppendFormat("Extension: {0}", counter).AppendLine(); suspInformation.AppendFormat("\tID: {0}, version {1}", extId, er.ext_ver).AppendLine(); suspInformation.AppendFormat("\tDescription: {0}", extDes).AppendLine(); suspInformation.AppendFormat("\tSource: {0}", extSrc).AppendLine(); counter++; } } byte[] ipbinSector = imagePlugin.ReadSector(0 + partition.Start); CD.IPBin? segaCd = CD.DecodeIPBin(ipbinSector); Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector); Dreamcast.IPBin?dreamcast = Dreamcast.DecodeIPBin(ipbinSector); string fsFormat; if (highSierra) { fsFormat = "High Sierra Format"; } else if (cdi) { fsFormat = "CD-i"; } else { fsFormat = "ISO9660"; } isoMetadata.AppendFormat("{0} file system", fsFormat).AppendLine(); if (xaExtensions) { isoMetadata.AppendLine("CD-ROM XA extensions present."); } if (amiga) { isoMetadata.AppendLine("Amiga extensions present."); } if (apple) { isoMetadata.AppendLine("Apple extensions present."); } if (jolietvd != null) { isoMetadata.AppendLine("Joliet extensions present."); } if (susp) { isoMetadata.AppendLine("System Use Sharing Protocol present."); } if (rrip) { isoMetadata.AppendLine("Rock Ridge Interchange Protocol present."); } if (aaip) { isoMetadata.AppendLine("Arbitrary Attribute Interchange Protocol present."); } if (ziso) { isoMetadata.AppendLine("zisofs compression present."); } if (bvd != null) { isoMetadata.AppendFormat("Disc bootable following {0} specifications.", bootSpec).AppendLine(); } if (segaCd != null) { isoMetadata.AppendLine("This is a SegaCD / MegaCD disc."); isoMetadata.AppendLine(CD.Prettify(segaCd)); } if (saturn != null) { isoMetadata.AppendLine("This is a Sega Saturn disc."); isoMetadata.AppendLine(Saturn.Prettify(saturn)); } if (dreamcast != null) { isoMetadata.AppendLine("This is a Sega Dreamcast disc."); isoMetadata.AppendLine(Dreamcast.Prettify(dreamcast)); } isoMetadata.AppendFormat("{0}------------------------------", cdi ? "---------------" : "").AppendLine(); isoMetadata.AppendFormat("{0}VOLUME DESCRIPTOR INFORMATION:", cdi ? "FILE STRUCTURE " : "").AppendLine(); isoMetadata.AppendFormat("{0}------------------------------", cdi ? "---------------" : "").AppendLine(); isoMetadata.AppendFormat("System identifier: {0}", decodedVd.SystemIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume identifier: {0}", decodedVd.VolumeIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume set identifier: {0}", decodedVd.VolumeSetIdentifier).AppendLine(); isoMetadata.AppendFormat("Publisher identifier: {0}", decodedVd.PublisherIdentifier).AppendLine(); isoMetadata.AppendFormat("Data preparer identifier: {0}", decodedVd.DataPreparerIdentifier).AppendLine(); isoMetadata.AppendFormat("Application identifier: {0}", decodedVd.ApplicationIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume creation date: {0}", decodedVd.CreationTime).AppendLine(); if (decodedVd.HasModificationTime) { isoMetadata.AppendFormat("Volume modification date: {0}", decodedVd.ModificationTime).AppendLine(); } else { isoMetadata.AppendFormat("Volume has not been modified.").AppendLine(); } if (decodedVd.HasExpirationTime) { isoMetadata.AppendFormat("Volume expiration date: {0}", decodedVd.ExpirationTime).AppendLine(); } else { isoMetadata.AppendFormat("Volume does not expire.").AppendLine(); } if (decodedVd.HasEffectiveTime) { isoMetadata.AppendFormat("Volume effective date: {0}", decodedVd.EffectiveTime).AppendLine(); } else { isoMetadata.AppendFormat("Volume has always been effective.").AppendLine(); } isoMetadata.AppendFormat("Volume has {0} blocks of {1} bytes each", decodedVd.Blocks, decodedVd.BlockSize) .AppendLine(); if (jolietvd != null) { isoMetadata.AppendLine("-------------------------------------"); isoMetadata.AppendLine("JOLIET VOLUME DESCRIPTOR INFORMATION:"); isoMetadata.AppendLine("-------------------------------------"); isoMetadata.AppendFormat("System identifier: {0}", decodedJolietVd.SystemIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume identifier: {0}", decodedJolietVd.VolumeIdentifier).AppendLine(); isoMetadata.AppendFormat("Volume set identifier: {0}", decodedJolietVd.VolumeSetIdentifier) .AppendLine(); isoMetadata.AppendFormat("Publisher identifier: {0}", decodedJolietVd.PublisherIdentifier).AppendLine(); isoMetadata.AppendFormat("Data preparer identifier: {0}", decodedJolietVd.DataPreparerIdentifier) .AppendLine(); isoMetadata.AppendFormat("Application identifier: {0}", decodedJolietVd.ApplicationIdentifier) .AppendLine(); isoMetadata.AppendFormat("Volume creation date: {0}", decodedJolietVd.CreationTime).AppendLine(); if (decodedJolietVd.HasModificationTime) { isoMetadata.AppendFormat("Volume modification date: {0}", decodedJolietVd.ModificationTime) .AppendLine(); } else { isoMetadata.AppendFormat("Volume has not been modified.").AppendLine(); } if (decodedJolietVd.HasExpirationTime) { isoMetadata.AppendFormat("Volume expiration date: {0}", decodedJolietVd.ExpirationTime) .AppendLine(); } else { isoMetadata.AppendFormat("Volume does not expire.").AppendLine(); } if (decodedJolietVd.HasEffectiveTime) { isoMetadata.AppendFormat("Volume effective date: {0}", decodedJolietVd.EffectiveTime).AppendLine(); } else { isoMetadata.AppendFormat("Volume has always been effective.").AppendLine(); } } if (torito != null) { vdSector = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start); int toritoOff = 0; if (vdSector[toritoOff] != 1) { goto exit_torito; } IntPtr ptr = Marshal.AllocHGlobal(EL_TORITO_ENTRY_SIZE); Marshal.Copy(vdSector, toritoOff, ptr, EL_TORITO_ENTRY_SIZE); ElToritoValidationEntry valentry = (ElToritoValidationEntry)Marshal.PtrToStructure(ptr, typeof(ElToritoValidationEntry)); Marshal.FreeHGlobal(ptr); if (valentry.signature != EL_TORITO_MAGIC) { goto exit_torito; } toritoOff += EL_TORITO_ENTRY_SIZE; ptr = Marshal.AllocHGlobal(EL_TORITO_ENTRY_SIZE); Marshal.Copy(vdSector, toritoOff, ptr, EL_TORITO_ENTRY_SIZE); ElToritoInitialEntry initialEntry = (ElToritoInitialEntry)Marshal.PtrToStructure(ptr, typeof(ElToritoInitialEntry)); Marshal.FreeHGlobal(ptr); initialEntry.boot_type = (ElToritoEmulation)((byte)initialEntry.boot_type & 0xF); DicConsole.DebugWriteLine("DEBUG (ISO9660 plugin)", "initialEntry.load_rba = {0}", initialEntry.load_rba); DicConsole.DebugWriteLine("DEBUG (ISO9660 plugin)", "initialEntry.sector_count = {0}", initialEntry.sector_count); byte[] bootImage = initialEntry.load_rba + partition.Start + initialEntry.sector_count - 1 <= partition.End ? imagePlugin.ReadSectors(initialEntry.load_rba + partition.Start, initialEntry.sector_count) : null; isoMetadata.AppendLine("----------------------"); isoMetadata.AppendLine("EL TORITO INFORMATION:"); isoMetadata.AppendLine("----------------------"); isoMetadata.AppendLine("Initial entry:"); isoMetadata.AppendFormat("\tDeveloper ID: {0}", Encoding.GetString(valentry.developer_id)).AppendLine(); if (initialEntry.bootable == ElToritoIndicator.Bootable) { isoMetadata.AppendFormat("\tBootable on {0}", valentry.platform_id).AppendLine(); isoMetadata.AppendFormat("\tBootable image starts at sector {0} and runs for {1} sectors", initialEntry.load_rba, initialEntry.sector_count).AppendLine(); if (valentry.platform_id == ElToritoPlatform.x86) { isoMetadata.AppendFormat("\tBootable image will be loaded at segment {0:X4}h", initialEntry.load_seg == 0 ? 0x7C0 : initialEntry.load_seg) .AppendLine(); } else { isoMetadata.AppendFormat("\tBootable image will be loaded at 0x{0:X8}", (uint)initialEntry.load_seg * 10).AppendLine(); } switch (initialEntry.boot_type) { case ElToritoEmulation.None: isoMetadata.AppendLine("\tImage uses no emulation"); break; case ElToritoEmulation.Md2hd: isoMetadata.AppendLine("\tImage emulates a 5.25\" high-density (MD2HD, 1.2Mb) floppy"); break; case ElToritoEmulation.Mf2hd: isoMetadata.AppendLine("\tImage emulates a 3.5\" high-density (MF2HD, 1.44Mb) floppy"); break; case ElToritoEmulation.Mf2ed: isoMetadata.AppendLine("\tImage emulates a 3.5\" extra-density (MF2ED, 2.88Mb) floppy"); break; default: isoMetadata.AppendFormat("\tImage uses unknown emulation type {0}", (byte)initialEntry.boot_type).AppendLine(); break; } isoMetadata.AppendFormat("\tSystem type: 0x{0:X2}", initialEntry.system_type).AppendLine(); if (bootImage != null) { isoMetadata.AppendFormat("\tBootable image's SHA1: {0}", Sha1Context.Data(bootImage, out _)) .AppendLine(); } } else { isoMetadata.AppendLine("\tNot bootable"); } toritoOff += EL_TORITO_ENTRY_SIZE; const int SECTION_COUNTER = 2; while (toritoOff < vdSector.Length && (vdSector[toritoOff] == (byte)ElToritoIndicator.Header || vdSector[toritoOff] == (byte)ElToritoIndicator.LastHeader)) { ptr = Marshal.AllocHGlobal(EL_TORITO_ENTRY_SIZE); Marshal.Copy(vdSector, toritoOff, ptr, EL_TORITO_ENTRY_SIZE); ElToritoSectionHeaderEntry sectionHeader = (ElToritoSectionHeaderEntry)Marshal.PtrToStructure(ptr, typeof(ElToritoSectionHeaderEntry)); Marshal.FreeHGlobal(ptr); toritoOff += EL_TORITO_ENTRY_SIZE; isoMetadata.AppendFormat("Boot section {0}:", SECTION_COUNTER); isoMetadata.AppendFormat("\tSection ID: {0}", Encoding.GetString(sectionHeader.identifier)) .AppendLine(); for (int entryCounter = 1; entryCounter <= sectionHeader.entries && toritoOff < vdSector.Length; entryCounter++) { ptr = Marshal.AllocHGlobal(EL_TORITO_ENTRY_SIZE); Marshal.Copy(vdSector, toritoOff, ptr, EL_TORITO_ENTRY_SIZE); ElToritoSectionEntry sectionEntry = (ElToritoSectionEntry)Marshal.PtrToStructure(ptr, typeof(ElToritoSectionEntry)); Marshal.FreeHGlobal(ptr); toritoOff += EL_TORITO_ENTRY_SIZE; isoMetadata.AppendFormat("\tEntry {0}:", entryCounter); if (sectionEntry.bootable == ElToritoIndicator.Bootable) { bootImage = sectionEntry.load_rba + partition.Start + sectionEntry.sector_count - 1 <= partition.End ? imagePlugin.ReadSectors(sectionEntry.load_rba + partition.Start, sectionEntry.sector_count) : null; isoMetadata.AppendFormat("\t\tBootable on {0}", sectionHeader.platform_id).AppendLine(); isoMetadata.AppendFormat("\t\tBootable image starts at sector {0} and runs for {1} sectors", sectionEntry.load_rba, sectionEntry.sector_count).AppendLine(); if (valentry.platform_id == ElToritoPlatform.x86) { isoMetadata.AppendFormat("\t\tBootable image will be loaded at segment {0:X4}h", sectionEntry.load_seg == 0 ? 0x7C0 : sectionEntry.load_seg) .AppendLine(); } else { isoMetadata.AppendFormat("\t\tBootable image will be loaded at 0x{0:X8}", (uint)sectionEntry.load_seg * 10).AppendLine(); } switch ((ElToritoEmulation)((byte)sectionEntry.boot_type & 0xF)) { case ElToritoEmulation.None: isoMetadata.AppendLine("\t\tImage uses no emulation"); break; case ElToritoEmulation.Md2hd: isoMetadata .AppendLine("\t\tImage emulates a 5.25\" high-density (MD2HD, 1.2Mb) floppy"); break; case ElToritoEmulation.Mf2hd: isoMetadata .AppendLine("\t\tImage emulates a 3.5\" high-density (MF2HD, 1.44Mb) floppy"); break; case ElToritoEmulation.Mf2ed: isoMetadata .AppendLine("\t\tImage emulates a 3.5\" extra-density (MF2ED, 2.88Mb) floppy"); break; default: isoMetadata.AppendFormat("\t\tImage uses unknown emulation type {0}", (byte)initialEntry.boot_type).AppendLine(); break; } isoMetadata.AppendFormat("\t\tSelection criteria type: {0}", sectionEntry.selection_criteria_type).AppendLine(); isoMetadata.AppendFormat("\t\tSystem type: 0x{0:X2}", sectionEntry.system_type) .AppendLine(); if (bootImage != null) { isoMetadata.AppendFormat("\t\tBootable image's SHA1: {0}", Sha1Context.Data(bootImage, out _)).AppendLine(); } } else { isoMetadata.AppendLine("\t\tNot bootable"); } ElToritoFlags flags = (ElToritoFlags)((byte)sectionEntry.boot_type & 0xF0); if (flags.HasFlag(ElToritoFlags.ATAPI)) { isoMetadata.AppendLine("\t\tImage contains ATAPI drivers"); } if (flags.HasFlag(ElToritoFlags.SCSI)) { isoMetadata.AppendLine("\t\tImage contains SCSI drivers"); } if (!flags.HasFlag(ElToritoFlags.Continued)) { continue; } while (toritoOff < vdSector.Length) { ptr = Marshal.AllocHGlobal(EL_TORITO_ENTRY_SIZE); Marshal.Copy(vdSector, toritoOff, ptr, EL_TORITO_ENTRY_SIZE); ElToritoSectionEntryExtension sectionExtension = (ElToritoSectionEntryExtension) Marshal.PtrToStructure(ptr, typeof(ElToritoSectionEntryExtension)); Marshal.FreeHGlobal(ptr); toritoOff += EL_TORITO_ENTRY_SIZE; if (!sectionExtension.extension_flags.HasFlag(ElToritoFlags.Continued)) { break; } } } if (sectionHeader.header_id == ElToritoIndicator.LastHeader) { break; } } } exit_torito: if (refareas.Count > 0) { isoMetadata.Append(suspInformation); } XmlFsType.Type = fsFormat; if (jolietvd != null) { XmlFsType.VolumeName = decodedJolietVd.VolumeIdentifier; if (decodedJolietVd.SystemIdentifier == null || decodedVd.SystemIdentifier.Length > decodedJolietVd.SystemIdentifier.Length) { XmlFsType.SystemIdentifier = decodedVd.SystemIdentifier; } else { XmlFsType.SystemIdentifier = decodedJolietVd.SystemIdentifier; } if (decodedJolietVd.VolumeSetIdentifier == null || decodedVd.VolumeSetIdentifier.Length > decodedJolietVd.VolumeSetIdentifier.Length) { XmlFsType.VolumeSetIdentifier = decodedVd.VolumeSetIdentifier; } else { XmlFsType.VolumeSetIdentifier = decodedJolietVd.VolumeSetIdentifier; } if (decodedJolietVd.PublisherIdentifier == null || decodedVd.PublisherIdentifier.Length > decodedJolietVd.PublisherIdentifier.Length) { XmlFsType.PublisherIdentifier = decodedVd.PublisherIdentifier; } else { XmlFsType.PublisherIdentifier = decodedJolietVd.PublisherIdentifier; } if (decodedJolietVd.DataPreparerIdentifier == null || decodedVd.DataPreparerIdentifier.Length > decodedJolietVd.DataPreparerIdentifier.Length) { XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier; } else { XmlFsType.DataPreparerIdentifier = decodedJolietVd.SystemIdentifier; } if (decodedJolietVd.ApplicationIdentifier == null || decodedVd.ApplicationIdentifier.Length > decodedJolietVd.ApplicationIdentifier.Length) { XmlFsType.ApplicationIdentifier = decodedVd.ApplicationIdentifier; } else { XmlFsType.ApplicationIdentifier = decodedJolietVd.SystemIdentifier; } XmlFsType.CreationDate = decodedJolietVd.CreationTime; XmlFsType.CreationDateSpecified = true; if (decodedJolietVd.HasModificationTime) { XmlFsType.ModificationDate = decodedJolietVd.ModificationTime; XmlFsType.ModificationDateSpecified = true; } if (decodedJolietVd.HasExpirationTime) { XmlFsType.ExpirationDate = decodedJolietVd.ExpirationTime; XmlFsType.ExpirationDateSpecified = true; } if (decodedJolietVd.HasEffectiveTime) { XmlFsType.EffectiveDate = decodedJolietVd.EffectiveTime; XmlFsType.EffectiveDateSpecified = true; } } else { XmlFsType.SystemIdentifier = decodedVd.SystemIdentifier; XmlFsType.VolumeName = decodedVd.VolumeIdentifier; XmlFsType.VolumeSetIdentifier = decodedVd.VolumeSetIdentifier; XmlFsType.PublisherIdentifier = decodedVd.PublisherIdentifier; XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier; XmlFsType.ApplicationIdentifier = decodedVd.ApplicationIdentifier; XmlFsType.CreationDate = decodedVd.CreationTime; XmlFsType.CreationDateSpecified = true; if (decodedVd.HasModificationTime) { XmlFsType.ModificationDate = decodedVd.ModificationTime; XmlFsType.ModificationDateSpecified = true; } if (decodedVd.HasExpirationTime) { XmlFsType.ExpirationDate = decodedVd.ExpirationTime; XmlFsType.ExpirationDateSpecified = true; } if (decodedVd.HasEffectiveTime) { XmlFsType.EffectiveDate = decodedVd.EffectiveTime; XmlFsType.EffectiveDateSpecified = true; } } XmlFsType.Bootable |= bvd != null || segaCd != null || saturn != null || dreamcast != null; XmlFsType.Clusters = decodedVd.Blocks; XmlFsType.ClusterSize = decodedVd.BlockSize; information = isoMetadata.ToString(); }
public UkladSloneczny(Saturn sat) { sat = sat; }
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary <string, string> options, string @namespace) { Encoding = encoding ?? Encoding.GetEncoding(1252); byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" if (options == null) { options = GetDefaultOptions(); } if (options.TryGetValue("debug", out string debugString)) { bool.TryParse(debugString, out debug); } if (options.TryGetValue("use_path_table", out string usePathTableString)) { bool.TryParse(usePathTableString, out usePathTable); } if (options.TryGetValue("use_trans_tbl", out string useTransTblString)) { bool.TryParse(useTransTblString, out useTransTbl); } if (options.TryGetValue("use_evd", out string useEvdString)) { bool.TryParse(useEvdString, out useEvd); } // Default namespace if (@namespace is null) { @namespace = "joliet"; } switch (@namespace.ToLowerInvariant()) { case "normal": this.@namespace = Namespace.Normal; break; case "vms": this.@namespace = Namespace.Vms; break; case "joliet": this.@namespace = Namespace.Joliet; break; case "rrip": this.@namespace = Namespace.Rrip; break; case "romeo": this.@namespace = Namespace.Romeo; break; default: return(Errno.InvalidArgument); } PrimaryVolumeDescriptor?pvd = null; PrimaryVolumeDescriptor?jolietvd = null; BootRecord?bvd = null; HighSierraPrimaryVolumeDescriptor?hsvd = null; FileStructureVolumeDescriptor? fsvd = null; // ISO9660 is designed for 2048 bytes/sector devices if (imagePlugin.Info.SectorSize < 2048) { return(Errno.InvalidArgument); } // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. if (partition.End < 16) { return(Errno.InvalidArgument); } ulong counter = 0; byte[] vdSector = imagePlugin.ReadSector(16 + counter + partition.Start); int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; int hsOff = 0; if (highSierra) { hsOff = 8; } cdi = false; List <ulong> bvdSectors = new List <ulong>(); List <ulong> pvdSectors = new List <ulong>(); List <ulong> svdSectors = new List <ulong>(); List <ulong> evdSectors = new List <ulong>(); List <ulong> vpdSectors = new List <ulong>(); while (true) { DicConsole.DebugWriteLine("ISO9660 plugin", "Processing VD loop no. {0}", counter); // Seek to Volume Descriptor DicConsole.DebugWriteLine("ISO9660 plugin", "Reading sector {0}", 16 + counter + partition.Start); byte[] vdSectorTmp = imagePlugin.ReadSector(16 + counter + partition.Start); vdSector = new byte[vdSectorTmp.Length - xaOff]; Array.Copy(vdSectorTmp, xaOff, vdSector, 0, vdSector.Length); byte vdType = vdSector[0 + hsOff]; // Volume Descriptor Type, should be 1 or 2. DicConsole.DebugWriteLine("ISO9660 plugin", "VDType = {0}", vdType); if (vdType == 255) // Supposedly we are in the PVD. { if (counter == 0) { return(Errno.InvalidArgument); } break; } Array.Copy(vdSector, 0x001, vdMagic, 0, 5); Array.Copy(vdSector, 0x009, hsMagic, 0, 5); if (Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && Encoding.GetString(vdMagic) != CDI_MAGIC ) // Recognized, it is an ISO9660, now check for rest of data. { if (counter == 0) { return(Errno.InvalidArgument); } break; } cdi |= Encoding.GetString(vdMagic) == CDI_MAGIC; switch (vdType) { case 0: { if (debug) { bvdSectors.Add(16 + counter + partition.Start); } break; } case 1: { if (highSierra) { hsvd = Marshal .ByteArrayToStructureLittleEndian <HighSierraPrimaryVolumeDescriptor>(vdSector); } else if (cdi) { fsvd = Marshal.ByteArrayToStructureBigEndian <FileStructureVolumeDescriptor>(vdSector); } else { pvd = Marshal.ByteArrayToStructureLittleEndian <PrimaryVolumeDescriptor>(vdSector); } if (debug) { pvdSectors.Add(16 + counter + partition.Start); } break; } case 2: { PrimaryVolumeDescriptor svd = Marshal.ByteArrayToStructureLittleEndian <PrimaryVolumeDescriptor>(vdSector); // TODO: Other escape sequences // Check if this is Joliet if (svd.version == 1) { if (svd.escape_sequences[0] == '%' && svd.escape_sequences[1] == '/') { if (svd.escape_sequences[2] == '@' || svd.escape_sequences[2] == 'C' || svd.escape_sequences[2] == 'E') { jolietvd = svd; } else { DicConsole.WriteLine("ISO9660 plugin", "Found unknown supplementary volume descriptor"); } } if (debug) { svdSectors.Add(16 + counter + partition.Start); } } else { if (debug) { evdSectors.Add(16 + counter + partition.Start); } if (useEvd) { // Basically until escape sequences are implemented, let the user chose the encoding. // This is the same as user chosing Romeo namespace, but using the EVD instead of the PVD this.@namespace = Namespace.Romeo; pvd = svd; } } break; } case 3: { if (debug) { vpdSectors.Add(16 + counter + partition.Start); } break; } } counter++; } DecodedVolumeDescriptor decodedVd; DecodedVolumeDescriptor decodedJolietVd = new DecodedVolumeDescriptor(); XmlFsType = new FileSystemType(); if (pvd == null && hsvd == null && fsvd == null) { DicConsole.ErrorWriteLine("ERROR: Could not find primary volume descriptor"); return(Errno.InvalidArgument); } if (highSierra) { decodedVd = DecodeVolumeDescriptor(hsvd.Value); } else if (cdi) { decodedVd = DecodeVolumeDescriptor(fsvd.Value); } else { decodedVd = DecodeVolumeDescriptor(pvd.Value); } if (jolietvd != null) { decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); } if (this.@namespace != Namespace.Romeo) { Encoding = Encoding.ASCII; } string fsFormat; byte[] pathTableData; uint pathTableSizeInSectors; uint pathTableMsbLocation; uint pathTableLsbLocation = 0; // Initialize to 0 as ignored in CD-i image = imagePlugin; if (highSierra) { pathTableSizeInSectors = hsvd.Value.path_table_size / 2048; if (hsvd.Value.path_table_size % 2048 > 0) { pathTableSizeInSectors++; } pathTableData = ReadSectors(Swapping.Swap(hsvd.Value.mandatory_path_table_msb), pathTableSizeInSectors); fsFormat = "High Sierra Format"; pathTableMsbLocation = hsvd.Value.mandatory_path_table_msb; pathTableLsbLocation = hsvd.Value.mandatory_path_table_lsb; } else if (cdi) { pathTableSizeInSectors = fsvd.Value.path_table_size / 2048; if (fsvd.Value.path_table_size % 2048 > 0) { pathTableSizeInSectors++; } pathTableData = ReadSectors(fsvd.Value.path_table_addr, pathTableSizeInSectors); fsFormat = "CD-i"; pathTableMsbLocation = fsvd.Value.path_table_addr; // TODO: Until escape sequences are implemented this is the default CD-i encoding. Encoding = Encoding.GetEncoding("iso8859-1"); } else { pathTableSizeInSectors = pvd.Value.path_table_size / 2048; if (pvd.Value.path_table_size % 2048 > 0) { pathTableSizeInSectors++; } pathTableData = ReadSectors(Swapping.Swap(pvd.Value.type_m_path_table), pathTableSizeInSectors); fsFormat = "ISO9660"; pathTableMsbLocation = pvd.Value.type_m_path_table; pathTableLsbLocation = pvd.Value.type_l_path_table; } pathTable = highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData); // High Sierra and CD-i do not support Joliet or RRIP if ((highSierra || cdi) && this.@namespace != Namespace.Normal && this.@namespace != Namespace.Vms) { this.@namespace = Namespace.Normal; } if (jolietvd is null && this.@namespace == Namespace.Joliet) { this.@namespace = Namespace.Normal; } uint rootLocation; uint rootSize; byte rootXattrLength = 0; if (!cdi) { rootLocation = highSierra ? hsvd.Value.root_directory_record.extent : pvd.Value.root_directory_record.extent; rootXattrLength = highSierra ? hsvd.Value.root_directory_record.xattr_len : pvd.Value.root_directory_record.xattr_len; if (highSierra) { rootSize = hsvd.Value.root_directory_record.size / hsvd.Value.logical_block_size; if (hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) { rootSize++; } } else { rootSize = pvd.Value.root_directory_record.size / pvd.Value.logical_block_size; if (pvd.Value.root_directory_record.size % pvd.Value.logical_block_size > 0) { rootSize++; } } } else { rootLocation = pathTable[0].Extent; byte[] firstRootSector = ReadSectors(rootLocation, 1); CdiDirectoryRecord rootEntry = Marshal.ByteArrayToStructureBigEndian <CdiDirectoryRecord>(firstRootSector); rootSize = rootEntry.size / fsvd.Value.logical_block_size; if (rootEntry.size % fsvd.Value.logical_block_size > 0) { rootSize++; } usePathTable = usePathTable || pathTable.Length == 1; useTransTbl = false; } // In case the path table is incomplete if (usePathTable && pathTableData.Length == 1) { usePathTable = false; } if (rootLocation + rootSize >= imagePlugin.Info.Sectors) { return(Errno.InvalidArgument); } byte[] rootDir = ReadSectors(rootLocation, rootSize); byte[] ipbinSector = ReadSectors(partition.Start, 1); CD.IPBin? segaCd = CD.DecodeIPBin(ipbinSector); Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector); Dreamcast.IPBin?dreamcast = Dreamcast.DecodeIPBin(ipbinSector); if (this.@namespace == Namespace.Joliet || this.@namespace == Namespace.Rrip) { usePathTable = false; useTransTbl = false; } // Cannot traverse path table if we substitute the names for the ones in TRANS.TBL if (useTransTbl) { usePathTable = false; } if (this.@namespace != Namespace.Joliet) { rootDirectoryCache = cdi ? DecodeCdiDirectory(rootLocation, rootSize, rootXattrLength) : highSierra ? DecodeHighSierraDirectory(rootLocation, rootSize, rootXattrLength) : DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); } XmlFsType.Type = fsFormat; if (debug) { rootDirectoryCache.Add("$", new DecodedDirectoryEntry { Extents = new List <(uint extent, uint size)> { (rootLocation, (uint)rootDir.Length) }, Filename = "$", Size = (uint)rootDir.Length, Timestamp = decodedVd.CreationTime });
private void LoadSolarSystem() { _sun = new Sun(); var mercury = new Mercury(); var venus = new Venus(); var earth = new Earth(); var moon = new Moon(earth.Position, earth.Velocity); var mars = new Mars(); var jupiter = new Jupiter(); var europa = new Europa(jupiter.Position, jupiter.Velocity); var saturn = new Saturn(); _massiveBodies = new List <IMassiveBody> { _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn }; ResolveMassiveBodyParents(); // Simulate the planets out to May 2018 with a 6000 second time step OrbitHelper.SimulateToTime(_massiveBodies, new DateTime(2018, 5, 1), 300); _spaceCrafts = new List <ISpaceCraft>(); for (int i = 0; i < ProfileDirectories.Count; i++) { string profileDirectory = ProfileDirectories[i]; //List<ISpaceCraft> spaceCraft = SpacecraftFactory.BuildSpaceCraft(mars, profileDirectory, i * 30); List <ISpaceCraft> spaceCraft = SpacecraftFactory.BuildSpaceCraft(earth, profileDirectory, i * -60); _spaceCrafts.AddRange(spaceCraft); } // Initialize the spacecraft controllers foreach (ISpaceCraft spaceCraft in _spaceCrafts) { spaceCraft.InitializeController(_eventManager); } // Start at nearly -Math.Pi / 2 var itsMount = new ITSMount(-1.570795, -69, earth); var strongback = new Strongback(-1.5708048, -32, earth); // Start downrange at ~300km //var asds = new ASDS(-1.8303485, 26, earth); _gravitationalBodies = new List <IGravitationalBody> { _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn }; foreach (ISpaceCraft spaceCraft in _spaceCrafts) { _gravitationalBodies.Add(spaceCraft); } _structures = new List <StructureBase> { itsMount, strongback, //asds }; // Target the spacecraft _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault()); ResolveSpaceCraftParents(); }
public static void DetectDiscType(ref MediaType mediaType, int sessions, FullTOC.CDFullTOC?decodedToc, Device dev, out bool hiddenTrack, out bool hiddenData, int firstTrackLastSession) { uint startOfFirstDataTrack = uint.MaxValue; byte[] cmdBuf; bool sense; byte secondSessionFirstTrack = 0; byte[] sector0; byte[] sector1 = null; byte[] ps2BootSectors = null; byte[] playdia1 = null; byte[] playdia2 = null; byte[] firstDataSectorNotZero = null; byte[] secondDataSectorNotZero = null; byte[] firstTrackSecondSession = null; byte[] firstTrackSecondSessionAudio = null; byte[] videoNowColorFrame; hiddenTrack = false; hiddenData = false; if (decodedToc.HasValue) { if (decodedToc.Value.TrackDescriptors.Any(t => t.SessionNumber == 2)) { secondSessionFirstTrack = decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == 2).Min(t => t.POINT); } } if (mediaType == MediaType.CD || mediaType == MediaType.CDROMXA) { bool hasDataTrack = false; bool hasAudioTrack = false; bool allFirstSessionTracksAreAudio = true; bool hasVideoTrack = false; if (decodedToc.HasValue) { foreach (FullTOC.TrackDataDescriptor track in decodedToc.Value.TrackDescriptors) { if (track.TNO == 1 && ((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)) { allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; } if ((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental) { uint startAddress = (uint)(((track.PHOUR * 3600 * 75) + (track.PMIN * 60 * 75) + (track.PSEC * 75) + track.PFRAME) - 150); if (startAddress < startOfFirstDataTrack) { startOfFirstDataTrack = startAddress; } hasDataTrack = true; allFirstSessionTracksAreAudio &= track.POINT >= firstTrackLastSession; } else { hasAudioTrack = true; } hasVideoTrack |= track.ADR == 4; } } if (hasDataTrack && hasAudioTrack && allFirstSessionTracksAreAudio && sessions == 2) { mediaType = MediaType.CDPLUS; } if (!hasDataTrack && hasAudioTrack && sessions == 1) { mediaType = MediaType.CDDA; } if (hasDataTrack && !hasAudioTrack && sessions == 1) { mediaType = MediaType.CDROM; } if (hasVideoTrack && !hasDataTrack && sessions == 1) { mediaType = MediaType.CDV; } } if (secondSessionFirstTrack != 0 && decodedToc.HasValue && decodedToc.Value.TrackDescriptors.Any(t => t.POINT == secondSessionFirstTrack)) { FullTOC.TrackDataDescriptor secondSessionFirstTrackTrack = decodedToc.Value.TrackDescriptors.First(t => t.POINT == secondSessionFirstTrack); uint firstSectorSecondSessionFirstTrack = (uint)(((secondSessionFirstTrackTrack.PHOUR * 3600 * 75) + (secondSessionFirstTrackTrack.PMIN * 60 * 75) + (secondSessionFirstTrackTrack.PSEC * 75) + secondSessionFirstTrackTrack.PFRAME) - 150); sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstTrackSecondSession = cmdBuf; } else { sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack, 2352, 1, MmcSectorTypes.Cdda, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstTrackSecondSession = cmdBuf; } } sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack - 1, 2352, 3, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstTrackSecondSessionAudio = cmdBuf; } else { sense = dev.ReadCd(out cmdBuf, out _, firstSectorSecondSessionFirstTrack - 1, 2352, 3, MmcSectorTypes.Cdda, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstTrackSecondSessionAudio = cmdBuf; } } } videoNowColorFrame = new byte[9 * 2352]; for (int i = 0; i < 9; i++) { sense = dev.ReadCd(out cmdBuf, out _, (uint)i, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (sense || dev.Error) { sense = dev.ReadCd(out cmdBuf, out _, (uint)i, 2352, 1, MmcSectorTypes.Cdda, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (sense || !dev.Error) { videoNowColorFrame = null; break; } } Array.Copy(cmdBuf, 0, videoNowColorFrame, i * 2352, 2352); } if (decodedToc.HasValue) { FullTOC.TrackDataDescriptor firstTrack = decodedToc.Value.TrackDescriptors.FirstOrDefault(t => t.POINT == 1); if (firstTrack.POINT == 1) { uint firstTrackSector = (uint)(((firstTrack.PHOUR * 3600 * 75) + (firstTrack.PMIN * 60 * 75) + (firstTrack.PSEC * 75) + firstTrack.PFRAME) - 150); // Check for hidden data before start of track 1 if (firstTrackSector > 0) { sense = dev.ReadCd(out sector0, out _, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!dev.Error && !sense) { hiddenTrack = true; hiddenData = IsData(sector0); if (hiddenData) { sense = dev.ReadCd(out byte[] sector16, out _, 16, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (IsCdi(sector0, sector16)) { mediaType = MediaType.CDIREADY; } } } } } } sector0 = null; switch (mediaType) { case MediaType.CD: case MediaType.CDDA: case MediaType.CDPLUS: case MediaType.CDROM: case MediaType.CDROMXA: { sense = dev.ReadCd(out cmdBuf, out _, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = new byte[2048]; Array.Copy(cmdBuf, 16, sector0, 0, 2048); sense = dev.ReadCd(out cmdBuf, out _, 1, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = new byte[2048]; Array.Copy(cmdBuf, 16, sector1, 0, 2048); } sense = dev.ReadCd(out cmdBuf, out _, 4200, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { playdia1 = new byte[2048]; Array.Copy(cmdBuf, 24, playdia1, 0, 2048); } sense = dev.ReadCd(out cmdBuf, out _, 4201, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { playdia2 = new byte[2048]; Array.Copy(cmdBuf, 24, playdia2, 0, 2048); } if (startOfFirstDataTrack != uint.MaxValue) { sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstDataSectorNotZero = new byte[2048]; Array.Copy(cmdBuf, 16, firstDataSectorNotZero, 0, 2048); } sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { secondDataSectorNotZero = new byte[2048]; Array.Copy(cmdBuf, 16, secondDataSectorNotZero, 0, 2048); } } var ps2Ms = new MemoryStream(); for (uint p = 0; p < 12; p++) { sense = dev.ReadCd(out cmdBuf, out _, p, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (sense || dev.Error) { break; } ps2Ms.Write(cmdBuf, cmdBuf[0x0F] == 0x02 ? 24 : 16, 2048); } if (ps2Ms.Length == 0x6000) { ps2BootSectors = ps2Ms.ToArray(); } } else { sense = dev.ReadCd(out cmdBuf, out _, 0, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = new byte[2048]; Array.Copy(cmdBuf, 0, sector0, 0, 2048); sense = dev.ReadCd(out cmdBuf, out _, 1, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = new byte[2048]; Array.Copy(cmdBuf, 1, sector0, 0, 2048); } sense = dev.ReadCd(out cmdBuf, out _, 4200, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { playdia1 = new byte[2048]; Array.Copy(cmdBuf, 0, playdia1, 0, 2048); } sense = dev.ReadCd(out cmdBuf, out _, 4201, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { playdia2 = new byte[2048]; Array.Copy(cmdBuf, 0, playdia2, 0, 2048); } if (startOfFirstDataTrack != uint.MaxValue) { sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstDataSectorNotZero = new byte[2048]; Array.Copy(cmdBuf, 0, firstDataSectorNotZero, 0, 2048); } sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { secondDataSectorNotZero = new byte[2048]; Array.Copy(cmdBuf, 0, secondDataSectorNotZero, 0, 2048); } } var ps2Ms = new MemoryStream(); for (uint p = 0; p < 12; p++) { sense = dev.ReadCd(out cmdBuf, out _, p, 2324, 1, MmcSectorTypes.Mode2, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (sense || dev.Error) { break; } ps2Ms.Write(cmdBuf, 0, 2048); } if (ps2Ms.Length == 0x6000) { ps2BootSectors = ps2Ms.ToArray(); } } else { sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 1, MmcSectorTypes.Mode1, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = cmdBuf; sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 1, MmcSectorTypes.Mode1, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = cmdBuf; } sense = dev.ReadCd(out cmdBuf, out _, 0, 2048, 12, MmcSectorTypes.Mode1, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { ps2BootSectors = cmdBuf; } if (startOfFirstDataTrack != uint.MaxValue) { sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack, 2048, 1, MmcSectorTypes.Mode1, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { firstDataSectorNotZero = cmdBuf; } sense = dev.ReadCd(out cmdBuf, out _, startOfFirstDataTrack + 1, 2048, 1, MmcSectorTypes.Mode1, false, false, true, MmcHeaderCodes.None, true, true, MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out _); if (!sense && !dev.Error) { secondDataSectorNotZero = cmdBuf; } } } else { goto case MediaType.DVDROM; } } } break; } // TODO: Check for CD-i Ready case MediaType.CDI: break; case MediaType.DVDROM: case MediaType.HDDVDROM: case MediaType.BDROM: case MediaType.Unknown: sense = dev.Read16(out cmdBuf, out _, 0, false, true, false, 0, 2048, 0, 1, false, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = cmdBuf; sense = dev.Read16(out cmdBuf, out _, 0, false, true, false, 1, 2048, 0, 1, false, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = cmdBuf; } sense = dev.Read16(out cmdBuf, out _, 0, false, true, false, 0, 2048, 0, 12, false, dev.Timeout, out _); if (!sense && !dev.Error && cmdBuf.Length == 0x6000) { ps2BootSectors = cmdBuf; } } else { sense = dev.Read12(out cmdBuf, out _, 0, false, true, false, false, 0, 2048, 0, 1, false, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = cmdBuf; sense = dev.Read12(out cmdBuf, out _, 0, false, true, false, false, 1, 2048, 0, 1, false, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = cmdBuf; } sense = dev.Read12(out cmdBuf, out _, 0, false, true, false, false, 0, 2048, 0, 12, false, dev.Timeout, out _); if (!sense && !dev.Error && cmdBuf.Length == 0x6000) { ps2BootSectors = cmdBuf; } } else { sense = dev.Read10(out cmdBuf, out _, 0, false, true, false, false, 0, 2048, 0, 1, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = cmdBuf; sense = dev.Read10(out cmdBuf, out _, 0, false, true, false, false, 1, 2048, 0, 1, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = cmdBuf; } sense = dev.Read10(out cmdBuf, out _, 0, false, true, false, false, 0, 2048, 0, 12, dev.Timeout, out _); if (!sense && !dev.Error && cmdBuf.Length == 0x6000) { ps2BootSectors = cmdBuf; } } else { sense = dev.Read6(out cmdBuf, out _, 0, 2048, 1, dev.Timeout, out _); if (!sense && !dev.Error) { sector0 = cmdBuf; sense = dev.Read6(out cmdBuf, out _, 1, 2048, 1, dev.Timeout, out _); if (!sense && !dev.Error) { sector1 = cmdBuf; } sense = dev.Read6(out cmdBuf, out _, 0, 2048, 12, dev.Timeout, out _); if (!sense && !dev.Error && cmdBuf.Length == 0x6000) { ps2BootSectors = cmdBuf; } } } } } break; // Recordables will not be checked case MediaType.CDR: case MediaType.CDRW: case MediaType.CDMRW: case MediaType.DDCDR: case MediaType.DDCDRW: case MediaType.DVDR: case MediaType.DVDRW: case MediaType.DVDPR: case MediaType.DVDPRW: case MediaType.DVDPRWDL: case MediaType.DVDRDL: case MediaType.DVDPRDL: case MediaType.DVDRAM: case MediaType.DVDRWDL: case MediaType.DVDDownload: case MediaType.HDDVDRAM: case MediaType.HDDVDR: case MediaType.HDDVDRW: case MediaType.HDDVDRDL: case MediaType.HDDVDRWDL: case MediaType.BDR: case MediaType.BDRE: case MediaType.BDRXL: case MediaType.BDREXL: return; } if (sector0 == null) { return; } switch (mediaType) { case MediaType.CD: case MediaType.CDDA: case MediaType.CDPLUS: case MediaType.CDROM: case MediaType.CDROMXA: // TODO: CDTV requires reading the filesystem, searching for a file called "/CDTV.TM" // TODO: CD32 requires reading the filesystem, searching for a file called "/CD32.TM" // TODO: Neo-Geo CD requires reading the filesystem and checking that the file "/IPL.TXT" is correct // TODO: Pippin requires interpreting Apple Partition Map, reading HFS and checking for Pippin signatures { if (CD.DecodeIPBin(sector0).HasValue) { mediaType = MediaType.MEGACD; return; } if (Saturn.DecodeIPBin(sector0).HasValue) { mediaType = MediaType.SATURNCD; } // Are GDR detectable ??? if (Dreamcast.DecodeIPBin(sector0).HasValue) { mediaType = MediaType.GDROM; } if (ps2BootSectors != null && ps2BootSectors.Length == 0x6000) { // The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :) byte decryptByte = ps2BootSectors[0]; for (int i = 0; i < 0x6000; i++) { ps2BootSectors[i] ^= decryptByte; } string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _); DicConsole.DebugWriteLine("Media-info Command", "PlayStation 2 boot sectors SHA256: {0}", ps2BootSectorsHash); if (ps2BootSectorsHash == PS2_PAL_HASH || ps2BootSectorsHash == PS2_NTSC_HASH || ps2BootSectorsHash == PS2_JAPANESE_HASH) { mediaType = MediaType.PS2CD; } } if (sector0 != null) { byte[] syncBytes = new byte[7]; Array.Copy(sector0, 0, syncBytes, 0, 7); if (_operaId.SequenceEqual(syncBytes)) { mediaType = MediaType.ThreeDO; } if (_fmTownsBootId.SequenceEqual(syncBytes)) { mediaType = MediaType.FMTOWNS; } } if (playdia1 != null && playdia2 != null) { byte[] pd1 = new byte[_playdiaCopyright.Length]; byte[] pd2 = new byte[_playdiaCopyright.Length]; Array.Copy(playdia1, 38, pd1, 0, pd1.Length); Array.Copy(playdia2, 0, pd2, 0, pd1.Length); if (_playdiaCopyright.SequenceEqual(pd1) && _playdiaCopyright.SequenceEqual(pd2)) { mediaType = MediaType.Playdia; } } if (secondDataSectorNotZero != null) { byte[] pce = new byte[_pcEngineSignature.Length]; Array.Copy(secondDataSectorNotZero, 32, pce, 0, pce.Length); if (_pcEngineSignature.SequenceEqual(pce)) { mediaType = MediaType.SuperCDROM2; } } if (firstDataSectorNotZero != null) { byte[] pcfx = new byte[_pcFxSignature.Length]; Array.Copy(firstDataSectorNotZero, 0, pcfx, 0, pcfx.Length); if (_pcFxSignature.SequenceEqual(pcfx)) { mediaType = MediaType.PCFX; } } if (firstTrackSecondSessionAudio != null) { byte[] jaguar = new byte[_atariSignature.Length]; for (int i = 0; i + jaguar.Length <= firstTrackSecondSessionAudio.Length; i += 2) { Array.Copy(firstTrackSecondSessionAudio, i, jaguar, 0, jaguar.Length); if (!_atariSignature.SequenceEqual(jaguar)) { continue; } mediaType = MediaType.JaguarCD; break; } } if (firstTrackSecondSession != null) { if (firstTrackSecondSession.Length >= 2336) { byte[] milcd = new byte[2048]; Array.Copy(firstTrackSecondSession, 24, milcd, 0, 2048); if (Dreamcast.DecodeIPBin(milcd).HasValue) { mediaType = MediaType.MilCD; } } } // TODO: Detect black and white VideoNow // TODO: Detect VideoNow XP if (IsVideoNowColor(videoNowColorFrame)) { mediaType = MediaType.VideoNowColor; } break; } // TODO: Check for CD-i Ready case MediaType.CDI: break; case MediaType.DVDROM: case MediaType.HDDVDROM: case MediaType.BDROM: case MediaType.Unknown: // TODO: Nuon requires reading the filesystem, searching for a file called "/NUON/NUON.RUN" if (ps2BootSectors != null && ps2BootSectors.Length == 0x6000) { // The decryption key is applied as XOR. As first byte is originally always NULL, it gives us the key :) byte decryptByte = ps2BootSectors[0]; for (int i = 0; i < 0x6000; i++) { ps2BootSectors[i] ^= decryptByte; } string ps2BootSectorsHash = Sha256Context.Data(ps2BootSectors, out _); DicConsole.DebugWriteLine("Media-info Command", "PlayStation 2 boot sectors SHA256: {0}", ps2BootSectorsHash); if (ps2BootSectorsHash == PS2_PAL_HASH || ps2BootSectorsHash == PS2_NTSC_HASH || ps2BootSectorsHash == PS2_JAPANESE_HASH) { mediaType = MediaType.PS2DVD; } } if (sector1 != null) { byte[] tmp = new byte[_ps3Id.Length]; Array.Copy(sector1, 0, tmp, 0, tmp.Length); if (tmp.SequenceEqual(_ps3Id)) { switch (mediaType) { case MediaType.BDROM: mediaType = MediaType.PS3BD; break; case MediaType.DVDROM: mediaType = MediaType.PS3DVD; break; } } tmp = new byte[_ps4Id.Length]; Array.Copy(sector1, 512, tmp, 0, tmp.Length); if (tmp.SequenceEqual(_ps4Id) && mediaType == MediaType.BDROM) { mediaType = MediaType.PS4BD; } } // TODO: Identify discs that require reading tracks (PC-FX, PlayStation, Sega, etc) break; } }
private void LoadSolarSystem() { _sun = new Sun(); var mercury = new Mercury(); var venus = new Venus(); var earth = new Earth(); var moon = new Moon(earth.Position, earth.Velocity); var mars = new Mars(); var jupiter = new Jupiter(); var callisto = new Callisto(jupiter.Position, jupiter.Velocity); var europa = new Europa(jupiter.Position, jupiter.Velocity); var ganymede = new Ganymede(jupiter.Position, jupiter.Velocity); var io = new Io(jupiter.Position, jupiter.Velocity); var saturn = new Saturn(); _massiveBodies = new List <IMassiveBody> { _sun, mercury, venus, earth, moon, mars, jupiter, callisto, europa, ganymede, io, saturn }; ResolveMassiveBodyParents(); _gravitationalBodies = new List <IGravitationalBody> { _sun, mercury, venus, earth, moon, mars, jupiter, callisto, europa, ganymede, io, saturn }; _spaceCraftManager = new SpaceCraftManager(_gravitationalBodies); _structures = new List <StructureBase>(); MissionConfig primaryMission = MissionConfig.Load(ProfilePaths[0]); _originTime = primaryMission.GetLaunchDate(); UpdateLoadingPercentage(20); OrbitHelper.SimulateToTime(_massiveBodies, _originTime, 300, UpdateLoadingPercentage); UpdateLoadingPercentage(80); // Load missions for (int i = 0; i < ProfilePaths.Count; i++) { MissionConfig missionConfig = MissionConfig.Load(ProfilePaths[i]); if (missionConfig.ClockDelay > _clockDelay) { _clockDelay = missionConfig.ClockDelay; } IMassiveBody targetPlanet = LocatePlanet(missionConfig.ParentPlanet); // Get the launch angle relative to the sun for the given time at the origin // and offset each vehicle by a certain amount on the surface double launchAngle = targetPlanet.GetSurfaceAngle(_originTime, _sun) + i * 0.00002; _spaceCraftManager.Add(SpacecraftFactory.BuildSpaceCraft(targetPlanet, launchAngle, missionConfig, ProfilePaths[i])); _structures.AddRange(StructureFactory.Load(targetPlanet, launchAngle, ProfilePaths[i])); } _spaceCraftManager.Initialize(_eventManager, _clockDelay); // Target the spacecraft _targetIndex = _gravitationalBodies.IndexOf(_spaceCraftManager.First); _spaceCraftManager.ResolveGravitionalParents(_massiveBodies); UpdateLoadingPercentage(90); }
public IActionResult Index(double latitude = 39.56, double longitude = 116.23, DateTime time = default, string zone = default) { if (time == default) { time = DateTime.Now; } TimeZoneInfo timeZone; if (string.IsNullOrEmpty(zone)) { timeZone = TimeZoneInfo.Local; } else { timeZone = TimeZoneInfo.FindSystemTimeZoneById(zone); } Sun sun = new Sun(latitude, longitude, time, timeZone); Mercury mercury = new Mercury(latitude, longitude, time, timeZone); Venus venus = new Venus(latitude, longitude, time, timeZone); Mars mars = new Mars(latitude, longitude, time, timeZone); Jupiter jupiter = new Jupiter(latitude, longitude, time, timeZone); Saturn saturn = new Saturn(latitude, longitude, time, timeZone); Uranus uranus = new Uranus(latitude, longitude, time, timeZone); Neptune neptune = new Neptune(latitude, longitude, time, timeZone); double[] ra = new[] { sun.Equator.RA, mercury.Equator.RA, venus.Equator.RA, mars.Equator.RA, jupiter.Equator.RA, saturn.Equator.RA, uranus.Equator.RA, neptune.Equator.RA }; double[] dec = new[] { sun.Equator.Dec, mercury.Equator.Dec, venus.Equator.Dec, mars.Equator.Dec, jupiter.Equator.Dec, saturn.Equator.Dec, uranus.Equator.Dec, neptune.Equator.Dec }; TimeSpan[] rising = new[] { sun.Rising, mercury.Rising, venus.Rising, mars.Rising, jupiter.Rising, saturn.Rising, uranus.Rising, neptune.Rising }; TimeSpan[] culmination = new[] { sun.Culmination, mercury.Culmination, venus.Culmination, mars.Culmination, jupiter.Culmination, saturn.Culmination, uranus.Culmination, neptune.Culmination }; TimeSpan[] setting = new[] { sun.Setting, mercury.Setting, venus.Setting, mars.Setting, jupiter.Setting, saturn.Setting, uranus.Setting, neptune.Setting }; double[] toEarth = new[] { sun.ToEarth, mercury.ToEarth, venus.ToEarth, mars.ToEarth, jupiter.ToEarth, saturn.ToEarth, uranus.ToEarth, neptune.ToEarth }; double[] toSun = new[] { 0, mercury.ToSun, venus.ToSun, mars.ToSun, jupiter.ToSun, saturn.ToSun, uranus.ToSun, neptune.ToSun }; double[] ea = new[] { sun.ElevationAngle, mercury.ElevationAngle, venus.ElevationAngle, mars.ElevationAngle, jupiter.ElevationAngle, saturn.ElevationAngle, uranus.ElevationAngle, neptune.ElevationAngle }; double[] az = new[] { sun.Azimuth, mercury.Azimuth, venus.Azimuth, mars.Azimuth, jupiter.Azimuth, saturn.Azimuth, uranus.Azimuth, neptune.Azimuth }; ViewData["Latitude"] = latitude; ViewData["Longitude"] = longitude; ViewData["Time"] = time; ViewData["Zone"] = timeZone.Id; ViewData["RA"] = ra; ViewData["Dec"] = dec; ViewData["Rising"] = rising; ViewData["Culmination"] = culmination; ViewData["Setting"] = setting; ViewData["ToEarth"] = toEarth; ViewData["ToSun"] = toSun; ViewData["EA"] = ea; ViewData["Az"] = az; return(View()); }
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary <string, string> options, string @namespace) { Encoding = encoding ?? Encoding.GetEncoding(1252); byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001" byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM" options ??= GetDefaultOptions(); if (options.TryGetValue("debug", out string debugString)) { bool.TryParse(debugString, out _debug); } if (options.TryGetValue("use_path_table", out string usePathTableString)) { bool.TryParse(usePathTableString, out _usePathTable); } if (options.TryGetValue("use_trans_tbl", out string useTransTblString)) { bool.TryParse(useTransTblString, out _useTransTbl); } if (options.TryGetValue("use_evd", out string useEvdString)) { bool.TryParse(useEvdString, out _useEvd); } // Default namespace @namespace ??= "joliet"; switch (@namespace.ToLowerInvariant()) { case "normal": _namespace = Namespace.Normal; break; case "vms": _namespace = Namespace.Vms; break; case "joliet": _namespace = Namespace.Joliet; break; case "rrip": _namespace = Namespace.Rrip; break; case "romeo": _namespace = Namespace.Romeo; break; default: return(Errno.InvalidArgument); } PrimaryVolumeDescriptor?pvd = null; PrimaryVolumeDescriptor?jolietvd = null; BootRecord?bvd = null; HighSierraPrimaryVolumeDescriptor?hsvd = null; FileStructureVolumeDescriptor? fsvd = null; // ISO9660 is designed for 2048 bytes/sector devices if (imagePlugin.Info.SectorSize < 2048) { return(Errno.InvalidArgument); } // ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size. if (partition.End < 16) { return(Errno.InvalidArgument); } ulong counter = 0; byte[] vdSector = imagePlugin.ReadSector(16 + counter + partition.Start); int xaOff = vdSector.Length == 2336 ? 8 : 0; Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5); _highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC; int hsOff = 0; if (_highSierra) { hsOff = 8; } _cdi = false; List <ulong> bvdSectors = new List <ulong>(); List <ulong> pvdSectors = new List <ulong>(); List <ulong> svdSectors = new List <ulong>(); List <ulong> evdSectors = new List <ulong>(); List <ulong> vpdSectors = new List <ulong>(); while (true) { AaruConsole.DebugWriteLine("ISO9660 plugin", "Processing VD loop no. {0}", counter); // Seek to Volume Descriptor AaruConsole.DebugWriteLine("ISO9660 plugin", "Reading sector {0}", 16 + counter + partition.Start); byte[] vdSectorTmp = imagePlugin.ReadSector(16 + counter + partition.Start); vdSector = new byte[vdSectorTmp.Length - xaOff]; Array.Copy(vdSectorTmp, xaOff, vdSector, 0, vdSector.Length); byte vdType = vdSector[0 + hsOff]; // Volume Descriptor Type, should be 1 or 2. AaruConsole.DebugWriteLine("ISO9660 plugin", "VDType = {0}", vdType); if (vdType == 255) // Supposedly we are in the PVD. { if (counter == 0) { return(Errno.InvalidArgument); } break; } Array.Copy(vdSector, 0x001, vdMagic, 0, 5); Array.Copy(vdSector, 0x009, hsMagic, 0, 5); if (Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && Encoding.GetString(vdMagic) != CDI_MAGIC ) // Recognized, it is an ISO9660, now check for rest of data. { if (counter == 0) { return(Errno.InvalidArgument); } break; } _cdi |= Encoding.GetString(vdMagic) == CDI_MAGIC; switch (vdType) { case 0: { if (_debug) { bvdSectors.Add(16 + counter + partition.Start); } break; } case 1: { if (_highSierra) { hsvd = Marshal. ByteArrayToStructureLittleEndian <HighSierraPrimaryVolumeDescriptor>(vdSector); } else if (_cdi) { fsvd = Marshal.ByteArrayToStructureBigEndian <FileStructureVolumeDescriptor>(vdSector); } else { pvd = Marshal.ByteArrayToStructureLittleEndian <PrimaryVolumeDescriptor>(vdSector); } if (_debug) { pvdSectors.Add(16 + counter + partition.Start); } break; } case 2: { PrimaryVolumeDescriptor svd = Marshal.ByteArrayToStructureLittleEndian <PrimaryVolumeDescriptor>(vdSector); // TODO: Other escape sequences // Check if this is Joliet if (svd.version == 1) { if (svd.escape_sequences[0] == '%' && svd.escape_sequences[1] == '/') { if (svd.escape_sequences[2] == '@' || svd.escape_sequences[2] == 'C' || svd.escape_sequences[2] == 'E') { jolietvd = svd; } else { AaruConsole.DebugWriteLine("ISO9660 plugin", "Found unknown supplementary volume descriptor"); } } if (_debug) { svdSectors.Add(16 + counter + partition.Start); } } else { if (_debug) { evdSectors.Add(16 + counter + partition.Start); } if (_useEvd) { // Basically until escape sequences are implemented, let the user chose the encoding. // This is the same as user choosing Romeo namespace, but using the EVD instead of the PVD _namespace = Namespace.Romeo; pvd = svd; } } break; } case 3: { if (_debug) { vpdSectors.Add(16 + counter + partition.Start); } break; } } counter++; } DecodedVolumeDescriptor decodedVd; var decodedJolietVd = new DecodedVolumeDescriptor(); XmlFsType = new FileSystemType(); if (pvd == null && hsvd == null && fsvd == null) { AaruConsole.ErrorWriteLine("ERROR: Could not find primary volume descriptor"); return(Errno.InvalidArgument); } if (_highSierra) { decodedVd = DecodeVolumeDescriptor(hsvd.Value); } else if (_cdi) { decodedVd = DecodeVolumeDescriptor(fsvd.Value); } else { decodedVd = DecodeVolumeDescriptor(pvd.Value); } if (jolietvd != null) { decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value); } if (_namespace != Namespace.Romeo) { Encoding = Encoding.ASCII; } string fsFormat; byte[] pathTableData; uint pathTableMsbLocation; uint pathTableLsbLocation = 0; // Initialize to 0 as ignored in CD-i _image = imagePlugin; if (_highSierra) { pathTableData = ReadSingleExtent(0, hsvd.Value.path_table_size, Swapping.Swap(hsvd.Value.mandatory_path_table_msb)); fsFormat = "High Sierra Format"; pathTableMsbLocation = hsvd.Value.mandatory_path_table_msb; pathTableLsbLocation = hsvd.Value.mandatory_path_table_lsb; } else if (_cdi) { pathTableData = ReadSingleExtent(0, fsvd.Value.path_table_size, fsvd.Value.path_table_addr); fsFormat = "CD-i"; pathTableMsbLocation = fsvd.Value.path_table_addr; // TODO: Until escape sequences are implemented this is the default CD-i encoding. Encoding = Encoding.GetEncoding("iso8859-1"); } else { pathTableData = ReadSingleExtent(0, pvd.Value.path_table_size, Swapping.Swap(pvd.Value.type_m_path_table)); fsFormat = "ISO9660"; pathTableMsbLocation = pvd.Value.type_m_path_table; pathTableLsbLocation = pvd.Value.type_l_path_table; } _pathTable = _highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData); // High Sierra and CD-i do not support Joliet or RRIP if ((_highSierra || _cdi) && _namespace != Namespace.Normal && _namespace != Namespace.Vms) { _namespace = Namespace.Normal; } if (jolietvd is null && _namespace == Namespace.Joliet) { _namespace = Namespace.Normal; } uint rootLocation; uint rootSize; byte rootXattrLength = 0; if (!_cdi) { rootLocation = _highSierra ? hsvd.Value.root_directory_record.extent : pvd.Value.root_directory_record.extent; rootXattrLength = _highSierra ? hsvd.Value.root_directory_record.xattr_len : pvd.Value.root_directory_record.xattr_len; rootSize = _highSierra ? hsvd.Value.root_directory_record.size : pvd.Value.root_directory_record.size; if (pathTableData.Length > 1 && rootLocation != _pathTable[0].Extent) { AaruConsole.DebugWriteLine("ISO9660 plugin", "Path table and PVD do not point to the same location for the root directory!"); byte[] firstRootSector = ReadSector(rootLocation); bool pvdWrongRoot = false; if (_highSierra) { HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian <HighSierraDirectoryRecord>(firstRootSector); if (rootEntry.extent != rootLocation) { pvdWrongRoot = true; } } else { DirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian <DirectoryRecord>(firstRootSector); if (rootEntry.extent != rootLocation) { pvdWrongRoot = true; } } if (pvdWrongRoot) { AaruConsole.DebugWriteLine("ISO9660 plugin", "PVD does not point to correct root directory, checking path table..."); bool pathTableWrongRoot = false; rootLocation = _pathTable[0].Extent; firstRootSector = ReadSector(_pathTable[0].Extent); if (_highSierra) { HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian <HighSierraDirectoryRecord>(firstRootSector); if (rootEntry.extent != rootLocation) { pathTableWrongRoot = true; } } else { DirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian <DirectoryRecord>(firstRootSector); if (rootEntry.extent != rootLocation) { pathTableWrongRoot = true; } } if (pathTableWrongRoot) { AaruConsole.ErrorWriteLine("Cannot find root directory..."); return(Errno.InvalidArgument); } _usePathTable = true; } } } else { rootLocation = _pathTable[0].Extent; byte[] firstRootSector = ReadSector(rootLocation); CdiDirectoryRecord rootEntry = Marshal.ByteArrayToStructureBigEndian <CdiDirectoryRecord>(firstRootSector); rootSize = rootEntry.size; _usePathTable = _usePathTable || _pathTable.Length == 1; _useTransTbl = false; } // In case the path table is incomplete if (_usePathTable && pathTableData.Length == 1) { _usePathTable = false; } if (_usePathTable && !_cdi) { rootLocation = _pathTable[0].Extent; byte[] firstRootSector = ReadSector(rootLocation); if (_highSierra) { HighSierraDirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian <HighSierraDirectoryRecord>(firstRootSector); rootSize = rootEntry.size; } else { DirectoryRecord rootEntry = Marshal.ByteArrayToStructureLittleEndian <DirectoryRecord>(firstRootSector); rootSize = rootEntry.size; } rootXattrLength = _pathTable[0].XattrLength; } try { _ = ReadSingleExtent(0, rootSize, rootLocation); } catch { return(Errno.InvalidArgument); } byte[] ipbinSector = ReadSector(partition.Start); CD.IPBin? segaCd = CD.DecodeIPBin(ipbinSector); Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector); Dreamcast.IPBin?dreamcast = Dreamcast.DecodeIPBin(ipbinSector); if (_namespace == Namespace.Joliet || _namespace == Namespace.Rrip) { _usePathTable = false; _useTransTbl = false; } // Cannot traverse path table if we substitute the names for the ones in TRANS.TBL if (_useTransTbl) { _usePathTable = false; } if (_namespace != Namespace.Joliet) { _rootDirectoryCache = _cdi ? DecodeCdiDirectory(rootLocation, rootSize, rootXattrLength) : _highSierra ? DecodeHighSierraDirectory(rootLocation, rootSize, rootXattrLength) : DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); } XmlFsType.Type = fsFormat; if (jolietvd != null && (_namespace == Namespace.Joliet || _namespace == Namespace.Rrip)) { rootLocation = jolietvd.Value.root_directory_record.extent; rootXattrLength = jolietvd.Value.root_directory_record.xattr_len; rootSize = jolietvd.Value.root_directory_record.size; _joliet = true; _rootDirectoryCache = DecodeIsoDirectory(rootLocation, rootSize, rootXattrLength); XmlFsType.VolumeName = decodedJolietVd.VolumeIdentifier; if (string.IsNullOrEmpty(decodedJolietVd.SystemIdentifier) || decodedVd.SystemIdentifier.Length > decodedJolietVd.SystemIdentifier.Length) { XmlFsType.SystemIdentifier = decodedVd.SystemIdentifier; } else { XmlFsType.SystemIdentifier = string.IsNullOrEmpty(decodedJolietVd.SystemIdentifier) ? null : decodedJolietVd.SystemIdentifier; } if (string.IsNullOrEmpty(decodedJolietVd.VolumeSetIdentifier) || decodedVd.VolumeSetIdentifier.Length > decodedJolietVd.VolumeSetIdentifier.Length) { XmlFsType.VolumeSetIdentifier = decodedVd.VolumeSetIdentifier; } else { XmlFsType.VolumeSetIdentifier = string.IsNullOrEmpty(decodedJolietVd.VolumeSetIdentifier) ? null : decodedJolietVd.VolumeSetIdentifier; } if (string.IsNullOrEmpty(decodedJolietVd.PublisherIdentifier) || decodedVd.PublisherIdentifier.Length > decodedJolietVd.PublisherIdentifier.Length) { XmlFsType.PublisherIdentifier = decodedVd.PublisherIdentifier; } else { XmlFsType.PublisherIdentifier = string.IsNullOrEmpty(decodedJolietVd.PublisherIdentifier) ? null : decodedJolietVd.PublisherIdentifier; } if (string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) || decodedVd.DataPreparerIdentifier.Length > decodedJolietVd.DataPreparerIdentifier.Length) { XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier; } else { XmlFsType.DataPreparerIdentifier = string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) ? null : decodedJolietVd.DataPreparerIdentifier; } if (string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier) || decodedVd.ApplicationIdentifier.Length > decodedJolietVd.ApplicationIdentifier.Length) { XmlFsType.ApplicationIdentifier = decodedVd.ApplicationIdentifier; } else { XmlFsType.ApplicationIdentifier = string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier) ? null : decodedJolietVd.ApplicationIdentifier; } XmlFsType.CreationDate = decodedJolietVd.CreationTime; XmlFsType.CreationDateSpecified = true; if (decodedJolietVd.HasModificationTime) { XmlFsType.ModificationDate = decodedJolietVd.ModificationTime; XmlFsType.ModificationDateSpecified = true; } if (decodedJolietVd.HasExpirationTime) { XmlFsType.ExpirationDate = decodedJolietVd.ExpirationTime; XmlFsType.ExpirationDateSpecified = true; } if (decodedJolietVd.HasEffectiveTime) { XmlFsType.EffectiveDate = decodedJolietVd.EffectiveTime; XmlFsType.EffectiveDateSpecified = true; } decodedVd = decodedJolietVd; } else { XmlFsType.SystemIdentifier = decodedVd.SystemIdentifier; XmlFsType.VolumeName = decodedVd.VolumeIdentifier; XmlFsType.VolumeSetIdentifier = decodedVd.VolumeSetIdentifier; XmlFsType.PublisherIdentifier = decodedVd.PublisherIdentifier; XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier; XmlFsType.ApplicationIdentifier = decodedVd.ApplicationIdentifier; XmlFsType.CreationDate = decodedVd.CreationTime; XmlFsType.CreationDateSpecified = true; if (decodedVd.HasModificationTime) { XmlFsType.ModificationDate = decodedVd.ModificationTime; XmlFsType.ModificationDateSpecified = true; } if (decodedVd.HasExpirationTime) { XmlFsType.ExpirationDate = decodedVd.ExpirationTime; XmlFsType.ExpirationDateSpecified = true; } if (decodedVd.HasEffectiveTime) { XmlFsType.EffectiveDate = decodedVd.EffectiveTime; XmlFsType.EffectiveDateSpecified = true; } } if (_debug) { _rootDirectoryCache.Add("$", new DecodedDirectoryEntry { Extents = new List <(uint extent, uint size)> { (rootLocation, rootSize) }, Filename = "$", Size = rootSize, Timestamp = decodedVd.CreationTime });
public override void Create() { Node n, n2; Mars = new Mars(); //Mars.rotationspeed.Y = 15.0f / 180.0f * (float)Math.PI; Mars.Position = new Vector3(2000, 0, 3000); Spawn(Mars, true); Moon = new Moon(); Moon.rotationspeed.Y = 15.0f / 180.0f * (float)Math.PI; Moon.Position = new Vector3(1000, 0, 0); Moon.Attach = Mars; Spawn(Moon, true); n = new Saturn(); n.rotationspeed.Y = 10.0f / 180.0f * (float)Math.PI; n.Orientation = QuaternionExtensions.FromAxisAngle(0, 1, 0, (float)Math.PI); n.Position = new Vector3(-2000, 0, 3000); Spawn(n, true); DominationPoint dp = new DominationPoint(); dp.Name = "DomPoint 1"; dp.Position = new Vector3(2000, 0, 2000); dp.rotationspeed = new Vector3(0, 1, 0); Spawn(dp, false); CheckPoint cp = new CheckPoint(); cp.CheckPointIndex = 0; cp.Position = new Vector3(3000, 0, 2000); Spawn(cp, true); cp = new CheckPoint(); cp.CheckPointIndex = 1; cp.Position = new Vector3(4000, 0, 2000); Spawn(cp, true); VecRandom r = new VecRandom(); Vector3 center = new Vector3(-4000, 0, -2000); for (int i = 0; i < 20; ++i) { Vector3 rv = r.NextScaledVector3(3000, 300, 2000); n = new Phobos(); Spawn(n, true); float s = 30.0f / 180.0f * (float)Math.PI; n.rotationspeed = r.NextScaledVector3(s, s, s); n.Position = center + rv; } //if (Root.Instance is Server) { n = new SpawnPoint(typeof(Repair), 20); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(-500, 0, 0); Spawn(n, true); } { n = new SpawnPoint(typeof(MissilePickup), 30); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(2000, 0, -1000); Spawn(n, true); } { n = new PlayerStart(); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(4000, 0, 4000); Spawn(n, true); } { n = new PlayerStart(); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(-4000, 0, -4000); Spawn(n, true); } { n = new PlayerStart(); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(-4000, 0, 4000); Spawn(n, true); } { n = new PlayerStart(); n.rotationspeed = new Vector3(0, 1, 0); n.Position = new Vector3(4000, 0, -4000); Spawn(n, true); } { n = new Flag(1, new Vector3(4800, 0, -4800)); Spawn(n, false); } { n = new Flag(0, new Vector3(4400, 0, -4400)); Spawn(n, false); } //ParticleNebula pn = new ParticleNebula(); n = new Nebula(); //n.Draw.Add(pn); //n.Transparent = true; n.Position = new Vector3(0, 0, 0); Spawn(n, true); n = new Nebula(); //n.Draw.Add(pn); //n.Transparent = true; n.Position = new Vector3(100, 0, 600); Spawn(n, true); //n = new LaserTurret(); //n = new Nebula(); //n.Draw.Add(pn); n = new PornCinema(); //Text3D tx = new Cheetah.Text3D("abcabcabc", (MeshFont)Root.Instance.ResourceManager.Load("models/font-arial-black", typeof(MeshFont))); //n.Draw.Add(tx); n.Position = new Vector3(300, 0, 1200); n.Orientation = QuaternionExtensions.FromAxisAngle(0, 1, 0, (float)Math.PI); Spawn(n, true); //n = new TestShip(); //Root.Instance.Scene.Spawn(n); //n.Position = new Vector3(400, 0, 0); Light l = new Light(); l.directional = true; l.Position = Vector3Extensions.GetUnit(new Vector3(1, 3, 4)); //l.directional = false; l.diffuse = new Color4f(0.5f, 0.8f, 1.0f, 1); Spawn(l, true); l = new Light(); l.Position = new Vector3(0, 0, 0); l.directional = false; l.diffuse = new Color4f(1, 0, 0, 1); Spawn(l, true); n = new EclipticNode(); //n.Draw.Add(new Ecliptic(new Color3f(0, 0, 0.5f), 10000, 100)); Spawn(n, true); //Spawn(new RandomSpawn(typeof(SpaceWar2006.Planets.PhobosAsteroid), 1, 1), true); }
public void SetSaturnData() { Ecliptic satquator = Saturn.EclipticalCoordinate(BirthDate); UserSaturn = satquator.Longitude; }
private void LoadSolarSystem() { _sun = new Sun(); var mercury = new Mercury(); var venus = new Venus(); var earth = new Earth(); var moon = new Moon(earth.Position, earth.Velocity); var mars = new Mars(); var jupiter = new Jupiter(); var europa = new Europa(jupiter.Position, jupiter.Velocity); var saturn = new Saturn(); _massiveBodies = new List <IMassiveBody> { _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn }; ResolveMassiveBodyParents(); _spaceCrafts = new List <ISpaceCraft>(); _structures = new List <StructureBase>(); MissionConfig primaryMission = MissionConfig.Load(ProfilePaths[0]); _originTime = primaryMission.GetLaunchDate(); OrbitHelper.SimulateToTime(_massiveBodies, _originTime, 300); // Load missions for (int i = 0; i < ProfilePaths.Count; i++) { MissionConfig missionConfig = MissionConfig.Load(ProfilePaths[i]); IMassiveBody targetPlanet = LocatePlanet(missionConfig.ParentPlanet); double launchAngle = targetPlanet.GetSurfaceAngle(_originTime, _sun); _spaceCrafts.AddRange(SpacecraftFactory.BuildSpaceCraft(targetPlanet, launchAngle, missionConfig, ProfilePaths[i])); _structures.AddRange(StructureFactory.Load(targetPlanet, launchAngle, ProfilePaths[i])); } // Initialize the spacecraft controllers foreach (ISpaceCraft spaceCraft in _spaceCrafts) { spaceCraft.InitializeController(_eventManager); } _gravitationalBodies = new List <IGravitationalBody> { _sun, mercury, venus, earth, moon, mars, jupiter, europa, saturn }; foreach (ISpaceCraft spaceCraft in _spaceCrafts) { _gravitationalBodies.Add(spaceCraft); } // Target the spacecraft _targetIndex = _gravitationalBodies.IndexOf(_spaceCrafts.FirstOrDefault()); ResolveSpaceCraftParents(); }
public SolarSystem(Saturn saturn) { this.saturn = saturn; }