Finishing the parsing of the ROM's Header

This commit is contained in:
AnonymusRaccoon
2020-02-04 10:43:52 +01:00
parent 6d7bf39dcd
commit 8261c273b2
2 changed files with 16 additions and 13 deletions
+4 -3
View File
@@ -109,7 +109,7 @@ namespace ComSquare::Cartridge
uint32_t Cartridge::_getHeaderAddress()
{
uint32_t address[] = {0x7FC0, 0xFFC0, 0x81C0, 0x101C0};
std::vector<uint32_t> address = {0x7FC0, 0xFFC0, 0x81C0, 0x101C0};
int bestScore = -1;
uint32_t bestAddress = 0;
@@ -129,7 +129,8 @@ namespace ComSquare::Cartridge
if (info.checksum + info.checksumComplement == 0xFFFF && info.checksum != 0 && info.checksumComplement != 0)
score += 8;
if (info.emulationInterrupts.reset <= 0x8000u) // The reset vector is the first thing called by the SNES so It must execute the code inside the ROM (the rom starts at 0x8000).
//Fail here
if (info.emulationInterrupts.reset < 0x8000u) // The reset vector is the first thing called by the SNES so It must execute the code inside the ROM (the rom starts at 0x8000).
continue;
uint8_t resetOpCode = this->_data[info.emulationInterrupts.reset - 0x8000u];
switch (resetOpCode) {
@@ -172,7 +173,7 @@ namespace ComSquare::Cartridge
this->header = this->_mapHeader(headerAddress);
char name[22];
std::memcpy(name, &this->_data[headerAddress], 21);
std::memcpy(name, &this->_data[headerAddress + 0xC0u], 21);
name[21] = '\0';
this->header.gameName = std::string(name);
return headerAddress & 0x200u;
+12 -10
View File
@@ -27,34 +27,36 @@ namespace ComSquare::Cartridge
//! @brief The name of the game
std::string gameName;
//! @brief The memory mapping of the ROM.
MappingMode mappingMode;
MappingMode mappingMode{};
//! @brief The rom type (special information about the rom, still don't know what).
uint8_t romType;
uint8_t romType = 0;
//! @brief The size (in bytes) of the ram
unsigned romSize;
unsigned romSize = 0;
//! @brief The size of the SRom inside the cartridge.
unsigned sramSize;
unsigned sramSize = 0;
//! @brief Creator license ID code.
union {
uint8_t creatorIDs[2];
uint16_t creatorID;
uint16_t creatorID = 0;
};
//! @brief The version of the game
uint8_t version;
uint8_t version = 0;
//! @brief Checksum complement
union {
uint8_t checksumComplements[2];
uint16_t checksumComplement;
uint16_t checksumComplement = 0;
};
//! @brief Checksum
union {
uint8_t checksums[2];
uint16_t checksum;
uint16_t checksum = 0;
};
//! @brief The interrupt vectors used to halt the CPU in native mode
InterruptVectors nativeInterrupts;
InterruptVectors nativeInterrupts{};
//! @brief The interrupt vectors used to halt the CPU in emulation mode
InterruptVectors emulationInterrupts;
InterruptVectors emulationInterrupts{};
Header() = default;
};
//! @brief Contains the rom's memory/instructions.