Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions core/libs/SceTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,49 @@ struct AudioOut2MasteringStatesHeader {
std::uint32_t states_id;
};

struct AudioOut2MasteringStatesDescriptor {
std::uint32_t id;
std::uint32_t size;
};

struct AudioOut2MasteringCompressorStates {
AudioOut2MasteringStatesDescriptor descriptor;
std::uint32_t reserved[2];
float input_rms[3][8];
float compression_coeff[3][8];
};

struct AudioOut2MasteringCompressorStatesV2 {
AudioOut2MasteringStatesDescriptor descriptor;
std::uint32_t reserved[2];
float input_rms[4][8];
float compression_coeff[4][8];
};

struct AudioOut2MasteringLimiterStates {
AudioOut2MasteringStatesDescriptor descriptor;
std::uint32_t reserved[2];
float input_peak[8];
float output_peak[8];
float gain_peak[8];
};

struct AudioOut2MasteringStates {
AudioOut2MasteringStatesHeader states_header;
std::uint32_t reserved[3];
AudioOut2MasteringCompressorStates compressor_states;
AudioOut2MasteringLimiterStates limiter_states;
};
static_assert(sizeof(AudioOut2MasteringStates) == 336);

struct AudioOut2MasteringStatesV2 {
AudioOut2MasteringStatesHeader states_header;
std::uint32_t reserved[3];
AudioOut2MasteringCompressorStatesV2 compressor_states;
AudioOut2MasteringLimiterStates limiter_states;
};
static_assert(sizeof(AudioOut2MasteringStatesV2) == 400);

