Ejemplo n.º 1
0
        private void InitColors()
        {
            for (var i = 0; i < 12; i++)
            {
                var palette = new ColorPickerPaletteViewModel
                {
                    Index = i
                };

                var hue = (i * 30f / 360f);

                for (var j = 0; j < ColorCount; j++)
                {
                    var row    = j / 4;
                    var column = j % 4;

                    var saturation = column * 0.25f + 0.25f;
                    var brightness = 1f - row * 0.12f;

                    var color = Color.FromHsb(hue, saturation, brightness);

                    palette.Colors.Add(color);
                }

                Palettes.Add(palette);
            }
        }
Ejemplo n.º 2
0
        public ChassisVisuals( )
        {
            Decals.Add(new Decal {
                ID        = 10000,
                Usage     = 0xff,
                Color     = 0xffffffff,
                Transform = new Half[] {
                    (Half)0.052460, (Half)0.019623, (Half)0, (Half)0.007484,
                    (Half)(-0.020020), (Half)(-0.051758), (Half)0.018127, (Half)(-0.048492),
                    (Half)0.021362, (Half)0.108154, (Half)(-0.105469), (Half)1.495117,
                }
            });

            Colors.Add(0x10000020u);
            Colors.Add(0xc8000000u);
            Colors.Add(0xfe206281u);
            Colors.Add(0xc8000000u);
            Colors.Add(0xc8000000u);
            Colors.Add(0xf5621861u);
            Colors.Add(0xf5621861u);

            Palettes.Add(new Palette {
                ID = 85163, Type = Enums.Visuals.PaletteType.FullBody
            });

            Patterns.Add(new Pattern {
                ID        = 10022,
                Usage     = 0x0,
                Transform = new Half[] {
                    0, Half.ToHalf((ushort)16384u),
                    0, 0
                }
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Register a palette
        /// </summary>
        /// <param name="p"></param>
        /// <param name="doubleClick"></param>
        private Palette AddPalette(BitmapCollection collection, RoutedCommand doubleClick = null)
        {
            Palette p = new Palette(collection);

            if (doubleClick != null)
            {
                p.DefaultDoubleClick = doubleClick;
            }
            p.OnThumbnailSelected += event_ThumbnailSelected;

            if (Palettes == null)
            {
                Palettes = new ObservableCollection <Palette>();
            }
            Palettes.Add(p);
            return(p);
        }
Ejemplo n.º 4
0
        // Read all palettes from ROM.
        private void ReadPalettes(Rom rom)
        {
            List <int> addressesPC = new List <int> ();

            foreach (TileSet t in TileSets)
            {
                int address = Tools.LRtoPC(t.PalettePtr);
                if (address != 0) // Skip invalid addresses
                {
                    addressesPC.Add(address);
                }
            }
            Tools.RemoveDuplicates(addressesPC);
            Palettes.Clear();
            for (int n = 0; n < addressesPC.Count; n++)
            {
                Palettes.Add(new CompressedPalette());
                Palettes [n].ReadFromROM(rom, addressesPC [n]);
            }
        }
Ejemplo n.º 5
0
        private void ReadPalettes(EndianReader reader)
        {
            var section = Sections[Section.Palettes];

            foreach (XmlNode paletteNode in section.Node.SelectNodes("*[@palette]"))
            {
                var paletteDef = new PaletteDefinition
                {
                    Name        = paletteNode.GetStringAttribute("palette"),
                    PaletteNode = paletteNode
                };

                var blockRef  = paletteDef.PaletteBlockRef = new BlockReference(paletteNode, reader, RootAddress);
                var refOffset = OffsetById(paletteNode, FieldId.TagReference);
                for (int i = 0; i < blockRef.TagBlock.Count; i++)
                {
                    reader.Seek(blockRef.TagBlock.Pointer.Address + blockRef.BlockSize * i + refOffset, SeekOrigin.Begin);
                    paletteDef.Palette.Add(reader.ReadObject <TagReference>());
                }

                Palettes.Add(paletteDef.Name, paletteDef);
            }
        }
Ejemplo n.º 6
0
        public PaletteSelector()
        {
            SetStyles();

            Grid mainGrid = new Grid();

            mainGrid.RowDefinitions.Add(new RowDefinition(0, GridUnitType.Auto));
            mainGrid.RowDefinitions.Add(new RowDefinition(0, GridUnitType.Auto));

            StackPanel headerPanel = new StackPanel()
            {
                Orientation = Avalonia.Layout.Orientation.Horizontal
            };

            mainGrid.Children.Add(headerPanel);

            headerPanel.Children.Add(new TextBlock()
            {
                Text = "Palette:", Margin = new Avalonia.Thickness(5), VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
            });

            List <string> paletteNames = (from el in Palettes select el.Name).ToList();

            int defaultIndex = DefaultIndex;

            if (Palette.CurrentPalette != null && Palettes.Contains(Palette.CurrentPalette))
            {
                defaultIndex = Palettes.IndexOf(Palette.CurrentPalette);
            }

            PaletteSelectorBox = new ComboBox()
            {
                Items = paletteNames, SelectedIndex = defaultIndex
            };
            headerPanel.Children.Add(PaletteSelectorBox);

            Canvas deleteCanvas = GetDeleteCanvas();

            deleteCanvas.Margin = new Thickness(5, 0, 0, 0);
            headerPanel.Children.Add(deleteCanvas);
            deleteCanvas.PointerPressed += (s, e) =>
            {
                Palette palette = Palettes[PaletteSelectorBox.SelectedIndex];
                if (File.Exists(palette.FileName))
                {
                    File.Delete(palette.FileName);
                }

                Palettes.Remove(palette);

                if (Palettes.Count == 0)
                {
                    string  id         = Guid.NewGuid().ToString("N");
                    Palette newPalette = new Palette("Custom", "A custom palette", Path.Combine(PaletteDirectory, id + ".palette"));
                    newPalette.Save();
                    Palettes.Add(newPalette);
                }

                List <string> _paletteNames = (from el in Palettes select el.Name).ToList();
                PaletteSelectorBox.Items         = _paletteNames;
                PaletteSelectorBox.SelectedIndex = 0;
            };

            Canvas saveCanvas = GetSaveCanvas();

            headerPanel.Children.Add(saveCanvas);
            saveCanvas.PointerPressed += (s, e) =>
            {
                Palettes[PaletteSelectorBox.SelectedIndex].Save();
            };

            Canvas addCanvas = GetAddCanvas();

            headerPanel.Children.Add(addCanvas);
            addCanvas.PointerPressed += async(s, e) =>
            {
                await AddButtonClicked();

                addCanvas.Classes.Remove("pressed");
            };

            PaletteDescription = new TextBlock()
            {
                FontStyle = FontStyle.Italic, Foreground = new SolidColorBrush(Color.FromRgb(128, 128, 128)), VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, Margin = new Thickness(5)
            };
            headerPanel.Children.Add(PaletteDescription);

            ScrollViewer paletteScroller = new ScrollViewer()
            {
                HorizontalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Auto, VerticalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled, HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Left, Margin = new Thickness(5)
            };

            Grid.SetRow(paletteScroller, 1);
            mainGrid.Children.Add(paletteScroller);

            ScrollerContainer = new Grid()
            {
                HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left
            };

            ScrollerContainer.Children.Add(BuildPaletteCanvas(Palettes[PaletteSelectorBox.SelectedIndex]));

            paletteScroller.Content = ScrollerContainer;
            PaletteDescription.Text = Palettes[PaletteSelectorBox.SelectedIndex].Description;

            PaletteSelectorBox.SelectionChanged += (s, e) =>
            {
                ScrollerContainer.Children.Clear();
                if (PaletteSelectorBox.SelectedIndex >= 0 && PaletteSelectorBox.SelectedIndex < Palettes.Count)
                {
                    Palette.CurrentPalette = Palettes[PaletteSelectorBox.SelectedIndex];
                    ScrollerContainer.Children.Add(BuildPaletteCanvas(Palettes[PaletteSelectorBox.SelectedIndex]));
                    PaletteDescription.Text = Palettes[PaletteSelectorBox.SelectedIndex].Description;
                }
                else
                {
                    Palette.CurrentPalette = null;
                }
            };

            if (PaletteSelectorBox.SelectedIndex >= 0 && PaletteSelectorBox.SelectedIndex < Palettes.Count)
            {
                Palette.CurrentPalette = Palettes[PaletteSelectorBox.SelectedIndex];
            }
            else
            {
                Palette.CurrentPalette = null;
            }

            this.Content = mainGrid;
        }
Ejemplo n.º 7
0
        private async Task AddButtonClicked()
        {
            Window win = new Window()
            {
                Title = "Create new palette"
            };

            win.Width  = 600;
            win.Height = 150;

            Grid mainGrid = new Grid()
            {
                Margin = new Thickness(10)
            };

            mainGrid.ColumnDefinitions.Add(new ColumnDefinition(0, GridUnitType.Auto));
            mainGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));
            mainGrid.RowDefinitions.Add(new RowDefinition(1, GridUnitType.Star));
            mainGrid.RowDefinitions.Add(new RowDefinition(1, GridUnitType.Star));
            mainGrid.RowDefinitions.Add(new RowDefinition(0, GridUnitType.Auto));

            TextBlock nameBlock = new TextBlock()
            {
                Text = "Name:", HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
            };

            mainGrid.Children.Add(nameBlock);

            TextBlock descriptionBlock = new TextBlock()
            {
                Text = "Description:", HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
            };

            Grid.SetRow(descriptionBlock, 1);
            mainGrid.Children.Add(descriptionBlock);

            TextBox nameBox = new TextBox()
            {
                VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, Margin = new Thickness(5, 0, 0, 0)
            };

            Grid.SetColumn(nameBox, 1);
            mainGrid.Children.Add(nameBox);

            TextBox descriptionBox = new TextBox()
            {
                VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, Margin = new Thickness(5, 0, 0, 0)
            };

            Grid.SetRow(descriptionBox, 1);
            Grid.SetColumn(descriptionBox, 1);
            mainGrid.Children.Add(descriptionBox);


            Grid buttonGrid = new Grid()
            {
                Margin = new Thickness(0, 10, 0, 0)
            };

            buttonGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));
            buttonGrid.ColumnDefinitions.Add(new ColumnDefinition(0, GridUnitType.Auto));
            buttonGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));
            buttonGrid.ColumnDefinitions.Add(new ColumnDefinition(0, GridUnitType.Auto));
            buttonGrid.ColumnDefinitions.Add(new ColumnDefinition(1, GridUnitType.Star));

            Grid.SetRow(buttonGrid, 2);
            Grid.SetColumnSpan(buttonGrid, 2);
            mainGrid.Children.Add(buttonGrid);

            Button okButton = new Button()
            {
                Content = "OK", Width = 100
            };

            Grid.SetColumn(okButton, 1);
            buttonGrid.Children.Add(okButton);

            Button cancelButton = new Button()
            {
                Content = "Cancel", Width = 100
            };

            Grid.SetColumn(cancelButton, 3);
            buttonGrid.Children.Add(cancelButton);

            bool result = false;

            cancelButton.Click += (s, e) =>
            {
                result = false;
                win.Close();
            };

            okButton.Click += (s, e) =>
            {
                result = true;
                win.Close();
            };

            win.Content = mainGrid;
            await win.ShowDialog(this.FindLogicalAncestorOfType <Window>());

            if (result)
            {
                string name        = nameBox.Text;
                string description = descriptionBox.Text;

                string id = Guid.NewGuid().ToString("N");

                Palette newPalette = new Palette(name, description, Path.Combine(PaletteDirectory, id + ".palette"));
                Palettes.Add(newPalette);
                List <string> paletteNames = (from el in Palettes select el.Name).ToList();
                PaletteSelectorBox.Items         = paletteNames;
                PaletteSelectorBox.SelectedIndex = Palettes.Count - 1;
            }
        }
