Пример #1
0
        public GetObjectRequest(BinaryReader br)
        {
            this.searchType = (SearchType)br.ReadInt32();
            if (searchType == SearchType.Path)
            {
                this.objectPath = br.ReadString();
            }
            else if (searchType == SearchType.ObjectGUID)
            {
                this.guid = new Guid(br.ReadString());
            }
            else
            {
                throw new NotImplementedException(searchType + " not implemented");
            }

            this.flags = (InfoFlags)br.ReadInt32();
        }
Пример #2
0
                private void _read()
                {
                    __raw_flags = m_io.ReadBytes(1);
                    var io___raw_flags = new KaitaiStream(__raw_flags);

                    _flags = new InfoFlags(io___raw_flags, this, m_root);
                    if (Flags.HasModTime)
                    {
                        _modTime = m_io.ReadU4le();
                    }
                    if (Flags.HasAccessTime)
                    {
                        _accessTime = m_io.ReadU4le();
                    }
                    if (Flags.HasCreateTime)
                    {
                        _createTime = m_io.ReadU4le();
                    }
                }
Пример #3
0
        public static byte StudioVersion(this InfoFlags flags)
        {
            flags &= InfoFlags.StudioVersionMask;

            byte r = 0;

            if ((flags & InfoFlags.StudioVersionB1) != 0)
            {
                r |= 1;
            }
            if ((flags & InfoFlags.StudioVersionB2) != 0)
            {
                r |= 2;
            }
            if ((flags & InfoFlags.StudioVersionB3) != 0)
            {
                r |= 4;
            }

            return(r);
        }
 public GetGameObjectRequest(BinaryReader br)
 {
     this.gameObjectPath   = br.ReadString();
     this.flags            = (InfoFlags)br.ReadInt32();
     this.includeInherited = br.ReadBoolean();
 }
 public GetGameObjectRequest(string gameObjectPath, InfoFlags flags, bool includeInherited)
 {
     this.gameObjectPath   = gameObjectPath;
     this.flags            = flags;
     this.includeInherited = includeInherited;
 }
Пример #6
0
        public Cartridge(string filePath, SystemBus bus)
        {
            using (BinaryReader reader = new BinaryReader(new FileStream(filePath, FileMode.Open)))
            {
                if (reader.BaseStream.Length < 16)
                {
                    return;
                }

                byte[] header = reader.ReadBytes(16);
                if (header[0] != 'N' || header[1] != 'E' || header[2] != 'S' || header[3] != 0x1A)
                {
                    return;
                }

                byte   mapperId = (byte)((header[7] & 0xF0) | (header[6] >> 4));
                byte   chrBankCount;
                ushort prgBankCount;
                if ((header[7] & 0x0C) != 0x08)
                {
                    // v1 format
                    prgBankCount = header[4];
                    chrBankCount = header[5];
                    info         = (InfoFlags)(header[6] & 0x0F);
                    timing       = (Timing)(header[9] & 0x01);
                }
                else
                {
                    // v2 format
                    prgBankCount = (ushort)(((header[9] & 0x0F) << 8) | header[4]);
                    chrBankCount = header[5];
                    info         = (InfoFlags)(header[6] & 0x0F);
                    timing       = (Timing)(header[12] & 0x03);
                }

                if (timing != Timing.NTSC)
                {
                    Console.WriteLine("WARNING: Loaded non-NTSC ROM");
                }

                //if (info.HasFlag(InfoFlags.Trainer))
                //{
                //    trainerData = new byte[512];
                //    reader.Read(trainerData, 0, trainerData.Length);
                //}

                int prgSize = prgBankCount * Utils.Kilo16;
                prgData = new byte[prgSize];
                int countRead = reader.Read(prgData, 0, prgSize);
                Debug.Assert(countRead == prgSize);

                int chrSize = chrBankCount * Utils.Kilo8;
                chrData   = new byte[chrSize];
                countRead = reader.Read(chrData, 0, chrSize);
                Debug.Assert(countRead == chrSize);

                if (chrSize == 0)
                {
                    chrData = new byte[Utils.Kilo8]; // Cartridge has RAM?
                }
                MirrorMode cartMirrorMode = info.HasFlag(InfoFlags.Mirroring) ? MirrorMode.Vertical : MirrorMode.Horizontal;
                if (mapperId == 0)
                {
                    // Fix some simple incorrect mapping IDs
                    if (chrBankCount > 1)
                    {
                        mapperId = 3;
                    }
                    else if (prgBankCount > 2)
                    {
                        mapperId = 2;
                    }
                }

                switch (mapperId)
                {
                case 0: mapper = new Mapper000(prgBankCount, chrBankCount, cartMirrorMode); break;

                case 1: mapper = new Mapper001(prgBankCount, chrBankCount, cartMirrorMode, info); break;

                case 2: mapper = new Mapper002(prgBankCount, chrBankCount, cartMirrorMode); break;

                case 3: mapper = new Mapper003(prgBankCount, chrBankCount, cartMirrorMode); break;

                case 4: mapper = new Mapper004(prgBankCount, chrBankCount, cartMirrorMode, bus); break;

                default:
                    throw new NotImplementedException("Mapper " + mapperId + " is not implemented");
                }
            }
        }
