Partial commit: Modules (cell)

This commit is contained in:
Nekotekina 2016-03-21 22:43:03 +03:00
parent 7e30a0f464
commit 5637c22363
140 changed files with 7290 additions and 8243 deletions

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
extern std::mutex g_mutex_avcodec_open2; extern std::mutex g_mutex_avcodec_open2;
@ -16,7 +15,7 @@ extern "C"
#include "cellPamf.h" #include "cellPamf.h"
#include "cellAdec.h" #include "cellAdec.h"
extern Module<> cellAdec; LOG_CHANNEL(cellAdec);
AudioDecoder::AudioDecoder(s32 type, u32 addr, u32 size, vm::ptr<CellAdecCbMsg> func, u32 arg) AudioDecoder::AudioDecoder(s32 type, u32 addr, u32 size, vm::ptr<CellAdecCbMsg> func, u32 arg)
: type(type) : type(type)
@ -467,8 +466,9 @@ void adecOpen(u32 adec_id) // TODO: call from the constructor
}; };
adec.adecCb->run(); adec.adecCb->cpu_init();
adec.adecCb->exec(); adec.adecCb->state -= cpu_state::stop;
adec.adecCb->safe_notify();
} }
bool adecCheckType(s32 type) bool adecCheckType(s32 type)
@ -572,7 +572,7 @@ s32 cellAdecClose(u32 handle)
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
} }
idm::remove<PPUThread>(adec->adecCb->get_id()); idm::remove<PPUThread>(adec->adecCb->id);
idm::remove<AudioDecoder>(handle); idm::remove<AudioDecoder>(handle);
return CELL_OK; return CELL_OK;
} }
@ -863,7 +863,7 @@ s32 cellAdecGetPcmItem(u32 handle, vm::pptr<CellAdecPcmItem> pcmItem)
return CELL_OK; return CELL_OK;
} }
Module<> cellAdec("cellAdec", []() DECLARE(ppu_module_manager::cellAdec)("cellAdec", []()
{ {
REG_FUNC(cellAdec, cellAdecQueryAttr); REG_FUNC(cellAdec, cellAdecQueryAttr);
REG_FUNC(cellAdec, cellAdecOpen); REG_FUNC(cellAdec, cellAdecOpen);

View File

@ -1,10 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellAtrac.h" #include "cellAtrac.h"
LOG_CHANNEL(cellAtrac);
s32 cellAtracSetDataAndGetMemSize(vm::ptr<CellAtracHandle> pHandle, vm::ptr<u8> pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr<u32> puiWorkMemByte) s32 cellAtracSetDataAndGetMemSize(vm::ptr<CellAtracHandle> pHandle, vm::ptr<u8> pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, vm::ptr<u32> puiWorkMemByte)
{ {
cellAtrac.warning("cellAtracSetDataAndGetMemSize(pHandle=*0x%x, pucBufferAddr=*0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, puiWorkMemByte=*0x%x)", pHandle, pucBufferAddr, uiReadByte, uiBufferByte, puiWorkMemByte); cellAtrac.warning("cellAtracSetDataAndGetMemSize(pHandle=*0x%x, pucBufferAddr=*0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, puiWorkMemByte=*0x%x)", pHandle, pucBufferAddr, uiReadByte, uiBufferByte, puiWorkMemByte);
@ -194,7 +195,7 @@ s32 cellAtracGetInternalErrorInfo(vm::ptr<CellAtracHandle> pHandle, vm::ptr<s32>
return CELL_OK; return CELL_OK;
} }
Module<> cellAtrac("cellAtrac", []() DECLARE(ppu_module_manager::cellAtrac)("cellAtrac", []()
{ {
REG_FUNC(cellAtrac, cellAtracSetDataAndGetMemSize); REG_FUNC(cellAtrac, cellAtracSetDataAndGetMemSize);

View File

@ -57,5 +57,3 @@ struct CellAtracExtRes
vm::ptr<struct CellSpurs> pSpurs; vm::ptr<struct CellSpurs> pSpurs;
u8 priority[8]; u8 priority[8];
}; };
extern Module<> cellAtrac;

View File

@ -1,10 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellAtracMulti.h" #include "cellAtracMulti.h"
LOG_CHANNEL(cellAtracMulti);
s32 cellAtracMultiSetDataAndGetMemSize(vm::ptr<CellAtracMultiHandle> pHandle, vm::ptr<u8> pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, u32 uiOutputChNum, vm::ptr<s32> piTrackArray, vm::ptr<u32> puiWorkMemByte) s32 cellAtracMultiSetDataAndGetMemSize(vm::ptr<CellAtracMultiHandle> pHandle, vm::ptr<u8> pucBufferAddr, u32 uiReadByte, u32 uiBufferByte, u32 uiOutputChNum, vm::ptr<s32> piTrackArray, vm::ptr<u32> puiWorkMemByte)
{ {
cellAtracMulti.warning("cellAtracMultiSetDataAndGetMemSize(pHandle=*0x%x, pucBufferAddr=*0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, uiOutputChNum=%d, piTrackArray=*0x%x, puiWorkMemByte=*0x%x)", cellAtracMulti.warning("cellAtracMultiSetDataAndGetMemSize(pHandle=*0x%x, pucBufferAddr=*0x%x, uiReadByte=0x%x, uiBufferByte=0x%x, uiOutputChNum=%d, piTrackArray=*0x%x, puiWorkMemByte=*0x%x)",
@ -202,7 +203,7 @@ s32 cellAtracMultiGetInternalErrorInfo(vm::ptr<CellAtracMultiHandle> pHandle, vm
return CELL_OK; return CELL_OK;
} }
Module<> cellAtracMulti("cellAtrac", []() DECLARE(ppu_module_manager::cellAtracMulti)("cellAtracMulti", []()
{ {
REG_FUNC(cellAtracMulti, cellAtracMultiSetDataAndGetMemSize); REG_FUNC(cellAtracMulti, cellAtracMultiSetDataAndGetMemSize);

View File

@ -58,5 +58,3 @@ struct CellAtracMultiExtRes
vm::ptr<struct CellSpurs> pSpurs; vm::ptr<struct CellSpurs> pSpurs;
u8 priority[8]; u8 priority[8];
}; };
extern Module<> cellAtracMulti;

View File

@ -0,0 +1,956 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/lv2/sys_event.h"
#include "Emu/Audio/AudioDumper.h"
#include "Emu/Audio/AudioThread.h"
#include "cellAudio.h"
LOG_CHANNEL(cellAudio);
cfg::bool_entry g_cfg_audio_dump_to_file(cfg::root.audio, "Dump to file");
cfg::bool_entry g_cfg_audio_convert_to_u16(cfg::root.audio, "Convert to 16 bit");
void audio_config::on_task()
{
for (u32 i = 0; i < AUDIO_PORT_COUNT; i++)
{
ports[i].number = i;
ports[i].addr = m_buffer + AUDIO_PORT_OFFSET * i;
ports[i].index = m_indexes + i;
}
AudioDumper m_dump(g_cfg_audio_dump_to_file ? 2 : 0); // Init AudioDumper for 2 channels if enabled
float buf2ch[2 * BUFFER_SIZE]{}; // intermediate buffer for 2 channels
float buf8ch[8 * BUFFER_SIZE]{}; // intermediate buffer for 8 channels
static const size_t out_buffer_size = 8 * BUFFER_SIZE; // output buffer for 8 channels
std::unique_ptr<float[]> out_buffer[BUFFER_NUM];
for (u32 i = 0; i < BUFFER_NUM; i++)
{
out_buffer[i].reset(new float[out_buffer_size] {});
}
const auto audio = Emu.GetCallbacks().get_audio();
audio->Open(buf8ch, out_buffer_size * (g_cfg_audio_convert_to_u16 ? 2 : 4));
while (fxm::check<audio_config>() && !Emu.IsStopped())
{
if (Emu.IsPaused())
{
std::this_thread::sleep_for(1ms); // hack
continue;
}
const u64 stamp0 = get_system_time();
const u64 time_pos = stamp0 - start_time - Emu.GetPauseTime();
// TODO: send beforemix event (in ~2,6 ms before mixing)
// precise time of sleeping: 5,(3) ms (or 256/48000 sec)
const u64 expected_time = m_counter * AUDIO_SAMPLES * 1000000 / 48000;
if (expected_time >= time_pos)
{
std::this_thread::sleep_for(1ms); // hack
continue;
}
m_counter++;
const u32 out_pos = m_counter % BUFFER_NUM;
bool first_mix = true;
// mixing:
for (auto& port : ports)
{
if (port.state != audio_port_state::started) continue;
const u32 block_size = port.channel * AUDIO_SAMPLES;
const u32 position = port.tag % port.block; // old value
const u32 buf_addr = port.addr.addr() + position * block_size * sizeof(float);
auto buf = vm::_ptr<f32>(buf_addr);
static const float k = 1.0f; // may be 1.0f
const float& m = port.level;
auto step_volume = [](audio_port& port) // part of cellAudioSetPortLevel functionality
{
const auto param = port.level_set.load();
if (param.inc != 0.0f)
{
port.level += param.inc;
const bool dec = param.inc < 0.0f;
if ((!dec && param.value - port.level <= 0.0f) || (dec && param.value - port.level >= 0.0f))
{
port.level = param.value;
port.level_set.compare_and_swap(param, { param.value, 0.0f });
}
}
};
if (port.channel == 2)
{
if (first_mix)
{
for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2)
{
step_volume(port);
// reverse byte order
const float left = buf[i + 0] * m;
const float right = buf[i + 1] * m;
buf2ch[i + 0] = left;
buf2ch[i + 1] = right;
buf8ch[i * 4 + 0] = left;
buf8ch[i * 4 + 1] = right;
buf8ch[i * 4 + 2] = 0.0f;
buf8ch[i * 4 + 3] = 0.0f;
buf8ch[i * 4 + 4] = 0.0f;
buf8ch[i * 4 + 5] = 0.0f;
buf8ch[i * 4 + 6] = 0.0f;
buf8ch[i * 4 + 7] = 0.0f;
}
first_mix = false;
}
else
{
for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2)
{
step_volume(port);
const float left = buf[i + 0] * m;
const float right = buf[i + 1] * m;
buf2ch[i + 0] += left;
buf2ch[i + 1] += right;
buf8ch[i * 4 + 0] += left;
buf8ch[i * 4 + 1] += right;
}
}
}
else if (port.channel == 8)
{
if (first_mix)
{
for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2)
{
step_volume(port);
const float left = buf[i * 4 + 0] * m;
const float right = buf[i * 4 + 1] * m;
const float center = buf[i * 4 + 2] * m;
const float low_freq = buf[i * 4 + 3] * m;
const float rear_left = buf[i * 4 + 4] * m;
const float rear_right = buf[i * 4 + 5] * m;
const float side_left = buf[i * 4 + 6] * m;
const float side_right = buf[i * 4 + 7] * m;
const float mid = (center + low_freq) * 0.708f;
buf2ch[i + 0] = (left + rear_left + side_left + mid) * k;
buf2ch[i + 1] = (right + rear_right + side_right + mid) * k;
buf8ch[i * 4 + 0] = left;
buf8ch[i * 4 + 1] = right;
buf8ch[i * 4 + 2] = center;
buf8ch[i * 4 + 3] = low_freq;
buf8ch[i * 4 + 4] = rear_left;
buf8ch[i * 4 + 5] = rear_right;
buf8ch[i * 4 + 6] = side_left;
buf8ch[i * 4 + 7] = side_right;
}
first_mix = false;
}
else
{
for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i += 2)
{
step_volume(port);
const float left = buf[i * 4 + 0] * m;
const float right = buf[i * 4 + 1] * m;
const float center = buf[i * 4 + 2] * m;
const float low_freq = buf[i * 4 + 3] * m;
const float rear_left = buf[i * 4 + 4] * m;
const float rear_right = buf[i * 4 + 5] * m;
const float side_left = buf[i * 4 + 6] * m;
const float side_right = buf[i * 4 + 7] * m;
const float mid = (center + low_freq) * 0.708f;
buf2ch[i + 0] += (left + rear_left + side_left + mid) * k;
buf2ch[i + 1] += (right + rear_right + side_right + mid) * k;
buf8ch[i * 4 + 0] += left;
buf8ch[i * 4 + 1] += right;
buf8ch[i * 4 + 2] += center;
buf8ch[i * 4 + 3] += low_freq;
buf8ch[i * 4 + 4] += rear_left;
buf8ch[i * 4 + 5] += rear_right;
buf8ch[i * 4 + 6] += side_left;
buf8ch[i * 4 + 7] += side_right;
}
}
}
else
{
throw EXCEPTION("Unknown channel count (port=%u, channel=%d)", port.number, port.channel);
}
memset(buf, 0, block_size * sizeof(float));
}
if (!first_mix)
{
// copy output data (2 ch)
//for (u32 i = 0; i < (sizeof(buf2ch) / sizeof(float)); i++)
//{
// out_buffer[out_pos][i] = buf2ch[i];
//}
// copy output data (8 ch)
for (u32 i = 0; i < (sizeof(buf8ch) / sizeof(float)); i++)
{
out_buffer[out_pos][i] = buf8ch[i];
}
}
const u64 stamp1 = get_system_time();
if (first_mix)
{
memset(out_buffer[out_pos].get(), 0, out_buffer_size * sizeof(float));
}
if (g_cfg_audio_convert_to_u16)
{
// convert the data from float to u16 with clipping:
// 2x MULPS
// 2x MAXPS (optional)
// 2x MINPS (optional)
// 2x CVTPS2DQ (converts float to s32)
// PACKSSDW (converts s32 to s16 with signed saturation)
u16 buf_u16[out_buffer_size];
for (size_t i = 0; i < out_buffer_size; i += 8)
{
const auto scale = _mm_set1_ps(0x8000);
(__m128i&)(buf_u16[i]) = _mm_packs_epi32(
_mm_cvtps_epi32(_mm_mul_ps(_mm_load_ps(out_buffer[out_pos].get() + i), scale)),
_mm_cvtps_epi32(_mm_mul_ps(_mm_load_ps(out_buffer[out_pos].get() + i + 4), scale)));
}
audio->AddData(buf_u16, out_buffer_size * sizeof(u16));
}
else
{
audio->AddData(out_buffer[out_pos].get(), out_buffer_size * sizeof(float));
}
const u64 stamp2 = get_system_time();
{
// update indices:
for (u32 i = 0; i < AUDIO_PORT_COUNT; i++)
{
audio_port& port = ports[i];
if (port.state != audio_port_state::started) continue;
u32 position = port.tag % port.block; // old value
port.counter = m_counter;
port.tag++; // absolute index of block that will be read
m_indexes[i] = (position + 1) % port.block; // write new value
}
// send aftermix event (normal audio event)
LV2_LOCK;
std::lock_guard<std::mutex> lock(mutex);
for (u64 key : keys)
{
if (auto&& queue = lv2_event_queue_t::find(key))
{
if (queue->events() < queue->size)
queue->push(lv2_lock, 0, 0, 0, 0); // TODO: check arguments
}
}
}
const u64 stamp3 = get_system_time();
switch (m_dump.GetCh())
{
case 2: m_dump.WriteData(&buf2ch, sizeof(buf2ch)); break; // write file data (2 ch)
case 8: m_dump.WriteData(&buf8ch, sizeof(buf8ch)); break; // write file data (8 ch)
}
cellAudio.trace("Audio perf: start=%d (access=%d, AddData=%d, events=%d, dump=%d)",
time_pos, stamp1 - stamp0, stamp2 - stamp1, stamp3 - stamp2, get_system_time() - stamp3);
}
}
s32 cellAudioInit()
{
cellAudio.warning("cellAudioInit()");
// Start audio thread
const auto g_audio = fxm::make<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_ALREADY_INIT;
}
return CELL_OK;
}
s32 cellAudioQuit()
{
cellAudio.warning("cellAudioQuit()");
// Stop audio thread
const auto g_audio = fxm::withdraw<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
return CELL_OK;
}
s32 cellAudioPortOpen(vm::ptr<CellAudioPortParam> audioParam, vm::ptr<u32> portNum)
{
cellAudio.warning("cellAudioPortOpen(audioParam=*0x%x, portNum=*0x%x)", audioParam, portNum);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (!audioParam || !portNum)
{
return CELL_AUDIO_ERROR_PARAM;
}
const u64 channel = audioParam->nChannel;
const u64 block = audioParam->nBlock;
const u64 attr = audioParam->attr;
// check attributes
if (channel != CELL_AUDIO_PORT_2CH &&
channel != CELL_AUDIO_PORT_8CH &&
channel)
{
return CELL_AUDIO_ERROR_PARAM;
}
if (block != CELL_AUDIO_BLOCK_8 &&
block != CELL_AUDIO_BLOCK_16 &&
block != 2 &&
block != 4 &&
block != 32)
{
return CELL_AUDIO_ERROR_PARAM;
}
// list unsupported flags
if (attr & CELL_AUDIO_PORTATTR_BGM)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_BGM");
}
if (attr & CELL_AUDIO_PORTATTR_OUT_SECONDARY)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_OUT_SECONDARY");
}
if (attr & CELL_AUDIO_PORTATTR_OUT_PERSONAL_0)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_OUT_PERSONAL_0");
}
if (attr & CELL_AUDIO_PORTATTR_OUT_PERSONAL_1)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_OUT_PERSONAL_1");
}
if (attr & CELL_AUDIO_PORTATTR_OUT_PERSONAL_2)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_OUT_PERSONAL_2");
}
if (attr & CELL_AUDIO_PORTATTR_OUT_PERSONAL_3)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_OUT_PERSONAL_3");
}
if (attr & CELL_AUDIO_PORTATTR_OUT_NO_ROUTE)
{
cellAudio.todo("cellAudioPortOpen(): CELL_AUDIO_PORTATTR_OUT_NO_ROUTE");
}
if (attr & 0xFFFFFFFFF0EFEFEEULL)
{
cellAudio.todo("cellAudioPortOpen(): unknown attributes (0x%llx)", attr);
}
// Open audio port
const auto port = g_audio->open_port();
if (!port)
{
return CELL_AUDIO_ERROR_PORT_FULL;
}
port->channel = ::narrow<u32>(channel);
port->block = ::narrow<u32>(block);
port->attr = attr;
port->size = ::narrow<u32>(channel * block * AUDIO_SAMPLES * sizeof(f32));
port->tag = 0;
if (attr & CELL_AUDIO_PORTATTR_INITLEVEL)
{
port->level = audioParam->level;
}
else
{
port->level = 1.0f;
}
port->level_set.store({ port->level, 0.0f });
*portNum = port->number;
return CELL_OK;
}
s32 cellAudioGetPortConfig(u32 portNum, vm::ptr<CellAudioPortConfig> portConfig)
{
cellAudio.warning("cellAudioGetPortConfig(portNum=%d, portConfig=*0x%x)", portNum, portConfig);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (!portConfig || portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
portConfig->readIndexAddr = port.index;
switch (auto state = port.state.load())
{
case audio_port_state::closed: portConfig->status = CELL_AUDIO_STATUS_CLOSE; break;
case audio_port_state::opened: portConfig->status = CELL_AUDIO_STATUS_READY; break;
case audio_port_state::started: portConfig->status = CELL_AUDIO_STATUS_RUN; break;
default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state);
}
portConfig->nChannel = port.channel;
portConfig->nBlock = port.block;
portConfig->portSize = port.size;
portConfig->portAddr = port.addr.addr();
return CELL_OK;
}
s32 cellAudioPortStart(u32 portNum)
{
cellAudio.warning("cellAudioPortStart(portNum=%d)", portNum);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
switch (auto state = g_audio->ports[portNum].state.compare_and_swap(audio_port_state::opened, audio_port_state::started))
{
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
case audio_port_state::started: return CELL_AUDIO_ERROR_PORT_ALREADY_RUN;
case audio_port_state::opened: return CELL_OK;
default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state);
}
}
s32 cellAudioPortClose(u32 portNum)
{
cellAudio.warning("cellAudioPortClose(portNum=%d)", portNum);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
switch (auto state = g_audio->ports[portNum].state.exchange(audio_port_state::closed))
{
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
case audio_port_state::started: return CELL_OK;
case audio_port_state::opened: return CELL_OK;
default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state);
}
}
s32 cellAudioPortStop(u32 portNum)
{
cellAudio.warning("cellAudioPortStop(portNum=%d)", portNum);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
switch (auto state = g_audio->ports[portNum].state.compare_and_swap(audio_port_state::started, audio_port_state::opened))
{
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_RUN;
case audio_port_state::started: return CELL_OK;
case audio_port_state::opened: return CELL_AUDIO_ERROR_PORT_NOT_RUN;
default: throw fmt::exception("Invalid port state (%d: %d)", portNum, state);
}
}
s32 cellAudioGetPortTimestamp(u32 portNum, u64 tag, vm::ptr<u64> stamp)
{
cellAudio.trace("cellAudioGetPortTimestamp(portNum=%d, tag=0x%llx, stamp=*0x%x)", portNum, tag, stamp);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
if (port.state == audio_port_state::closed)
{
return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
}
// TODO: check tag (CELL_AUDIO_ERROR_TAG_NOT_FOUND error)
*stamp = g_audio->start_time + Emu.GetPauseTime() + (port.counter + (tag - port.tag)) * 256000000 / 48000;
return CELL_OK;
}
s32 cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, vm::ptr<u64> tag)
{
cellAudio.trace("cellAudioGetPortBlockTag(portNum=%d, blockNo=0x%llx, tag=*0x%x)", portNum, blockNo, tag);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
if (port.state == audio_port_state::closed)
{
return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
}
if (blockNo >= port.block)
{
return CELL_AUDIO_ERROR_PARAM;
}
u64 tag_base = port.tag;
if (tag_base % port.block > blockNo)
{
tag_base &= ~(port.block - 1);
tag_base += port.block;
}
else
{
tag_base &= ~(port.block - 1);
}
*tag = tag_base + blockNo;
return CELL_OK;
}
s32 cellAudioSetPortLevel(u32 portNum, float level)
{
cellAudio.trace("cellAudioSetPortLevel(portNum=%d, level=%f)", portNum, level);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT)
{
return CELL_AUDIO_ERROR_PARAM;
}
audio_port& port = g_audio->ports[portNum];
if (port.state == audio_port_state::closed)
{
return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
}
if (level >= 0.0f)
{
port.level_set.exchange({ level, (port.level - level) / 624.0f });
}
else
{
cellAudio.todo("cellAudioSetPortLevel(%d): negative level value (%f)", portNum, level);
}
return CELL_OK;
}
s32 cellAudioCreateNotifyEventQueue(vm::ptr<u32> id, vm::ptr<u64> key)
{
cellAudio.warning("cellAudioCreateNotifyEventQueue(id=*0x%x, key=*0x%x)", id, key);
for (u64 k = 0; k < 100; k++)
{
const u64 key_value = 0x80004d494f323221ull + k;
// Create an event queue "bruteforcing" an available key
if (auto&& queue = lv2_event_queue_t::make(SYS_SYNC_FIFO, SYS_PPU_QUEUE, 0, key_value, 32))
{
*id = queue->id;
*key = key_value;
return CELL_OK;
}
}
return CELL_AUDIO_ERROR_EVENT_QUEUE;
}
s32 cellAudioCreateNotifyEventQueueEx(vm::ptr<u32> id, vm::ptr<u64> key, u32 iFlags)
{
cellAudio.todo("cellAudioCreateNotifyEventQueueEx(id=*0x%x, key=*0x%x, iFlags=0x%x)", id, key, iFlags);
if (iFlags & ~CELL_AUDIO_CREATEEVENTFLAG_SPU)
{
return CELL_AUDIO_ERROR_PARAM;
}
// TODO
return CELL_AUDIO_ERROR_EVENT_QUEUE;
}
s32 cellAudioSetNotifyEventQueue(u64 key)
{
cellAudio.warning("cellAudioSetNotifyEventQueue(key=0x%llx)", key);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
std::lock_guard<std::mutex> lock(g_audio->mutex);
for (auto k : g_audio->keys) // check for duplicates
{
if (k == key)
{
return CELL_AUDIO_ERROR_TRANS_EVENT;
}
}
g_audio->keys.emplace_back(key);
return CELL_OK;
}
s32 cellAudioSetNotifyEventQueueEx(u64 key, u32 iFlags)
{
cellAudio.todo("cellAudioSetNotifyEventQueueEx(key=0x%llx, iFlags=0x%x)", key, iFlags);
// TODO
return CELL_OK;
}
s32 cellAudioRemoveNotifyEventQueue(u64 key)
{
cellAudio.warning("cellAudioRemoveNotifyEventQueue(key=0x%llx)", key);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
std::lock_guard<std::mutex> lock(g_audio->mutex);
for (auto i = g_audio->keys.begin(); i != g_audio->keys.end(); i++)
{
if (*i == key)
{
g_audio->keys.erase(i);
return CELL_OK;
}
}
return CELL_AUDIO_ERROR_TRANS_EVENT;
}
s32 cellAudioRemoveNotifyEventQueueEx(u64 key, u32 iFlags)
{
cellAudio.todo("cellAudioRemoveNotifyEventQueueEx(key=0x%llx, iFlags=0x%x)", key, iFlags);
// TODO
return CELL_OK;
}
s32 cellAudioAddData(u32 portNum, vm::ptr<float> src, u32 samples, float volume)
{
cellAudio.trace("cellAudioAddData(portNum=%d, src=*0x%x, samples=%d, volume=%f)", portNum, src, samples, volume);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT || !src || !src.aligned())
{
return CELL_AUDIO_ERROR_PARAM;
}
if (samples != 256)
{
// despite the docs, seems that only fixed value is supported
cellAudio.error("cellAudioAddData(): invalid samples value (%d)", samples);
return CELL_AUDIO_ERROR_PARAM;
}
const audio_port& port = g_audio->ports[portNum];
const auto dst = vm::ptr<float>::make(port.addr.addr() + u32(port.tag % port.block) * port.channel * 256 * SIZE_32(float));
for (u32 i = 0; i < samples * port.channel; i++)
{
dst[i] += src[i] * volume; // mix all channels
}
return CELL_OK;
}
s32 cellAudioAdd2chData(u32 portNum, vm::ptr<float> src, u32 samples, float volume)
{
cellAudio.trace("cellAudioAdd2chData(portNum=%d, src=*0x%x, samples=%d, volume=%f)", portNum, src, samples, volume);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT || !src || !src.aligned())
{
return CELL_AUDIO_ERROR_PARAM;
}
if (samples != 256)
{
// despite the docs, seems that only fixed value is supported
cellAudio.error("cellAudioAdd2chData(): invalid samples value (%d)", samples);
return CELL_AUDIO_ERROR_PARAM;
}
const audio_port& port = g_audio->ports[portNum];
const auto dst = vm::ptr<float>::make(port.addr.addr() + s32(port.tag % port.block) * port.channel * 256 * SIZE_32(float));
if (port.channel == 2)
{
cellAudio.error("cellAudioAdd2chData(portNum=%d): port.channel = 2", portNum);
}
else if (port.channel == 6)
{
for (u32 i = 0; i < samples; i++)
{
dst[i * 6 + 0] += src[i * 2 + 0] * volume; // mix L ch
dst[i * 6 + 1] += src[i * 2 + 1] * volume; // mix R ch
//dst[i * 6 + 2] += 0.0f; // center
//dst[i * 6 + 3] += 0.0f; // LFE
//dst[i * 6 + 4] += 0.0f; // rear L
//dst[i * 6 + 5] += 0.0f; // rear R
}
}
else if (port.channel == 8)
{
for (u32 i = 0; i < samples; i++)
{
dst[i * 8 + 0] += src[i * 2 + 0] * volume; // mix L ch
dst[i * 8 + 1] += src[i * 2 + 1] * volume; // mix R ch
//dst[i * 8 + 2] += 0.0f; // center
//dst[i * 8 + 3] += 0.0f; // LFE
//dst[i * 8 + 4] += 0.0f; // rear L
//dst[i * 8 + 5] += 0.0f; // rear R
//dst[i * 8 + 6] += 0.0f; // side L
//dst[i * 8 + 7] += 0.0f; // side R
}
}
else
{
cellAudio.error("cellAudioAdd2chData(portNum=%d): invalid port.channel value (%d)", portNum, port.channel);
}
return CELL_OK;
}
s32 cellAudioAdd6chData(u32 portNum, vm::ptr<float> src, float volume)
{
cellAudio.trace("cellAudioAdd6chData(portNum=%d, src=*0x%x, volume=%f)", portNum, src, volume);
const auto g_audio = fxm::get<audio_config>();
if (!g_audio)
{
return CELL_AUDIO_ERROR_NOT_INIT;
}
if (portNum >= AUDIO_PORT_COUNT || !src || !src.aligned())
{
return CELL_AUDIO_ERROR_PARAM;
}
const audio_port& port = g_audio->ports[portNum];
const auto dst = vm::ptr<float>::make(port.addr.addr() + s32(port.tag % port.block) * port.channel * 256 * SIZE_32(float));
if (port.channel == 2 || port.channel == 6)
{
cellAudio.error("cellAudioAdd2chData(portNum=%d): port.channel = %d", portNum, port.channel);
}
else if (port.channel == 8)
{
for (u32 i = 0; i < 256; i++)
{
dst[i * 8 + 0] += src[i * 6 + 0] * volume; // mix L ch
dst[i * 8 + 1] += src[i * 6 + 1] * volume; // mix R ch
dst[i * 8 + 2] += src[i * 6 + 2] * volume; // mix center
dst[i * 8 + 3] += src[i * 6 + 3] * volume; // mix LFE
dst[i * 8 + 4] += src[i * 6 + 4] * volume; // mix rear L
dst[i * 8 + 5] += src[i * 6 + 5] * volume; // mix rear R
//dst[i * 8 + 6] += 0.0f; // side L
//dst[i * 8 + 7] += 0.0f; // side R
}
}
else
{
cellAudio.error("cellAudioAdd6chData(portNum=%d): invalid port.channel value (%d)", portNum, port.channel);
}
return CELL_OK;
}
s32 cellAudioMiscSetAccessoryVolume(u32 devNum, float volume)
{
cellAudio.todo("cellAudioMiscSetAccessoryVolume(devNum=%d, volume=%f)", devNum, volume);
return CELL_OK;
}
s32 cellAudioSendAck(u64 data3)
{
cellAudio.todo("cellAudioSendAck(data3=0x%llx)", data3);
return CELL_OK;
}
s32 cellAudioSetPersonalDevice(s32 iPersonalStream, s32 iDevice)
{
cellAudio.todo("cellAudioSetPersonalDevice(iPersonalStream=%d, iDevice=%d)", iPersonalStream, iDevice);
return CELL_OK;
}
s32 cellAudioUnsetPersonalDevice(s32 iPersonalStream)
{
cellAudio.todo("cellAudioUnsetPersonalDevice(iPersonalStream=%d)", iPersonalStream);
return CELL_OK;
}
DECLARE(ppu_module_manager::cellAudio)("cellAudio", []()
{
REG_FUNC(cellAudio, cellAudioInit);
REG_FUNC(cellAudio, cellAudioPortClose);
REG_FUNC(cellAudio, cellAudioPortStop);
REG_FUNC(cellAudio, cellAudioGetPortConfig);
REG_FUNC(cellAudio, cellAudioPortStart);
REG_FUNC(cellAudio, cellAudioQuit);
REG_FUNC(cellAudio, cellAudioPortOpen);
REG_FUNC(cellAudio, cellAudioSetPortLevel);
REG_FUNC(cellAudio, cellAudioCreateNotifyEventQueue);
REG_FUNC(cellAudio, cellAudioCreateNotifyEventQueueEx);
REG_FUNC(cellAudio, cellAudioMiscSetAccessoryVolume);
REG_FUNC(cellAudio, cellAudioSetNotifyEventQueue);
REG_FUNC(cellAudio, cellAudioSetNotifyEventQueueEx);
REG_FUNC(cellAudio, cellAudioGetPortTimestamp);
REG_FUNC(cellAudio, cellAudioAdd2chData);
REG_FUNC(cellAudio, cellAudioAdd6chData);
REG_FUNC(cellAudio, cellAudioAddData);
REG_FUNC(cellAudio, cellAudioGetPortBlockTag);
REG_FUNC(cellAudio, cellAudioRemoveNotifyEventQueue);
REG_FUNC(cellAudio, cellAudioRemoveNotifyEventQueueEx);
REG_FUNC(cellAudio, cellAudioSendAck);
REG_FUNC(cellAudio, cellAudioSetPersonalDevice);
REG_FUNC(cellAudio, cellAudioUnsetPersonalDevice);
});

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "Utilities/Thread.h"
namespace vm { using namespace ps3; } namespace vm { using namespace ps3; }
// Error codes // Error codes
@ -66,7 +68,7 @@ struct CellAudioPortParam
struct CellAudioPortConfig struct CellAudioPortConfig
{ {
be_t<u32> readIndexAddr; vm::bptr<u64> readIndexAddr;
be_t<u32> status; be_t<u32> status;
be_t<u64> nChannel; be_t<u64> nChannel;
be_t<u64> nBlock; be_t<u64> nBlock;
@ -83,36 +85,31 @@ enum : u32
AUDIO_SAMPLES = CELL_AUDIO_BLOCK_SAMPLES, AUDIO_SAMPLES = CELL_AUDIO_BLOCK_SAMPLES,
}; };
enum AudioState : u32 extern u64 get_system_time();
enum class audio_port_state : u32
{ {
AUDIO_STATE_NOT_INITIALIZED, closed,
AUDIO_STATE_INITIALIZED, opened,
AUDIO_STATE_FINALIZED, started,
}; };
enum AudioPortState : u32 struct audio_port
{ {
AUDIO_PORT_STATE_CLOSED, atomic_t<audio_port_state> state{ audio_port_state::closed };
AUDIO_PORT_STATE_OPENED,
AUDIO_PORT_STATE_STARTED,
};
struct AudioPortConfig u32 number;
{ vm::ptr<char> addr{};
atomic_t<AudioPortState> state; vm::ptr<u64> index{};
std::mutex mutex;
u32 channel; u32 channel;
u32 block; u32 block;
u64 attr; u64 attr;
u64 tag; u64 tag;
u64 counter; // copy of global counter u64 counter; // copy of global counter
u32 addr;
u32 read_index_addr;
u32 size; u32 size;
struct level_set_t struct alignas(8) level_set_t
{ {
float value; float value;
float inc; float inc;
@ -122,31 +119,36 @@ struct AudioPortConfig
atomic_t<level_set_t> level_set; atomic_t<level_set_t> level_set;
}; };
struct AudioConfig final // custom structure class audio_config final : public named_thread
{ {
atomic_t<AudioState> state; void on_task() override;
std::mutex mutex; std::string get_name() const override { return "Audio Thread"; }
vm::var<char[], vm::page_allocator<vm::main>> m_buffer{ AUDIO_PORT_OFFSET * AUDIO_PORT_COUNT };
vm::var<u64[], vm::page_allocator<vm::main>> m_indexes{ AUDIO_PORT_COUNT };
u64 m_counter{};
public:
const u64 start_time = get_system_time();
std::array<audio_port, AUDIO_PORT_COUNT> ports;
AudioPortConfig ports[AUDIO_PORT_COUNT];
u32 buffer; // 1 MB memory for audio ports
u32 indexes; // current block indexes and other info
u64 counter;
u64 start_time;
std::vector<u64> keys; std::vector<u64> keys;
u32 open_port() ~audio_config() noexcept = default;
audio_port* open_port()
{ {
for (u32 i = 0; i < AUDIO_PORT_COUNT; i++) for (u32 i = 0; i < AUDIO_PORT_COUNT; i++)
{ {
if (ports[i].state.compare_and_swap_test(AUDIO_PORT_STATE_CLOSED, AUDIO_PORT_STATE_OPENED)) if (ports[i].state.compare_and_swap_test(audio_port_state::closed, audio_port_state::opened))
{ {
return i; return &ports[i];
} }
} }
return ~0; return nullptr;
} }
}; };
extern AudioConfig g_audio;

View File

@ -1,10 +1,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
#include "cellAudioOut.h" #include "cellAudioOut.h"
extern Module<> cellSysutil; extern _log::channel cellSysutil;
s32 cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option) s32 cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
{ {

View File

@ -1,15 +1,14 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/state.h"
#include "cellAudioIn.h" #include "cellAudioIn.h"
#include "cellAudioOut.h" #include "cellAudioOut.h"
#include "cellVideoOut.h" #include "cellVideoOut.h"
extern Module<> cellAvconfExt; LOG_CHANNEL(cellAvconfExt);
f32 g_gamma; vm::gvar<f32> g_gamma; // TODO
s32 cellAudioOutUnregisterDevice() s32 cellAudioOutUnregisterDevice()
{ {
@ -50,7 +49,7 @@ s32 cellVideoOutGetGamma(u32 videoOut, vm::ptr<f32> gamma)
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
} }
*gamma = g_gamma; *gamma = *g_gamma;
return CELL_OK; return CELL_OK;
} }
@ -79,7 +78,7 @@ s32 cellVideoOutSetGamma(u32 videoOut, f32 gamma)
return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER; return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER;
} }
g_gamma = gamma; *g_gamma = gamma;
return CELL_OK; return CELL_OK;
} }
@ -127,34 +126,32 @@ s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr<float> screenSize)
// float diagonal = roundf(sqrtf((powf(wxGetDisplaySizeMM().GetWidth(), 2) + powf(wxGetDisplaySizeMM().GetHeight(), 2))) * 0.0393f); // float diagonal = roundf(sqrtf((powf(wxGetDisplaySizeMM().GetWidth(), 2) + powf(wxGetDisplaySizeMM().GetHeight(), 2))) * 0.0393f);
#endif #endif
if (rpcs3::config.rsx._3dtv.value())
{
*screenSize = 24.0f;
return CELL_OK;
}
return CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET; return CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET;
} }
Module<> cellAvconfExt("cellAvconfExt", []() DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []()
{ {
g_gamma = 1.0f; REG_VNID(cellSysutilAvconfExt, 0x00000000, g_gamma, []
{
REG_FUNC(cellAvconfExt, cellAudioOutUnregisterDevice); // Test
REG_FUNC(cellAvconfExt, cellAudioOutGetDeviceInfo2); *g_gamma = 1.0f;
REG_FUNC(cellAvconfExt, cellVideoOutSetXVColor); });
REG_FUNC(cellAvconfExt, cellVideoOutSetupDisplay);
REG_FUNC(cellAvconfExt, cellAudioInGetDeviceInfo); REG_FUNC(cellSysutilAvconfExt, cellAudioOutUnregisterDevice);
REG_FUNC(cellAvconfExt, cellVideoOutConvertCursorColor); REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetDeviceInfo2);
REG_FUNC(cellAvconfExt, cellVideoOutGetGamma); REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetXVColor);
REG_FUNC(cellAvconfExt, cellAudioInGetAvailableDeviceInfo); REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetupDisplay);
REG_FUNC(cellAvconfExt, cellAudioOutGetAvailableDeviceInfo); REG_FUNC(cellSysutilAvconfExt, cellAudioInGetDeviceInfo);
REG_FUNC(cellAvconfExt, cellVideoOutSetGamma); REG_FUNC(cellSysutilAvconfExt, cellVideoOutConvertCursorColor);
REG_FUNC(cellAvconfExt, cellAudioOutRegisterDevice); REG_FUNC(cellSysutilAvconfExt, cellVideoOutGetGamma);
REG_FUNC(cellAvconfExt, cellAudioOutSetDeviceMode); REG_FUNC(cellSysutilAvconfExt, cellAudioInGetAvailableDeviceInfo);
REG_FUNC(cellAvconfExt, cellAudioInSetDeviceMode); REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetAvailableDeviceInfo);
REG_FUNC(cellAvconfExt, cellAudioInRegisterDevice); REG_FUNC(cellSysutilAvconfExt, cellVideoOutSetGamma);
REG_FUNC(cellAvconfExt, cellAudioInUnregisterDevice); REG_FUNC(cellSysutilAvconfExt, cellAudioOutRegisterDevice);
REG_FUNC(cellAvconfExt, cellVideoOutGetScreenSize); REG_FUNC(cellSysutilAvconfExt, cellAudioOutSetDeviceMode);
REG_FUNC(cellSysutilAvconfExt, cellAudioInSetDeviceMode);
REG_FUNC(cellSysutilAvconfExt, cellAudioInRegisterDevice);
REG_FUNC(cellSysutilAvconfExt, cellAudioInUnregisterDevice);
REG_FUNC(cellSysutilAvconfExt, cellVideoOutGetScreenSize);
}); });

