2016-07-05 09:44:18 -04:00
|
|
|
#pragma once
|
2012-09-12 04:53:08 +00:00
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
#include "Iop_Intc.h"
|
2023-10-31 19:50:26 +00:00
|
|
|
#include "../PadInterface.h"
|
2012-09-12 04:53:08 +00:00
|
|
|
#include <deque>
|
2025-02-17 11:58:53 -05:00
|
|
|
#include <array>
|
2012-09-12 04:53:08 +00:00
|
|
|
|
|
|
|
namespace Iop
|
|
|
|
{
|
2023-10-31 19:50:26 +00:00
|
|
|
class CSio2 : public CPadInterface
|
2012-09-12 04:53:08 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
ADDR_BEGIN = 0x1F808200,
|
|
|
|
ADDR_END = 0x1F8082FF
|
2012-09-12 04:53:08 +00:00
|
|
|
};
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CSio2(Iop::CIntc&);
|
|
|
|
virtual ~CSio2() = default;
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void Reset();
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void LoadState(Framework::CZipArchiveReader&);
|
|
|
|
void SaveState(Framework::CZipArchiveWriter&);
|
2017-02-09 22:36:01 -05:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint32 ReadRegister(uint32);
|
|
|
|
void WriteRegister(uint32, uint32);
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2021-04-01 17:22:33 -04:00
|
|
|
uint32 ReceiveDmaIn(uint8*, uint32, uint32, uint32);
|
|
|
|
uint32 ReceiveDmaOut(uint8*, uint32, uint32, uint32);
|
2020-03-18 20:47:50 -04:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void SetButtonState(unsigned int, PS2::CControllerInfo::BUTTON, bool, uint8*) override;
|
|
|
|
void SetAxisState(unsigned int, PS2::CControllerInfo::BUTTON, uint8, uint8*) override;
|
2023-10-30 21:58:23 +00:00
|
|
|
void GetVibration(unsigned int padId, uint8& largeMotor, uint8& smallMotor) override;
|
2012-09-12 04:53:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum REGISTERS
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_BASE = 0x1F808200,
|
|
|
|
REG_BASE_END = 0x1F80823F,
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_PORT0_CTRL1 = 0x1F808240,
|
|
|
|
REG_PORT0_CTRL2 = 0x1F808244,
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_PORT1_CTRL1 = 0x1F808248,
|
|
|
|
REG_PORT1_CTRL2 = 0x1F80824C,
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_PORT2_CTRL1 = 0x1F808250,
|
|
|
|
REG_PORT2_CTRL2 = 0x1F808254,
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_PORT3_CTRL1 = 0x1F808258,
|
|
|
|
REG_PORT3_CTRL2 = 0x1F80825C,
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_DATA_OUT = 0x1F808260,
|
|
|
|
REG_DATA_IN = 0x1F808264,
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
REG_CTRL = 0x1F808268,
|
|
|
|
REG_STAT6C = 0x1F80826C,
|
2012-09-12 04:53:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2012-12-30 22:26:06 +00:00
|
|
|
MAX_REGS = 16,
|
|
|
|
MAX_PADS = 2,
|
|
|
|
MAX_PORTS = 4
|
2012-09-12 04:53:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PADSTATE
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
bool configMode;
|
|
|
|
uint8 mode;
|
|
|
|
uint8 pollMask[3];
|
|
|
|
uint16 buttonState;
|
|
|
|
uint8 analogStickState[4];
|
2023-10-30 21:58:23 +00:00
|
|
|
uint8 smallMotor;
|
|
|
|
uint8 largeMotor;
|
2012-09-12 04:53:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::deque<uint8> ByteBufferType;
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void ProcessCommand();
|
|
|
|
void ProcessController(unsigned int, size_t, uint32, uint32);
|
|
|
|
void ProcessMultitap(unsigned int, size_t, uint32, uint32);
|
2020-03-17 09:05:00 -04:00
|
|
|
void ProcessMemoryCard(unsigned int, size_t, uint32, uint32);
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void DisassembleRead(uint32, uint32);
|
|
|
|
void DisassembleWrite(uint32, uint32);
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
Iop::CIntc& m_intc;
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
unsigned int m_currentRegIndex;
|
|
|
|
uint32 m_regs[MAX_REGS];
|
|
|
|
uint32 m_ctrl1[MAX_PORTS];
|
|
|
|
uint32 m_ctrl2[MAX_PORTS];
|
2023-04-04 13:57:26 -04:00
|
|
|
uint32 m_stat6C;
|
2018-04-30 21:01:23 +01:00
|
|
|
ByteBufferType m_inputBuffer;
|
|
|
|
ByteBufferType m_outputBuffer;
|
2012-09-12 04:53:08 +00:00
|
|
|
|
2025-02-17 11:58:53 -05:00
|
|
|
std::array<PADSTATE, MAX_PADS> m_padState;
|
2012-09-12 04:53:08 +00:00
|
|
|
};
|
|
|
|
}
|