mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-09 20:59:06 +00:00
Finishing the parsing of the ROM's Header
This commit is contained in:
@@ -109,7 +109,7 @@ namespace ComSquare::Cartridge
|
|||||||
|
|
||||||
uint32_t Cartridge::_getHeaderAddress()
|
uint32_t Cartridge::_getHeaderAddress()
|
||||||
{
|
{
|
||||||
uint32_t address[] = {0x7FC0, 0xFFC0, 0x81C0, 0x101C0};
|
std::vector<uint32_t> address = {0x7FC0, 0xFFC0, 0x81C0, 0x101C0};
|
||||||
int bestScore = -1;
|
int bestScore = -1;
|
||||||
uint32_t bestAddress = 0;
|
uint32_t bestAddress = 0;
|
||||||
|
|
||||||
@@ -129,7 +129,8 @@ namespace ComSquare::Cartridge
|
|||||||
if (info.checksum + info.checksumComplement == 0xFFFF && info.checksum != 0 && info.checksumComplement != 0)
|
if (info.checksum + info.checksumComplement == 0xFFFF && info.checksum != 0 && info.checksumComplement != 0)
|
||||||
score += 8;
|
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;
|
continue;
|
||||||
uint8_t resetOpCode = this->_data[info.emulationInterrupts.reset - 0x8000u];
|
uint8_t resetOpCode = this->_data[info.emulationInterrupts.reset - 0x8000u];
|
||||||
switch (resetOpCode) {
|
switch (resetOpCode) {
|
||||||
@@ -172,7 +173,7 @@ namespace ComSquare::Cartridge
|
|||||||
|
|
||||||
this->header = this->_mapHeader(headerAddress);
|
this->header = this->_mapHeader(headerAddress);
|
||||||
char name[22];
|
char name[22];
|
||||||
std::memcpy(name, &this->_data[headerAddress], 21);
|
std::memcpy(name, &this->_data[headerAddress + 0xC0u], 21);
|
||||||
name[21] = '\0';
|
name[21] = '\0';
|
||||||
this->header.gameName = std::string(name);
|
this->header.gameName = std::string(name);
|
||||||
return headerAddress & 0x200u;
|
return headerAddress & 0x200u;
|
||||||
|
|||||||
@@ -27,34 +27,36 @@ namespace ComSquare::Cartridge
|
|||||||
//! @brief The name of the game
|
//! @brief The name of the game
|
||||||
std::string gameName;
|
std::string gameName;
|
||||||
//! @brief The memory mapping of the ROM.
|
//! @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).
|
//! @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
|
//! @brief The size (in bytes) of the ram
|
||||||
unsigned romSize;
|
unsigned romSize = 0;
|
||||||
//! @brief The size of the SRom inside the cartridge.
|
//! @brief The size of the SRom inside the cartridge.
|
||||||
unsigned sramSize;
|
unsigned sramSize = 0;
|
||||||
//! @brief Creator license ID code.
|
//! @brief Creator license ID code.
|
||||||
union {
|
union {
|
||||||
uint8_t creatorIDs[2];
|
uint8_t creatorIDs[2];
|
||||||
uint16_t creatorID;
|
uint16_t creatorID = 0;
|
||||||
};
|
};
|
||||||
//! @brief The version of the game
|
//! @brief The version of the game
|
||||||
uint8_t version;
|
uint8_t version = 0;
|
||||||
//! @brief Checksum complement
|
//! @brief Checksum complement
|
||||||
union {
|
union {
|
||||||
uint8_t checksumComplements[2];
|
uint8_t checksumComplements[2];
|
||||||
uint16_t checksumComplement;
|
uint16_t checksumComplement = 0;
|
||||||
};
|
};
|
||||||
//! @brief Checksum
|
//! @brief Checksum
|
||||||
union {
|
union {
|
||||||
uint8_t checksums[2];
|
uint8_t checksums[2];
|
||||||
uint16_t checksum;
|
uint16_t checksum = 0;
|
||||||
};
|
};
|
||||||
//! @brief The interrupt vectors used to halt the CPU in native mode
|
//! @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
|
//! @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.
|
//! @brief Contains the rom's memory/instructions.
|
||||||
|
|||||||
Reference in New Issue
Block a user