SI_DeviceGBA: clean up GetTransferTime()

This commit is contained in:
Michael Maltese 2017-03-31 14:21:39 -07:00
parent d30e0ea28e
commit e6cfc3a75b
2 changed files with 6 additions and 17 deletions

View File

@ -29,7 +29,7 @@ std::queue<std::unique_ptr<sf::TcpSocket>> s_waiting_socks;
std::queue<std::unique_ptr<sf::TcpSocket>> s_waiting_clocks; std::queue<std::unique_ptr<sf::TcpSocket>> s_waiting_clocks;
std::mutex s_cs_gba; std::mutex s_cs_gba;
std::mutex s_cs_gba_clk; std::mutex s_cs_gba_clk;
u8 s_num_connected; int s_num_connected;
Common::Flag s_server_running; Common::Flag s_server_running;
} }
@ -41,21 +41,12 @@ enum EJoybusCmds
CMD_WRITE = 0x15 CMD_WRITE = 0x15
}; };
const u64 BITS_PER_SECOND = 115200; constexpr auto BITS_PER_SECOND = 115200;
const u64 BYTES_PER_SECOND = BITS_PER_SECOND / 8; constexpr auto BYTES_PER_SECOND = BITS_PER_SECOND / 8;
u8 GetNumConnected()
{
int num_ports_connected = s_num_connected;
if (num_ports_connected == 0)
num_ports_connected = 1;
return num_ports_connected;
}
// --- GameBoy Advance "Link Cable" --- // --- GameBoy Advance "Link Cable" ---
int GetTransferTime(u8 cmd) static int GetTransferTime(u8 cmd)
{ {
u64 bytes_transferred = 0; u64 bytes_transferred = 0;
@ -83,8 +74,8 @@ int GetTransferTime(u8 cmd)
break; break;
} }
} }
return (int)(bytes_transferred * SystemTimers::GetTicksPerSecond() / return static_cast<int>(bytes_transferred * SystemTimers::GetTicksPerSecond() /
(GetNumConnected() * BYTES_PER_SECOND)); (std::max(s_num_connected, 1) * BYTES_PER_SECOND));
} }
static void GBAConnectionWaiter() static void GBAConnectionWaiter()

View File

@ -16,8 +16,6 @@
namespace SerialInterface namespace SerialInterface
{ {
u8 GetNumConnected();
int GetTransferTime(u8 cmd);
void GBAConnectionWaiter_Shutdown(); void GBAConnectionWaiter_Shutdown();
class GBASockServer class GBASockServer