public static void call() { int src1Addr = GprA0; int src2Addr = GprA1; int n = GprA2; if (log.TraceEnabled) { log.trace(string.Format("memcmp src1={0}, src2={1}, n=0x{2:X}", Utilities.getMemoryDump(src1Addr, n), Utilities.getMemoryDump(src2Addr, n), n)); } IMemoryReader memoryReader1 = MemoryReader.getMemoryReader(src1Addr, n, 1); IMemoryReader memoryReader2 = MemoryReader.getMemoryReader(src2Addr, n, 1); for (int i = 0; i < n; i++) { int c1 = memoryReader1.readNext(); int c2 = memoryReader2.readNext(); if (c1 != c2) { GprV0 = c1 - c2; return; } } GprV0 = 0; }
public virtual void copy(SBRData that) { bsFrameClass = that.bsFrameClass; bsAddHarmonicFlag = that.bsAddHarmonicFlag; bsNumEnv = that.bsNumEnv; Utilities.copy(bsFreqRes, that.bsFreqRes); bsNumNoise = that.bsNumNoise; Utilities.copy(bsDfEnv, that.bsDfEnv); Utilities.copy(bsDfNoise, that.bsDfNoise); Utilities.copy(bsInvfMode, that.bsInvfMode); Utilities.copy(bsAddHarmonic, that.bsAddHarmonic); bsAmpRes = that.bsAmpRes; // State variables Utilities.copy(synthesisFilterbankSamples, that.synthesisFilterbankSamples); Utilities.copy(analysisFilterbankSamples, that.analysisFilterbankSamples); synthesisFilterbankSamplesOffset = that.synthesisFilterbankSamplesOffset; Utilities.copy(eA, that.eA); Utilities.copy(bwArray, that.bwArray); Utilities.copy(W, that.W); Utilities.copy(Y, that.Y); Utilities.copy(gTemp, that.gTemp); Utilities.copy(qTemp, that.qTemp); Utilities.copy(sIndexmapped, that.sIndexmapped); Utilities.copy(envFacs, that.envFacs); Utilities.copy(noiseFacs, that.noiseFacs); Utilities.copy(tEnv, that.tEnv); tEnvNumEnvOld = that.tEnvNumEnvOld; Utilities.copy(tQ, that.tQ); fIndexnoise = that.fIndexnoise; fIndexsine = that.fIndexsine; }
// For Ptp sockets, data is stored in the internal buffer as a continuous byte stream. // The organization in packets doesn't matter. private int addReceivedMessage(AdhocMessage adhocMessage, int offset) { int Length = System.Math.Min(adhocMessage.DataLength - offset, BufSize - RcvdData); int addr = buffer.addr + RcvdData; adhocMessage.writeDataToMemory(addr, offset, Length); rcvdData += Length; //if (log.DebugEnabled) { if (offset == 0) { Console.WriteLine(string.Format("Successfully received message (Length={0:D}, rcvdData={1:D}) {2}", Length, RcvdData, adhocMessage)); } else { Console.WriteLine(string.Format("Appending received message (offset={0:D}, Length={1:D}, rcvdData={2:D}) {3}", offset, Length, RcvdData, adhocMessage)); } if (log.TraceEnabled) { log.trace(string.Format("Message data: {0}", Utilities.getMemoryDump(addr, Length))); } } return(Length); }
public virtual int sceSdGetLastIndex(TPointer ctx2Addr, TPointer8 hash, TPointer8 key) { SAVEDATA.SD_Ctx1 ctx = new SAVEDATA.SD_Ctx1(); ctx.read(ctx2Addr); sbyte[] hashBytes = new sbyte[16]; sbyte[] keyBytes; if (key.Null) { keyBytes = null; } else { keyBytes = new sbyte[16]; Utilities.readBytes(key.Address, keyBytes.Length, keyBytes, 0); } int result = crypto.SAVEDATAEngine.hleSdGetLastIndex(ctx, hashBytes, keyBytes); Utilities.writeBytes(hash.Address, hashBytes.Length, hashBytes, 0); ctx.write(ctx2Addr); return(result); }
public virtual void copy(Pulse that) { numPulse = that.numPulse; start = that.start; Utilities.copy(pos, that.pos); Utilities.copy(amp, that.amp); }
public virtual void copy(LongTermPrediction that) { present = that.present; lag = that.lag; coef = that.coef; Utilities.copy(used, that.used); }
public int gameSharingDataSize; // EBOOT.BIN data's size. protected internal override void read() { @base = new pspUtilityDialogCommon(); read(@base); MaxSize = @base.totalSizeof(); readUnknown(8); gameSharingName = readStringNZ(sceNetAdhocctl.GROUP_NAME_LENGTH); readUnknown(4); uploadCallbackArg = read32(); uploadCallbackAddr = read32(); result = read32(); gameSharingFilepathAddr = read32(); if (gameSharingFilepathAddr != 0) { gameSharingFilepath = Utilities.readStringNZ(gameSharingFilepathAddr, 32); } else { gameSharingFilepath = null; } gameSharingMode = read32(); gameSharingDataType = read32(); gameSharingDataAddr = read32(); gameSharingDataSize = read32(); }
public static void sceGuCallList() { int callAddr = GprA0; if (Modules.ThreadManForUserModule.isCurrentThreadStackAddress(callAddr)) { // Some games are calling GE lists stored on the thread stack... dirty programming! // Such a list can be overwritten as the thread stack gets used in further calls. // These changes are however not seen immediately by the GE engine due to the memory caching. // The developer of the games probably never found this bug due to the PSP hardware memory caching. // This is however an issue with pspsharp as no memory caching is implemented. // So, we simulate a memory cache here by reading the called list into an array and force the // VideoEngine to reuse these cached values when processing the GE list. int listSize = getListSize(callAddr); int memorySize = listSize << 2; if (log.InfoEnabled) { Console.WriteLine(string.Format("sceGuCallList Stack address 0x{0:X8}-0x{1:X8}", callAddr, callAddr + memorySize)); } int[] instructions = Utilities.readInt32(callAddr, memorySize); VideoEngine.Instance.addCachedInstructions(callAddr, instructions); } }
protected internal override void read() { base.read(); ticketVersionMajor = read16(); ticketVersionMinor = read16(); serviceIdAddr = read32(); cookie = read32(); cookieSize = read32(); entitlementIdAddr = read32(); consumedCount = read32(); ticketCallback = read32(); callbackArgument = read32(); if (serviceIdAddr != 0) { serviceId = Utilities.readStringZ(serviceIdAddr); } else { serviceId = null; } if (entitlementIdAddr != 0) { entitlementId = Utilities.readStringZ(entitlementIdAddr); } else { entitlementId = null; } }
public void setUnalignedValue32(int offset, int value) { if (NotNull) { Utilities.writeUnaligned32(Memory, Address + offset, value); } }
public virtual int sceSha256Digest(TPointer data, int Length, TPointer digest) { if (log.TraceEnabled) { log.trace(string.Format("sceSha256Digest data:{0}", Utilities.getMemoryDump(data.Address, Length))); } // Read in the source data. sbyte[] b = new sbyte[Length]; IMemoryReader memoryReader = MemoryReader.getMemoryReader(data.Address, Length, 1); for (int i = 0; i < Length; i++) { b[i] = (sbyte)memoryReader.readNext(); } // Calculate SHA-256. SHA256 sha256 = new SHA256(); sbyte[] d = sha256.doSHA256(b, Length); // Write back the resulting digest. IMemoryWriter memoryWriter = MemoryWriter.getMemoryWriter(digest.Address, 0x20, 1); for (int i = 0; i < 0x20; i++) { memoryWriter.writeNext((sbyte)d[i]); } return(0); }
public virtual int sceAdler32(int adler, TPointer data, int Length) { if (log.TraceEnabled) { log.trace(string.Format("sceAdler32 data:{0}", Utilities.getMemoryDump(data.Address, Length))); } sbyte[] b = new sbyte[Length]; IMemoryReader memoryReader = MemoryReader.getMemoryReader(data.Address, Length, 1); for (int i = 0; i < Length; i++) { b[i] = (sbyte)memoryReader.readNext(); } adler32.reset(); adler32.update(adler); adler32.update(b); int result = (int)adler32.Value; //if (log.DebugEnabled) { Console.WriteLine(string.Format("sceAdler32 returning 0x{0:X8}", result)); } return(result); }
public virtual void copy(OutputConfiguration that) { m4ac.copy(that.m4ac); Utilities.copy(layoutMap, that.layoutMap); layoutMapTags = that.layoutMapTags; channels = that.channels; channelLayout = that.channelLayout; status = that.status; }
public virtual void copy(ChannelCoupling that) { couplingPoint = that.couplingPoint; numCoupled = that.numCoupled; Utilities.copy(type, that.type); Utilities.copy(idSelect, that.idSelect); Utilities.copy(chSelect, that.chSelect); Utilities.copy(gain, that.gain); }
public virtual void copy(TemporalNoiseShaping that) { present = that.present; Utilities.copy(nFilt, that.nFilt); Utilities.copy(Length, that.Length); Utilities.copy(direction, that.direction); Utilities.copy(order, that.order); Utilities.copy(coef, that.coef); }
public virtual int sceGzipDecompress(TPointer outBufferAddr, int outBufferLength, TPointer inBufferAddr, TPointer32 crc32Addr) { if (log.TraceEnabled) { log.trace(string.Format("sceGzipDecompress: {0}", Utilities.getMemoryDump(inBufferAddr.Address, 16))); } int result; CRC32 crc32 = new CRC32(); sbyte[] buffer = new sbyte[4096]; try { // Using a GZIPInputStream instead of an Inflater because the GZIPInputStream // is skipping the GZIP header and this should be done manually with an Inflater. GZIPInputStream @is = new GZIPInputStream(new MemoryInputStream(inBufferAddr.Address)); IMemoryWriter memoryWriter = MemoryWriter.getMemoryWriter(outBufferAddr.Address, outBufferLength, 1); int decompressedLength = 0; while (decompressedLength < outBufferLength) { int Length = @is.read(buffer); if (Length < 0) { // End of GZIP stream break; } if (decompressedLength + Length > outBufferLength) { Console.WriteLine(string.Format("sceGzipDecompress : decompress buffer too small inBuffer={0}, outLength={1:D}", inBufferAddr, outBufferLength)); @is.close(); return(SceKernelErrors.ERROR_INVALID_SIZE); } crc32.update(buffer, 0, Length); for (int i = 0; i < Length; i++) { memoryWriter.writeNext(buffer[i] & 0xFF); } decompressedLength += Length; } @is.close(); memoryWriter.flush(); result = decompressedLength; } catch (IOException e) { Console.WriteLine("sceGzipDecompress", e); return(SceKernelErrors.ERROR_INVALID_FORMAT); } crc32Addr.setValue((int)crc32.Value); return(result); }
public virtual int notifyAddStream(int bytesToAdd) { if (log.TraceEnabled) { log.trace(string.Format("notifyAddStream: {0}", Utilities.getMemoryDump(inputBuffer.WriteAddr, bytesToAdd))); } inputBuffer.notifyWrite(bytesToAdd); return(0); }
public virtual bool sceGzipIsValid(TPointer gzipData) { int magic = gzipData.Value16 & 0xFFFF; if (log.TraceEnabled) { log.trace(string.Format("sceGzipIsValid gzipData:{0}", Utilities.getMemoryDump(gzipData.Address, 16))); } return(magic == GZIP_MAGIC); }
public virtual void copy(ChannelElement that) { commonWindow = that.commonWindow; msMode = that.msMode; Utilities.copy(msMask, that.msMask); for (int i = 0; i < ch.Length; i++) { ch[i].copy(that.ch[i]); } coup.copy(that.coup); sbr.copy(that.sbr); }
public static void call(int valueEqual, int valueLower, int valueHigher) { int str1 = GprA0; int str2 = GprA1; if (str1 == 0 || str2 == 0) { if (str1 == str2) { GprV0 = valueEqual; } if (str1 != 0) { GprV0 = valueHigher; } else { GprV0 = valueLower; } } else { if (!Memory.isAddressGood(str1)) { Memory.invalidMemoryAddress(str1, "strcmp", Emulator.EMU_STATUS_MEM_READ); return; } if (!Memory.isAddressGood(str2)) { Memory.invalidMemoryAddress(str2, "strcmp", Emulator.EMU_STATUS_MEM_READ); return; } //if (log.DebugEnabled) { Console.WriteLine(string.Format("strcmp src1={0}, src2={1}", Utilities.getMemoryDump(str1, getStrlen(str1)), Utilities.getMemoryDump(str2, getStrlen(str2)))); } int cmp = strcmp(str1, str2); if (cmp < 0) { GprV0 = valueLower; } else if (cmp > 0) { GprV0 = valueHigher; } else { GprV0 = valueEqual; } } }
public virtual int notifyAddStream(int bytesToAdd) { bytesToAdd = System.Math.Min(bytesToAdd, WritableBytes); if (log.TraceEnabled) { log.trace(string.Format("notifyAddStream inputBuffer {0}: {1}", inputBuffer, Utilities.getMemoryDump(inputBuffer.WriteAddr, bytesToAdd))); } inputBuffer.notifyWrite(bytesToAdd); return 0; }
public virtual int sceSdRemoveValue(TPointer ctx2Addr, TPointer data, int size) { SAVEDATA.SD_Ctx1 ctx = new SAVEDATA.SD_Ctx1(); ctx.read(ctx2Addr); sbyte[] bytes = new sbyte[size]; Utilities.readBytes(data.Address, size, bytes, 0); int result = crypto.SAVEDATAEngine.hleSdRemoveValue(ctx, bytes, size); ctx.write(ctx2Addr); return(result); }
public override void setBufferData(int target, int buffer, int size, Buffer data, int usage) { BufferInfo bufferInfo = buffers[buffer]; if (bufferInfo.byteBuffer != data) { bufferInfo.byteBuffer.clear(); Utilities.putBuffer(bufferInfo.byteBuffer, data, ByteOrder.nativeOrder()); } else { bufferInfo.byteBuffer.position(0); } }
/* * This method is interpreting a code sequence but caching the decoded instructions. * No jumps or branches are allowed in the code sequence. */ public static void call(int numberInstructions, int codeBlockContextSize) { // First time being called? if (instructions == null) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'sealed override': //ORIGINAL LINE: sealed override int startAddress = getPc(); int startAddress = Pc; // Read the opcodes opcodes = Utilities.readInt32(startAddress, numberInstructions << 2); // Decode the opcodes into instructions instructions = new Instruction[numberInstructions]; for (int i = 0; i < numberInstructions; i++) { instructions[i] = Decoder.instruction(opcodes[i]); } // Search for the code block including this sequence (search backwards) CodeBlock codeBlock = null; for (int i = 0; i < codeBlockContextSize && codeBlock == null; i++) { codeBlock = RuntimeContext.getCodeBlock(startAddress - (i << 2)); } // Define the action that need to be executed when the compiler has detected // that the opcodes have been modified by the application. // In that case, the "opcodes" array need to be updated. if (codeBlock != null) { codeBlock.UpdateOpcodesAction = new UpdateOpcodesAction(startAddress, numberInstructions << 2, opcodes, 0); } else { Console.WriteLine(string.Format("CachedInterpreter: could not find the CodeBlock 0x{0:X8}", startAddress)); } } // Interpret the decoded instructions //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'sealed override': //ORIGINAL LINE: sealed override pspsharp.Processor processor = getProcessor(); Processor processor = Processor; for (int i = 0; i < numberInstructions; i++) { instructions[i].interpret(processor, opcodes[i]); } }
public virtual void copy(SpectralBandReplication that) { sampleRate = that.sampleRate; start = that.start; reset = that.reset; spectrumParams.copy(that.spectrumParams); bsAmpResHeader = that.bsAmpResHeader; bsLimiterBands = that.bsLimiterBands; bsLimiterGains = that.bsLimiterGains; bsInterpolFreq = that.bsInterpolFreq; bsSmoothingMode = that.bsSmoothingMode; bsCoupling = that.bsCoupling; Utilities.copy(k, that.k); Utilities.copy(kx, that.kx); Utilities.copy(m, that.m); kxAndMPushed = that.kxAndMPushed; nMaster = that.nMaster; for (int i = 0; i < data.Length; i++) { data[i].copy(that.data[i]); } ps.copy(that.ps); Utilities.copy(n, that.n); nQ = that.nQ; nLim = that.nLim; Utilities.copy(fMaster, that.fMaster); Utilities.copy(fTablelow, that.fTablelow); Utilities.copy(fTablehigh, that.fTablehigh); Utilities.copy(fTablenoise, that.fTablenoise); Utilities.copy(fTablelim, that.fTablelim); numPatches = that.numPatches; Utilities.copy(patchNumSubbands, that.patchNumSubbands); Utilities.copy(patchStartSubband, that.patchStartSubband); Utilities.copy(Xlow, that.Xlow); Utilities.copy(Xhigh, that.Xhigh); Utilities.copy(X, that.X); Utilities.copy(alpha0, that.alpha0); Utilities.copy(alpha1, that.alpha1); Utilities.copy(eOrigmapped, that.eOrigmapped); Utilities.copy(qMapped, that.qMapped); Utilities.copy(sMapped, that.sMapped); Utilities.copy(eCurr, that.eCurr); Utilities.copy(qM, that.qM); Utilities.copy(sM, that.sM); Utilities.copy(gain, that.gain); Utilities.copy(qmfFilterScratch, that.qmfFilterScratch); mdctAna.copy(that.mdctAna); mdct.copy(that.mdct); }
public GETexture(int address, int bufferWidth, int width, int height, int pixelFormat, bool useViewportResize) { this.address = address; this.bufferWidth = bufferWidth; this.width = width; this.height = height; this.pixelFormat = pixelFormat; bytesPerPixel = sceDisplay.getPixelFormatBytes(pixelFormat); Length = bufferWidth * height * bytesPerPixel; widthPow2 = Utilities.makePow2(width); heightPow2 = Utilities.makePow2(height); this.useViewportResize = useViewportResize; changed = true; resizeScale = ViewportResizeScaleFactor; }
public virtual int sceSdSetMember(TPointer ctx2Addr, TPointer8 data, int dataLength) { SAVEDATA.SD_Ctx2 ctx = new SAVEDATA.SD_Ctx2(); ctx.read(ctx2Addr); sbyte[] dataBytes = new sbyte[dataLength]; Utilities.readBytes(data.Address, dataLength, dataBytes, 0); int result = crypto.SAVEDATAEngine.hleSdSetMember(ctx, dataBytes, dataLength); Utilities.writeBytes(data.Address, dataBytes.Length, dataBytes, 0); ctx.write(ctx2Addr); return(result); }
public static int readByteBuffer(int address, ByteBuffer destination, int Length) { readByteBuffer_Renamed.start(); Buffer source = Memory.getBuffer(address, Length); int offset = 0; if (source != null) { if (source is IntBuffer) { offset = address & 3; } Utilities.putBuffer(destination, source, ByteOrder.LITTLE_ENDIAN, Length + offset); } readByteBuffer_Renamed.end(); return(offset); }
public override int genBuffer(int target, int type, int size, int usage) { int totalSize = size * sizeOfType[type]; ByteBuffer byteBuffer = createByteBuffer(totalSize); int buffer = re.genBuffer(); if (buffer >= bufferDataSize.Length) { bufferDataSize = Utilities.extendArray(bufferDataSize, buffer - bufferDataSize.Length + 1); } setBufferData(target, buffer, totalSize, byteBuffer, usage); buffers[buffer] = new BufferInfo(buffer, byteBuffer, type, size); return(buffer); }
internal virtual void parseMp3FrameHeader() { Memory mem = Memory.Instance; int startAddr = inputBuffer.Addr; int headerAddr = startAddr; int header = readUnaligned32(mem, headerAddr); // Skip the ID3 tags if ((header & 0x00FFFFFF) == ID3) { int size = endianSwap32(readUnaligned32(mem, startAddr + 6)); // Highest bit of each byte has to be ignored (format: 0x7F7F7F7F) size = (size & 0x7F) | ((size & 0x7F00) >> 1) | ((size & 0x7F0000) >> 2) | ((size & 0x7F000000) >> 3); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Skipping ID3 of size 0x{0:X}", size)); } inputBuffer.notifyRead(10 + size); headerAddr = startAddr + 10 + size; header = readUnaligned32(mem, headerAddr); } if (!isMp3Magic(header)) { Console.WriteLine(string.Format("Invalid MP3 header 0x{0:X8}", header)); return; } header = Utilities.endianSwap32(header); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Mp3 header: 0x{0:X8}", header)); } Mp3Header mp3Header = new Mp3Header(); Mp3Decoder.decodeHeader(mp3Header, header); version = mp3Header.version; channels = mp3Header.nbChannels; sampleRate = mp3Header.sampleRate; bitRate = mp3Header.bitRate; maxSamples = mp3Header.maxSamples; parseInfoTag(headerAddr + 4 + infoTagOffsets[mp3Header.lsf][mp3Header.nbChannels - 1]); parseVbriTag(headerAddr + 4 + 32); }