Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit d72d1f3

Browse files
committed
Added more VS System info to DB, support for new NES 2.0 proposals (WIP) + some refactoring
1 parent 7c8a54a commit d72d1f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+31783
-31781
lines changed

Core/AXROM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AXROM : public BaseMapper
1414
SelectCHRPage(0, 0);
1515
}
1616

17-
bool HasBusConflicts() override { return _subMapperID == 2; }
17+
bool HasBusConflicts() override { return _romInfo.SubMapperID == 2; }
1818

1919
void WriteRegister(uint16_t addr, uint8_t value) override
2020
{

Core/BF9096.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BF9096 : public BaseMapper
2828
if(addr >= 0xC000) {
2929
_prgPage = value & 0x03;
3030
} else if(addr < 0xC000) {
31-
if(_subMapperID == 1) {
31+
if(_romInfo.SubMapperID == 1) {
3232
//"232: 1 Aladdin Deck Enhancer"
3333
//"Aladdin Deck Enhancer variation.Swap the bits of the outer bank number."
3434
//But this seems to match the Pegasus 4-in-1 behavior? Wiki wrong?

Core/BF909x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BF909x : public BaseMapper
1313

1414
void InitMapper() override
1515
{
16-
if(_subMapperID == 1) {
16+
if(_romInfo.SubMapperID == 1) {
1717
_bf9097Mode = true;
1818
}
1919

Core/BandaiFcg.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BandaiFcg : public BaseMapper
2222
uint16_t RegisterStartAddress() override { return 0x6000; }
2323
uint16_t RegisterEndAddress() override { return 0xFFFF; }
2424
bool AllowRegisterRead() override { return true; }
25-
ConsoleFeatures GetAvailableFeatures() override { return _mapperID == 157 ? (ConsoleFeatures)((int)ConsoleFeatures::BarcodeReader | (int)ConsoleFeatures::DatachBarcodeReader) : ConsoleFeatures::None; }
25+
ConsoleFeatures GetAvailableFeatures() override { return _romInfo.MapperID == 157 ? (ConsoleFeatures)((int)ConsoleFeatures::BarcodeReader | (int)ConsoleFeatures::DatachBarcodeReader) : ConsoleFeatures::None; }
2626

2727
void InitMapper() override
2828
{
@@ -33,7 +33,7 @@ class BandaiFcg : public BaseMapper
3333
_prgPage = 0;
3434
_prgBankSelect = 0;
3535

36-
if(_mapperID == 157) {
36+
if(_romInfo.MapperID == 157) {
3737
//"Mapper 157 is used for Datach Joint ROM System boards"
3838
_barcodeReader.reset(new DatachBarcodeReader(_console));
3939
_mapperControlDevice = _barcodeReader;
@@ -42,7 +42,7 @@ class BandaiFcg : public BaseMapper
4242
//Only allow reads from 0x6000 to 0x7FFF
4343
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
4444

45-
if(_mapperID != 16 || GetPRGPageCount() >= 0x20) {
45+
if(_romInfo.MapperID != 16 || GetPRGPageCount() >= 0x20) {
4646
//"For iNES Mapper 153 (with SRAM), the writeable ports must only be mirrored across $8000-$FFFF."
4747
//"Mappers 157 and 159 do not need to support the FCG-1 and -2 and so should only mirror the ports across $8000-$FFFF."
4848

@@ -86,14 +86,14 @@ class BandaiFcg : public BaseMapper
8686
switch(addr & 0x000F) {
8787
case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
8888
_chrRegs[addr & 0x07] = value;
89-
if(_mapperID == 153 || GetPRGPageCount() >= 0x20) {
89+
if(_romInfo.MapperID == 153 || GetPRGPageCount() >= 0x20) {
9090
_prgBankSelect = 0;
9191
for(int i = 0; i < 8; i++) {
9292
_prgBankSelect |= (_chrRegs[i] & 0x01) << 4;
9393
}
9494
SelectPRGPage(0, _prgPage | _prgBankSelect);
9595
SelectPRGPage(1, 0x0F | _prgBankSelect);
96-
} else if(!HasChrRam() && _mapperID != 157) {
96+
} else if(!HasChrRam() && _romInfo.MapperID != 157) {
9797
SelectCHRPage(addr & 0x07, value);
9898
}
9999
break;

Core/BaseMapper.cpp

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ uint8_t BaseMapper::GetPowerOnByte(uint8_t defaultValue)
347347

348348
bool BaseMapper::HasBattery()
349349
{
350-
return _hasBattery;
350+
return _romInfo.HasBattery;
351351
}
352352

353353
void BaseMapper::LoadBattery()
@@ -384,7 +384,7 @@ uint32_t BaseMapper::GetCHRPageCount()
384384

385385
string BaseMapper::GetBatteryFilename()
386386
{
387-
return FolderUtilities::CombinePath(FolderUtilities::GetSaveFolder(), FolderUtilities::GetFilename(_romName, false) + ".sav");
387+
return FolderUtilities::CombinePath(FolderUtilities::GetSaveFolder(), FolderUtilities::GetFilename(_romInfo.RomName, false) + ".sav");
388388
}
389389

390390
void BaseMapper::RestoreOriginalPrgRam()
@@ -493,17 +493,10 @@ void BaseMapper::StreamState(bool saving)
493493

494494
void BaseMapper::Initialize(RomData &romData)
495495
{
496-
_mapperID = romData.MapperID;
497-
_subMapperID = romData.SubMapperID;
496+
_romInfo = romData.Info;
498497

499-
_databaseInfo = romData.DatabaseInfo;
500-
501-
_romName = romData.RomName;
502-
_romFilename = romData.Filename;
503498
_batteryFilename = GetBatteryFilename();
504499

505-
_hasBattery = romData.HasBattery;
506-
507500
if(romData.SaveRamSize == -1 || ForceSaveRamSize()) {
508501
_saveRamSize = GetSaveRamSize();
509502
} else {
@@ -522,10 +515,7 @@ void BaseMapper::Initialize(RomData &romData)
522515
memset(_isWriteRegisterAddr, 0, sizeof(_isWriteRegisterAddr));
523516
AddRegisterRange(RegisterStartAddress(), RegisterEndAddress(), MemoryOperation::Any);
524517

525-
_nesHeader = romData.NesHeader;
526-
_romFormat = romData.Format;
527-
528-
_mirroringType = romData.Mirroring;
518+
_mirroringType = romData.Info.Mirroring;
529519

530520
_prgSize = (uint32_t)romData.PrgRom.size();
531521
_chrRomSize = (uint32_t)romData.ChrRom.size();
@@ -541,13 +531,7 @@ void BaseMapper::Initialize(RomData &romData)
541531

542532
_hasChrBattery = romData.SaveChrRamSize > 0 || ForceChrBattery();
543533

544-
_gameSystem = romData.System;
545-
_hashInfo.Crc32Hash = romData.Crc32;
546-
_hashInfo.PrgCrc32Hash = romData.PrgCrc32;
547-
_hashInfo.PrgChrCrc32Hash = romData.PrgChrCrc32;
548-
_hashInfo.Sha1Hash = romData.Sha1;
549-
_hashInfo.PrgChrMd5Hash = romData.PrgChrMd5;
550-
switch(romData.BusConflicts) {
534+
switch(romData.Info.BusConflicts) {
551535
case BusConflictType::Default: _hasBusConflicts = HasBusConflicts(); break;
552536
case BusConflictType::Yes: _hasBusConflicts = true; break;
553537
case BusConflictType::No: _hasBusConflicts = false; break;
@@ -590,7 +574,7 @@ void BaseMapper::Initialize(RomData &romData)
590574
//Load battery data if present
591575
LoadBattery();
592576

593-
if(romData.HasTrainer) {
577+
if(romData.Info.HasTrainer) {
594578
if(_workRamSize >= 0x2000) {
595579
memcpy(_workRam + 0x1000, romData.TrainerData.data(), 512);
596580
} else if(_saveRamSize >= 0x2000) {
@@ -604,6 +588,8 @@ void BaseMapper::Initialize(RomData &romData)
604588
InitMapper(romData);
605589

606590
ApplyCheats();
591+
592+
_romInfo.HasChrRam = HasChrRam();
607593
}
608594

609595
BaseMapper::~BaseMapper()
@@ -643,7 +629,7 @@ void BaseMapper::ApplyCheats()
643629

644630
void BaseMapper::GetMemoryRanges(MemoryRanges &ranges)
645631
{
646-
if(_gameSystem == GameSystem::VsUniSystem || _gameSystem == GameSystem::VsDualSystem) {
632+
if(_romInfo.System == GameSystem::VsSystem) {
647633
ranges.AddHandler(MemoryOperation::Read, 0x6000, 0xFFFF);
648634
ranges.AddHandler(MemoryOperation::Write, 0x6000, 0xFFFF);
649635
} else {
@@ -730,17 +716,9 @@ shared_ptr<BaseControlDevice> BaseMapper::GetMapperControlDevice()
730716
return _mapperControlDevice;
731717
}
732718

733-
MapperInfo BaseMapper::GetMapperInfo()
719+
RomInfo BaseMapper::GetRomInfo()
734720
{
735-
return {
736-
_romName,
737-
_romFormat,
738-
_gameSystem,
739-
_mapperID,
740-
_subMapperID,
741-
_hashInfo,
742-
HasChrRam()
743-
};
721+
return _romInfo;
744722
}
745723

746724
MirroringType BaseMapper::GetMirroringType()
@@ -859,7 +837,7 @@ void BaseMapper::WriteVRAM(uint16_t addr, uint8_t value)
859837

860838
bool BaseMapper::IsNes20()
861839
{
862-
return _nesHeader.GetRomHeaderVersion() == RomHeaderVersion::Nes2_0;
840+
return _romInfo.NesHeader.GetRomHeaderVersion() == RomHeaderVersion::Nes2_0;
863841
}
864842

865843
//Debugger Helper Functions
@@ -1131,11 +1109,6 @@ CartridgeState BaseMapper::GetState()
11311109
return state;
11321110
}
11331111

1134-
NESHeader BaseMapper::GetNesHeader()
1135-
{
1136-
return _nesHeader;
1137-
}
1138-
11391112
void BaseMapper::GetRomFileData(vector<uint8_t> &out, bool asIpsFile, uint8_t* header)
11401113
{
11411114
if(header) {
@@ -1147,7 +1120,7 @@ void BaseMapper::GetRomFileData(vector<uint8_t> &out, bool asIpsFile, uint8_t* h
11471120
out.insert(out.end(), originalFile.begin()+sizeof(NESHeader), originalFile.end());
11481121
} else {
11491122
vector<uint8_t> newFile;
1150-
newFile.insert(newFile.end(), (uint8_t*)&_nesHeader, ((uint8_t*)&_nesHeader) + sizeof(NESHeader));
1123+
newFile.insert(newFile.end(), (uint8_t*)&_romInfo.NesHeader, ((uint8_t*)&_romInfo.NesHeader) + sizeof(NESHeader));
11511124
newFile.insert(newFile.end(), _prgRom, _prgRom + _prgSize);
11521125
if(HasChrRom()) {
11531126
newFile.insert(newFile.end(), _chrRom, _chrRom + _chrRomSize);

Core/BaseMapper.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
3131
bool _onlyChrRam = false;
3232
bool _hasBusConflicts = false;
3333

34-
string _romFilename;
35-
string _romName;
36-
RomFormat _romFormat;
37-
3834
bool _allowRegisterRead = false;
3935
bool _isReadRegisterAddr[0x10000];
4036
bool _isWriteRegisterAddr[0x10000];
@@ -47,22 +43,15 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
4743
uint32_t _prgPageNumbers[64];
4844
uint32_t _chrPageNumbers[64];
4945

50-
HashInfo _hashInfo;
51-
5246
vector<uint8_t> _originalPrgRom;
5347
vector<uint8_t> _originalChrRom;
5448

5549
protected:
50+
RomInfo _romInfo;
51+
5652
shared_ptr<BaseControlDevice> _mapperControlDevice;
5753
shared_ptr<Console> _console;
5854

59-
NESHeader _nesHeader;
60-
GameInfo _databaseInfo;
61-
62-
uint16_t _mapperID;
63-
uint8_t _subMapperID;
64-
GameSystem _gameSystem;
65-
6655
uint8_t* _prgRom = nullptr;
6756
uint8_t* _chrRom = nullptr;
6857
uint8_t* _chrRam = nullptr;
@@ -74,7 +63,6 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
7463
uint32_t _saveRamSize = 0;
7564
uint32_t _workRamSize = 0;
7665
uint8_t* _workRam = nullptr;
77-
bool _hasBattery = false;
7866
bool _hasChrBattery = false;
7967
int16_t _vramOpenBusValue = -1;
8068

@@ -175,7 +163,7 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
175163
virtual void SetDefaultNametables(uint8_t* nametableA, uint8_t* nametableB);
176164

177165
shared_ptr<BaseControlDevice> GetMapperControlDevice();
178-
MapperInfo GetMapperInfo();
166+
RomInfo GetRomInfo();
179167

180168
__forceinline uint8_t ReadRAM(uint16_t addr) override;
181169
uint8_t DebugReadRAM(uint16_t addr);
@@ -229,7 +217,6 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
229217
bool IsWriteRegister(uint16_t addr);
230218
bool IsReadRegister(uint16_t addr);
231219

232-
NESHeader GetNesHeader();
233220
void GetRomFileData(vector<uint8_t> &out, bool asIpsFile, uint8_t* header);
234221

235222
vector<uint8_t> GetPrgChrCopy();

Core/BizhawkMovie.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ bool BizhawkMovie::InitializeGameData(ZipReader &reader)
106106
if(line.compare(0, 4, "SHA1", 4) == 0) {
107107
if(line.size() >= 45) {
108108
HashInfo hashInfo;
109-
hashInfo.Sha1Hash = line.substr(5, 40);
109+
hashInfo.Sha1 = line.substr(5, 40);
110110
if(_console->LoadMatchingRom("", hashInfo)) {
111111
return true;
112112
}
113113
}
114114
} else if(line.compare(0, 3, "MD5", 3) == 0) {
115115
if(line.size() >= 36) {
116116
HashInfo hashInfo;
117-
hashInfo.PrgChrMd5Hash = line.substr(4, 32);
118-
std::transform(hashInfo.PrgChrMd5Hash.begin(), hashInfo.PrgChrMd5Hash.end(), hashInfo.PrgChrMd5Hash.begin(), ::toupper);
117+
hashInfo.PrgChrMd5 = line.substr(4, 32);
118+
std::transform(hashInfo.PrgChrMd5.begin(), hashInfo.PrgChrMd5.end(), hashInfo.PrgChrMd5.begin(), ::toupper);
119119
if(_console->LoadMatchingRom("", hashInfo)) {
120120
return true;
121121
}

Core/CNROM.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class CNROM : public BaseMapper
2020
_vramOpenBusValue = 0xFF;
2121
}
2222

23-
bool HasBusConflicts() override { return (_mapperID == 3 && _subMapperID == 2) || _mapperID == 185; }
23+
bool HasBusConflicts() override { return (_romInfo.MapperID == 3 && _romInfo.SubMapperID == 2) || _romInfo.MapperID == 185; }
2424

2525
void WriteRegister(uint16_t addr, uint8_t value) override
2626
{
2727
if(_enableCopyProtection) {
2828
//"if C AND $0F is nonzero, and if C does not equal $13: CHR is enabled"
2929
//Seicross (mapper 185 version) is assigned to submapper 16 (not a real submapper) to make it work properly
30-
if((_subMapperID == 16 && !(value & 0x01)) || (_subMapperID == 0 && (value & 0x0F) != 0 && value != 0x13)) {
30+
if((_romInfo.SubMapperID == 16 && !(value & 0x01)) || (_romInfo.SubMapperID == 0 && (value & 0x0F) != 0 && value != 0x13)) {
3131
SelectCHRPage(0, 0);
3232
} else {
3333
RemovePpuMemoryMapping(0x0000, 0x1FFF);

Core/ColorDreams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ColorDreams : public BaseMapper
1717

1818
void WriteRegister(uint16_t addr, uint8_t value) override
1919
{
20-
if(_mapperID == 144) {
20+
if(_romInfo.MapperID == 144) {
2121
//"This addition means that only the ROM's least significant bit always wins bus conflicts."
2222
value |= (ReadRAM(addr) & 0x01);
2323
}

0 commit comments

Comments
 (0)