openMSX
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
openmsx::RomBlocks< BANK_SIZE_ > Class Template Reference

#include <RomBlocks.hh>

Inheritance diagram for openmsx::RomBlocks< BANK_SIZE_ >:
Inheritance graph
[legend]
Collaboration diagram for openmsx::RomBlocks< BANK_SIZE_ >:
Collaboration graph
[legend]

Public Member Functions

byte readMem (word address, EmuTime::param time) override
 Read a byte from a location at a certain time from this device. More...
 
byte peekMem (word address, EmuTime::param time) const override
 Read a byte from a given memory location. More...
 
const bytegetReadCacheLine (word start) const override
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading. More...
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::MSXRom
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. More...
 
bytegetWriteCacheLine (word address) const override
 Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing. More...
 
void getExtraDeviceInfo (TclObject &result) const override
 
- Public Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const MSXDevice &)=delete
 
MSXDeviceoperator= (const MSXDevice &)=delete
 
virtual ~MSXDevice ()=0
 
const HardwareConfiggetHardwareConfig () const
 Returns the hardwareconfig this device belongs to. More...
 
void testRemove (Devices alreadyRemoved) const
 Checks whether this device can be removed (no other device has a reference to it). More...
 
virtual void reset (EmuTime::param time)
 This method is called on reset. More...
 
virtual byte readIRQVector ()
 Gets IRQ vector used in IM2. More...
 
virtual void powerDown (EmuTime::param time)
 This method is called when MSX is powered down. More...
 
virtual void powerUp (EmuTime::param time)
 This method is called when MSX is powered up. More...
 
virtual std::string getName () const
 Returns a human-readable name for this device. More...
 
virtual void getNameList (TclObject &result) const
 Returns list of name(s) of this device. More...
 
void getDeviceInfo (TclObject &result) const
 Get device info. More...
 
void getVisibleMemRegion (unsigned &base, unsigned &size) const
 Returns the range where this device is visible in memory. More...
 
virtual byte readIO (word port, EmuTime::param time)
 Read a byte from an IO port at a certain time from this device. More...
 
virtual void writeIO (word port, byte value, EmuTime::param time)
 Write a byte to a given IO port at a certain time to this device. More...
 
virtual byte peekIO (word port, EmuTime::param time) const
 Read a byte from a given IO port. More...
 
virtual void globalWrite (word address, byte value, EmuTime::param time)
 Global writes. More...
 
void invalidateMemCache (word start, unsigned size)
 Invalidate CPU memory-mapping cache. More...
 
MSXMotherBoardgetMotherBoard () const
 Get the mother board this device belongs to. More...
 
const XMLElementgetDeviceConfig () const
 Get the configuration section for this device. More...
 
const DeviceConfiggetDeviceConfig2 () const
 
const DevicesgetReferences () const
 Get the device references that are specified for this device. More...
 
EmuTime::param getCurrentTime () const
 
MSXCPUgetCPU () const
 
MSXCPUInterfacegetCPUInterface () const
 
SchedulergetScheduler () const
 
CliCommgetCliComm () const
 
ReactorgetReactor () const
 
CommandControllergetCommandController () const
 
PluggingControllergetPluggingController () const
 
LedStatusgetLedStatus () const
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Static Public Attributes

static const unsigned BANK_SIZE = BANK_SIZE_
 
static const unsigned NUM_BANKS = 0x10000 / BANK_SIZE
 
static const unsigned BANK_MASK = BANK_SIZE - 1
 
- Static Public Attributes inherited from openmsx::MSXDevice
static byte unmappedRead [0x10000]
 
static byte unmappedWrite [0x10000]
 

Protected Member Functions

 RomBlocks (const DeviceConfig &config, Rom &&rom, unsigned debugBankSizeShift=0)
 Constructor. More...
 
 ~RomBlocks ()
 
void setUnmapped (byte region)
 Select 'unmapped' memory for this region. More...
 
void setBank (byte region, const byte *adr, int block)
 Sets the memory visible for reading in a certain region. More...
 
void setRom (byte region, int block)
 Selects a block of the ROM image for reading in a certain region. More...
 
void setBlockMask (int mask)
 Sets a mask for the block numbers. More...
 
void setExtraMemory (const byte *mem, unsigned size)
 Inform this base class of extra mapable memory block. More...
 
- Protected Member Functions inherited from openmsx::MSXRom
 MSXRom (const DeviceConfig &config, Rom &&rom)
 
