private void CheckISO(string filepath) { if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath)) { pnl_Params.Visible = true; using (Stream file = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { if (settings.WorldConditionalsRepoint) { if (context == Context.US_PSX) { int ramOffset = PsxIso.ReadFile(file, (PsxIso.Sectors)settings.WorldConditionalsPointerSector, settings.WorldConditionalsPointerOffset, 3).ToIntLE(); int wldcoreRamOffset = PsxIso.GetRamOffset(PsxIso.Sectors.WORLD_WLDCORE_BIN); int worldRamOffset = PsxIso.GetRamOffset(PsxIso.Sectors.WORLD_WORLD_BIN); if (ramOffset >= worldRamOffset) { spinner_WorldConditionals_Sector.Value = (int)PsxIso.Sectors.WORLD_WORLD_BIN; spinner_WorldConditionals_Offset.Value = ramOffset - worldRamOffset; } else if (ramOffset >= wldcoreRamOffset) { spinner_WorldConditionals_Sector.Value = (int)PsxIso.Sectors.WORLD_WLDCORE_BIN; spinner_WorldConditionals_Offset.Value = ramOffset - wldcoreRamOffset; } } } } EnableActionButton(); } }
private void btn_Load_Click(object sender, EventArgs e) { btn_Load.Enabled = false; string filepath = txt_ISO.Text; if (!string.IsNullOrEmpty(filepath)) { try { using (Stream file = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { if (chk_BattleConditionals.Checked) { PsxIso.Sectors battleSector = (PsxIso.Sectors)spinner_BattleConditionals_Sector.Value; int battleOffset = (int)spinner_BattleConditionals_Offset.Value; int battleSize = (int)spinner_BattleConditionals_Size.Value; byte[] battleBytes = PsxIso.ReadFile(file, battleSector, battleOffset, battleSize); _entryData.BattleConditionals = _dataHelper.LoadConditionalSetsFromByteArray(CommandType.BattleConditional, battleBytes); } if (chk_WorldConditionals.Checked) { PsxIso.Sectors worldSector = (PsxIso.Sectors)spinner_WorldConditionals_Sector.Value; int worldOffset = (int)spinner_WorldConditionals_Offset.Value; int worldSize = (int)spinner_WorldConditionals_Size.Value; byte[] worldBytes = PsxIso.ReadFile(file, worldSector, worldOffset, worldSize); _entryData.WorldConditionals = _dataHelper.LoadConditionalSetsFromByteArray(CommandType.WorldConditional, worldBytes); } if (chk_Events.Checked) { PsxIso.Sectors eventSector = (PsxIso.Sectors)spinner_Events_Sector.Value; int eventOffset = (int)spinner_Events_Offset.Value; int eventSize = (int)spinner_Events_Size.Value; byte[] eventBytes = PsxIso.ReadFile(file, eventSector, eventOffset, eventSize); _entryData.Events = _dataHelper.GetEventsFromBytes(eventBytes); } } DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { PatcherLib.MyMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK); btn_Load.Enabled = true; } } }
public static void GetCharMap(Stream iso, out GenericCharMap outCharmap, out IList <Glyph> customGlyphs) { var matchBytes = Encoding.UTF8.GetBytes(FFTText.CharmapHeader); var isoBytes = PsxIso.GetBlock(iso, new PsxIso.KnownPosition((PsxIso.Sectors)FFTText.PsxCharmapSector, 0, matchBytes.Length)); if (Utilities.CompareArrays(matchBytes, isoBytes)) { BuildCharMapFromIso(iso, out outCharmap, out customGlyphs); } else { IList <byte> dteBytes = PsxIso.ReadFile(iso, DTE.PsxDteTable); outCharmap = GetCharMap(dteBytes); customGlyphs = null; } }
public void RestoreFile(System.IO.Stream iso) { IList <byte> bytes = null; if (Layout.Context == Context.US_PSX) { KeyValuePair <Enum, int> sect = Layout.Sectors[SectorType.Sector][0]; bytes = PsxIso.ReadFile(iso, (PsxIso.Sectors)sect.Key, sect.Value, Layout.Size); } else if (Layout.Context == Context.US_PSP) { PatcherLib.Iso.PspIso.PspIsoInfo info = PatcherLib.Iso.PspIso.PspIsoInfo.GetPspIsoInfo(iso); if (Layout.Sectors.ContainsKey(SectorType.BootBin)) { KeyValuePair <Enum, int> sect = Layout.Sectors[SectorType.BootBin][0]; bytes = PspIso.GetFile(iso, info, (PspIso.Sectors)sect.Key, sect.Value, Layout.Size); } else if (Layout.Sectors.ContainsKey(SectorType.FFTPack)) { KeyValuePair <Enum, int> sect = Layout.Sectors[SectorType.FFTPack][0]; bytes = PspIso.GetFile(iso, info, (FFTPack.Files)sect.Key, sect.Value, Layout.Size); } else { throw new InvalidOperationException(); } } else { throw new InvalidOperationException(); } AbstractFile tempFile = ConstructFile( Layout.FileType, CharMap, Layout, bytes); this.Sections = tempFile.Sections; }
public static GenericCharMap GetCharMap(Stream iso) { IList <byte> dteBytes = PsxIso.ReadFile(iso, DTE.PsxDteTable); return(GetCharMap(dteBytes)); }