17 , rom(
getName() +
" ROM",
"rom", config)
18 , flashConfig(rom.
size() / 0x10000, {0x10000,
false})
19 , flash(rom, flashConfig, 0x01A4,
24 if ((rom.size() % 0x4000) != 0) {
25 throw MSXException(
"NowindInterface ROM size must be a multiple of 16kB");
27 if (rom.size() == 0) {
28 throw MSXException(
"NowindInterface ROM size cannot be zero");
30 if (rom.size() >
size_t(256 * 0x4000)) {
31 throw MSXException(
"NowindInterface ROM size cannot be larger than 4MB");
34 nowindsInUse = getMotherBoard().getSharedStuff<NowindsInUse>(
"nowindsInUse");
37 while ((*nowindsInUse)[i]) {
38 if (++i == MAX_NOWINDS) {
39 throw MSXException(
"Too many nowind interfaces.");
42 (*nowindsInUse)[i] =
true;
43 basename[6] = char(
'a' + i);
45 command.emplace(basename, getCommandController(), *
this);
48 auto drive = command->createDiskChanger(basename, 0, getMotherBoard());
49 drive->createCommand();
50 drives.push_back(std::move(drive));
52 reset(EmuTime::dummy());
57 unsigned i = basename[6] -
'a';
58 assert((*nowindsInUse)[i]);
59 (*nowindsInUse)[i] =
false;
74 if (((0x2000 <= address) && (address < 0x4000)) ||
75 ((0x8000 <= address) && (address < 0xA000))) {
77 }
else if ((0x4000 <= address) && (address < 0xC000)) {
79 return flash.
peek(bank * 0x4000 + (address & 0x3FFF));
87 if (((0x2000 <= address) && (address < 0x4000)) ||
88 ((0x8000 <= address) && (address < 0xA000))) {
90 }
else if ((0x4000 <= address) && (address < 0xC000)) {
92 return flash.
read(bank * 0x4000 + (address & 0x3FFF));
100 if (((0x2000 <= address) && (address < 0x4000)) ||
101 ((0x8000 <= address) && (address < 0xA000))) {
104 }
else if ((0x4000 <= address) && (address < 0xC000)) {
114 if (address < 0x4000) {
115 flash.
write(bank * 0x4000 + address, value);
116 }
else if (((0x4000 <= address) && (address < 0x6000)) ||
117 ((0x8000 <= address) && (address < 0xA000))) {
120 }
else if (((0x6000 <= address) && (address < 0x8000)) ||
121 ((0xA000 <= address) && (address < 0xC000))) {
122 auto max = narrow<uint8_t>((rom.
size() / 0x4000) - 1);
123 bank = (value <=
max) ? value : (value &
max);
131 if (address < 0xC000) {
140template<
typename Archive>
143 ar.template serializeBase<MSXDevice>(*
this);
144 ar.serialize(
"flash", flash);
146 ar.serialize(
"nowindhost", host,
void write(size_t address, uint8_t value)
const uint8_t * getReadCacheLine(size_t address) const
uint8_t peek(size_t address) const
uint8_t read(size_t address) const
Represents a clock with a fixed frequency.
constexpr unsigned getTicksTill(EmuTime::param e) const
Calculate the number of ticks for this clock until the given time.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
MSXMotherBoard & getMotherBoard() const
Get the mother board this device belongs to.
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
void write(byte data, unsigned time)
~NowindInterface() override
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void reset(EmuTime::param time) override
This method is called on reset.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
NowindInterface(const DeviceConfig &config)
void serialize(Archive &ar, unsigned version)
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
constexpr vecN< N, T > max(const vecN< N, T > &x, const vecN< N, T > &y)
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
size_t size(std::string_view utf8)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)