parent
bd1f72aac6
commit
d730844f65
|
@ -14,6 +14,10 @@ include_directories(include)
|
|||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/disp/display.c
|
||||
src/disp/print.c
|
||||
src/disp/init.c
|
||||
src/disp/clear.c
|
||||
)
|
||||
|
||||
set(ASSETS
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#define DISP_BUFFER_SIZE 1024
|
||||
extern char disp_buffer[DISP_BUFFER_SIZE];
|
||||
|
||||
void disp_init(void);
|
||||
void disp_clear(void);
|
||||
int disp_print(char *text);
|
||||
void disp_display(void);
|
|
@ -0,0 +1,7 @@
|
|||
#include "disp.h"
|
||||
|
||||
void
|
||||
disp_clear(void)
|
||||
{
|
||||
disp_buffer[0] = '\0';
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#include "disp.h"
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
static void draw_line(int x, int y, char *buffer, int len);
|
||||
|
||||
void
|
||||
disp_display(void)
|
||||
{
|
||||
static int line_height = 0;
|
||||
const int x = 2;
|
||||
int y = 2;
|
||||
char *buffer_cursor = disp_buffer;
|
||||
int line_length = 0;
|
||||
|
||||
if (!line_height)
|
||||
line_height = dfont_default()->line_height;
|
||||
|
||||
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;
|
||||
} 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);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include "disp.h"
|
||||
|
||||
char disp_buffer[DISP_BUFFER_SIZE];
|
||||
|
||||
void
|
||||
disp_init(void)
|
||||
{
|
||||
disp_clear();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#include "disp.h"
|
||||
|
||||
int
|
||||
disp_print(char *text)
|
||||
{
|
||||
char *buffer_cursor = disp_buffer;
|
||||
char *text_cursor = text;
|
||||
|
||||
while (*buffer_cursor != '\0')
|
||||
buffer_cursor += 1;
|
||||
|
||||
while (*text_cursor != '\0') {
|
||||
*buffer_cursor = *text_cursor;
|
||||
buffer_cursor += 1;
|
||||
text_cursor += 1;
|
||||
}
|
||||
buffer_cursor[1] = '\0';
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
#include "disp.h"
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
|
@ -6,8 +7,12 @@ main(void)
|
|||
{
|
||||
/* init */
|
||||
disp_init();
|
||||
disp_print("Hello, World!\n");
|
||||
disp_print("Draw me an unicorn!\n");
|
||||
disp_print("<Hackcell> UwU\n");
|
||||
|
||||
dclear(C_WHITE);
|
||||
disp_display();
|
||||
dupdate();
|
||||
|
||||
getkey();
|
||||
|
|
Loading…
Reference in New Issue