From b30be0fbc160b5b0ce9b5b8baa01c7deb05e690c Mon Sep 17 00:00:00 2001 From: Eladash Date: Tue, 31 Dec 2019 16:02:41 +0200 Subject: [PATCH] Update cellVoiceCreatePort syntax --- rpcs3/Emu/Cell/Modules/cellVoice.cpp | 24 +++++++++++++----------- rpcs3/Emu/Cell/Modules/cellVoice.h | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellVoice.cpp b/rpcs3/Emu/Cell/Modules/cellVoice.cpp index d3c8cc2e21..687699d1b8 100644 --- a/rpcs3/Emu/Cell/Modules/cellVoice.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVoice.cpp @@ -168,22 +168,24 @@ error_code cellVoiceCreatePort(vm::ptr portId, vm::cptr // Id: bits [8,15] seem to contain a "random" value // bits [0,7] are based on creation counter modulo 0xa0 // The rest are set to zero and ignored. - manager->id_ctr = (manager->id_ctr + 1) % 0xa0; - - auto port = manager->ports.begin(); - bool success = false; + manager->id_ctr++; manager->id_ctr %= 0xa0; // It isn't known whether bits[8,15] are guaranteed to be non-zero - for (u8 ctr2 = 1; !success; ctr2++) - { - verify(HERE), ctr2 < CELLVOICE_MAX_PORT + 1; + constexpr u32 min_value = 1; - std::tie(port, success) = manager->ports.try_emplace(::narrow((ctr2 << 8) | manager->id_ctr)); + for (u32 ctr2 = min_value; ctr2 < CELLVOICE_MAX_PORT + min_value; ctr2++) + { + const auto [port, success] = manager->ports.try_emplace(static_cast((ctr2 << 8) | manager->id_ctr)); + + if (success) + { + port->second.info = *pArg; + *portId = port->first; + return CELL_OK; + } } - port->second.info = *pArg; - *portId = port->first; - return CELL_OK; + fmt::throw_exception("Unreachable" HERE); } error_code cellVoiceDeletePort(u32 portId) diff --git a/rpcs3/Emu/Cell/Modules/cellVoice.h b/rpcs3/Emu/Cell/Modules/cellVoice.h index 73c3bf7fd5..4499c9f4cd 100644 --- a/rpcs3/Emu/Cell/Modules/cellVoice.h +++ b/rpcs3/Emu/Cell/Modules/cellVoice.h @@ -185,7 +185,7 @@ struct voice_manager }; // See cellVoiceCreatePort - u32 id_ctr = 0; + u8 id_ctr = 0; // For cellVoiceSetNotifyEventQueue u32 port_source = 0;