18 , panasonicMem(getMotherBoard().getPanasonicMemory())
22 sram = make_unique<SRAM>(
23 getName() +
" SRAM", sramSize * 1024, config);
50 for (
int region = 0; region < 8; ++region) {
51 bankSelect[region] = 0;
59 if ((control & 0x04) && (0x7FF0 <= address) && (address < 0x7FF8)) {
61 result = bankSelect[address & 7] & 0xFF;
62 }
else if ((control & 0x10) && (address == 0x7FF8)) {
65 for (
int i = 7; i >= 0; i--) {
67 if (bankSelect[i] & 0x100) {
71 }
else if ((control & 0x08) && (address == 0x7FF9)) {
87 if ((0x7FF0 & CacheLine::HIGH) == address) {
97 if ((0x6000 <= address) && (address < 0x7FF0)) {
99 int region = (address & 0x1C00) >> 10;
100 if ((region == 5) || (region == 6)) region ^= 3;
101 int selectedBank = bankSelect[region];
102 int newBank = (selectedBank & ~0xFF) | value;
103 changeBank(region, newBank);
104 }
else if (address == 0x7FF8) {
106 for (
int region = 0; region < 8; region++) {
108 changeBank(region, bankSelect[region] | 0x100);
110 changeBank(region, bankSelect[region] & ~0x100);
114 }
else if (address == 0x7FF9) {
117 }
else if ((0x8000 <= address) && (address < 0xC000)) {
118 int region = address >> 13;
119 int selectedBank = bankSelect[region];
121 (selectedBank < maxSRAMBank)) {
124 sram->write((block * 0x2000) | (address & 0x1FFF), value);
125 }
else if (
RAM_BASE <= selectedBank) {
127 const_cast<byte*
>(
bank[region])[address & 0x1FFF] = value;
135 if ((0x6000 <= address) && (address < 0x7FF0)) {
137 }
else if (address == (0x7FF8 & CacheLine::HIGH)) {
139 }
else if ((0x8000 <= address) && (address < 0xC000)) {
140 int region = address >> 13;
141 int selectedBank = bankSelect[region];
143 (selectedBank < maxSRAMBank)) {
146 }
else if (
RAM_BASE <= selectedBank) {
148 return const_cast<byte*
>(&
bank[region][address & 0x1FFF]);
157 void RomPanasonic::changeBank(
byte region,
int bank)
159 if (bank == bankSelect[region]) {
162 bankSelect[region] =
bank;
167 int sramSize =
sram->getSize();
168 if (offset >= sramSize) {
169 offset &= (sramSize - 1);
183 template<
typename Archive>
186 ar.template serializeBase<Rom8kBBlocks>(*this);
187 ar.serialize(
"bankSelect", bankSelect);
188 ar.serialize(
"control", control);