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

This commit is contained in:
Madeline Busig 2024-03-04 21:17:16 -07:00
parent e0f06fd2c2
commit b088b7499d

View File

@ -6,6 +6,8 @@
#include <tonc.h> #include <tonc.h>
#include <mtl/string.hpp>
namespace debug { namespace debug {
/** /**
* \brief MGBA debug registers and constants * \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. * \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); static mtl::string_ext string(reinterpret_cast<char*>(0x4FFF600), 256);
constexpr size_t string_len = 0x100;
}; // namespace reg }; // namespace reg
void puts(const char* msg, level lvl) { void puts(const char* msg, level lvl) {
std::strncpy(reg::string, msg, reg::string_len); reg::string = msg;
*reg::flags = (lvl) | 0x100; *reg::flags = (lvl) | 0x100;
} }