GetRoomDisk() public method

public GetRoomDisk ( byte res ) : int
res byte
return int
Ejemplo n.º 1
0
        public static Stream CreateResource(ResourceIndex0 index, byte resourceNumber)
        {
            var roomDisk = index.GetRoomDisk(resourceNumber);
            var disk = string.Format(index.Game.Pattern, roomDisk);
            var directory = ServiceLocator.FileStorage.GetDirectoryName(index.Game.Path);
            var path = ServiceLocator.FileStorage.OpenFileRead(ScummHelper.LocatePath(directory, disk));
            var br = new BinaryReader(path);

            if (index.Game.Platform == Platform.Apple2GS)
            {
                br.BaseStream.Seek(roomDisk == 1 ? 142080 : 143104, SeekOrigin.Begin);
            }

            var signature = br.ReadUInt16();
            if (roomDisk == 1 && signature != 0x0A31)
                throw new NotSupportedException(string.Format("Invalid signature '{0:X}' in disk 1", signature));
            var signatureExpected = index.Game.Platform == Platform.Apple2GS ? 0x0032 : 0x0132;
            if (roomDisk == 2 && signature != signatureExpected)
                throw new NotSupportedException(string.Format("Invalid signature '{0:X}' in disk 2", signature));

            int numResources;
            if (index.Game.GameId == GameId.Maniac)
            {
                if (index.Game.Features.HasFlag(GameFeatures.Demo))
                {
                    numResources = maniacDemoResourcesPerFile[resourceNumber];
                }
                else
                {
                    numResources = maniacResourcesPerFile[resourceNumber];
                }
            }
            else
            {
                numResources  = zakResourcesPerFile[resourceNumber];
            }

            // read resources
            var ms = new MemoryStream();
            var bw = new BinaryWriter(ms);
            var resourceOffset = index.GetResourceOffset(resourceNumber);
            br.BaseStream.Seek(resourceOffset, SeekOrigin.Begin);
            for (var i = 0; i < numResources; i++)
            {
                var size = br.ReadUInt16();
                bw.Write(size);
                if (size > 0)
                {
                    bw.Write(br.ReadBytes(size - 2));
                }
            }
            ms.Seek(0, SeekOrigin.Begin);
            return ms;
        }
Ejemplo n.º 2
0
        public static Stream CreateResource(ResourceIndex0 index, byte resourceNumber)
        {
            var roomDisk  = index.GetRoomDisk(resourceNumber);
            var disk      = string.Format(index.Game.Pattern, roomDisk);
            var directory = ServiceLocator.FileStorage.GetDirectoryName(index.Game.Path);
            var path      = ServiceLocator.FileStorage.OpenFileRead(ScummHelper.LocatePath(directory, disk));
            var br        = new BinaryReader(path);

            if (index.Game.Platform == Platform.Apple2GS)
            {
                br.BaseStream.Seek(roomDisk == 1 ? 142080 : 143104, SeekOrigin.Begin);
            }

            var signature = br.ReadUInt16();

            if (roomDisk == 1 && signature != 0x0A31)
            {
                throw new NotSupportedException(string.Format("Invalid signature '{0:X}' in disk 1", signature));
            }
            var signatureExpected = index.Game.Platform == Platform.Apple2GS ? 0x0032 : 0x0132;

            if (roomDisk == 2 && signature != signatureExpected)
            {
                throw new NotSupportedException(string.Format("Invalid signature '{0:X}' in disk 2", signature));
            }

            int numResources;

            if (index.Game.GameId == GameId.Maniac)
            {
                if (index.Game.Features.HasFlag(GameFeatures.Demo))
                {
                    numResources = maniacDemoResourcesPerFile[resourceNumber];
                }
                else
                {
                    numResources = maniacResourcesPerFile[resourceNumber];
                }
            }
            else
            {
                numResources = zakResourcesPerFile[resourceNumber];
            }

            // read resources
            var ms             = new MemoryStream();
            var bw             = new BinaryWriter(ms);
            var resourceOffset = index.GetResourceOffset(resourceNumber);

            br.BaseStream.Seek(resourceOffset, SeekOrigin.Begin);
            for (var i = 0; i < numResources; i++)
            {
                var size = br.ReadUInt16();
                bw.Write(size);
                if (size > 0)
                {
                    bw.Write(br.ReadBytes(size - 2));
                }
            }
            ms.Seek(0, SeekOrigin.Begin);
            return(ms);
        }