public void DumpObjectImages(ResourceManager index, IList<int> objIds = null) { var gdi = CreateGdi(); gdi.IsZBufferEnabled = false; gdi.RoomPalette = CreatePalette(); foreach (var room in index.Rooms) { foreach (var obj in room.Objects) { if (objIds != null && !objIds.Contains(obj.Number)) continue; try { DumpRoomObjectImages(room, obj, gdi); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e); Console.ResetColor(); } } } }
public void DumpRoomImages(ResourceManager index, IList<int> roomIds) { var gdi = CreateGdi(); gdi.IsZBufferEnabled = false; gdi.RoomPalette = CreatePalette(); var rooms = roomIds == null ? index.Rooms : roomIds.Select(i => index.GetRoom((byte)i)); foreach (var room in rooms) { if (room.Image == null) continue; var name = room.Name ?? "room_" + room.Number; Console.WriteLine("room #{0}: {1}", room.Number, name); try { DumpRoomImage(room, gdi); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e); Console.ResetColor(); } } }
public void DumpScripts(ResourceManager index) { var dumper = new ConsoleDumper(); foreach (var script in index.Scripts) { dumper.WriteLine("script " + script.Id); DumpScript(script.Data, dumper); } foreach (var room in index.Rooms) { dumper.WriteLine("room {0} {1} {{", room.Number, room.Name); foreach (var obj in room.Objects) { if (obj.Script.Data != null && obj.Script.Data.Length > 0) { dumper.WriteLine("obj {0} {1} {{", obj.Number, System.Text.Encoding.UTF8.GetString(obj.Name)); foreach (var off in obj.ScriptOffsets) { dumper.WriteLine("idx #{0}: {1}", off.Key, off.Value); } dumper.WriteLine("script"); DumpScript(obj.Script.Data, dumper); } } if (room.EntryScript.Data.Length > 0) { dumper.WriteLine("Entry script"); DumpScript(room.EntryScript.Data, dumper); } if (room.EntryScript.Data.Length > 0) { dumper.WriteLine("Exit script"); DumpScript(room.ExitScript.Data, dumper); } for (int i = 0; i < room.LocalScripts.Length; i++) { var script = room.LocalScripts[i]; if (script != null && script.Data != null) { dumper.WriteLine("Local script " + i); DumpScript(script.Data, dumper); } } dumper.WriteLine("}"); } }
public void DumpImages(ResourceManager index) { foreach (var room in index.Rooms) { if (room.Image == null) continue; var name = room.Name ?? "room_" + room.Number; Console.WriteLine("room #{0}: {1}", room.Number, name); try { var gdi = CreateGdi(); gdi.IsZBufferEnabled = false; gdi.RoomPalette = CreatePalette(); DumpRoomObjects(room, gdi); DumpRoomImage(room, gdi); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e); Console.ResetColor(); } } }
protected ScummEngine(GameSettings settings, IGraphicsManager gfxManager, IInputManager inputManager, IMixer mixer) { Settings = settings; var game = (GameInfo)settings.Game; _resManager = ResourceManager.Load(game); _game = game; InvalidBox = _game.Version < 5 ? (byte)255 : (byte)0; _gameMD5 = ToMd5Bytes(game.MD5); _gfxManager = gfxManager; _inputManager = inputManager; _inputState = inputManager.GetState(); _strings = new byte[_resManager.NumArray][]; _inventory = new ushort[_resManager.NumInventory]; _invData = new ObjectData[_resManager.NumInventory]; CurrentScript = 0xFF; Mixer = mixer; ScreenWidth = Game.Width; ScreenHeight = Game.Height; AudioCDManager = new DefaultAudioCDManager(this, mixer); Sound = new Sound(this, mixer); SetupMusic(); _variables = new int[_resManager.NumVariables]; _bitVars = new BitArray(_resManager.NumBitVariables); _slots = new ScriptSlot[NumScriptSlot]; for (int i = 0; i < NumScriptSlot; i++) { _slots[i] = new ScriptSlot(); } for (int i = 0; i < 200; i++) { _objs[i] = new ObjectData(); } for (int i = 0; i < 6; i++) { _string[i] = new TextSlot(); if (game.Version != 3) { _string[i].Default.Position = new Point(2, 5); } } _colorCycle = new ColorCycle[16]; for (int i = 0; i < _colorCycle.Length; i++) { _colorCycle[i] = new ColorCycle(); } _nest = new NestedScript[MaxScriptNesting + 1]; for (int i = 0; i < _nest.Length; i++) { _nest[i] = new NestedScript(); } _scaleSlots = new ScaleSlot[20]; for (int i = 0; i < _scaleSlots.Length; i++) { _scaleSlots[i] = new ScaleSlot(); } Gdi = Gdi.Create(this, game); switch (game.Version) { case 0: _costumeLoader = new CostumeLoader0(this); _costumeRenderer = new CostumeRenderer0(this); break; case 7: case 8: _costumeLoader = new AkosCostumeLoader(this); _costumeRenderer = new AkosRenderer(this); break; default: _costumeLoader = new ClassicCostumeLoader(this); _costumeRenderer = new ClassicCostumeRenderer(this); break; } CreateCharset(); ResetCursors(); // Create the text surface var pixelFormat = _game.Features.HasFlag(GameFeatures.Is16BitColor) ? PixelFormat.Rgb16 : PixelFormat.Indexed8; _textSurface = new Surface(ScreenWidth * _textSurfaceMultiplier, ScreenHeight * _textSurfaceMultiplier, PixelFormat.Indexed8, false); ClearTextSurface(); if (Game.Platform == Platform.FMTowns) { _townsScreen = new TownsScreen(_gfxManager, ScreenWidth * _textSurfaceMultiplier, ScreenHeight * _textSurfaceMultiplier, PixelFormat.Rgb16); _townsScreen.SetupLayer(0, ScreenWidth, ScreenHeight, 32767); _townsScreen.SetupLayer(1, ScreenWidth * _textSurfaceMultiplier, ScreenHeight * _textSurfaceMultiplier, 16, _textPalette); } if (Game.Version == 0) { InitScreens(8, 144); } else if ((Game.GameId == GameId.Maniac) && (_game.Version <= 1) && _game.Platform != Platform.NES) { InitScreens(16, 152); } else if (Game.Version >= 7) { InitScreens(0, ScreenHeight); } else { InitScreens(16, 144); } // Allocate gfx compositing buffer (not needed for V7/V8 games). if (Game.Version < 7) { _composite = new Surface(ScreenWidth, ScreenHeight, pixelFormat, false); } InitActors(); OwnerRoom = Game.Version >= 7 ? 0x0FF : 0x0F; if (Game.Version < 7) { Camera.LeftTrigger = 10; Camera.RightTrigger = 30; } InitPalettes(); InitializeVerbs(); // WORKAROUND for bug in boot script of Loom (CD) // The boot script sets the characters of string 21, // before creating the string.resource. if (_game.GameId == GameId.Loom) { _strings[21] = new byte[13]; } }