xb style.

This commit is contained in:
Ben Vanik 2015-08-07 07:56:57 -07:00
parent 5e08889d93
commit 14beb27ebc
63 changed files with 338 additions and 331 deletions

View File

@ -14,10 +14,6 @@
#include "xenia/cpu/processor.h" #include "xenia/cpu/processor.h"
#include "xenia/cpu/thread_state.h" #include "xenia/cpu/thread_state.h"
using namespace xe;
using namespace xe::cpu::backend::x64;
using namespace xe::cpu;
namespace xe { namespace xe {
namespace cpu { namespace cpu {
namespace backend { namespace backend {

View File

@ -10,6 +10,8 @@
#ifndef XENIA_CPU_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_ #ifndef XENIA_CPU_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_
#define XENIA_CPU_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_ #define XENIA_CPU_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_
#include <cmath>
#include "xenia/base/platform.h" #include "xenia/base/platform.h"
#include "xenia/cpu/compiler/compiler_pass.h" #include "xenia/cpu/compiler/compiler_pass.h"
@ -20,7 +22,6 @@
#include <llvm/ADT/BitVector.h> #include <llvm/ADT/BitVector.h>
#pragma warning(pop) #pragma warning(pop)
#else #else
#include <cmath>
#include <llvm/ADT/BitVector.h> #include <llvm/ADT/BitVector.h>
#endif // XE_COMPILER_MSVC #endif // XE_COMPILER_MSVC

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_APP_H_ #ifndef XENIA_KERNEL_APP_H_
#define XENIA_KERNEL_XBOXKRNL_APP_H_ #define XENIA_KERNEL_APP_H_
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
@ -53,4 +53,4 @@ class XAppManager {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APP_H_ #endif // XENIA_KERNEL_APP_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_APPS_APPS_H_ #ifndef XENIA_KERNEL_APPS_APPS_H_
#define XENIA_KERNEL_XBOXKRNL_APPS_APPS_H_ #define XENIA_KERNEL_APPS_APPS_H_
#include "xenia/kernel/app.h" #include "xenia/kernel/app.h"
#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/kernel_state.h"
@ -23,4 +23,4 @@ void RegisterApps(KernelState* kernel_state, XAppManager* manager);
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APPS_APPS_H_ #endif // XENIA_KERNEL_APPS_APPS_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_APPS_XGI_APP_H_ #ifndef XENIA_KERNEL_APPS_XGI_APP_H_
#define XENIA_KERNEL_XBOXKRNL_APPS_XGI_APP_H_ #define XENIA_KERNEL_APPS_XGI_APP_H_
#include "xenia/kernel/app.h" #include "xenia/kernel/app.h"
#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/kernel_state.h"
@ -31,4 +31,4 @@ class XXGIApp : public XApp {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APPS_XGI_APP_H_ #endif // XENIA_KERNEL_APPS_XGI_APP_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_APPS_XLIVEBASE_APP_H_ #ifndef XENIA_KERNEL_APPS_XLIVEBASE_APP_H_
#define XENIA_KERNEL_XBOXKRNL_APPS_XLIVEBASE_APP_H_ #define XENIA_KERNEL_APPS_XLIVEBASE_APP_H_
#include "xenia/kernel/app.h" #include "xenia/kernel/app.h"
#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/kernel_state.h"
@ -31,4 +31,4 @@ class XXLiveBaseApp : public XApp {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APPS_XLIVEBASE_APP_H_ #endif // XENIA_KERNEL_APPS_XLIVEBASE_APP_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_APPS_XMP_APP_H_ #ifndef XENIA_KERNEL_APPS_XMP_APP_H_
#define XENIA_KERNEL_XBOXKRNL_APPS_XMP_APP_H_ #define XENIA_KERNEL_APPS_XMP_APP_H_
#include <memory> #include <memory>
#include <mutex> #include <mutex>
@ -112,4 +112,4 @@ class XXMPApp : public XApp {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_APPS_XMP_APP_H_ #endif // XENIA_KERNEL_APPS_XMP_APP_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_ASYNC_REQUEST_H_ #ifndef XENIA_KERNEL_ASYNC_REQUEST_H_
#define XENIA_KERNEL_XBOXKRNL_ASYNC_REQUEST_H_ #define XENIA_KERNEL_ASYNC_REQUEST_H_
#include <vector> #include <vector>
@ -50,4 +50,4 @@ class XAsyncRequest {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_ASYNC_REQUEST_H_ #endif // XENIA_KERNEL_ASYNC_REQUEST_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_DISPATCHER_H_ #ifndef XENIA_KERNEL_DISPATCHER_H_
#define XENIA_KERNEL_XBOXKRNL_DISPATCHER_H_ #define XENIA_KERNEL_DISPATCHER_H_
#include <mutex> #include <mutex>
@ -44,4 +44,4 @@ class Dispatcher {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_DISPATCHER_H_ #endif // XENIA_KERNEL_DISPATCHER_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_NATIVE_LIST_H_ #ifndef XENIA_KERNEL_NATIVE_LIST_H_
#define XENIA_KERNEL_XBOXKRNL_NATIVE_LIST_H_ #define XENIA_KERNEL_NATIVE_LIST_H_
#include "xenia/memory.h" #include "xenia/memory.h"
#include "xenia/xbox.h" #include "xenia/xbox.h"
@ -47,4 +47,4 @@ class NativeList {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_NATIVE_LIST_H_ #endif // XENIA_KERNEL_NATIVE_LIST_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_OBJECT_TABLE_H_ #ifndef XENIA_KERNEL_OBJECT_TABLE_H_
#define XENIA_KERNEL_XBOXKRNL_OBJECT_TABLE_H_ #define XENIA_KERNEL_OBJECT_TABLE_H_
#include <mutex> #include <mutex>
#include <string> #include <string>
@ -74,4 +74,4 @@ class ObjectTable {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_OBJECT_TABLE_H_ #endif // XENIA_KERNEL_OBJECT_TABLE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XENUMERATOR_H_ #ifndef XENIA_KERNEL_OBJECTS_XENUMERATOR_H_
#define XENIA_KERNEL_XBOXKRNL_XENUMERATOR_H_ #define XENIA_KERNEL_OBJECTS_XENUMERATOR_H_
#include <cstring> #include <cstring>
#include <vector> #include <vector>
@ -82,4 +82,4 @@ class XStaticEnumerator : public XEnumerator {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XENUMERATOR_H_ #endif // XENIA_KERNEL_OBJECTS_XENUMERATOR_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XEVENT_H_ #ifndef XENIA_KERNEL_OBJECTS_XEVENT_H_
#define XENIA_KERNEL_XBOXKRNL_XEVENT_H_ #define XENIA_KERNEL_OBJECTS_XEVENT_H_
#include "xenia/base/threading.h" #include "xenia/base/threading.h"
#include "xenia/kernel/xobject.h" #include "xenia/kernel/xobject.h"
@ -44,4 +44,4 @@ class XEvent : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XEVENT_H_ #endif // XENIA_KERNEL_OBJECTS_XEVENT_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XFILE_H_ #ifndef XENIA_KERNEL_OBJECTS_XFILE_H_
#define XENIA_KERNEL_XBOXKRNL_XFILE_H_ #define XENIA_KERNEL_OBJECTS_XFILE_H_
#include "xenia/base/filesystem.h" #include "xenia/base/filesystem.h"
#include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xevent.h"
@ -130,4 +130,4 @@ class XFile : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XFILE_H_ #endif // XENIA_KERNEL_OBJECTS_XFILE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XKERNEL_MODULE_H_ #ifndef XENIA_KERNEL_OBJECTS_XKERNEL_MODULE_H_
#define XENIA_KERNEL_XBOXKRNL_XKERNEL_MODULE_H_ #define XENIA_KERNEL_OBJECTS_XKERNEL_MODULE_H_
#include "xenia/emulator.h" #include "xenia/emulator.h"
#include "xenia/kernel/objects/xmodule.h" #include "xenia/kernel/objects/xmodule.h"
@ -35,4 +35,4 @@ class XKernelModule : public XModule {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XKERNEL_MODULE_H_ #endif // XENIA_KERNEL_OBJECTS_XKERNEL_MODULE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XMODULE_H_ #ifndef XENIA_KERNEL_OBJECTS_XMODULE_H_
#define XENIA_KERNEL_XBOXKRNL_XMODULE_H_ #define XENIA_KERNEL_OBJECTS_XMODULE_H_
#include <string> #include <string>
@ -100,4 +100,4 @@ class XModule : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XMODULE_H_ #endif // XENIA_KERNEL_OBJECTS_XMODULE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XMUTANT_H_ #ifndef XENIA_KERNEL_OBJECTS_XMUTANT_H_
#define XENIA_KERNEL_XBOXKRNL_XMUTANT_H_ #define XENIA_KERNEL_OBJECTS_XMUTANT_H_
#include "xenia/base/threading.h" #include "xenia/base/threading.h"
#include "xenia/kernel/xobject.h" #include "xenia/kernel/xobject.h"
@ -36,4 +36,4 @@ class XMutant : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XMUTANT_H_ #endif // XENIA_KERNEL_OBJECTS_XMUTANT_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XNOTIFY_LISTENER_H_ #ifndef XENIA_KERNEL_OBJECTS_XNOTIFY_LISTENER_H_
#define XENIA_KERNEL_XBOXKRNL_XNOTIFY_LISTENER_H_ #define XENIA_KERNEL_OBJECTS_XNOTIFY_LISTENER_H_
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
@ -49,4 +49,4 @@ class XNotifyListener : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XNOTIFY_LISTENER_H_ #endif // XENIA_KERNEL_OBJECTS_XNOTIFY_LISTENER_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #ifndef XENIA_KERNEL_OBJECTS_XSEMAPHORE_H_
#define XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #define XENIA_KERNEL_OBJECTS_XSEMAPHORE_H_
#include "xenia/base/threading.h" #include "xenia/base/threading.h"
#include "xenia/kernel/xobject.h" #include "xenia/kernel/xobject.h"
@ -43,4 +43,4 @@ class XSemaphore : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_ #endif // XENIA_KERNEL_OBJECTS_XSEMAPHORE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XTHREAD_H_ #ifndef XENIA_KERNEL_OBJECTS_XTHREAD_H_
#define XENIA_KERNEL_XBOXKRNL_XTHREAD_H_ #define XENIA_KERNEL_OBJECTS_XTHREAD_H_
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
@ -208,4 +208,4 @@ class XHostThread : public XThread {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XTHREAD_H_ #endif // XENIA_KERNEL_OBJECTS_XTHREAD_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XTIMER_H_ #ifndef XENIA_KERNEL_OBJECTS_XTIMER_H_
#define XENIA_KERNEL_XBOXKRNL_XTIMER_H_ #define XENIA_KERNEL_OBJECTS_XTIMER_H_
#include "xenia/base/threading.h" #include "xenia/base/threading.h"
#include "xenia/kernel/xobject.h" #include "xenia/kernel/xobject.h"
@ -41,4 +41,4 @@ class XTimer : public XObject {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_TIMER_H_ #endif // XENIA_KERNEL_OBJECTS_TIMER_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XUSER_MODULE_H_ #ifndef XENIA_KERNEL_OBJECTS_XUSER_MODULE_H_
#define XENIA_KERNEL_XBOXKRNL_XUSER_MODULE_H_ #define XENIA_KERNEL_OBJECTS_XUSER_MODULE_H_
#include <string> #include <string>
@ -80,4 +80,4 @@ class XUserModule : public XModule {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XUSER_MODULE_H_ #endif // XENIA_KERNEL_OBJECTS_XUSER_MODULE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_USER_PROFILE_H_ #ifndef XENIA_KERNEL_USER_PROFILE_H_
#define XENIA_KERNEL_XBOXKRNL_USER_PROFILE_H_ #define XENIA_KERNEL_USER_PROFILE_H_
#include <memory> #include <memory>
#include <string> #include <string>
@ -196,4 +196,4 @@ class UserProfile {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_USER_PROFILE_H_ #endif // XENIA_KERNEL_USER_PROFILE_H_

View File

@ -78,7 +78,7 @@ inline uint64_t get_arg_64(PPCContext* ppc_context, uint8_t index) {
uint32_t stack_address = get_arg_stack_ptr(ppc_context, index - 8); uint32_t stack_address = get_arg_stack_ptr(ppc_context, index - 8);
return SHIM_MEM_64(stack_address); return SHIM_MEM_64(stack_address);
} }
} } // namespace util
#define SHIM_GET_ARG_8(n) util::get_arg_8(ppc_context, n) #define SHIM_GET_ARG_8(n) util::get_arg_8(ppc_context, n)
#define SHIM_GET_ARG_16(n) util::get_arg_16(ppc_context, n) #define SHIM_GET_ARG_16(n) util::get_arg_16(ppc_context, n)
@ -123,7 +123,8 @@ class Param {
}; };
template <> template <>
inline void Param::LoadValue<float>(Param::Init& init, float* out_value) { inline void Param::LoadValue<float>(Param::Init& init, float* out_value) {
*out_value = float(init.ppc_context->f[1 + ++init.float_ordinal]); *out_value =
static_cast<float>(init.ppc_context->f[1 + ++init.float_ordinal]);
} }
template <> template <>
inline void Param::LoadValue<double>(Param::Init& init, double* out_value) { inline void Param::LoadValue<double>(Param::Init& init, double* out_value) {
@ -322,10 +323,10 @@ inline void AppendParam(StringBuffer& string_buffer, qword_t param) {
string_buffer.AppendFormat("%.16llX", uint64_t(param)); string_buffer.AppendFormat("%.16llX", uint64_t(param));
} }
inline void AppendParam(StringBuffer& string_buffer, float_t param) { inline void AppendParam(StringBuffer& string_buffer, float_t param) {
string_buffer.AppendFormat("%G", float(param)); string_buffer.AppendFormat("%G", static_cast<float>(param));
} }
inline void AppendParam(StringBuffer& string_buffer, double_t param) { inline void AppendParam(StringBuffer& string_buffer, double_t param) {
string_buffer.AppendFormat("%G", double(param)); string_buffer.AppendFormat("%G", static_cast<double>(param));
} }
inline void AppendParam(StringBuffer& string_buffer, lpvoid_t param) { inline void AppendParam(StringBuffer& string_buffer, lpvoid_t param) {
string_buffer.AppendFormat("%.8X", uint32_t(param)); string_buffer.AppendFormat("%.8X", uint32_t(param));

View File

@ -9,12 +9,12 @@
#include "xenia/kernel/util/xex2.h" #include "xenia/kernel/util/xex2.h"
#include <gflags/gflags.h>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <vector> #include <vector>
#include <gflags/gflags.h>
#include "third_party/crypto/rijndael-alg-fst.h" #include "third_party/crypto/rijndael-alg-fst.h"
#include "third_party/crypto/rijndael-alg-fst.c" #include "third_party/crypto/rijndael-alg-fst.c"
#include "third_party/mspack/lzx.h" #include "third_party/mspack/lzx.h"

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XEX2_INFO_H_ #ifndef XENIA_KERNEL_UTIL_XEX2_INFO_H_
#define XENIA_KERNEL_XEX2_INFO_H_ #define XENIA_KERNEL_UTIL_XEX2_INFO_H_
#include <cstdint> #include <cstdint>
@ -91,7 +91,7 @@ enum xe_xex2_system_flags : uint32_t {
XEX_SYSTEM_ALLOW_AVATAR_GET_METADATA_BY_XUID = 0x20000000, XEX_SYSTEM_ALLOW_AVATAR_GET_METADATA_BY_XUID = 0x20000000,
XEX_SYSTEM_ALLOW_CONTROLLER_SWAPPING = 0x40000000, XEX_SYSTEM_ALLOW_CONTROLLER_SWAPPING = 0x40000000,
XEX_SYSTEM_DASH_EXTENSIBILITY_MODULE = 0x80000000, XEX_SYSTEM_DASH_EXTENSIBILITY_MODULE = 0x80000000,
// TODO: figure out how stored // TODO(benvanik): figure out how stored.
/*XEX_SYSTEM_ALLOW_NETWORK_READ_CANCEL = 0x0, /*XEX_SYSTEM_ALLOW_NETWORK_READ_CANCEL = 0x0,
XEX_SYSTEM_UNINTERRUPTABLE_READS = 0x0, XEX_SYSTEM_UNINTERRUPTABLE_READS = 0x0,
XEX_SYSTEM_REQUIRE_FULL_EXPERIENCE = 0x0, XEX_SYSTEM_REQUIRE_FULL_EXPERIENCE = 0x0,
@ -645,4 +645,4 @@ struct X_IMAGE_EXPORT_DIRECTORY {
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XEX2_INFO_H_ #endif // XENIA_KERNEL_UTIL_XEX2_INFO_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_MODULE_H_ #ifndef XENIA_KERNEL_MODULE_H_
#define XENIA_KERNEL_XBOXKRNL_MODULE_H_ #define XENIA_KERNEL_MODULE_H_
#include <memory> #include <memory>
@ -41,4 +41,4 @@ class XboxkrnlModule : public XKernelModule {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_MODULE_H_ #endif // XENIA_KERNEL_MODULE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ #ifndef XENIA_KERNEL_ORDINALS_H_
#define XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ #define XENIA_KERNEL_ORDINALS_H_
#include "xenia/cpu/export_resolver.h" #include "xenia/cpu/export_resolver.h"
@ -21,4 +21,4 @@ enum {
} // namespace ordinals } // namespace ordinals
#include "xenia/kernel/util/ordinal_table_post.inc" #include "xenia/kernel/util/ordinal_table_post.inc"
#endif // XENIA_KERNEL_XBOXKRNL_ORDINALS_H_ #endif // XENIA_KERNEL_ORDINALS_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ #ifndef XENIA_KERNEL_PRIVATE_H_
#define XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ #define XENIA_KERNEL_PRIVATE_H_
#include "xenia/kernel/xboxkrnl_ordinals.h" #include "xenia/kernel/xboxkrnl_ordinals.h"
@ -58,4 +58,4 @@ void RegisterVideoExports(xe::cpu::ExportResolver* export_resolver,
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_PRIVATE_H_ #endif // XENIA_KERNEL_PRIVATE_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_RTL_H_ #ifndef XENIA_KERNEL_RTL_H_
#define XENIA_KERNEL_XBOXKRNL_RTL_H_ #define XENIA_KERNEL_RTL_H_
#include "xenia/xbox.h" #include "xenia/xbox.h"
@ -26,4 +26,4 @@ X_STATUS xeRtlInitializeCriticalSectionAndSpinCount(X_RTL_CRITICAL_SECTION* cs,
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_RTL_H_ #endif // XENIA_KERNEL_RTL_H_

View File

@ -7,8 +7,8 @@
****************************************************************************** ******************************************************************************
*/ */
#ifndef XENIA_KERNEL_XBOXKRNL_XOBJECT_H_ #ifndef XENIA_KERNEL_XOBJECT_H_
#define XENIA_KERNEL_XBOXKRNL_XOBJECT_H_ #define XENIA_KERNEL_XOBJECT_H_
#include <atomic> #include <atomic>
@ -323,4 +323,4 @@ object_ref<T> retain_object(T* ptr) {
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe
#endif // XENIA_KERNEL_XBOXKRNL_XOBJECT_H_ #endif // XENIA_KERNEL_XOBJECT_H_

View File

@ -12,6 +12,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
namespace xe { namespace xe {

View File

@ -35,48 +35,46 @@ Blitter::~Blitter() = default;
bool Blitter::Initialize() { bool Blitter::Initialize() {
const std::string header = const std::string header =
"\n\ R"(
#version 450 \n\ #version 450
#extension GL_ARB_explicit_uniform_location : require \n\ #extension GL_ARB_explicit_uniform_location : require
#extension GL_ARB_shading_language_420pack : require \n\ #extension GL_ARB_shading_language_420pack : require
precision highp float; \n\ precision highp float;
precision highp int; \n\ precision highp int;
layout(std140, column_major) uniform; \n\ layout(std140, column_major) uniform;
layout(std430, column_major) buffer; \n\ layout(std430, column_major) buffer;
"; )";
const std::string vs_source = header + const std::string vs_source = header +
"\n\ R"(
layout(location = 0) uniform vec4 src_uv; \n\ layout(location = 0) uniform vec4 src_uv;
out gl_PerVertex { \n\ out gl_PerVertex {
vec4 gl_Position; \n\ vec4 gl_Position;
float gl_PointSize; \n\ float gl_PointSize;
float gl_ClipDistance[]; \n\ float gl_ClipDistance[];
}; \n\ };
layout(location = 0) in vec2 vfetch_pos; \n\ layout(location = 0) in vec2 vfetch_pos;
layout(location = 0) out vec2 vtx_uv; \n\ layout(location = 0) out vec2 vtx_uv;
void main() { \n\ void main() {
gl_Position = vec4(vfetch_pos.xy * vec2(2.0, -2.0) - vec2(1.0, -1.0), 0.0, 1.0); \n\ gl_Position = vec4(vfetch_pos.xy * vec2(2.0, -2.0) -
vtx_uv = vfetch_pos.xy * src_uv.zw + src_uv.xy; \n\ vec2(1.0, -1.0), 0.0, 1.0);
} \n\ vtx_uv = vfetch_pos.xy * src_uv.zw + src_uv.xy;
"; })";
const std::string color_fs_source = header + const std::string color_fs_source = header +
"\n\ R"(
layout(location = 1) uniform sampler2D src_texture; \n\ layout(location = 1) uniform sampler2D src_texture;
layout(location = 0) in vec2 vtx_uv; \n\ layout(location = 0) in vec2 vtx_uv;
layout(location = 0) out vec4 oC; \n\ layout(location = 0) out vec4 oC;
void main() { \n\ void main() {
oC = texture(src_texture, vtx_uv); \n\ oC = texture(src_texture, vtx_uv);
} \n\ })";
";
const std::string depth_fs_source = header + const std::string depth_fs_source = header +
"\n\ R"(
layout(location = 1) uniform sampler2D src_texture; \n\ layout(location = 1) uniform sampler2D src_texture;
layout(location = 0) in vec2 vtx_uv; \n\ layout(location = 0) in vec2 vtx_uv;
layout(location = 0) out vec4 oC; \n\ layout(location = 0) out vec4 oC;
void main() { \n\ void main() {
gl_FragDepth = texture(src_texture, vtx_uv).r; \n\ gl_FragDepth = texture(src_texture, vtx_uv).r;
} \n\ })";
";
auto vs_source_str = vs_source.c_str(); auto vs_source_str = vs_source.c_str();
vertex_program_ = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &vs_source_str); vertex_program_ = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &vs_source_str);
@ -165,7 +163,8 @@ struct SavedState {
glGetIntegerv(GL_CULL_FACE_MODE, &cull_face); glGetIntegerv(GL_CULL_FACE_MODE, &cull_face);
glGetIntegerv(GL_FRONT_FACE, &front_face); glGetIntegerv(GL_FRONT_FACE, &front_face);
glGetIntegerv(GL_POLYGON_MODE, &polygon_mode); glGetIntegerv(GL_POLYGON_MODE, &polygon_mode);
glGetBooleani_v(GL_COLOR_WRITEMASK, 0, (GLboolean*)&color_mask_0_enabled); glGetBooleani_v(GL_COLOR_WRITEMASK, 0,
reinterpret_cast<GLboolean*>(&color_mask_0_enabled));
blend_0_enabled = glIsEnabledi(GL_BLEND, 0); blend_0_enabled = glIsEnabledi(GL_BLEND, 0);
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_buffer); glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_buffer);
glGetFloati_v(GL_VIEWPORT, 0, viewport); glGetFloati_v(GL_VIEWPORT, 0, viewport);
@ -230,10 +229,11 @@ void Blitter::Draw(GLuint src_texture, Rect2D src_rect, Rect2D dest_rect,
GLint src_texture_height; GLint src_texture_height;
glGetTextureLevelParameteriv(src_texture, 0, GL_TEXTURE_HEIGHT, glGetTextureLevelParameteriv(src_texture, 0, GL_TEXTURE_HEIGHT,
&src_texture_height); &src_texture_height);
glProgramUniform4f(vertex_program_, 0, src_rect.x / float(src_texture_width), glProgramUniform4f(vertex_program_, 0,
src_rect.y / float(src_texture_height), src_rect.x / static_cast<float>(src_texture_width),
src_rect.width / float(src_texture_width), src_rect.y / static_cast<float>(src_texture_height),
src_rect.height / float(src_texture_height)); src_rect.width / static_cast<float>(src_texture_width),
src_rect.height / static_cast<float>(src_texture_height));
// Useful for seeing the entire framebuffer/etc: // Useful for seeing the entire framebuffer/etc:
// glProgramUniform4f(vertex_program_, 0, 0.0f, 0.0f, 1.0f, 1.0f); // glProgramUniform4f(vertex_program_, 0, 0.0f, 0.0f, 1.0f, 1.0f);

View File

@ -9,6 +9,8 @@
#include "xenia/ui/gl/circular_buffer.h" #include "xenia/ui/gl/circular_buffer.h"
#include <algorithm>
#include "xenia/base/assert.h" #include "xenia/base/assert.h"
#include "xenia/base/math.h" #include "xenia/base/math.h"

View File

@ -10,6 +10,7 @@
#include "xenia/ui/gl/gl4_elemental_renderer.h" #include "xenia/ui/gl/gl4_elemental_renderer.h"
#include <memory> #include <memory>
#include <string>
#include "el/graphics/bitmap_fragment.h" #include "el/graphics/bitmap_fragment.h"
#include "el/util/math.h" #include "el/util/math.h"
@ -93,45 +94,43 @@ bool GL4ElementalRenderer::Initialize() {
} }
const std::string header = const std::string header =
"\n\ R"(
#version 450 \n\ #version 450
#extension GL_ARB_bindless_texture : require \n\ #extension GL_ARB_bindless_texture : require
#extension GL_ARB_explicit_uniform_location : require \n\ #extension GL_ARB_explicit_uniform_location : require
#extension GL_ARB_shading_language_420pack : require \n\ #extension GL_ARB_shading_language_420pack : require
precision highp float; \n\ precision highp float;
precision highp int; \n\ precision highp int;
layout(std140, column_major) uniform; \n\ layout(std140, column_major) uniform;
layout(std430, column_major) buffer; \n\ layout(std430, column_major) buffer;
"; )";
const std::string vertex_shader_source = header + const std::string vertex_shader_source = header +
"\n\ R"(
layout(location = 0) uniform mat4 projection_matrix; \n\ layout(location = 0) uniform mat4 projection_matrix;
layout(location = 0) in vec2 in_pos; \n\ layout(location = 0) in vec2 in_pos;
layout(location = 1) in vec4 in_color; \n\ layout(location = 1) in vec4 in_color;
layout(location = 2) in vec2 in_uv; \n\ layout(location = 2) in vec2 in_uv;
layout(location = 0) out vec4 vtx_color; \n\ layout(location = 0) out vec4 vtx_color;
layout(location = 1) out vec2 vtx_uv; \n\ layout(location = 1) out vec2 vtx_uv;
void main() { \n\ void main() {
gl_Position = projection_matrix * vec4(in_pos.xy, 0.0, 1.0); \n\ gl_Position = projection_matrix * vec4(in_pos.xy, 0.0, 1.0);
vtx_color = in_color; \n\ vtx_color = in_color;
vtx_uv = in_uv; \n\ vtx_uv = in_uv;
} \n\ })";
";
const std::string fragment_shader_source = header + const std::string fragment_shader_source = header +
"\n\ R"(
layout(location = 1, bindless_sampler) uniform sampler2D texture_sampler; \n\ layout(location = 1, bindless_sampler) uniform sampler2D texture_sampler;
layout(location = 2) uniform float texture_mix; \n\ layout(location = 2) uniform float texture_mix;
layout(location = 0) in vec4 vtx_color; \n\ layout(location = 0) in vec4 vtx_color;
layout(location = 1) in vec2 vtx_uv; \n\ layout(location = 1) in vec2 vtx_uv;
layout(location = 0) out vec4 oC; \n\ layout(location = 0) out vec4 oC;
void main() { \n\ void main() {
oC = vtx_color; \n\ oC = vtx_color;
if (texture_mix > 0.0) { \n\ if (texture_mix > 0.0) {
vec4 color = texture(texture_sampler, vtx_uv); \n\ vec4 color = texture(texture_sampler, vtx_uv);
oC *= color.rgba; \n\ oC *= color.rgba;
} \n\ }
} \n\ })";
";
GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER); GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER);
const char* vertex_shader_source_ptr = vertex_shader_source.c_str(); const char* vertex_shader_source_ptr = vertex_shader_source.c_str();
@ -204,8 +203,8 @@ void GL4ElementalRenderer::BeginPaint(int render_target_w,
glScissor(0, 0, render_target_w, render_target_h); glScissor(0, 0, render_target_w, render_target_h);
float left = 0.0f; float left = 0.0f;
float right = float(render_target_w); float right = static_cast<float>(render_target_w);
float bottom = float(render_target_h); float bottom = static_cast<float>(render_target_h);
float top = 0.0f; float top = 0.0f;
float z_near = -1.0f; float z_near = -1.0f;
float z_far = 1.0f; float z_far = 1.0f;

View File

@ -23,7 +23,7 @@ namespace gl {
class GL4ElementalRenderer : public el::graphics::Renderer { class GL4ElementalRenderer : public el::graphics::Renderer {
public: public:
GL4ElementalRenderer(GLContext* context); explicit GL4ElementalRenderer(GLContext* context);
~GL4ElementalRenderer() override; ~GL4ElementalRenderer() override;
static std::unique_ptr<GL4ElementalRenderer> Create(GLContext* context); static std::unique_ptr<GL4ElementalRenderer> Create(GLContext* context);

View File

@ -449,7 +449,8 @@ void GLContext::BeginSwap() {
SCOPE_profile_cpu_i("gpu", "xe::ui::gl::GLContext::BeginSwap"); SCOPE_profile_cpu_i("gpu", "xe::ui::gl::GLContext::BeginSwap");
float clear_color[] = {238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f}; float clear_color[] = {238 / 255.0f, 238 / 255.0f, 238 / 255.0f, 1.0f};
if (FLAGS_random_clear_color) { if (FLAGS_random_clear_color) {
clear_color[0] = rand() / (float)RAND_MAX; clear_color[0] =
rand() / static_cast<float>(RAND_MAX); // NOLINT(runtime/threadsafe_fn)
clear_color[1] = 1.0f; clear_color[1] = 1.0f;
clear_color[2] = 0.0f; clear_color[2] = 0.0f;
clear_color[3] = 1.0f; clear_color[3] = 1.0f;

View File

@ -49,7 +49,7 @@ class GLContext : public GraphicsContext {
Blitter* blitter() { return &blitter_; } Blitter* blitter() { return &blitter_; }
private: private:
GLContext(Window* target_window); explicit GLContext(Window* target_window);
GLContext(Window* target_window, HGLRC glrc); GLContext(Window* target_window, HGLRC glrc);
bool Initialize(Window* target_window); bool Initialize(Window* target_window);

View File

@ -9,6 +9,9 @@
#include "xenia/ui/gl/gl_profiler_display.h" #include "xenia/ui/gl/gl_profiler_display.h"
#include <algorithm>
#include <string>
#include "third_party/microprofile/microprofileui.h" #include "third_party/microprofile/microprofileui.h"
#include "xenia/base/assert.h" #include "xenia/base/assert.h"
@ -255,50 +258,48 @@ bool GLProfilerDisplay::SetupState() {
bool GLProfilerDisplay::SetupShaders() { bool GLProfilerDisplay::SetupShaders() {
const std::string header = const std::string header =
"\n\ R"(
#version 450 \n\ #version 450
#extension GL_ARB_bindless_texture : require \n\ #extension GL_ARB_bindless_texture : require
#extension GL_ARB_explicit_uniform_location : require \n\ #extension GL_ARB_explicit_uniform_location : require
#extension GL_ARB_shading_language_420pack : require \n\ #extension GL_ARB_shading_language_420pack : require
precision highp float; \n\ precision highp float;
precision highp int; \n\ precision highp int;
layout(std140, column_major) uniform; \n\ layout(std140, column_major) uniform;
layout(std430, column_major) buffer; \n\ layout(std430, column_major) buffer;
"; )";
const std::string vertex_shader_source = header + const std::string vertex_shader_source = header +
"\n\ R"(
layout(location = 0) uniform mat4 projection_matrix; \n\ layout(location = 0) uniform mat4 projection_matrix;
layout(location = 0) in vec2 in_pos; \n\ layout(location = 0) in vec2 in_pos;
layout(location = 1) in vec4 in_color; \n\ layout(location = 1) in vec4 in_color;
layout(location = 2) in vec2 in_uv; \n\ layout(location = 2) in vec2 in_uv;
layout(location = 0) out vec4 vtx_color; \n\ layout(location = 0) out vec4 vtx_color;
layout(location = 1) out vec2 vtx_uv; \n\ layout(location = 1) out vec2 vtx_uv;
void main() { \n\ void main() {
gl_Position = projection_matrix * vec4(in_pos.xy, 0.0, 1.0); \n\ gl_Position = projection_matrix * vec4(in_pos.xy, 0.0, 1.0);
vtx_color = in_color; \n\ vtx_color = in_color;
vtx_uv = in_uv; \n\ vtx_uv = in_uv;
} \n\ })";
";
const std::string fragment_shader_source = header + const std::string fragment_shader_source = header +
"\n\ R"(
layout(location = 1, bindless_sampler) uniform sampler2D font_texture; \n\ layout(location = 1, bindless_sampler) uniform sampler2D font_texture;
layout(location = 2) uniform float font_height; \n\ layout(location = 2) uniform float font_height;
layout(location = 0) in vec4 vtx_color; \n\ layout(location = 0) in vec4 vtx_color;
layout(location = 1) in vec2 vtx_uv; \n\ layout(location = 1) in vec2 vtx_uv;
layout(location = 0) out vec4 oC; \n\ layout(location = 0) out vec4 oC;
void main() { \n\ void main() {
if (vtx_uv.x > 1.0) { \n\ if (vtx_uv.x > 1.0) {
oC = vtx_color; \n\ oC = vtx_color;
} else { \n\ } else {
vec4 color = texture(font_texture, vtx_uv); \n\ vec4 color = texture(font_texture, vtx_uv);
oC = color.rgba * vtx_color; \n\ oC = color.rgba * vtx_color;
if (color.a < 0.5) { \n\ if (color.a < 0.5) {
vec4 c1 = texture(font_texture, vtx_uv + vec2(0.0, font_height)); \n\ vec4 c1 = texture(font_texture, vtx_uv + vec2(0.0, font_height));
oC = vec4(0, 0, 0, c1.a); \n\ oC = vec4(0, 0, 0, c1.a);
} \n\ }
} \n\ }
} \n\ })";
";
GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER); GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER);
const char* vertex_shader_source_ptr = vertex_shader_source.c_str(); const char* vertex_shader_source_ptr = vertex_shader_source.c_str();
@ -365,8 +366,8 @@ void GLProfilerDisplay::Begin() {
glViewport(0, 0, width(), height()); glViewport(0, 0, width(), height());
float left = 0.0f; float left = 0.0f;
float right = float(width()); float right = static_cast<float>(width());
float bottom = float(height()); float bottom = static_cast<float>(height());
float top = 0.0f; float top = 0.0f;
float z_near = -1.0f; float z_near = -1.0f;
float z_far = 1.0f; float z_far = 1.0f;
@ -441,23 +442,23 @@ void GLProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
if (type == BoxType::kFlat) { if (type == BoxType::kFlat) {
color = color =
((color & 0xff) << 16) | ((color >> 16) & 0xff) | (0xff00ff00 & color); ((color & 0xff) << 16) | ((color >> 16) & 0xff) | (0xff00ff00 & color);
Q0(v, x, (float)x0); Q0(v, x, x0);
Q0(v, y, (float)y0); Q0(v, y, y0);
Q0(v, color, color); Q0(v, color, color);
Q0(v, u, 2.0f); Q0(v, u, 2.0f);
Q0(v, v, 2.0f); Q0(v, v, 2.0f);
Q1(v, x, (float)x1); Q1(v, x, x1);
Q1(v, y, (float)y0); Q1(v, y, y0);
Q1(v, color, color); Q1(v, color, color);
Q1(v, u, 2.0f); Q1(v, u, 2.0f);
Q1(v, v, 2.0f); Q1(v, v, 2.0f);
Q2(v, x, (float)x1); Q2(v, x, x1);
Q2(v, y, (float)y1); Q2(v, y, y1);
Q2(v, color, color); Q2(v, color, color);
Q2(v, u, 2.0f); Q2(v, u, 2.0f);
Q2(v, v, 2.0f); Q2(v, v, 2.0f);
Q3(v, x, (float)x0); Q3(v, x, x0);
Q3(v, y, (float)y1); Q3(v, y, y1);
Q3(v, color, color); Q3(v, color, color);
Q3(v, u, 2.0f); Q3(v, u, 2.0f);
Q3(v, v, 2.0f); Q3(v, v, 2.0f);
@ -477,23 +478,23 @@ void GLProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
uint32_t b1 = 0xff & ((b + nMin) / 2); uint32_t b1 = 0xff & ((b + nMin) / 2);
uint32_t color0 = (r0 << 0) | (g0 << 8) | (b0 << 16) | (0xff000000 & color); uint32_t color0 = (r0 << 0) | (g0 << 8) | (b0 << 16) | (0xff000000 & color);
uint32_t color1 = (r1 << 0) | (g1 << 8) | (b1 << 16) | (0xff000000 & color); uint32_t color1 = (r1 << 0) | (g1 << 8) | (b1 << 16) | (0xff000000 & color);
Q0(v, x, (float)x0); Q0(v, x, x0);
Q0(v, y, (float)y0); Q0(v, y, y0);
Q0(v, color, color0); Q0(v, color, color0);
Q0(v, u, 2.0f); Q0(v, u, 2.0f);
Q0(v, v, 2.0f); Q0(v, v, 2.0f);
Q1(v, x, (float)x1); Q1(v, x, x1);
Q1(v, y, (float)y0); Q1(v, y, y0);
Q1(v, color, color0); Q1(v, color, color0);
Q1(v, u, 3.0f); Q1(v, u, 3.0f);
Q1(v, v, 2.0f); Q1(v, v, 2.0f);
Q2(v, x, (float)x1); Q2(v, x, x1);
Q2(v, y, (float)y1); Q2(v, y, y1);
Q2(v, color, color1); Q2(v, color, color1);
Q2(v, u, 3.0f); Q2(v, u, 3.0f);
Q2(v, v, 3.0f); Q2(v, v, 3.0f);
Q3(v, x, (float)x0); Q3(v, x, x0);
Q3(v, y, (float)y1); Q3(v, y, y1);
Q3(v, color, color1); Q3(v, color, color1);
Q3(v, u, 2.0f); Q3(v, u, 2.0f);
Q3(v, v, 3.0f); Q3(v, v, 3.0f);
@ -532,8 +533,8 @@ void GLProfilerDisplay::DrawText(int x, int y, uint32_t color, const char* text,
} }
const float fOffsetU = 5.0f / 1024.0f; const float fOffsetU = 5.0f / 1024.0f;
float fX = (float)x; float fX = static_cast<float>(x);
float fY = (float)y; float fY = static_cast<float>(y);
float fY2 = fY + (MICROPROFILE_TEXT_HEIGHT + 1); float fY2 = fY + (MICROPROFILE_TEXT_HEIGHT + 1);
auto v = BeginVertices(6 * text_length); auto v = BeginVertices(6 * text_length);
@ -542,7 +543,7 @@ void GLProfilerDisplay::DrawText(int x, int y, uint32_t color, const char* text,
((color >> 16) & 0xff); ((color >> 16) & 0xff);
for (size_t j = 0; j < text_length; ++j) { for (size_t j = 0; j < text_length; ++j) {
int16_t char_offset = font_description_.char_offsets[(int)*pStr++]; int16_t char_offset = font_description_.char_offsets[*pStr++];
float fOffset = char_offset / 1024.0f; float fOffset = char_offset / 1024.0f;
Q0(v, x, fX); Q0(v, x, fX);
Q0(v, y, fY); Q0(v, y, fY);

View File

@ -20,7 +20,7 @@ namespace gl {
class GLProfilerDisplay : public ProfilerDisplay { class GLProfilerDisplay : public ProfilerDisplay {
public: public:
GLProfilerDisplay(xe::ui::Window* window); explicit GLProfilerDisplay(xe::ui::Window* window);
virtual ~GLProfilerDisplay(); virtual ~GLProfilerDisplay();
uint32_t width() const override; uint32_t width() const override;

View File

@ -43,7 +43,7 @@ class GraphicsContext {
}; };
struct GraphicsContextLock { struct GraphicsContextLock {
GraphicsContextLock(GraphicsContext* context) : context_(context) { explicit GraphicsContextLock(GraphicsContext* context) : context_(context) {
context_->MakeCurrent(); context_->MakeCurrent();
} }
~GraphicsContextLock() { context_->ClearCurrent(); } ~GraphicsContextLock() { context_->ClearCurrent(); }

View File

@ -17,7 +17,7 @@ class Window;
class UIEvent { class UIEvent {
public: public:
UIEvent(Window* target = nullptr) : target_(target) {} explicit UIEvent(Window* target = nullptr) : target_(target) {}
virtual ~UIEvent() = default; virtual ~UIEvent() = default;
Window* target() const { return target_; } Window* target() const { return target_; }

View File

@ -40,7 +40,7 @@ constexpr int32_t kMouseWheelDetent = 120;
class RootElement : public el::Element { class RootElement : public el::Element {
public: public:
RootElement(Window* owner) : owner_(owner) {} explicit RootElement(Window* owner) : owner_(owner) {}
void OnInvalid() override { owner_->Invalidate(); } void OnInvalid() override { owner_->Invalidate(); }
private: private:
@ -199,8 +199,9 @@ void Window::OnPaint(UIEvent& e) {
++fps_frame_count_; ++fps_frame_count_;
uint64_t now_ns = xe::Clock::QueryHostSystemTime(); uint64_t now_ns = xe::Clock::QueryHostSystemTime();
if (now_ns > fps_update_time_ + 1000 * 10000) { if (now_ns > fps_update_time_ + 1000 * 10000) {
fps_ = uint32_t(fps_frame_count_ / fps_ = static_cast<uint32_t>(
(double(now_ns - fps_update_time_) / 10000000.0)); fps_frame_count_ /
(static_cast<double>(now_ns - fps_update_time_) / 10000000.0));
fps_update_time_ = now_ns; fps_update_time_ = now_ns;
fps_frame_count_ = 0; fps_frame_count_ = 0;
} }

View File

@ -409,7 +409,7 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
TABLET_ENABLE_MULTITOUCHDATA; TABLET_ENABLE_MULTITOUCHDATA;
case WM_MENUCOMMAND: { case WM_MENUCOMMAND: {
// TODO: Redirect this to MenuItem's on_selected delegate. // TODO(benvanik): Redirect this to MenuItem's on_selected delegate.
MENUINFO menu_info = {0}; MENUINFO menu_info = {0};
menu_info.cbSize = sizeof(menu_info); menu_info.cbSize = sizeof(menu_info);
menu_info.fMask = MIM_MENUDATA; menu_info.fMask = MIM_MENUDATA;
@ -503,7 +503,7 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) {
} }
bool Win32Window::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam) { bool Win32Window::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam) {
auto e = KeyEvent(this, (int)wParam); auto e = KeyEvent(this, static_cast<int>(wParam));
switch (message) { switch (message) {
case WM_KEYDOWN: case WM_KEYDOWN:
OnKeyDown(e); OnKeyDown(e);

View File

@ -22,7 +22,7 @@ namespace vfs {
class Device { class Device {
public: public:
Device(const std::string& path); explicit Device(const std::string& path);
virtual ~Device(); virtual ~Device();
virtual bool Initialize() = 0; virtual bool Initialize() = 0;

View File

@ -34,13 +34,13 @@ bool DiscImageDevice::Initialize() {
ParseState state = {0}; ParseState state = {0};
state.ptr = mmap_->data(); state.ptr = mmap_->data();
state.size = mmap_->size(); state.size = mmap_->size();
auto result = Verify(state); auto result = Verify(&state);
if (result != Error::kSuccess) { if (result != Error::kSuccess) {
XELOGE("Failed to verify disc image header: %d", result); XELOGE("Failed to verify disc image header: %d", result);
return false; return false;
} }
result = ReadAllEntries(state, state.ptr + state.root_offset); result = ReadAllEntries(&state, state.ptr + state.root_offset);
if (result != Error::kSuccess) { if (result != Error::kSuccess) {
XELOGE("Failed to read all GDFX entries: %d", result); XELOGE("Failed to read all GDFX entries: %d", result);
return false; return false;
@ -49,15 +49,15 @@ bool DiscImageDevice::Initialize() {
return true; return true;
} }
DiscImageDevice::Error DiscImageDevice::Verify(ParseState& state) { DiscImageDevice::Error DiscImageDevice::Verify(ParseState* state) {
// Find sector 32 of the game partition - try at a few points. // Find sector 32 of the game partition - try at a few points.
static const size_t likely_offsets[] = { static const size_t likely_offsets[] = {
0x00000000, 0x0000FB20, 0x00020600, 0x0FD90000, 0x00000000, 0x0000FB20, 0x00020600, 0x0FD90000,
}; };
bool magic_found = false; bool magic_found = false;
for (size_t n = 0; n < xe::countof(likely_offsets); n++) { for (size_t n = 0; n < xe::countof(likely_offsets); n++) {
state.game_offset = likely_offsets[n]; state->game_offset = likely_offsets[n];
if (VerifyMagic(state, state.game_offset + (32 * kXESectorSize))) { if (VerifyMagic(state, state->game_offset + (32 * kXESectorSize))) {
magic_found = true; magic_found = true;
break; break;
} }
@ -68,27 +68,28 @@ DiscImageDevice::Error DiscImageDevice::Verify(ParseState& state) {
} }
// Read sector 32 to get FS state. // Read sector 32 to get FS state.
if (state.size < state.game_offset + (32 * kXESectorSize)) { if (state->size < state->game_offset + (32 * kXESectorSize)) {
return Error::kErrorReadError; return Error::kErrorReadError;
} }
uint8_t* fs_ptr = state.ptr + state.game_offset + (32 * kXESectorSize); uint8_t* fs_ptr = state->ptr + state->game_offset + (32 * kXESectorSize);
state.root_sector = xe::load<uint32_t>(fs_ptr + 20); state->root_sector = xe::load<uint32_t>(fs_ptr + 20);
state.root_size = xe::load<uint32_t>(fs_ptr + 24); state->root_size = xe::load<uint32_t>(fs_ptr + 24);
state.root_offset = state.game_offset + (state.root_sector * kXESectorSize); state->root_offset =
if (state.root_size < 13 || state.root_size > 32 * 1024 * 1024) { state->game_offset + (state->root_sector * kXESectorSize);
if (state->root_size < 13 || state->root_size > 32 * 1024 * 1024) {
return Error::kErrorDamagedFile; return Error::kErrorDamagedFile;
} }
return Error::kSuccess; return Error::kSuccess;
} }
bool DiscImageDevice::VerifyMagic(ParseState& state, size_t offset) { bool DiscImageDevice::VerifyMagic(ParseState* state, size_t offset) {
// Simple check to see if the given offset contains the magic value. // Simple check to see if the given offset contains the magic value.
return std::memcmp(state.ptr + offset, "MICROSOFT*XBOX*MEDIA", 20) == 0; return std::memcmp(state->ptr + offset, "MICROSOFT*XBOX*MEDIA", 20) == 0;
} }
DiscImageDevice::Error DiscImageDevice::ReadAllEntries( DiscImageDevice::Error DiscImageDevice::ReadAllEntries(
ParseState& state, const uint8_t* root_buffer) { ParseState* state, const uint8_t* root_buffer) {
auto root_entry = new DiscImageEntry(this, nullptr, "", mmap_.get()); auto root_entry = new DiscImageEntry(this, nullptr, "", mmap_.get());
root_entry->attributes_ = kFileAttributeDirectory; root_entry->attributes_ = kFileAttributeDirectory;
root_entry_ = std::unique_ptr<Entry>(root_entry); root_entry_ = std::unique_ptr<Entry>(root_entry);
@ -100,7 +101,7 @@ DiscImageDevice::Error DiscImageDevice::ReadAllEntries(
return Error::kSuccess; return Error::kSuccess;
} }
bool DiscImageDevice::ReadEntry(ParseState& state, const uint8_t* buffer, bool DiscImageDevice::ReadEntry(ParseState* state, const uint8_t* buffer,
uint16_t entry_ordinal, uint16_t entry_ordinal,
DiscImageEntry* parent) { DiscImageEntry* parent) {
const uint8_t* p = buffer + (entry_ordinal * 4); const uint8_t* p = buffer + (entry_ordinal * 4);
@ -111,7 +112,7 @@ bool DiscImageDevice::ReadEntry(ParseState& state, const uint8_t* buffer,
size_t length = xe::load<uint32_t>(p + 8); size_t length = xe::load<uint32_t>(p + 8);
uint8_t attributes = xe::load<uint8_t>(p + 12); uint8_t attributes = xe::load<uint8_t>(p + 12);
uint8_t name_length = xe::load<uint8_t>(p + 13); uint8_t name_length = xe::load<uint8_t>(p + 13);
char* name = (char*)(p + 14); auto name = reinterpret_cast<const char*>(p + 14);
if (node_l && !ReadEntry(state, buffer, node_l, parent)) { if (node_l && !ReadEntry(state, buffer, node_l, parent)) {
return false; return false;
@ -135,20 +136,20 @@ bool DiscImageDevice::ReadEntry(ParseState& state, const uint8_t* buffer,
entry->data_size_ = 0; entry->data_size_ = 0;
if (length) { if (length) {
// Not a leaf - read in children. // Not a leaf - read in children.
if (state.size < state.game_offset + (sector * kXESectorSize)) { if (state->size < state->game_offset + (sector * kXESectorSize)) {
// Out of bounds read. // Out of bounds read.
return false; return false;
} }
// Read child list. // Read child list.
uint8_t* folder_ptr = uint8_t* folder_ptr =
state.ptr + state.game_offset + (sector * kXESectorSize); state->ptr + state->game_offset + (sector * kXESectorSize);
if (!ReadEntry(state, folder_ptr, 0, entry)) { if (!ReadEntry(state, folder_ptr, 0, entry)) {
return false; return false;
} }
} }
} else { } else {
// File. // File.
entry->data_offset_ = state.game_offset + (sector * kXESectorSize); entry->data_offset_ = state->game_offset + (sector * kXESectorSize);
entry->data_size_ = length; entry->data_size_ = length;
} }

View File

@ -58,10 +58,10 @@ class DiscImageDevice : public Device {
size_t root_size; // Size (bytes) of root. size_t root_size; // Size (bytes) of root.
} ParseState; } ParseState;
Error Verify(ParseState& state); Error Verify(ParseState* state);
bool VerifyMagic(ParseState& state, size_t offset); bool VerifyMagic(ParseState* state, size_t offset);
Error ReadAllEntries(ParseState& state, const uint8_t* root_buffer); Error ReadAllEntries(ParseState* state, const uint8_t* root_buffer);
bool ReadEntry(ParseState& state, const uint8_t* buffer, bool ReadEntry(ParseState* state, const uint8_t* buffer,
uint16_t entry_ordinal, DiscImageEntry* parent); uint16_t entry_ordinal, DiscImageEntry* parent);
}; };

View File

@ -26,11 +26,11 @@ DiscImageEntry::DiscImageEntry(Device* device, Entry* parent, std::string path,
DiscImageEntry::~DiscImageEntry() = default; DiscImageEntry::~DiscImageEntry() = default;
X_STATUS DiscImageEntry::Open(KernelState* kernel_state, X_STATUS DiscImageEntry::Open(kernel::KernelState* kernel_state,
uint32_t desired_access, uint32_t desired_access,
object_ref<XFile>* out_file) { kernel::object_ref<kernel::XFile>* out_file) {
*out_file = *out_file = kernel::object_ref<kernel::XFile>(
object_ref<XFile>(new DiscImageFile(kernel_state, desired_access, this)); new DiscImageFile(kernel_state, desired_access, this));
return X_STATUS_SUCCESS; return X_STATUS_SUCCESS;
} }

View File

@ -10,6 +10,7 @@
#ifndef XENIA_VFS_DEVICES_DISC_IMAGE_ENTRY_H_ #ifndef XENIA_VFS_DEVICES_DISC_IMAGE_ENTRY_H_
#define XENIA_VFS_DEVICES_DISC_IMAGE_ENTRY_H_ #define XENIA_VFS_DEVICES_DISC_IMAGE_ENTRY_H_
#include <string>
#include <vector> #include <vector>
#include "xenia/base/filesystem.h" #include "xenia/base/filesystem.h"
@ -31,8 +32,8 @@ class DiscImageEntry : public Entry {
size_t data_offset() const { return data_offset_; } size_t data_offset() const { return data_offset_; }
size_t data_size() const { return data_size_; } size_t data_size() const { return data_size_; }
X_STATUS Open(KernelState* kernel_state, uint32_t desired_access, X_STATUS Open(kernel::KernelState* kernel_state, uint32_t desired_access,
object_ref<XFile>* out_file) override; kernel::object_ref<kernel::XFile>* out_file) override;
bool can_map() const override { return true; } bool can_map() const override { return true; }
std::unique_ptr<MappedMemory> OpenMapped(MappedMemory::Mode mode, std::unique_ptr<MappedMemory> OpenMapped(MappedMemory::Mode mode,

View File

@ -16,8 +16,8 @@
namespace xe { namespace xe {
namespace vfs { namespace vfs {
DiscImageFile::DiscImageFile(KernelState* kernel_state, uint32_t file_access, DiscImageFile::DiscImageFile(kernel::KernelState* kernel_state,
DiscImageEntry* entry) uint32_t file_access, DiscImageEntry* entry)
: XFile(kernel_state, file_access, entry), entry_(entry) {} : XFile(kernel_state, file_access, entry), entry_(entry) {}
DiscImageFile::~DiscImageFile() = default; DiscImageFile::~DiscImageFile() = default;

View File

@ -17,9 +17,9 @@ namespace vfs {
class DiscImageEntry; class DiscImageEntry;
class DiscImageFile : public XFile { class DiscImageFile : public kernel::XFile {
public: public:
DiscImageFile(KernelState* kernel_state, uint32_t file_access, DiscImageFile(kernel::KernelState* kernel_state, uint32_t file_access,
DiscImageEntry* entry); DiscImageEntry* entry);
~DiscImageFile() override; ~DiscImageFile() override;

View File

@ -47,8 +47,9 @@ HostPathEntry* HostPathEntry::Create(Device* device, Entry* parent,
return entry; return entry;
} }
X_STATUS HostPathEntry::Open(KernelState* kernel_state, uint32_t desired_access, X_STATUS HostPathEntry::Open(kernel::KernelState* kernel_state,
object_ref<XFile>* out_file) { uint32_t desired_access,
kernel::object_ref<kernel::XFile>* out_file) {
if (is_read_only() && (desired_access & (FileAccess::kFileWriteData | if (is_read_only() && (desired_access & (FileAccess::kFileWriteData |
FileAccess::kFileAppendData))) { FileAccess::kFileAppendData))) {
XELOGE("Attempting to open file for write access on read-only device"); XELOGE("Attempting to open file for write access on read-only device");
@ -60,8 +61,8 @@ X_STATUS HostPathEntry::Open(KernelState* kernel_state, uint32_t desired_access,
// TODO(benvanik): pick correct response. // TODO(benvanik): pick correct response.
return X_STATUS_NO_SUCH_FILE; return X_STATUS_NO_SUCH_FILE;
} }
*out_file = object_ref<XFile>(new HostPathFile(kernel_state, desired_access, *out_file = kernel::object_ref<kernel::XFile>(new HostPathFile(
this, std::move(file_handle))); kernel_state, desired_access, this, std::move(file_handle)));
return X_STATUS_SUCCESS; return X_STATUS_SUCCESS;
} }

View File

@ -32,8 +32,8 @@ class HostPathEntry : public Entry {
const std::wstring& local_path() { return local_path_; } const std::wstring& local_path() { return local_path_; }
X_STATUS Open(KernelState* kernel_state, uint32_t desired_access, X_STATUS Open(kernel::KernelState* kernel_state, uint32_t desired_access,
object_ref<XFile>* out_file) override; kernel::object_ref<kernel::XFile>* out_file) override;
bool can_map() const override { return true; } bool can_map() const override { return true; }
std::unique_ptr<MappedMemory> OpenMapped(MappedMemory::Mode mode, std::unique_ptr<MappedMemory> OpenMapped(MappedMemory::Mode mode,

View File

@ -15,7 +15,8 @@ namespace xe {
namespace vfs { namespace vfs {
HostPathFile::HostPathFile( HostPathFile::HostPathFile(
KernelState* kernel_state, uint32_t file_access, HostPathEntry* entry, kernel::KernelState* kernel_state, uint32_t file_access,
HostPathEntry* entry,
std::unique_ptr<xe::filesystem::FileHandle> file_handle) std::unique_ptr<xe::filesystem::FileHandle> file_handle)
: XFile(kernel_state, file_access, entry), : XFile(kernel_state, file_access, entry),
file_handle_(std::move(file_handle)) {} file_handle_(std::move(file_handle)) {}

View File

@ -20,9 +20,9 @@ namespace vfs {
class HostPathEntry; class HostPathEntry;
class HostPathFile : public XFile { class HostPathFile : public kernel::XFile {
public: public:
HostPathFile(KernelState* kernel_state, uint32_t file_access, HostPathFile(kernel::KernelState* kernel_state, uint32_t file_access,
HostPathEntry* entry, HostPathEntry* entry,
std::unique_ptr<xe::filesystem::FileHandle> file_handle); std::unique_ptr<xe::filesystem::FileHandle> file_handle);
~HostPathFile() override; ~HostPathFile() override;

View File

@ -9,6 +9,9 @@
#include "xenia/vfs/devices/stfs_container_device.h" #include "xenia/vfs/devices/stfs_container_device.h"
#include <algorithm>
#include <vector>
#include "xenia/base/logging.h" #include "xenia/base/logging.h"
#include "xenia/base/math.h" #include "xenia/base/math.h"
#include "xenia/vfs/devices/stfs_container_entry.h" #include "xenia/vfs/devices/stfs_container_entry.h"
@ -16,14 +19,14 @@
namespace xe { namespace xe {
namespace vfs { namespace vfs {
#define XEGETUINT24BE(p) \ uint32_t load_uint24_be(const uint8_t* p) {
(((uint32_t)xe::load_and_swap<uint8_t>((p) + 0) << 16) | \ return (static_cast<uint32_t>(p[0]) << 16) |
((uint32_t)xe::load_and_swap<uint8_t>((p) + 1) << 8) | \ (static_cast<uint32_t>(p[1]) << 8) | static_cast<uint32_t>(p[2]);
(uint32_t)xe::load_and_swap<uint8_t>((p) + 2)) }
#define XEGETUINT24LE(p) \ uint32_t load_uint24_le(const uint8_t* p) {
(((uint32_t)xe::load<uint8_t>((p) + 2) << 16) | \ return (static_cast<uint32_t>(p[2]) << 16) |
((uint32_t)xe::load<uint8_t>((p) + 1) << 8) | \ (static_cast<uint32_t>(p[1]) << 8) | static_cast<uint32_t>(p[0]);
(uint32_t)xe::load<uint8_t>((p) + 0)) }
StfsContainerDevice::StfsContainerDevice(const std::string& mount_path, StfsContainerDevice::StfsContainerDevice(const std::string& mount_path,
const std::wstring& local_path) const std::wstring& local_path)
@ -150,8 +153,8 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries(
} }
uint8_t filename_length_flags = xe::load_and_swap<uint8_t>(p + 0x28); uint8_t filename_length_flags = xe::load_and_swap<uint8_t>(p + 0x28);
// TODO(benvanik): use for allocation_size_? // TODO(benvanik): use for allocation_size_?
// uint32_t allocated_block_count = XEGETUINT24LE(p + 0x29); // uint32_t allocated_block_count = load_uint24_le(p + 0x29);
uint32_t start_block_index = XEGETUINT24LE(p + 0x2F); uint32_t start_block_index = load_uint24_le(p + 0x2F);
uint16_t path_indicator = xe::load_and_swap<uint16_t>(p + 0x32); uint16_t path_indicator = xe::load_and_swap<uint16_t>(p + 0x32);
uint32_t file_size = xe::load_and_swap<uint32_t>(p + 0x34); uint32_t file_size = xe::load_and_swap<uint32_t>(p + 0x34);
uint32_t update_timestamp = xe::load_and_swap<uint32_t>(p + 0x38); uint32_t update_timestamp = xe::load_and_swap<uint32_t>(p + 0x38);
@ -167,7 +170,8 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries(
auto entry = new StfsContainerEntry( auto entry = new StfsContainerEntry(
this, parent_entry, this, parent_entry,
std::string((char*)filename, filename_length_flags & 0x3F), std::string(reinterpret_cast<const char*>(filename),
filename_length_flags & 0x3F),
mmap_.get()); mmap_.get());
// bit 0x40 = consecutive blocks (not fragmented?) // bit 0x40 = consecutive blocks (not fragmented?)
if (filename_length_flags & 0x80) { if (filename_length_flags & 0x80) {
@ -286,7 +290,7 @@ StfsContainerDevice::BlockHash StfsContainerDevice::GetBlockHash(
const uint8_t* hash_data = map_ptr + BlockToOffset(table_index); const uint8_t* hash_data = map_ptr + BlockToOffset(table_index);
const uint8_t* record_data = hash_data + record * 0x18; const uint8_t* record_data = hash_data + record * 0x18;
uint32_t info = xe::load_and_swap<uint8_t>(record_data + 0x14); uint32_t info = xe::load_and_swap<uint8_t>(record_data + 0x14);
uint32_t next_block_index = XEGETUINT24BE(record_data + 0x15); uint32_t next_block_index = load_uint24_be(record_data + 0x15);
return {next_block_index, info}; return {next_block_index, info};
} }
@ -300,12 +304,12 @@ bool StfsVolumeDescriptor::Read(const uint8_t* p) {
reserved = xe::load_and_swap<uint8_t>(p + 0x01); reserved = xe::load_and_swap<uint8_t>(p + 0x01);
block_separation = xe::load_and_swap<uint8_t>(p + 0x02); block_separation = xe::load_and_swap<uint8_t>(p + 0x02);
file_table_block_count = xe::load_and_swap<uint16_t>(p + 0x03); file_table_block_count = xe::load_and_swap<uint16_t>(p + 0x03);
file_table_block_number = XEGETUINT24BE(p + 0x05); file_table_block_number = load_uint24_be(p + 0x05);
std::memcpy(top_hash_table_hash, p + 0x08, 0x14); std::memcpy(top_hash_table_hash, p + 0x08, 0x14);
total_allocated_block_count = xe::load_and_swap<uint32_t>(p + 0x1C); total_allocated_block_count = xe::load_and_swap<uint32_t>(p + 0x1C);
total_unallocated_block_count = xe::load_and_swap<uint32_t>(p + 0x20); total_unallocated_block_count = xe::load_and_swap<uint32_t>(p + 0x20);
return true; return true;
}; }
bool StfsHeader::Read(const uint8_t* p) { bool StfsHeader::Read(const uint8_t* p) {
std::memcpy(license_entries, p + 0x22C, 0x100); std::memcpy(license_entries, p + 0x22C, 0x100);

View File

@ -24,10 +24,10 @@ StfsContainerEntry::StfsContainerEntry(Device* device, Entry* parent,
StfsContainerEntry::~StfsContainerEntry() = default; StfsContainerEntry::~StfsContainerEntry() = default;
X_STATUS StfsContainerEntry::Open(KernelState* kernel_state, X_STATUS StfsContainerEntry::Open(kernel::KernelState* kernel_state,
uint32_t desired_access, uint32_t desired_access,
object_ref<XFile>* out_file) { kernel::object_ref<kernel::XFile>* out_file) {
*out_file = object_ref<XFile>( *out_file = kernel::object_ref<kernel::XFile>(
new StfsContainerFile(kernel_state, desired_access, this)); new StfsContainerFile(kernel_state, desired_access, this));
return X_STATUS_SUCCESS; return X_STATUS_SUCCESS;
} }

View File

@ -10,6 +10,7 @@
#ifndef XENIA_VFS_DEVICES_STFS_CONTAINER_ENTRY_H_ #ifndef XENIA_VFS_DEVICES_STFS_CONTAINER_ENTRY_H_
#define XENIA_VFS_DEVICES_STFS_CONTAINER_ENTRY_H_ #define XENIA_VFS_DEVICES_STFS_CONTAINER_ENTRY_H_
#include <string>
#include <vector> #include <vector>
#include "xenia/base/filesystem.h" #include "xenia/base/filesystem.h"
@ -31,8 +32,8 @@ class StfsContainerEntry : public Entry {
size_t data_offset() const { return data_offset_; } size_t data_offset() const { return data_offset_; }
size_t data_size() const { return data_size_; } size_t data_size() const { return data_size_; }
X_STATUS Open(KernelState* kernel_state, uint32_t desired_access, X_STATUS Open(kernel::KernelState* kernel_state, uint32_t desired_access,
object_ref<XFile>* out_file) override; kernel::object_ref<kernel::XFile>* out_file) override;
struct BlockRecord { struct BlockRecord {
size_t offset; size_t offset;

View File

@ -16,7 +16,7 @@
namespace xe { namespace xe {
namespace vfs { namespace vfs {
StfsContainerFile::StfsContainerFile(KernelState* kernel_state, StfsContainerFile::StfsContainerFile(kernel::KernelState* kernel_state,
uint32_t file_access, uint32_t file_access,
StfsContainerEntry* entry) StfsContainerEntry* entry)
: XFile(kernel_state, file_access, entry), entry_(entry) {} : XFile(kernel_state, file_access, entry), entry_(entry) {}
@ -38,7 +38,7 @@ X_STATUS StfsContainerFile::ReadSync(void* buffer, size_t buffer_length,
size_t end_block = size_t end_block =
std::min(entry_->block_list().size(), std::min(entry_->block_list().size(),
(size_t)ceil((byte_offset + real_length) / 4096.0)); (size_t)ceil((byte_offset + real_length) / 4096.0));
uint8_t* dest_ptr = (uint8_t*)buffer; uint8_t* dest_ptr = reinterpret_cast<uint8_t*>(buffer);
size_t remaining_length = real_length; size_t remaining_length = real_length;
for (size_t n = start_block; n < end_block; n++) { for (size_t n = start_block; n < end_block; n++) {
auto& record = entry_->block_list()[n]; auto& record = entry_->block_list()[n];

View File

@ -17,9 +17,9 @@ namespace vfs {
class StfsContainerEntry; class StfsContainerEntry;
class StfsContainerFile : public XFile { class StfsContainerFile : public kernel::XFile {
public: public:
StfsContainerFile(KernelState* kernel_state, uint32_t file_access, StfsContainerFile(kernel::KernelState* kernel_state, uint32_t file_access,
StfsContainerEntry* entry); StfsContainerEntry* entry);
~StfsContainerFile() override; ~StfsContainerFile() override;

View File

@ -21,9 +21,6 @@
#include "xenia/xbox.h" #include "xenia/xbox.h"
namespace xe { namespace xe {
namespace filesystem {
class WildcardEngine;
} // namespace filesystem
namespace kernel { namespace kernel {
class KernelState; class KernelState;
class XFile; class XFile;
@ -33,8 +30,6 @@ class XFile;
namespace xe { namespace xe {
namespace vfs { namespace vfs {
using namespace xe::kernel;
class Device; class Device;
// Matches http://source.winehq.org/source/include/winternl.h#1591. // Matches http://source.winehq.org/source/include/winternl.h#1591.
@ -110,8 +105,9 @@ class Entry {
bool Delete(); bool Delete();
void Touch(); void Touch();
virtual X_STATUS Open(KernelState* kernel_state, uint32_t desired_access, virtual X_STATUS Open(kernel::KernelState* kernel_state,
object_ref<XFile>* out_file) = 0; uint32_t desired_access,
kernel::object_ref<kernel::XFile>* out_file) = 0;
virtual bool can_map() const { return false; } virtual bool can_map() const { return false; }
virtual std::unique_ptr<MappedMemory> OpenMapped(MappedMemory::Mode mode, virtual std::unique_ptr<MappedMemory> OpenMapped(MappedMemory::Mode mode,

View File

@ -140,12 +140,10 @@ bool VirtualFileSystem::DeletePath(std::string path) {
return parent->Delete(entry); return parent->Delete(entry);
} }
X_STATUS VirtualFileSystem::OpenFile(KernelState* kernel_state, X_STATUS VirtualFileSystem::OpenFile(
std::string path, kernel::KernelState* kernel_state, std::string path,
FileDisposition creation_disposition, FileDisposition creation_disposition, uint32_t desired_access,
uint32_t desired_access, kernel::object_ref<kernel::XFile>* out_file, FileAction* out_action) {
object_ref<XFile>* out_file,
FileAction* out_action) {
// Cleanup access. // Cleanup access.
if (desired_access & FileAccess::kGenericRead) { if (desired_access & FileAccess::kGenericRead) {
desired_access |= FileAccess::kFileReadData; desired_access |= FileAccess::kFileReadData;

View File

@ -39,9 +39,10 @@ class VirtualFileSystem {
Entry* CreatePath(std::string path, uint32_t attributes); Entry* CreatePath(std::string path, uint32_t attributes);
bool DeletePath(std::string path); bool DeletePath(std::string path);
X_STATUS OpenFile(KernelState* kernel_state, std::string path, X_STATUS OpenFile(kernel::KernelState* kernel_state, std::string path,
FileDisposition creation_disposition, FileDisposition creation_disposition,
uint32_t desired_access, object_ref<XFile>* out_file, uint32_t desired_access,
kernel::object_ref<kernel::XFile>* out_file,
FileAction* out_action); FileAction* out_action);
private: private: