early-access version 1348
This commit is contained in:
parent
f7882f96ec
commit
861118690c
10 changed files with 1931 additions and 2306 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 1346.
|
This is the source code for early-access 1348.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,11 @@ namespace Common {
|
||||||
void ConfigureNvidiaEnvironmentFlags() {
|
void ConfigureNvidiaEnvironmentFlags() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const std::string shader_path = Common::FS::SanitizePath(
|
const std::string shader_path = Common::FS::SanitizePath(
|
||||||
fmt::format("{}\\nvidia", Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)),
|
fmt::format("{}/nvidia/", Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)));
|
||||||
Common::FS::DirectorySeparator::PlatformDefault);
|
const std::string windows_path =
|
||||||
std::filesystem::create_directories(shader_path);
|
Common::FS::SanitizePath(shader_path, Common::FS::DirectorySeparator::BackwardSlash);
|
||||||
void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", shader_path).c_str()));
|
void(Common::FS::CreateFullPath(shader_path + '/'));
|
||||||
|
void(_putenv(fmt::format("__GL_SHADER_DISK_CACHE_PATH={}", windows_path).c_str()));
|
||||||
void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1"));
|
void(_putenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,6 @@ void CpuManager::SingleCoreRunGuestThread() {
|
||||||
|
|
||||||
void CpuManager::SingleCoreRunGuestLoop() {
|
void CpuManager::SingleCoreRunGuestLoop() {
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
auto* thread = kernel.CurrentScheduler()->GetCurrentThread();
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto* physical_core = &kernel.CurrentPhysicalCore();
|
auto* physical_core = &kernel.CurrentPhysicalCore();
|
||||||
system.EnterDynarmicProfile();
|
system.EnterDynarmicProfile();
|
||||||
|
|
|
@ -1015,8 +1015,11 @@ ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, Thread
|
||||||
|
|
||||||
std::shared_ptr<KThread> thread = std::make_shared<KThread>(kernel);
|
std::shared_ptr<KThread> thread = std::make_shared<KThread>(kernel);
|
||||||
|
|
||||||
thread->InitializeThread(thread.get(), entry_point, arg, stack_top, priority, processor_id,
|
if (const auto result = thread->InitializeThread(thread.get(), entry_point, arg, stack_top, priority, processor_id,
|
||||||
owner_process, type_flags);
|
owner_process, type_flags); result.IsError()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
thread->name = name;
|
thread->name = name;
|
||||||
|
|
||||||
auto& scheduler = kernel.GlobalSchedulerContext();
|
auto& scheduler = kernel.GlobalSchedulerContext();
|
||||||
|
|
|
@ -117,14 +117,14 @@ struct KernelCore::Impl {
|
||||||
void InitializePhysicalCores() {
|
void InitializePhysicalCores() {
|
||||||
exclusive_monitor =
|
exclusive_monitor =
|
||||||
Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES);
|
Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES);
|
||||||
for (s32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
||||||
schedulers[i] = std::make_unique<Kernel::KScheduler>(system, i);
|
schedulers[i] = std::make_unique<Kernel::KScheduler>(system, i);
|
||||||
cores.emplace_back(i, system, *schedulers[i], interrupts);
|
cores.emplace_back(i, system, *schedulers[i], interrupts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeSchedulers() {
|
void InitializeSchedulers() {
|
||||||
for (s32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
||||||
cores[i].Scheduler().Initialize();
|
cores[i].Scheduler().Initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,30 +20,30 @@ public:
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, nullptr, "SaveCurrentSetting"},
|
{0, nullptr, "SaveCurrentSetting"},
|
||||||
{1, nullptr, "LoadCurrentSetting"},
|
{1, nullptr, "LoadCurrentSetting"},
|
||||||
{2, nullptr, "SetCurrentBrightnessSetting"},
|
{2, &LBL::SetCurrentBrightnessSetting, "SetCurrentBrightnessSetting"},
|
||||||
{3, nullptr, "GetCurrentBrightnessSetting"},
|
{3, &LBL::GetCurrentBrightnessSetting, "GetCurrentBrightnessSetting"},
|
||||||
{4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"},
|
{4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"},
|
||||||
{5, nullptr, "GetBrightnessSettingAppliedToBacklight"},
|
{5, nullptr, "GetBrightnessSettingAppliedToBacklight"},
|
||||||
{6, nullptr, "SwitchBacklightOn"},
|
{6, &LBL::SwitchBacklightOn, "SwitchBacklightOn"},
|
||||||
{7, nullptr, "SwitchBacklightOff"},
|
{7, &LBL::SwitchBacklightOff, "SwitchBacklightOff"},
|
||||||
{8, nullptr, "GetBacklightSwitchStatus"},
|
{8, &LBL::GetBacklightSwitchStatus, "GetBacklightSwitchStatus"},
|
||||||
{9, nullptr, "EnableDimming"},
|
{9, &LBL::EnableDimming, "EnableDimming"},
|
||||||
{10, nullptr, "DisableDimming"},
|
{10, &LBL::DisableDimming, "DisableDimming"},
|
||||||
{11, nullptr, "IsDimmingEnabled"},
|
{11, &LBL::IsDimmingEnabled, "IsDimmingEnabled"},
|
||||||
{12, nullptr, "EnableAutoBrightnessControl"},
|
{12, &LBL::EnableAutoBrightnessControl, "EnableAutoBrightnessControl"},
|
||||||
{13, nullptr, "DisableAutoBrightnessControl"},
|
{13, &LBL::DisableAutoBrightnessControl, "DisableAutoBrightnessControl"},
|
||||||
{14, nullptr, "IsAutoBrightnessControlEnabled"},
|
{14, &LBL::IsAutoBrightnessControlEnabled, "IsAutoBrightnessControlEnabled"},
|
||||||
{15, nullptr, "SetAmbientLightSensorValue"},
|
{15, &LBL::SetAmbientLightSensorValue, "SetAmbientLightSensorValue"},
|
||||||
{16, nullptr, "GetAmbientLightSensorValue"},
|
{16, &LBL::GetAmbientLightSensorValue, "GetAmbientLightSensorValue"},
|
||||||
{17, nullptr, "SetBrightnessReflectionDelayLevel"},
|
{17, &LBL::SetBrightnessReflectionDelayLevel, "SetBrightnessReflectionDelayLevel"},
|
||||||
{18, nullptr, "GetBrightnessReflectionDelayLevel"},
|
{18, &LBL::GetBrightnessReflectionDelayLevel, "GetBrightnessReflectionDelayLevel"},
|
||||||
{19, nullptr, "SetCurrentBrightnessMapping"},
|
{19, &LBL::SetCurrentBrightnessMapping, "SetCurrentBrightnessMapping"},
|
||||||
{20, nullptr, "GetCurrentBrightnessMapping"},
|
{20, &LBL::GetCurrentBrightnessMapping, "GetCurrentBrightnessMapping"},
|
||||||
{21, nullptr, "SetCurrentAmbientLightSensorMapping"},
|
{21, &LBL::SetCurrentAmbientLightSensorMapping, "SetCurrentAmbientLightSensorMapping"},
|
||||||
{22, nullptr, "GetCurrentAmbientLightSensorMapping"},
|
{22, &LBL::GetCurrentAmbientLightSensorMapping, "GetCurrentAmbientLightSensorMapping"},
|
||||||
{23, nullptr, "IsAmbientLightSensorAvailable"},
|
{23, &LBL::IsAmbientLightSensorAvailable, "IsAmbientLightSensorAvailable"},
|
||||||
{24, nullptr, "SetCurrentBrightnessSettingForVrMode"},
|
{24, &LBL::SetCurrentBrightnessSettingForVrMode, "SetCurrentBrightnessSettingForVrMode"},
|
||||||
{25, nullptr, "GetCurrentBrightnessSettingForVrMode"},
|
{25, &LBL::GetCurrentBrightnessSettingForVrMode, "GetCurrentBrightnessSettingForVrMode"},
|
||||||
{26, &LBL::EnableVrMode, "EnableVrMode"},
|
{26, &LBL::EnableVrMode, "EnableVrMode"},
|
||||||
{27, &LBL::DisableVrMode, "DisableVrMode"},
|
{27, &LBL::DisableVrMode, "DisableVrMode"},
|
||||||
{28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"},
|
{28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"},
|
||||||
|
@ -55,6 +55,237 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum class BacklightSwitchStatus : u32 {
|
||||||
|
Off = 0,
|
||||||
|
On = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetCurrentBrightnessSetting(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
auto brightness = rp.Pop<float>();
|
||||||
|
|
||||||
|
if (!std::isfinite(brightness)) {
|
||||||
|
LOG_ERROR(Service_LBL, "Brightness is infinite!");
|
||||||
|
brightness = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_LBL, "called brightness={}", brightness);
|
||||||
|
|
||||||
|
current_brightness = brightness;
|
||||||
|
update_instantly = true;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetCurrentBrightnessSetting(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
auto brightness = current_brightness;
|
||||||
|
if (!std::isfinite(brightness)) {
|
||||||
|
LOG_ERROR(Service_LBL, "Brightness is infinite!");
|
||||||
|
brightness = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_LBL, "called brightness={}", brightness);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(brightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchBacklightOn(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto fade_time = rp.Pop<u64_le>();
|
||||||
|
LOG_WARNING(Service_LBL, "(STUBBED) called, fade_time={}", fade_time);
|
||||||
|
|
||||||
|
backlight_enabled = true;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchBacklightOff(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto fade_time = rp.Pop<u64_le>();
|
||||||
|
LOG_WARNING(Service_LBL, "(STUBBED) called, fade_time={}", fade_time);
|
||||||
|
|
||||||
|
backlight_enabled = false;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetBacklightSwitchStatus(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.PushEnum<BacklightSwitchStatus>(backlight_enabled ? BacklightSwitchStatus::On
|
||||||
|
: BacklightSwitchStatus::Off);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableDimming(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
dimming = true;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisableDimming(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
dimming = false;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IsDimmingEnabled(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(dimming);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableAutoBrightnessControl(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
auto_brightness = true;
|
||||||
|
update_instantly = true;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisableAutoBrightnessControl(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
auto_brightness = false;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IsAutoBrightnessControlEnabled(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(auto_brightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetAmbientLightSensorValue(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto light_value = rp.Pop<float>();
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_LBL, "called light_value={}", light_value);
|
||||||
|
|
||||||
|
ambient_light_value = light_value;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetAmbientLightSensorValue(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(ambient_light_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBrightnessReflectionDelayLevel(Kernel::HLERequestContext& ctx) {
|
||||||
|
// This is Intentional, this function does absolutely nothing
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetBrightnessReflectionDelayLevel(Kernel::HLERequestContext& ctx) {
|
||||||
|
// This is intentional, the function is hard coded to return 0.0f on hardware
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCurrentBrightnessMapping(Kernel::HLERequestContext& ctx) {
|
||||||
|
// This is Intentional, this function does absolutely nothing
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetCurrentBrightnessMapping(Kernel::HLERequestContext& ctx) {
|
||||||
|
// This is Intentional, this function does absolutely nothing
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
// This function is suppose to return something but it seems like it doesn't
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCurrentAmbientLightSensorMapping(Kernel::HLERequestContext& ctx) {
|
||||||
|
// This is Intentional, this function does absolutely nothing
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetCurrentAmbientLightSensorMapping(Kernel::HLERequestContext& ctx) {
|
||||||
|
// This is Intentional, this function does absolutely nothing
|
||||||
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
// This function is suppose to return something but it seems like it doesn't
|
||||||
|
}
|
||||||
|
|
||||||
|
void IsAmbientLightSensorAvailable(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_WARNING(Service_LBL, "(STUBBED) called");
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
// TODO(ogniK): Only return true if there's no device error
|
||||||
|
rb.Push(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCurrentBrightnessSettingForVrMode(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
auto brightness = rp.Pop<float>();
|
||||||
|
|
||||||
|
if (!std::isfinite(brightness)) {
|
||||||
|
LOG_ERROR(Service_LBL, "Brightness is infinite!");
|
||||||
|
brightness = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_LBL, "called brightness={}", brightness);
|
||||||
|
|
||||||
|
current_vr_brightness = brightness;
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetCurrentBrightnessSettingForVrMode(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
auto brightness = current_vr_brightness;
|
||||||
|
if (!std::isfinite(brightness)) {
|
||||||
|
LOG_ERROR(Service_LBL, "Brightness is infinite!");
|
||||||
|
brightness = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_LBL, "called brightness={}", brightness);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.Push(brightness);
|
||||||
|
}
|
||||||
|
|
||||||
void EnableVrMode(Kernel::HLERequestContext& ctx) {
|
void EnableVrMode(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_LBL, "called");
|
LOG_DEBUG(Service_LBL, "called");
|
||||||
|
|
||||||
|
@ -82,6 +313,14 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vr_mode_enabled = false;
|
bool vr_mode_enabled = false;
|
||||||
|
float current_brightness = 1.0f;
|
||||||
|
float backlight_brightness = 1.0f;
|
||||||
|
float ambient_light_value = 0.0f;
|
||||||
|
float current_vr_brightness = 1.0f;
|
||||||
|
bool dimming = true;
|
||||||
|
bool backlight_enabled = true;
|
||||||
|
bool update_instantly = false;
|
||||||
|
bool auto_brightness = false; // TODO(ogniK): Move to system settings
|
||||||
};
|
};
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
|
void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace {
|
||||||
|
|
||||||
constexpr ResultCode ERROR_CANNOT_FIND_ENTRY{ErrorModule::Mii, 4};
|
constexpr ResultCode ERROR_CANNOT_FIND_ENTRY{ErrorModule::Mii, 4};
|
||||||
|
|
||||||
constexpr std::size_t DefaultMiiCount{sizeof(RawData::DefaultMii) / sizeof(DefaultMii)};
|
constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()};
|
||||||
|
|
||||||
constexpr MiiStoreData::Name DefaultMiiName{u'y', u'u', u'z', u'u'};
|
constexpr MiiStoreData::Name DefaultMiiName{u'y', u'u', u'z', u'u'};
|
||||||
constexpr std::array<u8, 8> HairColorLookup{8, 1, 2, 3, 4, 5, 6, 7};
|
constexpr std::array<u8, 8> HairColorLookup{8, 1, 2, 3, 4, 5, 6, 7};
|
||||||
|
@ -141,13 +141,6 @@ T GetRandomValue(T max) {
|
||||||
return GetRandomValue<T>({}, max);
|
return GetRandomValue<T>({}, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T GetArrayValue(const u8* data, std::size_t index) {
|
|
||||||
T result{};
|
|
||||||
std::memcpy(&result, &data[index * sizeof(T)], sizeof(T));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Common::UUID& user_id) {
|
MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Common::UUID& user_id) {
|
||||||
MiiStoreBitFields bf{};
|
MiiStoreBitFields bf{};
|
||||||
|
|
||||||
|
@ -193,32 +186,20 @@ MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Commo
|
||||||
const std::size_t index{3 * static_cast<std::size_t>(age) +
|
const std::size_t index{3 * static_cast<std::size_t>(age) +
|
||||||
9 * static_cast<std::size_t>(gender) + static_cast<std::size_t>(race)};
|
9 * static_cast<std::size_t>(gender) + static_cast<std::size_t>(race)};
|
||||||
|
|
||||||
const auto faceline_type_info{
|
const auto faceline_type_info{RawData::RandomMiiFaceline.at(index)};
|
||||||
GetArrayValue<RandomMiiData4>(&RawData::RandomMiiFaceline[0], index)};
|
const auto faceline_color_info{RawData::RandomMiiFacelineColor.at(
|
||||||
const auto faceline_color_info{GetArrayValue<RandomMiiData3>(
|
|
||||||
RawData::RandomMiiFacelineColor.data(),
|
|
||||||
3 * static_cast<std::size_t>(gender) + static_cast<std::size_t>(race))};
|
3 * static_cast<std::size_t>(gender) + static_cast<std::size_t>(race))};
|
||||||
const auto faceline_wrinkle_info{
|
const auto faceline_wrinkle_info{RawData::RandomMiiFacelineWrinkle.at(index)};
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiFacelineWrinkle.data(), index)};
|
const auto faceline_makeup_info{RawData::RandomMiiFacelineMakeup.at(index)};
|
||||||
const auto faceline_makeup_info{
|
const auto hair_type_info{RawData::RandomMiiHairType.at(index)};
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiFacelineMakeup.data(), index)};
|
const auto hair_color_info{RawData::RandomMiiHairColor.at(3 * static_cast<std::size_t>(race) +
|
||||||
const auto hair_type_info{
|
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiHairType.data(), index)};
|
|
||||||
const auto hair_color_info{GetArrayValue<RandomMiiData3>(RawData::RandomMiiHairColor.data(),
|
|
||||||
3 * static_cast<std::size_t>(race) +
|
|
||||||
static_cast<std::size_t>(age))};
|
|
||||||
const auto eye_type_info{
|
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiEyeType.data(), index)};
|
|
||||||
const auto eye_color_info{GetArrayValue<RandomMiiData2>(RawData::RandomMiiEyeColor.data(),
|
|
||||||
static_cast<std::size_t>(race))};
|
|
||||||
const auto eyebrow_type_info{
|
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiEyebrowType.data(), index)};
|
|
||||||
const auto nose_type_info{
|
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiNoseType.data(), index)};
|
|
||||||
const auto mouth_type_info{
|
|
||||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiMouthType.data(), index)};
|
|
||||||
const auto glasses_type_info{GetArrayValue<RandomMiiData2>(RawData::RandomMiiGlassType.data(),
|
|
||||||
static_cast<std::size_t>(age))};
|
static_cast<std::size_t>(age))};
|
||||||
|
const auto eye_type_info{RawData::RandomMiiEyeType.at(index)};
|
||||||
|
const auto eye_color_info{RawData::RandomMiiEyeColor.at(static_cast<std::size_t>(race))};
|
||||||
|
const auto eyebrow_type_info{RawData::RandomMiiEyebrowType.at(index)};
|
||||||
|
const auto nose_type_info{RawData::RandomMiiNoseType.at(index)};
|
||||||
|
const auto mouth_type_info{RawData::RandomMiiMouthType.at(index)};
|
||||||
|
const auto glasses_type_info{RawData::RandomMiiGlassType.at(static_cast<std::size_t>(age))};
|
||||||
|
|
||||||
bf.faceline_type.Assign(
|
bf.faceline_type.Assign(
|
||||||
faceline_type_info.values[GetRandomValue<std::size_t>(faceline_type_info.values_count)]);
|
faceline_type_info.values[GetRandomValue<std::size_t>(faceline_type_info.values_count)]);
|
||||||
|
@ -455,8 +436,7 @@ MiiInfo MiiManager::BuildRandom(Age age, Gender gender, Race race) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MiiInfo MiiManager::BuildDefault(std::size_t index) {
|
MiiInfo MiiManager::BuildDefault(std::size_t index) {
|
||||||
return ConvertStoreDataToInfo(BuildDefaultStoreData(
|
return ConvertStoreDataToInfo(BuildDefaultStoreData(RawData::DefaultMii.at(index), user_id));
|
||||||
GetArrayValue<DefaultMii>(RawData::DefaultMii.data(), index), user_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_flag) {
|
ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_flag) {
|
||||||
|
|
|
@ -233,7 +233,7 @@ struct RandomMiiData4 {
|
||||||
Age age{};
|
Age age{};
|
||||||
Race race{};
|
Race race{};
|
||||||
u32 values_count{};
|
u32 values_count{};
|
||||||
std::array<u8, 0xbc> values{};
|
std::array<u32, 47> values{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(RandomMiiData4) == 0xcc, "RandomMiiData4 has incorrect size.");
|
static_assert(sizeof(RandomMiiData4) == 0xcc, "RandomMiiData4 has incorrect size.");
|
||||||
|
|
||||||
|
@ -241,14 +241,14 @@ struct RandomMiiData3 {
|
||||||
u32 arg_1;
|
u32 arg_1;
|
||||||
u32 arg_2;
|
u32 arg_2;
|
||||||
u32 values_count;
|
u32 values_count;
|
||||||
std::array<u8, 0xbc> values{};
|
std::array<u32, 47> values{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(RandomMiiData3) == 0xc8, "RandomMiiData3 has incorrect size.");
|
static_assert(sizeof(RandomMiiData3) == 0xc8, "RandomMiiData3 has incorrect size.");
|
||||||
|
|
||||||
struct RandomMiiData2 {
|
struct RandomMiiData2 {
|
||||||
u32 arg_1;
|
u32 arg_1;
|
||||||
u32 values_count;
|
u32 values_count;
|
||||||
std::array<u8, 0xbc> values{};
|
std::array<u32, 47> values{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(RandomMiiData2) == 0xc4, "RandomMiiData2 has incorrect size.");
|
static_assert(sizeof(RandomMiiData2) == 0xc4, "RandomMiiData2 has incorrect size.");
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,21 +7,22 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/service/mii/manager.h"
|
||||||
|
|
||||||
namespace Service::Mii::RawData {
|
namespace Service::Mii::RawData {
|
||||||
|
|
||||||
extern const std::array<u8, 1728> DefaultMii;
|
extern const std::array<Service::Mii::DefaultMii, 8> DefaultMii;
|
||||||
extern const std::array<u8, 3672> RandomMiiFaceline;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiFaceline;
|
||||||
extern const std::array<u8, 1200> RandomMiiFacelineColor;
|
extern const std::array<Service::Mii::RandomMiiData3, 6> RandomMiiFacelineColor;
|
||||||
extern const std::array<u8, 3672> RandomMiiFacelineWrinkle;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiFacelineWrinkle;
|
||||||
extern const std::array<u8, 3672> RandomMiiFacelineMakeup;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiFacelineMakeup;
|
||||||
extern const std::array<u8, 3672> RandomMiiHairType;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiHairType;
|
||||||
extern const std::array<u8, 1800> RandomMiiHairColor;
|
extern const std::array<Service::Mii::RandomMiiData3, 9> RandomMiiHairColor;
|
||||||
extern const std::array<u8, 3672> RandomMiiEyeType;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiEyeType;
|
||||||
extern const std::array<u8, 588> RandomMiiEyeColor;
|
extern const std::array<Service::Mii::RandomMiiData2, 3> RandomMiiEyeColor;
|
||||||
extern const std::array<u8, 3672> RandomMiiEyebrowType;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiEyebrowType;
|
||||||
extern const std::array<u8, 3672> RandomMiiNoseType;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiNoseType;
|
||||||
extern const std::array<u8, 3672> RandomMiiMouthType;
|
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiMouthType;
|
||||||
extern const std::array<u8, 588> RandomMiiGlassType;
|
extern const std::array<Service::Mii::RandomMiiData2, 3> RandomMiiGlassType;
|
||||||
|
|
||||||
} // namespace Service::Mii::RawData
|
} // namespace Service::Mii::RawData
|
||||||
|
|
Loading…
Reference in a new issue