- Protected Member Functions inherited from openmsx::MSXDevice
 MSXDevice (const DeviceConfig &config, const std::string &name)
 Every MSXDevice has a config entry; this constructor gets some device properties from that config entry. More...
 
 MSXDevice (const DeviceConfig &config)
 
virtual void init ()
 

Protected Attributes

const bytebankPtr [NUM_BANKS]
 
std::unique_ptr< SRAMsram
 
byte blockNr [NUM_BANKS]
 
- Protected Attributes inherited from openmsx::MSXRom
Rom rom
 

Additional Inherited Members

- Public Types inherited from openmsx::MSXDevice
using Devices = std::vector< MSXDevice * >
 

Detailed Description

template<unsigned BANK_SIZE_>
class openmsx::RomBlocks< BANK_SIZE_ >

Definition at line 13 of file RomBlocks.hh.

Constructor & Destructor Documentation

◆ RomBlocks()

template<unsigned BANK_SIZE>
openmsx::RomBlocks< BANK_SIZE >::RomBlocks ( const DeviceConfig config,
Rom &&  rom,
unsigned  debugBankSizeShift = 0 
)
protected

Constructor.

Parameters
config
rom
debugBankSizeShiftSometimes the mapper is implemented with a smaller block size than the blocks that get logically switched. For example RomGameMaster2 is implemented as a 4kB mapper but blocks get switched in 8kB chunks (done like this because there is only 4kB SRAM, that needs to be mirrored in a 8kB chunk). This parameter indicates how much bigger the logical blocks are compared to the implementation block size, it's only used to correctly implement the 'romblocks' debuggable.

Definition at line 21 of file RomBlocks.cc.

References openmsx::Rom::addPadding(), openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE, openmsx::DeviceConfig::findChild(), openmsx::DeviceConfig::getCliComm(), openmsx::XMLElement::getData(), openmsx::Rom::getOriginalSHA1(), openmsx::Rom::getSize(), Math::isPowerOfTwo(), openmsx::RomBlocks< BANK_SIZE_ >::NUM_BANKS, openmsx::CliComm::printWarning(), openmsx::MSXRom::rom, openmsx::RomBlocks< BANK_SIZE_ >::setRom(), StringOp::toString(), and openmsx::RomBlocks< BANK_SIZE_ >::~RomBlocks().

◆ ~RomBlocks()

template<unsigned BANK_SIZE>
openmsx::RomBlocks< BANK_SIZE >::~RomBlocks ( )
protecteddefault

Member Function Documentation

◆ getReadCacheLine()

template<unsigned BANK_SIZE>
const byte * openmsx::RomBlocks< BANK_SIZE >::getReadCacheLine ( word  start) const
overridevirtual

Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.

If it is, a pointer to a buffer containing this interval must be returned. If not, a null pointer must be returned. Cacheable for reading means the data may be read directly from the buffer, thus bypassing the readMem() method, and thus also ignoring EmuTime. The default implementation always returns a null pointer. The start of the interval is CacheLine::SIZE aligned.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::RomFSA1FM2, openmsx::RomMitsubishiMLTS2, openmsx::RomKonamiSCC, openmsx::RomPanasonic, openmsx::RomPlayBall, openmsx::RomNational, and openmsx::RomHalnote.

Definition at line 73 of file RomBlocks.cc.

References openmsx::RomBlocks< BANK_SIZE_ >::BANK_MASK, openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE, and openmsx::RomBlocks< BANK_SIZE_ >::bankPtr.

Referenced by openmsx::RomHalnote::getReadCacheLine(), openmsx::RomAscii16_2::getReadCacheLine(), openmsx::RomNational::getReadCacheLine(), openmsx::RomPlayBall::getReadCacheLine(), openmsx::RomAscii8_8::getReadCacheLine(), openmsx::RomKonamiSCC::getReadCacheLine(), openmsx::RomPanasonic::getReadCacheLine(), openmsx::RomMitsubishiMLTS2::getReadCacheLine(), and openmsx::RomFSA1FM2::getReadCacheLine().

◆ peekMem()

template<unsigned BANK_SIZE>
byte openmsx::RomBlocks< BANK_SIZE >::peekMem ( word  address,
EmuTime::param  time 
) const
overridevirtual

Read a byte from a given memory location.