Ejemplo n.º 8
0
 //Add a grid to the palette
 public void AddPalette(Grid pal)
 {
     Palettes.Add(pal);
 }
Ejemplo n.º 9
0
        private void ParseTIM(BinaryReader br, long baseP, int barPos)
        {
            br.BaseStream.Position = baseP + 8 + 4;
            int count          = br.ReadInt32();
            int offsetTableOff = br.ReadInt32();
            int dataOff        = br.ReadInt32();
            int mkImgOff       = br.ReadInt32();

            br.BaseStream.Position = baseP + offsetTableOff;
            var offs = new int[count];

            for (int i = 0; i < count; ++i)
            {
                offs[i] = br.ReadByte();
            }

            long palOffs, palPos = br.BaseStream.Position = baseP + dataOff + 32;

            byte[] palData = getDataR(br, baseP, out palOffs);

            for (int i = 0; i < count; ++i)
            {
                var info = new parsedImgData
                {
                    barFile  = barPos,
                    baseP    = baseP,
                    palBOffs = palPos
                };

                br.BaseStream.Position = info.imgBOffs = baseP + dataOff + 32 + 144 + (144 * offs[i]);
                byte[] imgData = getData(br, baseP);

                br.BaseStream.Position = baseP + mkImgOff + 32 + (160 * i) + 8;
                byte[] palette = new byte[1024];

                Bitmap img = getImage(br, ref imgData, palData, palOffs, info, out palette);

                bmps.Add(Convert(img));
                Palettes.Add(new Color[256]);

                for (int c = 0; c < 256; c++)
                {
                    int alpha = palette[c * 4 + 3] * 2;
                    if (alpha > 255)
                    {
                        alpha = 255;
                    }

                    Palettes[Palettes.Count - 1][c] = Color.FromArgb((byte)alpha, palette[c * 4], palette[c * 4 + 1], palette[c * 4 + 2]);
                }
                imgDatas.Add(info);
            }

            /*br.BaseStream.Position = 0;
             *
             * for (int dmyReach = 0; dmyReach+16 < br.BaseStream.Length; dmyReach += 16)
             * {
             *  br.BaseStream.Position = dmyReach;
             *
             *  if (br.ReadUInt32() == 0x594D445F)
             *  {
             *      br.BaseStream.Position = dmyReach + 0x0C;
             *      int nextPatch = br.ReadInt32();
             *
             *      br.BaseStream.Position = dmyReach + 0x12;
             *      int patchPalette = br.ReadUInt16();
             *
             *      br.BaseStream.Position = dmyReach + 0x1E;
             *      int patchCount = br.ReadUInt16();
             *
             *      br.BaseStream.Position = dmyReach + 0x20;
             *      int patchX = br.ReadUInt16();
             *      int patchY = br.ReadUInt16();
             *      int patchWidth = br.ReadUInt16();
             *      int patchHeight = br.ReadUInt16();
             *
             *      br.BaseStream.Position = dmyReach + 0x30;
             *      int patchStart = br.ReadInt32();
             *
             *      nextPatch += 16 + dmyReach;
             *      patchStart += 16 + dmyReach;
             *
             *      Bitmap patch = new Bitmap(patchWidth, patchHeight * patchCount);
             *      int patchSize = patchWidth * patchHeight * patchCount;
             *      byte[] patchPixels = new byte[patchSize];
             *
             *      br.BaseStream.Position = patchStart;
             *      br.BaseStream.Read(patchPixels, 0, patchPixels.Length);
             *
             *      for (int of = 0; of < patchSize; of++)
             *      {
             *          patch.SetPixel(of % patchWidth, of / patchWidth, Palettes[patchPalette][patchPixels[of]]);
             *      }
             *
             *      Patches.Add(patch);
             *      PatchesCounts.Add(patchCount);
             *      PatchesSizes.Add(new Size(patchWidth, patchHeight));
             *      PatchesPositions.Add(new Point(patchX, patchY));
             *      PatchesDestinations.Add(patchPalette);
             *  }
             * }*/
        }
