Skip to content

Commit 82b74c0

Browse files
author
N3xoX1
committed
OS: IApplicationFunctions::GetDisplayVersion
Add title to DisplayError
1 parent 7edb0f0 commit 82b74c0

13 files changed

Lines changed: 61 additions & 31 deletions

File tree

‎src/nxemu-core/modules/module_notification.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "module_notification.h"
22
#include "notification.h"
33

4-
void ModuleNotification::DisplayError(const char * message)
4+
void ModuleNotification::DisplayError(const char * message, const char * title)
55
{
6-
g_notify->DisplayError(message);
6+
g_notify->DisplayError(message, title);
77
}
88

99
void ModuleNotification::BreakPoint(const char * fileName, uint32_t lineNumber)

‎src/nxemu-core/modules/module_notification.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class ModuleNotification :
66
public IModuleNotification
77
{
88
public:
9-
void DisplayError(const char * message);
10-
void BreakPoint(const char * fileName, uint32_t lineNumber);
9+
10+
//IModuleNotification
11+
void DisplayError(const char * message, const char * title) override;
12+
void BreakPoint(const char * fileName, uint32_t lineNumber) override;
1113
};

‎src/nxemu-core/notification.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__interface INotification
55
{
66
//Error Messages
7-
virtual void DisplayError(const char * message) const = 0;
7+
virtual void DisplayError(const char * message, const char * title) const = 0;
88
virtual void BreakPoint(const char * fileName, uint32_t lineNumber) = 0;
99

1010
virtual void AppInitDone(void) = 0;

‎src/nxemu-loader/core/file_sys/control_metadata.cpp‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ NACP::NACP() = default;
6363

6464
NACP::NACP(VirtualFile file) {
6565
file->ReadObject(&raw);
66+
version = Common::StringFromFixedZeroTerminatedBuffer(raw.version_string.data(), raw.version_string.size());
6667
}
6768

6869
NACP::~NACP() = default;
@@ -110,9 +111,8 @@ u64 NACP::GetDLCBaseTitleId() const {
110111
return raw.dlc_base_title_id;
111112
}
112113

113-
std::string NACP::GetVersionString() const {
114-
return Common::StringFromFixedZeroTerminatedBuffer(raw.version_string.data(),
115-
raw.version_string.size());
114+
const char * NACP::GetVersionString() const {
115+
return version.c_str();
116116
}
117117

118118
u64 NACP::GetDefaultNormalSaveSize() const {
@@ -139,10 +139,6 @@ u32 NACP::GetParentalControlFlag() const {
139139
return raw.parental_control;
140140
}
141141

142-
const std::array<u8, 0x20>& NACP::GetRatingAge() const {
143-
return raw.rating_age;
144-
}
145-
146142
std::vector<u8> NACP::GetRawBytes() const {
147143
std::vector<u8> out(sizeof(RawNACP));
148144
std::memcpy(out.data(), &raw, sizeof(RawNACP));

‎src/nxemu-loader/core/file_sys/control_metadata.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,21 @@ class NACP :
111111
std::string GetDeveloperName() const;
112112
u64 GetTitleId() const;
113113
u64 GetDLCBaseTitleId() const;
114-
std::string GetVersionString() const;
115114
u64 GetDefaultNormalSaveSize() const;
116115
u64 GetDefaultJournalSaveSize() const;
117-
u32 GetSupportedLanguages() const;
118116
std::vector<u8> GetRawBytes() const;
119117
bool GetUserAccountSwitchLock() const;
120118
u64 GetDeviceSaveDataSize() const;
121-
u32 GetParentalControlFlag() const;
122-
const std::array<u8, 0x20>& GetRatingAge() const;
123119

124120
//IFileSysNACP
121+
uint32_t GetSupportedLanguages() const override;
122+
uint32_t GetParentalControlFlag() const override;
125123
bool GetRatingAge(uint8_t* buffer, uint32_t bufferSize) const override;
124+
const char * GetVersionString() const override;
126125
void Release() override;
127126

128127
private:
128+
std::string version;
129129
RawNACP raw{};
130130
};
131131

‎src/nxemu-loader/core/loader/loader.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ FileType IdentifyFile(FileSys::VirtualFile file) {
3636
} else if (const auto nsp_type = IdentifyFileLoader<AppLoader_NSP>(file)) {
3737
return *nsp_type;
3838
} else {
39-
UNIMPLEMENTED();
4039
return FileType::Unknown;
4140
}
4241
}
@@ -49,6 +48,8 @@ FileType GuessFromFilename(const std::string& name) {
4948
return FileType::NRO;
5049
if (extension == "dxci")
5150
return FileType::XCI;
51+
if (extension == "dnsp")
52+
return FileType::NSP;
5253

5354
return FileType::Unknown;
5455
}
@@ -96,7 +97,6 @@ static std::unique_ptr<AppLoader> GetFileLoader(Systemloader & loader, FileSys::
9697
loader.GetContentProvider(), program_id,
9798
program_index);
9899
}
99-
UNIMPLEMENTED();
100100
return nullptr;
101101
}
102102

