openMSX
GoudaSCSI.cc
Go to the documentation of this file.
1 #include "GoudaSCSI.hh"
2 #include "serialize.hh"
3 #include "unreachable.hh"
4 
5 namespace openmsx {
6 
8  : MSXDevice(config)
9  , rom(getName() + " ROM", "rom", config)
10  , wd33c93(config)
11 {
12  reset(EmuTime::dummy());
13 }
14 
15 void GoudaSCSI::reset(EmuTime::param /*time*/)
16 {
17  wd33c93.reset(true);
18 }
19 
20 byte GoudaSCSI::readIO(word port, EmuTime::param /*time*/)
21 {
22  switch (port & 0x03) {
23  case 0:
24  return wd33c93.readAuxStatus();
25  case 1:
26  return wd33c93.readCtrl();
27  case 2:
28  return 0xb0; // bit 4: 1 = Halt on SCSI parity error
29  default:
30  UNREACHABLE; return 0;
31  }
32 }
33 
34 byte GoudaSCSI::peekIO(word port, EmuTime::param /*time*/) const
35 {
36  switch (port & 0x03) {
37  case 0:
38  return wd33c93.peekAuxStatus();
39  case 1:
40  return wd33c93.peekCtrl();
41  case 2:
42  return 0xb0; // bit 4: 1 = Halt on SCSI parity error
43  default:
44  UNREACHABLE; return 0;
45  }
46 }
47 
48 void GoudaSCSI::writeIO(word port, byte value, EmuTime::param time)
49 {
50  switch (port & 0x03) {
51  case 0:
52  wd33c93.writeAdr(value);
53  break;
54  case 1:
55  wd33c93.writeCtrl(value);
56  break;
57  case 2:
58  reset(time);
59  break;
60  default:
62  }
63 }
64 
65 byte GoudaSCSI::readMem(word address, EmuTime::param /*time*/)
66 {
67  return *GoudaSCSI::getReadCacheLine(address);
68 }
69 
71 {
72  return &rom[start & (rom.getSize() - 1)];
73 }
74 
75 
76 template<typename Archive>
77 void GoudaSCSI::serialize(Archive& ar, unsigned /*version*/)
78 {
79  ar.template serializeBase<MSXDevice>(*this);
80  ar.serialize("WD33C93", wd33c93);
81 }
83 REGISTER_MSXDEVICE(GoudaSCSI, "GoudaSCSI");
84 
85 } // namespace openmsx
void writeCtrl(byte value)
Definition: WD33C93.cc:253
byte readAuxStatus()
Definition: WD33C93.cc:312
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
GoudaSCSI(const DeviceConfig &config)
Definition: GoudaSCSI.cc:7
void serialize(Archive &ar, unsigned version)
Definition: GoudaSCSI.cc:77
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
void reset(bool scsireset)
Definition: WD33C93.cc:422
byte readCtrl()
Definition: WD33C93.cc:339
byte peekCtrl() const
Definition: WD33C93.cc:408
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading...
Definition: GoudaSCSI.cc:70
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: GoudaSCSI.cc:20
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:31
void writeAdr(byte value)
Definition: WD33C93.cc:246
unsigned getSize() const
Definition: Rom.hh:32
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: GoudaSCSI.cc:65
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
Definition: GoudaSCSI.cc:48
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:840
void reset(EmuTime::param time) override
This method is called on reset.
Definition: GoudaSCSI.cc:15
string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:589
byte peekAuxStatus() const
Definition: WD33C93.cc:403
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: GoudaSCSI.cc:34
#define UNREACHABLE
Definition: unreachable.hh:38