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?().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.