コード例 #1
0
        public virtual int sceMemab_9BF1A0A4(TPointer xorKey, TPointer buffer, int bufferLength)
        {
            // Decrypting (PSP_KIRK_CMD_DECRYPT) the data in unknownInputOutput buffer
            RuntimeContext.debugMemory(buffer.Address, bufferLength);

            return(0);
        }
コード例 #2
0
        public virtual Instruction interpret()
        {
            int         opcode = cpu.fetchOpcode();
            Instruction insn   = Decoder.instruction(opcode);

            if (log.TraceEnabled)
            {
                log.trace(string.Format("Interpreting 0x{0:X8}: [0x{1:X8}] - {2}", cpu.pc - 4, opcode, insn.disasm(cpu.pc - 4, opcode)));
            }
            insn.interpret(this, opcode);

            if (RuntimeContext.debugCodeBlockCalls)
            {
                if (insn == Instructions.JAL)
                {
                    RuntimeContext.debugCodeBlockStart(cpu, cpu.pc);
                }
                else if (insn == Instructions.JR && ((opcode >> 21) & 31) == Common._ra)
                {
                    int         opcodeCaller   = cpu.memory.read32(cpu._ra - 8);
                    Instruction insnCaller     = Decoder.instruction(opcodeCaller);
                    int         codeBlockStart = cpu.pc;
                    if (insnCaller == Instructions.JAL)
                    {
                        codeBlockStart = jumpTarget(cpu.pc, (opcodeCaller) & 0x3FFFFFF);
                    }
                    RuntimeContext.debugCodeBlockEnd(cpu, codeBlockStart, cpu._ra);
                }
            }

            return(insn);
        }
コード例 #3
0
 public static void writeByteBufferArea(int address, ByteBuffer source, int bufferWidth, int width, int height)
 {
     writeByteBufferArea_Renamed.start();
     if (RuntimeContext.hasMemoryInt() && (address & 3) == 0 && (width & 3) == 0 && (bufferWidth & 3) == 0 && isAddressGood(address))
     {
         int       Length            = bufferWidth * height;
         int       destinationOffset = (address & Memory.addressMask) >> 2;
         IntBuffer destination       = IntBuffer.wrap(RuntimeContext.MemoryInt, destinationOffset, Length >> 2);
         source.order(ByteOrder.nativeOrder());
         IntBuffer sourceInt    = source.asIntBuffer();
         int       width4       = width >> 2;
         int       bufferWidth4 = bufferWidth >> 2;
         for (int y = 0; y < height; y++)
         {
             int offset = y * bufferWidth4;
             sourceInt.limit(offset + width4);
             sourceInt.position(offset);
             destination.position(destinationOffset + offset);
             destination.put(sourceInt);
         }
     }
     else
     {
         Memory mem = Memory;
         for (int y = 0; y < height; y++)
         {
             int offset = y * bufferWidth;
             source.position(offset);
             mem.copyToMemory(address + offset, source, width);
         }
     }
     writeByteBufferArea_Renamed.end();
 }
コード例 #4
0
        public virtual int sceMemab_8ABE3445(TPointer unknownOutput, TPointer unknownInput)
        {
            unknownOutput.clear(192);
            RuntimeContext.debugMemory(unknownOutput.Address, 192);
            RuntimeContext.debugMemory(unknownInput.Address, 96);

            return(0);
        }
コード例 #5
0
        public virtual int sceMemab_4B54EAAD(TPointer unknownOutput1, TPointer unknownOutput2)
        {
            unknownOutput1.clear(192);
            RuntimeContext.debugMemory(unknownOutput1.Address, 192);
            unknownOutput2.clear(160);
            RuntimeContext.debugMemory(unknownOutput2.Address, 160);

            return(0);
        }
コード例 #6
0
        public virtual int sceMemab_3C15BC8C(TPointer unknownInputOutput, TPointer unknownInput, int inputLength, TPointer unknownInput2, int unknown2)
        {
            unknownInputOutput.clear(68);
            RuntimeContext.debugMemory(unknownInputOutput.Address, 68);
            RuntimeContext.debugMemory(unknownInput.Address, inputLength);
            RuntimeContext.debugMemory(unknownInput2.Address, 16);

            return(0);
        }
コード例 #7
0
        public static IRendererWriter getRendererWriter(int fbAddress, int fbBufferWidth, int fbPixelFormat, int depthAddress, int depthBufferWidth, int depthPixelFormat, bool needDepthRead, bool needDepthWrite)
        {
            if (RuntimeContext.hasMemoryInt())
            {
                return(getFastMemoryRendererWriter(fbAddress, fbBufferWidth, fbPixelFormat, depthAddress, depthBufferWidth, depthPixelFormat, needDepthRead, needDepthWrite));
            }

            return(getRendererWriterGeneric(fbAddress, fbBufferWidth, fbPixelFormat, depthAddress, depthBufferWidth, depthPixelFormat, needDepthRead, needDepthWrite));
        }
