Beispiel #1
0
  @HLEFunction(nid = 0x4C06E472, version = 150)
  public int sceGeContinue() {
    PspGeList list;
    if (ExternalGE.isActive()) {
      list = ExternalGE.getCurrentList();
    } else {
      list = VideoEngine.getInstance().getCurrentList();
    }

    if (list != null) {
      synchronized (this) {
        if (list.status == PSP_GE_LIST_END_REACHED) {
          Memory mem = Memory.getInstance();
          if (mem.read32(list.getPc()) == (GeCommands.FINISH << 24)
              && mem.read32(list.getPc() + 4) == (GeCommands.END << 24)) {
            list.readNextInstruction();
            list.readNextInstruction();
          }
        }
        list.restartList();
      }
    }

    return 0;
  }
  public int sceKernelReferLwMutexStatus(int workAreaAddr, int addr) {
    Memory mem = Processor.memory;

    int uid = mem.read32(workAreaAddr);

    if (log.isDebugEnabled()) {
      log.debug(
          "sceKernelReferLwMutexStatus (workAreaAddr=0x"
              + Integer.toHexString(workAreaAddr)
              + ", addr=0x"
              + addr
              + ")");
    }

    SceKernelLwMutexInfo info = lwMutexMap.get(uid);
    if (info == null) {
      log.warn("sceKernelReferLwMutexStatus unknown UID " + Integer.toHexString(uid));
      return ERROR_KERNEL_LWMUTEX_NOT_FOUND;
    }
    if (!Memory.isAddressGood(addr)) {
      log.warn("sceKernelReferLwMutexStatus bad address 0x" + Integer.toHexString(addr));
      return -1;
    }

    info.write(mem, addr);

    return 0;
  }
  public int sceKernelUnlockLwMutex(int workAreaAddr, int count) {
    Memory mem = Processor.memory;

    int uid = mem.read32(workAreaAddr);

    if (log.isDebugEnabled()) {
      log.debug(
          "sceKernelUnlockLwMutex (workAreaAddr=0x"
              + Integer.toHexString(workAreaAddr)
              + ", count="
              + count
              + ")");
    }

    SceKernelLwMutexInfo info = lwMutexMap.get(uid);
    if (info == null) {
      log.warn("sceKernelUnlockLwMutex unknown uid");
      return ERROR_KERNEL_LWMUTEX_NOT_FOUND;
    }
    if (info.lockedCount == 0) {
      log.debug("sceKernelUnlockLwMutex not locked");
      return ERROR_KERNEL_LWMUTEX_UNLOCKED;
    }
    if (info.lockedCount < 0) {
      log.warn("sceKernelUnlockLwMutex underflow");
      return ERROR_KERNEL_LWMUTEX_UNLOCK_UNDERFLOW;
    }

    info.lockedCount -= count;
    if (info.lockedCount == 0) {
      onLwMutexModified(info);
    }

    return 0;
  }
Beispiel #4
0
  @Override
  public void resolve(Memory mem, int address) {
    if (!hasSavedValue) {
      savedValue = mem.read32(getImportAddress());
      hasSavedValue = true;
    }

    // Perform a R_MIPS_32 relocation

    // Retrieve the current 32bit value
    int value = mem.read32(getImportAddress());

    // Relocate the value
    value += address;

    // Write back the relocated 32bit value
    mem.write32(getImportAddress(), value);
  }
  public int sceKernelTryLockLwMutex(int workAreaAddr, int count) {
    Memory mem = Processor.memory;

    int uid = mem.read32(workAreaAddr);

    if (log.isDebugEnabled()) {
      log.debug("sceKernelTryLockLwMutex redirecting to hleKernelLockLwMutex");
    }
    return hleKernelLockLwMutex(uid, count, 0, false, false);
  }
  public int sceKernelLockLwMutexCB(int workAreaAddr, int count, int timeout_addr) {
    Memory mem = Processor.memory;

    int uid = mem.read32(workAreaAddr);

    if (log.isDebugEnabled()) {
      log.debug("sceKernelLockLwMutexCB redirecting to hleKernelLockLwMutex");
    }
    return hleKernelLockLwMutex(uid, count, timeout_addr, true, true);
  }
Beispiel #7
0
  public int getAddress(Memory mem, int i) {
    if (ptr_index != 0 && index != 0) {
      int addr = ptr_index + i * index;
      switch (index) {
        case 1:
          i = mem.read8(addr);
          break; // GU_INDEX_8BIT
        case 2:
          i = mem.read16(addr);
          break; // GU_INDEX_16BIT
        case 3:
          i = mem.read32(addr);
          break; // GU_INDEX_UNK3 (assume 32bit)
      }
    }

    return ptr_vertex + i * vertexSize;
  }
  public int sceKernelDeleteLwMutex(int workAreaAddr) {
    Memory mem = Processor.memory;

    int uid = mem.read32(workAreaAddr);

    if (log.isDebugEnabled()) {
      log.debug("sceKernelDeleteLwMutex (workAreaAddr='" + Integer.toHexString(workAreaAddr) + ")");
    }

    SceKernelLwMutexInfo info = lwMutexMap.remove(uid);
    if (info == null) {
      log.warn("sceKernelDeleteLwMutex unknown UID " + Integer.toHexString(uid));
      return ERROR_KERNEL_LWMUTEX_NOT_FOUND;
    }

    mem.write32(workAreaAddr, 0); // Clear uid.
    onLwMutexDeleted(uid);

    return 0;
  }
