Esempio n. 1
0
        public static void captureRAM(int address, int Length)
        {
            if (!captureInProgress)
            {
                VideoEngine.log_Renamed.warn("Ignoring captureRAM, capture hasn't been started");
                return;
            }

            if (!Memory.isAddressGood(address))
            {
                return;
            }

            try
            {
                // write ram fragment
                CaptureHeader header = new CaptureHeader(CaptureHeader.PACKET_TYPE_RAM);
                header.write(@out);

                CaptureRAM captureRAM = new CaptureRAM(address, Length);
                captureRAM.write(@out);
            }
            catch (Exception e)
            {
                VideoEngine.log_Renamed.error("Failed to capture RAM: " + e.Message);
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public CaptureDisplayDetails() throws java.io.IOException
        public CaptureDisplayDetails()
        {
            VideoEngine ge      = VideoEngine.Instance;
            sceDisplay  display = Modules.sceDisplayModule;

            fbp = ge.FBP;
            fbw = ge.FBW;
            zbp = ge.ZBP;
            zbw = ge.ZBW;
            psm = ge.PSM;

            topaddrFb     = display.TopAddrFb;
            bufferwidthFb = display.BufferWidthFb;
            pixelformatFb = display.PixelFormatFb;
            sync          = display.Sync;

            // TODO clamp lengths to within valid RAM range
            int pixelFormatBytes = pspsharp.graphics.RE.IRenderingEngine_Fields.sizeOfTextureType[psm];

            drawBuffer = new CaptureRAM(fbp + MemoryMap.START_VRAM, fbw * 272 * pixelFormatBytes);

            depthBuffer = new CaptureRAM(zbp + MemoryMap.START_VRAM, zbw * 272 * 2);

            pixelFormatBytes = pspsharp.graphics.RE.IRenderingEngine_Fields.sizeOfTextureType[pixelformatFb];
            displayBuffer    = new CaptureRAM(topaddrFb, bufferwidthFb * 272 * pixelFormatBytes);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CaptureList read(java.io.InputStream in) throws java.io.IOException
        public static CaptureList read(System.IO.Stream @in)
        {
            CaptureList list = new CaptureList();

            DataInputStream data          = new DataInputStream(@in);
            int             sizeRemaining = data.readInt();

            if (sizeRemaining >= 16)
            {
                int list_addr = data.readInt();
                sizeRemaining -= 4;
                int stall_addr = data.readInt();
                sizeRemaining -= 4;
                int cbid = data.readInt();
                sizeRemaining -= 4;
                data.skipBytes(sizeRemaining);

                list.list = new PspGeList(0);
                list.list.init(list_addr, stall_addr, cbid, null);

                CaptureHeader header     = CaptureHeader.read(@in);
                int           packetType = header.PacketType;
                if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                {
                    throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                }
                list.listBuffer = CaptureRAM.read(@in);
            }
            else
            {
                throw new IOException("Not enough bytes remaining in stream");
            }

            return(list);
        }
Esempio n. 4
0
        public static void startReplay(string filename)
        {
            if (captureInProgress)
            {
                VideoEngine.log_Renamed.error("Ignoring startReplay, capture is in progress");
                return;
            }

            VideoEngine.log_Renamed.info("Starting replay: " + filename);

            try
            {
                System.IO.Stream @in = new BufferedInputStream(new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read));

                while (@in.available() > 0)
                {
                    CaptureHeader header     = CaptureHeader.read(@in);
                    int           packetType = header.PacketType;

                    switch (packetType)
                    {
                    case CaptureHeader.PACKET_TYPE_LIST:
                        CaptureList list = CaptureList.read(@in);
                        list.commit();
                        break;

                    case CaptureHeader.PACKET_TYPE_RAM:
                        CaptureRAM ramFragment = CaptureRAM.read(@in);
                        ramFragment.commit();
                        break;

                    // deprecated
                    case CaptureHeader.PACKET_TYPE_DISPLAY_DETAILS:
                        CaptureDisplayDetails displayDetails = CaptureDisplayDetails.read(@in);
                        displayDetails.commit();
                        break;

                    case CaptureHeader.PACKET_TYPE_FRAMEBUF_DETAILS:
                        // don't replay this one immediately, wait until after the list has finished executing
                        replayFrameBufDetails = CaptureFrameBufDetails.read(@in);
                        break;

                    default:
                        throw new Exception("Unknown packet type " + packetType);
                    }
                }

                @in.Close();
            }
            catch (Exception e)
            {
                VideoEngine.log_Renamed.error("Failed to start replay: " + e.Message);
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CaptureRAM read(java.io.InputStream in) throws java.io.IOException
        public static CaptureRAM read(System.IO.Stream @in)
        {
            CaptureRAM ramFragment = new CaptureRAM();

            DataInputStream data          = new DataInputStream(@in);
            int             sizeRemaining = data.readInt();

            if (sizeRemaining >= 8)
            {
                ramFragment.address = data.readInt();
                sizeRemaining      -= 4;
                ramFragment.Length  = data.readInt();
                sizeRemaining      -= 4;

                if (sizeRemaining > data.available())
                {
                    VideoEngine.log_Renamed.warn("CaptureRAM read want=" + sizeRemaining + " available=" + data.available());
                }

                if (sizeRemaining >= ramFragment.Length)
                {
                    ByteBuffer bb = ByteBuffer.allocate(ramFragment.Length);
                    sbyte[]    b  = bb.array();
                    if (b == null)
                    {
                        throw new IOException("Buffer is not backed by an array");
                    }
                    data.readFully(b, 0, ramFragment.Length);
                    ramFragment.buffer = bb;
                    sizeRemaining     -= ramFragment.Length;

                    data.skipBytes(sizeRemaining);

                    VideoEngine.log_Renamed.info(string.Format("Loaded memory {0:x8} - {1:x8} (len {2:x8})", ramFragment.address, ramFragment.address + ramFragment.Length, ramFragment.Length));
                }
                else
                {
                    throw new IOException("Not enough bytes remaining in stream");
                }
            }
            else
            {
                throw new IOException("Not enough bytes remaining in stream");
            }

            return(ramFragment);
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CaptureDisplayDetails read(java.io.InputStream in) throws java.io.IOException
        public static CaptureDisplayDetails read(System.IO.Stream @in)
        {
            CaptureDisplayDetails details = new CaptureDisplayDetails();

            DataInputStream data          = new DataInputStream(@in);
            int             sizeRemaining = data.readInt();

            if (sizeRemaining >= packetSize)
            {
                details.fbp    = data.readInt();
                sizeRemaining -= 4;
                details.fbw    = data.readInt();
                sizeRemaining -= 4;
                details.zbp    = data.readInt();
                sizeRemaining -= 4;
                details.zbw    = data.readInt();
                sizeRemaining -= 4;
                details.psm    = data.readInt();
                sizeRemaining -= 4;

                details.topaddrFb     = data.readInt();
                sizeRemaining        -= 4;
                details.bufferwidthFb = data.readInt();
                sizeRemaining        -= 4;
                details.pixelformatFb = data.readInt();
                sizeRemaining        -= 4;
                details.sync          = data.readInt();
                sizeRemaining        -= 4;

                data.skipBytes(sizeRemaining);

                if (captureRenderTargets)
                {
                    // read draw, depth and display buffers
                    CaptureHeader header     = CaptureHeader.read(@in);
                    int           packetType = header.PacketType;
                    if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                    {
                        throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                    }
                    details.drawBuffer = CaptureRAM.read(@in);

                    header     = CaptureHeader.read(@in);
                    packetType = header.PacketType;
                    if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                    {
                        throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                    }
                    details.depthBuffer = CaptureRAM.read(@in);

                    header     = CaptureHeader.read(@in);
                    packetType = header.PacketType;
                    if (packetType != CaptureHeader.PACKET_TYPE_RAM)
                    {
                        throw new IOException("Expected CaptureRAM(" + CaptureHeader.PACKET_TYPE_RAM + ") packet, found " + packetType);
                    }
                    details.displayBuffer = CaptureRAM.read(@in);
                }
            }
            else
            {
                throw new IOException("Not enough bytes remaining in stream");
            }

            return(details);
        }