blob: e093086d0f38a01eb1645b992aafcc9a435e3935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include "stdarg.h"
#include "stdio.h"
#include "string.h"
#include "types33.h"
#include "ui33.h"
#include "strings33.h"
#include "logger33.h"
#define _MBOX_SIZE 9
#define _PADDING 4
#define _SPACING 2
static char messageBox[ _MBOX_SIZE ][ _STRING_MAX ] = { 0, };
static Size head = 0;
static Size tail = 0;
Mouse33 __mouse = {0,};
void ui33_add_message( String fmt, ... )
{
va_list args;
va_start(args, fmt);
vsnprintf( messageBox[tail++], _STRING_MAX, fmt, args );
if( tail == _MBOX_SIZE ) tail = 0;
if( tail == head ) ++head;
if( head == _MBOX_SIZE ) head = 0;
va_end(args);
}
void ui33_draw_messages( void )
{
Size fontHeight = defFont.h;
Size stringCoord = __display.surface.h - _PADDING - fontHeight;
Size i = tail-1;
do {
if( i < 0 ) i = _MBOX_SIZE-1;
QPRINT( messageBox[i], _PADDING, stringCoord );
stringCoord -= (_SPACING + fontHeight);
} while( (i--) != head );
}
void ui33_draw_mouse( void )
{
Size x = __mouse.x;
Size y = __mouse.y;
Size w = __display.surface.w;
__display.surface.data[ x + y * w ] = YELLOW;
}
|