Factoring out XMsg app stuff.

This commit is contained in:
Ben Vanik
2014-08-03 14:38:04 -07:00
parent 19149bbba6
commit 57dda9c755
11 changed files with 354 additions and 60 deletions

View File

@@ -0,0 +1,27 @@
/**
******************************************************************************
* 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/apps/apps.h>
#include <xenia/kernel/apps/xmp_app.h>
namespace xe {
namespace kernel {
namespace apps {
void RegisterApps(KernelState* kernel_state, XAppManager* manager) {
manager->RegisterApp(std::make_unique<XXMPApp>(kernel_state));
}
} // namespace apps
} // namespace kernel
} // namespace xe

View File

@@ -0,0 +1,33 @@
/**
******************************************************************************
* 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_XBOXKRNL_APPS_APPS_H_
#define XENIA_KERNEL_XBOXKRNL_APPS_APPS_H_
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/app.h>
#include <xenia/kernel/kernel_state.h>
namespace xe {
namespace kernel {
namespace apps {
void RegisterApps(KernelState* kernel_state, XAppManager* manager);
} // namespace apps
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APPS_APPS_H_

View File

@@ -0,0 +1,9 @@
# Copyright 2013 Ben Vanik. All Rights Reserved.
{
'sources': [
'apps.cc',
'apps.h',
'xmp_app.cc',
'xmp_app.h',
],
}

View File

@@ -0,0 +1,107 @@
/**
******************************************************************************
* 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/apps/xmp_app.h>
namespace xe {
namespace kernel {
namespace apps {
X_RESULT XXMPApp::XMPGetStatus(uint32_t unk, uint32_t status_ptr) {
// Some stupid games will hammer this on a thread - induce a delay
// here to keep from starving real threads.
Sleep(1);
XELOGD("XMPGetStatus(%.8X, %.8X)", unk, status_ptr);
assert_true(unk == 2);
poly::store_and_swap<uint32_t>(membase_ + status_ptr, 0);
return X_ERROR_SUCCESS;
}
X_RESULT XXMPApp::XMPGetStatusEx(uint32_t unk, uint32_t unk_ptr, uint32_t disabled_ptr) {
// Some stupid games will hammer this on a thread - induce a delay
// here to keep from starving real threads.
Sleep(1);
XELOGD("XMPGetStatusEx(%.8X, %.8X, %.8X)", unk, unk_ptr, disabled_ptr);
assert_true(unk == 2);
poly::store_and_swap<uint32_t>(membase_ + unk_ptr, 0);
poly::store_and_swap<uint32_t>(membase_ + disabled_ptr, 1);
return X_ERROR_SUCCESS;
}
X_RESULT XXMPApp::DispatchMessageSync(uint32_t message, uint32_t arg1, uint32_t arg2) {
// http://freestyledash.googlecode.com/svn-history/r1/trunk/Freestyle/Scenes/Media/Music/ScnMusic.cpp
switch (message) {
case 0x00070009: {
uint32_t unk =
poly::load_and_swap<uint32_t>(membase_ + arg1 + 0); // 0x00000002
uint32_t status_ptr = poly::load_and_swap<uint32_t>(
membase_ + arg1 + 4); // out ptr to 4b - expect 0
assert_zero(arg2);
return XMPGetStatus(unk, status_ptr);
}
case 0x0007001A: {
// dcz
// arg1 = ?
// arg2 = 0
break;
}
case 0x0007001B: {
uint32_t unk =
poly::load_and_swap<uint32_t>(membase_ + arg1 + 0); // 0x00000002
uint32_t unk_ptr = poly::load_and_swap<uint32_t>(
membase_ + arg1 + 4); // out ptr to 4b - expect 0
uint32_t disabled_ptr = poly::load_and_swap<uint32_t>(
membase_ + arg1 + 8); // out ptr to 4b - expect 1 (to skip)
assert_zero(arg2);
return XMPGetStatusEx(unk, unk_ptr, disabled_ptr);
}
}
XELOGE("Unimplemented XMsg message app=%.8X, msg=%.8X, arg1=%.8X, arg2=%.8X",
app_id(), message, arg1, arg2);
return X_ERROR_NOT_FOUND;
}
X_RESULT XXMPApp::DispatchMessageAsync(uint32_t message, uint32_t buffer_ptr, size_t buffer_length) {
switch (message) {
case 0x00070009: {
uint32_t unk =
poly::load_and_swap<uint32_t>(membase_ + buffer_ptr + 0); // 0x00000002
uint32_t status_ptr = poly::load_and_swap<uint32_t>(
membase_ + buffer_ptr + 4); // out ptr to 4b - expect 0
assert_true(buffer_length == 8);
return XMPGetStatus(unk, status_ptr);
}
case 0x0007001B: {
uint32_t unk =
poly::load_and_swap<uint32_t>(membase_ + buffer_ptr + 0); // 0x00000002
uint32_t unk_ptr = poly::load_and_swap<uint32_t>(
membase_ + buffer_ptr + 4); // out ptr to 4b - expect 0
uint32_t disabled_ptr = poly::load_and_swap<uint32_t>(
membase_ + buffer_ptr + 8); // out ptr to 4b - expect 1 (to skip)
assert_true(buffer_length == 0xC);
return XMPGetStatusEx(unk, unk_ptr, disabled_ptr);
}
}
XELOGE("Unimplemented XMsg message app=%.8X, msg=%.8X, buffer=%.8X, len=%d",
app_id(), message, buffer_ptr, buffer_length);
return X_ERROR_NOT_FOUND;
}
} // namespace apps
} // namespace kernel
} // namespace xe

View File

@@ -0,0 +1,42 @@
/**
******************************************************************************
* 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_XBOXKRNL_APPS_XMP_APP_H_
#define XENIA_KERNEL_XBOXKRNL_APPS_XMP_APP_H_
#include <xenia/common.h>
#include <xenia/core.h>
#include <xenia/kernel/app.h>
#include <xenia/kernel/kernel_state.h>
namespace xe {
namespace kernel {
namespace apps {
class XXMPApp : public XApp {
public:
XXMPApp(KernelState* kernel_state) : XApp(kernel_state, 0xFA) {}
X_RESULT XMPGetStatus(uint32_t unk, uint32_t status_ptr);
X_RESULT XMPGetStatusEx(uint32_t unk, uint32_t unk_ptr, uint32_t disabled_ptr);
X_RESULT DispatchMessageSync(uint32_t message, uint32_t arg1, uint32_t arg2) override;
X_RESULT DispatchMessageAsync(uint32_t message, uint32_t buffer_ptr, size_t buffer_length) override;
};
} // namespace apps
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APPS_XMP_APP_H_