Skip to content

Commit

Permalink
Set the window title from the module resource pool
Browse files Browse the repository at this point in the history
  • Loading branch information
x1nixmzeng committed Jan 7, 2016
1 parent 729a1af commit 321e2d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/xenia/emulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "xenia/vfs/devices/host_path_device.h"
#include "xenia/vfs/devices/stfs_container_device.h"
#include "xenia/vfs/virtual_file_system.h"
#include "xenia/xdbf/xdbf_utils.h"

DEFINE_double(time_scalar, 1.0,
"Scalar used to speed or slow time (1x, 2x, 1/2x, etc).");
Expand Down Expand Up @@ -498,7 +499,7 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path,
// Allow xam to request module loads.
auto xam = kernel_state()->GetKernelModule<kernel::xam::XamModule>("xam.xex");

int result = 0;
X_STATUS result = X_STATUS_SUCCESS;
auto next_module = module_path;
while (next_module != "") {
XELOGI("Launching module %s", next_module.c_str());
Expand All @@ -513,6 +514,24 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path,
if (!main_xthread) {
return X_STATUS_UNSUCCESSFUL;
}

// Try and load the resource database (xex only)
char title[9] = { 0 };
sprintf(title, "%08X", module->title_id());

uint32_t resource_data = 0;
uint32_t resource_size = 0;
if (XSUCCEEDED(module->GetSection(title, &resource_data, &resource_size))) {
auto xdb_ptr = module->memory()->TranslateVirtual(resource_data);
if (xdb_ptr != nullptr) {
xe::xdbf::XdbfWrapper db;
if (db.initialize(xdb_ptr, static_cast<size_t>(resource_size))) {
// TODO(x1nixmzeng): Set the application icon
std::wstring title(xe::to_wstring(xe::xdbf::get_title(db)));
display_window_->set_title(title);
}
}
}

main_thread_ = main_xthread->thread();
WaitUntilExit();
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/kernel/user_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ X_STATUS UserModule::GetSection(const char* name, uint32_t* out_section_data,
return X_STATUS_NOT_FOUND;
}

uint32_t count = (resource_header->size - 4) / 16;
uint32_t count = (resource_header->size - 4) / sizeof(xex2_resource);
for (uint32_t i = 0; i < count; i++) {
auto& res = resource_header->resources[i];
if (std::strncmp(name, res.name, 8) == 0) {
Expand Down

0 comments on commit 321e2d8

Please sign in to comment.