internal ViewCell(View view, AssetLoader loader) : base(loader) { BinaryReader reader = loader.Reader; View = view; DataOffset = (ushort)reader.BaseStream.Position; var sizeX = reader.ReadUInt16(); var sizeY = reader.ReadUInt16(); Offset = new Vector2i(reader.ReadSByte(), reader.ReadSByte()); var transparentColor = reader.ReadByte(); byte[] pixels = new byte[sizeX * sizeY]; for (int offset = 0; offset < pixels.Length && reader.BaseStream.Position < reader.BaseStream.Length; ) { int code = reader.ReadByte(); int color = code & 15, repeat = code >> 4; int x = offset % sizeX; int y = offset / sizeX; if (color == transparentColor) color = 16; for (int count = 0; count < repeat && offset < pixels.Length; count++) pixels[offset++] = (byte)color; } Raster = new Raster(sizeX, sizeY, Raster.DefaultEgaColorsWithTransparent, data: pixels); #if false // For VGA // Width:WORD Height:WORD DisplaceX:BYTE DisplaceY:BYTE ClearKey:BYTE Unknown:BYTE RLEData starts now directly // For EGA // Width:WORD Height:WORD DisplaceX:BYTE DisplaceY:BYTE ClearKey:BYTE EGAData starts now directly cel = &_loop[loopNo].cel[celNo]; cel->scriptWidth = cel->width = READ_LE_UINT16(celData); cel->scriptHeight = cel->height = READ_LE_UINT16(celData + 2); cel->displaceX = (signed char)celData[4]; cel->displaceY = celData[5]; cel->clearKey = celData[6]; if (g_sci->getGameId() == GID_QFG3 && g_sci->isDemo() && resourceId == 39) cel->displaceY = 98; if (isEGA) { cel->offsetEGA = celOffset + 7; cel->offsetRLE = 0; cel->offsetLiteral = 0; } else { cel->offsetEGA = 0; if (isCompressed) { cel->offsetRLE = celOffset + 8; cel->offsetLiteral = 0; } else { cel->offsetRLE = 0; cel->offsetLiteral = celOffset + 8; } } cel->rawBitmap = 0; if (_loop[loopNo].mirrorFlag) cel->displaceX = -cel->displaceX; #endif }
internal ViewAnimation(View view, AssetLoader loader) : base(loader) { BinaryReader reader = loader.Reader; View = view; var cells = new Codex<ViewCell>(); Cells = cells; DataOffset = (ushort)reader.BaseStream.Position; var count = reader.ReadUInt16(); Unknowns.ReadInt16s(reader, 1); for (int index = 0; index < count; index++) { reader.BaseStream.Position = DataOffset + 4 + index * 2; cells.Add(view.FindCell(loader, reader.ReadUInt16())); } }