mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-03-18 19:32:41 +00:00
SI/SI_DeviceAMBaseboard: Expose the buffer size of 128 to eliminate some magic numbers.
This commit is contained in:
parent
1234a4e479
commit
4fa93e402d
@ -68,6 +68,8 @@ public:
|
||||
|
||||
u32 GetPollXLines();
|
||||
|
||||
static constexpr u32 BUFFER_SIZE = 128;
|
||||
|
||||
private:
|
||||
// SI Interrupt Types
|
||||
enum SIInterruptType
|
||||
@ -241,7 +243,7 @@ private:
|
||||
USIComCSR m_com_csr;
|
||||
USIStatusReg m_status_reg;
|
||||
USIEXIClockCount m_exi_clock_count;
|
||||
std::array<u8, 128> m_si_buffer{};
|
||||
std::array<u8, BUFFER_SIZE> m_si_buffer{};
|
||||
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
||||
@ -176,14 +176,6 @@ CSIDevice_AMBaseboard::CSIDevice_AMBaseboard(Core::System& system, SIDevices dev
|
||||
}
|
||||
}
|
||||
|
||||
constexpr u32 SI_XFER_LENGTH_MASK = 0x7f;
|
||||
|
||||
// Translate [0,1,2,...,126,127] to [128,1,2,...,126,127]
|
||||
constexpr s32 ConvertSILengthField(u32 field)
|
||||
{
|
||||
return ((field - 1) & SI_XFER_LENGTH_MASK) + 1;
|
||||
}
|
||||
|
||||
void CSIDevice_AMBaseboard::ICCardSendReply(ICCommand* iccommand, u8* buffer, u32* length)
|
||||
{
|
||||
iccommand->status = Common::swap16(iccommand->status);
|
||||
@ -201,9 +193,9 @@ void CSIDevice_AMBaseboard::ICCardSendReply(ICCommand* iccommand, u8* buffer, u3
|
||||
|
||||
void CSIDevice_AMBaseboard::SwapBuffers(u8* buffer, u32* buffer_length)
|
||||
{
|
||||
memcpy(m_last[1], buffer, 0x80); // Save current buffer
|
||||
memcpy(buffer, m_last[0], 0x80); // Load previous buffer
|
||||
memcpy(m_last[0], m_last[1], 0x80); // Update history
|
||||
memcpy(m_last[1], buffer, RESPONSE_SIZE); // Save current buffer
|
||||
memcpy(buffer, m_last[0], RESPONSE_SIZE); // Load previous buffer
|
||||
memcpy(m_last[0], m_last[1], RESPONSE_SIZE); // Update history
|
||||
|
||||
m_lastptr[1] = *buffer_length; // Swap lengths
|
||||
*buffer_length = m_lastptr[0];
|
||||
@ -212,11 +204,12 @@ void CSIDevice_AMBaseboard::SwapBuffers(u8* buffer, u32* buffer_length)
|
||||
|
||||
int CSIDevice_AMBaseboard::RunBuffer(u8* buffer, int request_length)
|
||||
{
|
||||
const auto& serial_interface = m_system.GetSerialInterface();
|
||||
u32 buffer_length = ConvertSILengthField(serial_interface.GetInLength());
|
||||
|
||||
// Debug logging
|
||||
ISIDevice::RunBuffer(buffer, buffer_length);
|
||||
ISIDevice::RunBuffer(buffer, request_length);
|
||||
|
||||
const auto& serial_interface = m_system.GetSerialInterface();
|
||||
|
||||
u32 buffer_length = RESPONSE_SIZE;
|
||||
|
||||
u32 buffer_position = 0;
|
||||
while (buffer_position < buffer_length)
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Core/HW/MagCard/MagneticCardReader.h"
|
||||
#include "Core/HW/SI/SI.h"
|
||||
#include "Core/HW/SI/SI_Device.h"
|
||||
|
||||
namespace SerialInterface
|
||||
@ -175,7 +176,9 @@ private:
|
||||
u32 extlen;
|
||||
};
|
||||
|
||||
u8 m_last[2][0x80] = {};
|
||||
static constexpr u32 RESPONSE_SIZE = SerialInterfaceManager::BUFFER_SIZE;
|
||||
|
||||
u8 m_last[2][RESPONSE_SIZE] = {};
|
||||
u32 m_lastptr[2] = {};
|
||||
|
||||
std::array<u16, 2> m_coin{};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user