Reading memory via this method has no side effects (doesn't change the device status). If save reading is not possible this method returns 0xFF. This method is not used by the emulation. It can however be used by a debugger. The default implementation uses the cache mechanism (getReadCacheLine() method). If a certain region is not cacheable you cannot read it by default, Override this method if you want to improve this behaviour.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::RomFSA1FM2, openmsx::RomMitsubishiMLTS2, openmsx::RomKonamiSCC, openmsx::RomPanasonic, openmsx::RomPlayBall, and openmsx::RomNational.

Definition at line 61 of file RomBlocks.cc.

References openmsx::RomBlocks< BANK_SIZE_ >::BANK_MASK, openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE, and openmsx::RomBlocks< BANK_SIZE_ >::bankPtr.

Referenced by openmsx::RomNational::peekMem(), openmsx::RomPlayBall::peekMem(), openmsx::RomKonamiSCC::peekMem(), openmsx::RomPanasonic::peekMem(), openmsx::RomMitsubishiMLTS2::peekMem(), openmsx::RomFSA1FM2::peekMem(), and openmsx::RomBlocks< BANK_SIZE_ >::readMem().

◆ readMem()

template<unsigned BANK_SIZE>
byte openmsx::RomBlocks< BANK_SIZE >::readMem ( word  address,
EmuTime::param  time 
)
overridevirtual

Read a byte from a location at a certain time from this device.

The default implementation returns 255.

Reimplemented from openmsx::MSXDevice.

Reimplemented in openmsx::RomFSA1FM2, openmsx::RomMitsubishiMLTS2, openmsx::RomKonamiSCC, openmsx::RomPanasonic, openmsx::RomPlayBall, openmsx::RomNational, and openmsx::RomHalnote.

Definition at line 67 of file RomBlocks.cc.

References openmsx::RomBlocks< BANK_SIZE_ >::peekMem().

Referenced by openmsx::RomAscii16_2::readMem(), openmsx::RomAscii8_8::readMem(), and openmsx::RomKonamiSCC::readMem().

◆ serialize()

template<unsigned BANK_SIZE>
template<typename Archive >
void openmsx::RomBlocks< BANK_SIZE >::serialize ( Archive &  ar,
unsigned  version 
)

◆ setBank()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setBank ( byte  region,
const byte adr,
int  block 
)
protected

Sets the memory visible for reading in a certain region.

Parameters
regionnumber of 8kB region in Z80 address space (region i starts at Z80 address i * 0x2000)
adrpointer to memory, area must be at least 0x2000 bytes long
blockBlock number, only used for the 'romblock' debuggable.

Definition at line 79 of file RomBlocks.cc.

References openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE, openmsx::RomBlocks< BANK_SIZE_ >::bankPtr, openmsx::RomBlocks< BANK_SIZE_ >::blockNr, openmsx::Rom::getSize(), openmsx::MSXDevice::invalidateMemCache(), openmsx::MSXRom::rom, openmsx::RomBlocks< BANK_SIZE_ >::sram, and openmsx::MSXDevice::unmappedRead.

Referenced by openmsx::RomPanasonic::getWriteCacheLine(), openmsx::RomBlocks< BANK_SIZE_ >::setRom(), openmsx::RomBlocks< BANK_SIZE_ >::setUnmapped(), openmsx::RomGameMaster2::writeMem(), openmsx::RomHalnote::writeMem(), and openmsx::RomAscii8_8::writeMem().

◆ setBlockMask()

template<unsigned BANK_SIZE_>
void openmsx::RomBlocks< BANK_SIZE_ >::setBlockMask ( int  mask)
inlineprotected

Sets a mask for the block numbers.

On every call to setRom, the given block number is AND-ed with this mask; if the resulting number if outside of the ROM, unmapped memory is selected. By default the mask is set up to wrap at the end of the ROM image, meaning the entire ROM is reachable and there is no unmapped memory.

Definition at line 72 of file RomBlocks.hh.

References openmsx::RomBlocks< BANK_SIZE_ >::setExtraMemory(), and size().

Referenced by openmsx::RomKonami::RomKonami().

◆ setExtraMemory()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setExtraMemory ( const byte mem,
unsigned  size 
)
protected

Inform this base class of extra mapable memory block.

This is needed for serialization of mappings in this block. Should only be called from subclass constructor. (e.g. used by RomPanasonic)

Definition at line 99 of file RomBlocks.cc.

References size().

Referenced by openmsx::RomPanasonic::RomPanasonic(), and openmsx::RomBlocks< BANK_SIZE_ >::setBlockMask().

◆ setRom()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setRom ( byte  region,
int  block 
)
protected

Selects a block of the ROM image for reading in a certain region.

Parameters
regionnumber of 8kB region in Z80 address space (region i starts at Z80 address i * 0x2000)
blocknumber of 8kB block in the ROM image (block i starts at ROM image offset i * 0x2000)

Definition at line 106 of file RomBlocks.cc.

References openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE, openmsx::MSXRom::rom, openmsx::RomBlocks< BANK_SIZE_ >::setBank(), and openmsx::MSXDevice::unmappedRead.

Referenced by openmsx::RomPanasonic::getWriteCacheLine(), openmsx::RomFSA1FM2::getWriteCacheLine(), openmsx::RomSuperLodeRunner::globalWrite(), openmsx::RomHalnote::reset(), openmsx::RomNational::reset(), openmsx::RomGeneric8kB::reset(), openmsx::RomPadial16kB::reset(), openmsx::RomPadial8kB::reset(), openmsx::RomHarryFox::reset(), openmsx::RomHolyQuran::reset(), openmsx::RomGameMaster2::reset(), openmsx::RomRType::reset(), openmsx::RomSuperSwangi::reset(), openmsx::RomZemina126in1::reset(), openmsx::RomGeneric16kB::reset(), openmsx::RomZemina80in1::reset(), openmsx::RomMSXDOS2::reset(), openmsx::RomSuperLodeRunner::reset(), openmsx::RomMSXWrite::reset(), openmsx::RomAscii16kB::reset(), openmsx::RomNettouYakyuu::reset(), openmsx::RomKonami::reset(), openmsx::RomAscii8kB::reset(), openmsx::RomMultiRom::reset(), openmsx::RomAscii8_8::reset(), openmsx::RomPanasonic::reset(), openmsx::RomKonamiSCC::reset(), openmsx::RomMitsubishiMLTS2::reset(), openmsx::RomArc::RomArc(), openmsx::RomBlocks< BANK_SIZE_ >::RomBlocks(), openmsx::RomKonamiKeyboardMaster::RomKonamiKeyboardMaster(), openmsx::RomMultiRom::RomMultiRom(), openmsx::RomPageNN::RomPageNN(), openmsx::RomPlain::RomPlain(), openmsx::RomPlayBall::RomPlayBall(), openmsx::RomSynthesizer::RomSynthesizer(), openmsx::RomZemina90in1::writeIO(), openmsx::RomZemina126in1::writeMem(), openmsx::RomMSXDOS2::writeMem(), openmsx::RomGeneric8kB::writeMem(), openmsx::RomHarryFox::writeMem(), openmsx::RomGeneric16kB::writeMem(), openmsx::RomGameMaster2::writeMem(), openmsx::RomCrossBlaim::writeMem(), openmsx::RomZemina80in1::writeMem(), openmsx::RomHolyQuran::writeMem(), openmsx::RomRType::writeMem(), openmsx::RomSuperSwangi::writeMem(), openmsx::RomAscii8kB::writeMem(), openmsx::RomNettouYakyuu::writeMem(), openmsx::RomAscii16kB::writeMem(), openmsx::RomKonami::writeMem(), openmsx::RomMSXWrite::writeMem(), openmsx::RomHalnote::writeMem(), openmsx::RomAscii8_8::writeMem(), openmsx::RomAscii16_2::writeMem(), openmsx::RomNational::writeMem(), openmsx::RomKonamiSCC::writeMem(), and openmsx::RomMitsubishiMLTS2::writeMem().

◆ setUnmapped()

template<unsigned BANK_SIZE>
void openmsx::RomBlocks< BANK_SIZE >::setUnmapped ( byte  region)
protected

Member Data Documentation

◆ BANK_MASK

template<unsigned BANK_SIZE_>
const unsigned openmsx::RomBlocks< BANK_SIZE_ >::BANK_MASK = BANK_SIZE - 1
static

◆ BANK_SIZE

template<unsigned BANK_SIZE_>
const unsigned openmsx::RomBlocks< BANK_SIZE_ >::BANK_SIZE = BANK_SIZE_
static

◆ bankPtr

template<unsigned BANK_SIZE_>
const byte* openmsx::RomBlocks< BANK_SIZE_ >::bankPtr[NUM_BANKS]
protected

◆ blockNr

template<unsigned BANK_SIZE_>
byte openmsx::RomBlocks< BANK_SIZE_ >::blockNr[NUM_BANKS]
protected

Definition at line 83 of file RomBlocks.hh.

Referenced by openmsx::RomBlocks< BANK_SIZE_ >::setBank().

◆ NUM_BANKS

template<unsigned BANK_SIZE_>
const unsigned openmsx::RomBlocks< BANK_SIZE_ >::NUM_BANKS = 0x10000 / BANK_SIZE
static

◆ sram

template<unsigned BANK_SIZE_>
std::unique_ptr<SRAM> openmsx::RomBlocks< BANK_SIZE_ >::sram
protected

The documentation for this class was generated from the following files: