XamShowMessageBoxUI (that auto-advances).

This commit is contained in:
Ben Vanik 2014-08-04 20:24:08 -07:00
parent 66d2a8aec2
commit 64d8ee386b
7 changed files with 137 additions and 1 deletions

View File

@ -10,6 +10,8 @@
#ifndef POLY_MEMORY_H_
#define POLY_MEMORY_H_
#include <string>
#include <poly/byte_order.h>
namespace poly {
@ -101,6 +103,32 @@ template <>
inline double load_and_swap<double>(const void* mem) {
return byte_swap(*reinterpret_cast<const double*>(mem));
}
template <>
inline std::string load_and_swap<std::string>(const void* mem) {
std::string value;
for (int i = 0;; ++i) {
auto c =
poly::load_and_swap<uint8_t>(reinterpret_cast<const uint8_t*>(mem) + i);
if (!c) {
break;
}
value.push_back(static_cast<char>(c));
}
return value;
}
template <>
inline std::wstring load_and_swap<std::wstring>(const void* mem) {
std::wstring value;
for (int i = 0;; ++i) {
auto c = poly::load_and_swap<uint16_t>(
reinterpret_cast<const uint16_t*>(mem) + i);
if (!c) {
break;
}
value.push_back(static_cast<wchar_t>(c));
}
return value;
}
template <typename T>
void store(void* mem, T value);

View File

@ -34,6 +34,8 @@
'xam_ordinals.h',
'xam_private.h',
'xam_table.inc',
'xam_ui.cc',
'xam_ui.h',
'xam_user.cc',
'xam_user.h',
'xam_video.cc',

View File

@ -37,6 +37,7 @@ XamModule::XamModule(Emulator* emulator, KernelState* kernel_state) :
RegisterMsgExports(export_resolver_, kernel_state);
RegisterNetExports(export_resolver_, kernel_state);
RegisterNotifyExports(export_resolver_, kernel_state);
RegisterUIExports(export_resolver_, kernel_state);
RegisterUserExports(export_resolver_, kernel_state);
RegisterVideoExports(export_resolver_, kernel_state);
RegisterVoiceExports(export_resolver_, kernel_state);

View File

@ -29,6 +29,7 @@ void RegisterInputExports(ExportResolver* export_resolver, KernelState* state);
void RegisterMsgExports(ExportResolver* export_resolver, KernelState* state);
void RegisterNetExports(ExportResolver* export_resolver, KernelState* state);
void RegisterNotifyExports(ExportResolver* export_resolver, KernelState* state);
void RegisterUIExports(ExportResolver* export_resolver, KernelState* state);
void RegisterUserExports(ExportResolver* export_resolver, KernelState* state);
void RegisterVideoExports(ExportResolver* export_resolver, KernelState* state);
void RegisterVoiceExports(ExportResolver* export_resolver, KernelState* state);

View File

@ -0,0 +1,76 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2014 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <xenia/kernel/xam_ui.h>
#include <xenia/kernel/kernel_state.h>
#include <xenia/kernel/xam_private.h>
#include <xenia/kernel/util/shim_utils.h>
using namespace xe;
using namespace xe::kernel;
using namespace xe::kernel::xam;
namespace xe {
namespace kernel {
// http://www.se7ensins.com/forums/threads/working-xshowmessageboxui.844116/?jdfwkey=sb0vm
SHIM_CALL XamShowMessageBoxUI_shim(
PPCContext* ppc_state, KernelState* state) {
uint32_t user_index = SHIM_GET_ARG_32(0);
uint32_t title_ptr = SHIM_GET_ARG_32(1);
uint32_t text_ptr = SHIM_GET_ARG_32(2);
uint32_t button_count = SHIM_GET_ARG_32(3);
uint32_t button_ptrs = SHIM_GET_ARG_32(4);
uint32_t active_button = SHIM_GET_ARG_32(5);
uint32_t flags = SHIM_GET_ARG_32(6);
uint32_t result_ptr = SHIM_GET_ARG_32(7);
// arg8 is in stack!
uint32_t sp = (uint32_t)ppc_state->r[1];
uint32_t overlapped_ptr = SHIM_MEM_32(sp + 0x54);
auto title = poly::load_and_swap<std::wstring>(SHIM_MEM_ADDR(title_ptr));
auto text = poly::load_and_swap<std::wstring>(SHIM_MEM_ADDR(text_ptr));
std::vector<std::wstring> buttons;
std::wstring all_buttons;
for (uint32_t j = 0; j < button_count; ++j) {
uint32_t button_ptr = SHIM_MEM_32(button_ptrs + j * 4);
auto button = poly::load_and_swap<std::wstring>(SHIM_MEM_ADDR(button_ptr));
all_buttons.append(button);
if (j + 1 < button_count) {
all_buttons.append(L" | ");
}
buttons.push_back(button);
}
XELOGD(
"XamShowMessageBoxUI(%d, %.8X(%S), %.8X(%S), %d, %.8X(%S), %d, %X, %.8X, "
"%.8X)",
user_index, title_ptr, title.c_str(), text_ptr, text.c_str(),
button_count, button_ptrs, all_buttons.c_str(), active_button, flags,
result_ptr, overlapped_ptr);
// Auto-pick the focused button.
SHIM_SET_MEM_32(result_ptr, active_button);
state->CompleteOverlappedImmediate(overlapped_ptr, X_ERROR_SUCCESS);
SHIM_SET_RETURN_32(X_ERROR_IO_PENDING);
}
} // namespace kernel
} // namespace xe
void xe::kernel::xam::RegisterUIExports(
ExportResolver* export_resolver, KernelState* state) {
SHIM_SET_MAPPING("xam.xex", XamShowMessageBoxUI, state);
}

28
src/xenia/kernel/xam_ui.h Normal file
View File

@ -0,0 +1,28 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2014 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_KERNEL_XAM_UI_H_
#define XENIA_KERNEL_XAM_UI_H_
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/xbox.h>
namespace xe {
namespace kernel {
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_XAM_UI_H_

View File

@ -60,7 +60,7 @@ SHIM_CALL XamUserGetSigninState_shim(
// Lie and say we are signed in, but local-only.
// This should keep games from asking us to sign in and also keep them
// from initializing the network.
if (user_index == 0) {
if (user_index == 0 || (user_index & 0xFF) == 0xFF) {
const auto& user_profile = state->user_profile();
SHIM_SET_RETURN_64(user_profile->signin_state());
} else {