Pārlūkot izejas kodu

* MS-DOS port of libee, using <conio.h>.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@156 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam pirms 21 gadiem
vecāks
revīzija
22560fc9a2
6 mainītis faili ar 84 papildinājumiem un 25 dzēšanām
  1. +8
    -1
      configure.ac
  2. +6
    -1
      libee/conic.c
  3. +29
    -9
      libee/ee.c
  4. +29
    -11
      libee/graphics.c
  5. +6
    -2
      libee/io.c
  6. +6
    -1
      libee/line.c

+ 8
- 1
configure.ac Parādīt failu

@@ -18,10 +18,17 @@ AC_ARG_ENABLE(slang,
[ --enable-slang slang graphics support (default enabled)])
AC_ARG_ENABLE(ncurses,
[ --enable-ncurses ncurses graphics support (default disabled)])
AC_ARG_ENABLE(conio,
[ --enable-conio DOS conio.h graphics support (default disabled)])

USE_SLANG=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_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library]))
AC_DEFINE(USE_NCURSES, 1, Define if the backend driver is ncurses)


+ 6
- 1
libee/conic.c Parādīt failu

@@ -28,8 +28,13 @@
# include <curses.h>
#endif

#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#else
typedef unsigned char uint8_t;
#endif

#include <stdlib.h>
#include <inttypes.h>

#include "ee.h"



+ 29
- 9
libee/ee.c Parādīt failu

@@ -26,6 +26,10 @@
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#elif USE_CONIO
# include <conio.h>
#else
# error "no graphics library detected"
#endif

#include <stdlib.h>
@@ -37,6 +41,9 @@
#include "ee.h"

static int _ee_delay;
#ifdef USE_CONIO
static struct text_info ti;
#endif

int ee_init(void)
{
@@ -97,8 +104,12 @@ int ee_init(void)
init_pair(EE_CYAN, COLOR_CYAN, 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
_ee_delay = 0;
@@ -117,8 +128,8 @@ int ee_get_width(void)
return SLtt_Screen_Cols;
#elif USE_NCURSES
return COLS;
#else
return 80;
#elif USE_CONIO
return ti.screenwidth;
#endif
}

@@ -129,10 +140,11 @@ int ee_get_height(void)
#elif USE_NCURSES
return LINES;
#else
return 25;
return ti.screenheight;
#endif
}

#ifndef USE_CONIO
static int64_t local_time(void)
{
struct timeval tv;
@@ -144,9 +156,11 @@ static int64_t local_time(void)
now += tv.tv_usec;
return now;
}
#endif

void ee_refresh(void)
{
#ifndef USE_CONIO
static int64_t local_clock = 0;
int64_t now;

@@ -160,15 +174,17 @@ void ee_refresh(void)
{
/* If we are late, we shouldn't display anything */
}
#endif

#ifdef USE_SLANG
SLsmg_refresh();
#elif USE_NCURSES
refresh();
#else
/* Use dummy driver */
#elif USE_CONIO
/* Do nothing? */
#endif

#ifndef USE_CONIO
now = local_time();

if(now < local_clock + _ee_delay - 10000)
@@ -177,6 +193,7 @@ void ee_refresh(void)
}

local_clock += _ee_delay;
#endif
}

void ee_end(void)
@@ -188,8 +205,11 @@ void ee_end(void)
#elif USE_NCURSES
curs_set(1);
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
}


+ 29
- 11
libee/graphics.c Parādīt failu

@@ -26,6 +26,10 @@
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#elif USE_CONIO
# include <conio.h>
#else
# error "no graphics library detected"
#endif

#include <string.h>
@@ -34,6 +38,21 @@
#include "ee.h"

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)
{
@@ -42,8 +61,9 @@ void ee_set_color(int color)
SLsmg_set_color(color);
#elif USE_NCURSES
attrset(COLOR_PAIR(color));
#else
/* Use dummy driver */
#elif USE_CONIO
if(color >= 1 && color <= 10)
textcolor(dos_colors[color]);
#endif
}

@@ -60,8 +80,9 @@ void ee_putchar(int x, int y, char c)
#elif USE_NCURSES
move(y,x);
addch(c);
#else
/* Use dummy driver */
#elif USE_CONIO
gotoxy(x+1,y+1);
putch(c);
#endif
}

@@ -73,15 +94,15 @@ void ee_putstr(int x, int y, char *s)
#elif USE_NCURSES
move(y,x);
addstr(s);
#else
/* Use dummy driver */
#elif USE_CONIO
gotoxy(x+1,y+1);
cputs(s);
#endif
}

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();
char *empty_line = malloc((x + 1) * sizeof(char));

@@ -94,8 +115,5 @@ void ee_clear(void)
}

free(empty_line);
#else
/* Use dummy driver */
#endif
}


+ 6
- 2
libee/io.c Parādīt failu

@@ -26,6 +26,10 @@
# include <slang.h>
#elif USE_NCURSES
# include <curses.h>
#elif USE_CONIO
# include <conio.h>
#else
# error "no graphics library detected"
#endif

#include "ee.h"
@@ -44,8 +48,8 @@ char ee_get_key(void)
{
return key;
}
#else
return 0;
#elif USE_CONIO
return _conio_kbhit() ? getch() : 0;

#endif



+ 6
- 1
libee/line.c Parādīt failu

@@ -28,7 +28,12 @@
# include <curses.h>
#endif

#include <inttypes.h>
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#else
typedef unsigned char uint8_t;
#endif

#include <stdlib.h>

#include "ee.h"


Notiek ielāde…
Atcelt
Saglabāt