public static ARGB1555Color From1555(ushort argb1555) { ARGB1555Color col = new ARGB1555Color(); col.Color1555 = argb1555; return(col); }
/// <summary> /// Serializes the data /// </summary> /// <param name="s">The serializer object</param> public override void SerializeImpl(SerializerObject s) { // HEADER base.SerializeImpl(s); // DATA BLOCK s.DoAt(DataBlockPointer, () => { DataBlock = s.SerializeArray <byte>(DataBlock, SecondBlockPointer - s.CurrentPointer, name: nameof(DataBlock)); }); // BLOCK 2 s.DoAt(SecondBlockPointer, () => { SecondBlock = s.SerializeArray <byte>(SecondBlock, TextureBlockPointer - s.CurrentPointer, name: nameof(SecondBlock)); }); // TEXTURE BLOCK s.DoAt(TextureBlockPointer, () => { TextureBlock = s.SerializeArray <byte>(TextureBlock, EventPalette1BlockPointer - s.CurrentPointer, name: nameof(TextureBlock)); }); // EVENT PALETTE 1 s.DoAt(EventPalette1BlockPointer, () => { EventPalette1 = s.SerializeObjectArray <ARGB1555Color>(EventPalette1, 256, name: nameof(EventPalette1)); }); // EVENT PALETTE 2 s.DoAt(EventPalette2BlockPointer, () => { EventPalette2 = s.SerializeObjectArray <ARGB1555Color>(EventPalette2, 256, name: nameof(EventPalette2)); }); if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1) { // TILES s.DoAt(TilesBlockPointer, () => { // Read the tiles which use a palette PalettedTiles = s.SerializeArray <byte>(PalettedTiles, TilePaletteBlockPointer - TilesBlockPointer, name: nameof(PalettedTiles)); }); // TILE PALETTES s.DoAt(TilePaletteBlockPointer, () => { // TODO: Find a better way to know the number of palettes uint numPalettes = (uint)(PaletteIndexBlockPointer - TilePaletteBlockPointer) / (256 * 2); if (TilePalettes == null) { TilePalettes = new ARGB1555Color[numPalettes][]; } for (int i = 0; i < TilePalettes.Length; i++) { TilePalettes[i] = s.SerializeObjectArray <ARGB1555Color>(TilePalettes[i], 256, name: nameof(TilePalettes) + "[" + i + "]"); } }); // TILE PALETTE ASSIGN s.DoAt(PaletteIndexBlockPointer, () => { // Read the palette index table TilePaletteIndexTable = s.SerializeArray <byte>(TilePaletteIndexTable, FileSize - PaletteIndexBlockPointer.FileOffset, name: nameof(TilePaletteIndexTable)); }); } else if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JP) { // TILES s.DoAt(TilesBlockPointer, () => { // Get the tile count int tileCount = RawTiles?.Length ?? (int)((FileSize - s.CurrentPointer.FileOffset) / 2); // Serialize the tiles RawTiles = s.SerializeObjectArray <ARGB1555Color>(RawTiles, tileCount, name: nameof(RawTiles)); }); } }