openMSX
RomZemina90in1.cc
Go to the documentation of this file.
1// Zemina 90-in-1 cartridge
2//
3// 90 in 1 uses Port &H77 for mapping:
4// bits 0-5: selected 16KB page
5// bits 6-7: addressing mode...
6// 00 = same page at 4000-7FFF and 8000-BFFF (normal mode)
7// 01 = same page at 4000-7FFF and 8000-BFFF (normal mode)
8// 10 = [page AND 3E] at 4000-7FFF, [page AND 3E OR 01] at 8000-BFFF
9// (32KB mode)
10// 11 = same page at 4000-7FFF and 8000-BFFF, but 8000-BFFF has high 8KB
11// and low 8KB swapped (Namco mode)
12
13#include "RomZemina90in1.hh"
14#include "MSXCPUInterface.hh"
15#include "serialize.hh"
16#include "unreachable.hh"
17
18namespace openmsx {
19
21 : Rom8kBBlocks(config, std::move(rom_))
22{
23 reset(EmuTime::dummy());
24 getCPUInterface().register_IO_Out(0x77, this);
25}
26
31
32void RomZemina90in1::reset(EmuTime::param time)
33{
34 setUnmapped(0);
35 setUnmapped(1);
36 setUnmapped(6);
37 setUnmapped(7);
38 writeIO(0x77, 0, time);
39}
40
41void RomZemina90in1::writeIO(word /*port*/, byte value, EmuTime::param /*time*/)
42{
43 byte page = 2 * (value & 0x3F);
44 switch (value & 0xC0) {
45 case 0x00:
46 case 0x40:
47 setRom(2, page + 0);
48 setRom(3, page + 1);
49 setRom(4, page + 0);
50 setRom(5, page + 1);
51 break;
52 case 0x80:
53 setRom(2, (page & ~2) + 0);
54 setRom(3, (page & ~2) + 1);
55 setRom(4, (page | 2) + 0);
56 setRom(5, (page | 2) + 1);
57 break;
58 case 0xC0:
59 setRom(2, page + 0);
60 setRom(3, page + 1);
61 setRom(4, page + 1);
62 setRom(5, page + 0);
63 break;
64 default:
66 }
67}
68
70{
71 return unmappedWrite.data();
72}
73
75
76} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
void unregister_IO_Out(byte port, MSXDevice *device)
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:307
MSXCPUInterface & getCPUInterface() const
Definition MSXDevice.cc:133
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
Definition RomBlocks.cc:92
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition RomBlocks.cc:104
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
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.
void reset(EmuTime::param time) override
This method is called on reset.
RomZemina90in1(const DeviceConfig &config, Rom &&rom)
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
STL namespace.
#define UNREACHABLE