#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; }