internal CharacterSprite(PatcherLib.Datatypes.Context context, string name, SpriteAttributes attributes, SpriteLocation location) : base(context, name, context == PatcherLib.Datatypes.Context.US_PSP ? (PatcherLib.Iso.KnownPosition) new PatcherLib.Iso.PspIso.KnownPosition((PatcherLib.Iso.FFTPack.Files)location.Sector, 0, (int)location.Size) : (PatcherLib.Iso.KnownPosition) new PatcherLib.Iso.PsxIso.KnownPosition((PatcherLib.Iso.PsxIso.Sectors)location.Sector, 0, (int)location.Size)) { this.location = location; this.attributes = attributes; }
internal CharacterSprite(PatcherLib.Datatypes.Context context, string name, SpriteAttributes attributes, SpriteLocation location) : base(context, name, context == PatcherLib.Datatypes.Context.US_PSP ? (PatcherLib.Iso.KnownPosition)new PatcherLib.Iso.PspIso.KnownPosition((PatcherLib.Iso.FFTPack.Files)location.Sector, 0, (int)location.Size) : (PatcherLib.Iso.KnownPosition)new PatcherLib.Iso.PsxIso.KnownPosition((PatcherLib.Iso.PsxIso.Sectors)location.Sector, 0, (int)location.Size)) { this.location = location; this.attributes = attributes; }
public static SpriteFileLocations FromPsxIso(Stream iso) { SpriteFileLocations result = new SpriteFileLocations(); byte[] spriteBytes = PatcherLib.Iso.PsxIso.ReadFile(iso, spriteLocationsPosition); byte[] sp2Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, sp2LocationsPosition); var sp2 = new Dictionary <byte, SpriteLocation>(); for (byte i = 0; i < numSp2; i++) { const byte offset = 0x87; sp2[(byte)(i + offset)] = SpriteLocation.BuildPsx( new PsxIso.KnownPosition(sp2LocationsPosition.Sector, sp2LocationsPosition.StartLocation + i * 8, 8), sp2Bytes.Sub(i * 8, (i + 1) * 8 - 1)); } IList <SpriteLocation> sprites = new SpriteLocation[numSprites + numWep]; for (byte i = 0; i < numSprites; i++) { if (psxSp2toSpriteMapping.ContainsKey(i)) { IList <byte> values = psxSp2toSpriteMapping[i]; SpriteLocation[] sp2s = new SpriteLocation[values.Count]; for (int j = 0; j < values.Count; j++) { sp2s[j] = sp2[values[j]]; } sprites[i] = SpriteLocation.BuildPsx( new PsxIso.KnownPosition(spriteLocationsPosition.Sector, spriteLocationsPosition.StartLocation + i * 8, 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1), sp2s); } else { sprites[i] = SpriteLocation.BuildPsx( new PsxIso.KnownPosition(spriteLocationsPosition.Sector, spriteLocationsPosition.StartLocation + i * 8, 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1)); } } //byte[] wep1Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, new PatcherLib.Iso.PsxIso.KnownPosition( // PatcherLib.Iso.PsxIso.Sectors.BATTLE_WEP_SPR, 0, 256 * 256 / 2 + 0x200)); //byte[] wep2Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, new PatcherLib.Iso.PsxIso.KnownPosition( // PatcherLib.Iso.PsxIso.Sectors.BATTLE_WEP_SPR, 256 * 256 / 2 + 0x200, 256 * 256 / 2 + 0x200)); //byte[] wep3Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, new PatcherLib.Iso.PsxIso.KnownPosition( // PatcherLib.Iso.PsxIso.Sectors.BATTLE_WEP_SPR, (256 * 256 / 2 + 0x200) * 2, 256 * 144 / 2 + 0x200)); result.sprites = sprites; result.sp2 = sp2; return(result); }
//public IList<byte> DefaultSpriteFileLocationsBytes { get { return defaultSpriteFileLocationsBytes; } } public static SpriteFileLocations FromPspIso(Stream iso, PspIso.PspIsoInfo info) { //const int numPspSp2 = 0x130 / 8; const int numPspSprites = 170; //0x4d0 / 8 + 0x58 / 8; //const int numPspSp2 = numSprites + 4; //0x130 / 8; const int numPspSp2 = numPspSprites + 4; //0x130 / 8; IList <byte> spriteBytes = new List <byte>(); //spriteBytes.AddRange(PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x32481C, 159 * 8))); //spriteBytes.AddRange(PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x324D14, 11 * 8))); spriteBytes.AddRange(PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x32481C, numPspSprites * 8))); spriteBytes = spriteBytes.ToArray(); // Read the sector -> fftpack map IList <byte> fftpackMap = PatcherLib.Iso.PspIso.GetBlock( iso, info, new PatcherLib.Iso.PspIso.KnownPosition(PatcherLib.Iso.PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x252F34, 0x3E00)); // Convert the fake "Sectors" into FFTPack indices Dictionary <uint, int> sectorToFftPackMap = new Dictionary <uint, int>(); Dictionary <int, uint> fftPackToSectorMap = new Dictionary <int, uint>(); for (int i = 3; i < PatcherLib.Iso.FFTPack.NumFftPackFiles - 1; i++) { UInt32 sector = fftpackMap.Sub((i - 3) * 4, (i - 3) * 4 + 4 - 1).ToUInt32(); sectorToFftPackMap.Add(sector, i); fftPackToSectorMap.Add(i, sector); } byte[] sp2Bytes = PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x324D6C, numPspSp2 * 8)).ToArray(); var sp2 = new Dictionary <byte, SpriteLocation>(); for (byte i = 0; i < numPspSp2; i++) { //const byte offset = 0x87; SpriteLocation loc = SpriteLocation.BuildPsp( new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x324D6C + i * 8, 8), sp2Bytes.Sub(i * 8, (i + 1) * 8 - 1)); if (loc.Sector != 0 && loc.Size != 0) { loc.Sector = (uint)sectorToFftPackMap[loc.Sector]; sp2[(byte)(i)] = loc; } } IList <SpriteLocation> sprites = new SpriteLocation[numPspSprites]; for (byte i = 0; i < numPspSprites; i++) { if (pspSp2toSpriteMapping.ContainsKey(i)) { IList <byte> values = pspSp2toSpriteMapping[i]; List <byte> newValues = new List <byte>(values.Count); foreach (byte value in values) { if (sp2.ContainsKey(value)) { newValues.Add(value); } } values = newValues.AsReadOnly(); SpriteLocation[] sp2s = new SpriteLocation[values.Count]; for (int j = 0; j < values.Count; j++) { sp2s[j] = sp2[values[j]]; } sprites[i] = SpriteLocation.BuildPsp( new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, //i <= 0x9A ? (0x32481C + i * 8) : (0x324D14 + (i - 0x9A - 1) * 8), (0x32481C + i * 8), 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1), sp2s); } else { sprites[i] = SpriteLocation.BuildPsp( new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, //i <= 0x9A ? (0x32481C + i * 8) : (0x324D14 + (i - 0x9A - 1) * 8), (0x32481C + i * 8), 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1)); } sprites[i].Sector = ((sprites[i].Sector > 0) ? (uint)sectorToFftPackMap[sprites[i].Sector] : 0); } SpriteFileLocations result = new SpriteFileLocations(); result.sprites = sprites; result.sp2 = sp2; return(result); }
public static SpriteFileLocations FromPsxIso(Stream iso) { SpriteFileLocations result = new SpriteFileLocations(); byte[] spriteBytes = PatcherLib.Iso.PsxIso.ReadFile(iso, spriteLocationsPosition); byte[] sp2Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, sp2LocationsPosition); var sp2 = new Dictionary<byte, SpriteLocation>(); for (byte i = 0; i < numSp2; i++) { const byte offset = 0x87; sp2[(byte)(i + offset)] = SpriteLocation.BuildPsx( new PsxIso.KnownPosition(sp2LocationsPosition.Sector, sp2LocationsPosition.StartLocation + i * 8, 8), sp2Bytes.Sub(i * 8, (i + 1) * 8 - 1)); } IList<SpriteLocation> sprites = new SpriteLocation[numSprites + numWep]; for (byte i = 0; i < numSprites; i++) { if (psxSp2toSpriteMapping.ContainsKey(i)) { IList<byte> values = psxSp2toSpriteMapping[i]; SpriteLocation[] sp2s = new SpriteLocation[values.Count]; for (int j = 0; j < values.Count; j++) { sp2s[j] = sp2[values[j]]; } sprites[i] = SpriteLocation.BuildPsx( new PsxIso.KnownPosition(spriteLocationsPosition.Sector, spriteLocationsPosition.StartLocation + i * 8, 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1), sp2s); } else { sprites[i] = SpriteLocation.BuildPsx( new PsxIso.KnownPosition(spriteLocationsPosition.Sector, spriteLocationsPosition.StartLocation + i * 8, 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1)); } } //byte[] wep1Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, new PatcherLib.Iso.PsxIso.KnownPosition( // PatcherLib.Iso.PsxIso.Sectors.BATTLE_WEP_SPR, 0, 256 * 256 / 2 + 0x200)); //byte[] wep2Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, new PatcherLib.Iso.PsxIso.KnownPosition( // PatcherLib.Iso.PsxIso.Sectors.BATTLE_WEP_SPR, 256 * 256 / 2 + 0x200, 256 * 256 / 2 + 0x200)); //byte[] wep3Bytes = PatcherLib.Iso.PsxIso.ReadFile(iso, new PatcherLib.Iso.PsxIso.KnownPosition( // PatcherLib.Iso.PsxIso.Sectors.BATTLE_WEP_SPR, (256 * 256 / 2 + 0x200) * 2, 256 * 144 / 2 + 0x200)); result.sprites = sprites; result.sp2 = sp2; return result; }
public static SpriteFileLocations FromPspIso(Stream iso, PspIso.PspIsoInfo info) { const int numPspSp2 = 0x130 / 8; const int numPspSprites = 0x4d0 / 8 + 0x58 / 8; IList<byte> spriteBytes = new List<byte>(); spriteBytes.AddRange(PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x324824, 0x4d0))); spriteBytes.AddRange(PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x324D14, 0x58))); spriteBytes = spriteBytes.ToArray(); // Read the sector -> fftpack map IList<byte> fftpackMap = PatcherLib.Iso.PspIso.GetBlock( iso, info, new PatcherLib.Iso.PspIso.KnownPosition(PatcherLib.Iso.PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x252f34, 0x3e00)); // Convert the fake "Sectors" into FFTPack indices Dictionary<uint, int> sectorToFftPackMap = new Dictionary<uint, int>(); Dictionary<int, uint> fftPackToSectorMap = new Dictionary<int, uint>(); for (int i = 3; i < PatcherLib.Iso.FFTPack.NumFftPackFiles - 1; i++) { UInt32 sector = fftpackMap.Sub((i - 3) * 4, (i - 3) * 4 + 4 - 1).ToUInt32(); sectorToFftPackMap.Add(sector, i); fftPackToSectorMap.Add(i, sector); } byte[] sp2Bytes = PspIso.GetBlock(iso, info, new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x3251ac, 0x130)).ToArray(); var sp2 = new Dictionary<byte, SpriteLocation>(); for (byte i = 0; i < numPspSp2; i++) { const byte offset = 0x87; SpriteLocation loc = SpriteLocation.BuildPsp( new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, 0x3251ac + i * 8, 8), sp2Bytes.Sub(i * 8, (i + 1) * 8 - 1)); if (loc.Sector != 0 && loc.Size != 0) { loc.Sector = (uint)sectorToFftPackMap[loc.Sector]; sp2[(byte)(i + offset)] = loc; } else { } } IList<SpriteLocation> sprites = new SpriteLocation[numPspSprites]; for (byte i = 0; i < numPspSprites; i++) { if (pspSp2toSpriteMapping.ContainsKey(i)) { IList<byte> values = pspSp2toSpriteMapping[i]; SpriteLocation[] sp2s = new SpriteLocation[values.Count]; for (int j = 0; j < values.Count; j++) { sp2s[j] = sp2[values[j]]; } sprites[i] = SpriteLocation.BuildPsp( new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, i <= 0x99 ? (0x324824 + i * 8) : (0x324d14 + (i - 0x99 - 1) * 8), 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1), sp2s); } else { sprites[i] = SpriteLocation.BuildPsp( new PspIso.KnownPosition(PspIso.Sectors.PSP_GAME_SYSDIR_BOOT_BIN, i <= 0x99 ? (0x324824 + i * 8) : (0x324d14 + (i - 0x99 - 1) * 8), 8), spriteBytes.Sub(i * 8, (i + 1) * 8 - 1)); } sprites[i].Sector = (uint)sectorToFftPackMap[sprites[i].Sector]; } SpriteFileLocations result = new SpriteFileLocations(); result.sprites = sprites; result.sp2 = sp2; return result; }