struct AudioOutOutputParam {
int handle;
const void* ptr;
Expand Down
30 changes: 20 additions & 10 deletions core/libs/prx/libSceAgcDriver/Submit/src/CommandBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
#include "prx/libSceAgcDriver/Submit/include/CommandBuffer.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"

#include <cstdint>
#include <cstddef>
#include <stdexcept>
#include <string>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"

extern "C" {

int APS5_VABI sceAgcDriverSubmitCommandBuffer(void* queue_context, const Packet* packet) {
(void)queue_context;
(void)packet;
NotImplemented_nid_no_patch(__func__);
return 0;
if (queue_context == nullptr || packet == nullptr) {
throw std::runtime_error(std::string(__func__) + ": null queue context or command buffer");
}
AgcDriver::Submit(packet, 0);
return 0;
}

int APS5_VABI sceAgcDriverSubmitMultiCommandBuffers(void* queue_context, uint32_t* const* command_buffers, const uint32_t* sizes_in_dwords, uint32_t count) {
(void)queue_context;
(void)command_buffers;
(void)sizes_in_dwords;
(void)count;
NotImplemented_nid_no_patch(__func__);
return 0;
if (count == 0) return 0;
if (queue_context == nullptr || command_buffers == nullptr || sizes_in_dwords == nullptr) {
throw std::runtime_error(std::string(__func__) + ": null queue context or command buffer arrays");
}
AgcDriver::GuestMemory::CheckRange(command_buffers, count * sizeof(*command_buffers), alignof(std::uint32_t*));
AgcDriver::GuestMemory::CheckRange(sizes_in_dwords, count * sizeof(*sizes_in_dwords), alignof(std::uint32_t));
for (uint32_t i = 0; i < count; ++i) {
const Packet packet{command_buffers[i], sizes_in_dwords[i], 0, {}};
AgcDriver::Submit(&packet, 0);
}
return 0;
}

}
12 changes: 0 additions & 12 deletions core/libs/prx/libSceAjm.native/Export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ static void AjmStub(const char* name) {

extern "C" {

int APS5_VABI sceAjmBatchJobDecodeSplit(AjmBatchInfo* info, uint32_t instance, const AjmBuffer* input_buffers, size_t input_buffers_num, const AjmBuffer* output_buffers, size_t output_buffers_num, void* result) {
(void)info;
(void)instance;
(void)input_buffers;
(void)input_buffers_num;
(void)output_buffers;
(void)output_buffers_num;
(void)result;
AjmStub(__func__);
return 0;
}

int APS5_VABI sceAjmBatchJobEncode(AjmBatchInfo* info, uint32_t instance, const void* pcm_input, size_t pcm_input_size, void* bitstream_output, size_t bitstream_output_size, void* result) {
(void)info;
(void)instance;
Expand Down
4 changes: 4 additions & 0 deletions core/libs/prx/libSceAjm.native/src/Ajm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,10 @@ int APS5_VABI sceAjmBatchJobDecode(AjmBatchInfo* info, uint32_t instance, const
return sceAjmBatchJobRun(info, instance, SIDEBAND_STREAM, bitstream_input, bitstream_input_size, pcm_output, pcm_output_size, result, sizeof(SidebandResult) + sizeof(SidebandStream));
}

int APS5_VABI sceAjmBatchJobDecodeSplit(AjmBatchInfo* info, uint32_t instance, const AjmBuffer* input_buffers, size_t input_buffers_num, const AjmBuffer* output_buffers, size_t output_buffers_num, void* result) {
return sceAjmBatchJobRunSplit(info, instance, SIDEBAND_STREAM, input_buffers, input_buffers_num, output_buffers, output_buffers_num, result, sizeof(SidebandResult) + sizeof(SidebandStream));
}

int APS5_VABI sceAjmBatchJobDecodeSingle(AjmBatchInfo* info, uint32_t instance, const void* bitstream_input, size_t bitstream_input_size, void* pcm_output, size_t pcm_output_size, void* result) {
return sceAjmBatchJobRun(info, instance, SIDEBAND_STREAM, bitstream_input, bitstream_input_size, pcm_output, pcm_output_size, result, sizeof(SidebandResult) + sizeof(SidebandStream));
}
Expand Down
60 changes: 31 additions & 29 deletions core/libs/prx/libSceAudioIn/Export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ constexpr int AUDIO_IN_ERROR_PORT_FULL = static_cast<int>(0x80260107);
constexpr int AUDIO_IN_ERROR_BUSY = static_cast<int>(0x8026010A);
constexpr int AUDIO_IN_SILENT_STATE_DEVICE_NONE = 1;
constexpr std::uint32_t MAX_QUEUED_BLOCKS = 4;
constexpr std::uint32_t MAX_GRAIN_ASYNC = 384;

using Clock = std::chrono::steady_clock;

Expand All @@ -47,6 +48,7 @@ bool formatOf(std::uint32_t param, Format& format) {
switch (param) {
case 1: format = {AUDIO_S16SYS, 1}; return true;
case 2: format = {AUDIO_S16SYS, 2}; return true;
case 0x10:
case 0x11: format = {AUDIO_F32SYS, 1}; return true;
case 0x12: format = {AUDIO_F32SYS, 2}; return true;
default: return false;
Expand All @@ -69,6 +71,18 @@ SDL_AudioDeviceID openDevice(std::uint32_t freq, std::uint32_t samples, const Fo
return device;
}

int openPort(std::uint32_t len, std::uint32_t freq, const Format& format) {
std::lock_guard lock(g_mutex);
for (std::size_t i = 0; i < g_ports.size(); ++i) {
if (g_ports[i].used) continue;
const auto frameBytes = static_cast<std::uint32_t>(SDL_AUDIO_BITSIZE(format.format) / 8 * format.channels);
const auto grain = std::chrono::duration_cast<Clock::duration>(std::chrono::microseconds(1000000ull * len / freq));
g_ports[i] = {true, false, len, frameBytes, openDevice(freq, len, format), grain, {}};
return static_cast<int>(i + 1);
}
return AUDIO_IN_ERROR_PORT_FULL;
}

Port* find(int handle) {
if (handle <= 0 || static_cast<std::size_t>(handle) > g_ports.size()) return nullptr;
Port& port = g_ports[static_cast<std::size_t>(handle - 1)];
Expand Down Expand Up @@ -136,21 +150,9 @@ int APS5_VABI sceAudioInOpen(int user_id, uint32_t type, uint32_t index, uint32_
if (index != 0) return AUDIO_IN_ERROR_INVALID_PARAM;
if (len != 128 && len != 256) return AUDIO_IN_ERROR_INVALID_SIZE;
if (freq != 48000 && freq != 16000) return AUDIO_IN_ERROR_INVALID_FREQ;
if (param == 0x10) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
Format format{};
if (!formatOf(param, format)) return AUDIO_IN_ERROR_INVALID_PARAM;
std::lock_guard lock(g_mutex);
for (std::size_t i = 0; i < g_ports.size(); ++i) {
if (g_ports[i].used) continue;
const auto frameBytes = static_cast<std::uint32_t>(SDL_AUDIO_BITSIZE(format.format) / 8 * format.channels);
const auto grain = std::chrono::duration_cast<Clock::duration>(std::chrono::microseconds(1000000ull * len / freq));
g_ports[i] = {true, false, len, frameBytes, openDevice(freq, len, format), grain, {}};
return static_cast<int>(i + 1);
}
return AUDIO_IN_ERROR_PORT_FULL;
return openPort(len, freq, format);
}

int32_t APS5_VABI sceAudioInClose(int32_t handle) {
Expand All @@ -164,25 +166,25 @@ int32_t APS5_VABI sceAudioInClose(int32_t handle) {
}

int32_t APS5_VABI sceAudioInHqOpen(int32_t user_id, uint32_t type, uint32_t index, uint32_t len, uint32_t freq, uint32_t param) {
(void)user_id;
(void)type;
(void)index;
(void)len;
(void)freq;
(void)param;
NotImplemented_nid_no_patch(__func__);
return 0;
(void)user_id;
if (type != 0 && type != 1) return AUDIO_IN_ERROR_INVALID_TYPE;
if (index != 0) return AUDIO_IN_ERROR_INVALID_PARAM;
if (len != 128) return AUDIO_IN_ERROR_INVALID_SIZE;
if (freq != 48000) return AUDIO_IN_ERROR_INVALID_FREQ;
Format format{};
if (!formatOf(param, format)) return AUDIO_IN_ERROR_INVALID_PARAM;
return openPort(len, freq, format);
}

int32_t APS5_VABI sceAudioInAsyncOpen(int32_t user_id, uint32_t type, uint32_t index, uint32_t len, uint32_t freq, uint32_t param) {
(void)user_id;
(void)type;
(void)index;
(void)len;
(void)freq;
(void)param;
NotImplemented_nid_no_patch(__func__);
return 0;
(void)user_id;
if (type != 0 && type != 1) return AUDIO_IN_ERROR_INVALID_TYPE;
if (index != 0) return AUDIO_IN_ERROR_INVALID_PARAM;
if (len > MAX_GRAIN_ASYNC) return AUDIO_IN_ERROR_INVALID_SIZE;
if (freq != 48000 && freq != 16000) return AUDIO_IN_ERROR_INVALID_FREQ;
Format format{};
if (!formatOf(param, format)) return AUDIO_IN_ERROR_INVALID_PARAM;
return openPort(len, freq, format);
}

APS5_EXPORT("X+4jdIS75P0", sceAudioInUnknown_X4jdIS75P0);
Expand Down
36 changes: 33 additions & 3 deletions core/libs/prx/libSceAudioOut/src/AudioOut2Mastering.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#include <cstdint>
#include <cstring>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"

static constexpr int SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_API_PARAM = static_cast<int>(0x80268201);
static constexpr int SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_STATES_ID = static_cast<int>(0x80268204);
static constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_ID_DEFAULT = 1;
static constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_ID_V2 = 2;
static constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_COMPRESSOR_DEFAULT = 0x01010001;
static constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_COMPRESSOR_V2 = 0x01020001;
static constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_LIMITER_DEFAULT = 0x01010003;

extern "C" {

int APS5_VABI sceAudioOut2MasteringInit(uint32_t flags) {
Expand All @@ -14,11 +23,32 @@ int APS5_VABI sceAudioOut2MasteringTerm(void) {
}

int APS5_VABI sceAudioOut2MasteringGetState(AudioOut2MasteringStatesHeader* state, uint32_t output, AudioOut2UserHandle user) {
(void)state;
(void)output;
(void)user;
NotImplemented_nid_no_patch(__func__);
return 0;
if (state == nullptr) return SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_API_PARAM;
switch (state->states_id) {
case AUDIO_OUT2_MASTERING_STATES_ID_DEFAULT: {
auto* full_state = reinterpret_cast<AudioOut2MasteringStates*>(state);
std::memset(full_state, 0, sizeof(AudioOut2MasteringStates));
full_state->states_header.states_id = AUDIO_OUT2_MASTERING_STATES_ID_DEFAULT;
full_state->compressor_states.descriptor.id = AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_COMPRESSOR_DEFAULT;
full_state->compressor_states.descriptor.size = sizeof(AudioOut2MasteringCompressorStates);
full_state->limiter_states.descriptor.id = AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_LIMITER_DEFAULT;
full_state->limiter_states.descriptor.size = sizeof(AudioOut2MasteringLimiterStates);
return 0;
}
case AUDIO_OUT2_MASTERING_STATES_ID_V2: {
auto* full_state = reinterpret_cast<AudioOut2MasteringStatesV2*>(state);
std::memset(full_state, 0, sizeof(AudioOut2MasteringStatesV2));
full_state->states_header.states_id = AUDIO_OUT2_MASTERING_STATES_ID_V2;
full_state->compressor_states.descriptor.id = AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_COMPRESSOR_V2;
full_state->compressor_states.descriptor.size = sizeof(AudioOut2MasteringCompressorStatesV2);
full_state->limiter_states.descriptor.id = AUDIO_OUT2_MASTERING_STATES_STRUCT_ID_LIMITER_DEFAULT;
full_state->limiter_states.descriptor.size = sizeof(AudioOut2MasteringLimiterStates);
return 0;
}
default: return SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_STATES_ID;
}
}

int APS5_VABI sceAudioOut2MasteringSetParam(const AudioOut2MasteringParamsHeader* param, uint32_t output, uint32_t flags) {
Expand Down
11 changes: 8 additions & 3 deletions core/libs/prx/libSceAudioOut/src/AudioOut2System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
static constexpr int USER_ID_SYSTEM = 0xFF;
static constexpr std::uint32_t MIN_SUPPORTED_3D_LATENCY = 1;
static constexpr std::uint32_t MAX_SUPPORTED_3D_LATENCY = 2;
static constexpr int SCE_AUDIO_OUT2_ERROR_INVALID_ARGUMENT = static_cast<int>(0x80260502);
static constexpr std::uint32_t PORT_ATTRIBUTE_ID_PCM = 0;
static constexpr std::uint32_t PORT_ATTRIBUTE_ID_GAIN = 1;
static constexpr std::uint32_t PORT_ATTRIBUTE_ID_AMBISONICS = 8;

extern "C" {

Expand All @@ -25,12 +29,13 @@ int APS5_VABI sceAudioOut2GetSystemState(AudioOut2SystemState* state) {

int APS5_VABI sceAudioOut2SetSystemDebugState(const AudioOut2SystemDebugStateParam* param) {
(void)param;
NotImplemented_nid_no_patch(__func__);
return 0;
}

int APS5_VABI sceAudioOut2UserGetSupportedAttributes(void) {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceAudioOut2UserGetSupportedAttributes(AudioOut2UserHandle handle, std::uint32_t* contextAttributes, std::uint32_t* portAttributes) {
if (contextAttributes == nullptr || portAttributes == nullptr || handle == 0) return SCE_AUDIO_OUT2_ERROR_INVALID_ARGUMENT;
*contextAttributes = 0;
*portAttributes = (1u << PORT_ATTRIBUTE_ID_PCM) | (1u << PORT_ATTRIBUTE_ID_GAIN) | (1u << PORT_ATTRIBUTE_ID_AMBISONICS);
return 0;
}

Expand Down
10 changes: 10 additions & 0 deletions core/libs/prx/libSceFont/include/FontInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ struct FontState {
FT_Face face = nullptr;
float scaleW = 16.0f;
float scaleH = 16.0f;
std::int32_t attribute = 0;
std::int32_t script = 0;
std::int32_t language = 0;
std::int32_t typographic = 0;
std::int32_t feature = 0;
bool hasAttribute = false;
bool hasScriptLanguage = false;
bool hasTypographic = false;

FontState() = default;
FontState(const FontState&) = delete;
Expand All @@ -49,6 +57,8 @@ struct GeneratedGlyph {
std::vector<std::uint16_t> outlineContours;
bool metricsInitialized = false;
bool outlineInitialized = false;
std::int32_t attribute = 0;
bool hasAttribute = false;
};

struct SystemFontFile {
Expand Down
12 changes: 12 additions & 0 deletions core/libs/prx/libSceFont/include/FontTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ struct FontTextCharacter {
std::uint8_t reserved_0x40[136];
};

struct FontTextCodes {
void* order;
std::uint32_t code;
std::uint32_t reserved;
FontTextCharacter* current;
FontTextCharacter* term;
void* systemReserved[4];
};

struct FontRenderSurface {
void* buffer;
std::int32_t widthByte;
Expand Down Expand Up @@ -427,6 +436,9 @@ static_assert(sizeof(FontSurfaceImage) == 0x10);
static_assert(sizeof(FontRenderOutput) == 0x40);
static_assert(sizeof(FontTextCharacter) == 0xC8);
static_assert(offsetof(FontTextCharacter, flags) == 0x38);
static_assert(sizeof(FontTextCodes) == 0x40);
static_assert(offsetof(FontTextCodes, current) == 0x10);
static_assert(offsetof(FontTextCodes, term) == 0x18);
static_assert(sizeof(FontRenderSurface) == 0x80);
static_assert(sizeof(FontStyleFrame) == 0x60);
static_assert(offsetof(FontStyleFrame, scalePixelW) == 0x14);
Expand Down
Loading
Loading