Changeset 158


Ignore:
Timestamp:
Nov 12, 2003, 7:41:02 PM (20 years ago)
Author:
Sam Hocevar
Message:
  • README: + Added a note about dos cross-compilation.
  • configure.ac: + Added a check for ScreenUpdate? in <pc.h>.
  • libee/graphics.c libee/ee.c: + Improved the conio port thanks to ScreenUpdate?().
Location:
ttyvaders/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ttyvaders/trunk/README

    r66 r158  
    77    --enable-slang: use the SLang library (default)
    88    --enable-ncurses: use the ncurses library
     9    --enable-conio: use MS-DOS conio.h
     10
     11   Cross-compilation example:
     12    ./configure --enable-conio --host=i386-pc-msdosdjgpp
    913
    1014
  • ttyvaders/trunk/configure.ac

    r156 r158  
    1515AC_PROG_RANLIB
    1616
     17dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
     18dnl now otherwise it might be set in an obscure if statement.
     19AC_EGREP_CPP(foo,foo)
     20
    1721AC_ARG_ENABLE(slang,
    1822  [  --enable-slang          slang graphics support (default enabled)])
     
    2731if test "${enable_conio}" = "yes"; then
    2832  AC_CHECK_HEADER(conio.h,:,AC_MSG_ERROR([cannot find conio.h header]))
     33  AC_MSG_CHECKING(for ScreenUpdate in pc.h)
     34  AC_EGREP_HEADER(ScreenUpdate,pc.h,[
     35    AC_MSG_RESULT(yes)
     36    AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
     37              Define if <pc.h> defines ScreenUpdate.)],[
     38    AC_MSG_RESULT(no)])
    2939  AC_DEFINE(USE_CONIO, 1, Define if the backend driver is conio.h)
    3040  USE_CONIO=:
  • ttyvaders/trunk/libee/ee.c

    r156 r158  
    2323#include "config.h"
    2424
    25 #ifdef USE_SLANG
     25#if defined(USE_SLANG)
    2626#   include <slang.h>
    27 #elif USE_NCURSES
     27#elif defined(USE_NCURSES)
    2828#   include <curses.h>
    29 #elif USE_CONIO
     29#elif defined(USE_CONIO)
     30#   include <dos.h>
    3031#   include <conio.h>
     32#   if defined(SCREENUPDATE_IN_PC_H)
     33#       include <pc.h>
     34#   endif
    3135#else
    3236#   error "no graphics library detected"
     
    4246
    4347static int _ee_delay;
    44 #ifdef USE_CONIO
     48#if defined(USE_CONIO)
    4549static struct text_info ti;
     50char *_screen_buffer;
    4651#endif
    4752
    4853int ee_init(void)
    4954{
    50 #ifdef USE_SLANG
     55#if defined(USE_SLANG)
    5156    static char * colors[] = { "black", "green", "yellow", "white",
    5257        "red", "gray", "lightgray", "blue", "cyan", "magenta", NULL };
     
    8287    }
    8388
    84 #elif USE_NCURSES
     89#elif defined(USE_NCURSES)
    8590    /* Initialize ncurses library */
    8691    initscr();
     
    105110    init_pair(EE_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
    106111
    107 #elif USE_CONIO
     112#elif defined(USE_CONIO)
    108113    _wscroll = 0;
    109114    _setcursortype(_NOCURSOR);
    110115    clrscr();
    111116    gettextinfo(&ti);
    112 //window(2, 2, 20, 20);
     117    _screen_buffer = malloc(ee_get_width() * ee_get_height() * 2);
     118    ScreenRetrieve(_screen_buffer);
    113119
    114120#endif
     
    118124}
    119125
    120 void ee_set_delay(int delay)
    121 {
    122     _ee_delay = delay;
     126void ee_set_delay(int usec)
     127{
     128    _ee_delay = usec;
    123129}
    124130
    125131int ee_get_width(void)
    126132{
    127 #ifdef USE_SLANG
     133#if defined(USE_SLANG)
    128134    return SLtt_Screen_Cols;
    129 #elif USE_NCURSES
     135#elif defined(USE_NCURSES)
    130136    return COLS;
    131 #elif USE_CONIO
     137#elif defined(USE_CONIO)
    132138    return ti.screenwidth;
    133139#endif
     
    136142int ee_get_height(void)
    137143{
    138 #ifdef USE_SLANG
     144#if defined(USE_SLANG)
    139145    return SLtt_Screen_Rows;
    140 #elif USE_NCURSES
     146#elif defined(USE_NCURSES)
    141147    return LINES;
    142148#else
     
    145151}
    146152
    147 #ifndef USE_CONIO
     153#if !defined(USE_CONIO)
    148154static int64_t local_time(void)
    149155{
     
    161167void ee_refresh(void)
    162168{
    163 #ifndef USE_CONIO
     169#if !defined(USE_CONIO)
    164170    static int64_t local_clock = 0;
    165171    int64_t now;
     
    177183#endif
    178184
    179 #ifdef USE_SLANG
     185#if defined(USE_SLANG)
    180186    SLsmg_refresh();
    181 #elif USE_NCURSES
     187#elif defined(USE_NCURSES)
    182188    refresh();
    183 #elif USE_CONIO
    184     /* Do nothing? */
    185 #endif
    186 
    187 #ifndef USE_CONIO
     189#elif defined(USE_CONIO)
     190    ScreenUpdate(_screen_buffer);
     191#endif
     192
     193#if !defined(USE_CONIO)
    188194    now = local_time();
    189195
     
    194200
    195201    local_clock += _ee_delay;
     202#else
     203    delay(5);
    196204#endif
    197205}
     
    199207void ee_end(void)
    200208{
    201 #ifdef USE_SLANG
     209#if defined(USE_SLANG)
    202210    SLtt_set_cursor_visibility(1);
    203211    SLang_reset_tty();
    204212    SLsmg_reset_smg();
    205 #elif USE_NCURSES
     213#elif defined(USE_NCURSES)
    206214    curs_set(1);
    207215    endwin();
    208 #elif USE_CONIO
     216#elif defined(USE_CONIO)
     217    ScreenUpdate(_screen_buffer);
    209218    _wscroll = 1;
    210     ee_set_color(EE_WHITE);
    211     ee_putstr(ee_get_width(), ee_get_height()-1, "\r\n");
     219    textcolor((enum COLORS)WHITE);
     220    textbackground((enum COLORS)BLACK);
     221    gotoxy(ee_get_width(), ee_get_height());
     222    cputs("\r\n");
    212223    _setcursortype(_NORMALCURSOR);
    213224#endif
  • ttyvaders/trunk/libee/graphics.c

    r156 r158  
    2323#include "config.h"
    2424
    25 #ifdef USE_SLANG
     25#if defined(USE_SLANG)
    2626#   include <slang.h>
    27 #elif USE_NCURSES
     27#elif defined(USE_NCURSES)
    2828#   include <curses.h>
    29 #elif USE_CONIO
     29#elif defined(USE_CONIO)
    3030#   include <conio.h>
    3131#else
     
    3939
    4040static int ee_color = 0;
    41 #ifdef USE_CONIO
     41#if defined(USE_CONIO)
    4242static enum COLORS dos_colors[] = {
    4343    0,
     
    5858{
    5959    ee_color = color;
    60 #ifdef USE_SLANG
     60#if defined(USE_SLANG)
    6161    SLsmg_set_color(color);
    62 #elif USE_NCURSES
     62#elif defined(USE_NCURSES)
    6363    attrset(COLOR_PAIR(color));
    64 #elif USE_CONIO
     64#elif defined(USE_CONIO)
    6565    if(color >= 1 && color <= 10)
    6666        textcolor(dos_colors[color]);
     
    7373}
    7474
     75extern char *_screen_buffer;
     76
    7577void ee_putchar(int x, int y, char c)
    7678{
    77 #ifdef USE_SLANG
     79#if defined(USE_SLANG)
    7880    SLsmg_gotorc(y,x);
    7981    SLsmg_write_char(c);
    80 #elif USE_NCURSES
     82#elif defined(USE_NCURSES)
    8183    move(y,x);
    8284    addch(c);
    83 #elif USE_CONIO
    84     gotoxy(x+1,y+1);
    85     putch(c);
     85#elif defined(USE_CONIO)
     86    if(x<0 || x>=ee_get_width() || y<0 || y>=ee_get_height())
     87        return;
     88    _screen_buffer[2 * (x + y * ee_get_width())] = c;
     89    _screen_buffer[2 * (x + y * ee_get_width()) + 1] = dos_colors[ee_color];
     90//    gotoxy(x+1,y+1);
     91//    putch(c);
    8692#endif
    8793}
     
    8995void ee_putstr(int x, int y, char *s)
    9096{
    91 #ifdef USE_SLANG
     97    if(y<0 || y>=ee_get_height())
     98        return;
     99#if defined(USE_SLANG)
    92100    SLsmg_gotorc(y,x);
    93101    SLsmg_write_string(s);
    94 #elif USE_NCURSES
     102#elif defined(USE_NCURSES)
    95103    move(y,x);
    96104    addstr(s);
    97 #elif USE_CONIO
    98     gotoxy(x+1,y+1);
    99     cputs(s);
     105#elif defined(USE_CONIO)
     106    char *buf = _screen_buffer + 2 * (x + y * ee_get_width());
     107    while(*s)
     108    {
     109        *buf++ = *s++;
     110        *buf++ = dos_colors[ee_color];
     111    }
     112//    gotoxy(x+1,y+1);
     113//    cputs(s);
    100114#endif
    101115}
Note: See TracChangeset for help on using the changeset viewer.