Skip to content

Commit

Permalink
Fixed NXE dashboard, implemented misc functions
Browse files Browse the repository at this point in the history
  • Loading branch information
seven7000real committed Nov 13, 2024
1 parent 167c85e commit 146fdc3
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 16 deletions.
17 changes: 14 additions & 3 deletions src/xenia/kernel/xam/xam_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,16 @@ dword_result_t XamGetSystemVersion_entry() {
}
DECLARE_XAM_EXPORT1(XamGetSystemVersion, kNone, kStub);

void XCustomRegisterDynamicActions_entry() {
// ???
dword_result_t XamUpdateGetBaseSystemVersion_entry() {
return XamGetSystemVersion_entry();
}
DECLARE_XAM_EXPORT1(XCustomRegisterDynamicActions, kNone, kStub);
DECLARE_XAM_EXPORT1(XamUpdateGetBaseSystemVersion, kNone, kStub);

// https://github.com/oukiar/freestyledash/blob/master/Freestyle/Tools/Generic/XamExports.h#L77
dword_result_t XamUpdateGetCurrentSystemVersion_entry() {
return XamGetSystemVersion_entry();
}
DECLARE_XAM_EXPORT1(XamUpdateGetCurrentSystemVersion, kNone, kStub);

dword_result_t XGetAVPack_entry() {
// Value from
Expand Down Expand Up @@ -393,6 +399,11 @@ void XamLoaderLaunchTitle_entry(lpstring_t raw_name_ptr, dword_t flags) {
}
DECLARE_XAM_EXPORT1(XamLoaderLaunchTitle, kNone, kSketchy);

// https://www.se7ensins.com/forums/threads/interested-in-programming-here-are-some-tips.1503852/
void XamLoaderLaunchTitleEx_entry(lpstring_t launch_path, lpstring_t mount_path,
lpstring_t cmdLine, dword_t flags) {}
DECLARE_XAM_EXPORT1(XamLoaderLaunchTitleEx, kNone, kSketchy);

void XamLoaderTerminateTitle_entry() {
// This function does not return.
kernel_state()->TerminateTitle();
Expand Down
33 changes: 33 additions & 0 deletions src/xenia/kernel/xam/xam_misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@ void XamSetDashContext_entry(dword_t context) {
}
DECLARE_XAM_EXPORT1(XamSetDashContext, kNone, kStub);

dword_result_t XamIsSystemTitleId_entry(dword_t title_id) {
if (title_id == 0) {
return true;
}
if ((title_id & 0xFF000000) == 0x58000000u) {
return (title_id & 0xFF0000) != 0x410000; // if 'X' but not 'XA' (XBLA)
}
return (title_id >> 16) == 0xFFFE; // FFFExxxx are always system apps
}
DECLARE_XAM_EXPORT1(XamIsSystemTitleId, kNone, kImplemented);

dword_result_t XamIsXbox1TitleId_entry(dword_t title_id) {
if (title_id == 0xFFFE0000) {
return true; // Xbox OG dashboard ID?
}
if (title_id == 0 || (title_id & 0xFF000000) == 0xFF000000) {
return false; // X360 system apps
}
return (title_id & 0x7FFF) < 0x7D0; // lower 15 bits smaller than 2000
}
DECLARE_XAM_EXPORT1(XamIsXbox1TitleId, kNone, kImplemented);

dword_result_t XamIsSystemExperienceTitleId_entry(dword_t title_id) {
if ((title_id >> 16) == 0x584A) { // 'XJ'
return true;
}
if ((title_id >> 16) == 0x5848) { // 'XH'
return true;
}
return title_id == 0x584E07D2 || title_id == 0x584E07D1; // XN-2002 / XN-2001
}
DECLARE_XAM_EXPORT1(XamIsSystemExperienceTitleId, kNone, kImplemented);

dword_result_t XamGetDashContext_entry() { return dash_context_; }
DECLARE_XAM_EXPORT1(XamGetDashContext, kNone, kStub);

Expand Down
10 changes: 10 additions & 0 deletions src/xenia/kernel/xam/xam_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "xenia/ui/windowed_app_context.h"
#include "xenia/xbox.h"

DECLARE_bool(xconfig_initial_setup);

DEFINE_bool(storage_selection_dialog, false,
"Show storage device selection dialog when the game requests it.",
"UI");
Expand Down Expand Up @@ -438,6 +440,14 @@ static dword_result_t XamShowMessageBoxUi(
return result;
}

dword_result_t XamDoesOmniNeedConfiguration_entry() { return 0; }
DECLARE_XAM_EXPORT1(XamDoesOmniNeedConfiguration, kMisc, kStub);

dword_result_t XamFirstRunExperienceShouldRun_entry() {
return cvars::xconfig_initial_setup;
}
DECLARE_XAM_EXPORT1(XamFirstRunExperienceShouldRun, kMisc, kStub);

// https://www.se7ensins.com/forums/threads/working-xshowmessageboxui.844116/
dword_result_t XamShowMessageBoxUI_entry(
dword_t user_index, lpu16string_t title_ptr, lpu16string_t text_ptr,
Expand Down
93 changes: 92 additions & 1 deletion src/xenia/kernel/xam/xam_user.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "xenia/kernel/xthread.h"
#include "xenia/xbox.h"

#include <src/xenia/kernel/xam/xam_enum.cc>

DECLARE_int32(user_language);

namespace xe {
Expand All @@ -28,7 +30,8 @@ namespace xam {

dword_result_t XamProfileOpen_entry(qword_t xuid, lpstring_t mount_name) {
std::string guest_name = mount_name;
bool result = kernel_state()->xam_state()->GetUserProfile(xuid);
bool result =
kernel_state()->xam_state()->profile_manager()->GetProfile(xuid);

if (!result) {
return X_ERROR_FUNCTION_FAILED;
Expand Down Expand Up @@ -58,6 +61,16 @@ dword_result_t XamProfileCreateEnumerator_entry(dword_t device_id,
}
DECLARE_XAM_EXPORT1(XamProfileCreateEnumerator, kUserProfiles, kStub);

dword_result_t XamProfileEnumerate_entry(dword_t handle, dword_t flags,
lpvoid_t buffer,
pointer_t<XAM_OVERLAPPED> overlapped) {
uint32_t dummy;
auto result = xe::kernel::xam::xeXamEnumerate(handle, flags, buffer, 0,
!overlapped ? &dummy : nullptr, overlapped);
return result;
}
DECLARE_XAM_EXPORT1(XamProfileEnumerate, kUserProfiles, kSketchy);

X_HRESULT_result_t XamUserGetXUID_entry(dword_t user_index, dword_t type_mask,
lpqword_t xuid_ptr) {
assert_true(type_mask == 1 || type_mask == 2 || type_mask == 3 ||
Expand Down Expand Up @@ -697,6 +710,58 @@ dword_result_t XamParseGamerTileKey_entry(lpdword_t key_ptr, lpdword_t out1_ptr,
}
DECLARE_XAM_EXPORT1(XamParseGamerTileKey, kUserProfiles, kStub);

// https://github.com/xenia-canary/xenia-canary/blob/new_dashboard_run/src/xenia/kernel/xam/xam_user.cc
dword_result_t XamReadTile_entry(dword_t tile_type, dword_t title_id,
qword_t tile_id, dword_t user_index,
lpdword_t output_ptr,
lpdword_t buffer_size_ptr,
dword_t overlapped_ptr) {
// TODO: fully implement this.
if (!tile_id) {
return X_ERROR_INVALID_PARAMETER;
}
// Wrap function in a lambda func so we can use return to exit out when
// needed, but still always be able to set the xoverlapped value
// this way we don't need a bunch of if/else nesting to accomplish the same
auto main_fn = [tile_type, title_id, tile_id, user_index, output_ptr,
buffer_size_ptr]() {
uint64_t image_id = tile_id;
uint8_t* data = nullptr;
size_t data_len = 0;
std::unique_ptr<MappedMemory> mmap;
if (!output_ptr || !buffer_size_ptr) {
return X_ERROR_FILE_NOT_FOUND;
}
*buffer_size_ptr = (uint32_t)data_len;
return X_ERROR_SUCCESS;
};
auto result = main_fn();
if (overlapped_ptr) {
kernel_state()->CompleteOverlappedImmediate(overlapped_ptr, result);
return X_ERROR_IO_PENDING;
}
return result;
}
DECLARE_XAM_EXPORT1(XamReadTile, kUserProfiles, kStub);

dword_result_t XamReadTileEx_entry(dword_t tile_type, dword_t game_id,
qword_t item_id, dword_t offset,
dword_t unk1, dword_t unk2,
lpdword_t output_ptr,
lpdword_t buffer_size_ptr) {
return XamReadTile_entry(tile_type, game_id, item_id, offset, output_ptr,
buffer_size_ptr, 0);
}
DECLARE_XAM_EXPORT1(XamReadTileEx, kUserProfiles, kSketchy);

dword_result_t XamUserCreateTitlesPlayedEnumerator_entry(
dword_t user_index, dword_t xuid, dword_t flags, dword_t offset,
dword_t games_count, lpdword_t buffer_size_ptr, lpdword_t handle_ptr) {
// TODO: implement this.
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT1(XamUserCreateTitlesPlayedEnumerator, kUserProfiles, kStub);

dword_result_t XamReadTileToTexture_entry(dword_t unknown, dword_t title_id,
qword_t tile_id, dword_t user_index,
lpvoid_t buffer_ptr, dword_t stride,
Expand Down Expand Up @@ -827,6 +892,32 @@ dword_result_t XamProfileClose_entry(lpstring_t mount_name) {
}
DECLARE_XAM_EXPORT1(XamProfileClose, kUserProfiles, kStub);

#pragma pack(push, 1)
struct X_USER_INFO {
xe::be<uint64_t> xuid;
char name[16];
xe::be<uint32_t> user_index;
xe::be<uint32_t> unk;
xe::be<uint32_t> title_id;
xe::be<uint32_t> unk2;
xe::be<uint32_t> unk3;
};
static_assert_size(X_USER_INFO, 44);

typedef struct {
xe::be<uint32_t> user_count;
X_USER_INFO users_info[7];
} X_USER_PARTY_LIST;
static_assert_size(X_USER_PARTY_LIST, 4 + sizeof(X_USER_INFO) * 7);
#pragma pack(pop)

dword_result_t XamPartyGetUserListInternal_entry(
pointer_t<X_USER_PARTY_LIST> party_struct_ptr) {
party_struct_ptr->user_count = 0;
return X_ERROR_SUCCESS;
}
DECLARE_XAM_EXPORT1(XamPartyGetUserListInternal, kUserProfiles, kStub);

} // namespace xam
} // namespace kernel
} // namespace xe
Expand Down
6 changes: 5 additions & 1 deletion src/xenia/memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ bool Memory::Initialize() {
: kMemoryProtectNoAccess);
heaps_.physical.AllocFixed(0x1FFF0000, 0x10000, 0x10000,
kMemoryAllocationReserve, kMemoryProtectNoAccess);

// Pre-reserve encrypted part of memory
heaps_.v80000000.AllocFixed(
0x8C000000, 0x03FFFFFF, 0x10000,
kMemoryAllocationReserve | kMemoryAllocationCommit,
kMemoryProtectRead | kMemoryProtectWrite);
// GPU writeback.
// 0xC... is physical, 0x7F... is virtual. We may need to overlay these.
heaps_.vC0000000.AllocFixed(
Expand Down
6 changes: 0 additions & 6 deletions src/xenia/ui/d3d12/d3d12_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,6 @@ bool D3D12Provider::Initialize() {
programmable_sample_positions_tier_ =
options2.ProgrammableSamplePositionsTier;
}
D3D12_FEATURE_DATA_D3D12_OPTIONS8 options8;
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS8,
&options8, sizeof(options8)))) {
unaligned_block_textures_supported_ =
bool(options8.UnalignedBlockTexturesSupported);
}
virtual_address_bits_per_resource_ = 0;
D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT virtual_address_support;
if (SUCCEEDED(device->CheckFeatureSupport(
Expand Down
5 changes: 0 additions & 5 deletions src/xenia/ui/window_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ bool Win32Window::OpenImpl() {
// Disable rounded corners starting with Windows 11 (or silently receive and
// ignore E_INVALIDARG on Windows versions before 10.0.22000.0), primarily to
// preserve all pixels of the guest output.
DWM_WINDOW_CORNER_PREFERENCE window_corner_preference = DWMWCP_DONOTROUND;
DwmSetWindowAttribute(hwnd_, DWMWA_WINDOW_CORNER_PREFERENCE,
&window_corner_preference,
sizeof(window_corner_preference));
// Disable flicks.
ATOM atom = GlobalAddAtomW(L"MicrosoftTabletPenServiceProperty");
const DWORD_PTR dwHwndTabletProperty =
TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click)
Expand Down

0 comments on commit 146fdc3

Please sign in to comment.