Ignore:
Timestamp:
Nov 16, 2003, 1:33:35 AM (17 years ago)
Author:
Sam Hocevar
Message:
  • Renamed libee to libcaca. Far less collisions.
Location:
libcaca/trunk/libcaca
Files:
2 moved

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/libcaca/caca.c

    r184 r185  
    11/*
    2  *   libee         ASCII-Art library
     2 *   libcaca       ASCII-Art library
    33 *   Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
    44 *                 All Rights Reserved
     
    4343#include <time.h>
    4444
    45 #include "ee.h"
    46 #include "ee_internals.h"
    47 
    48 static unsigned int _ee_delay;
    49 static unsigned int _ee_rendertime;
    50 char *_ee_empty_line;
    51 char *_ee_scratch_line;
     45#include "caca.h"
     46#include "caca_internals.h"
     47
     48static unsigned int _caca_delay;
     49static unsigned int _caca_rendertime;
     50char *_caca_empty_line;
     51char *_caca_scratch_line;
    5252
    5353#if defined(USE_NCURSES)
    54 int _ee_attr[16];
     54int _caca_attr[16];
    5555#endif
    5656
    5757#if defined(USE_CONIO)
    5858static struct text_info ti;
    59 char *_ee_screen;
    60 #endif
    61 
    62 int ee_init(void)
     59char *_caca_screen;
     60#endif
     61
     62int caca_init(void)
    6363{
    6464#if defined(USE_SLANG)
     
    144144    for(i = 0; i < 8; i++)
    145145    {
    146         _ee_attr[i] = COLOR_PAIR(1 + i);
    147         _ee_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i);
     146        _caca_attr[i] = COLOR_PAIR(1 + i);
     147        _caca_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i);
    148148    }
    149149
    150150#elif defined(USE_CONIO)
    151151    gettextinfo(&ti);
    152     _ee_screen = malloc(2 * ti.screenwidth * ti.screenheight);
    153     if(_ee_screen == NULL)
     152    _caca_screen = malloc(2 * ti.screenwidth * ti.screenheight);
     153    if(_caca_screen == NULL)
    154154        return -1;
    155155    _wscroll = 0;
     
    157157    clrscr();
    158158#   if defined(SCREENUPDATE_IN_PC_H)
    159     ScreenRetrieve(_ee_screen);
     159    ScreenRetrieve(_caca_screen);
    160160#   else
    161161    /* FIXME */
     
    163163
    164164#endif
    165     _ee_empty_line = malloc(ee_get_width() + 1);
    166     memset(_ee_empty_line, ' ', ee_get_width());
    167     _ee_empty_line[ee_get_width()] = '\0';
    168 
    169     _ee_scratch_line = malloc(ee_get_width() + 1);
    170 
    171     _ee_delay = 0;
    172     _ee_rendertime = 0;
     165    _caca_empty_line = malloc(caca_get_width() + 1);
     166    memset(_caca_empty_line, ' ', caca_get_width());
     167    _caca_empty_line[caca_get_width()] = '\0';
     168
     169    _caca_scratch_line = malloc(caca_get_width() + 1);
     170
     171    _caca_delay = 0;
     172    _caca_rendertime = 0;
    173173
    174174    return 0;
    175175}
    176176
    177 unsigned int ee_get_width(void)
     177unsigned int caca_get_width(void)
    178178{
    179179#if defined(USE_SLANG)
     
    186186}
    187187
    188 unsigned int ee_get_height(void)
     188unsigned int caca_get_height(void)
    189189{
    190190#if defined(USE_SLANG)
     
    197197}
    198198
    199 void ee_set_delay(unsigned int usec)
    200 {
    201     _ee_delay = usec;
    202 }
    203 
    204 unsigned int ee_get_rendertime(void)
    205 {
    206     return _ee_rendertime;
    207 }
    208 
    209 const char *ee_get_color_name(unsigned int color)
     199void caca_set_delay(unsigned int usec)
     200{
     201    _caca_delay = usec;
     202}
     203
     204unsigned int caca_get_rendertime(void)
     205{
     206    return _caca_rendertime;
     207}
     208
     209const char *caca_get_color_name(unsigned int color)
    210210{
    211211    static const char *color_names[16] =
     
    235235}
    236236
    237 static unsigned int _ee_getticks(void)
     237static unsigned int _caca_getticks(void)
    238238{
    239239    static unsigned int last_sec = 0, last_usec = 0;
     
    255255}
    256256
    257 void ee_refresh(void)
     257void caca_refresh(void)
    258258{
    259259#define IDLE_USEC 10000
    260260    static unsigned int lastticks = 0;
    261     unsigned int ticks = lastticks + _ee_getticks();
     261    unsigned int ticks = lastticks + _caca_getticks();
    262262
    263263#if defined(USE_SLANG)
     
    267267#elif defined(USE_CONIO)
    268268#   if defined(SCREENUPDATE_IN_PC_H)
    269     ScreenUpdate(_ee_screen);
     269    ScreenUpdate(_caca_screen);
    270270#   else
    271271    /* FIXME */
     
    273273#endif
    274274
    275     /* Wait until _ee_delay + time of last call */
    276     ticks += _ee_getticks();
    277     for(; ticks < _ee_delay - IDLE_USEC; ticks += _ee_getticks())
     275    /* Wait until _caca_delay + time of last call */
     276    ticks += _caca_getticks();
     277    for(; ticks < _caca_delay - IDLE_USEC; ticks += _caca_getticks())
    278278        usleep(IDLE_USEC);
    279279
    280280    /* Update the sliding mean of the render time */
    281     _ee_rendertime = (7 * _ee_rendertime + ticks) / 8;
    282 
    283     lastticks = ticks - _ee_delay;
     281    _caca_rendertime = (7 * _caca_rendertime + ticks) / 8;
     282
     283    lastticks = ticks - _caca_delay;
    284284
    285285    /* If we drifted too much, it's bad, bad, bad. */
    286     if(lastticks > _ee_delay)
     286    if(lastticks > _caca_delay)
    287287        lastticks = 0;
    288288}
    289289
    290 void ee_end(void)
     290void caca_end(void)
    291291{
    292292#if defined(USE_SLANG)
     
    301301    textcolor((enum COLORS)WHITE);
    302302    textbackground((enum COLORS)BLACK);
    303     gotoxy(ee_get_width(), ee_get_height());
     303    gotoxy(caca_get_width(), caca_get_height());
    304304    cputs("\r\n");
    305305    _setcursortype(_NORMALCURSOR);
Note: See TracChangeset for help on using the changeset viewer.