Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public CaptureList(pspsharp.HLE.kernel.types.PspGeList list) throws Exception
        public CaptureList(PspGeList list)
        {
            this.list = new PspGeList(list.id);
            this.list.init(list.list_addr, list.StallAddr, list.cbid, list.optParams);

            if (list.StallAddr - list.list_addr == 0)
            {
                VideoEngine.log_Renamed.error("Capture: Command list is empty");
            }

            int listSize = 0;

            if (list.StallAddr == 0)
            {
                // Scan list for END command
                Memory mem = Memory.Instance;
                for (int listPc = list.list_addr; Memory.isAddressGood(listPc); listPc += 4)
                {
                    int instruction = mem.read32(listPc);
                    int command     = VideoEngine.command(instruction);
                    if (command == GeCommands.END)
                    {
                        listSize = listPc - list.list_addr + 4;
                        break;
                    }
                    else if (command == GeCommands.JUMP)
                    {
                        VideoEngine.log_Renamed.error("Found a JUMP instruction while scanning the list. Aborting the scan.");
                        listSize = listPc - list.list_addr + 4;
                        break;
                    }
                    else if (command == GeCommands.RET)
                    {
                        VideoEngine.log_Renamed.error("Found a RET instruction while scanning the list. Aborting the scan.");
                        listSize = listPc - list.list_addr + 4;
                        break;
                    }
                    else if (command == GeCommands.CALL)
                    {
                        VideoEngine.log_Renamed.warn("Found a CALL instruction while scanning the list. Ignoring the called list.");
                    }
                }
            }
            else
            {
                listSize = list.StallAddr - list.list_addr;
            }

            listBuffer = new CaptureRAM(list.list_addr & Memory.addressMask, listSize);
        }
Пример #2
0
        private void setStallAddressWithCachedMemory(PspGeList list, int stallAddr)
        {
            int startAddress = list.list_addr;
            int Length;

            if (stallAddr != 0)
            {
                Length = stallAddr - startAddress;
            }
            else
            {
                // The list has no stall address, scan for the FINISH command
                IMemoryReader memoryReader = MemoryReader.getMemoryReader(startAddress, 4);
                Length = 0;
                while (true)
                {
                    int instruction = memoryReader.readNext();
                    int command     = VideoEngine.command(instruction);
                    if (command == GeCommands.FINISH)
                    {
                        // Add 4 to include the END command that follows the FINISH command
                        Length = memoryReader.CurrentAddress - startAddress + 4;
                        break;
                    }
                }
            }

            if (Length >= 0)
            {
                int[] baseMemoryInts = Utilities.readInt32(startAddress, Length);
                list.setStallAddr(stallAddr, MemoryReader.getMemoryReader(startAddress, baseMemoryInts, 0, Length), startAddress, startAddress + Length);

                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("setStallAddressWithCachedMemory [0x{0:X8}-0x{1:X8}] {2}", startAddress, startAddress + Length, list));
                }
            }
            else
            {
                list.StallAddr = stallAddr;
            }
        }