예제 #1
0
        void PerformUpdate()
        {
            if (memory.availableProcesses.Count > 0)
            {
                try
                {
                    memory.SetProcess(System.Diagnostics.Process.GetProcessById(memory.availableProcesses[0].pID));
                }
                catch { }
            }
            memory.Update();
            if (memory.process == null)
            {
                return;
            }
            //Check if savefile is ok. If not, we are reading invalid memory, so return;
            if (BitConverter.ToInt16(memory.ReadMemory(0x207700 + 0x36, 2), 0) != 0x4441)
            {
                inMenu = true;
                return;
            }
            int newLives = memory.ReadMemory(addr_numLives, 1)[0];

            if (newLives == numLives - 1 && !inMenu)
            {
                deathCount++;
            }
            numLives = newLives;

            uint levelScriptPosition = BitConverter.ToUInt32(memory.ReadMemory(0x38be28, 4), 0);
            uint levelScriptCommand  = BitConverter.ToUInt32(memory.ReadMemory((int)(levelScriptPosition & 0x7FFFFFFF), 4), 0);
            uint stackSize           = BitConverter.ToUInt32(memory.ReadMemory((int)(addr_levelscriptStack & 0x7FFFFFFFF), 4), 0);
            bool newInMenu           = stackSize == 0x8038BDA8;

            if (BitConverter.ToUInt32(memory.ReadMemory(0x38BDBC, 4), 0) == 0)
            {
                inMenu = newInMenu = true;
            }
            if (!newInMenu)
            {
                uint menuUpdate = BitConverter.ToUInt32(memory.ReadMemory((int)(addr_menuUpdate & 0x7FFFFFFFF), 4), 0);
                newInMenu = menuUpdate != 0;
            }
            int currentAction = BitConverter.ToInt32(memory.ReadMemory(addr_action, 4), 0);

            if (newInMenu && !inMenu && currentAction != victory_action)
            {
                deathCount++;
            }
            inMenu = newInMenu;
        }
예제 #2
0
        bool validateState()
        {
            short chkValue = (short)BitConverter.ToInt16(memory.ReadMemory(ADDR_FIRSTFILE + 0x36 + saveFile * 0x70, 2), 0);

            if (chkValue != 0x4441)
            {
                return(false);
            }
            short levelID    = (short)(BitConverter.ToInt16(memory.ReadMemory(ADDR_LEVELID, 2), 0) - 1);
            int   levelIndex = (levelID >= 0 ? (levelID >> 2 << 2) + 3 - levelID % 4 : -1);

            if (levelIndex + 0xC > stars.Length)
            {
                return(false);
            }
            return(true);
        }