public string GetSaveFileName() { if (Position is PatcherLib.Iso.PsxIso.KnownPosition) { PatcherLib.Iso.PsxIso.KnownPosition pos = Position as PatcherLib.Iso.PsxIso.KnownPosition; return(string.Format("{0}_{1}_{2}.bmp", pos.Sector, pos.StartLocation, pos.Length)); } else if (Position is PatcherLib.Iso.PspIso.KnownPosition) { PatcherLib.Iso.PspIso.KnownPosition pos = Position as PatcherLib.Iso.PspIso.KnownPosition; return(string.Format("{0}_{1}_{2}.bmp", pos.SectorEnum, pos.StartLocation, pos.Length)); } else { return(name); } }
public static AbstractImage GetPSPEffectImage(Stream iso, int effectIndex, string effectName, PatcherLib.Iso.PspIso.PspIsoInfo pspIsoInfo) { string strEffectNumber = effectIndex.ToString("000"); string sectorName = string.Format("EFFECT_E{0}_BIN", strEffectNumber); PatcherLib.Iso.FFTPack.Files fftPack = (PatcherLib.Iso.FFTPack.Files) 3; try { fftPack = (PatcherLib.Iso.FFTPack.Files)Enum.Parse(typeof(PatcherLib.Iso.FFTPack.Files), sectorName); } catch (Exception) { } byte[] fileBytes = PatcherLib.Iso.PspIso.GetFile(iso, pspIsoInfo, fftPack); //byte[] fileBytes = PatcherLib.Iso.FFTPack.TryGetFileFromIso(iso, pspIsoInfo, fftPack, 0, 0x5800); if (fileBytes.Length == 0) { return(null); } /* * int headerOffset = 0; * int lastMatchIndex = fileBytes.LastIndexOf(subroutineEndByteSequence); * if (lastMatchIndex >= 0) * { * int lastMatchIndex2 = fileBytes.Sub(lastMatchIndex + 8).IndexOf(frameDataOffsetByteSequence) + lastMatchIndex + 4; * headerOffset = (lastMatchIndex2 >= 0) ? (lastMatchIndex2 + 4) : (lastMatchIndex + 8); * } */ int headerOffset = fileBytes.IndexOf(Effect_FrameDataOffsetByteSequence); int frameDataOffset = fileBytes.SubLength(headerOffset, 4).ToIntLE() + headerOffset; int frameDataSectionCount = fileBytes.SubLength(frameDataOffset, 2).ToIntLE(); int firstFrameDataPointerOffset = fileBytes.SubLength(frameDataOffset + 4 + (2 * frameDataSectionCount), 2).ToIntLE() + frameDataOffset + 4; int firstFrameTexturePageHeader = fileBytes.SubLength(firstFrameDataPointerOffset, 2).ToIntLE(); int colorDepthCode = (firstFrameTexturePageHeader & 0x0180) >> 7; if (colorDepthCode > 1) // Invalid code { return(null); } bool is4bpp = (colorDepthCode == 0); int paletteOffset = fileBytes.SubLength(headerOffset + 0x24, 4).ToIntLE() + headerOffset; int secondSetPaletteOffset = paletteOffset + 0x200; int imageSizeDataOffset = paletteOffset + 0x400; int graphicsOffset = paletteOffset + 0x404; byte[] imageSizeData = fileBytes.SubLength(imageSizeDataOffset, 4).ToArray(); //byte[] imageSizeData = PatcherLib.Iso.FFTPack.TryGetFileFromIso(iso, pspIsoInfo, fftPack, imageSizeDataOffset, 4); int imageSizeCombinedValue = imageSizeData.Sub(0, 2).ToIntLE(); int rowBytes = (imageSizeData[3] != 0) ? 256 : 128; int height = imageSizeCombinedValue >> ((imageSizeData[3] != 0) ? 8 : 7); int width = is4bpp ? (rowBytes * 2) : rowBytes; int imageSize = rowBytes * height; int fileSize = graphicsOffset + imageSize; string name = String.Format("{0} {1}", effectIndex.ToString("X3"), effectName); string fileName = String.Format("E{0}.BIN", strEffectNumber); PatcherLib.Iso.PspIso.KnownPosition graphicsPosition = new PatcherLib.Iso.PspIso.KnownPosition(fftPack, graphicsOffset, imageSize); PatcherLib.Iso.PspIso.KnownPosition palettePosition = new PatcherLib.Iso.PspIso.KnownPosition(fftPack, (is4bpp ? secondSetPaletteOffset : paletteOffset), (is4bpp ? 32 : 512)); return(GetPalettedImage(is4bpp, name, width, height, fileName, fileSize, fftPack, graphicsPosition, palettePosition, true, effectIndex)); }