@@ -18,10 +18,17 @@ AC_ARG_ENABLE(slang, | |||||
[ --enable-slang slang graphics support (default enabled)]) | [ --enable-slang slang graphics support (default enabled)]) | ||||
AC_ARG_ENABLE(ncurses, | AC_ARG_ENABLE(ncurses, | ||||
[ --enable-ncurses ncurses graphics support (default disabled)]) | [ --enable-ncurses ncurses graphics support (default disabled)]) | ||||
AC_ARG_ENABLE(conio, | |||||
[ --enable-conio DOS conio.h graphics support (default disabled)]) | |||||
USE_SLANG=false | USE_SLANG=false | ||||
USE_NCURSES=false | USE_NCURSES=false | ||||
if test "${enable_ncurses}" = "yes"; then | |||||
USE_CONIO=false | |||||
if test "${enable_conio}" = "yes"; then | |||||
AC_CHECK_HEADER(conio.h,:,AC_MSG_ERROR([cannot find conio.h header])) | |||||
AC_DEFINE(USE_CONIO, 1, Define if the backend driver is conio.h) | |||||
USE_CONIO=: | |||||
elif test "${enable_ncurses}" = "yes"; then | |||||
AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers])) | AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers])) | ||||
AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library])) | AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library])) | ||||
AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses) | AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses) | ||||
@@ -28,8 +28,13 @@ | |||||
# include <curses.h> | # include <curses.h> | ||||
#endif | #endif | ||||
#ifdef HAVE_INTTYPES_H | |||||
# include <inttypes.h> | |||||
#else | |||||
typedef unsigned char uint8_t; | |||||
#endif | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <inttypes.h> | |||||
#include "ee.h" | #include "ee.h" | ||||
@@ -26,6 +26,10 @@ | |||||
# include <slang.h> | # include <slang.h> | ||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
# include <curses.h> | # include <curses.h> | ||||
#elif USE_CONIO | |||||
# include <conio.h> | |||||
#else | |||||
# error "no graphics library detected" | |||||
#endif | #endif | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
@@ -37,6 +41,9 @@ | |||||
#include "ee.h" | #include "ee.h" | ||||
static int _ee_delay; | static int _ee_delay; | ||||
#ifdef USE_CONIO | |||||
static struct text_info ti; | |||||
#endif | |||||
int ee_init(void) | int ee_init(void) | ||||
{ | { | ||||
@@ -97,8 +104,12 @@ int ee_init(void) | |||||
init_pair(EE_CYAN, COLOR_CYAN, COLOR_BLACK); | init_pair(EE_CYAN, COLOR_CYAN, COLOR_BLACK); | ||||
init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); | init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); | ||||
#else | |||||
/* Dummy driver */ | |||||
#elif USE_CONIO | |||||
_wscroll = 0; | |||||
_setcursortype(_NOCURSOR); | |||||
clrscr(); | |||||
gettextinfo(&ti); | |||||
//window(2, 2, 20, 20); | |||||
#endif | #endif | ||||
_ee_delay = 0; | _ee_delay = 0; | ||||
@@ -117,8 +128,8 @@ int ee_get_width(void) | |||||
return SLtt_Screen_Cols; | return SLtt_Screen_Cols; | ||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
return COLS; | return COLS; | ||||
#else | |||||
return 80; | |||||
#elif USE_CONIO | |||||
return ti.screenwidth; | |||||
#endif | #endif | ||||
} | } | ||||
@@ -129,10 +140,11 @@ int ee_get_height(void) | |||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
return LINES; | return LINES; | ||||
#else | #else | ||||
return 25; | |||||
return ti.screenheight; | |||||
#endif | #endif | ||||
} | } | ||||
#ifndef USE_CONIO | |||||
static int64_t local_time(void) | static int64_t local_time(void) | ||||
{ | { | ||||
struct timeval tv; | struct timeval tv; | ||||
@@ -144,9 +156,11 @@ static int64_t local_time(void) | |||||
now += tv.tv_usec; | now += tv.tv_usec; | ||||
return now; | return now; | ||||
} | } | ||||
#endif | |||||
void ee_refresh(void) | void ee_refresh(void) | ||||
{ | { | ||||
#ifndef USE_CONIO | |||||
static int64_t local_clock = 0; | static int64_t local_clock = 0; | ||||
int64_t now; | int64_t now; | ||||
@@ -160,15 +174,17 @@ void ee_refresh(void) | |||||
{ | { | ||||
/* If we are late, we shouldn't display anything */ | /* If we are late, we shouldn't display anything */ | ||||
} | } | ||||
#endif | |||||
#ifdef USE_SLANG | #ifdef USE_SLANG | ||||
SLsmg_refresh(); | SLsmg_refresh(); | ||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
refresh(); | refresh(); | ||||
#else | |||||
/* Use dummy driver */ | |||||
#elif USE_CONIO | |||||
/* Do nothing? */ | |||||
#endif | #endif | ||||
#ifndef USE_CONIO | |||||
now = local_time(); | now = local_time(); | ||||
if(now < local_clock + _ee_delay - 10000) | if(now < local_clock + _ee_delay - 10000) | ||||
@@ -177,6 +193,7 @@ void ee_refresh(void) | |||||
} | } | ||||
local_clock += _ee_delay; | local_clock += _ee_delay; | ||||
#endif | |||||
} | } | ||||
void ee_end(void) | void ee_end(void) | ||||
@@ -188,8 +205,11 @@ void ee_end(void) | |||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
curs_set(1); | curs_set(1); | ||||
endwin(); | endwin(); | ||||
#else | |||||
/* Use dummy driver */ | |||||
#elif USE_CONIO | |||||
_wscroll = 1; | |||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(ee_get_width(), ee_get_height()-1, "\r\n"); | |||||
_setcursortype(_NORMALCURSOR); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -26,6 +26,10 @@ | |||||
# include <slang.h> | # include <slang.h> | ||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
# include <curses.h> | # include <curses.h> | ||||
#elif USE_CONIO | |||||
# include <conio.h> | |||||
#else | |||||
# error "no graphics library detected" | |||||
#endif | #endif | ||||
#include <string.h> | #include <string.h> | ||||
@@ -34,6 +38,21 @@ | |||||
#include "ee.h" | #include "ee.h" | ||||
static int ee_color = 0; | static int ee_color = 0; | ||||
#ifdef USE_CONIO | |||||
static enum COLORS dos_colors[] = { | |||||
0, | |||||
BLACK, | |||||
GREEN, | |||||
YELLOW, | |||||
WHITE, | |||||
RED, | |||||
DARKGRAY, | |||||
LIGHTGRAY, | |||||
BLUE, | |||||
CYAN, | |||||
MAGENTA | |||||
}; | |||||
#endif | |||||
void ee_set_color(int color) | void ee_set_color(int color) | ||||
{ | { | ||||
@@ -42,8 +61,9 @@ void ee_set_color(int color) | |||||
SLsmg_set_color(color); | SLsmg_set_color(color); | ||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
attrset(COLOR_PAIR(color)); | attrset(COLOR_PAIR(color)); | ||||
#else | |||||
/* Use dummy driver */ | |||||
#elif USE_CONIO | |||||
if(color >= 1 && color <= 10) | |||||
textcolor(dos_colors[color]); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -60,8 +80,9 @@ void ee_putchar(int x, int y, char c) | |||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
move(y,x); | move(y,x); | ||||
addch(c); | addch(c); | ||||
#else | |||||
/* Use dummy driver */ | |||||
#elif USE_CONIO | |||||
gotoxy(x+1,y+1); | |||||
putch(c); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -73,15 +94,15 @@ void ee_putstr(int x, int y, char *s) | |||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
move(y,x); | move(y,x); | ||||
addstr(s); | addstr(s); | ||||
#else | |||||
/* Use dummy driver */ | |||||
#elif USE_CONIO | |||||
gotoxy(x+1,y+1); | |||||
cputs(s); | |||||
#endif | #endif | ||||
} | } | ||||
void ee_clear(void) | void ee_clear(void) | ||||
{ | { | ||||
#if defined(USE_SLANG) || defined(USE_NCURSES) | |||||
/* We could use SLsmg_cls(), but drawing empty lines is much faster */ | |||||
/* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ | |||||
int x = ee_get_width(), y = ee_get_height(); | int x = ee_get_width(), y = ee_get_height(); | ||||
char *empty_line = malloc((x + 1) * sizeof(char)); | char *empty_line = malloc((x + 1) * sizeof(char)); | ||||
@@ -94,8 +115,5 @@ void ee_clear(void) | |||||
} | } | ||||
free(empty_line); | free(empty_line); | ||||
#else | |||||
/* Use dummy driver */ | |||||
#endif | |||||
} | } | ||||
@@ -26,6 +26,10 @@ | |||||
# include <slang.h> | # include <slang.h> | ||||
#elif USE_NCURSES | #elif USE_NCURSES | ||||
# include <curses.h> | # include <curses.h> | ||||
#elif USE_CONIO | |||||
# include <conio.h> | |||||
#else | |||||
# error "no graphics library detected" | |||||
#endif | #endif | ||||
#include "ee.h" | #include "ee.h" | ||||
@@ -44,8 +48,8 @@ char ee_get_key(void) | |||||
{ | { | ||||
return key; | return key; | ||||
} | } | ||||
#else | |||||
return 0; | |||||
#elif USE_CONIO | |||||
return _conio_kbhit() ? getch() : 0; | |||||
#endif | #endif | ||||
@@ -28,7 +28,12 @@ | |||||
# include <curses.h> | # include <curses.h> | ||||
#endif | #endif | ||||
#include <inttypes.h> | |||||
#ifdef HAVE_INTTYPES_H | |||||
# include <inttypes.h> | |||||
#else | |||||
typedef unsigned char uint8_t; | |||||
#endif | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | #include "ee.h" | ||||