Ejemplo n.º 1
0
 public byte[] GetImageBytesForMip(Texture2DMipInfo info, MEGame game, bool useLowerMipsIfTFCMissing, string gamePathToUse = null, List <string> additionalTFCs = null)
 {
     byte[] imageBytes = null;
     try
     {
         imageBytes = GetTextureData(info, game, gamePathToUse, true, additionalTFCs);
     }
     catch (FileNotFoundException e)
     {
         if (useLowerMipsIfTFCMissing)
         {
             //External archive not found - using built in mips (will be hideous, but better than nothing)
             info = Mips.FirstOrDefault(x => x.storageType == StorageTypes.pccUnc);
             if (info != null)
             {
                 imageBytes = GetTextureData(info, game, gamePathToUse);
             }
         }
         else
         {
             throw e; //rethrow
         }
     }
     if (imageBytes == null)
     {
         throw new Exception(GetLocalizedCouldNotFetchTextureDataMessage(info?.Export.InstancedFullPath, info?.Export.FileRef.FilePath));
     }
     return(imageBytes);
 }
Ejemplo n.º 2
0
        private async void Mips_Click(object sender, RoutedEventArgs e)
        {
            Progress.Visibility = Visibility.Visible;
            var result = await Task.Run(() => {
                return(MipsGenerate());
            });

            Progress.Visibility = Visibility.Collapsed;
            if (result == true)
            {
                ModernDialog modernDialog = new ModernDialog
                {
                    Title   = "Mips生成汇编成功!",
                    Content = "查看结果?"
                };
                modernDialog.Buttons = new Button[] { modernDialog.OkButton, modernDialog.CancelButton };
                modernDialog.ShowDialog();
                result = modernDialog.MessageBoxResult.ToString();
                if (result == "OK")
                {
                    Mips page = new Mips();
                    page.Show();
                }
            }
        }
Ejemplo n.º 3
0
        private async void Mips_Click(object sender, RoutedEventArgs e)
        {
            Progress.Visibility = Visibility.Visible;
            var result = await Task.Run(() => {
                return(MipsGenerate());
            });

            Progress.Visibility = Visibility.Collapsed;
            if (result)
            {
                ContentDialog dialog = new ContentDialog();
                dialog.XamlRoot            = this.Content.XamlRoot;
                dialog.Title               = "生成Mips汇编成功";
                dialog.PrimaryButtonText   = "是";
                dialog.SecondaryButtonText = "否";
                dialog.DefaultButton       = ContentDialogButton.Primary;
                dialog.Content             = new ContentDialogContent();
                var choice = await dialog.ShowAsync();

                if (choice == ContentDialogResult.Primary)
                {
                    Mips page = new Mips();
                    page.Activate();
                }
            }
            else
            {
                ContentDialog dialog = new ContentDialog();
                dialog.XamlRoot          = this.Content.XamlRoot;
                dialog.Title             = "生成Mips汇编失败";
                dialog.PrimaryButtonText = "确定";
                await dialog.ShowAsync();
            }
        }
Ejemplo n.º 4
0
        public void Construct_Registers()
        {
            Registers reg = new Registers();

            target = new Mips(0x0, memDict, reg);

            Assert.AreEqual(reg, target.Reg);
        }
Ejemplo n.º 5
0
        private void Init_button_Click(object sender, EventArgs e)
        {
            if (pc_textbox.Text == "")
            {
                pc_textbox.Text = "1000";
            }

            _cpu = new Mips(uint.Parse(pc_textbox.Text));
            RefreshRegistersGridView();
            RefreshDataMemoryGridView();
            RefreshPipelineRegisterGridView();
            userCode_textbox.Text        = $@"{pc_textbox.Text}: ";
            RunClockCycle_button.Enabled = true;
        }
Ejemplo n.º 6
0
        public InstructionMemoryViewer(Mips mips)
        {
            InitializeComponent();
            this.mips = mips;
            var instructions = new ObservableCollection <InstructionInfo>();

            for (uint i = 0; i < mips.InstrMem.Size; i += mips.InstrMem.WordSize)
            {
                instructions.Add(new InstructionInfo()
                {
                    Address = i, Instruction = mips.InstrMem.GetInstruction(i).ToString()
                });
            }
            InstructionsList.ItemsSource = instructions;

            RefreshDisplay();
        }
