openMSX
SdCard.hh
Go to the documentation of this file.
1 #ifndef SDCARD_HH
2 #define SDCARD_HH
3 
4 #include "openmsx.hh"
5 #include "circular_buffer.hh"
6 #include "DiskImageUtils.hh"
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class DeviceConfig;
12 class HD;
13 
14 class SdCard
15 {
16 public:
17  explicit SdCard(const DeviceConfig& config);
18  ~SdCard();
19 
20  byte transfer(byte value, bool cs);
21 
22  template<typename Archive>
23  void serialize(Archive& ar, unsigned version);
24 
25 // private:
26  enum Mode {
32  };
33 
34 private:
35  void executeCommand();
36  byte readCurrentByteFromCurrentSector();
37 
38  const std::unique_ptr<HD> hd; // can be nullptr
39 
40  byte cmdBuf[6];
41  SectorBuffer sectorBuf;
42  unsigned cmdIdx;
43 
44  cb_queue<byte> responseQueue;
45 
46  byte transferDelayCounter;
47  Mode mode;
48  unsigned currentSector;
49  int currentByteInSector;
50 };
51 
52 } // namespace openmsx
53 
54 #endif
openmsx::SdCard::MULTI_READ
@ MULTI_READ
Definition: SdCard.hh:29
openmsx.hh
openmsx::SectorBuffer
Definition: DiskImageUtils.hh:90
openmsx::SdCard::~SdCard
~SdCard()
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::SdCard
Definition: SdCard.hh:14
DiskImageUtils.hh
openmsx::HD
HD
Definition: HD.cc:287
cb_queue< byte >
openmsx::SdCard::READ
@ READ
Definition: SdCard.hh:28
openmsx::SdCard::transfer
byte transfer(byte value, bool cs)
Definition: SdCard.cc:70
openmsx::SdCard::SdCard
SdCard(const DeviceConfig &config)
Definition: SdCard.cc:37
openmsx::SdCard::MULTI_WRITE
@ MULTI_WRITE
Definition: SdCard.hh:31
openmsx::SdCard::WRITE
@ WRITE
Definition: SdCard.hh:30
openmsx::SdCard::COMMAND
@ COMMAND
Definition: SdCard.hh:27
openmsx::SdCard::Mode
Mode
Definition: SdCard.hh:26
circular_buffer.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::SdCard::serialize
void serialize(Archive &ar, unsigned version)
Definition: SdCard.cc:335