Ejemplo n.º 10
0
        public GraphicProvider(GameData gameData, ExecutableData.ExecutableData executableData,
                               IntroData introData, OutroData outroData)
        {
            this.gameData = gameData;
            var graphicReader = new GraphicReader();

            Palettes = gameData.Files[paletteFile].Files.ToDictionary(f => f.Key, f => ReadPalette(graphicReader, f.Value));

            // Add builtin palettes
            for (int i = 0; i < 3; ++i)
            {
                Palettes.Add(50 + i, executableData.BuiltinPalettes[i]);
            }

            // And another palette for some UI graphics.
            // The portraits have a blue gradient as background. It is also 32x34 pixels in size and the gradient
            // is in y-direction. All colors have R=0x00 and G=0x11. The blue component is increased by 0x11
            // every 2 pixels starting at y=4 (first 4 pixel rows have B=0x00, next 2 have B=0x11, etc).
            // Last 2 rows have B=0xff.
            Palettes.Add(53, new Graphic
            {
                Width          = 32,
                Height         = 1,
                IndexedGraphic = false,
                Data           = new byte[]
                {
                    // The first colors are used for spells which use a materialize animation (earth and wind spells, waterfall, etc).
                    // The animation uses black, dark red, light purple, dark purple, dark beige, light beige in that order.
                    // We start with these color at offset 1. We leave the first color as fully transparent.
                    // Index 7 is unused.
                    0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0xff, 0x33, 0x11, 0x00, 0xff, 0x88, 0x77, 0xaa, 0xff,
                    0x66, 0x55, 0x88, 0xff, 0x99, 0x88, 0x77, 0xff, 0xbb, 0xbb, 0x99, 0xff, 0x00, 0x00, 0x00, 0x00,
                    // 16 colors for the blue background gradient of portraits
                    0x00, 0x11, 0x00, 0xff, 0x00, 0x11, 0x11, 0xff, 0x00, 0x11, 0x22, 0xff, 0x00, 0x11, 0x33, 0xff,
                    0x00, 0x11, 0x44, 0xff, 0x00, 0x11, 0x55, 0xff, 0x00, 0x11, 0x66, 0xff, 0x00, 0x11, 0x77, 0xff,
                    0x00, 0x11, 0x88, 0xff, 0x00, 0x11, 0x99, 0xff, 0x00, 0x11, 0xaa, 0xff, 0x00, 0x11, 0xbb, 0xff,
                    0x00, 0x11, 0xcc, 0xff, 0x00, 0x11, 0xdd, 0xff, 0x00, 0x11, 0xee, 0xff, 0x00, 0x11, 0xff, 0xff,
                    // some UI colors (TODO: character with ailment?)
                    0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x55, 0xff, 0x44, 0x44, 0x33, 0xff,
                    0x22, 0x22, 0x22, 0xff, 0x88, 0x88, 0x77, 0xff, 0xaa, 0xaa, 0x99, 0xff, 0xcc, 0xcc, 0xbb, 0xff
                }
            });

            // Add the 9 intro palettes
            int introPaletteCount = introData == null ? 0 : Math.Min(9, introData.IntroPalettes.Count);
            int p = 0;

            for (; p < introPaletteCount; ++p)
            {
                Palettes.Add(54 + p, introData.IntroPalettes[p]);
            }
            for (; p < 9; ++p)
            {
                Palettes.Add(54 + p, new Graphic
                {
                    Width          = 32,
                    Height         = 1,
                    IndexedGraphic = false,
                    Data           = new byte[32 * 4]
                });
            }

            // Add the 6 outro palettes
            int outroPaletteCount = outroData == null ? 0 : Math.Min(6, outroData.OutroPalettes.Count);

            p = 0;
            for (; p < outroPaletteCount; ++p)
            {
                Palettes.Add(63 + p, outroData.OutroPalettes[p]);
            }
            for (; p < 6; ++p)
            {
                Palettes.Add(63 + p, new Graphic
                {
                    Width          = 32,
                    Height         = 1,
                    IndexedGraphic = false,
                    Data           = new byte[32 * 4]
                });
            }

            foreach (var type in Enum.GetValues <GraphicType>())
            {
                if (type == GraphicType.Cursor)
                {
                    var cursorGraphics = graphics[GraphicType.Cursor] = new List <Graphic>();

                    foreach (var cursor in executableData.Cursors.Entries)
                    {
                        cursorGraphics.Add(cursor.Graphic);
                    }
                }
                else if (type == GraphicType.UIElements)
                {
                    graphics[type] = UIElementProvider.Create();
                    graphics[type].AddRange(executableData.UIGraphics.Entries.Values);
                    graphics[type].AddRange(executableData.Buttons.Entries.Values);
                }
                else if (type == GraphicType.TravelGfx)
                {
                    graphics[type] = gameData.TravelGraphics;
                }
                else if (type == GraphicType.Transports)
                {
                    var reader = gameData.Files["Stationary"].Files[1];
                    reader.Position = 0;
                    graphics[type]  = gameData.StationaryImageInfos.Select(info =>
                    {
                        var graphic = new Graphic();
                        graphicReader.ReadGraphic(graphic, reader, info.Value);
                        return(graphic);
                    }).ToList();
                }
                else if (type == GraphicType.NPC)
                {
                    var npcGraphics = new List <Graphic>(34);
                    var graphicInfo = new GraphicInfo
                    {
                        Width         = 16,
                        Height        = 32,
                        GraphicFormat = GraphicFormat.Palette5Bit,
                        Alpha         = true,
                        PaletteOffset = 0
                    };
                    var graphic = new Graphic();
                    foreach (var file in gameData.Files["NPC_gfx.amb"].Files)
                    {
                        NPCGraphicOffsets.Add(file.Key, npcGraphics.Count);
                        var reader = file.Value;
                        reader.Position = 0;

                        while (reader.Position <= reader.Size - graphicInfo.DataSize)
                        {
                            int numFrames = reader.ReadByte();
                            reader.AlignToWord();
                            var compoundGraphic = new Graphic(16 * numFrames, 32, 0);

                            for (int i = 0; i < numFrames; ++i)
                            {
                                graphicReader.ReadGraphic(graphic, reader, graphicInfo);
                                compoundGraphic.AddOverlay((uint)i * 16, 0, graphic, false);
                            }

                            npcGraphics.Add(compoundGraphic);
                        }
                    }

                    graphics[type] = npcGraphics;
                }
                else if (type == GraphicType.CombatGraphics)
                {
                    var combatGraphics = new List <Graphic>(42);
                    var graphicInfo    = new GraphicInfo
                    {
                        GraphicFormat = GraphicFormat.Palette5Bit,
                        Alpha         = true,
                        PaletteOffset = 0
                    };
                    var reader = gameData.Files["Combat_graphics"].Files[1];
                    reader.Position = 0;

                    foreach (var combatGraphic in CombatGraphics.Info)
                    {
                        var info = combatGraphic.Value;

                        if (combatGraphic.Key == CombatGraphicIndex.BattleFieldIcons)
                        {
                            var battleFieldIcons = new List <Graphic>(35);
                            var iconGraphicInfo  = new GraphicInfo
                            {
                                Width         = 16,
                                Height        = 14,
                                GraphicFormat = GraphicFormat.Palette5Bit,
                                Alpha         = true,
                                PaletteOffset = 0
                            };

                            for (int i = 0; i < 35; ++i)
                            {
                                var graphic = new Graphic();
                                graphicReader.ReadGraphic(graphic, reader, iconGraphicInfo);
                                battleFieldIcons.Add(graphic);
                            }

                            graphics[GraphicType.BattleFieldIcons] = battleFieldIcons;
                        }
                        else
                        {
                            var graphic         = new Graphic();
                            var compoundGraphic = new Graphic((int)info.FrameCount * info.GraphicInfo.Width, info.GraphicInfo.Height, 0);

                            for (int i = 0; i < info.FrameCount; ++i)
                            {
                                graphicReader.ReadGraphic(graphic, reader, info.GraphicInfo);
                                compoundGraphic.AddOverlay((uint)(i * info.GraphicInfo.Width), 0, graphic, false);
                            }

                            combatGraphics.Add(compoundGraphic);
                        }
                    }

                    graphics[type] = combatGraphics;
                }
                else if (type == GraphicType.BattleFieldIcons)
                {
                    // Do nothing. This is filled when processing GraphicType.CombatGraphics.
                }
                else if (type == GraphicType.RiddlemouthGraphics)
                {
                    var riddlemouthGraphics = new List <Graphic>(4 + 7);
                    var reader = gameData.Files["Riddlemouth_graphics"].Files[1];
                    reader.Position = 0;
                    // 4 eye frames
                    ReadAndAddGraphics(4, 48, 9);
                    // 7 mouth frames
                    ReadAndAddGraphics(7, 48, 15);
                    void ReadAndAddGraphics(int frames, int width, int height)
                    {
                        var graphicInfo = new GraphicInfo
                        {
                            Width         = width,
                            Height        = height,
                            GraphicFormat = GraphicFormat.Palette3Bit,
                            Alpha         = false,
                            PaletteOffset = 24
                        };
                        var graphic         = new Graphic();
                        var compoundGraphic = new Graphic(frames * width, height, 0);

                        for (int f = 0; f < frames; ++f)
                        {
                            graphicReader.ReadGraphic(graphic, reader, graphicInfo);
                            compoundGraphic.AddOverlay((uint)(f * width), 0, graphic, false);
                        }
                        riddlemouthGraphics.Add(compoundGraphic);
                    }

                    graphics[type] = riddlemouthGraphics;
                }
                else if (type == GraphicType.AutomapGraphics)
                {
                    var automapGraphics = new List <Graphic>(43);
                    var reader          = gameData.Files["Automap_graphics"].Files[1];
                    reader.Position = 0x100; // TODO: maybe decode the bytes before that later

                    void ReadAndAddGraphics(int amount, int width, int height, GraphicFormat graphicFormat,
                                            int frames = 1, bool alpha = false)
                    {
                        var graphicInfo = new GraphicInfo
                        {
                            Width         = width,
                            Height        = height,
                            GraphicFormat = graphicFormat,
                            Alpha         = alpha,
                            PaletteOffset = 0
                        };

                        for (int i = 0; i < amount; ++i)
                        {
                            Graphic graphic = new Graphic();
                            if (frames == 1)
                            {
                                graphicReader.ReadGraphic(graphic, reader, graphicInfo);
                            }
                            else
                            {
                                var compoundGraphic = new Graphic(frames * width, height, 0);

                                for (int f = 0; f < frames; ++f)
                                {
                                    graphicReader.ReadGraphic(graphic, reader, graphicInfo);
                                    compoundGraphic.AddOverlay((uint)(f * width), 0, graphic, false);
                                }

                                graphic = compoundGraphic;
                            }
                            automapGraphics.Add(graphic);
                        }
                    }

                    // Map corners
                    ReadAndAddGraphics(4, 32, 32, GraphicFormat.Palette3Bit);
                    // Top map border
                    ReadAndAddGraphics(4, 16, 32, GraphicFormat.Palette3Bit);
                    // Right map border
                    ReadAndAddGraphics(2, 32, 32, GraphicFormat.Palette3Bit);
                    // Bottom map border
                    ReadAndAddGraphics(4, 16, 32, GraphicFormat.Palette3Bit);
                    // Left map border
                    ReadAndAddGraphics(2, 32, 32, GraphicFormat.Palette3Bit);
                    // 10 pin graphics
                    ReadAndAddGraphics(10, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Riddlemouth (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Teleport (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Spinner (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Trap (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Trapdoor (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Special (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Monster (4 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 4, true);
                    // Door closed (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Door open (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Merchant (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Inn (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Chest closed (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Exit (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Chest open (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Pile (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Person (1 frame)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 1, true);
                    // Goto point (7 frames)
                    ReadAndAddGraphics(1, 16, 16, GraphicFormat.Palette5Bit, 7, true);

                    graphics[type] = automapGraphics;
                }
                else
                {
                    LoadGraphics(type);
                }
            }
        }