From 9df39e488383e2a0c701b9a8f6dd77645f4a337a Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 27 Aug 2019 23:50:30 +0300 Subject: [PATCH 1/2] [Kernel] Fix StoreXmaContextIndexedRegister, note about physical addresses in XMAInitializeContext --- src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc index 0fc5be3d5..07694e45b 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc @@ -80,9 +80,13 @@ DECLARE_XBOXKRNL_EXPORT2(XMAReleaseContext, kAudio, kImplemented, void StoreXmaContextIndexedRegister(KernelState* kernel_state, uint32_t base_reg, uint32_t context_ptr) { + uint32_t context_physical_address = + kernel_memory()->GetPhysicalAddress(context_ptr); + assert_true(context_physical_address != UINT32_MAX); auto xma_decoder = kernel_state->emulator()->audio_system()->xma_decoder(); - uint32_t hw_index = (context_ptr - xma_decoder->context_array_ptr()) / - sizeof(XMA_CONTEXT_DATA); + uint32_t hw_index = + (context_physical_address - xma_decoder->context_array_ptr()) / + sizeof(XMA_CONTEXT_DATA); uint32_t reg_num = base_reg + (hw_index >> 5) * 4; uint32_t reg_value = 1 << (hw_index & 0x1F); xma_decoder->WriteRegister(reg_num, xe::byte_swap(reg_value)); @@ -119,6 +123,9 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr, XMA_CONTEXT_DATA context(context_ptr); + // input_buffer_0_ptr, input_buffer_1_ptr and output_buffer_ptr are physical + // already and good enough for us, checked in sk8er boi simulators skate. and + // Tony Hawk's American Wasteland. Can be 0 also (in THAW). context.input_buffer_0_ptr = context_init->input_buffer_0_ptr; context.input_buffer_0_packet_count = context_init->input_buffer_0_packet_count; From 2f51949ece04860d8b6a35673e901a1b17260c1c Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 27 Aug 2019 23:52:41 +0300 Subject: [PATCH 2/2] [Kernel] Cya l8r recently added wrong XMAInitializeContext comment --- src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc index 07694e45b..84b8502d5 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio_xma.cc @@ -123,9 +123,6 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr, XMA_CONTEXT_DATA context(context_ptr); - // input_buffer_0_ptr, input_buffer_1_ptr and output_buffer_ptr are physical - // already and good enough for us, checked in sk8er boi simulators skate. and - // Tony Hawk's American Wasteland. Can be 0 also (in THAW). context.input_buffer_0_ptr = context_init->input_buffer_0_ptr; context.input_buffer_0_packet_count = context_init->input_buffer_0_packet_count;