Update convention for xboxkrnl_audio.cc (squashed commits)

This commit is contained in:
maxton 2016-11-25 20:48:17 -05:00
parent 7b6af84640
commit d307d83dc0
1 changed files with 46 additions and 85 deletions

View File

@ -19,123 +19,84 @@ namespace xe {
namespace kernel {
namespace xboxkrnl {
SHIM_CALL XAudioGetSpeakerConfig_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t config_ptr = SHIM_GET_ARG_32(0);
XELOGD("XAudioGetSpeakerConfig(%.8X)", config_ptr);
SHIM_SET_MEM_32(config_ptr, 0x00010001);
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
dword_result_t XAudioGetSpeakerConfig(lpdword_t config_ptr) {
*config_ptr = 0x00010001;
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioGetSpeakerConfig,
ExportTag::kImplemented | ExportTag::kAudio);
SHIM_CALL XAudioGetVoiceCategoryVolumeChangeMask_shim(
PPCContext* ppc_context, KernelState* kernel_state) {
uint32_t driver_ptr = SHIM_GET_ARG_32(0);
uint32_t out_ptr = SHIM_GET_ARG_32(1);
XELOGD("XAudioGetVoiceCategoryVolumeChangeMask(%.8X, %.8X)", driver_ptr,
out_ptr);
assert_true((driver_ptr & 0xFFFF0000) == 0x41550000);
dword_result_t XAudioGetVoiceCategoryVolumeChangeMask(lpunknown_t driver_ptr,
lpdword_t out_ptr) {
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
// Checking these bits to see if any voice volume changed.
// I think.
SHIM_SET_MEM_32(out_ptr, 0);
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
*out_ptr = 0;
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioGetVoiceCategoryVolumeChangeMask,
ExportTag::kStub | ExportTag::kAudio);
SHIM_CALL XAudioGetVoiceCategoryVolume_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t unk = SHIM_GET_ARG_32(0);
uint32_t out_ptr = SHIM_GET_ARG_32(1);
XELOGD("XAudioGetVoiceCategoryVolume(%.8X, %.8X)", unk, out_ptr);
dword_result_t XAudioGetVoiceCategoryVolume(dword_t unk, lpfloat_t out_ptr) {
// Expects a floating point single. Volume %?
xe::store_and_swap<float>(SHIM_MEM_ADDR(out_ptr), 1.0f);
*out_ptr = 1.0f;
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioGetVoiceCategoryVolume,
ExportTag::kStub | ExportTag::kAudio);
SHIM_CALL XAudioEnableDucker_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t unk = SHIM_GET_ARG_32(0);
dword_result_t XAudioEnableDucker(dword_t unk) { return X_ERROR_SUCCESS; }
DECLARE_XBOXKRNL_EXPORT(XAudioEnableDucker,
ExportTag::kStub | ExportTag::kAudio);
XELOGD("XAudioEnableDucker(%.8X)", unk);
dword_result_t XAudioRegisterRenderDriverClient(lpdword_t callback_ptr,
lpdword_t driver_ptr) {
uint32_t callback = callback_ptr[0];
uint32_t callback_arg = callback_ptr[1];
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
}
SHIM_CALL XAudioRegisterRenderDriverClient_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t callback_ptr = SHIM_GET_ARG_32(0);
uint32_t driver_ptr = SHIM_GET_ARG_32(1);
uint32_t callback = SHIM_MEM_32(callback_ptr + 0);
uint32_t callback_arg = SHIM_MEM_32(callback_ptr + 4);
XELOGD("XAudioRegisterRenderDriverClient(%.8X(%.8X, %.8X), %.8X)",
callback_ptr, callback, callback_arg, driver_ptr);
auto audio_system = kernel_state->emulator()->audio_system();
auto audio_system = kernel_state()->emulator()->audio_system();
size_t index;
auto result = audio_system->RegisterClient(callback, callback_arg, &index);
if (XFAILED(result)) {
SHIM_SET_RETURN_32(result);
return;
return result;
}
assert_true(!(index & ~0x0000FFFF));
SHIM_SET_MEM_32(driver_ptr,
0x41550000 | (static_cast<uint32_t>(index) & 0x0000FFFF));
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
*driver_ptr = 0x41550000 | (static_cast<uint32_t>(index) & 0x0000FFFF);
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioRegisterRenderDriverClient,
ExportTag::kImplemented | ExportTag::kAudio);
SHIM_CALL XAudioUnregisterRenderDriverClient_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t driver_ptr = SHIM_GET_ARG_32(0);
dword_result_t XAudioUnregisterRenderDriverClient(lpunknown_t driver_ptr) {
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
XELOGD("XAudioUnregisterRenderDriverClient(%.8X)", driver_ptr);
assert_true((driver_ptr & 0xFFFF0000) == 0x41550000);
auto audio_system = kernel_state->emulator()->audio_system();
audio_system->UnregisterClient(driver_ptr & 0x0000FFFF);
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
auto audio_system = kernel_state()->emulator()->audio_system();
audio_system->UnregisterClient(driver_ptr.guest_address() & 0x0000FFFF);
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioUnregisterRenderDriverClient,
ExportTag::kImplemented | ExportTag::kAudio);
SHIM_CALL XAudioSubmitRenderDriverFrame_shim(PPCContext* ppc_context,
KernelState* kernel_state) {
uint32_t driver_ptr = SHIM_GET_ARG_32(0);
uint32_t samples_ptr = SHIM_GET_ARG_32(1);
dword_result_t XAudioSubmitRenderDriverFrame(lpunknown_t driver_ptr,
lpunknown_t samples_ptr) {
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
XELOGD("XAudioSubmitRenderDriverFrame(%.8X, %.8X)", driver_ptr, samples_ptr);
auto audio_system = kernel_state()->emulator()->audio_system();
audio_system->SubmitFrame(driver_ptr.guest_address() & 0x0000FFFF,
samples_ptr);
assert_true((driver_ptr & 0xFFFF0000) == 0x41550000);
auto audio_system = kernel_state->emulator()->audio_system();
audio_system->SubmitFrame(driver_ptr & 0x0000FFFF, samples_ptr);
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
return X_ERROR_SUCCESS;
}
DECLARE_XBOXKRNL_EXPORT(XAudioSubmitRenderDriverFrame,
ExportTag::kImplemented | ExportTag::kAudio);
void RegisterAudioExports(xe::cpu::ExportResolver* export_resolver,
KernelState* kernel_state) {
// Additional XMA* methods are in xboxkrnl_audio_xma.cc.
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioGetSpeakerConfig, state);
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioGetVoiceCategoryVolumeChangeMask,
state);
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioGetVoiceCategoryVolume, state);
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioEnableDucker, state);
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioRegisterRenderDriverClient, state);
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioUnregisterRenderDriverClient, state);
SHIM_SET_MAPPING("xboxkrnl.exe", XAudioSubmitRenderDriverFrame, state);
}
} // namespace xboxkrnl