aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/clock.h12
-rw-r--r--include/clock33.h12
-rw-r--r--include/display.h48
-rw-r--r--include/display33.h51
-rw-r--r--include/input33.h63
-rw-r--r--include/logger.h35
-rw-r--r--include/logger33.h26
-rw-r--r--include/options.h12
-rw-r--r--include/options33.h12
-rw-r--r--include/strings33.h57
-rw-r--r--include/system.h26
-rw-r--r--include/system33.h28
-rw-r--r--include/types33.h (renamed from include/types.h)25
-rw-r--r--include/ui33.h30
14 files changed, 262 insertions, 175 deletions
diff --git a/include/clock.h b/include/clock.h
deleted file mode 100644
index 589fd61..0000000
--- a/include/clock.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __TIME_H__
-#define __TIME_H__
-
-
-#include "types.h"
-
-
-Size clock_get_us( void );
-f64 clock_get_s_hires( void );
-
-
-#endif /* __TIME_H__ */
diff --git a/include/clock33.h b/include/clock33.h
new file mode 100644
index 0000000..3b0c405
--- /dev/null
+++ b/include/clock33.h
@@ -0,0 +1,12 @@
+#ifndef __TIME33_H__
+#define __TIME33_H__
+
+
+#include "types33.h"
+
+
+Size clock33_get_us( void );
+f64 clock33_get_s_hires( void );
+
+
+#endif /* __TIME33_H__ */
diff --git a/include/display.h b/include/display.h
deleted file mode 100644
index 63fc7b2..0000000
--- a/include/display.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __DISPLAY_H__
-#define __DISPLAY_H__
-
-#include "libdrm/drm_mode.h"
-
-#include "types.h"
-/* TEMP */
-typedef struct {
- u32 *data;
- Size w, h;
-} Surface;
-/**/
-
-
-typedef struct {
- Size id[2];
- u32 *map[2];
- Size stride;
- Size size;
-} Framebuffer;
-
-
-typedef struct {
- Framebuffer fb;
- Surface surface;
-
- struct drm_mode_crtc crtc;
- struct drm_mode_modeinfo mode;
- struct drm_mode_get_connector connector;
-
- Size devfd, ttyfd;
-
- Size active;
-} Display;
-
-
-extern Display __display;
-
-
-Size display_init( void );
-
-void display_flip( void );
-void display_vtswitcher_poll( int timeout );
-
-void display_term( void );
-
-
-#endif /* __DISPLAY_H__ */
diff --git a/include/display33.h b/include/display33.h
new file mode 100644
index 0000000..85e0172
--- /dev/null
+++ b/include/display33.h
@@ -0,0 +1,51 @@
+#ifndef __DISPLAY33_H__
+#define __DISPLAY33_H__
+
+
+#include "libdrm/drm_mode.h"
+
+#include "types33.h"
+
+
+/* TEMP XXX */
+typedef struct {
+ u32 *data;
+ Size w, h;
+} Surface33;
+/**/
+
+
+typedef struct {
+ Size id[2];
+ u8 *map[2];
+ Size stride;
+ Size size;
+} Framebuffer33;
+
+
+typedef struct {
+ Framebuffer33 fb;
+ Surface33 surface;
+
+ struct drm_mode_crtc crtc;
+ struct drm_mode_modeinfo mode;
+ struct drm_mode_get_connector connector;
+
+ Size devFd, ttyFd;
+
+ Boolean active;
+} Display33;
+
+
+extern Display33 __display;
+
+
+Error display33_init( void );
+
+void display33_flip( void );
+void display33_vtswitcher_poll( int timeout );
+
+void display33_term( void );
+
+
+#endif /* __DISPLAY33_H__ */
diff --git a/include/input33.h b/include/input33.h
new file mode 100644
index 0000000..e0d7df0
--- /dev/null
+++ b/include/input33.h
@@ -0,0 +1,63 @@
+#ifndef __INPUT_H__
+#define __INPUT_H__
+
+
+#include "linux/input.h"
+
+#include "types33.h"
+
+
+//#define MAX_INPUT_EVENTS 32
+//#define INPUT_BUFFLEN 32
+
+#define _KBBUFF_LEN 32 /* must be ^2 */
+#define _MAX_DEVS 8
+
+//#define KEYBOARD 0x01
+//#define MOUSE 0x02
+
+#define _RELEASE 0x00
+#define _PRESS 0x01
+#define _REPEAT 0x02
+
+#define _SCROLLL 0x01
+#define _NUML 0x02
+#define _CAPSL 0x04
+/* TODO move these */
+#define _CAN_CAPSL 0x0B
+
+
+#define KEYDOWN(K) (__input.keyStates[K] >= _PRESS)
+#define KEYUP(K) (__input.keyStates[K] == _RELEASE)
+#define KEYREP(K) (__input.keyStates[K] == _REPEAT)
+#define MOUSE1 (__input.keyStates[BTN_LEFT] == 1)
+#define MOUSE2 (__input.keyStates[BTN_RIGHT] == 1)
+#define MOUSE3 (__input.keyStates[BTN_MIDDLE] == 1)
+#define MOUSEX (__input.relStates[REL_X])
+#define MOUSEY (__input.relStates[REL_Y])
+#define SCROLLW (__input.relStates[REL_WHEEL])
+
+
+typedef struct {
+ int devices[ _MAX_DEVS ];
+ Size deviceCount;
+
+ Bitfield cnsFlags; /* [0x7] :: Caps Num Scrl */
+ Bitfield modFlags; /* [0x1FF] :: CS AR AL SR SL A C AGr S */
+
+ int keyStates[ KEY_MAX ];
+ int relStates[ REL_MAX ];
+
+ __u16 buffer[ _KBBUFF_LEN ];
+ Size head, tail;
+} Input33;
+
+extern Input33 __input;
+
+
+Error input33_init( void );
+void input33_poll( void );
+void input33_term( void );
+
+
+#endif /** __INPUT_H__ **/
diff --git a/include/logger.h b/include/logger.h
deleted file mode 100644
index f582100..0000000
--- a/include/logger.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __LOGGER_H__
-#define __LOGGER_H__
-
-#include "types.h"
-
-
-#define LOG_DEBUG 0
-#define LOG_INFO 1
-#define LOG_WARN 2
-#define LOG_ERROR 3 /* will be fatal */
-#define LOG_FATAL 4 /* followed directly by maybe cleanup and exit */
-
-#define __LOGFUNC__ __logger.func = __func__
-
-#define logd( s, ... ) __LOGFUNC__; logger( LOG_DEBUG, s, ##__VA_ARGS__ );
-#define logi( s, ... ) __LOGFUNC__; logger( LOG_INFO, s, ##__VA_ARGS__ );
-#define logw( s, ... ) __LOGFUNC__; logger( LOG_WARN, s, ##__VA_ARGS__ );
-#define loge( s, ... ) __LOGFUNC__; logger( LOG_ERROR, s, ##__VA_ARGS__ );
-#define logf( s, ... ) __LOGFUNC__; logger( LOG_FATAL, s, ##__VA_ARGS__ );
-
-
-typedef struct {
- Size fd;
- String func;
-} Logger;
-
-extern Logger __logger;
-
-
-Size logger_init( void );
-void logger( Size level, String fmt, ... );
-void logger_term( void );
-
-
-#endif /* __DISPLAY_H__ */
diff --git a/include/logger33.h b/include/logger33.h
new file mode 100644
index 0000000..a489f67
--- /dev/null
+++ b/include/logger33.h
@@ -0,0 +1,26 @@
+#ifndef __LOGGER33_H__
+#define __LOGGER33_H__
+
+
+#include "types33.h"
+
+
+#define _DEBUG 0
+#define _INFO 1
+#define _WARN 2
+#define _ERROR 3 /* will be fatal */
+#define _FATAL 4
+
+#define LOGD( STR, ... ) _logger( _DEBUG, __FILE__, __LINE__, __FUNCTION__, STR, ##__VA_ARGS__ );
+#define LOGI( STR, ... ) _logger( _INFO, __FILE__, __LINE__, __FUNCTION__, STR, ##__VA_ARGS__ );
+#define LOGW( STR, ... ) _logger( _WARN, __FILE__, __LINE__, __FUNCTION__, STR, ##__VA_ARGS__ );
+#define LOGE( STR, ... ) _logger( _ERROR, __FILE__, __LINE__, __FUNCTION__, STR, ##__VA_ARGS__ );
+#define LOGF( STR, ... ) _logger( _FATAL, __FILE__, __LINE__, __FUNCTION__, STR, ##__VA_ARGS__ );
+
+
+Size logger33_init( void );
+void _logger( Size level, String file, int line, String function, const char *fmt, ... );
+void logger33_term( void );
+
+
+#endif /* __DISPLAY33_H__ */
diff --git a/include/options.h b/include/options.h
deleted file mode 100644
index 418a296..0000000
--- a/include/options.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __OPTIONS_H__
-#define __OPTIONS_H__
-
-
-#define LOG_PATH "/dev/tty3"
-
-#define DRM_DEVICE "/dev/dri/card0"
-#define DRM_MODE "1024x768"
-#define DRM_RATE 75
-
-
-#endif /* __OPTIONS_H */
diff --git a/include/options33.h b/include/options33.h
new file mode 100644
index 0000000..4d3c4a3
--- /dev/null
+++ b/include/options33.h
@@ -0,0 +1,12 @@
+#ifndef __OPTIONS33_H__
+#define __OPTIONS33_H__
+
+
+#define E33_LOG_FILE "/dev/tty3"
+
+#define E33_DRM_DEVICE "/dev/dri/card0"
+#define E33_DRM_MODE "1024x768"
+#define E33_DRM_RATE 75
+
+
+#endif /* __OPTIONS33_H */
diff --git a/include/strings33.h b/include/strings33.h
index c987690..5591913 100644
--- a/include/strings33.h
+++ b/include/strings33.h
@@ -1,42 +1,49 @@
-#ifndef __STRINGS_H__
-#define __STRINGS_H__
+#ifndef __STRINGS33_H__
+#define __STRINGS33_H__
-#include "types.h"
-#include "display.h"
-#include "system.h"
+#include "system33.h"
+#include "display33.h"
-#define E33_MAX_GLYPH_PLOTS 256
-#define E33_MAX_FONT_GLYPHS 256
-#define E33_FONT_DEFAULT 0
-#define E33_FONT_BIG 1
+#define _MAX_GLYPH_PLOTS 256
+#define _MAX_FONT_GLYPHS 256
-#define quprint( s, x, y, str ) e33_uprint( s, E33_FONT_DEFAULT, WHITE, x, y, str );
-#define quprintf( s, x, y, frm, ... ) e33_uprintf( s, E33_FONT_DEFAULT, WHITE, x, y, frm, ##__VA_ARGS__ );
-#define suprint( f, c, x, y, str ) e33_uprint( &__display.surface, f, c, x, y, str );
-#define suprintf( f, c, x, y, frm, ... ) e33_uprintf( &__display.surface, f, c, x, y, frm, ##__VA_ARGS__ );
-#define qsuprint( str, x, y ) e33_uprint( &__display.surface, E33_FONT_DEFAULT, WHITE, x, y, str );
-#define qsuprintf( x, y, frm, ... ) e33_uprintf( &__display.surface, E33_FONT_DEFAULT, WHITE, x, y, frm, ##__VA_ARGS__ )
+#define STRINGS33_FONT_DEFAULT 0
+#define STRINGS33_FONT_BIG 1
+
+
+#define SPRINT( s, x, y, str ) e33_uprint( s, STRINGS33_FONT_DEFAULT, WHITE, x, y, str );
+#define SPRINTF( s, x, y, frm, ... ) e33_uprintf( s, STRINGS33_FONT_DEFAULT, WHITE, x, y, frm, ##__VA_ARGS__ );
+
+#define PRINT( f, c, x, y, str ) e33_uprint( &__display.surface, f, c, x, y, str );
+#define PRINTF( f, c, x, y, frm, ... ) e33_uprintf( &__display.surface, f, c, x, y, frm, ##__VA_ARGS__ );
+
+#define QPRINT( str, x, y ) e33_uprint( &__display.surface, STRINGS33_FONT_DEFAULT, WHITE, x, y, str );
+#define QPRINTF( x, y, frm, ... ) e33_uprintf( &__display.surface, STRINGS33_FONT_DEFAULT, WHITE, x, y, frm, ##__VA_ARGS__ )
typedef struct {
- Size num_plots;
- Size width;
- u16 plots[ E33_MAX_GLYPH_PLOTS ];
+ Size plotCount;
+ Size w;
+ u16 plots[ _MAX_GLYPH_PLOTS ];
} FontGlyph33;
typedef struct {
Size xShift, yAnd;
- Size height;
- Size num_glyphs;
- Size maxGlyphWidth;
- FontGlyph33 glyphs[ E33_MAX_FONT_GLYPHS ];
+ Size h;
+ Size glyphCount;
+ Size glyphWidthMax;
+ FontGlyph33 glyphs[ _MAX_FONT_GLYPHS ];
} Font33;
-void e33_uprint( Surface *surf, Size font, u32 col, Size x, Size y, String str );
-void e33_uprintf( Surface *surf, Size font, u32 col, Size x, Size y, String fmt, ... );
+extern Font33 defFont;
+extern Font33 bigFont;
+
+
+void strings33_uprint( Surface33 *surf, Size font, u32 col, Size x, Size y, String str );
+void strings33_uprintf( Surface33 *surf, Size font, u32 col, Size x, Size y, String fmt, ... );
-#endif /* __STRING_H__ */
+#endif /* __STRINGS33_H__ */
diff --git a/include/system.h b/include/system.h
deleted file mode 100644
index 68cbac9..0000000
--- a/include/system.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef __SYSTEM_H__
-#define __SYSTEM_H__
-
-#include "types.h"
-
-#define NEAR 1.0
-#define FAR 24.0
-
-#define TRANSPARENT 0x0
-#define BLACK 0xff000000
-#define WHITE 0xffffffff
-#define RED 0xffff0000
-#define GREEN 0xff00ff00
-#define BLUE 0xff0000ff
-#define YELLOW 0xffffff00
-#define MAGENTA 0xffff00ff
-#define CYAN 0xff00ffff
-
-
-err e33_ioctl( Size fd, unsigned long req, void *arg );
-boolean e33_strcmp( String s1, String s2 );
-err e33_has_signal(Size signo);
-err e33_set_signal(Size signo, void(*sig_handler)(int));
-
-
-#endif /** __SYSTEM_H__ **/
diff --git a/include/system33.h b/include/system33.h
new file mode 100644
index 0000000..b61eddd
--- /dev/null
+++ b/include/system33.h
@@ -0,0 +1,28 @@
+#ifndef __SYSTEM33_H__
+#define __SYSTEM33_H__
+
+
+#include "types33.h"
+
+
+#define _STRING_MAX 256
+
+
+#define BLACK 0xff000000
+#define RED 0xffff0000
+#define GREEN 0xff00ff00
+#define BLUE 0xff0000ff
+#define YELLOW 0xffffff00
+#define ORANGE 0xffffaa00
+#define MAGENTA 0xffff00ff
+#define CYAN 0xff00ffff
+#define WHITE 0xffffffff
+
+
+Error e33_ioctl( Size fd, unsigned long req, void *arg );
+Boolean e33_strcmp( String s1, String s2 );
+Error e33_has_signal(Size signo);
+Error e33_set_signal(Size signo, void(*sig_handler)(int));
+
+
+#endif /** __SYSTEM33_H__ **/
diff --git a/include/types.h b/include/types33.h
index bd52ac4..a72414e 100644
--- a/include/types.h
+++ b/include/types33.h
@@ -1,8 +1,10 @@
-#ifndef __TYPES_H__
-#define __TYPES_H__
+#ifndef __TYPES33_H__
+#define __TYPES33_H__
+
#include "stdlib.h"
#include "stdint.h"
+
#include "sys/types.h"
@@ -30,17 +32,16 @@ typedef size_t uSize;
typedef const char * String;
-typedef Size err;
-typedef Size boolean;
-
-#define sizeof(x) (Size)sizeof(x)
-#define alignof(x) (Size)_Alignof(x)
-#define countof(a) (sizeof(a) / sizeof(*(a)))
-#define lengthof(s) (countof(s) - 1)
+typedef Size Error;
+typedef Size Boolean;
+typedef Size Bitfield;
-#define assert(c) while( !(c) ){ __builtin_unreachable(); }
+//#define sizeof(x) (Size)sizeof(x)
+//#define alignof(x) (Size)_Alignof(x)
+//#define countof(a) (sizeof(a) / sizeof(*(a)))
+//#define lengthof(s) (countof(s) - 1)
-#define bp(V) logd( "BREAKPOINT :: %d", V );
+//#define assert(c) while( !(c) ){ __builtin_unreachable(); }
-#endif /* __TYPES_H__ */
+#endif /* __TYPES33_H__ */
diff --git a/include/ui33.h b/include/ui33.h
index 7aa489c..22208fe 100644
--- a/include/ui33.h
+++ b/include/ui33.h
@@ -1,9 +1,29 @@
-#ifndef __UI_H__
-#define __UI_H__
+#ifndef __UI33_H__
+#define __UI33_H__
-void ui_add_message( String fmt, ... );
-void ui_draw_messages( void );
+#define UI33_BLACK 0
+#define UI33_RED 1
+#define UI33_GREEN 2
+#define UI33_BLUE 3
+#define UI33_YELLOW 4
+#define UI33_ORANGE 5
+#define UI33_MAGENTA 6
+#define UI33_CYAN 7
+#define UI33_WHITE 8
-#endif /** UI **/
+
+typedef struct {
+ Size x, y;
+} Mouse33;
+
+extern Mouse33 __mouse;
+
+
+void ui33_add_message( String fmt, ... );
+void ui33_draw_messages( void );
+void ui33_draw_mouse( void );
+
+
+#endif /** UI33_H **/