‎src/nxemu-loader/system_loader.cpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "core/loader/loader.h"
1717

1818
extern IModuleSettings * g_settings;
19+
extern IModuleNotification * g_notify;
1920

2021
namespace {
2122

@@ -110,13 +111,15 @@ bool Systemloader::LoadRom(const char * romFile)
110111
impl->app_loader = Loader::GetLoader(*this, file, 0, 0);
111112
if (!impl->app_loader)
112113
{
114+
g_notify->DisplayError("The file format is not supported.", "Error loading file!");
113115
g_settings->SetBool(NXCoreSetting::RomLoading, false);
114116
return false;
115117
}
116118

117119
const Loader::FileType file_type = impl->app_loader->GetFileType();
118120
if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error)
119121
{
122+
g_notify->DisplayError("The file format is not supported.", "Error loading file!");
120123
g_settings->SetBool(NXCoreSetting::RomLoading, false);
121124
return false;
122125
}
@@ -182,8 +185,8 @@ bool Systemloader::LoadRom(const char * romFile)
182185
std::string title;
183186
impl->app_loader->ReadTitle(title);
184187
g_settings->SetString(NXCoreSetting::GameName, title.c_str());
185-
g_settings->SetBool(NXCoreSetting::RomLoading, false);
186188
g_settings->SetString(NXCoreSetting::GameFile, romFile);
189+
g_settings->SetBool(NXCoreSetting::RomLoading, false);
187190
impl->m_system.StartEmulation();
188191
return true;
189192
}

‎src/nxemu-module-spec/base.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
enum
1818
{
19-
MODULE_LOADER_SPECS_VERSION = 0x010A,
20-
MODULE_VIDEO_SPECS_VERSION = 0x010C,
21-
MODULE_CPU_SPECS_VERSION = 0x0105,
22-
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x010A,
19+
MODULE_LOADER_SPECS_VERSION = 0x010B,
20+
MODULE_VIDEO_SPECS_VERSION = 0x010D,
21+
MODULE_CPU_SPECS_VERSION = 0x0106,
22+
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x010B,
2323
};
2424

2525
enum MODULE_TYPE : uint16_t
@@ -32,7 +32,7 @@ enum MODULE_TYPE : uint16_t
3232

3333
__interface IModuleNotification
3434
{
35-
void DisplayError(const char * message) = 0;
35+
void DisplayError(const char * message, const char * title) = 0;
3636
void BreakPoint(const char * fileName, uint32_t lineNumber) = 0;
3737
};
3838

‎src/nxemu-module-spec/system_loader.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ __interface IFileSysNACP
193193
uint32_t GetSupportedLanguages() const = 0;
194194
uint32_t GetParentalControlFlag() const = 0;
195195
bool GetRatingAge(uint8_t * buffer, uint32_t bufferSize) const = 0;
196+
const char * GetVersionString() const = 0;
196197
void Release() = 0;
197198
};
198199

‎src/nxemu-os/core/hle/service/am/service/application_functions.cpp‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,25 @@ Result IApplicationFunctions::SetTerminateResult(Result terminate_result) {
192192

193193
Result IApplicationFunctions::GetDisplayVersion(Out<DisplayVersion> out_display_version) {
194194
LOG_DEBUG(Service_AM, "called");
195-
UNIMPLEMENTED();
195+
196+
ISystemloader & loader = system.GetSystemloader();
197+
IFileSysNACPPtr metadata(loader.GetPMControlMetadata(m_applet->program_id));
198+
if (!metadata)
199+
{
200+
metadata = loader.GetPMControlMetadata(FileSys::GetUpdateTitleID(m_applet->program_id));
201+
}
202+
203+
if (metadata)
204+
{
205+
std::string version(metadata->GetVersionString());
206+
std::memcpy(out_display_version->string.data(), version.data(), std::min(version.size(), out_display_version->string.size()));
207+
}
208+
else
209+
{
210+
static constexpr char default_version[]{ "1.0.0" };
211+
std::memcpy(out_display_version->string.data(), default_version, sizeof(default_version));
212+
}
213+
out_display_version->string[out_display_version->string.size() - 1] = '\0';
196214
R_SUCCEED();
197215
}
198216

0 commit comments

Comments
 (0)