2016-05-22 18:13:06 +00:00
|
|
|
#include <mtgos.hpp>
|
|
|
|
extern "C" {
|
|
|
|
void * screenout_init(int err);
|
2016-05-29 06:30:53 +00:00
|
|
|
void * screenout_out(void* handle, const char *str);
|
2016-05-22 18:13:06 +00:00
|
|
|
void * screenout_clear(void* handle);
|
|
|
|
void * screenout_setcolor(void* handle, uint32_t BG, uint32_t FG);
|
|
|
|
void * screenout_destroy(void * handle);
|
|
|
|
}
|
|
|
|
ScreenOut::ScreenOut(bool err) {
|
2016-07-24 10:21:12 +00:00
|
|
|
handle=screenout_init(err);
|
2016-05-22 18:13:06 +00:00
|
|
|
}
|
2016-05-29 06:30:53 +00:00
|
|
|
auto ScreenOut::operator<<(const char * str) -> ScreenOut & {
|
2016-07-24 10:21:12 +00:00
|
|
|
screenout_out(handle, str);
|
|
|
|
return *this;
|
2016-05-22 18:13:06 +00:00
|
|
|
}
|
2016-05-29 06:30:53 +00:00
|
|
|
auto ScreenOut::operator<<(int output) -> ScreenOut & {
|
2016-07-24 10:21:12 +00:00
|
|
|
int base=10;
|
|
|
|
const char* chars="0123456789ABCDEF";
|
|
|
|
char buf[33];
|
|
|
|
buf[32]='\0';
|
|
|
|
char* ptr=buf+31;
|
|
|
|
do {
|
|
|
|
*(ptr--)=chars[output%base];
|
|
|
|
output/=base;
|
|
|
|
} while(output && (ptr!=buf));
|
|
|
|
*this << ptr+1;
|
|
|
|
return *this;
|
2016-05-29 06:30:53 +00:00
|
|
|
}
|
2016-05-22 18:13:06 +00:00
|
|
|
auto ScreenOut::clrscr() -> ScreenOut & {
|
2016-07-24 10:21:12 +00:00
|
|
|
screenout_clear(handle);
|
|
|
|
return *this;
|
2016-05-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
auto ScreenOut::setColor(BGColor bg, FGColor fg) -> ScreenOut & {
|
2016-07-24 10:21:12 +00:00
|
|
|
screenout_setcolor(handle, static_cast<uint32_t>(bg), static_cast<uint32_t>(fg));
|
|
|
|
return *this;
|
2016-05-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
ScreenOut::~ScreenOut() {
|
2016-07-24 10:21:12 +00:00
|
|
|
handle=screenout_destroy(handle);
|
2016-05-22 18:13:06 +00:00
|
|
|
}
|
|
|
|
void main();
|
|
|
|
extern "C" void _start() {
|
2016-07-24 10:21:12 +00:00
|
|
|
main();
|
|
|
|
for(;;);
|
2016-05-22 18:13:06 +00:00
|
|
|
}
|