This repository was archived by the owner on Aug 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
mGBA printf
Felix Jones edited this page May 22, 2021
·
1 revision
mGBA contains logging utilities available from within a GBA ROM.
The official mGBA C implementation is available in the mGBA GitHub.
gba-plusplus provides a light wrapper around this.
#include <gba/ext/mgba.hpp>
namespace gba::mgba {
enum class log_level {
fatal,
error,
warn,
info,
debug
};
}
bool gba::mgba::open() noexcept;
void gba::mgba::close() noexcept;
template <typename... Args>
void gba::mgba::printf( const gba::mgba::log_level lvl, const char * fmt, Args... args ) noexcept;Hello world.
#include <gba/gba.hpp>
#include <gba/ext/mgba.hpp>
using namespace gba;
int main() {
if ( mgba::open() ) {
mgba::printf( mgba::log_level::info, "Hello, world!" );
mgba::close();
}
}Print reg::vcount.
#include <gba/gba.hpp>
#include <gba/ext/mgba.hpp>
using namespace gba;
int main() {
mgba::open(); // Assume success
while ( true ) {
mgba::printf( mgba::log_level::info, "Line = %d", reg::vcount::read() );
}
}If the macro __posprintf is defined, mgba::printf will switch from std::vsnprintf to using posprintf if it is available to your project. Website for posprintf.
Under namespace gba::mgba:
::log_level::fatal::log_level::error::log_level::warn::log_level::info::log_level::debug