Exemplo n.º 1
0
        public static byte[] BackgroundToIntermediateFormat(room r)             //not dead code! This is used by external projects to get an RGBA32 image byte array instead of a Bitmap (in case they can't use System.Drawing)
        {
            byte[] output = new byte[r.background.Width * r.background.Height * 4];

            int pos = 0;

            for (int y = 0; y < r.background.Height; y++)
            {
                for (int x = 0; x < r.background.Width; x++)
                {
                    output[pos] = r.background.GetPixel(x, y).R;
                    pos++;
                    output[pos] = r.background.GetPixel(x, y).G;
                    pos++;
                    output[pos] = r.background.GetPixel(x, y).B;
                    pos++;
                    output[pos] = r.background.GetPixel(x, y).A;
                    pos++;
                }
            }

            return(output);
        }
Exemplo n.º 2
0
        public static void LoadRoom(int index)
        {
            ushort CurrentRoomID = rom.roomIDList[index];

            if (!Dictionaries.IDsAndRooms.Keys.Contains(CurrentRoomID))
            {
                room newRoom = new room();
                rom.CurrentRoom = newRoom;

                newRoom.offset = rom.roomIDList[index];
                newRoom.name   = Dictionaries.RoomIDsAndNames[newRoom.offset];

                newRoom.objectListOffset     = utility.ConvertToPCOffset(utility.Read3Bytes(rom.filebytes, newRoom.offset + 0x1C));
                newRoom.objectListLastOffset = utility.ConvertToPCOffset(utility.Read3Bytes(rom.filebytes, newRoom.offset + 0x22));

                int currentOffset = newRoom.offset = rom.roomIDList[index];

                int backgroundTilesValue = BitConverter.ToUInt16(rom.filebytes, currentOffset);

                currentOffset += 0x1C;

                newRoom.objectListOffset     = (uint)utility.GetPCOffset(rom.filebytes, currentOffset);
                currentOffset               += 0x03;
                currentOffset               += 0x03; //skip an identical offset (although... is it always identical?)
                newRoom.objectListLastOffset = (uint)utility.GetPCOffset(rom.filebytes, currentOffset);
                currentOffset               += 0x03;

                currentOffset = newRoom.offset + 0x2B;
                newRoom.foregroundSpritePalettesOffset = utility.GetPCOffset(rom.filebytes, currentOffset);

                currentOffset = newRoom.foregroundSpritePalettesOffset;

                newRoom.foreground_palettes = new Palette[8];

                newRoom.foreground_palettes[0] = new Palette(); //idk how this one should be written. it seemingly doesn't have an entry here

                //now for the actual entries
                newRoom.foreground_palettes[1] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]);
                currentOffset++;

                newRoom.foreground_palettes[2] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]);
                currentOffset++;

                newRoom.foreground_palettes[3] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]);
                currentOffset++;

                newRoom.foreground_palettes[4] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]);
                currentOffset++;

                newRoom.foreground_palettes[5] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]);
                currentOffset++;

                newRoom.foreground_palettes[6] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]); //usually used for scissorman
                currentOffset++;

                Console.WriteLine("begin reading foreground palette with index 7");
                newRoom.foreground_palettes[7] = imageTools.GetPaletteWithIndex(rom.filebytes, rom.filebytes[currentOffset]); //usually used for jennifer
                currentOffset++;


                int backgroundTileGraphicsValue = BitConverter.ToUInt16(rom.filebytes, newRoom.offset + 0x0C);
                int backgroundPaletteValue      = BitConverter.ToUInt16(rom.filebytes, newRoom.offset + 0x0E);
                Console.WriteLine(backgroundPaletteValue);

                newRoom.LoadBackgroundPalette(backgroundPaletteValue);
                newRoom.LoadBackgroundTileMap(backgroundTilesValue);
                newRoom.LoadBackgroundTileGraphics(backgroundTileGraphicsValue);

                newRoom.LoadRoomObjects();

                Dictionaries.IDsAndRooms.Add(CurrentRoomID, newRoom);
            }
            else
            {
                rom.CurrentRoom = Dictionaries.IDsAndRooms[CurrentRoomID];
            }

            if (rom.isStandaloneCradle)
            {
                form1.pictureBox1.Image = rom.CurrentRoom.background;

                form1.RoomOffsetLabel.Text = "Offset (d): " + rom.roomIDList[form1.RoomListBox.SelectedIndex];

                form1.numericUpDown1.Maximum = rom.CurrentRoom.objects.Count - 1;
                form1.numericUpDown1.Minimum = 0;

                form1.numericUpDown1.Value = form1.numericUpDown1.Minimum;
                form1.UpdateObjectPanel();
            }
        }