コード例 #1
0
ファイル: MainForm.cs プロジェクト: ManDude/JakContinueMapper
 internal void SetGame(GameMemoryAttribute game)
 {
     if (Game == null || Game != game) // game changed
     {
         memtimer.Enabled = false;
         // update current game and addresses
         Game             = game;
         addrTargetPos    = new GameAddr(Game.TargetPos);
         addrSymbolTable  = new GameAddr(Game.SymbolTable);
         memtimer.Enabled = true;
     }
 }
コード例 #2
0
        public void UpdateSymbols(EmuMemory emu, GameAddr addrSymbolTable)
        {
            emu.ReadMem(addrSymbolTable, 0x10000, out byte[] symboltable);
            emu.ReadMem(addrSymbolTable + 65336, 0x10000, out byte[] symbolnameptrs);

            int goal_false = GetSymbolVal(symboltable, 0);
            int goal_true  = GetSymbolVal(symboltable, 1);

            if (search_query)
            {
                for (int i = search_index; i < UsableSymbolCount; ++i)
                {
                    int    name_addr = GetSymbolVal(symbolnameptrs, i);
                    string name;
                    if ((name_addr & 0xF) == 4 && name_addr < 0x8000000)
                    {
                        name = emu.ReadCString(name_addr + 4);
                    }
                    else
                    {
                        continue;
                    }
                    if (name.Contains(search_term))
                    {
                        search_index = i + 1;
                        pagenum      = i / entries_per_page;
                        ValidatePageNav();
                        search_query = false;
                        break;
                    }
                }
                if (search_query)
                {
                    search_index = 0;
                    search_query = false;
                }
            }

            for (int i = 0, symbolindex = pagenum * entries_per_page; i < entries_per_page; ++i, ++symbolindex)
            {
                Label lbl = labels[i];
                if (symbolindex < UsableSymbolCount)
                {
                    lbl.Visible = true;
                    int name = GetSymbolVal(symbolnameptrs, symbolindex);
                    if ((name & 0xF) == 4 && name < 0x8000000)
                    {
                        lbl.Text = emu.ReadCString(name + 4);
                    }
                    else if (name == 0)
                    {
                        lbl.Visible = false;
                    }
                    else
                    {
                        throw new Exception("symbol had invalid name addr " + name.ToString("X"));
                    }
                    int val  = GetSymbolVal(symboltable, symbolindex);
                    int addr = GetSymbolAddr(symbolindex);
                    if (val == goal_false)
                    {
                        lbl.Font = fontItalic;
                        if ((int)lbl.Tag == 1)
                        {
                            lbl.Tag = 0;
                            emu.WriteInt32(addrSymbolTable + addr, (uint)goal_true);
                            lbl.ForeColor = Color.LimeGreen;
                        }
                        else
                        {
                            lbl.ForeColor = Color.Red;
                        }
                    }
                    else if (val == goal_true)
                    {
                        lbl.Font = fontItalic;
                        if ((int)lbl.Tag == 1)
                        {
                            lbl.Tag = 0;
                            emu.WriteInt32(addrSymbolTable + addr, (uint)goal_false);
                            lbl.ForeColor = Color.Red;
                        }
                        else
                        {
                            lbl.ForeColor = Color.LimeGreen;
                        }
                    }
                    else
                    {
                        lbl.Font      = fontRegular;
                        lbl.ForeColor = Color.Black;
                    }
                    if (symbolindex == search_index - 1)
                    {
                        lbl.Font = fontBold;
                    }
                }
                else
                {
                    lbl.Visible = false;
                }
            }
        }