Change debug registers to use references instead of pointers

This commit is contained in:
Myles Busig 2024-03-04 21:18:45 -07:00
parent 6a538fb5e5
commit 85aa1894e4

View File

@ -20,11 +20,11 @@ namespace reg {
* When 0 is written to the register, debug output is disabled.
* Will be set to 0x1DEA when successfully enabled.
*/
static volatile uint16_t* enable = reinterpret_cast<uint16_t*>(0x4FFF780);
static volatile uint16_t& enable = *reinterpret_cast<uint16_t*>(0x4FFF780);
/**
* \brief MGBA debug flags register.
*/
static volatile uint16_t* flags = reinterpret_cast<uint16_t*>(0x4FFF700);
static volatile uint16_t& flags = *reinterpret_cast<uint16_t*>(0x4FFF700);
/**
* \brief MGBA debug string register.
*
@ -36,15 +36,15 @@ static mtl::string_ext string(reinterpret_cast<char*>(0x4FFF600), 256);
void puts(const char* msg, level lvl) {
reg::string = msg;
*reg::flags = (lvl) | 0x100;
reg::flags = (lvl) | 0x100;
}
bool open() {
*reg::enable = 0xC0DE;
return *reg::enable ==0x1DEA;
reg::enable = 0xC0DE;
return reg::enable == 0x1DEA;
}
void close() {
*reg::enable = 0;
reg::enable = 0;
}
}; // namespace debug