2012-12-19 09:30:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/N64System/N64Types.h>
|
|
|
|
#include <Project64-core/Settings/DebugSettings.h>
|
2016-07-09 11:03:10 +00:00
|
|
|
#include <Project64-core/Multilanguage.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-02-14 03:10:05 +00:00
|
|
|
class CN64Rom :
|
2015-11-15 09:56:34 +00:00
|
|
|
protected CDebugSettings
|
2015-04-28 22:19:02 +00:00
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
public:
|
2015-11-15 09:56:34 +00:00
|
|
|
CN64Rom();
|
|
|
|
~CN64Rom();
|
2015-04-28 22:19:02 +00:00
|
|
|
|
2020-10-12 01:40:21 +00:00
|
|
|
bool LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly = false);
|
|
|
|
bool LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly = false);
|
2015-11-15 20:05:55 +00:00
|
|
|
static bool IsValidRomImage(uint8_t Test[4]);
|
2020-10-12 01:40:21 +00:00
|
|
|
bool IsLoadedRomDDIPL();
|
|
|
|
void SaveRomSettingID(bool temp);
|
|
|
|
void ClearRomSettingID();
|
2015-11-15 09:56:34 +00:00
|
|
|
CICChip CicChipID();
|
2022-04-18 11:27:59 +00:00
|
|
|
uint8_t * GetRomAddress() const { return m_ROMImage; }
|
2020-10-12 01:40:21 +00:00
|
|
|
uint32_t GetRomSize() const { return m_RomFileSize; }
|
|
|
|
const std::string & GetRomMD5() const { return m_MD5; }
|
|
|
|
const std::string & GetRomName() const { return m_RomName; }
|
|
|
|
const std::string & GetFileName() const { return m_FileName; }
|
2015-11-15 09:56:34 +00:00
|
|
|
Country GetCountry() const { return m_Country; }
|
2020-10-12 04:31:28 +00:00
|
|
|
bool IsPal();
|
2020-10-12 01:40:21 +00:00
|
|
|
void UnallocateRomImage();
|
2015-04-28 22:19:02 +00:00
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Get a message ID for the reason that you failed to load the ROM
|
2015-11-15 09:56:34 +00:00
|
|
|
LanguageStringID GetError() const { return m_ErrorMsg; }
|
2021-04-12 11:35:39 +00:00
|
|
|
static CICChip GetCicChipID(uint8_t * RomData, uint64_t * CRC = nullptr);
|
2016-04-15 23:17:37 +00:00
|
|
|
static void CleanRomName(char * RomName, bool byteswap = true);
|
2016-01-14 21:06:33 +00:00
|
|
|
|
|
|
|
private:
|
2020-10-12 01:40:21 +00:00
|
|
|
bool AllocateRomImage(uint32_t RomFileSize);
|
|
|
|
bool AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnly);
|
|
|
|
bool AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnly);
|
|
|
|
void ByteSwapRom();
|
|
|
|
void SetError(LanguageStringID ErrorMsg);
|
|
|
|
void CalculateCicChip();
|
|
|
|
void CalculateRomCrc();
|
|
|
|
|
2016-01-14 21:06:33 +00:00
|
|
|
static void NotificationCB(const char * Status, CN64Rom * _this);
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Constant values
|
2016-01-14 21:06:33 +00:00
|
|
|
enum { ReadFromRomSection = 0x400000 };
|
|
|
|
|
2021-05-18 11:51:36 +00:00
|
|
|
// Class variables
|
2016-01-14 21:06:33 +00:00
|
|
|
CFile m_RomFile;
|
|
|
|
uint8_t * m_ROMImage;
|
|
|
|
uint8_t * m_ROMImageBase;
|
|
|
|
uint32_t m_RomFileSize;
|
|
|
|
Country m_Country;
|
|
|
|
CICChip m_CicChip;
|
|
|
|
LanguageStringID m_ErrorMsg;
|
2020-03-18 03:11:40 +00:00
|
|
|
std::string m_RomName, m_FileName, m_MD5, m_RomIdent;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|