Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VFS/STFS] STFS structure improvements & CON support #1793

Merged
merged 8 commits into from
May 5, 2021
2 changes: 1 addition & 1 deletion src/xenia/emulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
module->memory()->TranslateVirtual(resource_data), resource_size);
if (db.is_valid()) {
// TODO(gibbed): get title respective to user locale.
title_name_ = db.title(kernel::util::XdbfLocale::kEnglish);
title_name_ = db.title(XLanguage::kEnglish);
if (title_name_.empty()) {
// If English title is unavailable, get the title in default locale.
title_name_ = db.title();
Expand Down
14 changes: 7 additions & 7 deletions src/xenia/kernel/util/xdbf_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ XdbfBlock XdbfWrapper::GetEntry(XdbfSection section, uint64_t id) const {
return {0};
}

std::string XdbfWrapper::GetStringTableEntry(XdbfLocale locale,
std::string XdbfWrapper::GetStringTableEntry(XLanguage language,
uint16_t string_id) const {
auto language_block =
GetEntry(XdbfSection::kStringTable, static_cast<uint64_t>(locale));
GetEntry(XdbfSection::kStringTable, static_cast<uint64_t>(language));
if (!language_block) {
return "";
}
Expand Down Expand Up @@ -88,22 +88,22 @@ XdbfBlock XdbfGameData::icon() const {
return GetEntry(XdbfSection::kImage, kXdbfIdTitle);
}

XdbfLocale XdbfGameData::default_language() const {
XLanguage XdbfGameData::default_language() const {
auto block = GetEntry(XdbfSection::kMetadata, kXdbfIdXstc);
if (!block.buffer) {
return XdbfLocale::kEnglish;
return XLanguage::kEnglish;
}
auto xstc = reinterpret_cast<const XdbfXstc*>(block.buffer);
assert_true(xstc->magic == kXdbfMagicXstc);
return static_cast<XdbfLocale>(static_cast<uint32_t>(xstc->default_language));
return static_cast<XLanguage>(static_cast<uint32_t>(xstc->default_language));
}

std::string XdbfGameData::title() const {
return GetStringTableEntry(default_language(), kXdbfIdTitle);
}

std::string XdbfGameData::title(XdbfLocale locale) const {
return GetStringTableEntry(locale, kXdbfIdTitle);
std::string XdbfGameData::title(XLanguage language) const {
return GetStringTableEntry(language, kXdbfIdTitle);
}

} // namespace util
Expand Down
20 changes: 4 additions & 16 deletions src/xenia/kernel/util/xdbf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <vector>

#include "xenia/base/memory.h"
#include "xenia/xbox.h"

namespace xe {
namespace kernel {
Expand All @@ -28,19 +29,6 @@ enum class XdbfSection : uint16_t {
kStringTable = 0x0003,
};

// Found by dumping the kSectionStringTable sections of various games:
enum class XdbfLocale : uint32_t {
kUnknown = 0,
kEnglish = 1,
kJapanese = 2,
kGerman = 3,
kFrench = 4,
kSpanish = 5,
kItalian = 6,
kKorean = 7,
kChinese = 8,
};

struct XdbfBlock {
const uint8_t* buffer;
size_t size;
Expand All @@ -63,7 +51,7 @@ class XdbfWrapper {

// Gets a string from the string table in the given language.
// Returns the empty string if the entry is not found.
std::string GetStringTableEntry(XdbfLocale locale, uint16_t string_id) const;
std::string GetStringTableEntry(XLanguage language, uint16_t string_id) const;

protected:
#pragma pack(push, 1)
Expand Down Expand Up @@ -133,12 +121,12 @@ class XdbfGameData : public XdbfWrapper {
XdbfBlock icon() const;

// The game's default language.
XdbfLocale default_language() const;
XLanguage default_language() const;

// The game's title in its default language.
std::string title() const;

std::string title(XdbfLocale locale) const;
std::string title(XLanguage language) const;
};

} // namespace util
Expand Down
11 changes: 4 additions & 7 deletions src/xenia/kernel/xam/xam_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ namespace xe {
namespace kernel {
namespace xam {

constexpr uint32_t X_LANGUAGE_ENGLISH = 1;
constexpr uint32_t X_LANGUAGE_JAPANESE = 2;

dword_result_t XamFeatureEnabled(dword_t unk) { return 0; }
DECLARE_XAM_EXPORT1(XamFeatureEnabled, kNone, kStub);

Expand Down Expand Up @@ -208,19 +205,19 @@ dword_result_t XGetGameRegion() { return xeXGetGameRegion(); }
DECLARE_XAM_EXPORT1(XGetGameRegion, kNone, kStub);

dword_result_t XGetLanguage() {
uint32_t desired_language = X_LANGUAGE_ENGLISH;
auto desired_language = XLanguage::kEnglish;

// Switch the language based on game region.
// TODO(benvanik): pull from xex header.
uint32_t game_region = XEX_REGION_NTSCU;
if (game_region & XEX_REGION_NTSCU) {
desired_language = X_LANGUAGE_ENGLISH;
desired_language = XLanguage::kEnglish;
} else if (game_region & XEX_REGION_NTSCJ) {
desired_language = X_LANGUAGE_JAPANESE;
desired_language = XLanguage::kJapanese;
}
// Add more overrides?

return desired_language;
return uint32_t(desired_language);
}
DECLARE_XAM_EXPORT1(XGetLanguage, kNone, kImplemented);

Expand Down
Loading