diff --git a/Core/Caltron41.h b/Core/Caltron41.h new file mode 100644 index 00000000..8450907c --- /dev/null +++ b/Core/Caltron41.h @@ -0,0 +1,52 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class Caltron41 : public BaseMapper +{ +private: + uint8_t _prgBank; + uint8_t _chrBank; + +protected: + virtual uint16_t GetPRGPageSize() { return 0x8000; } + virtual uint16_t GetCHRPageSize() { return 0x2000; } + virtual uint16_t RegisterStartAddress() { return 0x8000; } + virtual uint16_t RegisterEndAddress() { return 0xFFFF; } + + void InitMapper() + { + AddRegisterRange(0x6000, 0x67FF, MemoryOperation::Write); + } + + void Reset(bool softReset) + { + _chrBank = 0; + _prgBank = 0; + WriteRegister(0x6000, 0); + WriteRegister(0x8000, 0); + } + + void StreamState(bool saving) + { + BaseMapper::StreamState(saving); + Stream(_prgBank, _chrBank); + } + + void WriteRegister(uint16_t addr, uint8_t value) + { + if(addr <= 0x67FF) { + _prgBank = addr & 0x07; + _chrBank = (_chrBank & 0x03) | ((addr >> 1) & 0x0C); + SelectPRGPage(0, _prgBank); + SelectCHRPage(0, _chrBank); + SetMirroringType(addr & 0x20 ? MirroringType::Horizontal : MirroringType::Vertical); + } else { + //"Note that the Inner CHR Bank Select only can be written while the PRG ROM bank is 4, 5, 6, or 7" + if(_prgBank >= 4) { + _chrBank = (_chrBank & 0x0C) | (value & 0x03); + SelectCHRPage(0, _chrBank); + } + } + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index cf82887b..2f11ce3a 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -412,6 +412,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index d7172ae2..b64f030b 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -766,6 +766,9 @@ Nes\Mappers + + Nes\Mappers + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 5c5c10a8..a03b2475 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -10,6 +10,7 @@ #include "BnRom.h" #include "BF909x.h" #include "BF9096.h" +#include "Caltron41.h" #include "CNROM.h" #include "CpRom.h" #include "ColorDreams.h" @@ -131,11 +132,11 @@ #include "Waixing252.h" /* -Supported mappers: (... denotes bad mappers) +Supported mappers: (... denotes bad mappers, --- denotes potentially bad mappers) ----------------------------------------------------------------- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| | 15| | 16| 17| 18| 19|...| 21| 22| 23| 24| 25| 26| 27| 28| | | 31| -| 32| 33| 34| | 36| 37| 38| | 40| | 42| | 44| 45| 46| 47| +| 32| 33| 34| | 36| 37| 38|---| 40| 41| 42| | 44| 45| 46| 47| | 48| 49| 50| | 52| | | | 56| 57| 58| | 60| 61| 62| | | 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79| | 80| | 82| | | 85| 86| 87| 88| 89| | 91| 92| 93| 94| 95| @@ -202,6 +203,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 37: return new MMC3_37(); case 38: return new UnlPci556(); case 40: return new Mapper40(); + case 41: return new Caltron41(); case 42: return new Mapper42(); case 44: return new MMC3_44(); case 45: return new MMC3_45();