Changeset 156 for ttyvaders


Ignore:
Timestamp:
Nov 12, 2003, 5:23:18 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • MS-DOS port of libee, using <conio.h>.
Location:
ttyvaders/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/configure.ac

    r126 r156  
    1919AC_ARG_ENABLE(ncurses,
    2020  [  --enable-ncurses        ncurses graphics support (default disabled)])
     21AC_ARG_ENABLE(conio,
     22  [  --enable-conio          DOS conio.h graphics support (default disabled)])
    2123
    2224USE_SLANG=false
    2325USE_NCURSES=false
    24 if test "${enable_ncurses}" = "yes"; then
     26USE_CONIO=false
     27if test "${enable_conio}" = "yes"; then
     28  AC_CHECK_HEADER(conio.h,:,AC_MSG_ERROR([cannot find conio.h header]))
     29  AC_DEFINE(USE_CONIO, 1, Define if the backend driver is conio.h)
     30  USE_CONIO=:
     31elif test "${enable_ncurses}" = "yes"; then
    2532  AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers]))
    2633  AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library]))
  • ttyvaders/trunk/libee/conic.c

    r152 r156  
    2929#endif
    3030
     31#ifdef HAVE_INTTYPES_H
     32#   include <inttypes.h>
     33#else
     34typedef unsigned char uint8_t;
     35#endif
     36
    3137#include <stdlib.h>
    32 #include <inttypes.h>
    3338
    3439#include "ee.h"
  • ttyvaders/trunk/libee/ee.c

    r148 r156  
    2727#elif USE_NCURSES
    2828#   include <curses.h>
     29#elif USE_CONIO
     30#   include <conio.h>
     31#else
     32#   error "no graphics library detected"
    2933#endif
    3034
     
    3842
    3943static int _ee_delay;
     44#ifdef USE_CONIO
     45static struct text_info ti;
     46#endif
    4047
    4148int ee_init(void)
     
    98105    init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
    99106
    100 #else
    101     /* Dummy driver */
     107#elif USE_CONIO
     108    _wscroll = 0;
     109    _setcursortype(_NOCURSOR);
     110    clrscr();
     111    gettextinfo(&ti);
     112//window(2, 2, 20, 20);
    102113
    103114#endif
     
    118129#elif USE_NCURSES
    119130    return COLS;
    120 #else
    121     return 80;
     131#elif USE_CONIO
     132    return ti.screenwidth;
    122133#endif
    123134}
     
    130141    return LINES;
    131142#else
    132     return 25;
    133 #endif
    134 }
    135 
     143    return ti.screenheight;
     144#endif
     145}
     146
     147#ifndef USE_CONIO
    136148static int64_t local_time(void)
    137149{
     
    145157    return now;
    146158}
     159#endif
    147160
    148161void ee_refresh(void)
    149162{
     163#ifndef USE_CONIO
    150164    static int64_t local_clock = 0;
    151165    int64_t now;
     
    161175        /* If we are late, we shouldn't display anything */
    162176    }
     177#endif
    163178
    164179#ifdef USE_SLANG
     
    166181#elif USE_NCURSES
    167182    refresh();
    168 #else
    169     /* Use dummy driver */
    170 #endif
    171 
     183#elif USE_CONIO
     184    /* Do nothing? */
     185#endif
     186
     187#ifndef USE_CONIO
    172188    now = local_time();
    173189
     
    178194
    179195    local_clock += _ee_delay;
     196#endif
    180197}
    181198
     
    189206    curs_set(1);
    190207    endwin();
    191 #else
    192     /* Use dummy driver */
    193 #endif
    194 }
    195 
     208#elif USE_CONIO
     209    _wscroll = 1;
     210    ee_set_color(EE_WHITE);
     211    ee_putstr(ee_get_width(), ee_get_height()-1, "\r\n");
     212    _setcursortype(_NORMALCURSOR);
     213#endif
     214}
     215
  • ttyvaders/trunk/libee/graphics.c

    r154 r156  
    2727#elif USE_NCURSES
    2828#   include <curses.h>
     29#elif USE_CONIO
     30#   include <conio.h>
     31#else
     32#   error "no graphics library detected"
    2933#endif
    3034
     
    3539
    3640static int ee_color = 0;
     41#ifdef USE_CONIO
     42static enum COLORS dos_colors[] = {
     43    0,
     44    BLACK,
     45    GREEN,
     46    YELLOW,
     47    WHITE,
     48    RED,
     49    DARKGRAY,
     50    LIGHTGRAY,
     51    BLUE,
     52    CYAN,
     53    MAGENTA
     54};
     55#endif
    3756
    3857void ee_set_color(int color)
     
    4362#elif USE_NCURSES
    4463    attrset(COLOR_PAIR(color));
    45 #else
    46     /* Use dummy driver */
     64#elif USE_CONIO
     65    if(color >= 1 && color <= 10)
     66        textcolor(dos_colors[color]);
    4767#endif
    4868}
     
    6181    move(y,x);
    6282    addch(c);
    63 #else
    64     /* Use dummy driver */
     83#elif USE_CONIO
     84    gotoxy(x+1,y+1);
     85    putch(c);
    6586#endif
    6687}
     
    7495    move(y,x);
    7596    addstr(s);
    76 #else
    77     /* Use dummy driver */
     97#elif USE_CONIO
     98    gotoxy(x+1,y+1);
     99    cputs(s);
    78100#endif
    79101}
     
    81103void ee_clear(void)
    82104{
    83 #if defined(USE_SLANG) || defined(USE_NCURSES)
    84     /* We could use SLsmg_cls(), but drawing empty lines is much faster */
     105    /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */
    85106    int x = ee_get_width(), y = ee_get_height();
    86107    char *empty_line = malloc((x + 1) * sizeof(char));
     
    95116
    96117    free(empty_line);
    97 #else
    98     /* Use dummy driver */
    99 #endif
    100118}
    101119
  • ttyvaders/trunk/libee/io.c

    r148 r156  
    2727#elif USE_NCURSES
    2828#   include <curses.h>
     29#elif USE_CONIO
     30#   include <conio.h>
     31#else
     32#   error "no graphics library detected"
    2933#endif
    3034
     
    4549        return key;
    4650    }
    47 #else
    48     return 0;
     51#elif USE_CONIO
     52    return _conio_kbhit() ? getch() : 0;
    4953
    5054#endif
  • ttyvaders/trunk/libee/line.c

    r154 r156  
    2929#endif
    3030
    31 #include <inttypes.h>
     31#ifdef HAVE_INTTYPES_H
     32#   include <inttypes.h>
     33#else
     34typedef unsigned char uint8_t;
     35#endif
     36
    3237#include <stdlib.h>
    3338
Note: See TracChangeset for help on using the changeset viewer.