Esempio n. 1
0
        public SCUMM1ResourceMap GetResourceMap()
        {
            if (resourceMap != null)
            {
                return(resourceMap);
            }
            int room = RoomNumber;

            ushort objectCount = 0;
            byte   roomCount   = 0;
            byte   costCount   = 0;
            byte   scriptCount = 0;
            byte   soundCount  = 0;

            switch (FileVersion)
            {
            case 1:
                // Maniac Mansion
                // TODO: Zak
                objectCount = 0x320;
                roomCount   = 0x37;
                costCount   = 0x23;
                scriptCount = 0xC8;
                soundCount  = 0x64;
                break;

            case 2:
                break;
            }

            SCUMM1ResourceMap map = new SCUMM1ResourceMap();

            using (SCUMM1File file = OpenDirectory(Path))
            {
                file.Encryption = Encryption;
                // Skip magic number
                file.Position = 2;

                // Skip objects - 1 byte per object
                if (objectCount == 0)
                {
                    objectCount = file.ReadU16LE();
                }
                file.Position += objectCount;

                // Skip rooms - 3 bytes per room
                if (roomCount == 0)
                {
                    roomCount = file.ReadU8();
                }
                file.Position += (ulong)roomCount * 3;

                ReadResourceMap(SCUMM1ResourceType.Costume, map, file, room, costCount);
                ReadResourceMap(SCUMM1ResourceType.Script, map, file, room, scriptCount);
                ReadResourceMap(SCUMM1ResourceType.Sound, map, file, room, soundCount);

                resourceMap = map;
                return(map);
            }
        }
Esempio n. 2
0
        private void ReadResourceMap(SCUMM1ResourceType type, SCUMM1ResourceMap map, SCUMM1File file, int room, uint count)
        {
            if (count == 0)
            {
                count = file.ReadU8();
            }
            byte[]   roomNos = new byte[count];
            ushort[] offsets = new ushort[count];
            file.Read(roomNos, 0, count);
            for (int i = 0; i < count; i++)
            {
                offsets[i] = file.ReadU16LE();
            }

            for (int i = 0; i < count; i++)
            {
                if (room == roomNos[i])
                {
                    map.Add(offsets[i], type);
                }
            }
        }