View File

@ -1,9 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
extern Module<> cellBGDL; LOG_CHANNEL(cellBGDL);
// Return Codes // Return Codes
enum enum
@ -40,10 +39,10 @@ s32 cellBGDLGetMode()
return CELL_OK; return CELL_OK;
} }
Module<> cellBGDL("cellBGDL", []() DECLARE(ppu_module_manager::cellBGDL)("cellBGDLUtility", []()
{ {
REG_FUNC(cellBGDL, cellBGDLGetInfo); REG_FUNC(cellBGDLUtility, cellBGDLGetInfo);
REG_FUNC(cellBGDL, cellBGDLGetInfo2); REG_FUNC(cellBGDLUtility, cellBGDLGetInfo2);
REG_FUNC(cellBGDL, cellBGDLSetMode); REG_FUNC(cellBGDLUtility, cellBGDLSetMode);
REG_FUNC(cellBGDL, cellBGDLGetMode); REG_FUNC(cellBGDLUtility, cellBGDLGetMode);
}); });

View File

@ -1,13 +1,25 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/state.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
#include "cellCamera.h" #include "cellCamera.h"
extern Module<> cellCamera; LOG_CHANNEL(cellCamera);
cfg::map_entry<bool> g_cfg_camera(cfg::root.io, "Camera",
{
{ "Null", false },
{ "Fake", true },
});
cfg::map_entry<CellCameraType> g_cfg_camera_type(cfg::root.io, "Camera type",
{
{ "Unknown", CELL_CAMERA_TYPE_UNKNOWN },
{ "EyeToy", CELL_CAMERA_EYETOY },
{ "PS Eye", CELL_CAMERA_EYETOY2 },
{ "UVC 1.1", CELL_CAMERA_USBVIDEOCLASS },
});
static const char* get_camera_attr_name(s32 value) static const char* get_camera_attr_name(s32 value)
{ {
@ -82,7 +94,7 @@ s32 cellCameraInit()
{ {
cellCamera.warning("cellCameraInit()"); cellCamera.warning("cellCameraInit()");
if (rpcs3::config.io.camera.value() == io_camera_state::null) if (!g_cfg_camera.get())
{ {
return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND;
} }
@ -94,9 +106,9 @@ s32 cellCameraInit()
return CELL_CAMERA_ERROR_ALREADY_INIT; return CELL_CAMERA_ERROR_ALREADY_INIT;
} }
switch (rpcs3::config.io.camera_type.value()) switch (g_cfg_camera_type.get())
{ {
case io_camera_type::eye_toy: case CELL_CAMERA_EYETOY:
{ {
camera->attr[CELL_CAMERA_SATURATION] = { 164 }; camera->attr[CELL_CAMERA_SATURATION] = { 164 };
camera->attr[CELL_CAMERA_BRIGHTNESS] = { 96 }; camera->attr[CELL_CAMERA_BRIGHTNESS] = { 96 };
@ -115,7 +127,7 @@ s32 cellCameraInit()
} }
break; break;
case io_camera_type::play_station_eye: case CELL_CAMERA_EYETOY2:
{ {
camera->attr[CELL_CAMERA_SATURATION] = { 64 }; camera->attr[CELL_CAMERA_SATURATION] = { 64 };
camera->attr[CELL_CAMERA_BRIGHTNESS] = { 8 }; camera->attr[CELL_CAMERA_BRIGHTNESS] = { 8 };
@ -191,14 +203,7 @@ s32 cellCameraGetType(s32 dev_num, vm::ptr<s32> type)
return CELL_CAMERA_ERROR_NOT_INIT; return CELL_CAMERA_ERROR_NOT_INIT;
} }
switch (rpcs3::config.io.camera_type.value()) *type = g_cfg_camera_type.get();
{
case io_camera_type::eye_toy: *type = CELL_CAMERA_EYETOY; break;
case io_camera_type::play_station_eye: *type = CELL_CAMERA_EYETOY2; break;
case io_camera_type::usb_video_class_1_1: *type = CELL_CAMERA_USBVIDEOCLASS; break;
default: *type = CELL_CAMERA_TYPE_UNKNOWN; break;
}
return CELL_OK; return CELL_OK;
} }
@ -212,12 +217,12 @@ s32 cellCameraIsAttached(s32 dev_num)
{ {
cellCamera.warning("cellCameraIsAttached(dev_num=%d)", dev_num); cellCamera.warning("cellCameraIsAttached(dev_num=%d)", dev_num);
if (rpcs3::config.io.camera.value() == io_camera_state::connected) if (g_cfg_camera.get())
{ {
return 1; return 1;
} }
return CELL_OK; // CELL_OK means that no camera is attached return 0; // It's not CELL_OK lol
} }
s32 cellCameraIsOpen(s32 dev_num) s32 cellCameraIsOpen(s32 dev_num)
@ -381,7 +386,7 @@ s32 cellCameraRemoveNotifyEventQueue2(u64 key)
return CELL_OK; return CELL_OK;
} }
Module<> cellCamera("cellCamera", []() DECLARE(ppu_module_manager::cellCamera)("cellCamera", []()
{ {
REG_FUNC(cellCamera, cellCameraInit); REG_FUNC(cellCamera, cellCameraInit);
REG_FUNC(cellCamera, cellCameraEnd); REG_FUNC(cellCamera, cellCameraEnd);

View File

@ -1,9 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
extern Module<> cellCelp8Enc; LOG_CHANNEL(cellCelp8Enc);
// Return Codes // Return Codes
enum enum
@ -70,7 +69,7 @@ s32 cellCelp8EncGetAu()
return CELL_OK; return CELL_OK;
} }
Module<> cellCelp8Enc("cellCelp8Enc", []() DECLARE(ppu_module_manager::cellCelp8Enc)("cellCelp8Enc", []()
{ {
REG_FUNC(cellCelp8Enc, cellCelp8EncQueryAttr); REG_FUNC(cellCelp8Enc, cellCelp8EncQueryAttr);
REG_FUNC(cellCelp8Enc, cellCelp8EncOpen); REG_FUNC(cellCelp8Enc, cellCelp8EncOpen);

View File

@ -1,9 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
extern Module<> cellCelpEnc; LOG_CHANNEL(cellCelpEnc);
// Return Codes // Return Codes
enum enum
@ -70,7 +69,7 @@ s32 cellCelpEncGetAu()
return CELL_OK; return CELL_OK;
} }
Module<> cellCelpEnc("cellCelpEnc", []() DECLARE(ppu_module_manager::cellCelpEnc)("cellCelpEnc", []()
{ {
REG_FUNC(cellCelpEnc, cellCelpEncQueryAttr); REG_FUNC(cellCelpEnc, cellCelpEncQueryAttr);
REG_FUNC(cellCelpEnc, cellCelpEncOpen); REG_FUNC(cellCelpEnc, cellCelpEncOpen);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellDaisy; LOG_CHANNEL(cellDaisy);
s32 _ZN4cell5Daisy17LFQueue2PushCloseEPNS0_8LFQueue2EPFiPvjE() s32 _ZN4cell5Daisy17LFQueue2PushCloseEPNS0_8LFQueue2EPFiPvjE()
{ {
@ -265,7 +264,7 @@ s32 _QN4cell5Daisy22ScatterGatherInterlock7releaseEv()
} }
Module<> cellDaisy("cellDaisy", []() DECLARE(ppu_module_manager::cellDaisy)("cellDaisy", []()
{ {
REG_FUNC(cellDaisy, _ZN4cell5Daisy17LFQueue2PushCloseEPNS0_8LFQueue2EPFiPvjE); REG_FUNC(cellDaisy, _ZN4cell5Daisy17LFQueue2PushCloseEPNS0_8LFQueue2EPFiPvjE);
REG_FUNC(cellDaisy, _ZN4cell5Daisy21LFQueue2GetPopPointerEPNS0_8LFQueue2EPij); REG_FUNC(cellDaisy, _ZN4cell5Daisy21LFQueue2GetPopPointerEPNS0_8LFQueue2EPij);

View File

@ -1,13 +1,12 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellPamf.h" #include "cellPamf.h"
#include "cellDmux.h" #include "cellDmux.h"
extern Module<> cellDmux; LOG_CHANNEL(cellDmux);
PesHeader::PesHeader(DemuxerStream& stream) PesHeader::PesHeader(DemuxerStream& stream)
: pts(CODEC_TS_INVALID) : pts(CODEC_TS_INVALID)
@ -80,7 +79,6 @@ PesHeader::PesHeader(DemuxerStream& stream)
ElementaryStream::ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec) ElementaryStream::ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec)
: dmux(dmux) : dmux(dmux)
, id(idm::get_last_id())
, memAddr(align(addr, 128)) , memAddr(align(addr, 128))
, memSize(size - (addr - memAddr)) , memSize(size - (addr - memAddr))
, fidMajor(fidMajor) , fidMajor(fidMajor)
@ -112,8 +110,7 @@ bool ElementaryStream::is_full(u32 space)
u32 first = 0; u32 first = 0;
if (!entries.peek(first, 0, &dmux->is_closed) || !first) if (!entries.peek(first, 0, &dmux->is_closed) || !first)
{ {
assert(!"es::is_full() error: entries.Peek() failed"); throw std::runtime_error("entries.peek() failed" HERE);
return false;
} }
else if (first >= put) else if (first >= put)
{ {
@ -145,7 +142,7 @@ void ElementaryStream::push_au(u32 size, u64 dts, u64 pts, u64 userdata, bool ra
u32 addr; u32 addr;
{ {
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
assert(!is_full(size)); ASSERT(!is_full(size));
if (put + size + 128 > memAddr + memSize) if (put + size + 128 > memAddr + memSize)
{ {
@ -185,10 +182,8 @@ void ElementaryStream::push_au(u32 size, u64 dts, u64 pts, u64 userdata, bool ra
put_count++; put_count++;
} }
if (!entries.push(addr, &dmux->is_closed))
{ ASSERT(entries.push(addr, &dmux->is_closed));
assert(!"es::push_au() error: entries.Push() failed");
}
} }
void ElementaryStream::push(DemuxerStream& stream, u32 size) void ElementaryStream::push(DemuxerStream& stream, u32 size)
@ -762,8 +757,9 @@ void dmuxOpen(u32 dmux_id) // TODO: call from the constructor
dmux.is_finished = true; dmux.is_finished = true;
}; };
dmux.dmuxCb->run(); dmux.dmuxCb->cpu_init();
dmux.dmuxCb->exec(); dmux.dmuxCb->state -= cpu_state::stop;
dmux.dmuxCb->safe_notify();
} }
s32 cellDmuxQueryAttr(vm::cptr<CellDmuxType> type, vm::ptr<CellDmuxAttr> attr) s32 cellDmuxQueryAttr(vm::cptr<CellDmuxType> type, vm::ptr<CellDmuxAttr> attr)
@ -872,7 +868,7 @@ s32 cellDmuxClose(u32 handle)
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
} }
idm::remove<PPUThread>(dmux->dmuxCb->get_id()); idm::remove<PPUThread>(dmux->dmuxCb->id);
idm::remove<Demuxer>(handle); idm::remove<Demuxer>(handle);
return CELL_OK; return CELL_OK;
} }
@ -1178,7 +1174,7 @@ s32 cellDmuxFlushEs(u32 esHandle)
return CELL_OK; return CELL_OK;
} }
Module<> cellDmux("cellDmux", []() DECLARE(ppu_module_manager::cellDmux)("cellDmux", []()
{ {
REG_FUNC(cellDmux, cellDmuxQueryAttr); REG_FUNC(cellDmux, cellDmuxQueryAttr);
REG_FUNC(cellDmux, cellDmuxQueryAttr2); REG_FUNC(cellDmux, cellDmuxQueryAttr2);

View File

@ -405,8 +405,8 @@ public:
u32 id; u32 id;
volatile bool is_finished; volatile bool is_finished;
volatile bool is_closed; volatile bool is_closed;
std::atomic<bool> is_running; atomic_t<bool> is_running;
std::atomic<bool> is_working; atomic_t<bool> is_working;
std::shared_ptr<PPUThread> dmuxCb; std::shared_ptr<PPUThread> dmuxCb;
@ -440,7 +440,7 @@ public:
ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec); ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec);
Demuxer* dmux; Demuxer* dmux;
const u32 id; const u32 id{};
const u32 memAddr; const u32 memAddr;
const u32 memSize; const u32 memSize;
const u32 fidMajor; const u32 fidMajor;

View File

@ -1,11 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellFiber.h" #include "cellFiber.h"
extern Module<> cellFiber; LOG_CHANNEL(cellFiber);
s32 _cellFiberPpuInitialize() s32 _cellFiberPpuInitialize()
{ {
@ -291,59 +290,59 @@ s32 cellFiberPpuUtilWorkerControlInitializeWithAttribute()
return CELL_OK; return CELL_OK;
} }
Module<> cellFiber("cellFiber", []() DECLARE(ppu_module_manager::cellFiber)("cellFiber", []()
{ {
REG_FUNC(cellFiber, _cellFiberPpuInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, _cellFiberPpuInitialize);
REG_FUNC(cellFiber, _cellFiberPpuSchedulerAttributeInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, _cellFiberPpuSchedulerAttributeInitialize);
REG_FUNC(cellFiber, cellFiberPpuInitializeScheduler, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuInitializeScheduler);
REG_FUNC(cellFiber, cellFiberPpuFinalizeScheduler, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuFinalizeScheduler);
REG_FUNC(cellFiber, cellFiberPpuRunFibers, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuRunFibers);
REG_FUNC(cellFiber, cellFiberPpuCheckFlags, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuCheckFlags);
REG_FUNC(cellFiber, cellFiberPpuHasRunnableFiber, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuHasRunnableFiber);
REG_FUNC(cellFiber, _cellFiberPpuAttributeInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, _cellFiberPpuAttributeInitialize);
REG_FUNC(cellFiber, cellFiberPpuCreateFiber, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuCreateFiber);
REG_FUNC(cellFiber, cellFiberPpuExit, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuExit);
REG_FUNC(cellFiber, cellFiberPpuYield, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuYield);
REG_FUNC(cellFiber, cellFiberPpuJoinFiber, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuJoinFiber);
REG_FUNC(cellFiber, cellFiberPpuSelf); REG_FUNC(cellFiber, cellFiberPpuSelf);
REG_FUNC(cellFiber, cellFiberPpuSendSignal, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSendSignal);
REG_FUNC(cellFiber, cellFiberPpuWaitSignal, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuWaitSignal);
REG_FUNC(cellFiber, cellFiberPpuWaitFlag, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuWaitFlag);
REG_FUNC(cellFiber, cellFiberPpuGetScheduler, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuGetScheduler);
REG_FUNC(cellFiber, cellFiberPpuSetPriority, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSetPriority);
REG_FUNC(cellFiber, cellFiberPpuCheckStackLimit, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuCheckStackLimit);
REG_FUNC(cellFiber, _cellFiberPpuContextAttributeInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, _cellFiberPpuContextAttributeInitialize);
REG_FUNC(cellFiber, cellFiberPpuContextInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextInitialize);
REG_FUNC(cellFiber, cellFiberPpuContextFinalize, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextFinalize);
REG_FUNC(cellFiber, cellFiberPpuContextRun, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextRun);
REG_FUNC(cellFiber, cellFiberPpuContextSwitch, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextSwitch);
REG_FUNC(cellFiber, cellFiberPpuContextSelf, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextSelf);
REG_FUNC(cellFiber, cellFiberPpuContextReturnToThread, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextReturnToThread);
REG_FUNC(cellFiber, cellFiberPpuContextCheckStackLimit, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextCheckStackLimit);
REG_FUNC(cellFiber, cellFiberPpuContextRunScheduler, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextRunScheduler);
REG_FUNC(cellFiber, cellFiberPpuContextEnterScheduler, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuContextEnterScheduler);
REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceInitialize);
REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceFinalize, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceFinalize);
REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceStart, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceStart);
REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceStop, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuSchedulerTraceStop);
REG_FUNC(cellFiber, _cellFiberPpuUtilWorkerControlAttributeInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, _cellFiberPpuUtilWorkerControlAttributeInitialize);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlRunFibers, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlRunFibers);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlInitialize, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlInitialize);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlSetPollingMode, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlSetPollingMode);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlJoinFiber, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlJoinFiber);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlDisconnectEventQueue, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlDisconnectEventQueue);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlSendSignal, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlSendSignal);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlConnectEventQueueToSpurs, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlConnectEventQueueToSpurs);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlFinalize, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlFinalize);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlWakeup, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlWakeup);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlCreateFiber, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlCreateFiber);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlShutdown, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlShutdown);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlCheckFlags, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlCheckFlags);
REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlInitializeWithAttribute, MFF_NO_RETURN); REG_FUNC(cellFiber, cellFiberPpuUtilWorkerControlInitializeWithAttribute);
}); });

View File

