kimeera/src/disp/display.c

50 lines
928 B
C

#include "disp.h"
#include <gint/display.h>
#ifdef FX9860G
extern font_t font_kenney_mini;
#endif
static int line_height = 0;
static void draw_line(int x, int y, char *buffer, int len);
void
disp_display(void)
{
const int x = 2;
#ifdef FX9860G
int y = -2;
#else
int y = 2;
#endif
char *buffer_cursor = disp_buffer;
int line_length = 0;
if (!line_height) {
#ifdef FX9860G
dfont(&font_kenney_mini);
line_height = 6;
#else
line_height = dfont_default()->line_height;
#endif
}
while (buffer_cursor[line_length] != '\0') {
if (buffer_cursor[line_length] == '\n') {
draw_line(x, y, buffer_cursor, line_length);
buffer_cursor += line_length + 1;
line_length = 0;
y += line_height + 1;
} else
line_length += 1;
}
draw_line(x, y, buffer_cursor, line_length);
}
static void
draw_line(int x, int y, char *buffer, int len)
{
dtext_opt(x, y, C_BLACK, C_NONE, DTEXT_LEFT, DTEXT_TOP, buffer, len);
}