diff --git a/sources/Cartridge/Cartridge.cpp b/sources/Cartridge/Cartridge.cpp index c736972..fcc39eb 100644 --- a/sources/Cartridge/Cartridge.cpp +++ b/sources/Cartridge/Cartridge.cpp @@ -109,7 +109,7 @@ namespace ComSquare::Cartridge uint32_t Cartridge::_getHeaderAddress() { - uint32_t address[] = {0x7FC0, 0xFFC0, 0x81C0, 0x101C0}; + std::vector 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; diff --git a/sources/Cartridge/Cartridge.hpp b/sources/Cartridge/Cartridge.hpp index 192f0a8..c9717ae 100644 --- a/sources/Cartridge/Cartridge.hpp +++ b/sources/Cartridge/Cartridge.hpp @@ -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.