rpcsx/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp

892 lines
28 KiB
C++
Raw Normal View History

#include "stdafx.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/Modules.h"
2014-07-12 09:02:39 +02:00
#include "Emu/DbgCommand.h"
2014-08-23 22:40:04 +02:00
#include "rpcs3/Ini.h"
#include "Emu/FS/vfsFile.h"
2014-08-23 22:40:04 +02:00
#include "Loader/PSF.h"
#include "Emu/Audio/sysutil_audio.h"
2014-08-23 02:16:54 +02:00
#include "Emu/RSX/sysutil_video.h"
2014-08-26 01:55:37 +02:00
#include "Emu/RSX/GSManager.h"
#include "Emu/Audio/AudioManager.h"
#include "Emu/FS/VFS.h"
#include "cellMsgDialog.h"
2014-07-01 00:53:29 +02:00
#include "cellGame.h"
2014-08-23 22:40:04 +02:00
#include "cellSysutil.h"
2014-09-04 19:32:20 +02:00
#include "cellSaveData.h"
2014-09-01 14:47:26 +02:00
typedef void (*CellHddGameStatCallback)(vm::ptr<CellHddGameCBResult> cbResult, vm::ptr<CellHddGameStatGet> get, vm::ptr<CellHddGameStatSet> set);
//void cellSysutil_init();
//Module cellSysutil(0x0015, cellSysutil_init);
2014-07-10 21:07:46 +02:00
Module *cellSysutil = nullptr;
2014-09-01 02:51:48 +02:00
int cellSysutilGetSystemParamInt(int id, vm::ptr<be_t<u32>> value)
{
2014-09-01 02:51:48 +02:00
cellSysutil->Log("cellSysutilGetSystemParamInt(id=0x%x, value_addr=0x%x)", id, value.addr());
switch(id)
{
case CELL_SYSUTIL_SYSTEMPARAM_ID_LANG:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_LANG");
2014-09-01 02:51:48 +02:00
*value = Ini.SysLanguage.GetValue();
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_DATE_FORMAT");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_DATE_FMT_DDMMYYYY;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_TIME_FORMAT");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_TIME_FMT_CLOCK24;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE");
2014-09-01 02:51:48 +02:00
*value = 3;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_SUMMERTIME");
2014-09-01 02:51:48 +02:00
*value = 1;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_GAME_PARENTAL_OFF;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_GAME_PARENTAL_LEVEL0_RESTRICT");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_GAME_PARENTAL_LEVEL0_RESTRICT_OFF;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USER_HAS_NP_ACCOUNT");
2014-09-01 02:51:48 +02:00
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CAMERA_PLFREQ");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_CAMERA_PLFREQ_DISABLED;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_RUMBLE");
2014-09-01 02:51:48 +02:00
*value = CELL_SYSUTIL_PAD_RUMBLE_OFF;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_KEYBOARD_TYPE");
2014-09-01 02:51:48 +02:00
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_JAPANESE_KEYBOARD_ENTRY_METHOD");
2014-09-01 02:51:48 +02:00
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_CHINESE_KEYBOARD_ENTRY_METHOD");
2014-09-01 02:51:48 +02:00
*value = 0;
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF:
cellSysutil->Warning("cellSysutilGetSystemParamInt: CELL_SYSUTIL_SYSTEMPARAM_ID_PAD_AUTOOFF");
2014-09-01 02:51:48 +02:00
*value = 0;
break;
default:
return CELL_EINVAL;
}
return CELL_OK;
}
int cellSysutilGetSystemParamString(s32 id, vm::ptr<char> buf, u32 bufsize)
{
cellSysutil->Log("cellSysutilGetSystemParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.addr(), bufsize);
memset(buf.get_ptr(), 0, bufsize);
switch(id)
{
case CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME:
cellSysutil->Warning("cellSysutilGetSystemParamString: CELL_SYSUTIL_SYSTEMPARAM_ID_NICKNAME");
memcpy(buf.get_ptr(), "Unknown", 8); // for example
break;
case CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME:
cellSysutil->Warning("cellSysutilGetSystemParamString: CELL_SYSUTIL_SYSTEMPARAM_ID_CURRENT_USERNAME");
memcpy(buf.get_ptr(), "Unknown", 8);
break;
default:
return CELL_EINVAL;
}
return CELL_OK;
}
2014-09-03 18:33:30 +02:00
int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideoOutState> state)
{
2014-09-03 18:33:30 +02:00
cellSysutil->Log("cellVideoOutGetState(videoOut=0x%x, deviceIndex=0x%x, state_addr=0x%x)", videoOut, deviceIndex, state.addr());
if(deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;
switch(videoOut)
{
2014-09-03 18:33:30 +02:00
case CELL_VIDEO_OUT_PRIMARY:
state->state = Emu.GetGSManager().GetState();
state->colorSpace = Emu.GetGSManager().GetColorSpace();
state->displayMode.resolutionId = Emu.GetGSManager().GetInfo().mode.resolutionId;
state->displayMode.scanMode = Emu.GetGSManager().GetInfo().mode.scanMode;
state->displayMode.conversion = Emu.GetGSManager().GetInfo().mode.conversion;
state->displayMode.aspect = Emu.GetGSManager().GetInfo().mode.aspect;
state->displayMode.refreshRates = Emu.GetGSManager().GetInfo().mode.refreshRates;
return CELL_VIDEO_OUT_SUCCEEDED;
2014-09-03 18:33:30 +02:00
case CELL_VIDEO_OUT_SECONDARY:
2014-09-03 19:09:10 +02:00
*state = { CELL_VIDEO_OUT_OUTPUT_STATE_DISABLED }; // ???
return CELL_VIDEO_OUT_SUCCEEDED;
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
2014-09-02 03:05:13 +02:00
int cellVideoOutGetResolution(u32 resolutionId, vm::ptr<CellVideoOutResolution> resolution)
{
cellSysutil->Log("cellVideoOutGetResolution(resolutionId=%d, resolution_addr=0x%x)",
2014-09-02 03:05:13 +02:00
resolutionId, resolution.addr());
u32 num = ResolutionIdToNum(resolutionId);
if(!num)
return CELL_EINVAL;
resolution->width = ResolutionTable[num].width;
resolution->height = ResolutionTable[num].height;
return CELL_VIDEO_OUT_SUCCEEDED;
}
s32 cellVideoOutConfigure(u32 videoOut, u32 config_addr, u32 option_addr, u32 waitForEvent)
{
cellSysutil->Warning("cellVideoOutConfigure(videoOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=0x%x)",
videoOut, config_addr, option_addr, waitForEvent);
CellVideoOutConfiguration& config = (CellVideoOutConfiguration&)Memory[config_addr];
switch(videoOut)
{
case CELL_VIDEO_OUT_PRIMARY:
if(config.resolutionId)
{
Emu.GetGSManager().GetInfo().mode.resolutionId = config.resolutionId;
}
Emu.GetGSManager().GetInfo().mode.format = config.format;
if(config.aspect)
{
Emu.GetGSManager().GetInfo().mode.aspect = config.aspect;
}
if(config.pitch)
{
2014-09-03 18:33:30 +02:00
Emu.GetGSManager().GetInfo().mode.pitch = config.pitch;
}
return CELL_VIDEO_OUT_SUCCEEDED;
case CELL_VIDEO_OUT_SECONDARY:
return CELL_VIDEO_OUT_SUCCEEDED;
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
2014-09-03 18:33:30 +02:00
int cellVideoOutGetConfiguration(u32 videoOut, vm::ptr<CellVideoOutConfiguration> config, vm::ptr<CellVideoOutOption> option)
{
cellSysutil->Warning("cellVideoOutGetConfiguration(videoOut=%d, config_addr=0x%x, option_addr=0x%x)",
2014-09-03 18:33:30 +02:00
videoOut, config.addr(), option.addr());
2014-09-03 19:09:10 +02:00
if (option) *option = {};
switch(videoOut)
{
case CELL_VIDEO_OUT_PRIMARY:
2014-09-03 18:33:30 +02:00
config->resolutionId = Emu.GetGSManager().GetInfo().mode.resolutionId;
config->format = Emu.GetGSManager().GetInfo().mode.format;
config->aspect = Emu.GetGSManager().GetInfo().mode.aspect;
2014-09-03 19:09:10 +02:00
*config->reserved = {};
2014-09-03 18:33:30 +02:00
config->pitch = Emu.GetGSManager().GetInfo().mode.pitch;
return CELL_VIDEO_OUT_SUCCEEDED;
case CELL_VIDEO_OUT_SECONDARY:
2014-09-03 19:09:10 +02:00
*config = {}; // ???
return CELL_VIDEO_OUT_SUCCEEDED;
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
2014-09-02 03:05:13 +02:00
int cellVideoOutGetDeviceInfo(u32 videoOut, u32 deviceIndex, vm::ptr<CellVideoOutDeviceInfo> info)
{
cellSysutil->Warning("cellVideoOutGetDeviceInfo(videoOut=%u, deviceIndex=%u, info_addr=0x%x)",
2014-09-02 03:05:13 +02:00
videoOut, deviceIndex, info.addr());
if(deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;
// Use standard dummy values for now.
info->portType = CELL_VIDEO_OUT_PORT_HDMI;
info->colorSpace = Emu.GetGSManager().GetColorSpace();
info->latency = 1000;
info->availableModeCount = 1;
info->state = CELL_VIDEO_OUT_DEVICE_STATE_AVAILABLE;
info->rgbOutputRange = 1;
info->colorInfo.blueX = 0xFFFF;
info->colorInfo.blueY = 0xFFFF;
info->colorInfo.greenX = 0xFFFF;
info->colorInfo.greenY = 0xFFFF;
info->colorInfo.redX = 0xFFFF;
info->colorInfo.redY = 0xFFFF;
info->colorInfo.whiteX = 0xFFFF;
info->colorInfo.whiteY = 0xFFFF;
info->colorInfo.gamma = 100;
info->availableModes[0].aspect = 0;
info->availableModes[0].conversion = 0;
info->availableModes[0].refreshRates = 0xF;
info->availableModes[0].resolutionId = 1;
info->availableModes[0].scanMode = 0;
return CELL_OK;
}
int cellVideoOutGetNumberOfDevice(u32 videoOut)
{
cellSysutil->Warning("cellVideoOutGetNumberOfDevice(videoOut=%d)", videoOut);
switch(videoOut)
{
case CELL_VIDEO_OUT_PRIMARY: return 1;
case CELL_VIDEO_OUT_SECONDARY: return 0;
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
int cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, u32 aspect, u32 option)
{
cellSysutil->Warning("cellVideoOutGetResolutionAvailability(videoOut=%d, resolutionId=0x%x, option_addr=0x%x, aspect=0x%x, option=0x%x)",
videoOut, resolutionId, aspect, option);
if(!ResolutionIdToNum(resolutionId))
{
return CELL_EINVAL;
}
switch(videoOut)
{
case CELL_VIDEO_OUT_PRIMARY: return 1;
case CELL_VIDEO_OUT_SECONDARY: return 0;
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
}
int cellSysutilCheckCallback()
{
cellSysutil->Log("cellSysutilCheckCallback()");
2014-02-15 22:16:35 +01:00
Emu.GetCallbackManager().m_exit_callback.Check();
CPUThread& thr = Emu.GetCallbackThread();
2014-07-07 19:22:36 +02:00
while (thr.IsAlive())
2014-02-15 22:16:35 +01:00
{
2014-07-12 09:02:39 +02:00
std::this_thread::sleep_for(std::chrono::milliseconds(1));
2014-02-16 16:23:58 +01:00
if (Emu.IsStopped())
{
2014-08-23 22:40:04 +02:00
cellSysutil->Warning("cellSysutilCheckCallback() aborted");
2014-02-16 16:23:58 +01:00
break;
}
2014-02-15 22:16:35 +01:00
}
return CELL_OK;
}
int cellSysutilRegisterCallback(int slot, u64 func_addr, u64 userdata)
{
cellSysutil->Warning("cellSysutilRegisterCallback(slot=%d, func_addr=0x%llx, userdata=0x%llx)", slot, func_addr, userdata);
2014-02-15 22:16:35 +01:00
Emu.GetCallbackManager().m_exit_callback.Register(slot, func_addr, userdata);
SendDbgCommand(DID_REGISTRED_CALLBACK);
return CELL_OK;
}
int cellSysutilUnregisterCallback(int slot)
{
cellSysutil->Warning("cellSysutilUnregisterCallback(slot=%d)", slot);
2014-02-15 22:16:35 +01:00
Emu.GetCallbackManager().m_exit_callback.Unregister(slot);
SendDbgCommand(DID_UNREGISTRED_CALLBACK);
return CELL_OK;
}
int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
{
cellSysutil->Warning("cellAudioOutGetSoundAvailability(audioOut=%d, type=%d, fs=0x%x, option=%d)",
2014-02-14 21:08:02 +01:00
audioOut, type, fs, option);
option = 0;
2014-04-12 12:27:27 +02:00
int available = 2; // should be at least 2
2014-02-14 21:08:02 +01:00
switch(fs)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_FS_32KHZ:
case CELL_AUDIO_OUT_FS_44KHZ:
case CELL_AUDIO_OUT_FS_48KHZ:
case CELL_AUDIO_OUT_FS_88KHZ:
case CELL_AUDIO_OUT_FS_96KHZ:
case CELL_AUDIO_OUT_FS_176KHZ:
case CELL_AUDIO_OUT_FS_192KHZ:
break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(type)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
2014-09-03 18:33:30 +02:00
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(audioOut)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_PRIMARY: return available;
case CELL_AUDIO_OUT_SECONDARY: return 0;
}
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION;
}
int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u32 option)
{
cellSysutil->Warning("cellAudioOutGetSoundAvailability2(audioOut=%d, type=%d, fs=0x%x, ch=%d, option=%d)",
2014-02-14 21:08:02 +01:00
audioOut, type, fs, ch, option);
option = 0;
2014-04-12 12:27:27 +02:00
int available = 2; // should be at least 2
2014-02-14 21:08:02 +01:00
switch(fs)
{
case CELL_AUDIO_OUT_FS_32KHZ:
case CELL_AUDIO_OUT_FS_44KHZ:
case CELL_AUDIO_OUT_FS_48KHZ:
case CELL_AUDIO_OUT_FS_88KHZ:
case CELL_AUDIO_OUT_FS_96KHZ:
case CELL_AUDIO_OUT_FS_176KHZ:
case CELL_AUDIO_OUT_FS_192KHZ:
break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(ch)
{
2014-02-14 21:08:02 +01:00
case 2: break;
case 6: available = 0; break;
case 8: available = 0; break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(type)
{
2014-02-14 21:08:02 +01:00
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(audioOut)
{
2014-02-14 21:08:02 +01:00
case CELL_AUDIO_OUT_PRIMARY: return available;
case CELL_AUDIO_OUT_SECONDARY: return 0;
}
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION;
}
2014-09-03 18:33:30 +02:00
int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutState> state)
{
2014-09-03 18:33:30 +02:00
cellSysutil->Warning("cellAudioOutGetState(audioOut=0x%x, deviceIndex=0x%x, state_addr=0x%x)", audioOut, deviceIndex, state.addr());
switch(audioOut)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_PRIMARY:
state->state = Emu.GetAudioManager().GetState();
state->encoder = Emu.GetAudioManager().GetInfo().mode.encoder;
2014-09-03 19:09:10 +02:00
*state->reserved = {};
2014-09-03 18:33:30 +02:00
state->downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer;
state->soundMode.type = Emu.GetAudioManager().GetInfo().mode.type;
state->soundMode.channel = Emu.GetAudioManager().GetInfo().mode.channel;
state->soundMode.fs = Emu.GetAudioManager().GetInfo().mode.fs;
state->soundMode.reserved = 0;
state->soundMode.layout = Emu.GetAudioManager().GetInfo().mode.layout;
return CELL_AUDIO_OUT_SUCCEEDED;
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_SECONDARY:
2014-09-03 19:09:10 +02:00
*state = { CELL_AUDIO_OUT_OUTPUT_STATE_DISABLED };
return CELL_AUDIO_OUT_SUCCEEDED;
}
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
2014-09-02 03:05:13 +02:00
int cellAudioOutConfigure(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option, u32 waitForEvent)
{
2014-09-03 18:33:30 +02:00
cellSysutil->Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=%d)",
2014-09-02 03:05:13 +02:00
audioOut, config.addr(), option.addr(), waitForEvent);
switch(audioOut)
{
case CELL_AUDIO_OUT_PRIMARY:
2014-02-14 21:08:02 +01:00
if (config->channel)
{
2014-02-14 21:08:02 +01:00
Emu.GetAudioManager().GetInfo().mode.channel = config->channel;
}
2014-02-14 21:08:02 +01:00
Emu.GetAudioManager().GetInfo().mode.encoder = config->encoder;
2014-02-14 21:08:02 +01:00
if(config->downMixer)
{
2014-02-14 21:08:02 +01:00
Emu.GetAudioManager().GetInfo().mode.downMixer = config->downMixer;
}
return CELL_AUDIO_OUT_SUCCEEDED;
case CELL_AUDIO_OUT_SECONDARY:
return CELL_AUDIO_OUT_SUCCEEDED;
}
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
2014-09-03 18:33:30 +02:00
int cellAudioOutGetConfiguration(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option)
{
2014-09-03 18:33:30 +02:00
cellSysutil->Warning("cellAudioOutGetConfiguration(audioOut=%d, config_addr=0x%x, option_addr=0x%x)", audioOut, config.addr(), option.addr());
2014-09-03 19:09:10 +02:00
if (option) *option = {};
switch(audioOut)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_PRIMARY:
config->channel = Emu.GetAudioManager().GetInfo().mode.channel;
config->encoder = Emu.GetAudioManager().GetInfo().mode.encoder;
2014-09-03 19:09:10 +02:00
*config->reserved = {};
2014-09-03 18:33:30 +02:00
config->downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer;
return CELL_AUDIO_OUT_SUCCEEDED;
case CELL_AUDIO_OUT_SECONDARY:
2014-09-03 19:09:10 +02:00
*config = {};
return CELL_AUDIO_OUT_SUCCEEDED;
}
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
int cellAudioOutGetNumberOfDevice(u32 audioOut)
{
2014-09-03 18:33:30 +02:00
cellSysutil->Warning("cellAudioOutGetNumberOfDevice(audioOut=%d)", audioOut);
switch(audioOut)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_PRIMARY: return 1;
case CELL_AUDIO_OUT_SECONDARY: return 0;
}
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
2014-09-02 03:05:13 +02:00
int cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutDeviceInfo> info)
{
2014-09-03 18:33:30 +02:00
cellSysutil->Todo("cellAudioOutGetDeviceInfo(audioOut=%d, deviceIndex=%d, info_addr=0x%x)", audioOut, deviceIndex, info.addr());
if(deviceIndex) return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND;
info->portType = CELL_AUDIO_OUT_PORT_HDMI;
info->availableModeCount = 1;
info->state = CELL_AUDIO_OUT_DEVICE_STATE_AVAILABLE;
info->latency = 1000;
info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
info->availableModes[0].channel = CELL_AUDIO_OUT_CHNUM_2;
info->availableModes[0].fs = CELL_AUDIO_OUT_FS_48KHZ;
info->availableModes[0].layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_2CH;
return CELL_AUDIO_OUT_SUCCEEDED;
}
int cellAudioOutSetCopyControl(u32 audioOut, u32 control)
{
cellSysutil->Warning("cellAudioOutSetCopyControl(audioOut=%d,control=%d)",audioOut,control);
switch(audioOut)
{
2014-09-03 18:33:30 +02:00
case CELL_AUDIO_OUT_PRIMARY:
case CELL_AUDIO_OUT_SECONDARY:
break;
2014-09-03 18:33:30 +02:00
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
switch(control)
{
case CELL_AUDIO_OUT_COPY_CONTROL_COPY_FREE:
case CELL_AUDIO_OUT_COPY_CONTROL_COPY_ONCE:
case CELL_AUDIO_OUT_COPY_CONTROL_COPY_NEVER:
break;
default: return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
}
return CELL_AUDIO_OUT_SUCCEEDED;
}
typedef struct{
char cacheId[CELL_SYSCACHE_ID_SIZE];
char getCachePath[CELL_SYSCACHE_PATH_MAX];
2014-09-02 03:05:13 +02:00
vm::ptr<void> reserved;
} CellSysCacheParam;
//class WxDirDeleteTraverser : public wxDirTraverser
//{
//public:
// virtual wxDirTraverseResult OnFile(const wxString& filename)
// {
// if (!wxRemoveFile(filename)){
// cellSysutil->Error("Couldn't delete File: %s", fmt::ToUTF8(filename).c_str());
// }
// return wxDIR_CONTINUE;
// }
// virtual wxDirTraverseResult OnDir(const wxString& dirname)
// {
// wxDir dir(dirname);
// dir.Traverse(*this);
// if (!wxRmDir(dirname)){
// //this get triggered a few times while clearing folders
// //but if this gets reimplented we should probably warn
// //if directories can't be removed
// }
// return wxDIR_CONTINUE;
// }
//};
int cellSysCacheClear(void)
{
2014-08-05 16:06:40 +02:00
cellSysutil->Warning("cellSysCacheClear()");
//if some software expects CELL_SYSCACHE_ERROR_NOTMOUNTED we need to check whether
//it was mounted before, for that we would need to save the state which I don't know
//where to put
std::string localPath;
Emu.GetVFS().GetDevice(std::string("/dev_hdd1/cache/"), localPath);
//TODO: implement
//if (rIsDir(localPath)){
// WxDirDeleteTraverser deleter;
// wxString f = wxFindFirstFile(fmt::FromUTF8(localPath+"\\*"),wxDIR);
// while (!f.empty())
// {
// wxDir dir(f);
// dir.Traverse(deleter);
// f = wxFindNextFile();
// }
// return CELL_SYSCACHE_RET_OK_CLEARED;
//}
//else{
// return CELL_SYSCACHE_ERROR_ACCESS_ERROR;
//}
return CELL_SYSCACHE_RET_OK_CLEARED;
}
2014-09-02 03:05:13 +02:00
int cellSysCacheMount(vm::ptr<CellSysCacheParam> param)
{
2014-09-02 03:05:13 +02:00
cellSysutil->Warning("cellSysCacheMount(param_addr=0x%x)", param.addr());
2014-08-05 16:06:40 +02:00
//TODO: implement
char id[CELL_SYSCACHE_ID_SIZE];
strncpy(id, param->cacheId, CELL_SYSCACHE_ID_SIZE);
strncpy(param->getCachePath, ("/dev_hdd1/cache/" + std::string(id) + "/").c_str(), CELL_SYSCACHE_PATH_MAX);
param->getCachePath[CELL_SYSCACHE_PATH_MAX - 1] = '\0';
Emu.GetVFS().CreateDir(std::string(param->getCachePath));
return CELL_SYSCACHE_RET_OK_RELAYED;
}
2014-09-04 19:32:20 +02:00
int cellHddGameCheck(u32 version, vm::ptr<const char> dirName, u32 errDialog, vm::ptr<CellHddGameStatCallback> funcStat, u32 container)
{
2014-09-04 19:32:20 +02:00
cellSysutil->Warning("cellHddGameCheck(version=%d, dirName_addr=0x%x, errDialog=%d, funcStat_addr=0x%x, container=%d)",
version, dirName.addr(), errDialog, funcStat.addr(), container);
2014-09-04 19:32:20 +02:00
std::string dir = dirName.get_ptr();
if (dir.size() != 9)
return CELL_HDDGAME_ERROR_PARAM;
vm::var<CellHddGameSystemFileParam> param;
vm::var<CellHddGameCBResult> result;
vm::var<CellHddGameStatGet> get;
vm::var<CellHddGameStatSet> set;
get->hddFreeSizeKB = 40 * 1024 * 1024; // 40 GB, TODO: Use the free space of the computer's HDD where RPCS3 is being run.
get->isNewData = CELL_HDDGAME_ISNEWDATA_EXIST;
get->sysSizeKB = 0; // TODO
2014-03-21 15:07:05 +01:00
get->st_atime__ = 0; // TODO
get->st_ctime__ = 0; // TODO
get->st_mtime__ = 0; // TODO
get->sizeKB = CELL_HDDGAME_SIZEKB_NOTCALC;
2014-09-04 19:32:20 +02:00
memcpy(get->contentInfoPath, ("/dev_hdd0/game/" + dir).c_str(), CELL_HDDGAME_PATH_MAX);
memcpy(get->hddGamePath, ("/dev_hdd0/game/" + dir + "/USRDIR").c_str(), CELL_HDDGAME_PATH_MAX);
2014-09-04 19:32:20 +02:00
if (!Emu.GetVFS().ExistsDir(("/dev_hdd0/game/" + dir).c_str()))
{
get->isNewData = CELL_HDDGAME_ISNEWDATA_NODIR;
}
else
{
// TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else)
2014-09-04 19:32:20 +02:00
vfsFile f(("/dev_hdd0/game/" + dir + "/PARAM.SFO").c_str());
PSFLoader psf(f);
if (!psf.Load(false)) {
return CELL_HDDGAME_ERROR_BROKEN;
}
get->getParam.parentalLevel = psf.GetInteger("PARENTAL_LEVEL");
get->getParam.attribute = psf.GetInteger("ATTRIBUTE");
get->getParam.resolution = psf.GetInteger("RESOLUTION");
get->getParam.soundFormat = psf.GetInteger("SOUND_FORMAT");
std::string title = psf.GetString("TITLE");
2014-09-04 19:32:20 +02:00
strcpy_trunc(get->getParam.title, title);
std::string app_ver = psf.GetString("APP_VER");
2014-09-04 19:32:20 +02:00
strcpy_trunc(get->getParam.dataVersion, app_ver);
strcpy_trunc(get->getParam.titleId, dir);
for (u32 i=0; i<CELL_HDDGAME_SYSP_LANGUAGE_NUM; i++) {
char key [16];
sprintf(key, "TITLE_%02d", i);
title = psf.GetString(key);
2014-09-04 19:32:20 +02:00
strcpy_trunc(get->getParam.titleLang[i], title);
}
}
// TODO ?
2014-09-01 14:47:26 +02:00
funcStat(result, get, set);
if (result->result != CELL_HDDGAME_CBRESULT_OK &&
result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL)
return CELL_HDDGAME_ERROR_CBRESULT;
// TODO ?
return CELL_OK;
}
2014-06-27 13:11:56 +02:00
bool bgm_playback_enabled = true;
int cellSysutilEnableBgmPlayback()
{
cellSysutil->Warning("cellSysutilEnableBgmPlayback()");
2014-06-27 13:11:56 +02:00
// TODO
bgm_playback_enabled = true;
return CELL_OK;
}
2014-09-02 03:05:13 +02:00
int cellSysutilEnableBgmPlaybackEx(vm::ptr<CellSysutilBgmPlaybackExtraParam> param)
{
2014-09-02 03:05:13 +02:00
cellSysutil->Warning("cellSysutilEnableBgmPlaybackEx(param_addr=0x%x)", param.addr());
2014-06-27 13:11:56 +02:00
// TODO
bgm_playback_enabled = true;
return CELL_OK;
}
int cellSysutilDisableBgmPlayback()
{
cellSysutil->Warning("cellSysutilDisableBgmPlayback()");
2014-06-27 13:11:56 +02:00
// TODO
bgm_playback_enabled = false;
return CELL_OK;
}
2014-09-02 03:05:13 +02:00
int cellSysutilDisableBgmPlaybackEx(vm::ptr<CellSysutilBgmPlaybackExtraParam> param)
{
2014-09-02 03:05:13 +02:00
cellSysutil->Warning("cellSysutilDisableBgmPlaybackEx(param_addr=0x%x)", param.addr());
2014-06-27 13:11:56 +02:00
// TODO
bgm_playback_enabled = false;
return CELL_OK;
}
2014-09-02 03:05:13 +02:00
int cellSysutilGetBgmPlaybackStatus(vm::ptr<CellSysutilBgmPlaybackStatus> status)
{
2014-09-02 03:05:13 +02:00
cellSysutil->Log("cellSysutilGetBgmPlaybackStatus(status_addr=0x%x)", status.addr());
// TODO
2014-06-27 13:11:56 +02:00
status->playerState = CELL_SYSUTIL_BGMPLAYBACK_STATUS_STOP;
status->enableState = bgm_playback_enabled ? CELL_SYSUTIL_BGMPLAYBACK_STATUS_ENABLE : CELL_SYSUTIL_BGMPLAYBACK_STATUS_DISABLE;
status->currentFadeRatio = 0; // current volume ratio (0%)
memset(status->contentId, 0, sizeof(status->contentId));
2014-06-27 13:11:56 +02:00
memset(status->reserved, 0, sizeof(status->reserved));
return CELL_OK;
}
2014-09-02 03:05:13 +02:00
int cellSysutilGetBgmPlaybackStatus2(vm::ptr<CellSysutilBgmPlaybackStatus2> status2)
{
2014-09-02 03:05:13 +02:00
cellSysutil->Log("cellSysutilGetBgmPlaybackStatus2(status2_addr=0x%x)", status2.addr());
// TODO
2014-06-27 13:11:56 +02:00
status2->playerState = CELL_SYSUTIL_BGMPLAYBACK_STATUS_STOP;
memset(status2->reserved, 0, sizeof(status2->reserved));
return CELL_OK;
}
int cellWebBrowserEstimate2(const vm::ptr<const CellWebBrowserConfig2> config, vm::ptr<be_t<u32>> memSize)
{
cellSysutil->Warning("cellWebBrowserEstimate2(config_addr=0x%x, memSize_addr=0x%x)", config.addr(), memSize.addr());
2014-08-05 16:06:40 +02:00
// TODO: When cellWebBrowser stuff is implemented, change this to some real
// needed memory buffer size.
*memSize = 1024 * 1024 * 1; // 1 MB
return CELL_OK;
}
extern int cellGameDataCheckCreate2(u32 version, vm::ptr<const char> dirName, u32 errDialog,
2014-09-01 14:47:26 +02:00
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container);
2014-07-01 00:53:29 +02:00
extern int cellGameDataCheckCreate(u32 version, vm::ptr<const char> dirName, u32 errDialog,
2014-09-01 14:47:26 +02:00
vm::ptr<void(*)(vm::ptr<CellGameDataCBResult> cbResult, vm::ptr<CellGameDataStatGet> get, vm::ptr<CellGameDataStatSet> set)> funcStat, u32 container);
2014-07-01 00:53:29 +02:00
void cellSysutil_init()
{
cellSysutil->AddFunc(0x40e895d3, cellSysutilGetSystemParamInt);
cellSysutil->AddFunc(0x938013a0, cellSysutilGetSystemParamString);
cellSysutil->AddFunc(0x887572d5, cellVideoOutGetState);
cellSysutil->AddFunc(0xe558748d, cellVideoOutGetResolution);
cellSysutil->AddFunc(0x0bae8772, cellVideoOutConfigure);
cellSysutil->AddFunc(0x15b0b0cd, cellVideoOutGetConfiguration);
cellSysutil->AddFunc(0x1e930eef, cellVideoOutGetDeviceInfo);
cellSysutil->AddFunc(0x75bbb672, cellVideoOutGetNumberOfDevice);
cellSysutil->AddFunc(0xa322db75, cellVideoOutGetResolutionAvailability);
cellSysutil->AddFunc(0x189a74da, cellSysutilCheckCallback);
cellSysutil->AddFunc(0x9d98afa0, cellSysutilRegisterCallback);
cellSysutil->AddFunc(0x02ff3c1b, cellSysutilUnregisterCallback);
cellSysutil->AddFunc(0x7603d3db, cellMsgDialogOpen2);
cellSysutil->AddFunc(0x3e22cb4b, cellMsgDialogOpenErrorCode);
cellSysutil->AddFunc(0x9d6af72a, cellMsgDialogProgressBarSetMsg);
cellSysutil->AddFunc(0x7bc2c8a8, cellMsgDialogProgressBarReset);
cellSysutil->AddFunc(0x94862702, cellMsgDialogProgressBarInc);
cellSysutil->AddFunc(0x20543730, cellMsgDialogClose);
cellSysutil->AddFunc(0x62b0f803, cellMsgDialogAbort);
cellSysutil->AddFunc(0xf4e3caa0, cellAudioOutGetState);
cellSysutil->AddFunc(0x4692ab35, cellAudioOutConfigure);
cellSysutil->AddFunc(0xc01b4e7c, cellAudioOutGetSoundAvailability);
cellSysutil->AddFunc(0x2beac488, cellAudioOutGetSoundAvailability2);
cellSysutil->AddFunc(0x7663e368, cellAudioOutGetDeviceInfo);
cellSysutil->AddFunc(0xe5e2b09d, cellAudioOutGetNumberOfDevice);
cellSysutil->AddFunc(0xed5d96af, cellAudioOutGetConfiguration);
cellSysutil->AddFunc(0xc96e89e9, cellAudioOutSetCopyControl);
cellSysutil->AddFunc(0xa11552f6, cellSysutilGetBgmPlaybackStatus);
cellSysutil->AddFunc(0x6cfd856f, cellSysutilGetBgmPlaybackStatus2);
cellSysutil->AddFunc(0x220894e3, cellSysutilEnableBgmPlayback);
cellSysutil->AddFunc(0xac58ad2b, cellSysutilEnableBgmPlaybackEx);
cellSysutil->AddFunc(0xcfdd8e87, cellSysutilDisableBgmPlayback);
cellSysutil->AddFunc(0xa36335a5, cellSysutilDisableBgmPlaybackEx);
cellSysutil->AddFunc(0x1e7bff94, cellSysCacheMount);
cellSysutil->AddFunc(0x744c1544, cellSysCacheClear);
cellSysutil->AddFunc(0x9117df20, cellHddGameCheck);
//cellSysutil->AddFunc(0x4bdec82a, cellHddGameCheck2);
//cellSysutil->AddFunc(0xf82e2ef7, cellHddGameGetSizeKB);
//cellSysutil->AddFunc(0x9ca9ffa7, cellHddGameSetSystemVer);
//cellSysutil->AddFunc(0xafd605b3, cellHddGameExitBroken);
//cellSysutil_SaveData
//cellSysutil->AddFunc(0x04c06fc2, cellSaveDataGetListItem);
//cellSysutil->AddFunc(0x273d116a, cellSaveDataUserListExport);
//cellSysutil->AddFunc(0x27cb8bc2, cellSaveDataListDelete);
//cellSysutil->AddFunc(0x39d6ee43, cellSaveDataUserListImport);
//cellSysutil->AddFunc(0x46a2d878, cellSaveDataFixedExport);
//cellSysutil->AddFunc(0x491cc554, cellSaveDataListExport);
//cellSysutil->AddFunc(0x52541151, cellSaveDataFixedImport);
//cellSysutil->AddFunc(0x529231b0, cellSaveDataUserFixedImport);
//cellSysutil->AddFunc(0x6b4e0de6, cellSaveDataListImport);
//cellSysutil->AddFunc(0x7048a9ba, cellSaveDataUserListDelete);
//cellSysutil->AddFunc(0x95ae2cde, cellSaveDataUserFixedExport);
//cellSysutil->AddFunc(0xf6482036, cellSaveDataUserGetListItem);
cellSysutil->AddFunc(0x2de0d663, cellSaveDataListSave2);
cellSysutil->AddFunc(0x1dfbfdd6, cellSaveDataListLoad2);
cellSysutil->AddFunc(0x2aae9ef5, cellSaveDataFixedSave2);
cellSysutil->AddFunc(0x2a8eada2, cellSaveDataFixedLoad2);
cellSysutil->AddFunc(0x8b7ed64b, cellSaveDataAutoSave2);
cellSysutil->AddFunc(0xfbd5c856, cellSaveDataAutoLoad2);
cellSysutil->AddFunc(0x4dd03a4e, cellSaveDataListAutoSave);
cellSysutil->AddFunc(0x21425307, cellSaveDataListAutoLoad);
//cellSysutil->AddFunc(0xedadd797, cellSaveDataDelete2);
//cellSysutil->AddFunc(0x0f03cfb0, cellSaveDataUserListSave);
//cellSysutil->AddFunc(0x39dd8425, cellSaveDataUserListLoad);
//cellSysutil->AddFunc(0x40b34847, cellSaveDataUserFixedSave);
//cellSysutil->AddFunc(0x6e7264ed, cellSaveDataUserFixedLoad);
//cellSysutil->AddFunc(0x52aac4fa, cellSaveDataUserAutoSave);
//cellSysutil->AddFunc(0xcdc6aefd, cellSaveDataUserAutoLoad);
//cellSysutil->AddFunc(0x0e091c36, cellSaveDataUserListAutoSave);
//cellSysutil->AddFunc(0xe7fa820b, cellSaveDataEnableOverlay);
cellSysutil->AddFunc(0x6d087930, cellWebBrowserEstimate2);
2014-07-01 00:53:29 +02:00
cellSysutil->AddFunc(0xe7951dee, cellGameDataCheckCreate);
cellSysutil->AddFunc(0xc9645c41, cellGameDataCheckCreate2);
}