Exemplo n.º 1
0
        protected override ResourceFile OpenRoom(byte roomIndex)
        {
            var diskNum = Index.RoomResources[roomIndex].RoomNum;
            var diskName = Game.Pattern == null ? string.Format("{0}.{1:000}", Game.Id, diskNum) : string.Format(Game.Pattern, diskNum);
            var game1Path = ScummHelper.NormalizePath(ServiceLocator.FileStorage.Combine(Directory, diskName));

            var file = new ResourceFile7(ServiceLocator.FileStorage.OpenFileRead(game1Path));
            return file;
        }
Exemplo n.º 2
0
        public void SetCostume(int costume, int shadow)
        {
            akos = _vm.ResourceManager.GetCostumeData(costume);
            Debug.Assert(akos != null);

            akhd   = ResourceFile7.ReadData <AkosHeader>(akos, "AKHD");
            akof   = ResourceFile7.FindOffset(akos, "AKOF");
            akci   = ResourceFile7.FindOffset(akos, "AKCI");
            aksq   = ResourceFile7.ReadData(akos, "AKSQ");
            akcd   = ResourceFile7.ReadData(akos, "AKCD");
            akpl   = ResourceFile7.ReadData(akos, "AKPL");
            _codec = akhd.codec;
//            akct = ResourceFile7.ReadData(akos,"AKCT");
//            rgbs = ResourceFile7.ReadData(akos,"RGBS");

//            xmap = 0;
//            if (shadow) {
//                const byte *xmapPtr = _vm.getResourceAddress(rtImage, shadow);
//                Debug.Assert(xmapPtr);
//                xmap = ResourceFile7.ReadData(akos,'X','M','A','P'), xmapPtr);
//                Debug.Assert(xmap);
//            }
        }
Exemplo n.º 3
0
        byte DrawLimb(Actor a, int limb)
        {
            var  cost   = a.Cost;
            byte result = 0;

            var lastDx = 0;
            var lastDy = 0;

            if (SkipLimbs)
            {
                return(0);
            }

            if (cost.Active[limb] == 0 || ((cost.Stopped & (1 << limb)) != 0))
            {
                return(0);
            }

            var p = cost.Curpos[limb];

            AkosOpcode code = (AkosOpcode)aksq[p];

            if (((ushort)code & 0x80) != 0)
            {
                code = (AkosOpcode)ScummHelper.SwapBytes(BitConverter.ToUInt16(aksq, p));
            }


            if (code == AkosOpcode.C021 || code == AkosOpcode.C022)
            {
                ushort s     = (ushort)(cost.Curpos[limb] + 4);
                var    extra = aksq[p + 3];
                byte   n     = extra;
                p   += (ushort)(extra + 2);
                code = (code == AkosOpcode.C021) ? AkosOpcode.ComplexChan : AkosOpcode.ComplexChan2;
            }

            if (code == AkosOpcode.Return || code == AkosOpcode.EndSeq)
            {
                return(0);
            }

            if (code != AkosOpcode.ComplexChan && code != AkosOpcode.ComplexChan2)
            {
                var off = ResourceFile7.ToStructure <AkosOffset>(akos, (int)(akof + 6 * ((ushort)code & 0xFFF)));

                Debug.Assert(((ushort)code & 0xFFF) * 6 < ScummHelper.SwapBytes(BitConverter.ToUInt32(akos, (int)(akof - 4))) - 8);
                Debug.Assert(((ushort)code & 0x7000) == 0);

                _srcptr = (int)off.akcd;
                Debug.Assert(_srcptr < akcd.Length);
                var costumeInfo = ResourceFile7.ToStructure <CostumeInfo>(akos, (int)(akci + off.akci));

                _width  = costumeInfo.width;
                _height = costumeInfo.height;
                var xmoveCur = _xmove + costumeInfo.rel_x;
                var ymoveCur = _ymove + costumeInfo.rel_y;
                _xmove += costumeInfo.move_x;
                _ymove -= costumeInfo.move_y;

                switch (_codec)
                {
                case 1:
                    result |= Codec1(xmoveCur, ymoveCur);
                    break;

                case 5:
                    result |= Codec5(xmoveCur, ymoveCur);
                    break;

                case 16:
                    result |= Codec16(xmoveCur, ymoveCur);
                    break;

                default:
                    throw new InvalidOperationException(string.Format("akos_drawLimb: invalid _codec {0}", _codec));
                }
            }
            else
            {
                if (code == AkosOpcode.ComplexChan2)
                {
                    lastDx = BitConverter.ToInt16(aksq, p + 2);
                    lastDy = BitConverter.ToInt16(aksq, p + 4);
                    p     += 4;
                }

                var extra = aksq[p + 2];
                p += 3;

                for (var i = 0; i != extra; i++)
                {
                    code = (AkosOpcode)aksq[p + 4];
                    if (((ushort)code & 0x80) != 0)
                    {
                        code = (AkosOpcode)ScummHelper.SwapBytes(BitConverter.ToUInt16(aksq, p + 4));
                    }
                    var off = ResourceFile7.ToStructure <AkosOffset>(akos, (int)(akof + 6 * ((ushort)code & 0xFFF)));

                    _srcptr = (int)off.akcd;
                    var costumeInfo = ResourceFile7.ToStructure <CostumeInfo>(akos, (int)(akci + off.akci));

                    _width  = costumeInfo.width;
                    _height = costumeInfo.height;

                    var xmoveCur = _xmove + BitConverter.ToInt16(aksq, p + 0);
                    var ymoveCur = _ymove + BitConverter.ToInt16(aksq, p + 2);

                    if (i == extra - 1)
                    {
                        _xmove += lastDx;
                        _ymove -= lastDy;
                    }

                    p += ((aksq[p + 4] & 0x80) != 0) ? (ushort)6 : (ushort)5;

                    switch (_codec)
                    {
                    case 1:
                        result |= Codec1(xmoveCur, ymoveCur);
                        break;

                    case 5:
                        result |= Codec5(xmoveCur, ymoveCur);
                        break;

                    case 16:
                        result |= Codec16(xmoveCur, ymoveCur);
                        break;

                    case 32:
                        result |= Codec32(xmoveCur, ymoveCur);
                        break;

                    default:
                        throw new InvalidOperationException(string.Format("akos_drawLimb: invalid _codec {0}", _codec));
                    }
                }
            }

            return(result);
        }