예제 #1
0
  // sceKernelAllocMemoryBlock (internal name)
  @HLEFunction(nid = 0xFE707FDF, version = 352)
  public int SysMemUserForUser_FE707FDF(
      @StringInfo(maxLength = 32) PspString name,
      int type,
      int size,
      @CanBeNull TPointer paramsAddr) {
    if (paramsAddr.isNotNull()) {
      int length = paramsAddr.getValue32();
      if (length != 4) {
        log.warn(
            String.format("SysMemUserForUser_FE707FDF: unknown parameters with length=%d", length));
      }
    }

    if (type < PSP_SMEM_Low || type > PSP_SMEM_High) {
      return SceKernelErrors.ERROR_KERNEL_ILLEGAL_MEMBLOCK_ALLOC_TYPE;
    }

    // Always allocate memory in user area (partitionid == 2).
    SysMemInfo info = malloc(SysMemUserForUser.USER_PARTITION_ID, name.getString(), type, size, 0);
    if (info == null) {
      return SceKernelErrors.ERROR_KERNEL_FAILED_ALLOC_MEMBLOCK;
    }

    return info.uid;
  }
예제 #2
0
  @HLEFunction(nid = 0x0BF608FB, version = 150)
  public int sceGeRestoreContext(TPointer contextAddr) {
    if (ExternalGE.isActive()) {
      return ExternalGE.restoreContext(contextAddr.getAddress());
    }

    VideoEngine.getInstance().hleRestoreContext(contextAddr.getAddress());

    return 0;
  }
예제 #3
0
  @HLEFunction(nid = 0x438A385A, version = 150)
  public int sceGeSaveContext(TPointer contextAddr) {
    if (ExternalGE.isActive()) {
      return ExternalGE.saveContext(contextAddr.getAddress());
    }

    VideoEngine.getInstance().hleSaveContext(contextAddr.getAddress());

    return 0;
  }
예제 #4
0
  @HLEFunction(nid = 0xE0D68148, version = 150)
  public int sceGeListUpdateStallAddr(
      @CheckArgument("checkListId") int id, @CanBeNull TPointer stallAddr) {
    synchronized (this) {
      PspGeList list = allGeLists[id];
      if (list.getStallAddr() != stallAddr.getAddress()) {
        list.setStallAddr(stallAddr.getAddress());
        Modules.sceDisplayModule.setGeDirty(true);
      }
    }

    return 0;
  }
예제 #5
0
  @HLEFunction(nid = 0x57C8945B, version = 150)
  public int sceGeGetMtx(int mtxType, TPointer mtxAddr) {
    if (mtxType < 0 || mtxType > PSP_GE_MATRIX_TEXGEN) {
      log.warn(String.format("sceGeGetMtx invalid type mtxType=%d", mtxType));
      return SceKernelErrors.ERROR_INVALID_INDEX;
    }

    float[] mtx;
    if (ExternalGE.isActive()) {
      mtx = ExternalGE.getMatrix(mtxType);
    } else {
      mtx = VideoEngine.getInstance().getMatrix(mtxType);
    }

    for (int i = 0; i < mtx.length; i++) {
      // Float value is returned in lower 24 bits.
      mtxAddr.setValue32(i << 2, Float.floatToRawIntBits(mtx[i]) >>> 8);
    }

    if (log.isInfoEnabled()) {
      log.info(String.format("sceGeGetMtx mtxType=%d, mtxAddr=%s, mtx=%s", mtxType, mtxAddr, mtx));
    }

    return 0;
  }
예제 #6
0
  @HLEFunction(nid = 0x0C116E1B, version = 620)
  public int sceAtracLowLevelDecode(
      @CheckArgument("checkAtracID") int atID,
      TPointer sourceAddr,
      TPointer32 sourceBytesConsumedAddr,
      TPointer samplesAddr,
      TPointer32 sampleBytesAddr) {
    AtracID id = atracIDs[atID];
    ICodec codec = id.getCodec();

    if (log.isTraceEnabled()) {
      log.trace(
          String.format(
              "sceAtracLowLevelDecode input:%s",
              Utilities.getMemoryDump(sourceAddr.getAddress(), id.getSourceBufferLength())));
    }

    int sourceBytesConsumed = 0;
    int bytesPerSample = id.getOutputChannels() << 1;
    int result =
        codec.decode(sourceAddr.getAddress(), id.getSourceBufferLength(), samplesAddr.getAddress());
    if (log.isDebugEnabled()) {
      log.debug(String.format("sceAtracLowLevelDecode codec returned 0x%08X", result));
    }
    if (result < 0) {
      log.info(String.format("sceAtracLowLevelDecode codec returning 0x%08X", result));
      return result;
    }
    sourceBytesConsumed = result > 0 ? id.getSourceBufferLength() : 0;
    sampleBytesAddr.setValue(codec.getNumberOfSamples() * bytesPerSample);

    // Consume a part of the Atrac3 source buffer
    sourceBytesConsumedAddr.setValue(sourceBytesConsumed);

    Modules.ThreadManForUserModule.hleKernelDelayThread(atracDecodeDelay, false);

    return 0;
  }
예제 #7
0
  public int hleGeListEnQueue(
      TPointer listAddr,
      @CanBeNull TPointer stallAddr,
      int cbid,
      @CanBeNull TPointer argAddr,
      int saveContextAddr,
      boolean enqueueHead) {
    pspGeListOptParam optParams = null;
    int stackAddr = 0;
    if (argAddr.isNotNull()) {
      optParams = new pspGeListOptParam();
      optParams.read(argAddr);
      stackAddr = optParams.stackAddr;
      if (log.isDebugEnabled()) {
        log.debug(String.format("hleGeListEnQueue optParams=%s", optParams));
      }
    }

    if (Modules.SysMemUserForUserModule.hleKernelGetCompiledSdkVersion() >= 0x02000000) {
      boolean isBusy;
      if (ExternalGE.isActive()) {
        isBusy = ExternalGE.hasDrawList(listAddr.getAddress(), stackAddr);
      } else {
        isBusy = VideoEngine.getInstance().hasDrawList(listAddr.getAddress(), stackAddr);
      }
      if (isBusy) {
        log.warn(
            String.format(
                "hleGeListEnQueue can't enqueue duplicate list address %s, stack 0x%08X",
                listAddr, stackAddr));
        return SceKernelErrors.ERROR_BUSY;
      }
    }

    int result;
    synchronized (this) {
      PspGeList list = listFreeQueue.poll();
      if (list == null) {
        log.warn("hleGeListEnQueue no more free list available!");
        if (log.isDebugEnabled()) {
          for (int i = 0; i < NUMBER_GE_LISTS; i++) {
            log.debug(String.format("List#%d: %s", i, allGeLists[i]));
          }
        }
        return SceKernelErrors.ERROR_OUT_OF_MEMORY;
      }

      list.init(listAddr.getAddress(), stallAddr.getAddress(), cbid, optParams);
      list.setSaveContextAddr(saveContextAddr);
      if (enqueueHead) {
        // Send the list to the VideoEngine at the head of the queue.
        list.startListHead();
      } else {
        // Send the list to the VideoEngine before triggering the display (setting GE dirty)
        list.startList();
      }
      Modules.sceDisplayModule.setGeDirty(true);
      result = list.id;
    }

    if (log.isDebugEnabled()) {
      log.debug(String.format("hleGeListEnQueue returning 0x%X", result));
    }

    return result;
  }