openMSX
FraelSwitchableROM.cc
Go to the documentation of this file.
1 #include "FraelSwitchableROM.hh"
2 #include "serialize.hh"
3 
4 /*
5  * Information as reverse engineered by FRS:
6  *
7  * Curiously, the machine works without the bootlogo+firmware ROM, because the
8  * MainBIOS checks for its presence. If it's not there, it just skips the logo and
9  * the menu. Maybe they were planning a cheaper version without that ROM.
10  *
11  * The bootlogo+firmware ROM is selected by the bit7 of the I/O port 90h. This is
12  * the same port that has the strobe bit (bit-1) in normal MSX computers. Besides
13  * the extra bit, the rest of the printer port seems to be pretty ordinary.
14  *
15  * Bit7=0: Select Frael MainBIOS ROM on slot-0
16  * Bit7=1: Select the bootlogo+firmware ROM on slot-0
17  */
18 
19 namespace openmsx {
20 
22  : MSXDevice(config)
23  , basicbiosRom(getName() + " BASIC/BIOS", "rom", config, "basicbios")
24  , firmwareRom (getName() + " firmware" , "rom", config, "firmware" )
25 {
26  reset(EmuTime::dummy());
27 }
28 
29 void FraelSwitchableROM::writeIO(word /*port*/, byte value, EmuTime::param /*time*/)
30 {
31  bool newValue = value & 0x80;
32  if (newValue != firmwareSelected) {
33  firmwareSelected = newValue;
35  }
36 }
37 
38 void FraelSwitchableROM::reset(EmuTime::param /*time*/)
39 {
40  firmwareSelected = false;
42 }
43 
44 byte FraelSwitchableROM::readMem(word address, EmuTime::param /*time*/)
45 {
46  return *getReadCacheLine(address);
47 }
48 
50 {
51  return firmwareSelected ? &firmwareRom[start & (firmwareRom.getSize() - 1)] :
52  &basicbiosRom[start & (basicbiosRom.getSize() - 1)];
53 }
54 
55 template<typename Archive>
56 void FraelSwitchableROM::serialize(Archive& ar, unsigned /*version*/)
57 {
58  ar.template serializeBase<MSXDevice>(*this);
59  ar.serialize("firmwareSelected", firmwareSelected);
60 }
62 REGISTER_MSXDEVICE(FraelSwitchableROM, "FraelSwitchableROM");
63 
64 } // namespace openmsx
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::FraelSwitchableROM::readMem
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: FraelSwitchableROM.cc:44
serialize.hh
openmsx::FraelSwitchableROM::FraelSwitchableROM
FraelSwitchableROM(const DeviceConfig &DeviceConfig)
Definition: FraelSwitchableROM.cc:21
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
FraelSwitchableROM.hh
openmsx::FraelSwitchableROM::getReadCacheLine
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: FraelSwitchableROM.cc:49
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::Keys::getName
string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:740
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::MSXDevice::invalidateDeviceRCache
void invalidateDeviceRCache()
Definition: MSXDevice.hh:209
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::FraelSwitchableROM::serialize
void serialize(Archive &ar, unsigned version)
Definition: FraelSwitchableROM.cc:56
openmsx::FraelSwitchableROM::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: FraelSwitchableROM.cc:38
openmsx::FraelSwitchableROM
Definition: FraelSwitchableROM.hh:10
openmsx::Rom::getSize
unsigned getSize() const
Definition: Rom.hh:32
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::FraelSwitchableROM::writeIO
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: FraelSwitchableROM.cc:29