Пример #7
0
 public GetObjectRequest(Guid objectGuid, InfoFlags flags)
 {
     this.searchType = SearchType.ObjectGUID;
     this.guid       = objectGuid;
     this.flags      = flags;
 }
Пример #8
0
 public GetObjectRequest(string objectPath, InfoFlags flags)
 {
     this.searchType = SearchType.Path;
     this.objectPath = objectPath;
     this.flags      = flags;
 }
Пример #9
0
 public bool IsDodged()
 {
     return(InfoFlags.HasFlag(DamageInfoFlags.Dodged));
 }
Пример #10
0
        public override void Unserialize(GMDataReader reader)
        {
            base.Unserialize(reader);

            DisableDebug = reader.ReadBoolean();
            FormatID     = reader.ReadByte();
            reader.VersionInfo.FormatID = FormatID;
            Unknown      = reader.ReadInt16();
            Filename     = reader.ReadStringPointerObject();
            Config       = reader.ReadStringPointerObject();
            LastObjectID = reader.ReadInt32();
            LastTileID   = reader.ReadInt32();
            GameID       = reader.ReadInt32();
            LegacyGUID   = new Guid(reader.ReadBytes(16).Memory.ToArray());
            GameName     = reader.ReadStringPointerObject();
            Major        = reader.ReadInt32();
            Minor        = reader.ReadInt32();
            Release      = reader.ReadInt32();
            Build        = reader.ReadInt32();
            reader.VersionInfo.SetNumber(Major, Minor, Release, Build);
            DefaultWindowWidth  = reader.ReadInt32();
            DefaultWindowHeight = reader.ReadInt32();
            Info                    = (InfoFlags)reader.ReadUInt32();
            LicenseCRC32            = reader.ReadInt32();
            LicenseMD5              = reader.ReadBytes(16);
            Timestamp               = reader.ReadInt64();
            DisplayName             = reader.ReadStringPointerObject();
            ActiveTargets           = reader.ReadInt64();
            FunctionClassifications = (FunctionClassification)reader.ReadUInt64();
            SteamAppID              = reader.ReadInt32();
            if (FormatID >= 14)
            {
                DebuggerPort = reader.ReadInt32();
            }

            int count = reader.ReadInt32();

            RoomOrder = new List <int>(count);
            for (int i = 0; i < count; i++)
            {
                RoomOrder.Add(reader.ReadInt32());
            }

            if (reader.VersionInfo.Major >= 2)
            {
                // Begin parsing random UID, and verify it based on original algorithm
                GMS2_RandomUID = new List <long>();

                Random random      = new Random((int)(Timestamp & 4294967295L));
                long   firstRandom = (long)random.Next() << 32 | (long)random.Next();
                if (reader.ReadInt64() != firstRandom)
                {
                    reader.Warnings.Add(new GMWarning("Unexpected random UID", GMWarning.WarningLevel.Info));
                }
                long  infoNumber = Timestamp - 1000;
                ulong temp       = (ulong)infoNumber;
                temp = ((temp << 56 & 18374686479671623680UL) | (temp >> 8 & 71776119061217280UL) |
                        (temp << 32 & 280375465082880UL) | (temp >> 16 & 1095216660480UL) | (temp << 8 & 4278190080UL) |
                        (temp >> 24 & 16711680UL) | (temp >> 16 & 65280UL) | (temp >> 32 & 255UL));
                infoNumber  = (long)temp;
                infoNumber ^= firstRandom;
                infoNumber  = ~infoNumber;
                infoNumber ^= ((long)GameID << 32 | (long)GameID);
                infoNumber ^= ((long)(DefaultWindowWidth + (int)Info) << 48 |
                               (long)(DefaultWindowHeight + (int)Info) << 32 |
                               (long)(DefaultWindowHeight + (int)Info) << 16 |
                               (long)(DefaultWindowWidth + (int)Info));
                infoNumber ^= FormatID;
                int infoLocation = Math.Abs((int)(Timestamp & 65535L) / 7 + (GameID - DefaultWindowWidth) + RoomOrder.Count) % 4;
                for (int i = 0; i < 4; i++)
                {
                    if (i == infoLocation)
                    {
                        long curr = reader.ReadInt64();
                        GMS2_RandomUID.Add(curr);
                        if (curr != infoNumber)
                        {
                            reader.Warnings.Add(new GMWarning("Unexpected random UID info", GMWarning.WarningLevel.Info));
                        }
                    }
                    else
                    {
                        int first  = reader.ReadInt32();
                        int second = reader.ReadInt32();
                        if (first != random.Next())
                        {
                            reader.Warnings.Add(new GMWarning("Unexpected random UID", GMWarning.WarningLevel.Info));
                        }
                        if (second != random.Next())
                        {
                            reader.Warnings.Add(new GMWarning("Unexpected random UID", GMWarning.WarningLevel.Info));
                        }
                        GMS2_RandomUID.Add((long)(first << 32) | (long)second);
                    }
                }

                // Other GMS2-specific data
                GMS2_FPS             = reader.ReadSingle();
                GMS2_AllowStatistics = reader.ReadWideBoolean();
                GMS2_GameGUID        = new Guid(reader.ReadBytes(16).Memory.ToArray());
            }
        }