@ -1,15 +1,14 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
// Defines STB_TRUETYPE_IMPLEMENTATION *once* before including stb_truetype.h (as noted in stb_truetype.h's comments) // Defines STB_TRUETYPE_IMPLEMENTATION *once* before including stb_truetype.h (as noted in stb_truetype.h's comments)
#define STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION
#include <stb_truetype.h> #include <stb_truetype.h>
#include "Emu/FS/vfsFile.h"
#include "cellFont.h" #include "cellFont.h"
extern Module<> cellFont; LOG_CHANNEL(cellFont);
// Functions // Functions
s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> config) s32 cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr<CellFontConfig> config)
@ -68,15 +67,15 @@ s32 cellFontOpenFontFile(vm::ptr<CellFontLibrary> library, vm::cptr<char> fontPa
{ {
cellFont.warning("cellFontOpenFontFile(library=*0x%x, fontPath=*0x%x, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontPath, subNum, uniqueId, font); cellFont.warning("cellFontOpenFontFile(library=*0x%x, fontPath=*0x%x, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontPath, subNum, uniqueId, font);
vfsFile f(fontPath.get_ptr()); fs::file f(vfs::get(fontPath.get_ptr()));
if (!f.IsOpened()) if (!f)
{ {
return CELL_FONT_ERROR_FONT_OPEN_FAILED; return CELL_FONT_ERROR_FONT_OPEN_FAILED;
} }
u32 fileSize = (u32)f.GetSize(); u32 fileSize = ::size32(f);
u32 bufferAddr = vm::alloc(fileSize, vm::main); // Freed in cellFontCloseFont u32 bufferAddr = vm::alloc(fileSize, vm::main); // Freed in cellFontCloseFont
f.Read(vm::base(bufferAddr), fileSize); f.read(vm::base(bufferAddr), fileSize);
s32 ret = cellFontOpenFontMemory(library, bufferAddr, fileSize, subNum, uniqueId, font); s32 ret = cellFontOpenFontMemory(library, bufferAddr, fileSize, subNum, uniqueId, font);
font->origin = CELL_FONT_OPEN_FONT_FILE; font->origin = CELL_FONT_OPEN_FONT_FILE;
@ -742,7 +741,7 @@ s32 cellFontGraphicsGetLineRGBA()
} }
Module<> cellFont("cellFont", []() DECLARE(ppu_module_manager::cellFont)("cellFont", []()
{ {
REG_FUNC(cellFont, cellFontSetFontsetOpenMode); REG_FUNC(cellFont, cellFontSetFontsetOpenMode);
REG_FUNC(cellFont, cellFontSetFontOpenMode); REG_FUNC(cellFont, cellFontSetFontOpenMode);

View File

@ -1,10 +1,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
#include "cellFontFT.h" #include "cellFontFT.h"
extern Module<> cellFontFT; LOG_CHANNEL(cellFontFT);
s32 cellFontInitLibraryFreeTypeWithRevision(u64 revisionFlags, vm::ptr<CellFontLibraryConfigFT> config, vm::pptr<CellFontLibrary> lib) s32 cellFontInitLibraryFreeTypeWithRevision(u64 revisionFlags, vm::ptr<CellFontLibraryConfigFT> config, vm::pptr<CellFontLibrary> lib)
{ {
@ -27,7 +26,7 @@ s32 cellFontFTGetInitializedRevisionFlags()
return CELL_OK; return CELL_OK;
} }
Module<> cellFontFT("cellFontFT", []() DECLARE(ppu_module_manager::cellFontFT)("cellFontFT", []()
{ {
REG_FUNC(cellFontFT, cellFontInitLibraryFreeTypeWithRevision); REG_FUNC(cellFontFT, cellFontInitLibraryFreeTypeWithRevision);
REG_FUNC(cellFontFT, cellFontFTGetRevisionFlags); REG_FUNC(cellFontFT, cellFontFTGetRevisionFlags);

View File

@ -1,18 +1,12 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Callback.h"
#include "Emu/FS/VFS.h" #include "Emu/Cell/lv2/sys_fs.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/FS/vfsDir.h"
#include "Emu/SysCalls/lv2/sys_fs.h"
#include "cellFs.h" #include "cellFs.h"
extern Module<> cellFs; LOG_CHANNEL(cellFs);
s32 cellFsOpen(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<void> arg, u64 size) s32 cellFsOpen(vm::cptr<char> path, s32 flags, vm::ptr<u32> fd, vm::cptr<void> arg, u64 size)
{ {
@ -222,20 +216,22 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32
for (; count < entries_size; count++) for (; count < entries_size; count++)
{ {
if (const auto info = directory->dir->Read()) fs::dir_entry info;
if (directory->dir.read(info))
{ {
entries[count].attribute.mode = info->flags & DirEntry_TypeDir ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666; entries[count].attribute.mode = info.is_directory ? CELL_FS_S_IFDIR | 0777 : CELL_FS_S_IFREG | 0666;
entries[count].attribute.uid = 1; // ??? entries[count].attribute.uid = 1; // ???
entries[count].attribute.gid = 1; // ??? entries[count].attribute.gid = 1; // ???
entries[count].attribute.atime = info->access_time; entries[count].attribute.atime = info.atime;
entries[count].attribute.mtime = info->modify_time; entries[count].attribute.mtime = info.mtime;
entries[count].attribute.ctime = info->create_time; entries[count].attribute.ctime = info.ctime;
entries[count].attribute.size = info->size; entries[count].attribute.size = info.size;
entries[count].attribute.blksize = 4096; // ??? entries[count].attribute.blksize = 4096; // ???
entries[count].entry_name.d_type = info->flags & DirEntry_TypeFile ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY; entries[count].entry_name.d_type = info.is_directory ? CELL_FS_TYPE_DIRECTORY : CELL_FS_TYPE_REGULAR;
entries[count].entry_name.d_namlen = u8(std::min<size_t>(info->name.length(), CELL_FS_MAX_FS_FILE_NAME_LENGTH)); entries[count].entry_name.d_namlen = u8(std::min<size_t>(info.name.size(), CELL_FS_MAX_FS_FILE_NAME_LENGTH));
strcpy_trunc(entries[count].entry_name.d_name, info->name); strcpy_trunc(entries[count].entry_name.d_name, info.name);
} }
else else
{ {
@ -263,13 +259,11 @@ s32 cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 buffer_size,
std::lock_guard<std::mutex> lock(file->mutex); std::lock_guard<std::mutex> lock(file->mutex);
const auto old_position = file->file->Tell(); const auto old_pos = file->file.pos(); file->file.seek(offset);
CHECK_ASSERTION(file->file->Seek(offset) != -1); const auto read = file->file.read(buf.get_ptr(), buffer_size);
const auto read = file->file->Read(buf.get_ptr(), buffer_size); ASSERT(file->file.seek(old_pos) == old_pos);
CHECK_ASSERTION(file->file->Seek(old_position) != -1);
if (nread) if (nread)
{ {
@ -294,13 +288,11 @@ s32 cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr<void> buf, u64 data_size,
std::lock_guard<std::mutex> lock(file->mutex); std::lock_guard<std::mutex> lock(file->mutex);
const auto old_position = file->file->Tell(); const auto old_pos = file->file.pos(); file->file.seek(offset);
CHECK_ASSERTION(file->file->Seek(offset) != -1); const auto written = file->file.write(buf.get_ptr(), data_size);
const auto written = file->file->Write(buf.get_ptr(), data_size); ASSERT(file->file.seek(old_pos) == old_pos);
CHECK_ASSERTION(file->file->Seek(old_position) != -1);
if (nwrite) if (nwrite)
{ {
@ -489,12 +481,12 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
} }
} }
offset = std::min<u64>(file->file->GetSize(), offset); offset = std::min<u64>(file->file.size(), offset);
size = std::min<u64>(file->file->GetSize() - offset, size); size = std::min<u64>(file->file.size() - offset, size);
file->st_read_size = size; file->st_read_size = size;
file->st_thread = thread_ctrl::spawn(PURE_EXPR("FS ST Thread"s), [=]() file->st_thread = thread_ctrl::spawn("FS ST Thread", [=]()
{ {
std::unique_lock<std::mutex> lock(file->mutex); std::unique_lock<std::mutex> lock(file->mutex);
@ -504,13 +496,13 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
if (file->st_total_read - file->st_copied <= file->st_ringbuf_size - file->st_block_size && file->st_total_read < file->st_read_size) if (file->st_total_read - file->st_copied <= file->st_ringbuf_size - file->st_block_size && file->st_total_read < file->st_read_size)
{ {
// get buffer position // get buffer position
const u32 position = VM_CAST(file->st_buffer + file->st_total_read % file->st_ringbuf_size); const u32 position = vm::cast(file->st_buffer + file->st_total_read % file->st_ringbuf_size, HERE);
// read data // read data
auto old = file->file->Tell(); auto old = file->file.pos();
CHECK_ASSERTION(file->file->Seek(offset + file->st_total_read) != -1); file->file.seek(offset + file->st_total_read);
auto res = file->file->Read(vm::base(position), file->st_block_size); auto res = file->file.read(vm::base(position), file->st_block_size);
CHECK_ASSERTION(file->file->Seek(old) != -1); ASSERT(file->file.seek(old) == old);
// notify // notify
file->st_total_read += res; file->st_total_read += res;
@ -594,7 +586,7 @@ s32 cellFsStRead(u32 fd, vm::ptr<u8> buf, u64 size, vm::ptr<u64> rsize)
} }
const u64 copied = file->st_copied; const u64 copied = file->st_copied;
const u32 position = VM_CAST(file->st_buffer + copied % file->st_ringbuf_size); const u32 position = vm::cast(file->st_buffer + copied % file->st_ringbuf_size, HERE);
const u64 total_read = file->st_total_read; const u64 total_read = file->st_total_read;
const u64 copy_size = (*rsize = std::min<u64>(size, total_read - copied)); // write rsize const u64 copy_size = (*rsize = std::min<u64>(size, total_read - copied)); // write rsize
@ -628,7 +620,7 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr<u32> addr, vm::ptr<u64> size)
} }
const u64 copied = file->st_copied; const u64 copied = file->st_copied;
const u32 position = VM_CAST(file->st_buffer + copied % file->st_ringbuf_size); const u32 position = vm::cast(file->st_buffer + copied % file->st_ringbuf_size, HERE);
const u64 total_read = file->st_total_read; const u64 total_read = file->st_total_read;
if ((*size = std::min<u64>(file->st_ringbuf_size - (position - file->st_buffer), total_read - copied))) if ((*size = std::min<u64>(file->st_ringbuf_size - (position - file->st_buffer), total_read - copied)))
@ -752,23 +744,23 @@ bool sdata_check(u32 version, u32 flags, u64 filesizeInput, u64 filesizeTmp)
s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_file) s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_file)
{ {
std::shared_ptr<vfsFileBase> packed_stream(Emu.GetVFS().OpenFile(packed_file, fom::read)); fs::file packed_stream(vfs::get(packed_file));
std::shared_ptr<vfsFileBase> unpacked_stream(Emu.GetVFS().OpenFile(unpacked_file, fom::rewrite)); fs::file unpacked_stream(vfs::get(unpacked_file), fs::rewrite);
if (!packed_stream || !packed_stream->IsOpened()) if (!packed_stream)
{ {
cellFs.error("File '%s' not found!", packed_file.c_str()); cellFs.error("File '%s' not found!", packed_file);
return CELL_ENOENT; return CELL_ENOENT;
} }
if (!unpacked_stream || !unpacked_stream->IsOpened()) if (!unpacked_stream)
{ {
cellFs.error("File '%s' couldn't be created!", unpacked_file.c_str()); cellFs.error("File '%s' couldn't be created!", unpacked_file);
return CELL_ENOENT; return CELL_ENOENT;
} }
char buffer[10200]; char buffer[10200];
packed_stream->Read(buffer, 256); packed_stream.read(buffer, 256);
u32 format = *(be_t<u32>*)&buffer[0]; u32 format = *(be_t<u32>*)&buffer[0];
if (format != 0x4E504400) // "NPD\x00" if (format != 0x4E504400) // "NPD\x00"
{ {
@ -780,7 +772,7 @@ s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
u32 flags = *(be_t<u32>*)&buffer[0x80]; u32 flags = *(be_t<u32>*)&buffer[0x80];
u32 blockSize = *(be_t<u32>*)&buffer[0x84]; u32 blockSize = *(be_t<u32>*)&buffer[0x84];
u64 filesizeOutput = *(be_t<u64>*)&buffer[0x88]; u64 filesizeOutput = *(be_t<u64>*)&buffer[0x88];
u64 filesizeInput = packed_stream->GetSize(); u64 filesizeInput = packed_stream.size();
u32 blockCount = (u32)((filesizeOutput + blockSize - 1) / blockSize); u32 blockCount = (u32)((filesizeOutput + blockSize - 1) / blockSize);
// SDATA file is compressed // SDATA file is compressed
@ -804,20 +796,18 @@ s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
if (flags & 0x20) if (flags & 0x20)
{ {
CHECK_ASSERTION(packed_stream->Seek(0x100) != -1); ASSERT(packed_stream.seek(0x100) == 0x100);
} }
else else
{ {
CHECK_ASSERTION(packed_stream->Seek(startOffset) != -1); ASSERT(packed_stream.seek(startOffset) == startOffset);
} }
for (u32 i = 0; i < blockCount; i++) for (u32 i = 0; i < blockCount; i++)
{ {
if (flags & 0x20) if (flags & 0x20)
{ {
s64 cur; packed_stream.seek(t1, fs::seek_cur);
CHECK_ASSERTION((cur = packed_stream->Tell()) != -1);
CHECK_ASSERTION(packed_stream->Seek(cur + t1) != -1);
} }
if (!(blockCount - i - 1)) if (!(blockCount - i - 1))
@ -825,8 +815,8 @@ s32 sdata_unpack(const std::string& packed_file, const std::string& unpacked_fil
blockSize = (u32)(filesizeOutput - i * blockSize); blockSize = (u32)(filesizeOutput - i * blockSize);
} }
packed_stream->Read(buffer + 256, blockSize); packed_stream.read(buffer + 256, blockSize);
unpacked_stream->Write(buffer + 256, blockSize); unpacked_stream.write(buffer + 256, blockSize);
} }
} }
@ -891,13 +881,13 @@ void fsAio(vm::ptr<CellFsAio> aio, bool write, s32 xid, fs_aio_cb_t func)
{ {
std::lock_guard<std::mutex> lock(file->mutex); std::lock_guard<std::mutex> lock(file->mutex);
const auto old_position = file->file->Tell(); const auto old_pos = file->file.pos(); file->file.seek(aio->offset);
CHECK_ASSERTION(file->file->Seek(aio->offset) != -1); result = write
? file->file.write(aio->buf.get_ptr(), aio->size)
: file->file.read(aio->buf.get_ptr(), aio->size);
result = write ? file->file->Write(aio->buf.get_ptr(), aio->size) : file->file->Read(aio->buf.get_ptr(), aio->size); ASSERT(file->file.seek(old_pos) == old_pos);
CHECK_ASSERTION(file->file->Seek(old_position) != -1);
} }
// should be executed directly by FS AIO thread // should be executed directly by FS AIO thread
@ -927,7 +917,7 @@ s32 cellFsAioFinish(vm::cptr<char> mount_point)
return CELL_OK; return CELL_OK;
} }
std::atomic<s32> g_fs_aio_id; atomic_t<s32> g_fs_aio_id;
s32 cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func) s32 cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
{ {
@ -937,7 +927,7 @@ s32 cellFsAioRead(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
const s32 xid = (*id = ++g_fs_aio_id); const s32 xid = (*id = ++g_fs_aio_id);
thread_ctrl::spawn(PURE_EXPR("FS AIO Read Thread"s), COPY_EXPR(fsAio(aio, false, xid, func))); thread_ctrl::spawn("FS AIO Read Thread", COPY_EXPR(fsAio(aio, false, xid, func)));
return CELL_OK; return CELL_OK;
} }
@ -950,7 +940,7 @@ s32 cellFsAioWrite(vm::ptr<CellFsAio> aio, vm::ptr<s32> id, fs_aio_cb_t func)
const s32 xid = (*id = ++g_fs_aio_id); const s32 xid = (*id = ++g_fs_aio_id);
thread_ctrl::spawn(PURE_EXPR("FS AIO Write Thread"s), COPY_EXPR(fsAio(aio, true, xid, func))); thread_ctrl::spawn("FS AIO Write Thread", COPY_EXPR(fsAio(aio, true, xid, func)));
return CELL_OK; return CELL_OK;
} }
@ -1051,66 +1041,64 @@ s32 cellFsUnregisterL10nCallbacks()
} }
Module<> cellFs("cellFs", []() DECLARE(ppu_module_manager::cellFs)("sys_fs", []()
{ {
g_fs_aio_id = 1; REG_FUNC(sys_fs, cellFsOpen);
REG_FUNC(sys_fs, cellFsSdataOpen);
REG_FUNC(cellFs, cellFsOpen); REG_FUNC(sys_fs, cellFsSdataOpenByFd);
REG_FUNC(cellFs, cellFsSdataOpen); REG_FUNC(sys_fs, cellFsRead, MFF_PERFECT);
REG_FUNC(cellFs, cellFsSdataOpenByFd); REG_FUNC(sys_fs, cellFsWrite, MFF_PERFECT);
REG_FUNC(cellFs, cellFsRead, MFF_PERFECT); REG_FUNC(sys_fs, cellFsClose, MFF_PERFECT);
REG_FUNC(cellFs, cellFsWrite, MFF_PERFECT); REG_FUNC(sys_fs, cellFsOpendir);
REG_FUNC(cellFs, cellFsClose, MFF_PERFECT); REG_FUNC(sys_fs, cellFsReaddir, MFF_PERFECT);
REG_FUNC(cellFs, cellFsOpendir); REG_FUNC(sys_fs, cellFsClosedir, MFF_PERFECT);
REG_FUNC(cellFs, cellFsReaddir, MFF_PERFECT); REG_FUNC(sys_fs, cellFsStat);
REG_FUNC(cellFs, cellFsClosedir, MFF_PERFECT); REG_FUNC(sys_fs, cellFsFstat, MFF_PERFECT);
REG_FUNC(cellFs, cellFsStat); REG_FUNC(sys_fs, cellFsMkdir);
REG_FUNC(cellFs, cellFsFstat, MFF_PERFECT); REG_FUNC(sys_fs, cellFsRename);
REG_FUNC(cellFs, cellFsMkdir); REG_FUNC(sys_fs, cellFsChmod);
REG_FUNC(cellFs, cellFsRename); REG_FUNC(sys_fs, cellFsFsync);
REG_FUNC(cellFs, cellFsChmod); REG_FUNC(sys_fs, cellFsRmdir);
REG_FUNC(cellFs, cellFsFsync); REG_FUNC(sys_fs, cellFsUnlink);
REG_FUNC(cellFs, cellFsRmdir); REG_FUNC(sys_fs, cellFsLseek, MFF_PERFECT);
REG_FUNC(cellFs, cellFsUnlink); REG_FUNC(sys_fs, cellFsFtruncate, MFF_PERFECT);
REG_FUNC(cellFs, cellFsLseek, MFF_PERFECT); REG_FUNC(sys_fs, cellFsTruncate);
REG_FUNC(cellFs, cellFsFtruncate, MFF_PERFECT); REG_FUNC(sys_fs, cellFsFGetBlockSize, MFF_PERFECT);
REG_FUNC(cellFs, cellFsTruncate); REG_FUNC(sys_fs, cellFsAioInit);
REG_FUNC(cellFs, cellFsFGetBlockSize, MFF_PERFECT); REG_FUNC(sys_fs, cellFsAioFinish);
REG_FUNC(cellFs, cellFsAioInit); REG_FUNC(sys_fs, cellFsAioRead);
REG_FUNC(cellFs, cellFsAioFinish); REG_FUNC(sys_fs, cellFsAioWrite);
REG_FUNC(cellFs, cellFsAioRead); REG_FUNC(sys_fs, cellFsAioCancel);
REG_FUNC(cellFs, cellFsAioWrite); REG_FUNC(sys_fs, cellFsGetBlockSize);
REG_FUNC(cellFs, cellFsAioCancel); REG_FUNC(sys_fs, cellFsGetFreeSize);
REG_FUNC(cellFs, cellFsGetBlockSize); REG_FUNC(sys_fs, cellFsReadWithOffset);
REG_FUNC(cellFs, cellFsGetFreeSize); REG_FUNC(sys_fs, cellFsWriteWithOffset);
REG_FUNC(cellFs, cellFsReadWithOffset); REG_FUNC(sys_fs, cellFsGetDirectoryEntries);
REG_FUNC(cellFs, cellFsWriteWithOffset); REG_FUNC(sys_fs, cellFsStReadInit);
REG_FUNC(cellFs, cellFsGetDirectoryEntries); REG_FUNC(sys_fs, cellFsStReadFinish);
REG_FUNC(cellFs, cellFsStReadInit); REG_FUNC(sys_fs, cellFsStReadGetRingBuf);
REG_FUNC(cellFs, cellFsStReadFinish); REG_FUNC(sys_fs, cellFsStReadGetStatus);
REG_FUNC(cellFs, cellFsStReadGetRingBuf); REG_FUNC(sys_fs, cellFsStReadGetRegid);
REG_FUNC(cellFs, cellFsStReadGetStatus); REG_FUNC(sys_fs, cellFsStReadStart);
REG_FUNC(cellFs, cellFsStReadGetRegid); REG_FUNC(sys_fs, cellFsStReadStop);
REG_FUNC(cellFs, cellFsStReadStart); REG_FUNC(sys_fs, cellFsStRead);
REG_FUNC(cellFs, cellFsStReadStop); REG_FUNC(sys_fs, cellFsStReadGetCurrentAddr);
REG_FUNC(cellFs, cellFsStRead); REG_FUNC(sys_fs, cellFsStReadPutCurrentAddr);
REG_FUNC(cellFs, cellFsStReadGetCurrentAddr); REG_FUNC(sys_fs, cellFsStReadWait);
REG_FUNC(cellFs, cellFsStReadPutCurrentAddr); REG_FUNC(sys_fs, cellFsStReadWaitCallback);
REG_FUNC(cellFs, cellFsStReadWait); REG_FUNC(sys_fs, cellFsSetDefaultContainer);
REG_FUNC(cellFs, cellFsStReadWaitCallback); REG_FUNC(sys_fs, cellFsSetIoBufferFromDefaultContainer);
REG_FUNC(cellFs, cellFsSetDefaultContainer); REG_FUNC(sys_fs, cellFsUtime);
REG_FUNC(cellFs, cellFsSetIoBufferFromDefaultContainer); REG_FUNC(sys_fs, cellFsArcadeHddSerialNumber);
REG_FUNC(cellFs, cellFsUtime); REG_FUNC(sys_fs, cellFsAllocateFileAreaWithInitialData);
REG_FUNC(cellFs, cellFsArcadeHddSerialNumber); REG_FUNC(sys_fs, cellFsAllocateFileAreaByFdWithoutZeroFill);
REG_FUNC(cellFs, cellFsAllocateFileAreaWithInitialData); REG_FUNC(sys_fs, cellFsSetIoBuffer);
REG_FUNC(cellFs, cellFsAllocateFileAreaByFdWithoutZeroFill); REG_FUNC(sys_fs, cellFsAllocateFileAreaByFdWithInitialData);
REG_FUNC(cellFs, cellFsSetIoBuffer); REG_FUNC(sys_fs, cellFsTruncate2);
REG_FUNC(cellFs, cellFsAllocateFileAreaByFdWithInitialData); REG_FUNC(sys_fs, cellFsChangeFileSizeWithoutAllocation);
REG_FUNC(cellFs, cellFsTruncate2); REG_FUNC(sys_fs, cellFsAllocateFileAreaWithoutZeroFill);
REG_FUNC(cellFs, cellFsChangeFileSizeWithoutAllocation); REG_FUNC(sys_fs, cellFsChangeFileSizeByFdWithoutAllocation);
REG_FUNC(cellFs, cellFsAllocateFileAreaWithoutZeroFill); REG_FUNC(sys_fs, cellFsSetDiscReadRetrySetting);
REG_FUNC(cellFs, cellFsChangeFileSizeByFdWithoutAllocation); REG_FUNC(sys_fs, cellFsRegisterConversionCallback);
REG_FUNC(cellFs, cellFsSetDiscReadRetrySetting); REG_FUNC(sys_fs, cellFsUnregisterL10nCallbacks);
REG_FUNC(cellFs, cellFsRegisterConversionCallback);
REG_FUNC(cellFs, cellFsUnregisterL10nCallbacks);
}); });

View File

@ -1,17 +1,15 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFile.h"
#include "Loader/PSF.h"
#include "cellSysutil.h" #include "cellSysutil.h"
#include "cellMsgDialog.h" #include "cellMsgDialog.h"
#include "cellGame.h" #include "cellGame.h"
extern Module<> cellGame; #include <future>
LOG_CHANNEL(cellGame);
// Normal content directory (if is_temporary is not involved): // Normal content directory (if is_temporary is not involved):
// contentInfo = dir // contentInfo = dir
@ -40,7 +38,7 @@ struct content_permission_t final
{ {
if (is_temporary) if (is_temporary)
{ {
Emu.GetVFS().DeleteAll("/dev_hdd1/game/" + dir); fs::remove_all(vfs::get("/dev_hdd1/game/" + dir));
} }
} }
}; };
@ -56,7 +54,6 @@ s32 cellHddGameCheck(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 er
return CELL_HDDGAME_ERROR_PARAM; return CELL_HDDGAME_ERROR_PARAM;
} }
vm::var<CellHddGameSystemFileParam> param;
vm::var<CellHddGameCBResult> result; vm::var<CellHddGameCBResult> result;
vm::var<CellHddGameStatGet> get; vm::var<CellHddGameStatGet> get;
vm::var<CellHddGameStatSet> set; vm::var<CellHddGameStatSet> set;
@ -71,14 +68,17 @@ s32 cellHddGameCheck(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 er
strcpy_trunc(get->contentInfoPath, "/dev_hdd0/game/" + dir); strcpy_trunc(get->contentInfoPath, "/dev_hdd0/game/" + dir);
strcpy_trunc(get->hddGamePath, "/dev_hdd0/game/" + dir + "/USRDIR"); strcpy_trunc(get->hddGamePath, "/dev_hdd0/game/" + dir + "/USRDIR");
if (!Emu.GetVFS().ExistsDir("/dev_hdd0/game/" + dir)) const std::string& local_dir = vfs::get("/dev_hdd0/game/" + dir);
if (!fs::is_dir(local_dir))
{ {
get->isNewData = CELL_HDDGAME_ISNEWDATA_NODIR; get->isNewData = CELL_HDDGAME_ISNEWDATA_NODIR;
get->getParam = {};
} }
else else
{ {
// TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else) // TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else)
const auto& psf = psf::load(vfsFile("/dev_hdd0/game/" + dir + "/PARAM.SFO").VRead<char>()); const auto& psf = psf::load_object(fs::file(local_dir +"/PARAM.SFO"));
get->getParam.parentalLevel = psf.at("PARENTAL_LEVEL").as_integer(); get->getParam.parentalLevel = psf.at("PARENTAL_LEVEL").as_integer();
get->getParam.attribute = psf.at("ATTRIBUTE").as_integer(); get->getParam.attribute = psf.at("ATTRIBUTE").as_integer();
@ -159,16 +159,9 @@ s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGa
size->sysSizeKB = 0; size->sysSizeKB = 0;
} }
const auto& psf = psf::load(vfsFile("/app_home/../PARAM.SFO").VRead<char>());
if (psf.empty())
{
// According to testing (in debug mode) cellGameBootCheck doesn't return an error code, when PARAM.SFO doesn't exist. // According to testing (in debug mode) cellGameBootCheck doesn't return an error code, when PARAM.SFO doesn't exist.
cellGame.error("cellGameBootCheck(): Cannot read PARAM.SFO."); const std::string& category = psf::get_string(Emu.GetPSF(), "CATEGORY");
return CELL_GAME_RET_OK;
}
const std::string& category = psf.at("CATEGORY").as_string();
if (category == "DG") if (category == "DG")
{ {
*type = CELL_GAME_GAMETYPE_DISC; *type = CELL_GAME_GAMETYPE_DISC;
@ -182,22 +175,20 @@ s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGa
} }
else if (category == "HG") else if (category == "HG")
{ {
const std::string& titleId = psf.at("TITLE_ID").as_string();
*type = CELL_GAME_GAMETYPE_HDD; *type = CELL_GAME_GAMETYPE_HDD;
*attributes = 0; // TODO *attributes = 0; // TODO
if (dirName) strcpy_trunc(*dirName, titleId); if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID());
if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + titleId, false)) if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + Emu.GetTitleID(), false))
{ {
return CELL_GAME_ERROR_BUSY; return CELL_GAME_ERROR_BUSY;
} }
} }
else if (category == "GD") else if (category == "GD")
{ {
const std::string& titleId = psf.at("TITLE_ID").as_string();
*type = CELL_GAME_GAMETYPE_DISC; *type = CELL_GAME_GAMETYPE_DISC;
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO *attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
if (dirName) strcpy_trunc(*dirName, titleId); // ??? if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); // ???
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME", false)) if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME", false))
{ {
@ -206,7 +197,7 @@ s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGa
} }
else else
{ {
cellGame.error("cellGameBootCheck(): Unknown CATEGORY."); cellGame.error("cellGameBootCheck(): Unknown CATEGORY value: %s", category);
} }
return CELL_GAME_RET_OK; return CELL_GAME_RET_OK;
@ -226,15 +217,13 @@ s32 cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> reserved
size->sysSizeKB = 0; size->sysSizeKB = 0;
} }
const auto& psf = psf::load(vfsFile("/app_home/../PARAM.SFO").VRead<char>()); if (psf::get_string(Emu.GetPSF(), "CATEGORY") != "GD")
if (psf.empty() || psf.at("CATEGORY").as_string() != "GD")
{ {
cellGame.error("cellGamePatchCheck(): CELL_GAME_ERROR_NOTPATCH"); cellGame.error("cellGamePatchCheck(): CELL_GAME_ERROR_NOTPATCH");
return CELL_GAME_ERROR_NOTPATCH; return CELL_GAME_ERROR_NOTPATCH;
} }
if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + psf.at("TITLE_ID").as_string(), false)) if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + Emu.GetTitleID(), false))
{ {
return CELL_GAME_ERROR_BUSY; return CELL_GAME_ERROR_BUSY;
} }
@ -262,26 +251,10 @@ s32 cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameContentS
size->sysSizeKB = 0; size->sysSizeKB = 0;
} }
if (type == CELL_GAME_GAMETYPE_DISC)
{
// TODO: not sure what should be checked there // TODO: not sure what should be checked there
const std::string& dir = type == CELL_GAME_GAMETYPE_DISC ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/"s + dirName.get_ptr();
if (!Emu.GetVFS().ExistsDir("/dev_bdvd/PS3_GAME")) if (!fs::is_dir(vfs::get(dir)))
{
cellGame.warning("cellGameDataCheck(): /dev_bdvd/PS3_GAME not found");
return CELL_GAME_RET_NONE;
}
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME", false))
{
return CELL_GAME_ERROR_BUSY;
}
}
else
{
const std::string dir = "/dev_hdd0/game/"s + dirName.get_ptr();
if (!Emu.GetVFS().ExistsDir(dir))
{ {
cellGame.warning("cellGameDataCheck(): '%s' directory not found", dir.c_str()); cellGame.warning("cellGameDataCheck(): '%s' directory not found", dir.c_str());
return CELL_GAME_RET_NONE; return CELL_GAME_RET_NONE;
@ -291,7 +264,6 @@ s32 cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameContentS
{ {
return CELL_GAME_ERROR_BUSY; return CELL_GAME_ERROR_BUSY;
} }
}
return CELL_GAME_RET_OK; return CELL_GAME_RET_OK;
} }
@ -314,19 +286,21 @@ s32 cellGameContentPermit(vm::ptr<char[CELL_GAME_PATH_MAX]> contentInfoPath, vm:
if (path_set->is_temporary) if (path_set->is_temporary)
{ {
const std::string dir = "/dev_hdd0/game/" + path_set->dir; const std::string& dir = "/dev_hdd0/game/" + path_set->dir;
// make temporary directory persistent // Make temporary directory persistent
if (Emu.GetVFS().Rename("/dev_hdd1/game/" + path_set->dir, dir)) fs::remove_all(vfs::get(dir));
if (fs::rename(vfs::get("/dev_hdd1/game/" + path_set->dir), vfs::get(dir)))
{ {
cellGame.success("cellGameContentPermit(): '%s' directory created", dir); cellGame.success("cellGameContentPermit(): created directory %s", dir);
} }
else else
{ {
throw EXCEPTION("Cannot create gamedata directory"); throw fmt::exception("cellGameContentPermit(): failed to rename to %s", dir);
} }
// prevent deleting directory // Disable deletion
path_set->is_temporary = false; path_set->is_temporary = false;
strcpy_trunc(*contentInfoPath, dir); strcpy_trunc(*contentInfoPath, dir);
@ -353,17 +327,15 @@ s32 cellGameDataCheckCreate2(PPUThread& ppu, u32 version, vm::cptr<char> dirName
// TODO: output errors (errDialog) // TODO: output errors (errDialog)
const std::string dir = "/dev_hdd0/game/"s + dirName.get_ptr(); const std::string& dir = "/dev_hdd0/game/"s + dirName.get_ptr();
if (!Emu.GetVFS().ExistsDir(dir)) if (!fs::is_dir(vfs::get(dir)))
{ {
cellGame.todo("cellGameDataCheckCreate2(): creating directory '%s'", dir.c_str()); cellGame.todo("cellGameDataCheckCreate2(): should create directory %s", dir);
// TODO: create data // TODO: create data
return CELL_GAMEDATA_RET_OK; return CELL_GAMEDATA_RET_OK;
} }
const auto& psf = psf::load(vfsFile("/app_home/../PARAM.SFO").VRead<char>());
vm::var<CellGameDataCBResult> cbResult; vm::var<CellGameDataCBResult> cbResult;
vm::var<CellGameDataStatGet> cbGet; vm::var<CellGameDataStatGet> cbGet;
vm::var<CellGameDataStatSet> cbSet; vm::var<CellGameDataStatSet> cbSet;
@ -385,10 +357,10 @@ s32 cellGameDataCheckCreate2(PPUThread& ppu, u32 version, vm::cptr<char> dirName
cbGet->sysSizeKB = 0; cbGet->sysSizeKB = 0;
cbGet->getParam.attribute = CELL_GAMEDATA_ATTR_NORMAL; cbGet->getParam.attribute = CELL_GAMEDATA_ATTR_NORMAL;
cbGet->getParam.parentalLevel = psf.at("PARENTAL_LEVEL").as_integer(); cbGet->getParam.parentalLevel = Emu.GetPSF().at("PARENTAL_LEVEL").as_integer();
strcpy_trunc(cbGet->getParam.dataVersion, psf.at("APP_VER").as_string()); strcpy_trunc(cbGet->getParam.dataVersion, Emu.GetPSF().at("APP_VER").as_string());
strcpy_trunc(cbGet->getParam.titleId, psf.at("TITLE_ID").as_string()); strcpy_trunc(cbGet->getParam.titleId, Emu.GetPSF().at("TITLE_ID").as_string());
strcpy_trunc(cbGet->getParam.title, psf.at("TITLE").as_string()); strcpy_trunc(cbGet->getParam.title, Emu.GetPSF().at("TITLE").as_string());
// TODO: write lang titles // TODO: write lang titles
funcStat(ppu, cbResult, cbGet, cbSet); funcStat(ppu, cbResult, cbGet, cbSet);
@ -446,15 +418,15 @@ s32 cellGameCreateGameData(vm::ptr<CellGameSetInitParams> init, vm::ptr<char[CEL
std::string tmp_contentInfo = "/dev_hdd1/game/" + dir; std::string tmp_contentInfo = "/dev_hdd1/game/" + dir;
std::string tmp_usrdir = "/dev_hdd1/game/" + dir + "/USRDIR"; std::string tmp_usrdir = "/dev_hdd1/game/" + dir + "/USRDIR";
if (!Emu.GetVFS().CreateDir(tmp_contentInfo)) if (!fs::create_dir(vfs::get(tmp_contentInfo)))
{ {
cellGame.error("cellGameCreateGameData(): failed to create content directory ('%s')", tmp_contentInfo); cellGame.error("cellGameCreateGameData(): failed to create content directory %s", tmp_contentInfo);
return CELL_GAME_ERROR_ACCESS_ERROR; // ??? return CELL_GAME_ERROR_ACCESS_ERROR; // ???
} }
if (!Emu.GetVFS().CreateDir(tmp_usrdir)) if (!fs::create_dir(vfs::get(tmp_usrdir)))
{ {
cellGame.error("cellGameCreateGameData(): failed to create USRDIR directory ('%s')", tmp_usrdir); cellGame.error("cellGameCreateGameData(): failed to create USRDIR directory %s", tmp_usrdir);
return CELL_GAME_ERROR_ACCESS_ERROR; // ??? return CELL_GAME_ERROR_ACCESS_ERROR; // ???
} }
@ -484,8 +456,6 @@ s32 cellGameGetParamInt(u32 id, vm::ptr<u32> value)
{ {
cellGame.warning("cellGameGetParamInt(id=%d, value=*0x%x)", id, value); cellGame.warning("cellGameGetParamInt(id=%d, value=*0x%x)", id, value);
const auto& psf = psf::load(vfsFile("/app_home/../PARAM.SFO").VRead<char>());
std::string key; std::string key;
switch(id) switch(id)
@ -498,7 +468,7 @@ s32 cellGameGetParamInt(u32 id, vm::ptr<u32> value)
return CELL_GAME_ERROR_INVALID_ID; return CELL_GAME_ERROR_INVALID_ID;
} }
*value = psf.at(key).as_integer(); *value = Emu.GetPSF().at(key).as_integer();
return CELL_OK; return CELL_OK;
} }
@ -506,9 +476,8 @@ s32 cellGameGetParamString(u32 id, vm::ptr<char> buf, u32 bufsize)
{ {
cellGame.warning("cellGameGetParamString(id=%d, buf=*0x%x, bufsize=%d)", id, buf, bufsize); cellGame.warning("cellGameGetParamString(id=%d, buf=*0x%x, bufsize=%d)", id, buf, bufsize);
const auto& psf = psf::load(vfsFile("/app_home/../PARAM.SFO").VRead<char>());
std::string key; std::string key;
switch(id) switch(id)
{ {
case CELL_GAME_PARAMID_TITLE: key = "TITLE"; break; // TODO: Is this value correct? case CELL_GAME_PARAMID_TITLE: key = "TITLE"; break; // TODO: Is this value correct?
@ -542,7 +511,7 @@ s32 cellGameGetParamString(u32 id, vm::ptr<char> buf, u32 bufsize)
return CELL_GAME_ERROR_INVALID_ID; return CELL_GAME_ERROR_INVALID_ID;
} }
const std::string& value = psf.at(key).as_string().substr(0, bufsize - 1); const std::string& value = Emu.GetPSF().at(key).as_string().substr(0, bufsize - 1);
std::copy_n(value.c_str(), value.size() + 1, buf.get_ptr()); std::copy_n(value.c_str(), value.size() + 1, buf.get_ptr());
@ -666,8 +635,6 @@ s32 cellGameUnregisterDiscChangeCallback()
void cellSysutil_GameData_init() void cellSysutil_GameData_init()
{ {
extern Module<> cellSysutil;
REG_FUNC(cellSysutil, cellHddGameCheck); REG_FUNC(cellSysutil, cellHddGameCheck);
REG_FUNC(cellSysutil, cellHddGameCheck2); REG_FUNC(cellSysutil, cellHddGameCheck2);
REG_FUNC(cellSysutil, cellHddGameGetSizeKB); REG_FUNC(cellSysutil, cellHddGameGetSizeKB);
@ -688,7 +655,7 @@ void cellSysutil_GameData_init()
REG_FUNC(cellSysutil, cellGameUnregisterDiscChangeCallback); REG_FUNC(cellSysutil, cellGameUnregisterDiscChangeCallback);
} }
Module<> cellGame("cellGame", []() DECLARE(ppu_module_manager::cellGame)("cellGame", []()
{ {
REG_FUNC(cellGame, cellGameBootCheck); REG_FUNC(cellGame, cellGameBootCheck);
REG_FUNC(cellGame, cellGamePatchCheck); REG_FUNC(cellGame, cellGamePatchCheck);

View File

@ -1,10 +1,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
#include "cellGame.h" #include "cellGame.h"
extern Module<> cellGameExec; LOG_CHANNEL(cellGameExec);
s32 cellGameSetExitParam() s32 cellGameSetExitParam()
{ {
@ -45,7 +44,7 @@ s32 cellGameGetBootGameInfo(vm::ptr<u32> type, vm::ptr<char> dirName, vm::ptr<u3
return CELL_OK; return CELL_OK;
} }
Module<> cellGameExec("cellGameExec", []() DECLARE(ppu_module_manager::cellGameExec)("cellGameExec", []()
{ {
REG_FUNC(cellGameExec, cellGameSetExitParam); REG_FUNC(cellGameExec, cellGameSetExitParam);
REG_FUNC(cellGameExec, cellGameGetHomeDataExportPath); REG_FUNC(cellGameExec, cellGameGetHomeDataExportPath);

View File

@ -1,17 +1,16 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "sysPrxForUser.h" #include "Emu/Cell/PPUOpcodes.h"
#include "Emu/Memory/Memory.h"
//#include "Emu/RSX/GCM.h"
#include "Emu/RSX/GSManager.h"
#include "Emu/RSX/GSRender.h" #include "Emu/RSX/GSRender.h"
//#include "Emu/SysCalls/lv2/sys_process.h"
#include "cellGcmSys.h" #include "cellGcmSys.h"
extern Module<> cellGcmSys; LOG_CHANNEL(cellGcmSys);
extern s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count);
const u32 tiled_pitches[] = { const u32 tiled_pitches[] = {
0x00000000, 0x00000200, 0x00000300, 0x00000400, 0x00000000, 0x00000200, 0x00000300, 0x00000400,
@ -101,8 +100,7 @@ vm::ptr<CellGcmReportData> cellGcmGetReportDataAddressLocation(u32 index, u32 lo
cellGcmSys.error("cellGcmGetReportDataAddressLocation: Wrong main index (%d)", index); cellGcmSys.error("cellGcmGetReportDataAddressLocation: Wrong main index (%d)", index);
return vm::null; return vm::null;
} }
// TODO: It seems m_report_main_addr is not initialized return vm::ptr<CellGcmReportData>::make(RSXIOMem.RealAddr(index * 0x10));
return vm::ptr<CellGcmReportData>::make(Emu.GetGSManager().GetRender().report_main_addr + index * 0x10);
} }
cellGcmSys.error("cellGcmGetReportDataAddressLocation: Wrong location (%d)", location); cellGcmSys.error("cellGcmGetReportDataAddressLocation: Wrong location (%d)", location);
@ -200,8 +198,7 @@ u64 cellGcmGetTimeStampLocation(u32 index, u32 location)
cellGcmSys.error("cellGcmGetTimeStampLocation: Wrong main index (%d)", index); cellGcmSys.error("cellGcmGetTimeStampLocation: Wrong main index (%d)", index);
return 0; return 0;
} }
// TODO: It seems m_report_main_addr is not initialized return vm::read64(RSXIOMem.RealAddr(index * 0x10));
return vm::read64(Emu.GetGSManager().GetRender().report_main_addr + index * 0x10);
} }
cellGcmSys.error("cellGcmGetTimeStampLocation: Wrong location (%d)", location); cellGcmSys.error("cellGcmGetTimeStampLocation: Wrong location (%d)", location);
@ -257,8 +254,7 @@ s32 cellGcmBindTile(u8 index)
return CELL_GCM_ERROR_INVALID_VALUE; return CELL_GCM_ERROR_INVALID_VALUE;
} }
auto& tile = Emu.GetGSManager().GetRender().tiles[index]; fxm::get<GSRender>()->tiles[index].binded = true;
tile.binded = true;
return CELL_OK; return CELL_OK;
} }
@ -273,8 +269,7 @@ s32 cellGcmBindZcull(u8 index)
return CELL_GCM_ERROR_INVALID_VALUE; return CELL_GCM_ERROR_INVALID_VALUE;
} }
auto& zcull = Emu.GetGSManager().GetRender().zculls[index]; fxm::get<GSRender>()->zculls[index].binded = true;
zcull.binded = true;
return CELL_OK; return CELL_OK;
} }
@ -290,7 +285,7 @@ s32 cellGcmGetConfiguration(vm::ptr<CellGcmConfig> config)
s32 cellGcmGetFlipStatus() s32 cellGcmGetFlipStatus()
{ {
s32 status = Emu.GetGSManager().GetRender().flip_status; s32 status = fxm::get<GSRender>()->flip_status;
cellGcmSys.trace("cellGcmGetFlipStatus() -> %d", status); cellGcmSys.trace("cellGcmGetFlipStatus() -> %d", status);
@ -328,6 +323,11 @@ s32 _cellGcmInitBody(vm::pptr<CellGcmContextData> context, u32 cmdSize, u32 ioSi
{ {
cellGcmSys.warning("_cellGcmInitBody(context=**0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context, cmdSize, ioSize, ioAddress); cellGcmSys.warning("_cellGcmInitBody(context=**0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context, cmdSize, ioSize, ioAddress);
current_config.ioAddress = 0;
current_config.localAddress = 0;
local_size = 0;
local_addr = 0;
if (!local_size && !local_addr) if (!local_size && !local_addr)
{ {
local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize
@ -369,15 +369,19 @@ s32 _cellGcmInitBody(vm::pptr<CellGcmContextData> context, u32 cmdSize, u32 ioSi
g_defaultCommandBufferBegin = ioAddress; g_defaultCommandBufferBegin = ioAddress;
g_defaultCommandBufferFragmentCount = cmdSize / (32 * 1024); g_defaultCommandBufferFragmentCount = cmdSize / (32 * 1024);
gcm_info.context_addr = vm::alloc(0x1000, vm::main);
gcm_info.control_addr = vm::alloc(0x1000, vm::main);
gcm_info.label_addr = vm::alloc(0x1000, vm::main); // ???
current_context.begin.set(g_defaultCommandBufferBegin + 4096); // 4 kb reserved at the beginning current_context.begin.set(g_defaultCommandBufferBegin + 4096); // 4 kb reserved at the beginning
current_context.end.set(g_defaultCommandBufferBegin + 32 * 1024 - 4); // 4b at the end for jump current_context.end.set(g_defaultCommandBufferBegin + 32 * 1024 - 4); // 4b at the end for jump
current_context.current = current_context.begin; current_context.current = current_context.begin;
current_context.callback.set(Emu.GetRSXCallback() - 4); current_context.callback.set(gcm_info.context_addr + 0x40);
gcm_info.context_addr = vm::alloc(0x1000, vm::main); vm::write32(gcm_info.context_addr + 0x40, gcm_info.context_addr + 0x48);
gcm_info.control_addr = gcm_info.context_addr + 0x40; vm::write32(gcm_info.context_addr + 0x44, 0xabadcafe);
vm::write32(gcm_info.context_addr + 0x48, ppu_instructions::HACK(FIND_FUNC(cellGcmCallback)));
gcm_info.label_addr = vm::alloc(0x1000, vm::main); // ??? vm::write32(gcm_info.context_addr + 0x4c, ppu_instructions::BLR());
vm::_ref<CellGcmContextData>(gcm_info.context_addr) = current_context; vm::_ref<CellGcmContextData>(gcm_info.context_addr) = current_context;
context->set(gcm_info.context_addr); context->set(gcm_info.context_addr);
@ -387,16 +391,16 @@ s32 _cellGcmInitBody(vm::pptr<CellGcmContextData> context, u32 cmdSize, u32 ioSi
ctrl.get = 0; ctrl.get = 0;
ctrl.ref = -1; ctrl.ref = -1;
auto& render = Emu.GetGSManager().GetRender(); const auto render = fxm::get<GSRender>();
render.ctxt_addr = context.addr(); render->ctxt_addr = context.addr();
render.gcm_buffers.set(vm::alloc(sizeof(CellGcmDisplayInfo) * 8, vm::main)); render->gcm_buffers.set(vm::alloc(sizeof(CellGcmDisplayInfo) * 8, vm::main));
render.zculls_addr = vm::alloc(sizeof(CellGcmZcullInfo) * 8, vm::main); render->zculls_addr = vm::alloc(sizeof(CellGcmZcullInfo) * 8, vm::main);
render.tiles_addr = vm::alloc(sizeof(CellGcmTileInfo) * 15, vm::main); render->tiles_addr = vm::alloc(sizeof(CellGcmTileInfo) * 15, vm::main);
render.gcm_buffers_count = 0; render->gcm_buffers_count = 0;
render.gcm_current_buffer = 0; render->gcm_current_buffer = 0;
render.main_mem_addr = 0; render->main_mem_addr = 0;
render.label_addr = gcm_info.label_addr; render->label_addr = gcm_info.label_addr;
render.init(g_defaultCommandBufferBegin, cmdSize, gcm_info.control_addr, local_addr); render->init(g_defaultCommandBufferBegin, cmdSize, gcm_info.control_addr, local_addr);
return CELL_OK; return CELL_OK;
} }
@ -405,7 +409,7 @@ s32 cellGcmResetFlipStatus()
{ {
cellGcmSys.trace("cellGcmResetFlipStatus()"); cellGcmSys.trace("cellGcmResetFlipStatus()");
Emu.GetGSManager().GetRender().flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_WAITING; fxm::get<GSRender>()->flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_WAITING;
return CELL_OK; return CELL_OK;
} }
@ -419,7 +423,7 @@ s32 cellGcmSetDebugOutputLevel(s32 level)
case CELL_GCM_DEBUG_LEVEL0: case CELL_GCM_DEBUG_LEVEL0:
case CELL_GCM_DEBUG_LEVEL1: case CELL_GCM_DEBUG_LEVEL1:
case CELL_GCM_DEBUG_LEVEL2: case CELL_GCM_DEBUG_LEVEL2:
Emu.GetGSManager().GetRender().debug_level = level; fxm::get<GSRender>()->debug_level = level;
break; break;
default: return CELL_EINVAL; default: return CELL_EINVAL;
@ -438,16 +442,18 @@ s32 cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height
return CELL_EINVAL; return CELL_EINVAL;
} }
auto buffers = Emu.GetGSManager().GetRender().gcm_buffers; const auto render = fxm::get<GSRender>();
auto buffers = render->gcm_buffers;
buffers[id].offset = offset; buffers[id].offset = offset;
buffers[id].pitch = pitch; buffers[id].pitch = pitch;
buffers[id].width = width; buffers[id].width = width;
buffers[id].height = height; buffers[id].height = height;
if (id + 1 > Emu.GetGSManager().GetRender().gcm_buffers_count) if (id + 1 > render->gcm_buffers_count)
{ {
Emu.GetGSManager().GetRender().gcm_buffers_count = id + 1; render->gcm_buffers_count = id + 1;
} }
return CELL_OK; return CELL_OK;
@ -457,7 +463,7 @@ void cellGcmSetFlipHandler(vm::ptr<void(u32)> handler)
{ {
cellGcmSys.warning("cellGcmSetFlipHandler(handler=*0x%x)", handler); cellGcmSys.warning("cellGcmSetFlipHandler(handler=*0x%x)", handler);
Emu.GetGSManager().GetRender().flip_handler = handler; fxm::get<GSRender>()->flip_handler = handler;
} }
s32 cellGcmSetFlipMode(u32 mode) s32 cellGcmSetFlipMode(u32 mode)
@ -469,7 +475,7 @@ s32 cellGcmSetFlipMode(u32 mode)
case CELL_GCM_DISPLAY_HSYNC: case CELL_GCM_DISPLAY_HSYNC:
case CELL_GCM_DISPLAY_VSYNC: case CELL_GCM_DISPLAY_VSYNC:
case CELL_GCM_DISPLAY_HSYNC_WITH_NOISE: case CELL_GCM_DISPLAY_HSYNC_WITH_NOISE:
Emu.GetGSManager().GetRender().flip_mode = mode; fxm::get<GSRender>()->flip_mode = mode;
break; break;
default: default:
@ -483,7 +489,7 @@ void cellGcmSetFlipStatus()
{ {
cellGcmSys.warning("cellGcmSetFlipStatus()"); cellGcmSys.warning("cellGcmSetFlipStatus()");
Emu.GetGSManager().GetRender().flip_status = 0; fxm::get<GSRender>()->flip_status = 0;
} }
s32 cellGcmSetPrepareFlip(PPUThread& ppu, vm::ptr<CellGcmContextData> ctxt, u32 id) s32 cellGcmSetPrepareFlip(PPUThread& ppu, vm::ptr<CellGcmContextData> ctxt, u32 id)
@ -541,14 +547,22 @@ s32 cellGcmSetSecondVFrequency(u32 freq)
{ {
cellGcmSys.warning("cellGcmSetSecondVFrequency(level=%d)", freq); cellGcmSys.warning("cellGcmSetSecondVFrequency(level=%d)", freq);
const auto render = fxm::get<GSRender>();
switch (freq) switch (freq)
{ {
case CELL_GCM_DISPLAY_FREQUENCY_59_94HZ: case CELL_GCM_DISPLAY_FREQUENCY_59_94HZ:
Emu.GetGSManager().GetRender().frequency_mode = freq; Emu.GetGSManager().GetRender().fps_limit = 59.94; break; render->frequency_mode = freq;
render->fps_limit = 59.94;
break;
case CELL_GCM_DISPLAY_FREQUENCY_SCANOUT: case CELL_GCM_DISPLAY_FREQUENCY_SCANOUT:
Emu.GetGSManager().GetRender().frequency_mode = freq; cellGcmSys.todo("Unimplemented display frequency: Scanout"); break; render->frequency_mode = freq;
cellGcmSys.todo("Unimplemented display frequency: Scanout");
break;
case CELL_GCM_DISPLAY_FREQUENCY_DISABLE: case CELL_GCM_DISPLAY_FREQUENCY_DISABLE:
Emu.GetGSManager().GetRender().frequency_mode = freq; cellGcmSys.todo("Unimplemented display frequency: Disabled"); break; render->frequency_mode = freq;
cellGcmSys.todo("Unimplemented display frequency: Disabled");
break;
default: cellGcmSys.error("Improper display frequency specified!"); return CELL_OK; default: cellGcmSys.error("Improper display frequency specified!"); return CELL_OK;
} }
@ -583,7 +597,9 @@ s32 cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u
cellGcmSys.error("cellGcmSetTileInfo: bad compression mode! (%d)", comp); cellGcmSys.error("cellGcmSetTileInfo: bad compression mode! (%d)", comp);
} }
auto& tile = Emu.GetGSManager().GetRender().tiles[index]; const auto render = fxm::get<GSRender>();
auto& tile = render->tiles[index];
tile.location = location; tile.location = location;
tile.offset = offset; tile.offset = offset;
tile.size = size; tile.size = size;
@ -592,7 +608,7 @@ s32 cellGcmSetTileInfo(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u
tile.base = base; tile.base = base;
tile.bank = bank; tile.bank = bank;
vm::_ptr<CellGcmTileInfo>(Emu.GetGSManager().GetRender().tiles_addr)[index] = tile.pack(); vm::_ptr<CellGcmTileInfo>(render->tiles_addr)[index] = tile.pack();
return CELL_OK; return CELL_OK;
} }
@ -600,7 +616,7 @@ void cellGcmSetUserHandler(vm::ptr<void(u32)> handler)
{ {
cellGcmSys.warning("cellGcmSetUserHandler(handler=*0x%x)", handler); cellGcmSys.warning("cellGcmSetUserHandler(handler=*0x%x)", handler);
Emu.GetGSManager().GetRender().user_handler = handler; fxm::get<GSRender>()->user_handler = handler;
} }
s32 cellGcmSetUserCommand() s32 cellGcmSetUserCommand()
@ -612,7 +628,7 @@ void cellGcmSetVBlankHandler(vm::ptr<void(u32)> handler)
{ {
cellGcmSys.warning("cellGcmSetVBlankHandler(handler=*0x%x)", handler); cellGcmSys.warning("cellGcmSetVBlankHandler(handler=*0x%x)", handler);
Emu.GetGSManager().GetRender().vblank_handler = handler; fxm::get<GSRender>()->vblank_handler = handler;
} }
s32 cellGcmSetWaitFlip(vm::ptr<CellGcmContextData> ctxt) s32 cellGcmSetWaitFlip(vm::ptr<CellGcmContextData> ctxt)
@ -640,7 +656,9 @@ s32 cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart,
return CELL_GCM_ERROR_INVALID_VALUE; return CELL_GCM_ERROR_INVALID_VALUE;
} }
auto& zcull = Emu.GetGSManager().GetRender().zculls[index]; const auto render = fxm::get<GSRender>();
auto& zcull = render->zculls[index];
zcull.offset = offset; zcull.offset = offset;
zcull.width = width; zcull.width = width;
zcull.height = height; zcull.height = height;
@ -653,7 +671,7 @@ s32 cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart,
zcull.sRef = sRef; zcull.sRef = sRef;
zcull.sMask = sMask; zcull.sMask = sMask;
vm::_ptr<CellGcmZcullInfo>(Emu.GetGSManager().GetRender().zculls_addr)[index] = zcull.pack(); vm::_ptr<CellGcmZcullInfo>(render->zculls_addr)[index] = zcull.pack();
return CELL_OK; return CELL_OK;
} }
@ -667,8 +685,7 @@ s32 cellGcmUnbindTile(u8 index)
return CELL_GCM_ERROR_INVALID_VALUE; return CELL_GCM_ERROR_INVALID_VALUE;
} }
auto& tile = Emu.GetGSManager().GetRender().tiles[index]; fxm::get<GSRender>()->tiles[index].binded = false;
tile.binded = false;
return CELL_OK; return CELL_OK;
} }
@ -683,8 +700,7 @@ s32 cellGcmUnbindZcull(u8 index)
return CELL_EINVAL; return CELL_EINVAL;
} }
auto& zcull = Emu.GetGSManager().GetRender().zculls[index]; fxm::get<GSRender>()->zculls[index].binded = false;
zcull.binded = false;
return CELL_OK; return CELL_OK;
} }
@ -692,32 +708,30 @@ s32 cellGcmUnbindZcull(u8 index)
u32 cellGcmGetTileInfo() u32 cellGcmGetTileInfo()
{ {
cellGcmSys.warning("cellGcmGetTileInfo()"); cellGcmSys.warning("cellGcmGetTileInfo()");
return Emu.GetGSManager().GetRender().tiles_addr; return fxm::get<GSRender>()->tiles_addr;
} }
u32 cellGcmGetZcullInfo() u32 cellGcmGetZcullInfo()
{ {
cellGcmSys.warning("cellGcmGetZcullInfo()"); cellGcmSys.warning("cellGcmGetZcullInfo()");
return Emu.GetGSManager().GetRender().zculls_addr; return fxm::get<GSRender>()->zculls_addr;
} }
u32 cellGcmGetDisplayInfo() u32 cellGcmGetDisplayInfo()
{ {
cellGcmSys.warning("cellGcmGetDisplayInfo() = 0x%x", Emu.GetGSManager().GetRender().gcm_buffers.addr()); cellGcmSys.warning("cellGcmGetDisplayInfo()");
return Emu.GetGSManager().GetRender().gcm_buffers.addr(); return fxm::get<GSRender>()->gcm_buffers.addr();
} }
s32 cellGcmGetCurrentDisplayBufferId(vm::ptr<u8> id) s32 cellGcmGetCurrentDisplayBufferId(vm::ptr<u8> id)
{ {
cellGcmSys.warning("cellGcmGetCurrentDisplayBufferId(id=*0x%x)", id); cellGcmSys.warning("cellGcmGetCurrentDisplayBufferId(id=*0x%x)", id);
if (Emu.GetGSManager().GetRender().gcm_current_buffer > UINT8_MAX) if ((*id = fxm::get<GSRender>()->gcm_current_buffer) > UINT8_MAX)
{ {
throw EXCEPTION("Unexpected"); throw EXCEPTION("Unexpected");
} }
*id = Emu.GetGSManager().GetRender().gcm_current_buffer;
return CELL_OK; return CELL_OK;
} }
@ -748,7 +762,7 @@ u64 cellGcmGetLastFlipTime()
{ {
cellGcmSys.trace("cellGcmGetLastFlipTime()"); cellGcmSys.trace("cellGcmGetLastFlipTime()");
return Emu.GetGSManager().GetRender().last_flip_time; return fxm::get<GSRender>()->last_flip_time;
} }
u64 cellGcmGetLastSecondVTime() u64 cellGcmGetLastSecondVTime()
@ -761,7 +775,7 @@ u64 cellGcmGetVBlankCount()
{ {
cellGcmSys.trace("cellGcmGetVBlankCount()"); cellGcmSys.trace("cellGcmGetVBlankCount()");
return Emu.GetGSManager().GetRender().vblank_count; return fxm::get<GSRender>()->vblank_count;
} }
s32 cellGcmSysGetLastVBlankTime() s32 cellGcmSysGetLastVBlankTime()
@ -896,6 +910,8 @@ s32 gcmMapEaIoAddress(u32 ea, u32 io, u32 size, bool is_strict)
{ {
if ((ea & 0xFFFFF) || (io & 0xFFFFF) || (size & 0xFFFFF)) return CELL_GCM_ERROR_FAILURE; if ((ea & 0xFFFFF) || (io & 0xFFFFF) || (size & 0xFFFFF)) return CELL_GCM_ERROR_FAILURE;
const auto render = fxm::get<GSRender>();
// Check if the mapping was successfull // Check if the mapping was successfull
if (RSXIOMem.Map(ea, size, io)) if (RSXIOMem.Map(ea, size, io))
{ {
@ -904,7 +920,7 @@ s32 gcmMapEaIoAddress(u32 ea, u32 io, u32 size, bool is_strict)
{ {
offsetTable.ioAddress[(ea >> 20) + i] = (io >> 20) + i; offsetTable.ioAddress[(ea >> 20) + i] = (io >> 20) + i;
offsetTable.eaAddress[(io >> 20) + i] = (ea >> 20) + i; offsetTable.eaAddress[(io >> 20) + i] = (ea >> 20) + i;
Emu.GetGSManager().GetRender().strict_ordering[(io >> 20) + i] = is_strict; render->strict_ordering[(io >> 20) + i] = is_strict;
} }
} }
else else
@ -927,7 +943,7 @@ s32 cellGcmMapEaIoAddressWithFlags(u32 ea, u32 io, u32 size, u32 flags)
{ {
cellGcmSys.warning("cellGcmMapEaIoAddressWithFlags(ea=0x%x, io=0x%x, size=0x%x, flags=0x%x)", ea, io, size, flags); cellGcmSys.warning("cellGcmMapEaIoAddressWithFlags(ea=0x%x, io=0x%x, size=0x%x, flags=0x%x)", ea, io, size, flags);
assert(flags == 2 /*CELL_GCM_IOMAP_FLAG_STRICT_ORDERING*/); ASSERT(flags == 2 /*CELL_GCM_IOMAP_FLAG_STRICT_ORDERING*/);
return gcmMapEaIoAddress(ea, io, size, true); return gcmMapEaIoAddress(ea, io, size, true);
} }
@ -958,6 +974,8 @@ s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr<u32> offset)
u32 io = RSXIOMem.Map(ea, size); u32 io = RSXIOMem.Map(ea, size);
const auto render = fxm::get<GSRender>();
//check if the mapping was successfull //check if the mapping was successfull
if (RSXIOMem.RealAddr(io) == ea) if (RSXIOMem.RealAddr(io) == ea)
{ {
@ -966,7 +984,7 @@ s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr<u32> offset)
{ {
offsetTable.ioAddress[(ea >> 20) + i] = (u16)((io >> 20) + i); offsetTable.ioAddress[(ea >> 20) + i] = (u16)((io >> 20) + i);
offsetTable.eaAddress[(io >> 20) + i] = (u16)((ea >> 20) + i); offsetTable.eaAddress[(io >> 20) + i] = (u16)((ea >> 20) + i);
Emu.GetGSManager().GetRender().strict_ordering[(io >> 20) + i] = false; render->strict_ordering[(io >> 20) + i] = false;
} }
*offset = io; *offset = io;
@ -977,7 +995,7 @@ s32 cellGcmMapMainMemory(u32 ea, u32 size, vm::ptr<u32> offset)
return CELL_GCM_ERROR_NO_IO_PAGE_TABLE; return CELL_GCM_ERROR_NO_IO_PAGE_TABLE;
} }
Emu.GetGSManager().GetRender().main_mem_addr = Emu.GetGSManager().GetRender().ioAddress; render->main_mem_addr = render->ioAddress;
return CELL_OK; return CELL_OK;
} }
@ -1117,7 +1135,7 @@ s32 cellGcmSetCursorImageOffset(u32 offset)
void cellGcmSetDefaultCommandBuffer() void cellGcmSetDefaultCommandBuffer()
{ {
cellGcmSys.warning("cellGcmSetDefaultCommandBuffer()"); cellGcmSys.warning("cellGcmSetDefaultCommandBuffer()");
vm::write32(Emu.GetGSManager().GetRender().ctxt_addr, gcm_info.context_addr); vm::write32(fxm::get<GSRender>()->ctxt_addr, gcm_info.context_addr);
} }
s32 cellGcmSetDefaultCommandBufferAndSegmentWordSize() s32 cellGcmSetDefaultCommandBufferAndSegmentWordSize()
@ -1174,7 +1192,9 @@ s32 cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co
cellGcmSys.error("cellGcmSetTile: bad compression mode! (%d)", comp); cellGcmSys.error("cellGcmSetTile: bad compression mode! (%d)", comp);
} }
auto& tile = Emu.GetGSManager().GetRender().tiles[index]; const auto render = fxm::get<GSRender>();
auto& tile = render->tiles[index];
tile.location = location; tile.location = location;
tile.offset = offset; tile.offset = offset;
tile.size = size; tile.size = size;
@ -1183,7 +1203,7 @@ s32 cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co
tile.base = base; tile.base = base;
tile.bank = bank; tile.bank = bank;
vm::_ptr<CellGcmTileInfo>(Emu.GetGSManager().GetRender().tiles_addr)[index] = tile.pack(); vm::_ptr<CellGcmTileInfo>(render->tiles_addr)[index] = tile.pack();
return CELL_OK; return CELL_OK;
} }
@ -1247,7 +1267,7 @@ static std::pair<u32, u32> getNextCommandBufferBeginEnd(u32 current)
static u32 getOffsetFromAddress(u32 address) static u32 getOffsetFromAddress(u32 address)
{ {
const u32 upper = offsetTable.ioAddress[address >> 20]; // 12 bits const u32 upper = offsetTable.ioAddress[address >> 20]; // 12 bits
assert(upper != 0xFFFF); Expects(upper != 0xFFFF);
return (upper << 20) | (address & 0xFFFFF); return (upper << 20) | (address & 0xFFFFF);
} }
@ -1269,7 +1289,6 @@ static bool isInCommandBufferExcept(u32 getPos, u32 bufferBegin, u32 bufferEnd)
return true; return true;
} }
// TODO: Avoid using syscall 1023 for calling this function
s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count) s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count)
{ {
cellGcmSys.trace("cellGcmCallback(context=*0x%x, count=0x%x)", context, count); cellGcmSys.trace("cellGcmCallback(context=*0x%x, count=0x%x)", context, count);
@ -1306,13 +1325,8 @@ s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
Module<> cellGcmSys("cellGcmSys", []() DECLARE(ppu_module_manager::cellGcmSys)("cellGcmSys", []()
{ {
current_config.ioAddress = 0;
current_config.localAddress = 0;
local_size = 0;
local_addr = 0;
// Data Retrieval // Data Retrieval
REG_FUNC(cellGcmSys, cellGcmGetCurrentField); REG_FUNC(cellGcmSys, cellGcmGetCurrentField);
REG_FUNC(cellGcmSys, cellGcmGetLabelAddress); REG_FUNC(cellGcmSys, cellGcmGetLabelAddress);
@ -1419,4 +1433,7 @@ Module<> cellGcmSys("cellGcmSys", []()
REG_FUNC(cellGcmSys, cellGcmGpadGetStatus); REG_FUNC(cellGcmSys, cellGcmGpadGetStatus);
REG_FUNC(cellGcmSys, cellGcmGpadNotifyCaptureSurface); REG_FUNC(cellGcmSys, cellGcmGpadNotifyCaptureSurface);
REG_FUNC(cellGcmSys, cellGcmGpadCaptureSnapshot); REG_FUNC(cellGcmSys, cellGcmGpadCaptureSnapshot);
// Special
REG_FNID(cellGcmSys, 0x00000000, cellGcmCallback);
}); });

View File

@ -22,6 +22,3 @@ struct CellGcmOffsetTable
// Auxiliary functions // Auxiliary functions
s32 gcmMapEaIoAddress(u32 ea, u32 io, u32 size, bool is_strict); s32 gcmMapEaIoAddress(u32 ea, u32 io, u32 size, bool is_strict);
// Syscall
s32 cellGcmCallback(vm::ptr<CellGcmContextData> context, u32 count);

View File

@ -1,11 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
#include "cellGem.h" #include "cellGem.h"
extern Module<> cellGem; LOG_CHANNEL(cellGem);
struct gem_t struct gem_t
{ {
@ -273,43 +272,43 @@ s32 cellGemWriteExternalPort()
return CELL_OK; return CELL_OK;
} }
Module<> cellGem("cellGem", []() DECLARE(ppu_module_manager::cellGem)("libgem", []()
{ {
REG_FUNC(cellGem, cellGemCalibrate); REG_FUNC(libgem, cellGemCalibrate);
REG_FUNC(cellGem, cellGemClearStatusFlags); REG_FUNC(libgem, cellGemClearStatusFlags);
REG_FUNC(cellGem, cellGemConvertVideoFinish); REG_FUNC(libgem, cellGemConvertVideoFinish);
REG_FUNC(cellGem, cellGemConvertVideoStart); REG_FUNC(libgem, cellGemConvertVideoStart);
REG_FUNC(cellGem, cellGemEnableCameraPitchAngleCorrection); REG_FUNC(libgem, cellGemEnableCameraPitchAngleCorrection);
REG_FUNC(cellGem, cellGemEnableMagnetometer); REG_FUNC(libgem, cellGemEnableMagnetometer);
REG_FUNC(cellGem, cellGemEnd); REG_FUNC(libgem, cellGemEnd);
REG_FUNC(cellGem, cellGemFilterState); REG_FUNC(libgem, cellGemFilterState);
REG_FUNC(cellGem, cellGemForceRGB); REG_FUNC(libgem, cellGemForceRGB);
REG_FUNC(cellGem, cellGemGetAccelerometerPositionInDevice); REG_FUNC(libgem, cellGemGetAccelerometerPositionInDevice);
REG_FUNC(cellGem, cellGemGetAllTrackableHues); REG_FUNC(libgem, cellGemGetAllTrackableHues);
REG_FUNC(cellGem, cellGemGetCameraState); REG_FUNC(libgem, cellGemGetCameraState);
REG_FUNC(cellGem, cellGemGetEnvironmentLightingColor); REG_FUNC(libgem, cellGemGetEnvironmentLightingColor);
REG_FUNC(cellGem, cellGemGetHuePixels); REG_FUNC(libgem, cellGemGetHuePixels);
REG_FUNC(cellGem, cellGemGetImageState); REG_FUNC(libgem, cellGemGetImageState);
REG_FUNC(cellGem, cellGemGetInertialState); REG_FUNC(libgem, cellGemGetInertialState);
REG_FUNC(cellGem, cellGemGetInfo); REG_FUNC(libgem, cellGemGetInfo);
REG_FUNC(cellGem, cellGemGetMemorySize); REG_FUNC(libgem, cellGemGetMemorySize);
REG_FUNC(cellGem, cellGemGetRGB); REG_FUNC(libgem, cellGemGetRGB);
REG_FUNC(cellGem, cellGemGetRumble); REG_FUNC(libgem, cellGemGetRumble);
REG_FUNC(cellGem, cellGemGetState); REG_FUNC(libgem, cellGemGetState);
REG_FUNC(cellGem, cellGemGetStatusFlags); REG_FUNC(libgem, cellGemGetStatusFlags);
REG_FUNC(cellGem, cellGemGetTrackerHue); REG_FUNC(libgem, cellGemGetTrackerHue);
REG_FUNC(cellGem, cellGemHSVtoRGB); REG_FUNC(libgem, cellGemHSVtoRGB);
REG_FUNC(cellGem, cellGemInit); REG_FUNC(libgem, cellGemInit);
REG_FUNC(cellGem, cellGemInvalidateCalibration); REG_FUNC(libgem, cellGemInvalidateCalibration);
REG_FUNC(cellGem, cellGemIsTrackableHue); REG_FUNC(libgem, cellGemIsTrackableHue);
REG_FUNC(cellGem, cellGemPrepareCamera); REG_FUNC(libgem, cellGemPrepareCamera);
REG_FUNC(cellGem, cellGemPrepareVideoConvert); REG_FUNC(libgem, cellGemPrepareVideoConvert);
REG_FUNC(cellGem, cellGemReadExternalPortDeviceInfo); REG_FUNC(libgem, cellGemReadExternalPortDeviceInfo);
REG_FUNC(cellGem, cellGemReset); REG_FUNC(libgem, cellGemReset);
REG_FUNC(cellGem, cellGemSetRumble); REG_FUNC(libgem, cellGemSetRumble);
REG_FUNC(cellGem, cellGemSetYaw); REG_FUNC(libgem, cellGemSetYaw);
REG_FUNC(cellGem, cellGemTrackHues); REG_FUNC(libgem, cellGemTrackHues);
REG_FUNC(cellGem, cellGemUpdateFinish); REG_FUNC(libgem, cellGemUpdateFinish);
REG_FUNC(cellGem, cellGemUpdateStart); REG_FUNC(libgem, cellGemUpdateStart);
REG_FUNC(cellGem, cellGemWriteExternalPort); REG_FUNC(libgem, cellGemWriteExternalPort);
}); });

View File

@ -1,19 +1,15 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
// STB_IMAGE_IMPLEMENTATION is already defined in stb_image.cpp // STB_IMAGE_IMPLEMENTATION is already defined in stb_image.cpp
#include <stb_image.h> #include <stb_image.h>
#include "Emu/FS/VFS.h" #include "Emu/Cell/lv2/sys_fs.h"
#include "Emu/FS/vfsFileBase.h"
#include "Emu/SysCalls/lv2/sys_fs.h"
#include "cellGifDec.h" #include "cellGifDec.h"
extern Module<> cellGifDec; LOG_CHANNEL(cellGifDec);
// cellGifDec aliases (only for cellGifDec.cpp) // cellGifDec aliases (only for cellGifDec.cpp)
using PPMainHandle = vm::pptr<GifDecoder>; using PPMainHandle = vm::pptr<GifDecoder>;
@ -61,11 +57,11 @@ s32 cellGifDecOpen(PMainHandle mainHandle, PPSubHandle subHandle, PSrc src, POpe
case CELL_GIFDEC_FILE: case CELL_GIFDEC_FILE:
{ {
// Get file descriptor and size // Get file descriptor and size
std::shared_ptr<vfsStream> file_s(Emu.GetVFS().OpenFile(src->fileName.get_ptr(), fom::read)); fs::file file_s(vfs::get(src->fileName.get_ptr()));
if (!file_s) return CELL_GIFDEC_ERROR_OPEN_FILE; if (!file_s) return CELL_GIFDEC_ERROR_OPEN_FILE;
current_subHandle.fd = idm::make<lv2_file_t>(file_s, 0, 0); current_subHandle.fileSize = file_s.size();
current_subHandle.fileSize = file_s->GetSize(); current_subHandle.fd = idm::make<lv2_file_t>(std::move(file_s), 0, 0);
break; break;
} }
} }
@ -102,8 +98,8 @@ s32 cellGifDecReadHeader(PMainHandle mainHandle, PSubHandle subHandle, PInfo inf
case CELL_GIFDEC_FILE: case CELL_GIFDEC_FILE:
{ {
auto file = idm::get<lv2_file_t>(fd); auto file = idm::get<lv2_file_t>(fd);
file->file->Seek(0); file->file.seek(0);
file->file->Read(buffer, sizeof(buffer)); file->file.read(buffer, sizeof(buffer));
break; break;
} }
} }
@ -186,8 +182,8 @@ s32 cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr<u
case CELL_GIFDEC_FILE: case CELL_GIFDEC_FILE:
{ {
auto file = idm::get<lv2_file_t>(fd); auto file = idm::get<lv2_file_t>(fd);
file->file->Seek(0); file->file.seek(0);
file->file->Read(gif.get(), fileSize); file->file.read(gif.get(), fileSize);
break; break;
} }
} }
@ -300,7 +296,7 @@ s32 cellGifDecDestroy(PMainHandle mainHandle)
return CELL_OK; return CELL_OK;
} }
Module<> cellGifDec("cellGifDec", []() DECLARE(ppu_module_manager::cellGifDec)("cellGifDec", []()
{ {
REG_FUNC(cellGifDec, cellGifDecCreate); REG_FUNC(cellGifDec, cellGifDecCreate);
REG_FUNC(cellGifDec, cellGifDecExtCreate); REG_FUNC(cellGifDec, cellGifDecExtCreate);

View File

@ -1,9 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellHttp; LOG_CHANNEL(cellHttp);
extern Module<> cellHttps;
s32 cellHttpInit() s32 cellHttpInit()
{ {
@ -599,7 +597,7 @@ s32 cellHttpClientSetSslIdDestroyCallback()
return CELL_OK; return CELL_OK;
} }
Module<> cellHttp("cellHttp", []() DECLARE(ppu_module_manager::cellHttp)("cellHttp", []()
{ {
REG_FUNC(cellHttp, cellHttpInit); REG_FUNC(cellHttp, cellHttpInit);
REG_FUNC(cellHttp, cellHttpEnd); REG_FUNC(cellHttp, cellHttpEnd);
@ -713,7 +711,7 @@ Module<> cellHttp("cellHttp", []()
REG_FUNC(cellHttp, cellHttpClientSetSslIdDestroyCallback); REG_FUNC(cellHttp, cellHttpClientSetSslIdDestroyCallback);
}); });
Module<> cellHttps("cellHttps", []() DECLARE(ppu_module_manager::cellHttps)("cellHttps", []()
{ {
// cellHttps doesn't have functions (cellHttpsInit belongs to cellHttp, for example) // cellHttps doesn't have functions (cellHttpsInit belongs to cellHttp, for example)
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellHttpUtil; LOG_CHANNEL(cellHttpUtil);
s32 cellHttpUtilParseUri() s32 cellHttpUtilParseUri()
{ {
@ -124,7 +123,7 @@ s32 cellHttpUtilBase64Decoder()
return CELL_OK; return CELL_OK;
} }
Module<> cellHttpUtil("cellHttpUtil", []() DECLARE(ppu_module_manager::cellHttpUtil)("cellHttpUtil", []()
{ {
REG_FUNC(cellHttpUtil, cellHttpUtilParseUri); REG_FUNC(cellHttpUtil, cellHttpUtilParseUri);
REG_FUNC(cellHttpUtil, cellHttpUtilParseUriPath); REG_FUNC(cellHttpUtil, cellHttpUtilParseUriPath);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellImeJp; LOG_CHANNEL(cellImeJp);
// Return Codes // Return Codes
enum enum
@ -262,50 +261,50 @@ s32 cellImeJpConfirmPrediction()
return CELL_OK; return CELL_OK;
} }
Module<> cellImeJp("cellImeJp", []() DECLARE(ppu_module_manager::cellImeJp)("cellImeJpUtility", []()
{ {
REG_FUNC(cellImeJp, cellImeJpOpen); REG_FUNC(cellImeJpUtility, cellImeJpOpen);
REG_FUNC(cellImeJp, cellImeJpOpen2); REG_FUNC(cellImeJpUtility, cellImeJpOpen2);
REG_FUNC(cellImeJp, cellImeJpOpen3); REG_FUNC(cellImeJpUtility, cellImeJpOpen3);
REG_FUNC(cellImeJp, cellImeJpClose); REG_FUNC(cellImeJpUtility, cellImeJpClose);
REG_FUNC(cellImeJp, cellImeJpSetKanaInputMode); REG_FUNC(cellImeJpUtility, cellImeJpSetKanaInputMode);
REG_FUNC(cellImeJp, cellImeJpSetInputCharType); REG_FUNC(cellImeJpUtility, cellImeJpSetInputCharType);
REG_FUNC(cellImeJp, cellImeJpSetFixInputMode); REG_FUNC(cellImeJpUtility, cellImeJpSetFixInputMode);
REG_FUNC(cellImeJp, cellImeJpAllowExtensionCharacters); REG_FUNC(cellImeJpUtility, cellImeJpAllowExtensionCharacters);
REG_FUNC(cellImeJp, cellImeJpReset); REG_FUNC(cellImeJpUtility, cellImeJpReset);
REG_FUNC(cellImeJp, cellImeJpGetStatus); REG_FUNC(cellImeJpUtility, cellImeJpGetStatus);
REG_FUNC(cellImeJp, cellImeJpEnterChar); REG_FUNC(cellImeJpUtility, cellImeJpEnterChar);
REG_FUNC(cellImeJp, cellImeJpEnterCharExt); REG_FUNC(cellImeJpUtility, cellImeJpEnterCharExt);
REG_FUNC(cellImeJp, cellImeJpEnterString); REG_FUNC(cellImeJpUtility, cellImeJpEnterString);
REG_FUNC(cellImeJp, cellImeJpEnterStringExt); REG_FUNC(cellImeJpUtility, cellImeJpEnterStringExt);
REG_FUNC(cellImeJp, cellImeJpModeCaretRight); REG_FUNC(cellImeJpUtility, cellImeJpModeCaretRight);
REG_FUNC(cellImeJp, cellImeJpModeCaretLeft); REG_FUNC(cellImeJpUtility, cellImeJpModeCaretLeft);
REG_FUNC(cellImeJp, cellImeJpBackspaceWord); REG_FUNC(cellImeJpUtility, cellImeJpBackspaceWord);
REG_FUNC(cellImeJp, cellImeJpDeleteWord); REG_FUNC(cellImeJpUtility, cellImeJpDeleteWord);
REG_FUNC(cellImeJp, cellImeJpAllDeleteConvertString); REG_FUNC(cellImeJpUtility, cellImeJpAllDeleteConvertString);
REG_FUNC(cellImeJp, cellImeJpConvertForward); REG_FUNC(cellImeJpUtility, cellImeJpConvertForward);
REG_FUNC(cellImeJp, cellImeJpConvertBackward); REG_FUNC(cellImeJpUtility, cellImeJpConvertBackward);
REG_FUNC(cellImeJp, cellImeJpCurrentPartConfirm); REG_FUNC(cellImeJpUtility, cellImeJpCurrentPartConfirm);
REG_FUNC(cellImeJp, cellImeJpAllConfirm); REG_FUNC(cellImeJpUtility, cellImeJpAllConfirm);
REG_FUNC(cellImeJp, cellImeJpConvertCancel); REG_FUNC(cellImeJpUtility, cellImeJpConvertCancel);
REG_FUNC(cellImeJp, cellImeJpAllConvertCancel); REG_FUNC(cellImeJpUtility, cellImeJpAllConvertCancel);
REG_FUNC(cellImeJp, cellImeJpExtendConvertArea); REG_FUNC(cellImeJpUtility, cellImeJpExtendConvertArea);
REG_FUNC(cellImeJp, cellImeJpShortenConvertArea); REG_FUNC(cellImeJpUtility, cellImeJpShortenConvertArea);
REG_FUNC(cellImeJp, cellImeJpTemporalConfirm); REG_FUNC(cellImeJpUtility, cellImeJpTemporalConfirm);
REG_FUNC(cellImeJp, cellImeJpPostConvert); REG_FUNC(cellImeJpUtility, cellImeJpPostConvert);
REG_FUNC(cellImeJp, cellImeJpMoveFocusClause); REG_FUNC(cellImeJpUtility, cellImeJpMoveFocusClause);
REG_FUNC(cellImeJp, cellImeJpGetFocusTop); REG_FUNC(cellImeJpUtility, cellImeJpGetFocusTop);
REG_FUNC(cellImeJp, cellImeJpGetFocusLength); REG_FUNC(cellImeJpUtility, cellImeJpGetFocusLength);
REG_FUNC(cellImeJp, cellImeJpGetConfirmYomiString); REG_FUNC(cellImeJpUtility, cellImeJpGetConfirmYomiString);
REG_FUNC(cellImeJp, cellImeJpGetConfirmString); REG_FUNC(cellImeJpUtility, cellImeJpGetConfirmString);
REG_FUNC(cellImeJp, cellImeJpGetConvertYomiString); REG_FUNC(cellImeJpUtility, cellImeJpGetConvertYomiString);
REG_FUNC(cellImeJp, cellImeJpGetConvertString); REG_FUNC(cellImeJpUtility, cellImeJpGetConvertString);
REG_FUNC(cellImeJp, cellImeJpGetCandidateListSize); REG_FUNC(cellImeJpUtility, cellImeJpGetCandidateListSize);
REG_FUNC(cellImeJp, cellImeJpGetCandidateList); REG_FUNC(cellImeJpUtility, cellImeJpGetCandidateList);
REG_FUNC(cellImeJp, cellImeJpGetCandidateSelect); REG_FUNC(cellImeJpUtility, cellImeJpGetCandidateSelect);
REG_FUNC(cellImeJp, cellImeJpGetPredictList); REG_FUNC(cellImeJpUtility, cellImeJpGetPredictList);
REG_FUNC(cellImeJp, cellImeJpConfirmPrediction); REG_FUNC(cellImeJpUtility, cellImeJpConfirmPrediction);
}); });

View File

@ -1,19 +1,15 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
// STB_IMAGE_IMPLEMENTATION is already defined in stb_image.cpp // STB_IMAGE_IMPLEMENTATION is already defined in stb_image.cpp
#include <stb_image.h> #include <stb_image.h>
#include "Emu/FS/VFS.h" #include "Emu/Cell/lv2/sys_fs.h"
#include "Emu/FS/vfsFileBase.h"
#include "Emu/SysCalls/lv2/sys_fs.h"
#include "cellJpgDec.h" #include "cellJpgDec.h"
extern Module<> cellJpgDec; LOG_CHANNEL(cellJpgDec);
s32 cellJpgDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam) s32 cellJpgDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam)
{ {
@ -51,11 +47,11 @@ s32 cellJpgDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellJpgDecSrc
case CELL_JPGDEC_FILE: case CELL_JPGDEC_FILE:
{ {
// Get file descriptor and size // Get file descriptor and size
std::shared_ptr<vfsStream> file_s(Emu.GetVFS().OpenFile(src->fileName.get_ptr(), fom::read)); fs::file file_s(vfs::get(src->fileName.get_ptr()));
if (!file_s) return CELL_JPGDEC_ERROR_OPEN_FILE; if (!file_s) return CELL_JPGDEC_ERROR_OPEN_FILE;
current_subHandle.fd = idm::make<lv2_file_t>(file_s, 0, 0); current_subHandle.fileSize = file_s.size();
current_subHandle.fileSize = file_s->GetSize(); current_subHandle.fd = idm::make<lv2_file_t>(std::move(file_s), 0, 0);
break; break;
} }
} }
@ -115,8 +111,8 @@ s32 cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
case CELL_JPGDEC_FILE: case CELL_JPGDEC_FILE:
{ {
auto file = idm::get<lv2_file_t>(fd); auto file = idm::get<lv2_file_t>(fd);
file->file->Seek(0); file->file.seek(0);
file->file->Read(buffer.get(), fileSize); file->file.read(buffer.get(), fileSize);
break; break;
} }
} }
@ -194,8 +190,8 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
case CELL_JPGDEC_FILE: case CELL_JPGDEC_FILE:
{ {
auto file = idm::get<lv2_file_t>(fd); auto file = idm::get<lv2_file_t>(fd);
file->file->Seek(0); file->file.seek(0);
file->file->Read(jpg.get(), fileSize); file->file.read(jpg.get(), fileSize);
break; break;
} }
} }
@ -357,7 +353,7 @@ s32 cellJpgDecExtSetParameter()
} }
Module<> cellJpgDec("cellJpgDec", []() DECLARE(ppu_module_manager::cellJpgDec)("cellJpgDec", []()
{ {
REG_FUNC(cellJpgDec, cellJpgDecCreate); REG_FUNC(cellJpgDec, cellJpgDecCreate);
REG_FUNC(cellJpgDec, cellJpgDecExtCreate); REG_FUNC(cellJpgDec, cellJpgDecExtCreate);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellJpgEnc; LOG_CHANNEL(cellJpgEnc);
// Error Codes // Error Codes
enum enum
@ -75,7 +74,7 @@ s32 cellJpgEncReset()
return CELL_OK; return CELL_OK;
} }
Module<> cellJpgEnc("cellJpgEnc", []() DECLARE(ppu_module_manager::cellJpgEnc)("cellJpgEnc", []()
{ {
REG_FUNC(cellJpgEnc, cellJpgEncQueryAttr); REG_FUNC(cellJpgEnc, cellJpgEncQueryAttr);
REG_FUNC(cellJpgEnc, cellJpgEncOpen); REG_FUNC(cellJpgEnc, cellJpgEncOpen);

View File

@ -1,35 +1,37 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Io/Keyboard.h" #include "Emu/Io/KeyboardHandler.h"
#include "cellKb.h" #include "cellKb.h"
extern Module<> sys_io; extern _log::channel sys_io;
s32 cellKbInit(u32 max_connect) s32 cellKbInit(u32 max_connect)
{ {
sys_io.warning("cellKbInit(max_connect=%d)", max_connect); sys_io.warning("cellKbInit(max_connect=%d)", max_connect);
if (Emu.GetKeyboardManager().IsInited())
return CELL_KB_ERROR_ALREADY_INITIALIZED;
if (max_connect > 7) if (max_connect > 7)
return CELL_KB_ERROR_INVALID_PARAMETER; return CELL_KB_ERROR_INVALID_PARAMETER;
Emu.GetKeyboardManager().Init(max_connect); const auto handler = fxm::import<KeyboardHandlerBase>(PURE_EXPR(Emu.GetCallbacks().get_kb_handler()));
if (!handler)
return CELL_KB_ERROR_ALREADY_INITIALIZED;
handler->Init(max_connect);
return CELL_OK; return CELL_OK;
} }
s32 cellKbEnd() s32 cellKbEnd()
{ {
sys_io.trace("cellKbEnd()"); sys_io.notice("cellKbEnd()");
if (!Emu.GetKeyboardManager().IsInited()) if (!fxm::remove<KeyboardHandlerBase>())
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
Emu.GetKeyboardManager().Close();
return CELL_OK; return CELL_OK;
} }
@ -37,10 +39,12 @@ s32 cellKbClearBuf(u32 port_no)
{ {
sys_io.trace("cellKbClearBuf(port_no=%d)", port_no); sys_io.trace("cellKbClearBuf(port_no=%d)", port_no);
if (!Emu.GetKeyboardManager().IsInited()) const auto handler = fxm::get<KeyboardHandlerBase>();
if (!handler)
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
if (port_no >= Emu.GetKeyboardManager().GetKeyboards().size()) if (port_no >= handler->GetKeyboards().size())
return CELL_KB_ERROR_INVALID_PARAMETER; return CELL_KB_ERROR_INVALID_PARAMETER;
//? //?
@ -98,10 +102,12 @@ s32 cellKbGetInfo(vm::ptr<CellKbInfo> info)
{ {
sys_io.trace("cellKbGetInfo(info=*0x%x)", info); sys_io.trace("cellKbGetInfo(info=*0x%x)", info);
if (!Emu.GetKeyboardManager().IsInited()) const auto handler = fxm::get<KeyboardHandlerBase>();
if (!handler)
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
const KbInfo& current_info = Emu.GetKeyboardManager().GetInfo(); const KbInfo& current_info = handler->GetInfo();
info->max_connect = current_info.max_connect; info->max_connect = current_info.max_connect;
info->now_connect = current_info.now_connect; info->now_connect = current_info.now_connect;
info->info = current_info.info; info->info = current_info.info;
@ -118,14 +124,17 @@ s32 cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
{ {
sys_io.trace("cellKbRead(port_no=%d, data=*0x%x)", port_no, data); sys_io.trace("cellKbRead(port_no=%d, data=*0x%x)", port_no, data);
const std::vector<Keyboard>& keyboards = Emu.GetKeyboardManager().GetKeyboards(); const auto handler = fxm::get<KeyboardHandlerBase>();
if (!Emu.GetKeyboardManager().IsInited())
if (!handler)
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
const std::vector<Keyboard>& keyboards = handler->GetKeyboards();
if (port_no >= keyboards.size()) if (port_no >= keyboards.size())
return CELL_KB_ERROR_INVALID_PARAMETER; return CELL_KB_ERROR_INVALID_PARAMETER;
KbData& current_data = Emu.GetKeyboardManager().GetData(port_no); KbData& current_data = handler->GetData(port_no);
data->led = current_data.led; data->led = current_data.led;
data->mkey = current_data.mkey; data->mkey = current_data.mkey;
data->len = std::min((u32)current_data.len, CELL_KB_MAX_KEYCODES); data->len = std::min((u32)current_data.len, CELL_KB_MAX_KEYCODES);
@ -144,10 +153,12 @@ s32 cellKbSetCodeType(u32 port_no, u32 type)
{ {
sys_io.trace("cellKbSetCodeType(port_no=%d,type=%d)", port_no, type); sys_io.trace("cellKbSetCodeType(port_no=%d,type=%d)", port_no, type);
if (!Emu.GetKeyboardManager().IsInited()) const auto handler = fxm::get<KeyboardHandlerBase>();
if (!handler)
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no); KbConfig& current_config = handler->GetConfig(port_no);
current_config.code_type = type; current_config.code_type = type;
return CELL_OK; return CELL_OK;
} }
@ -162,10 +173,12 @@ s32 cellKbSetReadMode(u32 port_no, u32 rmode)
{ {
sys_io.trace("cellKbSetReadMode(port_no=%d,rmode=%d)", port_no, rmode); sys_io.trace("cellKbSetReadMode(port_no=%d,rmode=%d)", port_no, rmode);
if (!Emu.GetKeyboardManager().IsInited()) const auto handler = fxm::get<KeyboardHandlerBase>();
if (!handler)
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no); KbConfig& current_config = handler->GetConfig(port_no);
current_config.read_mode = rmode; current_config.read_mode = rmode;
return CELL_OK; return CELL_OK;
@ -175,10 +188,12 @@ s32 cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
{ {
sys_io.trace("cellKbGetConfiguration(port_no=%d, config=*0x%x)", port_no, config); sys_io.trace("cellKbGetConfiguration(port_no=%d, config=*0x%x)", port_no, config);
if (!Emu.GetKeyboardManager().IsInited()) const auto handler = fxm::get<KeyboardHandlerBase>();
if (!handler)
return CELL_KB_ERROR_UNINITIALIZED; return CELL_KB_ERROR_UNINITIALIZED;
const KbConfig& current_config = Emu.GetKeyboardManager().GetConfig(port_no); const KbConfig& current_config = handler->GetConfig(port_no);
config->arrange = current_config.arrange; config->arrange = current_config.arrange;
config->read_mode = current_config.read_mode; config->read_mode = current_config.read_mode;
config->code_type = current_config.code_type; config->code_type = current_config.code_type;

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellKey2char; LOG_CHANNEL(cellKey2char);
// Return Codes // Return Codes
enum enum
@ -46,7 +45,7 @@ s32 cellKey2CharSetArrangement()
return CELL_OK; return CELL_OK;
} }
Module<> cellKey2char("cellKey2char", []() DECLARE(ppu_module_manager::cellKey2char)("cellKey2char", []()
{ {
REG_FUNC(cellKey2char, cellKey2CharOpen); REG_FUNC(cellKey2char, cellKey2CharOpen);
REG_FUNC(cellKey2char, cellKey2CharClose); REG_FUNC(cellKey2char, cellKey2CharClose);

View File

@ -1,9 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <Windows.h>
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
@ -15,7 +14,7 @@ typedef const char *HostCode;
#include "cellL10n.h" #include "cellL10n.h"
extern Module<> cellL10n; LOG_CHANNEL(cellL10n);
// Translate code id to code name. some codepage may has another name. // Translate code id to code name. some codepage may has another name.
// If this makes your compilation fail, try replace the string code with one in "iconv -l" // If this makes your compilation fail, try replace the string code with one in "iconv -l"
@ -1061,7 +1060,7 @@ s32 UTF8toBIG5()
s32 UTF16stoUTF8s(vm::cptr<u16> utf16, vm::ref<s32> utf16_len, vm::ptr<u8> utf8, vm::ref<s32> utf8_len) s32 UTF16stoUTF8s(vm::cptr<u16> utf16, vm::ref<s32> utf16_len, vm::ptr<u8> utf8, vm::ref<s32> utf8_len)
{ {
cellL10n.error("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len, utf8, utf8_len); cellL10n.error("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len.addr(), utf8, utf8_len.addr());
const u32 max_len = utf8_len; utf8_len = 0; const u32 max_len = utf8_len; utf8_len = 0;
@ -1170,7 +1169,7 @@ s32 UTF8stoUCS2s()
} }
Module<> cellL10n("cellL10n", []() DECLARE(ppu_module_manager::cellL10n)("cellL10n", []()
{ {
REG_FUNC(cellL10n, UCS2toEUCJP); REG_FUNC(cellL10n, UCS2toEUCJP);
REG_FUNC(cellL10n, l10n_convert); REG_FUNC(cellL10n, l10n_convert);

View File

@ -1,11 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellMic.h" #include "cellMic.h"
extern Module<> cellMic; LOG_CHANNEL(cellMic);
s32 cellMicInit() s32 cellMicInit()
{ {
@ -260,13 +259,12 @@ s32 cellMicGetDeviceIdentifier()
return CELL_OK; return CELL_OK;
} }
Module<> cellMic("cellMic", []() DECLARE(ppu_module_manager::cellMic)("cellMic", []()
{ {
REG_FUNC(cellMic, cellMicInit); REG_FUNC(cellMic, cellMicInit);
REG_FUNC(cellMic, cellMicEnd); REG_FUNC(cellMic, cellMicEnd);
REG_FUNC(cellMic, cellMicOpen); REG_FUNC(cellMic, cellMicOpen);
REG_FUNC(cellMic, cellMicClose); REG_FUNC(cellMic, cellMicClose);
REG_FUNC(cellMic, cellMicGetDeviceGUID); REG_FUNC(cellMic, cellMicGetDeviceGUID);
REG_FUNC(cellMic, cellMicGetType); REG_FUNC(cellMic, cellMicGetType);
REG_FUNC(cellMic, cellMicIsAttached); REG_FUNC(cellMic, cellMicIsAttached);
@ -276,16 +274,13 @@ Module<> cellMic("cellMic", []()
REG_FUNC(cellMic, cellMicGetSignalAttr); REG_FUNC(cellMic, cellMicGetSignalAttr);
REG_FUNC(cellMic, cellMicSetSignalAttr); REG_FUNC(cellMic, cellMicSetSignalAttr);
REG_FUNC(cellMic, cellMicGetSignalState); REG_FUNC(cellMic, cellMicGetSignalState);
REG_FUNC(cellMic, cellMicStart); REG_FUNC(cellMic, cellMicStart);
REG_FUNC(cellMic, cellMicRead); REG_FUNC(cellMic, cellMicRead);
REG_FUNC(cellMic, cellMicStop); REG_FUNC(cellMic, cellMicStop);
REG_FUNC(cellMic, cellMicReset); REG_FUNC(cellMic, cellMicReset);
REG_FUNC(cellMic, cellMicSetNotifyEventQueue); REG_FUNC(cellMic, cellMicSetNotifyEventQueue);
REG_FUNC(cellMic, cellMicSetNotifyEventQueue2); REG_FUNC(cellMic, cellMicSetNotifyEventQueue2);
REG_FUNC(cellMic, cellMicRemoveNotifyEventQueue); REG_FUNC(cellMic, cellMicRemoveNotifyEventQueue);
REG_FUNC(cellMic, cellMicOpenEx); REG_FUNC(cellMic, cellMicOpenEx);
REG_FUNC(cellMic, cellMicStartEx); REG_FUNC(cellMic, cellMicStartEx);
REG_FUNC(cellMic, cellMicGetFormatRaw); REG_FUNC(cellMic, cellMicGetFormatRaw);
@ -295,7 +290,6 @@ Module<> cellMic("cellMic", []()
REG_FUNC(cellMic, cellMicReadRaw); REG_FUNC(cellMic, cellMicReadRaw);
REG_FUNC(cellMic, cellMicReadAux); REG_FUNC(cellMic, cellMicReadAux);
REG_FUNC(cellMic, cellMicReadDsp); REG_FUNC(cellMic, cellMicReadDsp);
REG_FUNC(cellMic, cellMicGetStatus); REG_FUNC(cellMic, cellMicGetStatus);
REG_FUNC(cellMic, cellMicStopEx); // this function shouldn't exist REG_FUNC(cellMic, cellMicStopEx); // this function shouldn't exist
REG_FUNC(cellMic, cellMicSysShareClose); REG_FUNC(cellMic, cellMicSysShareClose);

View File

@ -1,42 +1,45 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Io/Mouse.h" #include "Emu/Io/MouseHandler.h"
#include "cellMouse.h" #include "cellMouse.h"
extern Module<> sys_io; extern _log::channel sys_io;
s32 cellMouseInit(u32 max_connect) s32 cellMouseInit(u32 max_connect)
{ {
sys_io.warning("cellMouseInit(max_connect=%d)", max_connect); sys_io.warning("cellMouseInit(max_connect=%d)", max_connect);
if (Emu.GetMouseManager().IsInited())
{
return CELL_MOUSE_ERROR_ALREADY_INITIALIZED;
}
if (max_connect > 7) if (max_connect > 7)
{ {
return CELL_MOUSE_ERROR_INVALID_PARAMETER; return CELL_MOUSE_ERROR_INVALID_PARAMETER;
} }
Emu.GetMouseManager().Init(max_connect); const auto handler = fxm::import<MouseHandlerBase>(PURE_EXPR(Emu.GetCallbacks().get_mouse_handler()));
return CELL_OK;
if (!handler)
{
return CELL_MOUSE_ERROR_ALREADY_INITIALIZED;
} }
handler->Init(max_connect);
return CELL_OK;
}
s32 cellMouseClearBuf(u32 port_no) s32 cellMouseClearBuf(u32 port_no)
{ {
sys_io.trace("cellMouseClearBuf(port_no=%d)", port_no); sys_io.trace("cellMouseClearBuf(port_no=%d)", port_no);
if (!Emu.GetMouseManager().IsInited()) const auto handler = fxm::get<MouseHandlerBase>();
if (!handler)
{ {
return CELL_MOUSE_ERROR_UNINITIALIZED; return CELL_MOUSE_ERROR_UNINITIALIZED;
} }
if (port_no >= Emu.GetMouseManager().GetMice().size()) if (port_no >= handler->GetMice().size())
{ {
return CELL_MOUSE_ERROR_INVALID_PARAMETER; return CELL_MOUSE_ERROR_INVALID_PARAMETER;
} }
@ -48,14 +51,13 @@ s32 cellMouseClearBuf(u32 port_no)
s32 cellMouseEnd() s32 cellMouseEnd()
{ {
sys_io.trace("cellMouseEnd()"); sys_io.notice("cellMouseEnd()");
if (!Emu.GetMouseManager().IsInited()) if (!fxm::remove<MouseHandlerBase>())
{ {
return CELL_MOUSE_ERROR_UNINITIALIZED; return CELL_MOUSE_ERROR_UNINITIALIZED;
} }
Emu.GetMouseManager().Close();
return CELL_OK; return CELL_OK;
} }
@ -63,12 +65,14 @@ s32 cellMouseGetInfo(vm::ptr<CellMouseInfo> info)
{ {
sys_io.trace("cellMouseGetInfo(info=*0x%x)", info); sys_io.trace("cellMouseGetInfo(info=*0x%x)", info);
if (!Emu.GetMouseManager().IsInited()) const auto handler = fxm::get<MouseHandlerBase>();
if (!handler)
{ {
return CELL_MOUSE_ERROR_UNINITIALIZED; return CELL_MOUSE_ERROR_UNINITIALIZED;
} }
const MouseInfo& current_info = Emu.GetMouseManager().GetInfo(); const MouseInfo& current_info = handler->GetInfo();
info->max_connect = current_info.max_connect; info->max_connect = current_info.max_connect;
info->now_connect = current_info.now_connect; info->now_connect = current_info.now_connect;
info->info = current_info.info; info->info = current_info.info;
@ -82,12 +86,15 @@ s32 cellMouseGetInfo(vm::ptr<CellMouseInfo> info)
s32 cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> info) s32 cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> info)
{ {
sys_io.trace("cellMouseInfoTabletMode(port_no=%d, info=*0x%x)", port_no, info); sys_io.trace("cellMouseInfoTabletMode(port_no=%d, info=*0x%x)", port_no, info);
if (!Emu.GetMouseManager().IsInited())
const auto handler = fxm::get<MouseHandlerBase>();
if (!handler)
{ {
return CELL_MOUSE_ERROR_UNINITIALIZED; return CELL_MOUSE_ERROR_UNINITIALIZED;
} }
if (port_no >= Emu.GetMouseManager().GetMice().size()) if (port_no >= handler->GetMice().size())
{ {
return CELL_MOUSE_ERROR_INVALID_PARAMETER; return CELL_MOUSE_ERROR_INVALID_PARAMETER;
} }
@ -101,16 +108,20 @@ s32 cellMouseInfoTabletMode(u32 port_no, vm::ptr<CellMouseInfoTablet> info)
s32 cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data) s32 cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)
{ {
sys_io.trace("cellMouseGetData(port_no=%d, data=*0x%x)", port_no, data); sys_io.trace("cellMouseGetData(port_no=%d, data=*0x%x)", port_no, data);
if (!Emu.GetMouseManager().IsInited())
const auto handler = fxm::get<MouseHandlerBase>();
if (!handler)
{ {
return CELL_MOUSE_ERROR_UNINITIALIZED; return CELL_MOUSE_ERROR_UNINITIALIZED;
} }
if (port_no >= Emu.GetMouseManager().GetMice().size())
if (port_no >= handler->GetMice().size())
{ {
return CELL_MOUSE_ERROR_NO_DEVICE; return CELL_MOUSE_ERROR_NO_DEVICE;
} }
MouseData& current_data = Emu.GetMouseManager().GetData(port_no); MouseData& current_data = handler->GetData(port_no);
data->update = current_data.update; data->update = current_data.update;
data->buttons = current_data.buttons; data->buttons = current_data.buttons;
data->x_axis = current_data.x_axis; data->x_axis = current_data.x_axis;
@ -147,20 +158,21 @@ s32 cellMouseGetTabletDataList(u32 port_no, u32 data_addr)
return CELL_OK; return CELL_OK;
} }
s32 cellMouseGetRawData(u32 port_no, vm::ptr<struct CellMouseRawData> data) s32 cellMouseGetRawData(u32 port_no, vm::ptr<CellMouseRawData> data)
{ {
sys_io.todo("cellMouseGetRawData(port_no=%d, data=*0x%x)", port_no, data); sys_io.todo("cellMouseGetRawData(port_no=%d, data=*0x%x)", port_no, data);
/*if (!Emu.GetMouseManager().IsInited()) return CELL_MOUSE_ERROR_UNINITIALIZED;
if (port_no >= Emu.GetMouseManager().GetMice().size()) return CELL_MOUSE_ERROR_NO_DEVICE;
CellMouseRawData& current_rawdata = Emu.GetMouseManager().GetRawData(port_no); const auto handler = fxm::get<MouseHandlerBase>();
data += current_rawdata.len;
for(s32 i=0; i<current_rawdata.len; i++) if (!handler)
{ {
data += current_rawdata.data[i]; return CELL_MOUSE_ERROR_UNINITIALIZED;
} }
current_rawdata.len = 0;*/ if (port_no >= handler->GetMice().size())
{
return CELL_MOUSE_ERROR_NO_DEVICE;
}
return CELL_OK; return CELL_OK;
} }

View File

@ -51,3 +51,9 @@ struct CellMouseDataList
}; };
static const u32 CELL_MOUSE_MAX_CODES = 64; static const u32 CELL_MOUSE_MAX_CODES = 64;
struct CellMouseRawData
{
be_t<s32> len;
u8 data[CELL_MOUSE_MAX_CODES];
};

View File

@ -1,14 +1,14 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Callback.h"
#include "cellSysutil.h" #include "cellSysutil.h"
#include "cellMsgDialog.h" #include "cellMsgDialog.h"
extern Module<> cellSysutil; #include <future>
extern _log::channel cellSysutil;
s32 cellMsgDialogOpen() s32 cellMsgDialogOpen()
{ {
@ -61,7 +61,7 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
default: return CELL_MSGDIALOG_ERROR_PARAM; default: return CELL_MSGDIALOG_ERROR_PARAM;
} }
const auto dlg = fxm::import<MsgDialogBase>(WRAP_EXPR(Emu.GetCallbacks().get_msg_dialog())); const auto dlg = fxm::import<MsgDialogBase>(PURE_EXPR(Emu.GetCallbacks().get_msg_dialog()));
if (!dlg) if (!dlg)
{ {
@ -103,8 +103,21 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
} }
}; };
// call initialization asynchronously from the GUI thread, wait for the "result" // Make "shared" promise to workaround std::function limitation
Emu.CallAfter(WRAP_EXPR(dlg->Create(msgString.get_ptr()))).get(); auto spr = std::make_shared<std::promise<void>>();
// Get future
std::future<void> future = spr->get_future();
// Run asynchronously in GUI thread
Emu.CallAfter([&, spr = std::move(spr)]()
{
dlg->Create(msgString.get_ptr());
spr->set_value();
});
// Wait for the "result"
future.get();
return CELL_OK; return CELL_OK;
} }
@ -206,7 +219,7 @@ s32 cellMsgDialogClose(f32 delay)
const u64 wait_until = get_system_time() + static_cast<s64>(std::max<float>(delay, 0.0f) * 1000); const u64 wait_until = get_system_time() + static_cast<s64>(std::max<float>(delay, 0.0f) * 1000);
thread_ctrl::spawn(PURE_EXPR("MsgDialog Thread"s), [=]() thread_ctrl::spawn("MsgDialog Thread", [=]()
{ {
while (dlg->state == MsgDialogState::Open && get_system_time() < wait_until) while (dlg->state == MsgDialogState::Open && get_system_time() < wait_until)
{ {

View File

@ -1,13 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Callback.h"
#include "Emu/SysCalls/Modules.h"
#include "cellMusic.h" #include "cellMusic.h"
extern Module<> cellMusic; LOG_CHANNEL(cellMusic);
struct music2_t struct music2_t
{ {
@ -144,28 +142,28 @@ s32 cellMusicGetVolume2()
} }
Module<> cellMusic("cellMusic", []() DECLARE(ppu_module_manager::cellMusic)("cellMusicUtility", []()
{ {
REG_FUNC(cellMusic, cellMusicGetSelectionContext); REG_FUNC(cellMusicUtility, cellMusicGetSelectionContext);
REG_FUNC(cellMusic, cellMusicSetSelectionContext2); REG_FUNC(cellMusicUtility, cellMusicSetSelectionContext2);
REG_FUNC(cellMusic, cellMusicSetVolume2); REG_FUNC(cellMusicUtility, cellMusicSetVolume2);
REG_FUNC(cellMusic, cellMusicGetContentsId); REG_FUNC(cellMusicUtility, cellMusicGetContentsId);
REG_FUNC(cellMusic, cellMusicSetSelectionContext); REG_FUNC(cellMusicUtility, cellMusicSetSelectionContext);
REG_FUNC(cellMusic, cellMusicInitialize2SystemWorkload); REG_FUNC(cellMusicUtility, cellMusicInitialize2SystemWorkload);
REG_FUNC(cellMusic, cellMusicGetPlaybackStatus2); REG_FUNC(cellMusicUtility, cellMusicGetPlaybackStatus2);
REG_FUNC(cellMusic, cellMusicGetContentsId2); REG_FUNC(cellMusicUtility, cellMusicGetContentsId2);
REG_FUNC(cellMusic, cellMusicFinalize); REG_FUNC(cellMusicUtility, cellMusicFinalize);
REG_FUNC(cellMusic, cellMusicInitializeSystemWorkload); REG_FUNC(cellMusicUtility, cellMusicInitializeSystemWorkload);
REG_FUNC(cellMusic, cellMusicInitialize); REG_FUNC(cellMusicUtility, cellMusicInitialize);
REG_FUNC(cellMusic, cellMusicFinalize2); REG_FUNC(cellMusicUtility, cellMusicFinalize2);
REG_FUNC(cellMusic, cellMusicGetSelectionContext2); REG_FUNC(cellMusicUtility, cellMusicGetSelectionContext2);
REG_FUNC(cellMusic, cellMusicGetVolume); REG_FUNC(cellMusicUtility, cellMusicGetVolume);
REG_FUNC(cellMusic, cellMusicGetPlaybackStatus); REG_FUNC(cellMusicUtility, cellMusicGetPlaybackStatus);
REG_FUNC(cellMusic, cellMusicSetPlaybackCommand2); REG_FUNC(cellMusicUtility, cellMusicSetPlaybackCommand2);
REG_FUNC(cellMusic, cellMusicSetPlaybackCommand); REG_FUNC(cellMusicUtility, cellMusicSetPlaybackCommand);
REG_FUNC(cellMusic, cellMusicSelectContents2); REG_FUNC(cellMusicUtility, cellMusicSelectContents2);
REG_FUNC(cellMusic, cellMusicSelectContents); REG_FUNC(cellMusicUtility, cellMusicSelectContents);
REG_FUNC(cellMusic, cellMusicInitialize2); REG_FUNC(cellMusicUtility, cellMusicInitialize2);
REG_FUNC(cellMusic, cellMusicSetVolume); REG_FUNC(cellMusicUtility, cellMusicSetVolume);
REG_FUNC(cellMusic, cellMusicGetVolume2); REG_FUNC(cellMusicUtility, cellMusicGetVolume2);
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellMusicDecode; LOG_CHANNEL(cellMusicDecode);
// Return Codes // Return Codes
enum enum
@ -145,27 +144,27 @@ s32 cellMusicDecodeGetContentsId2()
} }
Module<> cellMusicDecode("cellMusicDecode", []() DECLARE(ppu_module_manager::cellMusicDecode)("cellMusicDecodeUtility", []()
{ {
REG_FUNC(cellMusicDecode, cellMusicDecodeInitialize); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeInitialize);
REG_FUNC(cellMusicDecode, cellMusicDecodeInitializeSystemWorkload); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeInitializeSystemWorkload);
REG_FUNC(cellMusicDecode, cellMusicDecodeFinalize); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeFinalize);
REG_FUNC(cellMusicDecode, cellMusicDecodeSelectContents); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeSelectContents);
REG_FUNC(cellMusicDecode, cellMusicDecodeSetDecodeCommand); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeSetDecodeCommand);
REG_FUNC(cellMusicDecode, cellMusicDecodeGetDecodeStatus); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeGetDecodeStatus);
REG_FUNC(cellMusicDecode, cellMusicDecodeRead); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeRead);
REG_FUNC(cellMusicDecode, cellMusicDecodeGetSelectionContext); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeGetSelectionContext);
REG_FUNC(cellMusicDecode, cellMusicDecodeSetSelectionContext); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeSetSelectionContext);
REG_FUNC(cellMusicDecode, cellMusicDecodeGetContentsId); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeGetContentsId);
REG_FUNC(cellMusicDecode, cellMusicDecodeInitialize2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeInitialize2);
REG_FUNC(cellMusicDecode, cellMusicDecodeInitialize2SystemWorkload); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeInitialize2SystemWorkload);
REG_FUNC(cellMusicDecode, cellMusicDecodeFinalize2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeFinalize2);
REG_FUNC(cellMusicDecode, cellMusicDecodeSelectContents2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeSelectContents2);
REG_FUNC(cellMusicDecode, cellMusicDecodeSetDecodeCommand2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeSetDecodeCommand2);
REG_FUNC(cellMusicDecode, cellMusicDecodeGetDecodeStatus2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeGetDecodeStatus2);
REG_FUNC(cellMusicDecode, cellMusicDecodeRead2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeRead2);
REG_FUNC(cellMusicDecode, cellMusicDecodeGetSelectionContext2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeGetSelectionContext2);
REG_FUNC(cellMusicDecode, cellMusicDecodeSetSelectionContext2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeSetSelectionContext2);
REG_FUNC(cellMusicDecode, cellMusicDecodeGetContentsId2); REG_FUNC(cellMusicDecodeUtility, cellMusicDecodeGetContentsId2);
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellMusicExport; LOG_CHANNEL(cellMusicExport);
// Return Codes // Return Codes
enum enum
@ -51,11 +50,11 @@ s32 cellMusicExportProgress()
return CELL_OK; return CELL_OK;
} }
Module<> cellMusicExport("cellMusicExport", []() DECLARE(ppu_module_manager::cellMusicExport)("cellMusicExportUtility", []()
{ {
REG_FUNC(cellMusicExport, cellMusicExportInitialize); REG_FUNC(cellMusicExportUtility, cellMusicExportInitialize);
REG_FUNC(cellMusicExport, cellMusicExportInitialize2); REG_FUNC(cellMusicExportUtility, cellMusicExportInitialize2);
REG_FUNC(cellMusicExport, cellMusicExportFinalize); REG_FUNC(cellMusicExportUtility, cellMusicExportFinalize);
REG_FUNC(cellMusicExport, cellMusicExportFromFile); REG_FUNC(cellMusicExportUtility, cellMusicExportFromFile);
REG_FUNC(cellMusicExport, cellMusicExportProgress); REG_FUNC(cellMusicExportUtility, cellMusicExportProgress);
}); });

View File

@ -0,0 +1,211 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUModule.h"
#include "cellSysutil.h"
#include "cellNetCtl.h"
LOG_CHANNEL(cellNetCtl);
cfg::map_entry<s32> g_cfg_net_status(cfg::root.net, "Connection status",
{
{ "Disconnected", CELL_NET_CTL_STATE_Disconnected },
{ "Connecting", CELL_NET_CTL_STATE_Connecting },
{ "Obtaining IP", CELL_NET_CTL_STATE_IPObtaining },
{ "IP Obtained", CELL_NET_CTL_STATE_IPObtained },
});
cfg::string_entry g_cfg_net_ip_address(cfg::root.net, "IP address", "192.168.1.1");
s32 cellNetCtlInit()
{
cellNetCtl.warning("cellNetCtlInit()");
return CELL_OK;
}
s32 cellNetCtlTerm()
{
cellNetCtl.warning("cellNetCtlTerm()");
return CELL_OK;
}
s32 cellNetCtlGetState(vm::ptr<u32> state)
{
cellNetCtl.trace("cellNetCtlGetState(state=*0x%x)", state);
*state = g_cfg_net_status.get();
return CELL_OK;
}
s32 cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler, vm::ptr<void> arg, vm::ptr<s32> hid)
{
cellNetCtl.todo("cellNetCtlAddHandler(handler=*0x%x, arg=*0x%x, hid=*0x%x)", handler, arg, hid);
return CELL_OK;
}
s32 cellNetCtlDelHandler(s32 hid)
{
cellNetCtl.todo("cellNetCtlDelHandler(hid=0x%x)", hid);
return CELL_OK;
}
s32 cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
{
cellNetCtl.todo("cellNetCtlGetInfo(code=0x%x (%s), info=*0x%x)", code, InfoCodeToName(code), info);
if (code == CELL_NET_CTL_INFO_MTU)
{
info->mtu = 1500;
}
else if (code == CELL_NET_CTL_INFO_LINK)
{
if (g_cfg_net_status.get() != CELL_NET_CTL_STATE_Disconnected)
{
info->link = CELL_NET_CTL_LINK_CONNECTED;
}
else
{
info->link = CELL_NET_CTL_LINK_DISCONNECTED;
}
}
else if (code == CELL_NET_CTL_INFO_IP_ADDRESS)
{
if (g_cfg_net_status.get() != CELL_NET_CTL_STATE_IPObtained)
{
// 0.0.0.0 seems to be the default address when no ethernet cables are connected to the PS3
strcpy_trunc(info->ip_address, "0.0.0.0");
}
else
{
strcpy_trunc(info->ip_address, g_cfg_net_ip_address);
}
}
else if (code == CELL_NET_CTL_INFO_NETMASK)
{
strcpy_trunc(info->netmask, "255.255.255.255");
}
return CELL_OK;
}
s32 cellNetCtlNetStartDialogLoadAsync(vm::ptr<CellNetCtlNetStartDialogParam> param)
{
cellNetCtl.error("cellNetCtlNetStartDialogLoadAsync(param=*0x%x)", param);
// TODO: Actually sign into PSN or an emulated network similar to PSN (ESN)
// TODO: Properly open the dialog prompt for sign in
sysutilSendSystemCommand(CELL_SYSUTIL_NET_CTL_NETSTART_LOADED, 0);
sysutilSendSystemCommand(CELL_SYSUTIL_NET_CTL_NETSTART_FINISHED, 0);
return CELL_OK;
}
s32 cellNetCtlNetStartDialogAbortAsync()
{
cellNetCtl.error("cellNetCtlNetStartDialogAbortAsync()");
return CELL_OK;
}
s32 cellNetCtlNetStartDialogUnloadAsync(vm::ptr<CellNetCtlNetStartDialogResult> result)
{
cellNetCtl.warning("cellNetCtlNetStartDialogUnloadAsync(result=*0x%x)", result);
result->result = CELL_NET_CTL_ERROR_DIALOG_CANCELED;
sysutilSendSystemCommand(CELL_SYSUTIL_NET_CTL_NETSTART_UNLOADED, 0);
return CELL_OK;
}
s32 cellNetCtlGetNatInfo(vm::ptr<CellNetCtlNatInfo> natInfo)
{
cellNetCtl.todo("cellNetCtlGetNatInfo(natInfo=*0x%x)", natInfo);
if (natInfo->size == 0)
{
cellNetCtl.error("cellNetCtlGetNatInfo : CELL_NET_CTL_ERROR_INVALID_SIZE");
return CELL_NET_CTL_ERROR_INVALID_SIZE;
}
return CELL_OK;
}
s32 cellGameUpdateInit()
{
throw EXCEPTION("");
}
s32 cellGameUpdateTerm()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckStartAsync()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckFinishAsync()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckStartWithoutDialogAsync()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckAbort()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckStartAsyncEx()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckFinishAsyncEx()
{
throw EXCEPTION("");
}
s32 cellGameUpdateCheckStartWithoutDialogAsyncEx()
{
throw EXCEPTION("");
}
DECLARE(ppu_module_manager::cellNetCtl)("cellNetCtl", []()
{
REG_FUNC(cellNetCtl, cellNetCtlInit);
REG_FUNC(cellNetCtl, cellNetCtlTerm);
REG_FUNC(cellNetCtl, cellNetCtlGetState);
REG_FUNC(cellNetCtl, cellNetCtlAddHandler);
REG_FUNC(cellNetCtl, cellNetCtlDelHandler);
REG_FUNC(cellNetCtl, cellNetCtlGetInfo);
REG_FUNC(cellNetCtl, cellNetCtlNetStartDialogLoadAsync);
REG_FUNC(cellNetCtl, cellNetCtlNetStartDialogAbortAsync);
REG_FUNC(cellNetCtl, cellNetCtlNetStartDialogUnloadAsync);
REG_FUNC(cellNetCtl, cellNetCtlGetNatInfo);
REG_FUNC(cellNetCtl, cellGameUpdateInit);
REG_FUNC(cellNetCtl, cellGameUpdateTerm);
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartAsync);
REG_FUNC(cellNetCtl, cellGameUpdateCheckFinishAsync);
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartWithoutDialogAsync);
REG_FUNC(cellNetCtl, cellGameUpdateCheckAbort);
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartAsyncEx);
REG_FUNC(cellNetCtl, cellGameUpdateCheckFinishAsyncEx);
REG_FUNC(cellNetCtl, cellGameUpdateCheckStartWithoutDialogAsyncEx);
});

View File

@ -220,19 +220,19 @@ union CellNetCtlInfo
CellNetCtlSSID ssid; CellNetCtlSSID ssid;
be_t<u32> wlan_security; be_t<u32> wlan_security;
be_t<u32> auth_8021x_type; be_t<u32> auth_8021x_type;
s8 auth_8021x_auth_name[128]; char auth_8021x_auth_name[128];
u8 rssi; u8 rssi;
u8 channel; u8 channel;
be_t<u32> ip_config; be_t<u32> ip_config;
s8 dhcp_hostname[256]; char dhcp_hostname[256];
s8 pppoe_auth_name[128]; char pppoe_auth_name[128];
char ip_address[16]; char ip_address[16];
s8 netmask[16]; char netmask[16];
s8 default_route[16]; char default_route[16];
s8 primary_dns[16]; char primary_dns[16];
s8 secondary_dns[16]; char secondary_dns[16];
be_t<u32> http_proxy_config; be_t<u32> http_proxy_config;
s8 http_proxy_server[256]; char http_proxy_server[256];
be_t<u16> http_proxy_port; be_t<u16> http_proxy_port;
be_t<u32> upnp_config; be_t<u32> upnp_config;
}; };

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellOskDialog; LOG_CHANNEL(cellOskDialog);
s32 cellOskDialogLoadAsync() s32 cellOskDialogLoadAsync()
{ {
@ -153,9 +152,6 @@ s32 cellOskDialogExtRegisterForceFinishCallback()
void cellSysutil_OskDialog_init() void cellSysutil_OskDialog_init()
{ {
extern Module<> cellSysutil;
// cellOskDialog functions:
REG_FUNC(cellSysutil, cellOskDialogLoadAsync); REG_FUNC(cellSysutil, cellOskDialogLoadAsync);
REG_FUNC(cellSysutil, cellOskDialogUnloadAsync); REG_FUNC(cellSysutil, cellOskDialogUnloadAsync);
REG_FUNC(cellSysutil, cellOskDialogGetSize); REG_FUNC(cellSysutil, cellOskDialogGetSize);
@ -171,23 +167,22 @@ void cellSysutil_OskDialog_init()
REG_FUNC(cellSysutil, cellOskDialogGetInputText); REG_FUNC(cellSysutil, cellOskDialogGetInputText);
} }
Module<> cellOskDialog("cellOskDialog", []() DECLARE(ppu_module_manager::cellOskDialog)("cellOskExtUtility", []()
{ {
// cellOskDialogExt functions: REG_FUNC(cellOskExtUtility, cellOskDialogExtInputDeviceUnlock);
REG_FUNC(cellOskDialog, cellOskDialogExtInputDeviceUnlock); REG_FUNC(cellOskExtUtility, cellOskDialogExtRegisterKeyboardEventHookCallback);
REG_FUNC(cellOskDialog, cellOskDialogExtRegisterKeyboardEventHookCallback); REG_FUNC(cellOskExtUtility, cellOskDialogExtAddJapaneseOptionDictionary);
REG_FUNC(cellOskDialog, cellOskDialogExtAddJapaneseOptionDictionary); REG_FUNC(cellOskExtUtility, cellOskDialogExtEnableClipboard);
REG_FUNC(cellOskDialog, cellOskDialogExtEnableClipboard); REG_FUNC(cellOskExtUtility, cellOskDialogExtSendFinishMessage);
REG_FUNC(cellOskDialog, cellOskDialogExtSendFinishMessage); REG_FUNC(cellOskExtUtility, cellOskDialogExtAddOptionDictionary);
REG_FUNC(cellOskDialog, cellOskDialogExtAddOptionDictionary); REG_FUNC(cellOskExtUtility, cellOskDialogExtSetInitialScale);
REG_FUNC(cellOskDialog, cellOskDialogExtSetInitialScale); REG_FUNC(cellOskExtUtility, cellOskDialogExtInputDeviceLock);
REG_FUNC(cellOskDialog, cellOskDialogExtInputDeviceLock); REG_FUNC(cellOskExtUtility, cellOskDialogExtSetBaseColor);
REG_FUNC(cellOskDialog, cellOskDialogExtSetBaseColor); REG_FUNC(cellOskExtUtility, cellOskDialogExtRegisterConfirmWordFilterCallback);
REG_FUNC(cellOskDialog, cellOskDialogExtRegisterConfirmWordFilterCallback); REG_FUNC(cellOskExtUtility, cellOskDialogExtUpdateInputText);
REG_FUNC(cellOskDialog, cellOskDialogExtUpdateInputText); REG_FUNC(cellOskExtUtility, cellOskDialogExtDisableHalfByteKana);
REG_FUNC(cellOskDialog, cellOskDialogExtDisableHalfByteKana); REG_FUNC(cellOskExtUtility, cellOskDialogExtSetPointerEnable);
REG_FUNC(cellOskDialog, cellOskDialogExtSetPointerEnable); REG_FUNC(cellOskExtUtility, cellOskDialogExtUpdatePointerDisplayPos);
REG_FUNC(cellOskDialog, cellOskDialogExtUpdatePointerDisplayPos); REG_FUNC(cellOskExtUtility, cellOskDialogExtEnableHalfByteKana);
REG_FUNC(cellOskDialog, cellOskDialogExtEnableHalfByteKana); REG_FUNC(cellOskExtUtility, cellOskDialogExtRegisterForceFinishCallback);
REG_FUNC(cellOskDialog, cellOskDialogExtRegisterForceFinishCallback);
}); });

View File

@ -1,10 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
namespace vm { using namespace ps3; } LOG_CHANNEL(cellOvis);
extern Module<> cellOvis;
// Return Codes // Return Codes
enum enum
@ -38,7 +35,7 @@ s32 cellOvisInvalidateOverlappedSegments()
return CELL_OK; return CELL_OK;
} }
Module<> cellOvis("cellOvis", []() DECLARE(ppu_module_manager::cellOvis)("cellOvis", []()
{ {
REG_FUNC(cellOvis, cellOvisGetOverlayTableSize); REG_FUNC(cellOvis, cellOvisGetOverlayTableSize);
REG_FUNC(cellOvis, cellOvisInitializeOverlayTable); REG_FUNC(cellOvis, cellOvisInitializeOverlayTable);

View File

@ -1,37 +1,37 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Io/Pad.h" #include "Emu/Io/PadHandler.h"
#include "cellPad.h" #include "cellPad.h"
extern Module<> sys_io; extern _log::channel sys_io;
s32 cellPadInit(u32 max_connect) s32 cellPadInit(u32 max_connect)
{ {
sys_io.warning("cellPadInit(max_connect=%d)", max_connect); sys_io.warning("cellPadInit(max_connect=%d)", max_connect);
if (Emu.GetPadManager().IsInited())
return CELL_PAD_ERROR_ALREADY_INITIALIZED;
if (max_connect > CELL_PAD_MAX_PORT_NUM) if (max_connect > CELL_PAD_MAX_PORT_NUM)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
Emu.GetPadManager().Init(max_connect); const auto handler = fxm::import<PadHandlerBase>(PURE_EXPR(Emu.GetCallbacks().get_pad_handler()));
if (!handler)
return CELL_PAD_ERROR_ALREADY_INITIALIZED;
handler->Init(max_connect);
return CELL_OK; return CELL_OK;
} }
s32 cellPadEnd() s32 cellPadEnd()
{ {
sys_io.trace("cellPadEnd()"); sys_io.notice("cellPadEnd()");
if (!Emu.GetPadManager().IsInited()) if (!fxm::remove<PadHandlerBase>())
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
Emu.GetPadManager().Close();
return CELL_OK; return CELL_OK;
} }
@ -39,10 +39,12 @@ s32 cellPadClearBuf(u32 port_no)
{ {
sys_io.trace("cellPadClearBuf(port_no=%d)", port_no); sys_io.trace("cellPadClearBuf(port_no=%d)", port_no);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
@ -52,7 +54,7 @@ s32 cellPadClearBuf(u32 port_no)
//Set 'm_buffer_cleared' to force a resend of everything //Set 'm_buffer_cleared' to force a resend of everything
//might as well also reset everything in our pad 'buffer' to nothing as well //might as well also reset everything in our pad 'buffer' to nothing as well
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
Pad& pad = pads[port_no]; Pad& pad = pads[port_no];
pad.m_buffer_cleared = true; pad.m_buffer_cleared = true;
@ -74,18 +76,18 @@ s32 cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
{ {
sys_io.todo("cellPadPeriphGetInfo(info=*0x%x)", info); sys_io.todo("cellPadPeriphGetInfo(info=*0x%x)", info);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
{
return CELL_PAD_ERROR_UNINITIALIZED;
}
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = handler->GetInfo();
info->max_connect = rinfo.max_connect; info->max_connect = rinfo.max_connect;
info->now_connect = rinfo.now_connect; info->now_connect = rinfo.now_connect;
info->system_info = rinfo.system_info; info->system_info = rinfo.system_info;
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
// TODO: Support other types of controllers // TODO: Support other types of controllers
for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i) for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i)
@ -113,12 +115,14 @@ s32 cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
{ {
sys_io.trace("cellPadGetData(port_no=%d, data=*0x%x)", port_no, data); sys_io.trace("cellPadGetData(port_no=%d, data=*0x%x)", port_no, data);
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); const auto handler = fxm::get<PadHandlerBase>();
if (!Emu.GetPadManager().IsInited()) if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); std::vector<Pad>& pads = handler->GetPads();
const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
@ -297,10 +301,12 @@ s32 cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadDa
{ {
sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, device_type=*0x%x)", port_no, device_type, data); sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, device_type=*0x%x)", port_no, device_type, data);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
@ -314,10 +320,12 @@ s32 cellPadSetActDirect(u32 port_no, vm::ptr<struct CellPadActParam> param)
{ {
sys_io.trace("cellPadSetActDirect(port_no=%d, param=*0x%x)", port_no, param); sys_io.trace("cellPadSetActDirect(port_no=%d, param=*0x%x)", port_no, param);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
@ -331,16 +339,18 @@ s32 cellPadGetInfo(vm::ptr<CellPadInfo> info)
{ {
sys_io.trace("cellPadGetInfo(info=*0x%x)", info); sys_io.trace("cellPadGetInfo(info=*0x%x)", info);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
info->max_connect = rinfo.max_connect; info->max_connect = rinfo.max_connect;
info->now_connect = rinfo.now_connect; info->now_connect = rinfo.now_connect;
info->system_info = rinfo.system_info; info->system_info = rinfo.system_info;
//Can't have this as const, we need to reset Assign Changes Flag here //Can't have this as const, we need to reset Assign Changes Flag here
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
for (u32 i=0; i<CELL_MAX_PADS; ++i) for (u32 i=0; i<CELL_MAX_PADS; ++i)
{ {
@ -360,15 +370,17 @@ s32 cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
{ {
sys_io.trace("cellPadGetInfo2(info=*0x%x)", info); sys_io.trace("cellPadGetInfo2(info=*0x%x)", info);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
info->max_connect = rinfo.max_connect; info->max_connect = rinfo.max_connect;
info->now_connect = rinfo.now_connect; info->now_connect = rinfo.now_connect;
info->system_info = rinfo.system_info; info->system_info = rinfo.system_info;
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
for (u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i) for (u32 i=0; i<CELL_PAD_MAX_PORT_NUM; ++i)
{ {
@ -389,17 +401,19 @@ s32 cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellCapabilityInfo> info)
{ {
sys_io.trace("cellPadGetCapabilityInfo(port_no=%d, data_addr:=0x%x)", port_no, info.addr()); sys_io.trace("cellPadGetCapabilityInfo(port_no=%d, data_addr:=0x%x)", port_no, info.addr());
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
if (port_no >= rinfo.now_connect) if (port_no >= rinfo.now_connect)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); const std::vector<Pad>& pads = handler->GetPads();
//Should return the same as device capability mask, psl1ght has it backwards in pad.h //Should return the same as device capability mask, psl1ght has it backwards in pad.h
info->info[0] = pads[port_no].m_device_capability; info->info[0] = pads[port_no].m_device_capability;
@ -411,17 +425,19 @@ s32 cellPadSetPortSetting(u32 port_no, u32 port_setting)
{ {
sys_io.trace("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting); sys_io.trace("cellPadSetPortSetting(port_no=%d, port_setting=0x%x)", port_no, port_setting);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
if (port_no >= rinfo.now_connect) if (port_no >= rinfo.now_connect)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
pads[port_no].m_port_setting = port_setting; pads[port_no].m_port_setting = port_setting;
return CELL_OK; return CELL_OK;
@ -431,17 +447,19 @@ s32 cellPadInfoPressMode(u32 port_no)
{ {
sys_io.trace("cellPadInfoPressMode(port_no=%d)", port_no); sys_io.trace("cellPadInfoPressMode(port_no=%d)", port_no);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
if (port_no >= rinfo.now_connect) if (port_no >= rinfo.now_connect)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); const std::vector<Pad>& pads = handler->GetPads();
return (pads[port_no].m_device_capability & CELL_PAD_CAPABILITY_PRESS_MODE) > 0; return (pads[port_no].m_device_capability & CELL_PAD_CAPABILITY_PRESS_MODE) > 0;
} }
@ -450,17 +468,19 @@ s32 cellPadInfoSensorMode(u32 port_no)
{ {
sys_io.trace("cellPadInfoSensorMode(port_no=%d)", port_no); sys_io.trace("cellPadInfoSensorMode(port_no=%d)", port_no);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
if (port_no >= rinfo.now_connect) if (port_no >= rinfo.now_connect)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); const std::vector<Pad>& pads = handler->GetPads();
return (pads[port_no].m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE) > 0; return (pads[port_no].m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE) > 0;
} }
@ -469,19 +489,22 @@ s32 cellPadSetPressMode(u32 port_no, u32 mode)
{ {
sys_io.trace("cellPadSetPressMode(port_no=%d, mode=%d)", port_no, mode); sys_io.trace("cellPadSetPressMode(port_no=%d, mode=%d)", port_no, mode);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
if (mode != 0 && mode != 1) if (mode != 0 && mode != 1)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
if (port_no >= rinfo.now_connect) if (port_no >= rinfo.now_connect)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
if (mode) if (mode)
pads[port_no].m_port_setting |= CELL_PAD_SETTING_PRESS_ON; pads[port_no].m_port_setting |= CELL_PAD_SETTING_PRESS_ON;
@ -495,19 +518,22 @@ s32 cellPadSetSensorMode(u32 port_no, u32 mode)
{ {
sys_io.trace("cellPadSetSensorMode(port_no=%d, mode=%d)", port_no, mode); sys_io.trace("cellPadSetSensorMode(port_no=%d, mode=%d)", port_no, mode);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
if (mode != 0 && mode != 1) if (mode != 0 && mode != 1)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); const PadInfo& rinfo = handler->GetInfo();
if (port_no >= rinfo.max_connect) if (port_no >= rinfo.max_connect)
return CELL_PAD_ERROR_INVALID_PARAMETER; return CELL_PAD_ERROR_INVALID_PARAMETER;
if (port_no >= rinfo.now_connect) if (port_no >= rinfo.now_connect)
return CELL_PAD_ERROR_NO_DEVICE; return CELL_PAD_ERROR_NO_DEVICE;
std::vector<Pad>& pads = Emu.GetPadManager().GetPads(); std::vector<Pad>& pads = handler->GetPads();
if (mode) if (mode)
pads[port_no].m_port_setting |= CELL_PAD_SETTING_SENSOR_ON; pads[port_no].m_port_setting |= CELL_PAD_SETTING_SENSOR_ON;
@ -521,7 +547,9 @@ s32 cellPadLddRegisterController()
{ {
sys_io.todo("cellPadLddRegisterController()"); sys_io.todo("cellPadLddRegisterController()");
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
return CELL_OK; return CELL_OK;
@ -531,7 +559,9 @@ s32 cellPadLddDataInsert(s32 handle, vm::ptr<CellPadData> data)
{ {
sys_io.todo("cellPadLddDataInsert(handle=%d, data=*0x%x)", handle, data); sys_io.todo("cellPadLddDataInsert(handle=%d, data=*0x%x)", handle, data);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
return CELL_OK; return CELL_OK;
@ -541,7 +571,9 @@ s32 cellPadLddGetPortNo(s32 handle)
{ {
sys_io.todo("cellPadLddGetPortNo(handle=%d)", handle); sys_io.todo("cellPadLddGetPortNo(handle=%d)", handle);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
return CELL_OK; return CELL_OK;
@ -551,7 +583,9 @@ s32 cellPadLddUnregisterController(s32 handle)
{ {
sys_io.todo("cellPadLddUnregisterController(handle=%d)", handle); sys_io.todo("cellPadLddUnregisterController(handle=%d)", handle);
if (!Emu.GetPadManager().IsInited()) const auto handler = fxm::get<PadHandlerBase>();
if (!handler)
return CELL_PAD_ERROR_UNINITIALIZED; return CELL_PAD_ERROR_UNINITIALIZED;
return CELL_OK; return CELL_OK;

View File

@ -1,16 +1,23 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellPamf.h" #include "cellPamf.h"
extern Module<> cellPamf; const std::function<bool()> SQUEUE_ALWAYS_EXIT = []() { return true; };
const std::function<bool()> SQUEUE_NEVER_EXIT = []() { return false; };
bool squeue_test_exit()
{
return Emu.IsStopped();
}
LOG_CHANNEL(cellPamf);
s32 pamfStreamTypeToEsFilterId(u8 type, u8 ch, CellCodecEsFilterId& pEsFilterId) s32 pamfStreamTypeToEsFilterId(u8 type, u8 ch, CellCodecEsFilterId& pEsFilterId)
{ {
// convert type and ch to EsFilterId // convert type and ch to EsFilterId
assert(ch < 16); Expects(ch < 16);
pEsFilterId.supplementalInfo1 = type == CELL_PAMF_STREAM_TYPE_AVC; pEsFilterId.supplementalInfo1 = type == CELL_PAMF_STREAM_TYPE_AVC;
pEsFilterId.supplementalInfo2 = 0; pEsFilterId.supplementalInfo2 = 0;
@ -110,7 +117,7 @@ s32 pamfStreamTypeToEsFilterId(u8 type, u8 ch, CellCodecEsFilterId& pEsFilterId)
u8 pamfGetStreamType(vm::ptr<CellPamfReader> pSelf, u32 stream) u8 pamfGetStreamType(vm::ptr<CellPamfReader> pSelf, u32 stream)
{ {
// TODO: get stream type correctly // TODO: get stream type correctly
assert(stream < (u32)pSelf->pAddr->stream_count); Expects(stream < (u32)pSelf->pAddr->stream_count);
auto& header = pSelf->pAddr->stream_headers[stream]; auto& header = pSelf->pAddr->stream_headers[stream];
switch (header.type) switch (header.type)
@ -131,7 +138,7 @@ u8 pamfGetStreamType(vm::ptr<CellPamfReader> pSelf, u32 stream)
u8 pamfGetStreamChannel(vm::ptr<CellPamfReader> pSelf, u32 stream) u8 pamfGetStreamChannel(vm::ptr<CellPamfReader> pSelf, u32 stream)
{ {
// TODO: get stream channel correctly // TODO: get stream channel correctly
assert(stream < (u32)pSelf->pAddr->stream_count); Expects(stream < (u32)pSelf->pAddr->stream_count);
auto& header = pSelf->pAddr->stream_headers[stream]; auto& header = pSelf->pAddr->stream_headers[stream];
switch (header.type) switch (header.type)
@ -139,29 +146,29 @@ u8 pamfGetStreamChannel(vm::ptr<CellPamfReader> pSelf, u32 stream)
case 0x1b: // AVC case 0x1b: // AVC
case 0x02: // M2V case 0x02: // M2V
{ {
assert((header.fid_major & 0xf0) == 0xe0 && header.fid_minor == 0); Expects((header.fid_major & 0xf0) == 0xe0 && header.fid_minor == 0);
return header.fid_major % 16; return header.fid_major % 16;
} }
case 0xdc: // ATRAC3PLUS case 0xdc: // ATRAC3PLUS
{ {
assert(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0); Expects(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0);
return header.fid_minor % 16; return header.fid_minor % 16;
} }
case 0x80: // LPCM case 0x80: // LPCM
{ {
assert(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0x40); Expects(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0x40);
return header.fid_minor % 16; return header.fid_minor % 16;
} }
case 0x81: // AC3 case 0x81: // AC3
{ {
assert(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0x30); Expects(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0x30);
return header.fid_minor % 16; return header.fid_minor % 16;
} }
case 0xdd: case 0xdd:
{ {
assert(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0x20); Expects(header.fid_major == 0xbd && (header.fid_minor & 0xf0) == 0x20);
return header.fid_minor % 16; return header.fid_minor % 16;
} }
} }
@ -447,7 +454,7 @@ s32 cellPamfReaderGetEsFilterId(vm::ptr<CellPamfReader> pSelf, vm::ptr<CellCodec
// always returns CELL_OK // always returns CELL_OK
assert((u32)pSelf->stream < (u32)pSelf->pAddr->stream_count); Expects((u32)pSelf->stream < (u32)pSelf->pAddr->stream_count);
auto& header = pSelf->pAddr->stream_headers[pSelf->stream]; auto& header = pSelf->pAddr->stream_headers[pSelf->stream];
pEsFilterId->filterIdMajor = header.fid_major; pEsFilterId->filterIdMajor = header.fid_major;
pEsFilterId->filterIdMinor = header.fid_minor; pEsFilterId->filterIdMinor = header.fid_minor;
@ -460,7 +467,7 @@ s32 cellPamfReaderGetStreamInfo(vm::ptr<CellPamfReader> pSelf, vm::ptr<void> pIn
{ {
cellPamf.warning("cellPamfReaderGetStreamInfo(pSelf=*0x%x, pInfo=*0x%x, size=%d)", pSelf, pInfo, size); cellPamf.warning("cellPamfReaderGetStreamInfo(pSelf=*0x%x, pInfo=*0x%x, size=%d)", pSelf, pInfo, size);
assert((u32)pSelf->stream < (u32)pSelf->pAddr->stream_count); Expects((u32)pSelf->stream < (u32)pSelf->pAddr->stream_count);
auto& header = pSelf->pAddr->stream_headers[pSelf->stream]; auto& header = pSelf->pAddr->stream_headers[pSelf->stream];
const u8 type = pamfGetStreamType(pSelf, pSelf->stream); const u8 type = pamfGetStreamType(pSelf, pSelf->stream);
const u8 ch = pamfGetStreamChannel(pSelf, pSelf->stream); const u8 ch = pamfGetStreamChannel(pSelf, pSelf->stream);
@ -733,7 +740,7 @@ s32 cellPamfEpIteratorMove(vm::ptr<CellPamfEpIterator> pIt, s32 steps, vm::ptr<C
return 0; return 0;
} }
Module<> cellPamf("cellPamf", []() DECLARE(ppu_module_manager::cellPamf)("cellPamf", []()
{ {
REG_FUNC(cellPamf, cellPamfGetHeaderSize); REG_FUNC(cellPamf, cellPamfGetHeaderSize);
REG_FUNC(cellPamf, cellPamfGetHeaderSize2); REG_FUNC(cellPamf, cellPamfGetHeaderSize2);

View File

@ -399,3 +399,342 @@ struct CellPamfReader
CHECK_SIZE(CellPamfReader, 128); CHECK_SIZE(CellPamfReader, 128);
s32 cellPamfReaderInitialize(vm::ptr<CellPamfReader> pSelf, vm::cptr<PamfHeader> pAddr, u64 fileSize, u32 attribute); s32 cellPamfReaderInitialize(vm::ptr<CellPamfReader> pSelf, vm::cptr<PamfHeader> pAddr, u64 fileSize, u32 attribute);
extern const std::function<bool()> SQUEUE_ALWAYS_EXIT;
extern const std::function<bool()> SQUEUE_NEVER_EXIT;
bool squeue_test_exit();
// TODO: eliminate this boolshit
template<typename T, u32 sq_size = 256>
class squeue_t
{
struct alignas(8) squeue_sync_var_t
{
struct
{
u32 position : 31;
u32 pop_lock : 1;
};
struct
{
u32 count : 31;
u32 push_lock : 1;
};
};
atomic_t<squeue_sync_var_t> m_sync;
mutable std::mutex m_rcv_mutex;
mutable std::mutex m_wcv_mutex;
mutable std::condition_variable m_rcv;
mutable std::condition_variable m_wcv;
T m_data[sq_size];
enum squeue_sync_var_result : u32
{
SQSVR_OK = 0,
SQSVR_LOCKED = 1,
SQSVR_FAILED = 2,
};
public:
squeue_t()
: m_sync(squeue_sync_var_t{})
{
}
u32 get_max_size() const
{
return sq_size;
}
bool is_full() const
{
return m_sync.load().count == sq_size;
}
bool push(const T& data, const std::function<bool()>& test_exit)
{
u32 pos = 0;
while (u32 res = m_sync.atomic_op([&pos](squeue_sync_var_t& sync) -> u32
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
if (sync.push_lock)
{
return SQSVR_LOCKED;
}
if (sync.count == sq_size)
{
return SQSVR_FAILED;
}
sync.push_lock = 1;
pos = sync.position + sync.count;
return SQSVR_OK;
}))
{
if (res == SQSVR_FAILED && (test_exit() || squeue_test_exit()))
{
return false;
}
std::unique_lock<std::mutex> wcv_lock(m_wcv_mutex);
m_wcv.wait_for(wcv_lock, std::chrono::milliseconds(1));
}
m_data[pos >= sq_size ? pos - sq_size : pos] = data;
m_sync.atomic_op([](squeue_sync_var_t& sync)
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
Expects(sync.push_lock);
sync.push_lock = 0;
sync.count++;
});
m_rcv.notify_one();
m_wcv.notify_one();
return true;
}
bool push(const T& data, const volatile bool* do_exit)
{
return push(data, [do_exit]() { return do_exit && *do_exit; });
}
force_inline bool push(const T& data)
{
return push(data, SQUEUE_NEVER_EXIT);
}
force_inline bool try_push(const T& data)
{
return push(data, SQUEUE_ALWAYS_EXIT);
}
bool pop(T& data, const std::function<bool()>& test_exit)
{
u32 pos = 0;
while (u32 res = m_sync.atomic_op([&pos](squeue_sync_var_t& sync) -> u32
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
if (!sync.count)
{
return SQSVR_FAILED;
}
if (sync.pop_lock)
{
return SQSVR_LOCKED;
}
sync.pop_lock = 1;
pos = sync.position;
return SQSVR_OK;
}))
{
if (res == SQSVR_FAILED && (test_exit() || squeue_test_exit()))
{
return false;
}
std::unique_lock<std::mutex> rcv_lock(m_rcv_mutex);
m_rcv.wait_for(rcv_lock, std::chrono::milliseconds(1));
}
data = m_data[pos];
m_sync.atomic_op([](squeue_sync_var_t& sync)
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
Expects(sync.pop_lock);
sync.pop_lock = 0;
sync.position++;
sync.count--;
if (sync.position == sq_size)
{
sync.position = 0;
}
});
m_rcv.notify_one();
m_wcv.notify_one();
return true;
}
bool pop(T& data, const volatile bool* do_exit)
{
return pop(data, [do_exit]() { return do_exit && *do_exit; });
}
force_inline bool pop(T& data)
{
return pop(data, SQUEUE_NEVER_EXIT);
}
force_inline bool try_pop(T& data)
{
return pop(data, SQUEUE_ALWAYS_EXIT);
}
bool peek(T& data, u32 start_pos, const std::function<bool()>& test_exit)
{
Expects(start_pos < sq_size);
u32 pos = 0;
while (u32 res = m_sync.atomic_op([&pos, start_pos](squeue_sync_var_t& sync) -> u32
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
if (sync.count <= start_pos)
{
return SQSVR_FAILED;
}
if (sync.pop_lock)
{
return SQSVR_LOCKED;
}
sync.pop_lock = 1;
pos = sync.position + start_pos;
return SQSVR_OK;
}))
{
if (res == SQSVR_FAILED && (test_exit() || squeue_test_exit()))
{
return false;
}
std::unique_lock<std::mutex> rcv_lock(m_rcv_mutex);
m_rcv.wait_for(rcv_lock, std::chrono::milliseconds(1));
}
data = m_data[pos >= sq_size ? pos - sq_size : pos];
m_sync.atomic_op([](squeue_sync_var_t& sync)
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
Expects(sync.pop_lock);
sync.pop_lock = 0;
});
m_rcv.notify_one();
return true;
}
bool peek(T& data, u32 start_pos, const volatile bool* do_exit)
{
return peek(data, start_pos, [do_exit]() { return do_exit && *do_exit; });
}
force_inline bool peek(T& data, u32 start_pos = 0)
{
return peek(data, start_pos, SQUEUE_NEVER_EXIT);
}
force_inline bool try_peek(T& data, u32 start_pos = 0)
{
return peek(data, start_pos, SQUEUE_ALWAYS_EXIT);
}
class squeue_data_t
{
T* const m_data;
const u32 m_pos;
const u32 m_count;
squeue_data_t(T* data, u32 pos, u32 count)
: m_data(data)
, m_pos(pos)
, m_count(count)
{
}
public:
T& operator [] (u32 index)
{
Expects(index < m_count);
index += m_pos;
index = index < sq_size ? index : index - sq_size;
return m_data[index];
}
};
void process(void(*proc)(squeue_data_t data))
{
u32 pos, count;
while (m_sync.atomic_op([&pos, &count](squeue_sync_var_t& sync) -> u32
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
if (sync.pop_lock || sync.push_lock)
{
return SQSVR_LOCKED;
}
pos = sync.position;
count = sync.count;
sync.pop_lock = 1;
sync.push_lock = 1;
return SQSVR_OK;
}))
{
std::unique_lock<std::mutex> rcv_lock(m_rcv_mutex);
m_rcv.wait_for(rcv_lock, std::chrono::milliseconds(1));
}
proc(squeue_data_t(m_data, pos, count));
m_sync.atomic_op([](squeue_sync_var_t& sync)
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
Expects(sync.pop_lock && sync.push_lock);
sync.pop_lock = 0;
sync.push_lock = 0;
});
m_wcv.notify_one();
m_rcv.notify_one();
}
void clear()
{
while (m_sync.atomic_op([](squeue_sync_var_t& sync) -> u32
{
Expects(sync.count <= sq_size);
Expects(sync.position < sq_size);
if (sync.pop_lock || sync.push_lock)
{
return SQSVR_LOCKED;
}
sync.pop_lock = 1;
sync.push_lock = 1;
return SQSVR_OK;
}))
{
std::unique_lock<std::mutex> rcv_lock(m_rcv_mutex);
m_rcv.wait_for(rcv_lock, std::chrono::milliseconds(1));
}
m_sync.exchange({});
m_wcv.notify_one();
m_rcv.notify_one();
}
};

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellPhotoDecode; LOG_CHANNEL(cellPhotoDecode);
// Return Codes // Return Codes
enum enum
@ -56,10 +55,10 @@ s32 cellPhotoDecodeFromFile()
return CELL_OK; return CELL_OK;
} }
Module<> cellPhotoDecode("cellPhotoDecode", []() DECLARE(ppu_module_manager::cellPhotoDecode)("cellPhotoDecodeUtil", []()
{ {
REG_FUNC(cellPhotoDecode, cellPhotoDecodeInitialize); REG_FUNC(cellPhotoDecodeUtil, cellPhotoDecodeInitialize);
REG_FUNC(cellPhotoDecode, cellPhotoDecodeInitialize2); REG_FUNC(cellPhotoDecodeUtil, cellPhotoDecodeInitialize2);
REG_FUNC(cellPhotoDecode, cellPhotoDecodeFinalize); REG_FUNC(cellPhotoDecodeUtil, cellPhotoDecodeFinalize);
REG_FUNC(cellPhotoDecode, cellPhotoDecodeFromFile); REG_FUNC(cellPhotoDecodeUtil, cellPhotoDecodeFromFile);
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellPhotoExport; LOG_CHANNEL(cellPhotoExport);
// Return Codes // Return Codes
enum enum
@ -75,15 +74,15 @@ s32 cellPhotoExportProgress()
return CELL_OK; return CELL_OK;
} }
Module<> cellPhotoExport("cellPhotoExport", []() DECLARE(ppu_module_manager::cellPhotoExport)("cellPhotoUtility", []()
{ {
REG_FUNC(cellPhotoExport, cellPhotoInitialize); REG_FUNC(cellPhotoUtility, cellPhotoInitialize);
REG_FUNC(cellPhotoExport, cellPhotoFinalize); REG_FUNC(cellPhotoUtility, cellPhotoFinalize);
REG_FUNC(cellPhotoExport, cellPhotoRegistFromFile); REG_FUNC(cellPhotoUtility, cellPhotoRegistFromFile);
REG_FUNC(cellPhotoExport, cellPhotoExportInitialize); REG_FUNC(cellPhotoUtility, cellPhotoExportInitialize);
REG_FUNC(cellPhotoExport, cellPhotoExportInitialize2); REG_FUNC(cellPhotoUtility, cellPhotoExportInitialize2);
REG_FUNC(cellPhotoExport, cellPhotoExportFinalize); REG_FUNC(cellPhotoUtility, cellPhotoExportFinalize);
REG_FUNC(cellPhotoExport, cellPhotoExportFromFile); REG_FUNC(cellPhotoUtility, cellPhotoExportFromFile);
REG_FUNC(cellPhotoExport, cellPhotoExportFromFileWithCopy); REG_FUNC(cellPhotoUtility, cellPhotoExportFromFileWithCopy);
REG_FUNC(cellPhotoExport, cellPhotoExportProgress); REG_FUNC(cellPhotoUtility, cellPhotoExportProgress);
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellPhotoImportUtil; LOG_CHANNEL(cellPhotoImportUtil);
// Return Codes // Return Codes
enum enum
@ -53,7 +52,7 @@ s32 cellPhotoImport2()
return CELL_OK; return CELL_OK;
} }
Module<> cellPhotoImportUtil("cellPhotoImport", []() DECLARE(ppu_module_manager::cellPhotoImportUtil)("cellPhotoImportUtil", []()
{ {
REG_FUNC(cellPhotoImportUtil, cellPhotoImport); REG_FUNC(cellPhotoImportUtil, cellPhotoImport);
REG_FUNC(cellPhotoImportUtil, cellPhotoImport2); REG_FUNC(cellPhotoImportUtil, cellPhotoImport2);

View File

@ -1,16 +1,13 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFileBase.h"
#include "Emu/SysCalls/lv2/sys_fs.h"
#include "Emu/Cell/lv2/sys_fs.h"
#include "png.h" #include "png.h"
#include "cellPngDec.h" #include "cellPngDec.h"
extern Module<> cellPngDec; LOG_CHANNEL(cellPngDec);
// cellPngDec aliases to improve readability // cellPngDec aliases to improve readability
using PPHandle = vm::pptr<PngHandle>; using PPHandle = vm::pptr<PngHandle>;
@ -59,7 +56,7 @@ void pngDecReadBuffer(png_structp png_ptr, png_bytep out, png_size_t length)
auto file = idm::get<lv2_file_t>(buffer.fd); auto file = idm::get<lv2_file_t>(buffer.fd);
// Read the data // Read the data
file->file->Read(out, length); file->file.read(out, length);
} }
else else
{ {
@ -338,7 +335,7 @@ s32 pngDecOpen(PPUThread& ppu, PHandle handle, PPStream png_stream, PSrc source,
if (source->srcSelect == CELL_PNGDEC_FILE) if (source->srcSelect == CELL_PNGDEC_FILE)
{ {
// Open a file stream // Open a file stream
std::shared_ptr<vfsStream> file_stream(Emu.GetVFS().OpenFile(stream->source.fileName.get_ptr(), fom::read)); fs::file file_stream(vfs::get(stream->source.fileName.get_ptr()));
// Check if opening of the PNG file failed // Check if opening of the PNG file failed
if (!file_stream) if (!file_stream)
@ -348,14 +345,14 @@ s32 pngDecOpen(PPUThread& ppu, PHandle handle, PPStream png_stream, PSrc source,
} }
// Read the header // Read the header
if (file_stream->Read(header, 8) != 8) if (file_stream.read(header, 8) != 8)
{ {
cellPngDec.error("PNG header is too small."); cellPngDec.error("PNG header is too small.");
return CELL_PNGDEC_ERROR_HEADER; return CELL_PNGDEC_ERROR_HEADER;
} }
// Get the file descriptor // Get the file descriptor
buffer->fd = idm::make<lv2_file_t>(file_stream, 0, 0); buffer->fd = idm::make<lv2_file_t>(std::move(file_stream), 0, 0);
// Indicate that we need to read from a file stream // Indicate that we need to read from a file stream
buffer->file = true; buffer->file = true;
@ -852,7 +849,7 @@ s32 cellPngDecGetTextChunk(PHandle handle, PStream stream, vm::ptr<u32> textInfo
throw EXCEPTION(""); throw EXCEPTION("");
} }
Module<> cellPngDec("cellPngDec", []() DECLARE(ppu_module_manager::cellPngDec)("cellPngDec", []()
{ {
REG_FUNC(cellPngDec, cellPngDecGetUnknownChunks); REG_FUNC(cellPngDec, cellPngDecGetUnknownChunks);
REG_FUNC(cellPngDec, cellPngDecClose); REG_FUNC(cellPngDec, cellPngDecClose);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellPngEnc; LOG_CHANNEL(cellPngEnc);
// Error Codes // Error Codes
enum enum
@ -69,7 +68,7 @@ s32 cellPngEncReset()
return CELL_OK; return CELL_OK;
} }
Module<> cellPngEnc("cellPngEnc", []() DECLARE(ppu_module_manager::cellPngEnc)("cellPngEnc", []()
{ {
REG_FUNC(cellPngEnc, cellPngEncQueryAttr); REG_FUNC(cellPngEnc, cellPngEncQueryAttr);
REG_FUNC(cellPngEnc, cellPngEncOpen); REG_FUNC(cellPngEnc, cellPngEncOpen);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellPrint; LOG_CHANNEL(cellPrint);
// Error Codes // Error Codes
enum enum
@ -101,21 +100,21 @@ s32 cellPrintSendBand()
return CELL_OK; return CELL_OK;
} }
Module<> cellPrint("cellPrint", []() DECLARE(ppu_module_manager::cellPrint)("cellPrintUtility", []()
{ {
REG_FUNC(cellPrint, cellSysutilPrintInit); REG_FUNC(cellPrintUtility, cellSysutilPrintInit);
REG_FUNC(cellPrint, cellSysutilPrintShutdown); REG_FUNC(cellPrintUtility, cellSysutilPrintShutdown);
REG_FUNC(cellPrint, cellPrintLoadAsync); REG_FUNC(cellPrintUtility, cellPrintLoadAsync);
REG_FUNC(cellPrint, cellPrintLoadAsync2); REG_FUNC(cellPrintUtility, cellPrintLoadAsync2);
REG_FUNC(cellPrint, cellPrintUnloadAsync); REG_FUNC(cellPrintUtility, cellPrintUnloadAsync);
REG_FUNC(cellPrint, cellPrintGetStatus); REG_FUNC(cellPrintUtility, cellPrintGetStatus);
REG_FUNC(cellPrint, cellPrintOpenConfig); REG_FUNC(cellPrintUtility, cellPrintOpenConfig);
REG_FUNC(cellPrint, cellPrintGetPrintableArea); REG_FUNC(cellPrintUtility, cellPrintGetPrintableArea);
REG_FUNC(cellPrint, cellPrintStartJob); REG_FUNC(cellPrintUtility, cellPrintStartJob);
REG_FUNC(cellPrint, cellPrintEndJob); REG_FUNC(cellPrintUtility, cellPrintEndJob);
REG_FUNC(cellPrint, cellPrintCancelJob); REG_FUNC(cellPrintUtility, cellPrintCancelJob);
REG_FUNC(cellPrint, cellPrintStartPage); REG_FUNC(cellPrintUtility, cellPrintStartPage);
REG_FUNC(cellPrint, cellPrintEndPage); REG_FUNC(cellPrintUtility, cellPrintEndPage);
REG_FUNC(cellPrint, cellPrintSendBand); REG_FUNC(cellPrintUtility, cellPrintSendBand);
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellRec; LOG_CHANNEL(cellRec);
s32 cellRecOpen() s32 cellRecOpen()
{ {
@ -40,7 +39,7 @@ s32 cellRecSetInfo()
} }
Module<> cellRec("cellRec", []() DECLARE(ppu_module_manager::cellRec)("cellRec", []()
{ {
REG_FUNC(cellRec, cellRecOpen); REG_FUNC(cellRec, cellRecOpen);
REG_FUNC(cellRec, cellRecClose); REG_FUNC(cellRec, cellRecClose);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellRemotePlay; LOG_CHANNEL(cellRemotePlay);
s32 cellRemotePlayGetStatus() s32 cellRemotePlayGetStatus()
{ {
@ -45,7 +44,7 @@ s32 cellRemotePlayBreak()
} }
Module<> cellRemotePlay("cellRemotePlay", []() DECLARE(ppu_module_manager::cellRemotePlay)("cellRemotePlay", []()
{ {
REG_FUNC(cellRemotePlay, cellRemotePlayGetStatus); REG_FUNC(cellRemotePlay, cellRemotePlayGetStatus);
REG_FUNC(cellRemotePlay, cellRemotePlaySetComparativeVolume); REG_FUNC(cellRemotePlay, cellRemotePlaySetComparativeVolume);

View File

@ -0,0 +1,180 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/RSX/GCM.h"
#include "cellResc.h"
LOG_CHANNEL(cellResc);
s32 cellRescInit(vm::ptr<CellRescInitConfig> initConfig)
{
cellResc.todo("cellRescInit(initConfig=*0x%x)", initConfig);
return CELL_OK;
}
void cellRescExit()
{
cellResc.todo("cellRescExit()");
}
s32 cellRescVideoOutResolutionId2RescBufferMode(u32 resolutionId, vm::ptr<u32> bufferMode)
{
cellResc.todo("cellRescVideoOutResolutionId2RescBufferMode(resolutionId=%d, bufferMode=*0x%x)", resolutionId, bufferMode);
return CELL_OK;
}
s32 cellRescSetDsts(u32 dstsMode, vm::ptr<CellRescDsts> dsts)
{
cellResc.todo("cellRescSetDsts(dstsMode=%d, dsts=*0x%x)", dstsMode, dsts);
return CELL_OK;
}
s32 cellRescSetDisplayMode(u32 displayMode)
{
cellResc.todo("cellRescSetDisplayMode(displayMode=%d)", displayMode);
return CELL_OK;
}
s32 cellRescAdjustAspectRatio(f32 horizontal, f32 vertical)
{
cellResc.todo("cellRescAdjustAspectRatio(horizontal=%f, vertical=%f)", horizontal, vertical);
return CELL_OK;
}
s32 cellRescSetPalInterpolateDropFlexRatio(f32 ratio)
{
cellResc.todo("cellRescSetPalInterpolateDropFlexRatio(ratio=%f)", ratio);
return CELL_OK;
}
s32 cellRescGetBufferSize(vm::ptr<u32> colorBuffers, vm::ptr<u32> vertexArray, vm::ptr<u32> fragmentShader)
{
cellResc.todo("cellRescGetBufferSize(colorBuffers=*0x%x, vertexArray=*0x%x, fragmentShader=*0x%x)", colorBuffers, vertexArray, fragmentShader);
return CELL_OK;
}
s32 cellRescGetNumColorBuffers(u32 dstMode, u32 palTemporalMode, u32 reserved)
{
cellResc.todo("cellRescGetNumColorBuffers(dstMode=%d, palTemporalMode=%d, reserved=%d)", dstMode, palTemporalMode, reserved);
return 2;
}
s32 cellRescGcmSurface2RescSrc(vm::ptr<CellGcmSurface> gcmSurface, vm::ptr<CellRescSrc> rescSrc)
{
cellResc.todo("cellRescGcmSurface2RescSrc(gcmSurface=*0x%x, rescSrc=*0x%x)", gcmSurface, rescSrc);
return CELL_OK;
}
s32 cellRescSetSrc(s32 idx, vm::ptr<CellRescSrc> src)
{
cellResc.todo("cellRescSetSrc(idx=0x%x, src=*0x%x)", idx, src);
return CELL_OK;
}
s32 cellRescSetConvertAndFlip(PPUThread& ppu, vm::ptr<CellGcmContextData> cntxt, s32 idx)
{
cellResc.todo("cellRescSetConvertAndFlip(cntxt=*0x%x, idx=0x%x)", cntxt, idx);
return CELL_OK;
}
s32 cellRescSetWaitFlip()
{
cellResc.todo("cellRescSetWaitFlip()");
return CELL_OK;
}
s32 cellRescSetBufferAddress(vm::ptr<u32> colorBuffers, vm::ptr<u32> vertexArray, vm::ptr<u32> fragmentShader)
{
cellResc.todo("cellRescSetBufferAddress(colorBuffers=*0x%x, vertexArray=*0x%x, fragmentShader=*0x%x)", colorBuffers, vertexArray, fragmentShader);
return CELL_OK;
}
void cellRescSetFlipHandler(vm::ptr<void(u32)> handler)
{
cellResc.todo("cellRescSetFlipHandler(handler=*0x%x)", handler);
}
void cellRescResetFlipStatus()
{
cellResc.todo("cellRescResetFlipStatus()");
}
s32 cellRescGetFlipStatus()
{
cellResc.todo("cellRescGetFlipStatus()");
return 0;
}
s32 cellRescGetRegisterCount()
{
UNIMPLEMENTED_FUNC(cellResc);
return CELL_OK;
}
u64 cellRescGetLastFlipTime()
{
cellResc.todo("cellRescGetLastFlipTime()");
return 0;
}
s32 cellRescSetRegisterCount()
{
UNIMPLEMENTED_FUNC(cellResc);
return CELL_OK;
}
void cellRescSetVBlankHandler(vm::ptr<void(u32)> handler)
{
cellResc.todo("cellRescSetVBlankHandler(handler=*0x%x)", handler);
}
s32 cellRescCreateInterlaceTable(u32 ea_addr, f32 srcH, CellRescTableElement depth, s32 length)
{
cellResc.todo("cellRescCreateInterlaceTable(ea_addr=0x%x, srcH=%f, depth=%d, length=%d)", ea_addr, srcH, depth, length);
return CELL_OK;
}
DECLARE(ppu_module_manager::cellResc)("cellResc", []()
{
REG_FUNC(cellResc, cellRescSetConvertAndFlip);
REG_FUNC(cellResc, cellRescSetWaitFlip);
REG_FUNC(cellResc, cellRescSetFlipHandler);
REG_FUNC(cellResc, cellRescGcmSurface2RescSrc);
REG_FUNC(cellResc, cellRescGetNumColorBuffers);
REG_FUNC(cellResc, cellRescSetDsts);
REG_FUNC(cellResc, cellRescResetFlipStatus);
REG_FUNC(cellResc, cellRescSetPalInterpolateDropFlexRatio);
REG_FUNC(cellResc, cellRescGetRegisterCount);
REG_FUNC(cellResc, cellRescAdjustAspectRatio);
REG_FUNC(cellResc, cellRescSetDisplayMode);
REG_FUNC(cellResc, cellRescExit);
REG_FUNC(cellResc, cellRescInit);
REG_FUNC(cellResc, cellRescGetBufferSize);
REG_FUNC(cellResc, cellRescGetLastFlipTime);
REG_FUNC(cellResc, cellRescSetSrc);
REG_FUNC(cellResc, cellRescSetRegisterCount);
REG_FUNC(cellResc, cellRescSetBufferAddress);
REG_FUNC(cellResc, cellRescGetFlipStatus);
REG_FUNC(cellResc, cellRescVideoOutResolutionId2RescBufferMode);
REG_FUNC(cellResc, cellRescSetVBlankHandler);
REG_FUNC(cellResc, cellRescCreateInterlaceTable);
});

View File

@ -1,12 +1,7 @@
#pragma once #pragma once
#define roundup(x,a) (((x)+(a)-1)&(~((a)-1)))
#define SEVIRITY 80.f
namespace vm { using namespace ps3; } namespace vm { using namespace ps3; }
#include "Emu/RSX/GCM.h"
enum enum
{ {
CELL_RESC_ERROR_NOT_INITIALIZED = 0x80210301, CELL_RESC_ERROR_NOT_INITIALIZED = 0x80210301,
@ -109,41 +104,3 @@ struct CellRescSrc
be_t<u16> height; be_t<u16> height;
be_t<u32> offset; be_t<u32> offset;
}; };
struct RescVertex_t
{
be_t<float> Px, Py;
be_t<float> u, v;
be_t<float> u2, v2;
};
struct CCellRescInternal
{
CellRescInitConfig m_initConfig;
CellRescSrc m_rescSrc[SRC_BUFFER_NUM];
u32 m_dstMode;
CellRescDsts m_rescDsts[4], *m_pRescDsts;
CellRescTableElement m_interlaceElement;
u32 m_colorBuffersEA, m_vertexArrayEA, m_fragmentUcodeEA;
u32 m_bufIdFront;
s32 m_dstWidth, m_dstHeight, m_dstPitch;
u16 m_srcWidthInterlace, m_srcHeightInterlace;
u32 m_dstBufInterval, m_dstOffsets[MAX_DST_BUFFER_NUM];
s32 m_nVertex;
u32 m_bufIdFrontPrevDrop, m_bufIdPalMidPrev, m_bufIdPalMidNow;
u32 m_interlaceTableEA;
int m_interlaceTableLength;
float m_ratioAdjX, m_ratioAdjY, m_flexRatio;
bool m_bInitialized, m_bNewlyAdjustRatio;
bool m_isDummyFlipped;
u8 m_cgParamIndex[RESC_PARAM_NUM];
u64 m_commandIdxCaF, m_rcvdCmdIdx;
vm::ptr<void(u32)> s_applicationFlipHandler;
vm::ptr<void(u32)> s_applicationVBlankHandler;
CCellRescInternal()
: m_bInitialized(false)
{
}
};

View File

@ -0,0 +1,295 @@
#include "stdafx.h"
#include "Emu/Cell/PPUModule.h"
#include "cellRtc.h"
LOG_CHANNEL(cellRtc);
s64 convertToUNIXTime(u16 seconds, u16 minutes, u16 hours, u16 days, s32 years)
{
return (s64)seconds + (s64)minutes * 60 + (s64)hours * 3600 + (s64)days * 86400 +
(s64)(years - 70) * 31536000 + (s64)((years - 69) / 4) * 86400 -
(s64)((years - 1) / 100) * 86400 + (s64)((years + 299) / 400) * 86400;
}
u64 convertToWin32FILETIME(u16 seconds, u16 minutes, u16 hours, u16 days, s32 years)
{
s64 unixtime = convertToUNIXTime(seconds, minutes, hours, days, years);
u64 win32time = u64(unixtime) * u64(10000000) + u64(116444736000000000);
u64 win32filetime = win32time | win32time >> 32;
return win32filetime;
}
s32 cellRtcGetCurrentTick(vm::ptr<CellRtcTick> pTick)
{
cellRtc.todo("cellRtcGetCurrentTick(pTick=*0x%x)", pTick);
return CELL_OK;
}
s32 cellRtcGetCurrentClock(vm::ptr<CellRtcDateTime> pClock, s32 iTimeZone)
{
cellRtc.todo("cellRtcGetCurrentClock(pClock=*0x%x, time_zone=%d)", pClock, iTimeZone);
return CELL_OK;
}
s32 cellRtcGetCurrentClockLocalTime(vm::ptr<CellRtcDateTime> pClock)
{
cellRtc.todo("cellRtcGetCurrentClockLocalTime(pClock=*0x%x)", pClock);
return CELL_OK;
}
s32 cellRtcFormatRfc2822(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
{
cellRtc.todo("cellRtcFormatRfc2822(pszDateTime=*0x%x, pUtc=*0x%x, time_zone=%d)", pszDateTime, pUtc, iTimeZone);
return CELL_OK;
}
s32 cellRtcFormatRfc2822LocalTime(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc)
{
cellRtc.todo("cellRtcFormatRfc2822LocalTime(pszDateTime=*0x%x, pUtc=*0x%x)", pszDateTime, pUtc);
return CELL_OK;
}
s32 cellRtcFormatRfc3339(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc, s32 iTimeZone)
{
cellRtc.todo("cellRtcFormatRfc3339(pszDateTime=*0x%x, pUtc=*0x%x, iTimeZone=%d)", pszDateTime, pUtc, iTimeZone);
return CELL_OK;
}
s32 cellRtcFormatRfc3339LocalTime(vm::ptr<char> pszDateTime, vm::ptr<CellRtcTick> pUtc)
{
cellRtc.todo("cellRtcFormatRfc3339LocalTime(pszDateTime=*0x%x, pUtc=*0x%x)", pszDateTime, pUtc);
return CELL_OK;
}
s32 cellRtcParseDateTime(vm::ptr<CellRtcTick> pUtc, vm::cptr<char> pszDateTime)
{
cellRtc.todo("cellRtcParseDateTime(pUtc=*0x%x, pszDateTime=*0x%x)", pUtc, pszDateTime);
return CELL_OK;
}
s32 cellRtcParseRfc3339(vm::ptr<CellRtcTick> pUtc, vm::cptr<char> pszDateTime)
{
cellRtc.todo("cellRtcParseRfc3339(pUtc=*0x%x, pszDateTime=*0x%x)", pUtc, pszDateTime);
return CELL_OK;
}
s32 cellRtcGetTick(vm::ptr<CellRtcDateTime> pTime, vm::ptr<CellRtcTick> pTick)
{
cellRtc.todo("cellRtcGetTick(pTime=*0x%x, pTick=*0x%x)", pTime, pTick);
return CELL_OK;
}
s32 cellRtcSetTick(vm::ptr<CellRtcDateTime> pTime, vm::ptr<CellRtcTick> pTick)
{
cellRtc.todo("cellRtcSetTick(pTime=*0x%x, pTick=*0x%x)", pTime, pTick);
return CELL_OK;
}
s32 cellRtcTickAddTicks(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc.todo("cellRtcTickAddTicks(pTick0=*0x%x, pTick1=*0x%x, lAdd=%lld)", pTick0, pTick1, lAdd);
return CELL_OK;
}
s32 cellRtcTickAddMicroseconds(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc.todo("cellRtcTickAddMicroseconds(pTick0=*0x%x, pTick1=*0x%x, lAdd=%lld)", pTick0, pTick1, lAdd);
return CELL_OK;
}
s32 cellRtcTickAddSeconds(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc.todo("cellRtcTickAddSeconds(pTick0=*0x%x, pTick1=*0x%x, lAdd=%lld)", pTick0, pTick1, lAdd);
return CELL_OK;
}
s32 cellRtcTickAddMinutes(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s64 lAdd)
{
cellRtc.todo("cellRtcTickAddMinutes(pTick0=*0x%x, pTick1=*0x%x, lAdd=%lld)", pTick0, pTick1, lAdd);
return CELL_OK;
}
s32 cellRtcTickAddHours(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc.todo("cellRtcTickAddHours(pTick0=*0x%x, pTick1=*0x%x, iAdd=%d)", pTick0, pTick1, iAdd);
return CELL_OK;
}
s32 cellRtcTickAddDays(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc.todo("cellRtcTickAddDays(pTick0=*0x%x, pTick1=*0x%x, iAdd=%d)", pTick0, pTick1, iAdd);
return CELL_OK;
}
s32 cellRtcTickAddWeeks(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc.todo("cellRtcTickAddWeeks(pTick0=*0x%x, pTick1=*0x%x, iAdd=%d)", pTick0, pTick1, iAdd);
return CELL_OK;
}
s32 cellRtcTickAddMonths(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc.todo("cellRtcTickAddMonths(pTick0=*0x%x, pTick1=*0x%x, iAdd=%d)", pTick0, pTick1, iAdd);
return CELL_OK;
}
s32 cellRtcTickAddYears(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1, s32 iAdd)
{
cellRtc.todo("cellRtcTickAddYears(pTick0=*0x%x, pTick1=*0x%x, iAdd=%d)", pTick0, pTick1, iAdd);
return CELL_OK;
}
s32 cellRtcConvertUtcToLocalTime(vm::ptr<CellRtcTick> pUtc, vm::ptr<CellRtcTick> pLocalTime)
{
cellRtc.todo("cellRtcConvertUtcToLocalTime(pUtc=*0x%x, pLocalTime=*0x%x)", pUtc, pLocalTime);
return CELL_OK;
}
s32 cellRtcConvertLocalTimeToUtc(vm::ptr<CellRtcTick> pLocalTime, vm::ptr<CellRtcTick> pUtc)
{
cellRtc.todo("cellRtcConvertLocalTimeToUtc(pLocalTime=*0x%x, pUtc=*0x%x)", pLocalTime, pUtc);
return CELL_OK;
}
s32 cellRtcGetDosTime(vm::ptr<CellRtcDateTime> pDateTime, vm::ptr<u32> puiDosTime)
{
cellRtc.todo("cellRtcGetDosTime(pDateTime=*0x%x, puiDosTime=*0x%x)", pDateTime, puiDosTime);
return CELL_OK;
}
s32 cellRtcGetTime_t(vm::ptr<CellRtcDateTime> pDateTime, vm::ptr<s64> piTime)
{
cellRtc.todo("cellRtcGetTime_t(pDateTime=*0x%x, piTime=*0x%x)", pDateTime, piTime);
return CELL_OK;
}
s32 cellRtcGetWin32FileTime(vm::ptr<CellRtcDateTime> pDateTime, vm::ptr<u64> pulWin32FileTime)
{
cellRtc.todo("cellRtcGetWin32FileTime(pDateTime=*0x%x, pulWin32FileTime=*0x%x)", pDateTime, pulWin32FileTime);
return CELL_OK;
}
s32 cellRtcSetDosTime(vm::ptr<CellRtcDateTime> pDateTime, u32 uiDosTime)
{
cellRtc.todo("cellRtcSetDosTime(pDateTime=*0x%x, uiDosTime=0x%x)", pDateTime, uiDosTime);
return CELL_OK;
}
s32 cellRtcSetTime_t(vm::ptr<CellRtcDateTime> pDateTime, u64 iTime)
{
cellRtc.todo("cellRtcSetTime_t(pDateTime=*0x%x, iTime=0x%llx)", pDateTime, iTime);
return CELL_OK;
}
s32 cellRtcSetWin32FileTime(vm::ptr<CellRtcDateTime> pDateTime, u64 ulWin32FileTime)
{
cellRtc.todo("cellRtcSetWin32FileTime(pDateTime=*0x%x, ulWin32FileTime=0x%llx)", pDateTime, ulWin32FileTime);
return CELL_OK;
}
s32 cellRtcIsLeapYear(s32 year)
{
cellRtc.todo("cellRtcIsLeapYear(year=%d)", year);
return 0;
}
s32 cellRtcGetDaysInMonth(s32 year, s32 month)
{
cellRtc.todo("cellRtcGetDaysInMonth(year=%d, month=%d)", year, month);
return 0;
}
s32 cellRtcGetDayOfWeek(s32 year, s32 month, s32 day)
{
cellRtc.todo("cellRtcGetDayOfWeek(year=%d, month=%d, day=%d)", year, month, day);
return 0;
}
s32 cellRtcCheckValid(vm::ptr<CellRtcDateTime> pTime)
{
cellRtc.todo("cellRtcCheckValid(pTime=*0x%x)", pTime);
return CELL_OK;
}
s32 cellRtcCompareTick(vm::ptr<CellRtcTick> pTick0, vm::ptr<CellRtcTick> pTick1)
{
cellRtc.todo("cellRtcCompareTick(pTick0=*0x%x, pTick1=*0x%x)", pTick0, pTick1);
return CELL_OK;
}
DECLARE(ppu_module_manager::cellRtc)("cellRtc", []()
{
REG_FUNC(cellRtc, cellRtcGetCurrentTick);
REG_FUNC(cellRtc, cellRtcGetCurrentClock);
REG_FUNC(cellRtc, cellRtcGetCurrentClockLocalTime);
REG_FUNC(cellRtc, cellRtcFormatRfc2822);
REG_FUNC(cellRtc, cellRtcFormatRfc2822LocalTime);
REG_FUNC(cellRtc, cellRtcFormatRfc3339);
REG_FUNC(cellRtc, cellRtcFormatRfc3339LocalTime);
REG_FUNC(cellRtc, cellRtcParseDateTime);
REG_FUNC(cellRtc, cellRtcParseRfc3339);
REG_FUNC(cellRtc, cellRtcGetTick);
REG_FUNC(cellRtc, cellRtcSetTick);
REG_FUNC(cellRtc, cellRtcTickAddTicks);
REG_FUNC(cellRtc, cellRtcTickAddMicroseconds);
REG_FUNC(cellRtc, cellRtcTickAddSeconds);
REG_FUNC(cellRtc, cellRtcTickAddMinutes);
REG_FUNC(cellRtc, cellRtcTickAddHours);
REG_FUNC(cellRtc, cellRtcTickAddDays);
REG_FUNC(cellRtc, cellRtcTickAddWeeks);
REG_FUNC(cellRtc, cellRtcTickAddMonths);
REG_FUNC(cellRtc, cellRtcTickAddYears);
REG_FUNC(cellRtc, cellRtcConvertUtcToLocalTime);
REG_FUNC(cellRtc, cellRtcConvertLocalTimeToUtc);
REG_FUNC(cellRtc, cellRtcGetDosTime);
REG_FUNC(cellRtc, cellRtcGetTime_t);
REG_FUNC(cellRtc, cellRtcGetWin32FileTime);
REG_FUNC(cellRtc, cellRtcSetDosTime);
REG_FUNC(cellRtc, cellRtcSetTime_t);
REG_FUNC(cellRtc, cellRtcSetWin32FileTime);
REG_FUNC(cellRtc, cellRtcIsLeapYear);
REG_FUNC(cellRtc, cellRtcGetDaysInMonth);
REG_FUNC(cellRtc, cellRtcGetDayOfWeek);
REG_FUNC(cellRtc, cellRtcCheckValid);
REG_FUNC(cellRtc, cellRtcCompareTick);
});

View File

@ -1,12 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/IdManager.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "cellRudp.h" #include "cellRudp.h"
extern Module<> cellRudp; LOG_CHANNEL(cellRudp);
struct rudp_t struct rudp_t
{ {
@ -239,7 +238,7 @@ s32 cellRudpProcessEvents()
return CELL_OK; return CELL_OK;
} }
Module<> cellRudp("cellRudp", []() DECLARE(ppu_module_manager::cellRudp)("cellRudp", []()
{ {
REG_FUNC(cellRudp, cellRudpInit); REG_FUNC(cellRudp, cellRudpInit);
REG_FUNC(cellRudp, cellRudpEnd); REG_FUNC(cellRudp, cellRudpEnd);

View File

@ -1,14 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Callback.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/FS/vfsFile.h"
#include "cellSail.h" #include "cellSail.h"
#include "cellPamf.h" #include "cellPamf.h"
extern Module<> cellSail; LOG_CHANNEL(cellSail);
void playerBoot(vm::ptr<CellSailPlayer> pSelf, u64 userParam) void playerBoot(vm::ptr<CellSailPlayer> pSelf, u64 userParam)
{ {
@ -815,15 +812,13 @@ s32 cellSailPlayerCreateDescriptor(vm::ptr<CellSailPlayer> pSelf, s32 streamType
std::string uri = pUri.get_ptr(); std::string uri = pUri.get_ptr();
if (uri.substr(0, 12) == "x-cell-fs://") if (uri.substr(0, 12) == "x-cell-fs://")
{ {
std::string path = uri.substr(12); if (fs::file f{ vfs::get(uri.substr(12)) })
vfsFile f;
if (f.Open(path))
{ {
u64 size = f.GetSize(); u64 size = f.size();
u32 buffer = vm::alloc(size, vm::main); u32 buffer = vm::alloc(size, vm::main);
auto bufPtr = vm::cptr<PamfHeader>::make(buffer); auto bufPtr = vm::cptr<PamfHeader>::make(buffer);
PamfHeader *buf = const_cast<PamfHeader*>(bufPtr.get_ptr()); PamfHeader *buf = const_cast<PamfHeader*>(bufPtr.get_ptr());
assert(f.Read(buf, size) == size); ASSERT(f.read(buf, size) == size);
u32 sp_ = vm::alloc(sizeof(CellPamfReader), vm::main); u32 sp_ = vm::alloc(sizeof(CellPamfReader), vm::main);
auto sp = vm::ptr<CellPamfReader>::make(sp_); auto sp = vm::ptr<CellPamfReader>::make(sp_);
u32 reader = cellPamfReaderInitialize(sp, bufPtr, size, 0); u32 reader = cellPamfReaderInitialize(sp, bufPtr, size, 0);
@ -1043,7 +1038,7 @@ s32 cellSailPlayerUnregisterSource()
return CELL_OK; return CELL_OK;
} }
Module<> cellSail("cellSail", []() DECLARE(ppu_module_manager::cellSail)("cellSail", []()
{ {
REG_FUNC(cellSail, cellSailMemAllocatorInitialize); REG_FUNC(cellSail, cellSailMemAllocatorInitialize);

View File

@ -674,11 +674,13 @@ union CellSailEvent
be_t<u64> value; be_t<u64> value;
}; };
template<typename T, bool is_enum> struct cast_ppu_gpr; template<typename T, typename>
struct ppu_gpr_cast_impl;
template<> struct cast_ppu_gpr<CellSailEvent, false> template<>
struct ppu_gpr_cast_impl<CellSailEvent, void>
{ {
static inline u64 to_gpr(const CellSailEvent& event) static inline u64 to(const CellSailEvent& event)
{ {
return event.value; return event.value;
} }

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellSailRec; LOG_CHANNEL(cellSailRec);
// Error Codes // Error Codes
enum enum
@ -255,7 +254,7 @@ s32 cellSailRecorderDumpImage()
return CELL_OK; return CELL_OK;
} }
Module<> cellSailRec("cellSailRec", []() DECLARE(ppu_module_manager::cellSailRec)("cellSailRec", []()
{ {
REG_FUNC(cellSailRec, cellSailProfileSetEsAudioParameter); REG_FUNC(cellSailRec, cellSailProfileSetEsAudioParameter);
REG_FUNC(cellSailRec, cellSailProfileSetEsVideoParameter); REG_FUNC(cellSailRec, cellSailProfileSetEsVideoParameter);

View File

@ -1,17 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/FS/VFS.h"
#include "Emu/FS/vfsFile.h"
#include "Emu/FS/vfsDir.h"
#include "Loader/PSF.h"
#include "cellSaveData.h" #include "cellSaveData.h"
extern Module<> cellSysutil; LOG_CHANNEL(cellSaveData);
extern Module<> cellSaveData;
extern Module<> cellMinisSaveData;
// cellSaveData aliases (only for cellSaveData.cpp) // cellSaveData aliases (only for cellSaveData.cpp)
using PSetList = vm::ptr<CellSaveDataSetList>; using PSetList = vm::ptr<CellSaveDataSetList>;
@ -38,7 +31,7 @@ enum : u32
std::mutex g_savedata_mutex; std::mutex g_savedata_mutex;
never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cptr<char> dirName, static never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cptr<char> dirName,
u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncFixed funcFixed, PFuncStat funcStat, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncFixed funcFixed, PFuncStat funcStat,
PFuncFile funcFile, u32 container, u32 unknown, vm::ptr<void> userdata, u32 userId, PFuncDone funcDone) PFuncFile funcFile, u32 container, u32 unknown, vm::ptr<void> userdata, u32 userId, PFuncDone funcDone)
{ {
@ -61,7 +54,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
vm::var<CellSaveDataFileSet> fileSet; vm::var<CellSaveDataFileSet> fileSet;
// path of the specified user (00000001 by default) // path of the specified user (00000001 by default)
const std::string base_dir = fmt::format("/dev_hdd0/home/%08u/savedata/", userId ? userId : 1u); const std::string& base_dir = vfs::get(fmt::format("/dev_hdd0/home/%08u/savedata/", userId ? userId : 1u));
result->userdata = userdata; // probably should be assigned only once (allows the callback to change it) result->userdata = userdata; // probably should be assigned only once (allows the callback to change it)
@ -78,16 +71,16 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
const auto prefix_list = fmt::split(setList->dirNamePrefix.get_ptr(), { "|" }); const auto prefix_list = fmt::split(setList->dirNamePrefix.get_ptr(), { "|" });
for (const auto entry : vfsDir(base_dir)) for (const auto& entry : fs::dir(base_dir))
{ {
if (entry->flags & DirEntry_TypeFile) if (entry.is_directory)
{ {
continue; continue;
} }
for (const auto& prefix : prefix_list) for (const auto& prefix : prefix_list)
{ {
if (entry->name.substr(0, prefix.size()) == prefix) if (entry.name.substr(0, prefix.size()) == prefix)
{ {
// Count the amount of matches and the amount of listed directories // Count the amount of matches and the amount of listed directories
if (listGet->dirListNum++ < setBuf->dirListMax) if (listGet->dirListNum++ < setBuf->dirListMax)
@ -95,7 +88,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
listGet->dirNum++; listGet->dirNum++;
// PSF parameters // PSF parameters
const auto& psf = psf::load(vfsFile(base_dir + entry->name + "/PARAM.SFO").VRead<char>()); const auto& psf = psf::load_object(fs::file(base_dir + entry.name + "/PARAM.SFO"));
if (psf.empty()) if (psf.empty())
{ {
@ -111,14 +104,14 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
save_entry2.size = 0; save_entry2.size = 0;
for (const auto entry2 : vfsDir(base_dir + entry->name)) for (const auto entry2 : fs::dir(base_dir + entry.name))
{ {
save_entry2.size += entry2->size; save_entry2.size += entry2.size;
} }
save_entry2.atime = entry->access_time; save_entry2.atime = entry.atime;
save_entry2.mtime = entry->modify_time; save_entry2.mtime = entry.mtime;
save_entry2.ctime = entry->create_time; save_entry2.ctime = entry.ctime;
//save_entry2.iconBuf = NULL; // TODO: Here should be the PNG buffer //save_entry2.iconBuf = NULL; // TODO: Here should be the PNG buffer
//save_entry2.iconBufSize = 0; // TODO: Size of the PNG file //save_entry2.iconBufSize = 0; // TODO: Size of the PNG file
save_entry2.isNew = false; save_entry2.isNew = false;
@ -184,7 +177,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
if (result->result < 0) if (result->result < 0)
{ {
cellSysutil.warning("savedata_op(): funcList returned < 0."); cellSaveData.warning("savedata_op(): funcList returned < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT; return CELL_SAVEDATA_ERROR_CBRESULT;
} }
@ -266,7 +259,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
} }
default: default:
{ {
cellSysutil.error("savedata_op(): unknown listSet->focusPosition (0x%x)", pos_type); cellSaveData.error("savedata_op(): unknown listSet->focusPosition (0x%x)", pos_type);
return CELL_SAVEDATA_ERROR_PARAM; return CELL_SAVEDATA_ERROR_PARAM;
} }
} }
@ -294,7 +287,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
if (result->result < 0) if (result->result < 0)
{ {
cellSysutil.warning("savedata_op(): funcFixed returned < 0."); cellSaveData.warning("savedata_op(): funcFixed returned < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT; return CELL_SAVEDATA_ERROR_CBRESULT;
} }
@ -339,16 +332,12 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
std::string dir_path = base_dir + save_entry.dirName + "/"; std::string dir_path = base_dir + save_entry.dirName + "/";
std::string sfo_path = dir_path + "PARAM.SFO"; std::string sfo_path = dir_path + "PARAM.SFO";
auto&& psf = psf::load(vfsFile(sfo_path).VRead<char>()); auto&& psf = psf::load_object(fs::file(sfo_path));
// Get save stats // Get save stats
{ {
std::string dir_local_path; fs::stat_t dir_info{};
if (!fs::stat(dir_path, dir_info))
Emu.GetVFS().GetDevice(dir_path, dir_local_path);
fs::stat_t dir_info;
if (!fs::stat(dir_local_path, dir_info))
{ {
// error // error
} }
@ -381,32 +370,32 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
auto file_list = statGet->fileList.get_ptr(); auto file_list = statGet->fileList.get_ptr();
for (const auto entry : vfsDir(dir_path)) for (const auto& entry : fs::dir(dir_path))
{ {
// only files, system files ignored, fileNum is limited by setBuf->fileListMax // only files, system files ignored, fileNum is limited by setBuf->fileListMax
if (entry->flags & DirEntry_TypeFile && entry->name != "PARAM.SFO" && statGet->fileListNum++ < setBuf->fileListMax) if (!entry.is_directory && entry.name != "PARAM.SFO" && statGet->fileListNum++ < setBuf->fileListMax)
{ {
statGet->fileNum++; statGet->fileNum++;
auto& file = *file_list++; auto& file = *file_list++;
if (entry->name == "ICON0.PNG") if (entry.name == "ICON0.PNG")
{ {
file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON0; file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON0;
} }
else if (entry->name == "ICON1.PAM") else if (entry.name == "ICON1.PAM")
{ {
file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON1; file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_ICON1;
} }
else if (entry->name == "PIC1.PNG") else if (entry.name == "PIC1.PNG")
{ {
file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_PIC1; file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_PIC1;
} }
else if (entry->name == "SND0.AT3") else if (entry.name == "SND0.AT3")
{ {
file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_SND0; file.fileType = CELL_SAVEDATA_FILETYPE_CONTENT_SND0;
} }
else if (psf::get_integer(psf, "*" + entry->name)) // let's put the list of protected files in PARAM.SFO (int param = 1 if protected) else if (psf::get_integer(psf, "*" + entry.name)) // let's put the list of protected files in PARAM.SFO (int param = 1 if protected)
{ {
file.fileType = CELL_SAVEDATA_FILETYPE_SECUREFILE; file.fileType = CELL_SAVEDATA_FILETYPE_SECUREFILE;
} }
@ -415,11 +404,11 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
file.fileType = CELL_SAVEDATA_FILETYPE_NORMALFILE; file.fileType = CELL_SAVEDATA_FILETYPE_NORMALFILE;
} }
file.size = entry->size; file.size = entry.size;
file.atime = entry->access_time; file.atime = entry.atime;
file.mtime = entry->modify_time; file.mtime = entry.mtime;
file.ctime = entry->create_time; file.ctime = entry.ctime;
strcpy_trunc(file.fileName, entry->name); strcpy_trunc(file.fileName, entry.name);
} }
} }
@ -428,7 +417,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
if (result->result < 0) if (result->result < 0)
{ {
cellSysutil.warning("savedata_op(): funcStat returned < 0."); cellSaveData.warning("savedata_op(): funcStat returned 0x%x", result->result);
return CELL_SAVEDATA_ERROR_CBRESULT; return CELL_SAVEDATA_ERROR_CBRESULT;
} }
@ -473,19 +462,19 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
case CELL_SAVEDATA_RECREATE_YES: case CELL_SAVEDATA_RECREATE_YES:
case CELL_SAVEDATA_RECREATE_YES_RESET_OWNER: case CELL_SAVEDATA_RECREATE_YES_RESET_OWNER:
{ {
// kill it with fire // TODO?
for (const auto entry : vfsDir(dir_path)) for (const auto& entry : fs::dir(dir_path))
{ {
if (entry->flags & DirEntry_TypeFile) if (!entry.is_directory)
{ {
Emu.GetVFS().RemoveFile(dir_path + entry->name); fs::remove_file(dir_path + entry.name);
} }
} }
if (!statSet->setParam) if (!statSet->setParam)
{ {
// Savedata deleted and setParam is NULL: delete directory and abort operation // Savedata deleted and setParam is NULL: delete directory and abort operation
if (Emu.GetVFS().RemoveDir(dir_path)) cellSysutil.error("savedata_op(): savedata directory %s deleted", save_entry.dirName); if (fs::remove_dir(dir_path)) cellSaveData.error("savedata_op(): savedata directory %s deleted", save_entry.dirName);
return CELL_OK; return CELL_OK;
} }
@ -495,16 +484,17 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
default: default:
{ {
cellSysutil.error("savedata_op(): unknown statSet->reCreateMode (0x%x)", statSet->reCreateMode); cellSaveData.error("savedata_op(): unknown statSet->reCreateMode (0x%x)", statSet->reCreateMode);
return CELL_SAVEDATA_ERROR_PARAM; return CELL_SAVEDATA_ERROR_PARAM;
} }
} }
} }
// Create save directory if necessary // Create save directory if necessary
if (psf.size() && save_entry.isNew && !Emu.GetVFS().CreateDir(dir_path)) if (psf.size() && save_entry.isNew && !fs::create_dir(dir_path))
{ {
// Let's ignore this error for now // Let's ignore this error for now
cellSaveData.warning("savedata_op(): failed to create %s", dir_path);
} }
// Enter the loop where the save files are read/created/deleted // Enter the loop where the save files are read/created/deleted
@ -518,7 +508,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
if (result->result < 0) if (result->result < 0)
{ {
cellSysutil.warning("savedata_op(): funcFile returned < 0."); cellSaveData.warning("savedata_op(): funcFile returned < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT; return CELL_SAVEDATA_ERROR_CBRESULT;
} }
@ -564,22 +554,18 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
default: default:
{ {
cellSysutil.error("savedata_op(): unknown fileSet->fileType (0x%x)", type); cellSaveData.error("savedata_op(): unknown fileSet->fileType (0x%x)", type);
return CELL_SAVEDATA_ERROR_PARAM; return CELL_SAVEDATA_ERROR_PARAM;
} }
} }
psf.emplace("*" + file_path, fileSet->fileType == CELL_SAVEDATA_FILETYPE_SECUREFILE); psf.emplace("*" + file_path, fileSet->fileType == CELL_SAVEDATA_FILETYPE_SECUREFILE);
std::string local_path;
Emu.GetVFS().GetDevice(dir_path + file_path, local_path);
switch (const u32 op = fileSet->fileOperation) switch (const u32 op = fileSet->fileOperation)
{ {
case CELL_SAVEDATA_FILEOP_READ: case CELL_SAVEDATA_FILEOP_READ:
{ {
fs::file file(local_path, fom::read); fs::file file(dir_path + file_path, fs::read);
file.seek(fileSet->fileOffset); file.seek(fileSet->fileOffset);
fileGet->excSize = static_cast<u32>(file.read(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize))); fileGet->excSize = static_cast<u32>(file.read(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize)));
break; break;
@ -587,23 +573,23 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
case CELL_SAVEDATA_FILEOP_WRITE: case CELL_SAVEDATA_FILEOP_WRITE:
{ {
fs::file file(local_path, fom::write | fom::create); fs::file file(dir_path + file_path, fs::write + fs::create);
file.seek(fileSet->fileOffset); file.seek(fileSet->fileOffset);
fileGet->excSize = static_cast<u32>(file.write(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize))); fileGet->excSize = static_cast<u32>(file.write(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize)));
file.trunc(file.seek(0, fs::seek_cur)); // truncate file.trunc(file.pos()); // truncate
break; break;
} }
case CELL_SAVEDATA_FILEOP_DELETE: case CELL_SAVEDATA_FILEOP_DELETE:
{ {
fs::remove_file(local_path); fs::remove_file(dir_path + file_path);
fileGet->excSize = 0; fileGet->excSize = 0;
break; break;
} }
case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC: case CELL_SAVEDATA_FILEOP_WRITE_NOTRUNC:
{ {
fs::file file(local_path, fom::write | fom::create); fs::file file(dir_path + file_path, fs::write + fs::create);
file.seek(fileSet->fileOffset); file.seek(fileSet->fileOffset);
fileGet->excSize = static_cast<u32>(file.write(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize))); fileGet->excSize = static_cast<u32>(file.write(fileSet->fileBuf.get_ptr(), std::min<u32>(fileSet->fileSize, fileSet->fileBufSize)));
break; break;
@ -611,7 +597,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
default: default:
{ {
cellSysutil.error("savedata_op(): unknown fileSet->fileOperation (0x%x)", op); cellSaveData.error("savedata_op(): unknown fileSet->fileOperation (0x%x)", op);
return CELL_SAVEDATA_ERROR_PARAM; return CELL_SAVEDATA_ERROR_PARAM;
} }
} }
@ -620,7 +606,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
// Write PARAM.SFO // Write PARAM.SFO
if (psf.size()) if (psf.size())
{ {
vfsFile(sfo_path, fom::rewrite).VWrite(psf::save(psf)); fs::file(sfo_path, fs::rewrite).write(psf::save_object(psf));
} }
return CELL_OK; return CELL_OK;
@ -630,7 +616,7 @@ never_inline s32 savedata_op(PPUThread& ppu, u32 operation, u32 version, vm::cpt
s32 cellSaveDataListSave2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList, s32 cellSaveDataListSave2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList,
PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataListSave2(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataListSave2(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, setList, setBuf, funcList, funcStat, funcFile, container, userdata); version, setList, setBuf, funcList, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_SAVE, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_SAVE, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null);
@ -639,7 +625,7 @@ s32 cellSaveDataListSave2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf
s32 cellSaveDataListLoad2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList, s32 cellSaveDataListLoad2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList,
PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataListLoad2(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataListLoad2(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, setList, setBuf, funcList, funcStat, funcFile, container, userdata); version, setList, setBuf, funcList, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_LOAD, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_LOAD, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null);
@ -648,7 +634,7 @@ s32 cellSaveDataListLoad2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf
s32 cellSaveDataListSave(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList, s32 cellSaveDataListSave(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList,
PFuncStat funcStat, PFuncFile funcFile, u32 container) PFuncStat funcStat, PFuncFile funcFile, u32 container)
{ {
cellSysutil.warning("cellSaveDataListSave(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", cellSaveData.warning("cellSaveDataListSave(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)",
version, setList, setBuf, funcList, funcStat, funcFile, container); version, setList, setBuf, funcList, funcStat, funcFile, container);
return savedata_op(ppu, SAVEDATA_OP_LIST_SAVE, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_SAVE, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null);
@ -657,7 +643,7 @@ s32 cellSaveDataListSave(PPUThread& ppu, u32 version, PSetList setList, PSetBuf
s32 cellSaveDataListLoad(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList, s32 cellSaveDataListLoad(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncList funcList,
PFuncStat funcStat, PFuncFile funcFile, u32 container) PFuncStat funcStat, PFuncFile funcFile, u32 container)
{ {
cellSysutil.warning("cellSaveDataListLoad(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", cellSaveData.warning("cellSaveDataListLoad(version=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)",
version, setList, setBuf, funcList, funcStat, funcFile, container); version, setList, setBuf, funcList, funcStat, funcFile, container);
return savedata_op(ppu, SAVEDATA_OP_LIST_LOAD, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_LOAD, version, vm::null, 1, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null);
@ -667,7 +653,7 @@ s32 cellSaveDataListLoad(PPUThread& ppu, u32 version, PSetList setList, PSetBuf
s32 cellSaveDataFixedSave2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, s32 cellSaveDataFixedSave2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed,
PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataFixedSave2(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataFixedSave2(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, userdata, 0, vm::null);
@ -676,7 +662,7 @@ s32 cellSaveDataFixedSave2(PPUThread& ppu, u32 version, PSetList setList, PSetBu
s32 cellSaveDataFixedLoad2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, s32 cellSaveDataFixedLoad2(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed,
PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataFixedLoad2(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataFixedLoad2(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_FIXED_LOAD, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_FIXED_LOAD, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, userdata, 0, vm::null);
@ -685,7 +671,7 @@ s32 cellSaveDataFixedLoad2(PPUThread& ppu, u32 version, PSetList setList, PSetBu
s32 cellSaveDataFixedSave(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, s32 cellSaveDataFixedSave(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed,
PFuncStat funcStat, PFuncFile funcFile, u32 container) PFuncStat funcStat, PFuncFile funcFile, u32 container)
{ {
cellSysutil.warning("cellSaveDataFixedSave(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", cellSaveData.warning("cellSaveDataFixedSave(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)",
version, setList, setBuf, funcFixed, funcStat, funcFile, container); version, setList, setBuf, funcFixed, funcStat, funcFile, container);
return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, vm::null, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, vm::null, 0, vm::null);
@ -695,7 +681,7 @@ s32 cellSaveDataFixedSave(PPUThread& ppu, u32 version, PSetList setList, PSetBuf
s32 cellSaveDataFixedLoad(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, s32 cellSaveDataFixedLoad(PPUThread& ppu, u32 version, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed,
PFuncStat funcStat, PFuncFile funcFile, u32 container) PFuncStat funcStat, PFuncFile funcFile, u32 container)
{ {
cellSysutil.warning("cellSaveDataFixedLoad(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", cellSaveData.warning("cellSaveDataFixedLoad(version=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)",
version, setList, setBuf, funcFixed, funcStat, funcFile, container); version, setList, setBuf, funcFixed, funcStat, funcFile, container);
return savedata_op(ppu, SAVEDATA_OP_FIXED_LOAD, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, vm::null, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_FIXED_LOAD, version, vm::null, 1, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 2, vm::null, 0, vm::null);
@ -704,7 +690,7 @@ s32 cellSaveDataFixedLoad(PPUThread& ppu, u32 version, PSetList setList, PSetBuf
s32 cellSaveDataAutoSave2(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, s32 cellSaveDataAutoSave2(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf,
PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataAutoSave2(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataAutoSave2(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); version, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null);
@ -713,7 +699,7 @@ s32 cellSaveDataAutoSave2(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u
s32 cellSaveDataAutoLoad2(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, s32 cellSaveDataAutoLoad2(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf,
PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataAutoLoad2(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataAutoLoad2(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); version, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, userdata, 0, vm::null);
@ -722,7 +708,7 @@ s32 cellSaveDataAutoLoad2(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u
s32 cellSaveDataAutoSave(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, s32 cellSaveDataAutoSave(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf,
PFuncStat funcStat, PFuncFile funcFile, u32 container) PFuncStat funcStat, PFuncFile funcFile, u32 container)
{ {
cellSysutil.warning("cellSaveDataAutoSave(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", cellSaveData.warning("cellSaveDataAutoSave(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)",
version, dirName, errDialog, setBuf, funcStat, funcFile, container); version, dirName, errDialog, setBuf, funcStat, funcFile, container);
return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null);
@ -731,7 +717,7 @@ s32 cellSaveDataAutoSave(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u3
s32 cellSaveDataAutoLoad(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, s32 cellSaveDataAutoLoad(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf,
PFuncStat funcStat, PFuncFile funcFile, u32 container) PFuncStat funcStat, PFuncFile funcFile, u32 container)
{ {
cellSysutil.warning("cellSaveDataAutoLoad(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)", cellSaveData.warning("cellSaveDataAutoLoad(version=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x)",
version, dirName, errDialog, setBuf, funcStat, funcFile, container); version, dirName, errDialog, setBuf, funcStat, funcFile, container);
return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 2, vm::null, 0, vm::null);
@ -739,7 +725,7 @@ s32 cellSaveDataAutoLoad(PPUThread& ppu, u32 version, vm::cptr<char> dirName, u3
s32 cellSaveDataListAutoSave(PPUThread& ppu, u32 version, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataListAutoSave(PPUThread& ppu, u32 version, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataListAutoSave(version=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataListAutoSave(version=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_SAVE, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 0, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_SAVE, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 0, userdata, 0, vm::null);
@ -747,7 +733,7 @@ s32 cellSaveDataListAutoSave(PPUThread& ppu, u32 version, u32 errDialog, PSetLis
s32 cellSaveDataListAutoLoad(PPUThread& ppu, u32 version, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataListAutoLoad(PPUThread& ppu, u32 version, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.warning("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.warning("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_LOAD, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 0, userdata, 0, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_LOAD, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 0, userdata, 0, vm::null);
@ -755,21 +741,21 @@ s32 cellSaveDataListAutoLoad(PPUThread& ppu, u32 version, u32 errDialog, PSetLis
s32 cellSaveDataDelete2(u32 container) s32 cellSaveDataDelete2(u32 container)
{ {
cellSysutil.todo("cellSaveDataDelete2(container=0x%x)", container); cellSaveData.todo("cellSaveDataDelete2(container=0x%x)", container);
return CELL_SAVEDATA_RET_CANCEL; return CELL_SAVEDATA_RET_CANCEL;
} }
s32 cellSaveDataDelete(u32 container) s32 cellSaveDataDelete(u32 container)
{ {
cellSysutil.todo("cellSaveDataDelete(container=0x%x)", container); cellSaveData.todo("cellSaveDataDelete(container=0x%x)", container);
return CELL_SAVEDATA_RET_CANCEL; return CELL_SAVEDATA_RET_CANCEL;
} }
s32 cellSaveDataFixedDelete(PPUThread& ppu, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncDone funcDone, u32 container, vm::ptr<void> userdata) s32 cellSaveDataFixedDelete(PPUThread& ppu, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncDone funcDone, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.todo("cellSaveDataFixedDelete(setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcDone=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.todo("cellSaveDataFixedDelete(setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcDone=*0x%x, container=0x%x, userdata=*0x%x)",
setList, setBuf, funcFixed, funcDone, container, userdata); setList, setBuf, funcFixed, funcDone, container, userdata);
return CELL_OK; return CELL_OK;
@ -777,7 +763,7 @@ s32 cellSaveDataFixedDelete(PPUThread& ppu, PSetList setList, PSetBuf setBuf, PF
s32 cellSaveDataUserListSave(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserListSave(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserListSave(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserListSave(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, setList, setBuf, funcList, funcStat, funcFile, container, userdata); version, userId, setList, setBuf, funcList, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_SAVE, version, vm::null, 0, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_SAVE, version, vm::null, 0, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -785,7 +771,7 @@ s32 cellSaveDataUserListSave(PPUThread& ppu, u32 version, u32 userId, PSetList s
s32 cellSaveDataUserListLoad(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserListLoad(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserListLoad(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserListLoad(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcList=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, setList, setBuf, funcList, funcStat, funcFile, container, userdata); version, userId, setList, setBuf, funcList, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_LOAD, version, vm::null, 0, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_LOAD, version, vm::null, 0, setList, setBuf, funcList, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -793,7 +779,7 @@ s32 cellSaveDataUserListLoad(PPUThread& ppu, u32 version, u32 userId, PSetList s
s32 cellSaveDataUserFixedSave(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserFixedSave(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserFixedSave(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserFixedSave(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, userId, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 0, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_FIXED_SAVE, version, vm::null, 0, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -801,7 +787,7 @@ s32 cellSaveDataUserFixedSave(PPUThread& ppu, u32 version, u32 userId, PSetList
s32 cellSaveDataUserFixedLoad(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserFixedLoad(PPUThread& ppu, u32 version, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserFixedLoad(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserFixedLoad(version=%d, userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, userId, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_FIXED_LOAD, version, vm::null, 0, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_FIXED_LOAD, version, vm::null, 0, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -809,7 +795,7 @@ s32 cellSaveDataUserFixedLoad(PPUThread& ppu, u32 version, u32 userId, PSetList
s32 cellSaveDataUserAutoSave(PPUThread& ppu, u32 version, u32 userId, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserAutoSave(PPUThread& ppu, u32 version, u32 userId, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserAutoSave(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserAutoSave(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_AUTO_SAVE, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -817,7 +803,7 @@ s32 cellSaveDataUserAutoSave(PPUThread& ppu, u32 version, u32 userId, vm::cptr<c
s32 cellSaveDataUserAutoLoad(PPUThread& ppu, u32 version, u32 userId, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserAutoLoad(PPUThread& ppu, u32 version, u32 userId, vm::cptr<char> dirName, u32 errDialog, PSetBuf setBuf, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserAutoLoad(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserAutoLoad(version=%d, userId=%d, dirName=*0x%x, errDialog=%d, setBuf=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata); version, userId, dirName, errDialog, setBuf, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_AUTO_LOAD, version, dirName, errDialog, vm::null, setBuf, vm::null, vm::null, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -825,7 +811,7 @@ s32 cellSaveDataUserAutoLoad(PPUThread& ppu, u32 version, u32 userId, vm::cptr<c
s32 cellSaveDataUserListAutoSave(PPUThread& ppu, u32 version, u32 userId, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserListAutoSave(PPUThread& ppu, u32 version, u32 userId, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserListAutoSave(version=%d, userId=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserListAutoSave(version=%d, userId=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, userId, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_SAVE, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_SAVE, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -833,7 +819,7 @@ s32 cellSaveDataUserListAutoSave(PPUThread& ppu, u32 version, u32 userId, u32 er
s32 cellSaveDataUserListAutoLoad(PPUThread& ppu, u32 version, u32 userId, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserListAutoLoad(PPUThread& ppu, u32 version, u32 userId, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.error("cellSaveDataUserListAutoLoad(version=%d, userId=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.error("cellSaveDataUserListAutoLoad(version=%d, userId=%d, errDialog=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcStat=*0x%x, funcFile=*0x%x, container=0x%x, userdata=*0x%x)",
version, userId, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata); version, userId, errDialog, setList, setBuf, funcFixed, funcStat, funcFile, container, userdata);
return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_LOAD, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null); return savedata_op(ppu, SAVEDATA_OP_LIST_AUTO_LOAD, version, vm::null, errDialog, setList, setBuf, vm::null, funcFixed, funcStat, funcFile, container, 6, userdata, userId, vm::null);
@ -841,7 +827,7 @@ s32 cellSaveDataUserListAutoLoad(PPUThread& ppu, u32 version, u32 userId, u32 er
s32 cellSaveDataUserFixedDelete(PPUThread& ppu, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncDone funcDone, u32 container, vm::ptr<void> userdata) s32 cellSaveDataUserFixedDelete(PPUThread& ppu, u32 userId, PSetList setList, PSetBuf setBuf, PFuncFixed funcFixed, PFuncDone funcDone, u32 container, vm::ptr<void> userdata)
{ {
cellSysutil.todo("cellSaveDataUserFixedDelete(userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcDone=*0x%x, container=0x%x, userdata=*0x%x)", cellSaveData.todo("cellSaveDataUserFixedDelete(userId=%d, setList=*0x%x, setBuf=*0x%x, funcFixed=*0x%x, funcDone=*0x%x, container=0x%x, userdata=*0x%x)",
userId, setList, setBuf, funcFixed, funcDone, container, userdata); userId, setList, setBuf, funcFixed, funcDone, container, userdata);
return CELL_OK; return CELL_OK;
@ -849,7 +835,7 @@ s32 cellSaveDataUserFixedDelete(PPUThread& ppu, u32 userId, PSetList setList, PS
void cellSaveDataEnableOverlay(s32 enable) void cellSaveDataEnableOverlay(s32 enable)
{ {
cellSysutil.error("cellSaveDataEnableOverlay(enable=%d)", enable); cellSaveData.error("cellSaveDataEnableOverlay(enable=%d)", enable);
return; return;
} }
@ -977,7 +963,7 @@ void cellSysutil_SaveData_init()
REG_FUNC(cellSysutil, cellSaveDataAutoSave); REG_FUNC(cellSysutil, cellSaveDataAutoSave);
} }
Module<> cellSaveData("cellSaveData", []() DECLARE(ppu_module_manager::cellSaveData)("cellSaveData", []()
{ {
// libsysutil_savedata functions: // libsysutil_savedata functions:
REG_FUNC(cellSaveData, cellSaveDataUserGetListItem); REG_FUNC(cellSaveData, cellSaveDataUserGetListItem);
@ -994,7 +980,7 @@ Module<> cellSaveData("cellSaveData", []()
REG_FUNC(cellSaveData, cellSaveDataListImport); REG_FUNC(cellSaveData, cellSaveDataListImport);
}); });
Module<> cellMinisSaveData("cellMinisSaveData", []() DECLARE(ppu_module_manager::cellMinisSaveData)("cellMinisSaveData", []()
{ {
// libsysutil_savedata_psp functions: // libsysutil_savedata_psp functions:
//REG_FUNC(cellMinisSaveData, cellMinisSaveDataDelete); // 0x6eb168b3 //REG_FUNC(cellMinisSaveData, cellMinisSaveDataDelete); // 0x6eb168b3

View File

@ -1,10 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellScreenshot.h" #include "cellScreenshot.h"
extern Module<> cellScreenshot; LOG_CHANNEL(cellScreenshot);
s32 cellScreenShotSetParameter() //const CellScreenShotSetParam *param s32 cellScreenShotSetParameter() //const CellScreenShotSetParam *param
{ {
@ -30,10 +30,10 @@ s32 cellScreenShotDisable()
return CELL_OK; return CELL_OK;
} }
Module<> cellScreenshot("cellScreenshot", []() DECLARE(ppu_module_manager::cellScreenShot)("cellScreenShotUtility", []()
{ {
REG_FUNC(cellScreenshot, cellScreenShotSetParameter); REG_FUNC(cellScreenShotUtility, cellScreenShotSetParameter);
REG_FUNC(cellScreenshot, cellScreenShotSetOverlayImage); REG_FUNC(cellScreenShotUtility, cellScreenShotSetOverlayImage);
REG_FUNC(cellScreenshot, cellScreenShotEnable); REG_FUNC(cellScreenShotUtility, cellScreenShotEnable);
REG_FUNC(cellScreenshot, cellScreenShotDisable); REG_FUNC(cellScreenShotUtility, cellScreenShotDisable);
}); });

View File

@ -1,10 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "cellSearch.h" #include "cellSearch.h"
extern Module<> cellSearch; LOG_CHANNEL(cellSearch);
s32 cellSearchInitialize(CellSearchMode mode, u32 container, vm::ptr<CellSearchSystemCallback> func, vm::ptr<u32> userData) s32 cellSearchInitialize(CellSearchMode mode, u32 container, vm::ptr<CellSearchSystemCallback> func, vm::ptr<u32> userData)
{ {
@ -130,26 +130,26 @@ s32 cellSearchEnd()
return CELL_OK; return CELL_OK;
} }
Module<> cellSearch("cellSearch", []() DECLARE(ppu_module_manager::cellSearch)("cellSearchUtility", []()
{ {
REG_FUNC(cellSearch, cellSearchInitialize); REG_FUNC(cellSearchUtility, cellSearchInitialize);
REG_FUNC(cellSearch, cellSearchFinalize); REG_FUNC(cellSearchUtility, cellSearchFinalize);
REG_FUNC(cellSearch, cellSearchStartListSearch); REG_FUNC(cellSearchUtility, cellSearchStartListSearch);
REG_FUNC(cellSearch, cellSearchStartContentSearchInList); REG_FUNC(cellSearchUtility, cellSearchStartContentSearchInList);
REG_FUNC(cellSearch, cellSearchStartContentSearch); REG_FUNC(cellSearchUtility, cellSearchStartContentSearch);
REG_FUNC(cellSearch, cellSearchStartSceneSearchInVideo); REG_FUNC(cellSearchUtility, cellSearchStartSceneSearchInVideo);
REG_FUNC(cellSearch, cellSearchStartSceneSearch); REG_FUNC(cellSearchUtility, cellSearchStartSceneSearch);
REG_FUNC(cellSearch, cellSearchGetContentInfoByOffset); REG_FUNC(cellSearchUtility, cellSearchGetContentInfoByOffset);
REG_FUNC(cellSearch, cellSearchGetContentInfoByContentId); REG_FUNC(cellSearchUtility, cellSearchGetContentInfoByContentId);
REG_FUNC(cellSearch, cellSearchGetOffsetByContentId); REG_FUNC(cellSearchUtility, cellSearchGetOffsetByContentId);
REG_FUNC(cellSearch, cellSearchGetContentIdByOffset); REG_FUNC(cellSearchUtility, cellSearchGetContentIdByOffset);
REG_FUNC(cellSearch, cellSearchGetContentInfoGameComment); REG_FUNC(cellSearchUtility, cellSearchGetContentInfoGameComment);
REG_FUNC(cellSearch, cellSearchGetMusicSelectionContext); REG_FUNC(cellSearchUtility, cellSearchGetMusicSelectionContext);
REG_FUNC(cellSearch, cellSearchGetMusicSelectionContextOfSingleTrack); REG_FUNC(cellSearchUtility, cellSearchGetMusicSelectionContextOfSingleTrack);
REG_FUNC(cellSearch, cellSearchGetContentInfoPath); REG_FUNC(cellSearchUtility, cellSearchGetContentInfoPath);
REG_FUNC(cellSearch, cellSearchGetContentInfoPathMovieThumb); REG_FUNC(cellSearchUtility, cellSearchGetContentInfoPathMovieThumb);
REG_FUNC(cellSearch, cellSearchPrepareFile); REG_FUNC(cellSearchUtility, cellSearchPrepareFile);
REG_FUNC(cellSearch, cellSearchGetContentInfoDeveloperData); REG_FUNC(cellSearchUtility, cellSearchGetContentInfoDeveloperData);
REG_FUNC(cellSearch, cellSearchCancel); REG_FUNC(cellSearchUtility, cellSearchCancel);
REG_FUNC(cellSearch, cellSearchEnd); REG_FUNC(cellSearchUtility, cellSearchEnd);
}); });

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellSheap; LOG_CHANNEL(cellSheap);
// Return Codes // Return Codes
enum enum
@ -121,7 +120,7 @@ s32 cellKeySheapQueueDelete()
return CELL_OK; return CELL_OK;
} }
Module<> cellSheap("cellSheap", []() DECLARE(ppu_module_manager::cellSheap)("cellSheap", []()
{ {
REG_FUNC(cellSheap, cellSheapInitialize); REG_FUNC(cellSheap, cellSheapInitialize);
REG_FUNC(cellSheap, cellSheapAllocate); REG_FUNC(cellSheap, cellSheapAllocate);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellSpudll; LOG_CHANNEL(cellSpudll);
s32 cellSpudllGetImageSize(vm::ptr<u32> psize, vm::cptr<void> so_elf, vm::cptr<struct CellSpudllHandleConfig> config) s32 cellSpudllGetImageSize(vm::ptr<u32> psize, vm::cptr<void> so_elf, vm::cptr<struct CellSpudllHandleConfig> config)
{ {
@ -14,7 +13,7 @@ s32 cellSpudllHandleConfigSetDefaultValues(vm::ptr<struct CellSpudllHandleConfig
throw EXCEPTION(""); throw EXCEPTION("");
} }
Module<> cellSpudll("cellSpudll", []() DECLARE(ppu_module_manager::cellSpudll)("cellSpudll", []()
{ {
REG_FUNC(cellSpudll, cellSpudllGetImageSize); REG_FUNC(cellSpudll, cellSpudllGetImageSize);
REG_FUNC(cellSpudll, cellSpudllHandleConfigSetDefaultValues); REG_FUNC(cellSpudll, cellSpudllHandleConfigSetDefaultValues);

View File

@ -1,28 +1,34 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
#include "Emu/Event.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/SPUThread.h" #include "Emu/Cell/SPUThread.h"
#include "Emu/SysCalls/lv2/sys_sync.h" #include "Emu/Cell/lv2/sys_lwmutex.h"
#include "Emu/SysCalls/lv2/sys_lwmutex.h" #include "Emu/Cell/lv2/sys_lwcond.h"
#include "Emu/SysCalls/lv2/sys_lwcond.h" #include "Emu/Cell/lv2/sys_spu.h"
#include "Emu/SysCalls/lv2/sys_spu.h" #include "Emu/Cell/lv2/sys_ppu_thread.h"
#include "Emu/SysCalls/lv2/sys_ppu_thread.h" #include "Emu/Cell/lv2/sys_memory.h"
#include "Emu/SysCalls/lv2/sys_memory.h" #include "Emu/Cell/lv2/sys_process.h"
#include "Emu/SysCalls/lv2/sys_process.h" #include "Emu/Cell/lv2/sys_semaphore.h"
#include "Emu/SysCalls/lv2/sys_semaphore.h" #include "Emu/Cell/lv2/sys_event.h"
#include "Emu/SysCalls/lv2/sys_event.h"
#include "sysPrxForUser.h" #include "sysPrxForUser.h"
#include "cellSpurs.h" #include "cellSpurs.h"
//---------------------------------------------------------------------------- LOG_CHANNEL(cellSpurs);
// Externs
//----------------------------------------------------------------------------
extern Module<> cellSpurs; // TODO
struct cell_error_t
{
s32 value;
explicit operator bool() const
{
return (value < 0);
}
};
#define CHECK_SUCCESS(expr) if (cell_error_t error{expr}) throw fmt::exception("Failure: %s -> 0x%x" HERE, #expr, error.value)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Function prototypes // Function prototypes
@ -582,7 +588,7 @@ void _spurs::handler_entry(PPUThread& ppu, vm::ptr<CellSpurs> spurs)
if ((spurs->flags1 & SF1_EXIT_IF_NO_WORK) == 0) if ((spurs->flags1 & SF1_EXIT_IF_NO_WORK) == 0)
{ {
CHECK_ASSERTION(spurs->handlerExiting == 1); ASSERT(spurs->handlerExiting == 1);
return sys_ppu_thread_exit(ppu, 0); return sys_ppu_thread_exit(ppu, 0);
} }
@ -645,16 +651,16 @@ s32 _spurs::wakeup_shutdown_completion_waiter(PPUThread& ppu, vm::ptr<CellSpurs>
{ {
wklF->hook(ppu, spurs, wid, wklF->hookArg); wklF->hook(ppu, spurs, wid, wklF->hookArg);
CHECK_ASSERTION(wklEvent->load() & 0x01); ASSERT(wklEvent->load() & 0x01);
CHECK_ASSERTION(wklEvent->load() & 0x02); ASSERT(wklEvent->load() & 0x02);
CHECK_ASSERTION((wklEvent->load() & 0x20) == 0); ASSERT((wklEvent->load() & 0x20) == 0);
*wklEvent |= 0x20; wklEvent->fetch_or(0x20);
} }
s32 rc = CELL_OK; s32 rc = CELL_OK;
if (!wklF->hook || wklEvent->load() & 0x10) if (!wklF->hook || wklEvent->load() & 0x10)
{ {
CHECK_ASSERTION(wklF->x28 == 2); ASSERT(wklF->x28 == 2);
rc = sys_semaphore_post((u32)wklF->sem, 1); rc = sys_semaphore_post((u32)wklF->sem, 1);
} }
@ -665,7 +671,7 @@ void _spurs::event_helper_entry(PPUThread& ppu, vm::ptr<CellSpurs> spurs)
{ {
bool terminate = false; bool terminate = false;
vm::var<sys_event_t[8]> events; vm::var<sys_event_t[]> events(8);
vm::var<u32> count; vm::var<u32> count;
while (!terminate) while (!terminate)
@ -738,7 +744,7 @@ void _spurs::event_helper_entry(PPUThread& ppu, vm::ptr<CellSpurs> spurs)
} }
else else
{ {
CHECK_SUCCESS(data0); throw fmt::exception("data0=0x%x" HERE, data0);
} }
} }
} }
@ -1021,7 +1027,7 @@ s32 _spurs::initialize(PPUThread& ppu, vm::ptr<CellSpurs> spurs, u32 revision, u
// Import SPURS kernel // Import SPURS kernel
spurs->spuImg.type = SYS_SPU_IMAGE_TYPE_USER; spurs->spuImg.type = SYS_SPU_IMAGE_TYPE_USER;
spurs->spuImg.addr = vm::alloc(0x40000, vm::main); spurs->spuImg.segs = { vm::alloc(0x40000, vm::main), vm::addr };
spurs->spuImg.entry_point = isSecond ? CELL_SPURS_KERNEL2_ENTRY_ADDR : CELL_SPURS_KERNEL1_ENTRY_ADDR; spurs->spuImg.entry_point = isSecond ? CELL_SPURS_KERNEL2_ENTRY_ADDR : CELL_SPURS_KERNEL1_ENTRY_ADDR;
spurs->spuImg.nsegs = 1; spurs->spuImg.nsegs = 1;
@ -2111,8 +2117,8 @@ s32 _spurs::add_workload(vm::ptr<CellSpurs> spurs, vm::ptr<u32> wid, vm::cptr<vo
u32 index = wnum & 0xf; u32 index = wnum & 0xf;
if (wnum <= 15) if (wnum <= 15)
{ {
CHECK_ASSERTION((spurs->wklCurrentContention[wnum] & 0xf) == 0); ASSERT((spurs->wklCurrentContention[wnum] & 0xf) == 0);
CHECK_ASSERTION((spurs->wklPendingContention[wnum] & 0xf) == 0); ASSERT((spurs->wklPendingContention[wnum] & 0xf) == 0);
spurs->wklState1[wnum] = 1; spurs->wklState1[wnum] = 1;
spurs->wklStatus1[wnum] = 0; spurs->wklStatus1[wnum] = 0;
spurs->wklEvent1[wnum] = 0; spurs->wklEvent1[wnum] = 0;
@ -2147,8 +2153,8 @@ s32 _spurs::add_workload(vm::ptr<CellSpurs> spurs, vm::ptr<u32> wid, vm::cptr<vo
} }
else else
{ {
CHECK_ASSERTION((spurs->wklCurrentContention[index] & 0xf0) == 0); ASSERT((spurs->wklCurrentContention[index] & 0xf0) == 0);
CHECK_ASSERTION((spurs->wklPendingContention[index] & 0xf0) == 0); ASSERT((spurs->wklPendingContention[index] & 0xf0) == 0);
spurs->wklState2[index] = 1; spurs->wklState2[index] = 1;
spurs->wklStatus2[index] = 0; spurs->wklStatus2[index] = 0;
spurs->wklEvent2[index] = 0; spurs->wklEvent2[index] = 0;
@ -2183,7 +2189,7 @@ s32 _spurs::add_workload(vm::ptr<CellSpurs> spurs, vm::ptr<u32> wid, vm::cptr<vo
v &= ~0xf; v &= ~0xf;
v |= (maxContention > 8 ? 8 : maxContention); v |= (maxContention > 8 ? 8 : maxContention);
}); });
spurs->wklSignal1._and_not(0x8000 >> index); // clear bit in wklFlag1 spurs->wklSignal1.fetch_and(~(0x8000 >> index)); // clear bit in wklFlag1
} }
else else
{ {
@ -2192,7 +2198,7 @@ s32 _spurs::add_workload(vm::ptr<CellSpurs> spurs, vm::ptr<u32> wid, vm::cptr<vo
v &= ~0xf0; v &= ~0xf0;
v |= (maxContention > 8 ? 8 : maxContention) << 4; v |= (maxContention > 8 ? 8 : maxContention) << 4;
}); });
spurs->wklSignal2._and_not(0x8000 >> index); // clear bit in wklFlag2 spurs->wklSignal2.fetch_and(~(0x8000 >> index)); // clear bit in wklFlag2
} }
spurs->wklFlagReceiver.compare_and_swap(wnum, 0xff); spurs->wklFlagReceiver.compare_and_swap(wnum, 0xff);
@ -2227,7 +2233,7 @@ s32 _spurs::add_workload(vm::ptr<CellSpurs> spurs, vm::ptr<u32> wid, vm::cptr<vo
v = mask | (0x80000000u >> wnum); v = mask | (0x80000000u >> wnum);
}); });
CHECK_ASSERTION(res_wkl <= 31); ASSERT(res_wkl <= 31);
spurs->wklState(wnum).exchange(2); spurs->wklState(wnum).exchange(2);
spurs->sysSrvMsgUpdateWorkload.exchange(0xff); spurs->sysSrvMsgUpdateWorkload.exchange(0xff);
spurs->sysSrvMessage.exchange(0xff); spurs->sysSrvMessage.exchange(0xff);
@ -3160,10 +3166,15 @@ s32 cellSpursEventFlagGetTasksetAddress(vm::ptr<CellSpursEventFlag> eventFlag, v
return CELL_SPURS_TASK_ERROR_ALIGN; return CELL_SPURS_TASK_ERROR_ALIGN;
} }
taskset->set(eventFlag->isIwl ? 0u : VM_CAST(eventFlag->addr)); taskset->set(eventFlag->isIwl ? 0u : vm::cast(eventFlag->addr, HERE));
return CELL_OK; return CELL_OK;
} }
static inline s32 SyncErrorToSpursError(const ppu_error_code& res)
{
return res.value < 0 ? 0x80410900 | (res.value & 0xff) : res.value;
}
s32 _cellSpursLFQueueInitialize(vm::ptr<void> pTasksetOrSpurs, vm::ptr<CellSpursLFQueue> pQueue, vm::cptr<void> buffer, u32 size, u32 depth, u32 direction) s32 _cellSpursLFQueueInitialize(vm::ptr<void> pTasksetOrSpurs, vm::ptr<CellSpursLFQueue> pQueue, vm::cptr<void> buffer, u32 size, u32 depth, u32 direction)
{ {
cellSpurs.todo("_cellSpursLFQueueInitialize(pTasksetOrSpurs=*0x%x, pQueue=*0x%x, buffer=*0x%x, size=0x%x, depth=0x%x, direction=%d)", pTasksetOrSpurs, pQueue, buffer, size, depth, direction); cellSpurs.todo("_cellSpursLFQueueInitialize(pTasksetOrSpurs=*0x%x, pQueue=*0x%x, buffer=*0x%x, size=0x%x, depth=0x%x, direction=%d)", pTasksetOrSpurs, pQueue, buffer, size, depth, direction);
@ -4094,7 +4105,7 @@ s32 cellSpursSemaphoreGetTasksetAddress()
return CELL_OK; return CELL_OK;
} }
Module<> cellSpurs("cellSpurs", []() DECLARE(ppu_module_manager::cellSpurs)("cellSpurs", []()
{ {
// Core // Core
REG_FUNC(cellSpurs, cellSpursInitialize); REG_FUNC(cellSpurs, cellSpursInitialize);

View File

@ -500,7 +500,7 @@ struct alignas(128) CellSpurs
u8 xCA; // 0xCA u8 xCA; // 0xCA
u8 xCB; // 0xCB u8 xCB; // 0xCB
struct SrvTraceSyncVar struct alignas(4) SrvTraceSyncVar
{ {
u8 sysSrvTraceInitialised; // 0xCC u8 sysSrvTraceInitialised; // 0xCC
u8 sysSrvNotifyUpdateTraceComplete; // 0xCD u8 sysSrvNotifyUpdateTraceComplete; // 0xCD
@ -539,7 +539,7 @@ struct alignas(128) CellSpurs
atomic_t<u8> handlerExiting; // 0xD66 atomic_t<u8> handlerExiting; // 0xD66
atomic_be_t<u32> enableEH; // 0xD68 atomic_be_t<u32> enableEH; // 0xD68
be_t<u32> exception; // 0xD6C be_t<u32> exception; // 0xD6C
sys_spu_image spuImg; // 0xD70 sys_spu_image_t spuImg; // 0xD70
be_t<u32> flags; // 0xD80 be_t<u32> flags; // 0xD80
be_t<s32> spuPriority; // 0xD84 be_t<s32> spuPriority; // 0xD84
be_t<u32> ppuPriority; // 0xD88 be_t<u32> ppuPriority; // 0xD88
@ -611,7 +611,7 @@ CHECK_SIZE_ALIGN(CellSpursWorkloadAttribute, 512, 8);
struct alignas(128) CellSpursEventFlag struct alignas(128) CellSpursEventFlag
{ {
struct ControlSyncVar struct alignas(8) ControlSyncVar
{ {
be_t<u16> events; // 0x00 Event bits be_t<u16> events; // 0x00 Event bits
be_t<u16> spuTaskPendingRecv; // 0x02 A bit is set to 1 when the condition of the SPU task using the slot are met and back to 0 when the SPU task unblocks be_t<u16> spuTaskPendingRecv; // 0x02 A bit is set to 1 when the condition of the SPU task using the slot are met and back to 0 when the SPU task unblocks
@ -914,8 +914,3 @@ CHECK_SIZE(SpursTasksetContext, 0x900);
class SpursModuleExit class SpursModuleExit
{ {
}; };
inline static s32 SyncErrorToSpursError(s32 res)
{
return res < 0 ? 0x80410900 | (res & 0xff) : res;
}

View File

@ -1,16 +1,14 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/lv2/sys_sync.h" #include "Emu/Cell/lv2/sys_lwmutex.h"
#include "Emu/SysCalls/lv2/sys_lwmutex.h" #include "Emu/Cell/lv2/sys_lwcond.h"
#include "Emu/SysCalls/lv2/sys_lwcond.h" #include "Emu/Cell/lv2/sys_spu.h"
#include "Emu/SysCalls/lv2/sys_spu.h"
#include "cellSpurs.h" #include "cellSpurs.h"
#include "cellSpursJq.h" #include "cellSpursJq.h"
extern Module<> cellSpursJq; LOG_CHANNEL(cellSpursJq);
s32 cellSpursJobQueueAttributeInitialize() s32 cellSpursJobQueueAttributeInitialize()
{ {
@ -390,7 +388,7 @@ s32 cellSpursJobQueueUnsetExceptionEventHandler()
return CELL_OK; return CELL_OK;
} }
Module<> cellSpursJq("cellSpursJq", []() DECLARE(ppu_module_manager::cellSpursJq)("cellSpursJq", []()
{ {
REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeInitialize); REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeInitialize);
REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetMaxGrab); REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetMaxGrab);

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellSsl; LOG_CHANNEL(cellSsl);
s32 cellSslInit() s32 cellSslInit()
{ {
@ -88,7 +87,7 @@ s32 cellSslCertGetMd5Fingerprint()
return CELL_OK; return CELL_OK;
} }
Module<> cellSsl("cellSsl", []() DECLARE(ppu_module_manager::cellSsl)("cellSsl", []()
{ {
REG_FUNC(cellSsl, cellSslInit); REG_FUNC(cellSsl, cellSslInit);
REG_FUNC(cellSsl, cellSslEnd); REG_FUNC(cellSsl, cellSslEnd);

View File

@ -1,8 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Cell/PPUModule.h"
#include "Emu/SysCalls/Modules.h"
extern Module<> cellSysutil; extern _log::channel cellSysutil;
s32 cellStorageDataImportMove() s32 cellStorageDataImportMove()
{ {

Some files were not shown because too many files have changed in this diff Show More