Compare commits

..

3 Commits

Author SHA1 Message Date
Gliniak 47fa5f36c5 Initial version of new XMA decoder 2024-02-23 18:46:47 +01:00
Gliniak 64f5cc69e5 Added ReadOnly BitStream 2024-02-23 18:46:47 +01:00
Gliniak 0cc7a6b23b Disable decoding on dedicated thread 2024-02-23 18:46:47 +01:00
20 changed files with 55 additions and 68 deletions

4
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "third_party/xbyak"]
path = third_party/xbyak
url = https://github.com/herumi/xbyak.git
url = https://github.com/xenia-project/xbyak.git
[submodule "third_party/imgui"]
path = third_party/imgui
url = https://github.com/ocornut/imgui.git
@ -30,7 +30,7 @@
url = https://github.com/openluopworld/aes_128.git
[submodule "third_party/capstone"]
path = third_party/capstone
url = https://github.com/capstone-engine/capstone.git
url = https://github.com/xenia-project/capstone.git
[submodule "third_party/cpptoml"]
path = third_party/cpptoml
url = https://github.com/skystrife/cpptoml.git

View File

@ -35,20 +35,6 @@ extern "C" {
namespace xe {
namespace apu {
static void dump_raw(AVFrame* frame, int id) {
FILE* outfile = fopen(fmt::format("out{}.raw", id).c_str(), "ab");
if (!outfile) {
return;
}
size_t data_size = sizeof(float);
for (int i = 0; i < frame->nb_samples; i++) {
for (int ch = 0; ch < frame->channels; ch++) {
fwrite(frame->data[ch] + data_size * i, 1, data_size, outfile);
}
}
fclose(outfile);
}
XmaContext::XmaContext() = default;
XmaContext::~XmaContext() {
@ -61,6 +47,9 @@ XmaContext::~XmaContext() {
if (av_frame_) {
av_frame_free(&av_frame_);
}
// if (current_frame_) {
// delete[] current_frame_;
// }
}
int XmaContext::Setup(uint32_t id, Memory* memory, uint32_t guest_ptr) {
@ -261,7 +250,7 @@ void XmaContext::Release() {
}
int XmaContext::GetSampleRate(int id) {
return kIdToSampleRate[std::min(id, 3)];
return kIdToSampleRate[id > 3 ? 3 : id];
}
void XmaContext::SwapInputBuffer(XMA_CONTEXT_DATA* data) {
@ -275,6 +264,20 @@ void XmaContext::SwapInputBuffer(XMA_CONTEXT_DATA* data) {
data->input_buffer_read_offset = kBitsPerPacketHeader;
}
static void dump_raw(AVFrame* frame, int id) {
FILE* outfile = fopen(fmt::format("out{}.raw", id).c_str(), "ab");
if (!outfile) {
return;
}
size_t data_size = sizeof(float);
for (int i = 0; i < frame->nb_samples; i++) {
for (int ch = 0; ch < frame->channels; ch++) {
fwrite(frame->data[ch] + data_size * i, 1, data_size, outfile);
}
}
fclose(outfile);
}
void XmaContext::Consume(RingBuffer* output_rb, XMA_CONTEXT_DATA* data) {
if (!current_frame_remaining_subframes_) {
return;

View File

@ -56,7 +56,7 @@
} \
template <typename TRet = void, typename... TArgs> \
inline TRet invoke(TArgs... args) { \
return reinterpret_cast<TRet(NTAPI*)(TArgs...)>(fn)(args...); \
return reinterpret_cast<NTSYSAPI TRet(NTAPI*)(TArgs...)>(fn)(args...); \
} \
inline operator bool() const { return fn != nullptr; } \
} clsvar

View File

@ -2940,7 +2940,7 @@ void DxbcShaderTranslator::CompletePixelShader() {
SystemConstants::Index::kAlphaTestReference,
offsetof(SystemConstants, alpha_test_reference), dxbc::Src::kXXXX));
// Epsilon for alpha checks
dxbc::Src fuzzy_epsilon = dxbc::Src::LF(1e-3f);
dxbc::Src fuzzy_epsilon = dxbc::Src::LF(0.01f);
// Handle "not equal" specially (specifically as "not equal" so it's true
// for NaN, not "less or greater" which is false for NaN).
a_.OpIEq(alpha_test_op_dest, alpha_test_mask_src,

View File

@ -40,6 +40,7 @@ SDLInputDriver::SDLInputDriver(xe::ui::Window* window, size_t window_z_order)
sdl_events_unflushed_(0),
sdl_pumpevents_queued_(false),
controllers_(),
controllers_mutex_(),
keystroke_states_() {}
SDLInputDriver::~SDLInputDriver() {
@ -150,6 +151,8 @@ X_RESULT SDLInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags,
QueueControllerUpdate();
std::unique_lock<std::mutex> guard(controllers_mutex_);
auto controller = GetControllerState(user_index);
if (!controller) {
return X_ERROR_DEVICE_NOT_CONNECTED;
@ -177,6 +180,8 @@ X_RESULT SDLInputDriver::GetState(uint32_t user_index,
QueueControllerUpdate();
}
std::unique_lock<std::mutex> guard(controllers_mutex_);
auto controller = GetControllerState(user_index);
if (!controller) {
return X_ERROR_DEVICE_NOT_CONNECTED;
@ -290,6 +295,8 @@ X_RESULT SDLInputDriver::GetKeystroke(uint32_t users, uint32_t flags,
QueueControllerUpdate();
}
std::unique_lock<std::mutex> guard(controllers_mutex_);
for (uint32_t user_index = (user_any ? 0 : users);
user_index < (user_any ? HID_SDL_USER_COUNT : users + 1); user_index++) {
auto controller = GetControllerState(user_index);
@ -413,6 +420,8 @@ void SDLInputDriver::HandleEvent(const SDL_Event& event) {
}
void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
std::unique_lock<std::mutex> guard(controllers_mutex_);
// Open the controller.
const auto controller = SDL_GameControllerOpen(event.cdevice.which);
if (!controller) {
@ -476,6 +485,8 @@ void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
}
void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
std::unique_lock<std::mutex> guard(controllers_mutex_);
// Find the disconnected gamecontroller and close it.
auto idx = GetControllerIndexFromInstanceID(event.cdevice.which);
if (idx) {
@ -490,6 +501,8 @@ void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
}
void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
std::unique_lock<std::mutex> guard(controllers_mutex_);
auto idx = GetControllerIndexFromInstanceID(event.caxis.which);
assert(idx);
auto& pad = controllers_.at(*idx).state.gamepad;
@ -520,6 +533,8 @@ void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
}
void SDLInputDriver::OnControllerDeviceButtonChanged(const SDL_Event& event) {
std::unique_lock<std::mutex> guard(controllers_mutex_);
// Define a lookup table to map between SDL and XInput button codes.
// These need to be in the order of the SDL_GameControllerButton enum.
static constexpr std::array<

View File

@ -84,6 +84,7 @@ class SDLInputDriver final : public InputDriver {
int sdl_events_unflushed_;
std::atomic<bool> sdl_pumpevents_queued_;
std::array<ControllerState, HID_SDL_USER_COUNT> controllers_;
std::mutex controllers_mutex_;
std::array<KeystrokeState, HID_SDL_USER_COUNT> keystroke_states_;
};

View File

@ -38,9 +38,6 @@ DEFINE_uint32(max_signed_profiles, 4,
"Limits how many profiles can be assigned. Possible values: 1-4",
"Kernel");
DEFINE_uint32(kernel_build_version, 1888, "Define current kernel version",
"Kernel");
namespace xe {
namespace kernel {
@ -69,7 +66,6 @@ KernelState::KernelState(Emulator* emulator)
user_profiles_.emplace(0, std::make_unique<xam::UserProfile>(0));
InitializeKernelGuestGlobals();
kernel_version_ = KernelVersion(cvars::kernel_build_version);
auto content_root = emulator_->content_root();
if (!content_root.empty()) {

View File

@ -48,8 +48,6 @@ namespace kernel {
constexpr fourcc_t kKernelSaveSignature = make_fourcc("KRNL");
static constexpr const uint16_t kBaseKernelBuildVersion = 1888;
// (?), used by KeGetCurrentProcessType
constexpr uint32_t X_PROCTYPE_IDLE = 0;
constexpr uint32_t X_PROCTYPE_TITLE = 1;
@ -147,27 +145,6 @@ struct KernelGuestGlobals {
struct DPCImpersonationScope {
uint8_t previous_irql_;
};
struct KernelVersion {
union {
xe::be<uint64_t> value;
struct {
xe::be<uint16_t> major;
xe::be<uint16_t> minor;
xe::be<uint16_t> build;
xe::be<uint16_t> qfe;
};
};
KernelVersion(uint16_t build_ver = kBaseKernelBuildVersion) {
major = 2;
minor = 0;
build = std::max(kBaseKernelBuildVersion, build_ver);
qfe = 0;
}
};
class KernelState {
public:
explicit KernelState(Emulator* emulator);
@ -223,8 +200,6 @@ class KernelState {
// Access must be guarded by the global critical region.
util::ObjectTable* object_table() { return &object_table_; }
const KernelVersion* GetKernelVersion() const { return &kernel_version_; }
uint32_t GetSystemProcess() const {
return kernel_guest_globals_ + offsetof(KernelGuestGlobals, system_process);
}
@ -357,8 +332,6 @@ class KernelState {
std::map<uint8_t, std::unique_ptr<xam::UserProfile>> user_profiles_;
std::unique_ptr<AchievementManager> achievement_manager_;
KernelVersion kernel_version_;
xe::global_critical_region global_critical_region_;
// Must be guarded by the global critical region.

View File

@ -13,10 +13,8 @@
#include "xenia/kernel/xbdm/xbdm_private.h"
#include "xenia/kernel/xthread.h"
#include "xenia/xbox.h"
// chrispy: no idea what a real valid value is for this
static constexpr const char DmXboxName[] = "Xbox360Name";
namespace xe {
namespace kernel {
namespace xbdm {
@ -144,8 +142,8 @@ dword_result_t DmGetSystemInfo_entry(pointer_t<XBDM_SYSTEM_INFO> info) {
info->base_kernel_version.minor = info->kernel_version.minor = 0;
info->base_kernel_version.qfe = info->kernel_version.qfe = 0;
info->base_kernel_version.build = kBaseKernelBuildVersion;
info->kernel_version.build = kernel_state()->GetKernelVersion()->build;
info->base_kernel_version.build = 1888;
info->kernel_version.build = 13139;
return XBDM_SUCCESSFUL;
}

View File

@ -205,12 +205,15 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
// XboxKrnlVersion (8b)
// Kernel version, looks like 2b.2b.2b.2b.
// I've only seen games check >=, so we just fake something here.
uint32_t pXboxKrnlVersion = memory_->SystemHeapAlloc(sizeof(KernelVersion));
uint32_t pXboxKrnlVersion = memory_->SystemHeapAlloc(8);
auto lpXboxKrnlVersion = memory_->TranslateVirtual(pXboxKrnlVersion);
export_resolver_->SetVariableMapping(
"xboxkrnl.exe", ordinals::XboxKrnlVersion, pXboxKrnlVersion);
std::memcpy(lpXboxKrnlVersion, kernel_state_->GetKernelVersion(),
sizeof(KernelVersion));
xe::store_and_swap<uint16_t>(lpXboxKrnlVersion + 0, 2);
xe::store_and_swap<uint16_t>(lpXboxKrnlVersion + 2, 0xFFFF);
xe::store_and_swap<uint16_t>(lpXboxKrnlVersion + 4, 0xFFFF);
xe::store_and_swap<uint8_t>(lpXboxKrnlVersion + 6, 0x80);
xe::store_and_swap<uint8_t>(lpXboxKrnlVersion + 7, 0x00);
export_resolver_->SetVariableMapping("xboxkrnl.exe",
ordinals::KeTimeStampBundle,

@ -1 +1 @@
Subproject commit 69e54e29086b7035acffb304cec57a350225f8b0
Subproject commit 6b6f40200bea5ed99367513f53f6a28e52fd3d0e

@ -1 +1 @@
Subproject commit 44d72a9b36702f093dd20815561a56778b2d181e
Subproject commit dd534e877e725c9bb6f751c427442456a05384e4

@ -1 +1 @@
Subproject commit 46dc0f6e514f5730784bb2cac2a7c731636839e8
Subproject commit b32da5329b50e3cb96229aaecba9ded032fe29cc

@ -1 +1 @@
Subproject commit 19b940e864bd3a5afb3c79e3c6788869d01a19eb
Subproject commit 51c8b56011303e94840370089f816b19dbe7edf0

@ -1 +1 @@
Subproject commit 097c04d9413c59a58b00d4d1c8d5dc0ac158ffaa
Subproject commit f9c6a90489be7b3637ff1c7298e45efafe7cf1b9

View File

@ -39,8 +39,6 @@ project("capstone")
"capstone/SStream.h",
"capstone/utils.c",
"capstone/utils.h",
"capstone/Mapping.c",
"capstone/Mapping.h",
"capstone/arch/X86/*.c",
"capstone/arch/X86/*.h",

2
third_party/cxxopts vendored

@ -1 +1 @@
Subproject commit 3bf268481da8208d171d8908e6491459de3651d7
Subproject commit b2b8cf2f50a449720874f43445e23d75b77dcc43

2
third_party/fmt vendored

@ -1 +1 @@
Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b
Subproject commit 27e3c0fe9b5dc99f339637ec2ea7efae5b945ab8

2
third_party/xbyak vendored

@ -1 +1 @@
Subproject commit 63e6ee92cc906a3dbf6b333b2fd51ac1ca95f891
Subproject commit bc70e7e11ad37f207ece73330c5b72a55fef1ceb

2
third_party/xxhash vendored

@ -1 +1 @@
Subproject commit bbb27a5efb85b92a0486cf361a8635715a53f6ba
Subproject commit 4c881f796d6af27ef7d9c48f87817da0d3d75dc1