コード例 #8
0
 /// <summary>
 /// Creates a MemoryReader to read values from memory.
 /// </summary>
 /// <param name="address"> the address where to start reading.
 ///                When step == 2, the address has to be 16-bit aligned ((address & 1) == 0).
 ///                When step == 4, the address has to be 32-bit aligned ((address & 3) == 0). </param>
 /// <param name="step">    when step == 1, read 8-bit values
 ///                when step == 2, read 16-bit values
 ///                when step == 4, read 32-bit values
 ///                other value for step are not allowed. </param>
 /// <returns>        the MemoryReader </returns>
 public static IMemoryReader getMemoryReader(int address, int step)
 {
     if (RuntimeContext.hasMemoryInt(address))
     {
         address &= Memory.addressMask;
         return(getFastMemoryReader(address, step));
     }
     return(getMemoryReader(address, getMaxLength(address), step));
 }
コード例 #9
0
        public virtual int sceMemab_D47A50B1(TPointer unknownInputOutput, TPointer unknownInput, int inputLength, TPointer unknownOutput, int unknown1, int unknown2)
        {
            unknownInputOutput.clear(76);
            RuntimeContext.debugMemory(unknownInputOutput.Address, 76);
            RuntimeContext.debugMemory(unknownInput.Address, inputLength);
            unknownOutput.clear(32);
            RuntimeContext.debugMemory(unknownOutput.Address, 32);

            return(0);
        }
コード例 #10
0
        public virtual int sceMemab_C3981EE1(TPointer unknownInputOuput, TPointer unknownInput, TPointer unknownOutput)
        {
            unknownInputOuput.clear(192);
            RuntimeContext.debugMemory(unknownInputOuput.Address, 192);
            RuntimeContext.debugMemory(unknownInput.Address, 272);
            unknownOutput.clear(256);
            RuntimeContext.debugMemory(unknownOutput.Address, 256);

            return(0);
        }
コード例 #11
0
        public virtual int sceMemab_9BF0C95D(TPointer unknownOutput1, TPointer unknownInput, TPointer unknownOutput2)
        {
            RuntimeContext.debugMemory(unknownInput.Address, 160);
            unknownOutput1.clear(192);
            RuntimeContext.debugMemory(unknownOutput1.Address, 192);
            unknownOutput2.clear(272);
            RuntimeContext.debugMemory(unknownOutput2.Address, 272);

            return(0);
        }
コード例 #12
0
        public static IMemoryReaderWriter getMemoryReaderWriter(int address, int step)
        {
            address &= Memory.addressMask;
            if (RuntimeContext.hasMemoryInt())
            {
                return(getFastMemoryReaderWriter(address, step));
            }

            // No dedicated class available, use the generic one.
            return(new MemoryReaderWriterGeneric(address, step));
        }
コード例 #13
0
        public virtual int sceMemab_23E4659B(TPointer unknownInputOutput1, TPointer unknownInputOutput2, TPointer unknownOutput)
        {
            unknownInputOutput1.clear(192);
            RuntimeContext.debugMemory(unknownInputOutput1.Address, 192);
            unknownInputOutput2.clear(256);
            RuntimeContext.debugMemory(unknownInputOutput2.Address, 256);
            unknownOutput.clear(96);
            RuntimeContext.debugMemory(unknownOutput.Address, 96);

            return(0);
        }
コード例 #14
0
        /// <summary>
        /// Creates a MemoryReader to read values from memory.
        /// </summary>
        /// <param name="address"> the address where to start reading.
        ///                When step == 2, the address has to be 16-bit aligned ((address & 1) == 0).
        ///                When step == 4, the address has to be 32-bit aligned ((address & 3) == 0). </param>
        /// <param name="Length">  the maximum number of bytes that can be read. </param>
        /// <param name="step">    when step == 1, read 8-bit values
        ///                when step == 2, read 16-bit values
        ///                when step == 4, read 32-bit values
        ///                other value for step are not allowed. </param>
        /// <returns>        the MemoryReader </returns>
        public static IMemoryReader getMemoryReader(int address, int Length, int step)
        {
            if (Memory.isAddressGood(address))
            {
                address &= Memory.addressMask;
                if (RuntimeContext.hasMemoryInt())
                {
                    return(getFastMemoryReader(address, step));
                }

                if (!DebuggerMemory.Installed)
                {
                    Buffer buffer = Memory.Instance.getBuffer(address, Length);

                    if (buffer is IntBuffer)
                    {
                        IntBuffer intBuffer = (IntBuffer)buffer;
                        switch (step)
                        {
                        case 1:
                            return(new MemoryReaderInt8(intBuffer, address));

                        case 2:
                            return(new MemoryReaderInt16(intBuffer, address));

                        case 4:
                            return(new MemoryReaderInt32(intBuffer, address));
                        }
                    }
                    else if (buffer is ByteBuffer)
                    {
                        ByteBuffer byteBuffer = (ByteBuffer)buffer;
                        switch (step)
                        {
                        case 1:
                            return(new MemoryReaderByte8(byteBuffer, address));

                        case 2:
                            return(new MemoryReaderByte16(byteBuffer, address));

                        case 4:
                            return(new MemoryReaderByte32(byteBuffer, address));
                        }
                    }
                }
            }

            // Default (generic) MemoryReader
            return(new MemoryReaderGeneric(address, Length, step));
        }
コード例 #15
0
 public static void writeByteBuffer(int address, ByteBuffer source, int Length)
 {
     writeByteBuffer_Renamed.start();
     if (RuntimeContext.hasMemoryInt() && (address & 3) == 0 && (Length & 3) == 0 && isAddressGood(address))
     {
         IntBuffer destination = IntBuffer.wrap(RuntimeContext.MemoryInt, (address & Memory.addressMask) >> 2, Length >> 2);
         source.order(ByteOrder.nativeOrder());
         destination.put(source.asIntBuffer());
     }
     else
     {
         Memory.copyToMemory(address, source, Length);
     }
     writeByteBuffer_Renamed.end();
 }
コード例 #16
0
        public virtual void run()
        {
            if (!Emulator.run_Renamed)
            {
                return;
            }

            if (instructions == null)
            {
                initRun();
            }

            //if (log.DebugEnabled)
            {
//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: Console.WriteLine(String.format("MEProcessor starting run: halt=%b, pendingInterruptIPbits=0x%X, pc=0x%08X", halt, pendingInterruptIPbits, cpu.pc));
                Console.WriteLine(string.Format("MEProcessor starting run: halt=%b, pendingInterruptIPbits=0x%X, pc=0x%08X", halt_Renamed, pendingInterruptIPbits, cpu.pc));
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'sealed override':
//ORIGINAL LINE: sealed override bool hasMemoryInt = pspsharp.Allegrex.compiler.RuntimeContext.hasMemoryInt();
            bool hasMemoryInt = RuntimeContext.hasMemoryInt();

            while (!halt_Renamed && !Emulator.pause)
            {
                int pc = cpu.pc & Memory.addressMask;
                if (hasMemoryInt && pc >= optimizedRunStart && pc < optimizedRunEnd)
                {
                    optimizedRun();
                }
                else
                {
                    normalRun();
                }
            }

            //if (log.DebugEnabled)
            {
//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: Console.WriteLine(String.format("MEProcessor exiting run: halt=%b, pendingInterruptIPbits=0x%X, isInterruptExecutionAllowed=%b, status=0x%X, pc=0x%08X", halt, pendingInterruptIPbits, isInterruptExecutionAllowed(), cp0.getStatus(), cpu.pc));
                Console.WriteLine(string.Format("MEProcessor exiting run: halt=%b, pendingInterruptIPbits=0x%X, isInterruptExecutionAllowed=%b, status=0x%X, pc=0x%08X", halt_Renamed, pendingInterruptIPbits, InterruptExecutionAllowed, cp0.Status, cpu.pc));
            }
        }
コード例 #17
0
        private void normalRun()
        {
            int  count = 0;
            long start = Emulator.Clock.currentTimeMillis();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'sealed override':
//ORIGINAL LINE: sealed override bool hasMemoryInt = pspsharp.Allegrex.compiler.RuntimeContext.hasMemoryInt();
            bool hasMemoryInt = RuntimeContext.hasMemoryInt();

            while (!halt_Renamed && !Emulator.pause)
            {
                if (pendingInterruptIPbits != 0)
                {
                    checkPendingInterruptException();
                }

                step();
                count++;

                int pc = cpu.pc & Memory.addressMask;
                if (hasMemoryInt && pc >= optimizedRunStart && pc < optimizedRunEnd)
                {
                    break;
                }

                if (cpu.pc == unchecked ((int)0x883000E0) && log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("Initial ME memory content from meimg.img:"));
                    Console.WriteLine(Utilities.getMemoryDump(meMemory, 0x00101000, cpu._v0));
                    //				log.setLevel(Level.TRACE);
                }
            }

            long end = Emulator.Clock.currentTimeMillis();

            if (count > 0 && log.InfoEnabled)
            {
                int duration = System.Math.Max((int)(end - start), 1);
                Console.WriteLine(string.Format("MEProcessor {0:D} instructions executed in {1:D} ms: {2:D} instructions per ms", count, duration, (count + duration / 2) / duration));
            }
        }