Ejemplo n.º 7
0
        public void SetUp()
        {
            uint[] instructions = new uint[] {
                0x201d0f3c, 0x3c08ffff, 0x3508ffff, 0x2009ffff, 0x1509001b, 0x00084600, 0x3508f000, 0x00084203, 0x00084102,
                0x340a0003, 0x01495022, 0x01484004, 0x010a582a, 0x010a582b, 0x20080005, 0x2d0b000a, 0x2d0b0004, 0x2008fffb,
                0x2d0b0005, 0x3c0b1010, 0x356b1010, 0x3c0c0101, 0x218c1010, 0x016c6824, 0x016c6825, 0x016c6826, 0x016c6827,
                0x8c040004, 0x20840002, 0x2484fffe, 0x0c000021, 0xac020000, 0x08F00020, 0x23bdfff8, 0xafbf0004, 0xafa40000,
                0x28880002, 0x11000002, 0x00041020, 0x0800002e, 0x2084ffff, 0x0c000021, 0x8fa40000, 0x00441020, 0x00441020,
                0x2042ffff, 0x8fbf0004, 0x23bd0008, 0x03e00008
            };
            InstructionFactory instrFact = new InstructionFactory();

            Instruction[] instrs = new Instruction[instructions.Length];
            for (int i = 0; i < instructions.Length; i++)
            {
                instrs[i] = instrFact.CreateInstruction(instructions[i]);
            }

            InstructionMemory instrMem = new InstructionMemory(instrs);
            var dataMem = new DataMemory(10000);

            dataMem[4] = 99;
            var map      = new MappedMemoryUnit(dataMem, 0);
            var unitList = new List <MappedMemoryUnit> {
                map
            };
            var mem = new MemoryMapper(unitList);

            memDict = new Dictionary <Type, List <MemoryUnit> >();
            memDict.Add(instrMem.GetType(), new List <MemoryUnit> {
                instrMem
            });
            memDict.Add(mem.GetType(), new List <MemoryUnit> {
                mem
            });

            target = new Mips(0x0, memDict);
        }
Ejemplo n.º 8
0
        public VgaDisplay(Mips mips)
        {
            images = new Image[gridWidth * gridHeight];

            InitializeComponent();
            InitializeGrid(gridWidth, gridHeight);
            AddGridImages();
            BitmapMemory bmem = (BitmapMemory)mips.MemDict[typeof(BitmapMemory)][0];

            GenerateBitmaps(bmem);

            this.smem = (ScreenMemory)mips.MemDict[typeof(ScreenMemory)][0];

            hasSprite = mips.MemDict.ContainsKey(typeof(SpriteMemory)) &&
                        mips.MemDict.ContainsKey(typeof(SpriteBitmapMemory));

            if (hasSprite)
            {
                GenerateSpriteImage((SpriteBitmapMemory)mips.MemDict[typeof(SpriteBitmapMemory)][0]);
                spmem = (SpriteMemory)mips.MemDict[typeof(SpriteMemory)][0];
            }

            RefreshDisplay();
        }
Ejemplo n.º 9
0
 public FTexture2DMipMap?GetFirstMip() => Mips.FirstOrDefault(x => x.Data.Data != null);
Ejemplo n.º 10
0
        public void Construct_NoRegisters()
        {
            target = new Mips(0x0, memDict);

            Assert.NotNull(target.Reg);
        }
Ejemplo n.º 11
0
        public void PcSetFromFile()
        {
            Mips mips = target.Mips;

            Assert.AreEqual(4, mips.Pc);
        }
Ejemplo n.º 12
0
 public Texture2DMipInfo GetTopMip()
 {
     return(Mips.FirstOrDefault(x => x.storageType != StorageTypes.empty));
 }
Ejemplo n.º 13
0
 public void RemoveEmptyMipsFromMipList()
 {
     Mips.RemoveAll(x => x.storageType == StorageTypes.empty);
 }
Ejemplo n.º 14
0
 public void ReplaceMips(List <Texture2DMipInfo> mipmaps)
 {
     Mips.Clear();
     Mips.AddRange(mipmaps);
 }