20 , panasonicMem(getMotherBoard().getPanasonicMemory())
24 sram = std::make_unique<SRAM>(
25 getName() +
" SRAM", sramSize * 1024, config);
42 reset(EmuTime::dummy());
49 for (
auto region :
xrange(8)) {
57 if ((control & 0x04) && (0x7FF0 <= address) && (address < 0x7FF8)) {
59 return bankSelect[address & 7] & 0xFF;
60 }
else if ((control & 0x10) && (address == 0x7FF8)) {
63 for (
int i = 7; i >= 0; i--) {
65 if (bankSelect[i] & 0x100) {
70 }
else if ((control & 0x08) && (address == 0x7FF9)) {
95 if ((0x6000 <= address) && (address < 0x7FF0)) {
97 auto region = (address & 0x1C00) >> 10;
98 if (region ==
one_of(5, 6)) region ^= 3;
99 auto selectedBank = bankSelect[region];
100 auto newBank = (selectedBank & ~0xFF) | value;
101 changeBank(region, newBank);
102 }
else if (address == 0x7FF8) {
104 for (
auto region :
xrange(8)) {
106 changeBank(region, bankSelect[region] | 0x100);
108 changeBank(region, bankSelect[region] & ~0x100);
112 }
else if (address == 0x7FF9) {
119 auto region = address >> 13;
120 auto selectedBank = bankSelect[region];
122 (selectedBank < maxSRAMBank)) {
125 sram->write((block * 0x2000) | (address & 0x1FFF), value);
126 }
else if (
RAM_BASE <= selectedBank) {
128 const_cast<byte*
>(
bankPtr[region])[address & 0x1FFF] = value;
135 if ((0x6000 <= address) && (address < 0x8000)) {
139 auto region = address >> 13;
140 auto selectedBank = bankSelect[region];
142 (selectedBank < maxSRAMBank)) {
145 }
else if (
RAM_BASE <= selectedBank) {
147 return const_cast<byte*
>(&
bankPtr[region][address & 0x1FFF]);
154void RomPanasonic::changeBank(
unsigned region,
unsigned bank)
156 if (bank == bankSelect[region]) {
159 bankSelect[region] = bank;
163 auto offset = (bank -
SRAM_BASE) *
size_t(0x2000);
164 if (
auto sramSize =
sram->size(); offset >= sramSize) {
165 offset &= (sramSize - 1);
168 setBank(region, &
sram->operator[](offset), narrow_cast<byte>(bank));
184template<
typename Archive>
187 ar.template serializeBase<Rom8kBBlocks>(*
this);
188 ar.serialize(
"bankSelect", bankSelect,
#define REGISTER_MSXDEVICE(CLASS, NAME)
bool getChildDataAsBool(std::string_view name, bool defaultValue=false) const
int getChildDataAsInt(std::string_view name, int defaultValue) const
void invalidateDeviceRCache()
void invalidateDeviceWCache()
virtual const std::string & getName() const
Returns a human-readable name for this device.
static std::array< byte, 0x10000 > unmappedWrite
unsigned getRamSize() const
byte * getRamBlock(unsigned block)
Note that this is always unchecked RAM! There is no UMR detection when accessing Ram in DRAM mode or ...
void setBank(unsigned region, const byte *adr, byte block)
Sets the memory visible for reading in a certain region.
void setExtraMemory(std::span< const byte > mem)
Inform this base class of extra mappable memory block.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
std::unique_ptr< SRAM > sram
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
std::array< const byte *, NUM_BANKS > bankPtr
void serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time) override
This method is called on reset.
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.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
RomPanasonic(const DeviceConfig &config, Rom &&rom)
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
constexpr void fill(ForwardRange &&range, const T &value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)