2019-02-15 21:33:13 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "IMemoryHandler.h"
|
2019-03-12 09:15:57 -04:00
|
|
|
#include "CartTypes.h"
|
|
|
|
#include "../Utilities/ISerializable.h"
|
2019-02-15 21:33:13 -05:00
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
class BaseCoprocessor;
|
2019-02-17 14:42:35 -05:00
|
|
|
class MemoryManager;
|
|
|
|
class VirtualFile;
|
2019-07-06 14:25:51 -04:00
|
|
|
class EmuSettings;
|
2019-07-14 21:45:12 -04:00
|
|
|
class NecDsp;
|
|
|
|
class Console;
|
2019-02-17 14:42:35 -05:00
|
|
|
|
2019-03-12 09:15:57 -04:00
|
|
|
class BaseCartridge : public ISerializable
|
2019-02-15 21:33:13 -05:00
|
|
|
{
|
|
|
|
private:
|
2019-07-14 21:45:12 -04:00
|
|
|
Console *_console;
|
2019-07-06 14:25:51 -04:00
|
|
|
|
2019-02-17 14:42:35 -05:00
|
|
|
vector<unique_ptr<IMemoryHandler>> _prgRomHandlers;
|
|
|
|
vector<unique_ptr<IMemoryHandler>> _saveRamHandlers;
|
2019-07-13 13:43:56 -04:00
|
|
|
SnesCartInformation _cartInfo = {};
|
2019-02-17 14:42:35 -05:00
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
unique_ptr<BaseCoprocessor> _coprocessor;
|
|
|
|
NecDsp *_necDsp = nullptr;
|
|
|
|
|
2019-07-13 13:43:56 -04:00
|
|
|
CartFlags::CartFlags _flags = CartFlags::CartFlags::None;
|
2019-07-14 21:45:12 -04:00
|
|
|
CoprocessorType _coprocessorType = CoprocessorType::None;
|
2019-02-24 20:04:59 -05:00
|
|
|
string _romPath;
|
2019-03-31 15:51:13 -04:00
|
|
|
string _patchPath;
|
2019-02-24 20:04:59 -05:00
|
|
|
|
2019-02-15 21:33:13 -05:00
|
|
|
uint8_t* _prgRom = nullptr;
|
|
|
|
uint8_t* _saveRam = nullptr;
|
|
|
|
|
|
|
|
uint32_t _prgRomSize = 0;
|
|
|
|
uint32_t _saveRamSize = 0;
|
|
|
|
|
2019-04-03 19:22:34 -04:00
|
|
|
void MapBanks(MemoryManager &mm, vector<unique_ptr<IMemoryHandler>> &handlers, uint8_t startBank, uint8_t endBank, uint16_t startPage = 0, uint16_t endPage = 0x0F, uint16_t pageIncrement = 0, bool mirror = false, uint16_t startPageNumber = 0);
|
2019-02-24 20:04:59 -05:00
|
|
|
|
|
|
|
void LoadBattery();
|
2019-02-17 14:42:35 -05:00
|
|
|
|
2019-03-08 20:18:13 -05:00
|
|
|
int32_t GetHeaderScore(uint32_t addr);
|
2019-03-02 21:17:45 -05:00
|
|
|
void DisplayCartInfo();
|
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
CoprocessorType GetCoprocessorType();
|
|
|
|
CoprocessorType GetDspVersion();
|
|
|
|
|
2019-04-10 18:45:49 -04:00
|
|
|
bool MapSpecificCarts(MemoryManager &mm);
|
2019-07-14 21:45:12 -04:00
|
|
|
void InitCoprocessor(MemoryManager &mm);
|
|
|
|
|
2019-04-10 18:45:49 -04:00
|
|
|
string GetCartName();
|
2019-07-05 21:27:45 -04:00
|
|
|
string GetGameCode();
|
2019-04-10 18:45:49 -04:00
|
|
|
|
2019-02-15 21:33:13 -05:00
|
|
|
public:
|
2019-03-31 14:50:12 -04:00
|
|
|
virtual ~BaseCartridge();
|
2019-02-16 01:16:57 -05:00
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
static shared_ptr<BaseCartridge> CreateCartridge(Console* console, VirtualFile &romFile, VirtualFile &patchFile);
|
2019-02-15 21:33:13 -05:00
|
|
|
|
2019-02-17 14:42:35 -05:00
|
|
|
void Init();
|
2019-07-14 21:45:12 -04:00
|
|
|
void Reset();
|
2019-02-17 14:42:35 -05:00
|
|
|
|
2019-03-16 12:20:18 -04:00
|
|
|
void SaveBattery();
|
|
|
|
|
2019-02-26 22:27:09 -05:00
|
|
|
RomInfo GetRomInfo();
|
2019-03-12 09:15:57 -04:00
|
|
|
string GetSha1Hash();
|
2019-07-14 21:45:12 -04:00
|
|
|
CartFlags::CartFlags GetCartFlags();
|
2019-02-26 22:27:09 -05:00
|
|
|
|
2019-02-17 14:42:35 -05:00
|
|
|
void RegisterHandlers(MemoryManager &mm);
|
2019-02-15 21:33:13 -05:00
|
|
|
|
|
|
|
uint8_t* DebugGetPrgRom() { return _prgRom; }
|
|
|
|
uint8_t* DebugGetSaveRam() { return _saveRam; }
|
|
|
|
uint32_t DebugGetPrgRomSize() { return _prgRomSize; }
|
|
|
|
uint32_t DebugGetSaveRamSize() { return _saveRamSize; }
|
2019-03-12 09:15:57 -04:00
|
|
|
|
2019-07-14 21:45:12 -04:00
|
|
|
NecDsp* GetDsp();
|
|
|
|
BaseCoprocessor* GetCoprocessor();
|
|
|
|
|
2019-03-12 09:15:57 -04:00
|
|
|
void Serialize(Serializer &s) override;
|
2019-02-15 21:33:13 -05:00
|
|
|
};
|