MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Memcard

Method Memcard

pcsx2/SIO/Sio2.cpp:248–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248void Sio2::Memcard()
249{
250 MultitapProtocol& mtap = g_MultitapArr.at(this->port);
251
252 mcd = &mcds[port][mtap.GetMemcardSlot()];
253
254 // Check if auto ejection is active. If so, set cmd stat to DISCONNECTED,
255 // and zero out the fifo to simulate dead air over the wire.
256 if (mcd->autoEjectTicks)
257 {
258 SetCmdStat(CmdStat::DISCONNECTED);
259 g_Sio2FifoOut.push_back(0xff); // Because Sio2::Write pops the first g_Sio2FifoIn member
260
261 while (!g_Sio2FifoIn.empty())
262 {
263 g_Sio2FifoIn.pop_front();
264 g_Sio2FifoOut.push_back(0xff);
265 }
266
267 return;
268 }
269
270 SetCmdStat(mcd->IsPresent() ? CmdStat::CONNECTED : CmdStat::DISCONNECTED);
271
272 const u8 commandByte = g_Sio2FifoIn.front();
273 g_Sio2FifoIn.pop_front();
274 const u8 responseByte = mcd->IsPresent() ? 0x00 : 0xff;
275 g_Sio2FifoOut.push_back(responseByte);
276 g_Sio2FifoOut.push_back(responseByte);
277 u8 ps1Input = 0;
278 u8 ps1Output = 0;
279
280 switch (commandByte)
281 {
282 case MemcardCommand::PROBE:
283 g_MemoryCardProtocol.Probe();
284 break;
285 case MemcardCommand::UNKNOWN_WRITE_DELETE_END:
286 g_MemoryCardProtocol.UnknownWriteDeleteEnd();
287 break;
288 case MemcardCommand::SET_ERASE_SECTOR:
289 case MemcardCommand::SET_WRITE_SECTOR:
290 case MemcardCommand::SET_READ_SECTOR:
291 g_MemoryCardProtocol.SetSector();
292 break;
293 case MemcardCommand::GET_SPECS:
294 g_MemoryCardProtocol.GetSpecs();
295 break;
296 case MemcardCommand::SET_TERMINATOR:
297 g_MemoryCardProtocol.SetTerminator();
298 break;
299 case MemcardCommand::GET_TERMINATOR:
300 g_MemoryCardProtocol.GetTerminator();
301 break;
302 case MemcardCommand::WRITE_DATA:
303 g_MemoryCardProtocol.WriteData();
304 break;
305 case MemcardCommand::READ_DATA:

Callers 1

WriteMethod · 0.95

Calls 15

atMethod · 0.80
GetMemcardSlotMethod · 0.80
ProbeMethod · 0.80
UnknownWriteDeleteEndMethod · 0.80
SetSectorMethod · 0.80
GetSpecsMethod · 0.80
SetTerminatorMethod · 0.80
GetTerminatorMethod · 0.80
WriteDataMethod · 0.80
ReadDataMethod · 0.80
ResetPS1StateMethod · 0.80
PS1ReadMethod · 0.80

Tested by

no test coverage detected