Пример #11
0
 public GetObjectRequest(BinaryReader br)
 {
     this.gameObjectPath = br.ReadString();
     this.flags          = (InfoFlags)br.ReadInt32();
 }
Пример #12
0
 public GetObjectRequest(string gameObjectPath, InfoFlags flags)
 {
     this.gameObjectPath = gameObjectPath;
     this.flags          = flags;
 }
Пример #13
0
 public bool IsSpiritLink()
 {
     return(InfoFlags.HasFlag(DamageInfoFlags.SpiritLink));
 }
Пример #14
0
 public bool IsCritical()
 {
     return(InfoFlags.HasFlag(DamageInfoFlags.Critical));
 }
Пример #15
0
 public bool IsReflected()
 {
     return(InfoFlags.HasFlag(DamageInfoFlags.Reflected));
 }
Пример #16
0
 public bool IsBlocked()
 {
     return(InfoFlags.HasFlag(DamageInfoFlags.Blocked));
 }
Пример #17
0
 public Mapper001(ushort prgBankCount, byte chrBankCount, MirrorMode cartMirrorMode, InfoFlags info) :
     base(prgBankCount, chrBankCount, cartMirrorMode)
 {
     //if (info.HasFlag(InfoFlags.Battery))
     cartridgeRAM = new byte[Utils.Kilo8]; // TODO: Persist
 }
Пример #18
0
 public bool IsInvulnerable()
 {
     return(InfoFlags.HasFlag(DamageInfoFlags.Invulnerable));
 }