Change debug::string to use MTL string instead of C strings

This commit is contained in:
Myles Busig 2024-03-04 21:17:16 -07:00
parent 93f5d32fb6
commit 6a538fb5e5

View File

@ -6,6 +6,8 @@
#include <tonc.h>
#include <mtl/string.hpp>
namespace debug {
/**
* \brief MGBA debug registers and constants
@ -26,15 +28,14 @@ static volatile uint16_t* flags = reinterpret_cast<uint16_t*>(0x4FFF700);
/**
* \brief MGBA debug string register.
*
* Max length of 0x100 (256)
* Max length of 0x100 (256) including null terminator.
*/
static char* string = reinterpret_cast<char*>(0x4FFF600);
constexpr size_t string_len = 0x100;
static mtl::string_ext string(reinterpret_cast<char*>(0x4FFF600), 256);
}; // namespace reg
void puts(const char* msg, level lvl) {
std::strncpy(reg::string, msg, reg::string_len);
reg::string = msg;
*reg::flags = (lvl) | 0x100;
}