Beispiel #9
0
  public void atracSetData(
      int atracID, int codecType, int address, int length, int atracFileSize, int atracHash) {
    this.atracFileSize = atracFileSize;
    this.atracBufferAddress = address;
    this.atracHash = atracHash;
    id = generateID(address, length, atracFileSize);
    closeStreams();
    atracEndSample = -1;
    requireAllAtracData = false;

    int memoryCodecType = sceAtrac3plus.getCodecType(address);
    if (memoryCodecType != codecType && memoryCodecType != 0) {
      Modules.log.info(
          String.format(
              "Different CodecType received %d != %d, assuming %d",
              codecType, memoryCodecType, memoryCodecType));
      codecType = memoryCodecType;
    }

    if (codecType == 0x00001001) {
      Modules.log.info("Decodable AT3 data detected.");
      if (checkMediaEngineState()) {
        me.finish();
        atracChannel = new PacketChannel();
        atracChannel.setTotalStreamSize(atracFileSize);
        atracChannel.setFarRewindAllowed(true);
        atracChannel.write(address, length);
        // Defer the initialization of the MediaEngine until atracDecodeData()
        // to ensure we have enough data into the channel.
        atracEndSample = 0;
        return;
      }
    } else if (codecType == 0x00001000) {
      if (checkMediaEngineState() && ExternalDecoder.isEnabled()) {
        String decodedFile =
            externalDecoder.decodeAtrac(address, length, atracFileSize, atracHash, this);
        if (decodedFile != null) {
          Modules.log.info("AT3+ data decoded by the external decoder.");
          me.finish();
          atracChannel = null;
          me.init(new FileProtocolHandler(decodedFile), false, true, 0, 0);
          atracEndSample = -1;
          return;
        } else if (requireAllAtracData) {
          // The external decoder requires all the atrac data
          // before it can try to decode the atrac.
          me.finish();
          atracChannel = new PacketChannel();
          atracChannel.setTotalStreamSize(atracFileSize);
          atracChannel.write(address, length);
          return;
        }
        Modules.log.info("AT3+ data could not be decoded by the external decoder.");
      } else {
        Modules.log.info("Undecodable AT3+ data detected.");
      }
    }
    me = null;

    File decodedFile = new File(getCompleteFileName(decodedAtracSuffix));

    if (!decodedFile.canRead()) {
      // Try to read the decoded file using an alternate file name,
      // without HashCode. These files can be generated by external tools
      // decoding the Atrac3+ files. These tools can't generate the HashCode.
      //
      // Use the following alternate file name scheme:
      //       Atrac-SSSSSSSS-NNNNNNNN-DDDDDDDD.at3.decoded
      // where SSSSSSSS is the file size in Hex
      //       NNNNNNNN is the number of samples in Hex found in the "fact" Chunk
      //       DDDDDDDD are the first 32-bit in Hex found in the "data" Chunk
      int numberOfSamples = 0;
      int data = 0;

      // Scan the Atrac data for NNNNNNNN and DDDDDDDD values
      Memory mem = Memory.getInstance();
      int scanAddress = address + 12;
      int endScanAddress = address + length;
      while (scanAddress < endScanAddress) {
        int chunkHeader = mem.read32(scanAddress);
        int chunkSize = mem.read32(scanAddress + 4);

        if (chunkHeader == waveFactChunkHeader) {
          numberOfSamples = mem.read32(scanAddress + 8);
        } else if (chunkHeader == waveDataChunkHeader) {
          data = mem.read32(scanAddress + 8);
          break;
        }

        // Go to the next Chunk
        scanAddress += chunkSize + 8;
      }

      File alternateDecodedFile =
          new File(
              String.format(
                  "%sAtrac-%08X-%08X-%08X%s",
                  getBaseDirectory(), atracFileSize, numberOfSamples, data, decodedAtracSuffix));
      if (alternateDecodedFile.canRead()) {
        decodedFile = alternateDecodedFile;
      }
    }

    File atracFile = new File(getCompleteFileName(atracSuffix));
    if (decodedFile.canRead()) {
      try {
        decodedStream = new RandomAccessFile(decodedFile, "r");
        atracEndSample = (int) (decodedFile.length() / 4);
      } catch (FileNotFoundException e) {
        // Decoded file should already be present
        Modules.log.warn(e);
      }
    } else if (atracFile.canRead() && atracFile.length() == atracFileSize) {
      // Atrac file is already written, no need to write it again
    } else if (sceAtrac3plus.isEnableConnector()) {
      commandFileDirty = true;
      displayInstructions();
      new File(getBaseDirectory()).mkdirs();

      try {
        atracStream = new FileOutputStream(getCompleteFileName(atracSuffix));
        byte[] buffer = new byte[length];
        IMemoryReader memoryReader = MemoryReader.getMemoryReader(address, length, 1);
        for (int i = 0; i < length; i++) {
          buffer[i] = (byte) memoryReader.readNext();
        }
        atracStream.write(buffer);
      } catch (IOException e) {
        Modules.log.warn(e);
      }
      generateCommandFile();
    }
  }