openMSX
GoudaSCSI.cc
Go to the documentation of this file.
1#include "GoudaSCSI.hh"
2#include "serialize.hh"
3#include "unreachable.hh"
4
5namespace openmsx {
6
8 : MSXDevice(config)
9 , rom(getName() + " ROM", "rom", config)
10 , wd33c93(config)
11{
12 reset(EmuTime::dummy());
13}
14
15void GoudaSCSI::reset(EmuTime::param /*time*/)
16{
17 wd33c93.reset(true);
18}
19
20byte 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:
31 }
32}
33
34byte 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:
45 }
46}
47
48void 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
65byte GoudaSCSI::readMem(word address, EmuTime::param /*time*/)
66{
67 return *GoudaSCSI::getReadCacheLine(address);
68}
69
70const byte* GoudaSCSI::getReadCacheLine(word start) const
71{
72 return &rom[start & (rom.size() - 1)];
73}
74
75
76template<typename Archive>
77void GoudaSCSI::serialize(Archive& ar, unsigned /*version*/)
78{
79 ar.template serializeBase<MSXDevice>(*this);
80 ar.serialize("WD33C93", wd33c93);
81}
84
85} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
void serialize(Archive &ar, unsigned version)
Definition GoudaSCSI.cc:77
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition GoudaSCSI.cc:34
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
GoudaSCSI(const DeviceConfig &config)
Definition GoudaSCSI.cc:7
void reset(EmuTime::param time) override
This method is called on reset.
Definition GoudaSCSI.cc:15
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 readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition GoudaSCSI.cc:65
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
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
auto size() const
Definition Rom.hh:36
void reset(bool scsiReset)
Definition WD33C93.cc:423
void writeAdr(uint8_t value)
Definition WD33C93.cc:247
uint8_t peekCtrl() const
Definition WD33C93.cc:409
uint8_t peekAuxStatus() const
Definition WD33C93.cc:404
void writeCtrl(uint8_t value)
Definition WD33C93.cc:254
uint8_t readCtrl()
Definition WD33C93.cc:340
uint8_t readAuxStatus()
Definition WD33C93.cc:313
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
#define UNREACHABLE