0
I am trying to develop a Gameboy emulator as a challenge to myself, I am in the process of decoding the opcodes, for this I need to get the hexadecimal value of it extracted from the game ROM, but instead of returning an Hex value it returns strange characters, like in the photo:
void CPU::Exec()
{
std::uint8_t opcode = mmu->ReadMemory(PC);
switch (opcode) {
case 0x0:
cycles += 4;
PC++;
break;
}
std::cout << "Current opcode: 0x" << std::hex << std::uppercase << opcode << std::endl;
}
The function ReadMemmory
basically reading from the ROM which is basically a uint8_t vector that stores the contents of the ROM
bool Cartridge::Load()
{
std::fstream file(gamePath, std::ios::in | std::ios::binary);
if (!file.is_open()) {
std::cerr << "Error: Could not read file" << std::endl;
return false;
}
this->romData = std::vector<std::uint8_t>(std::istreambuf_iterator<char>(file), {});
file.close();
return true;
}
I thought Hex would return hexadecimal value of any type
– Samuel Ives
std::dec
,std::hex
,std::oct
https://en.cppreference.com/w/cpp/io/manip/hex "Modifies the default Numeric base for integer I/O." Only of numerical and integer types.– darcamo