mirror of
https://github.com/jscrane/r65emu.git
synced 2024-12-21 12:29:51 +00:00
51 lines
923 B
C++
51 lines
923 B
C++
|
#include <UTFT.h>
|
||
|
|
||
|
#include "memory.h"
|
||
|
#include "utftdisplay.h"
|
||
|
|
||
|
extern UTFT utft;
|
||
|
|
||
|
void UTFTDisplay::begin(unsigned bg, unsigned fg) {
|
||
|
_bg = bg;
|
||
|
_fg = fg;
|
||
|
_dx = utft.getDisplayXSize();
|
||
|
_dy = utft.getDisplayYSize();
|
||
|
_cx = utft.getFontXsize();
|
||
|
_cy = utft.getFontYsize();
|
||
|
_oxs = _dx;
|
||
|
}
|
||
|
|
||
|
void UTFTDisplay::clear() {
|
||
|
utft.fillScr(_bg);
|
||
|
}
|
||
|
|
||
|
void UTFTDisplay::error(char *s)
|
||
|
{
|
||
|
utft.setColor(_fg);
|
||
|
char *lines[5];
|
||
|
int l = 0;
|
||
|
for (char *p = s, *q = s; *p; p++)
|
||
|
if (*p == '\n') {
|
||
|
*p++ = 0;
|
||
|
lines[l++] = q;
|
||
|
q = p;
|
||
|
}
|
||
|
unsigned y = (_dy - l*_cy)/2;
|
||
|
for (int i = 0; i < l; i++) {
|
||
|
char *p = lines[i];
|
||
|
unsigned x = (_dx - strlen(p)*_cx)/2;
|
||
|
utft.print(p, x, y);
|
||
|
y += _cy;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void UTFTDisplay::status(const char *s)
|
||
|
{
|
||
|
utft.setColor(_fg);
|
||
|
unsigned y = _dy - _cy, n = strlen(s), xs = _dx - n*_cx;
|
||
|
for (unsigned x = _oxs; x < xs; x += _cx)
|
||
|
utft.print(" ", x, y);
|
||
|
utft.print(s, xs, y);
|
||
|
_oxs = xs;
|
||
|
}
|