[Kernel] Fix StoreXmaContextIndexedRegister, note about physical addresses in XMAInitializeContext

This commit is contained in:
Triang3l 2019-08-27 23:50:30 +03:00
parent b01f6cd7ea
commit 9df39e4883
1 changed files with 9 additions and 2 deletions

View File

@ -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;