git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@186 92316355-f0b4-4df1-b90c-862c8a59935fmaster
@@ -2,7 +2,7 @@ | |||||
# Automake targets and declarations for ttyvaders | # Automake targets and declarations for ttyvaders | ||||
############################################################################### | ############################################################################### | ||||
SUBDIRS = libee test src | |||||
SUBDIRS = libcaca test src | |||||
DIST_SUBDIRS = $(SUBDIRS) autotools data debian | DIST_SUBDIRS = $(SUBDIRS) autotools data debian | ||||
EXTRA_DIST = BUGS doc/shapes.txt bootstrap | EXTRA_DIST = BUGS doc/shapes.txt bootstrap | ||||
@@ -1,6 +1,6 @@ | |||||
$Id$ | $Id$ | ||||
TODO for libee | |||||
TODO for libcaca | |||||
o Sprite library | o Sprite library | ||||
@@ -60,7 +60,7 @@ CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-protot | |||||
AC_OUTPUT([ | AC_OUTPUT([ | ||||
Makefile | Makefile | ||||
libee/Makefile | |||||
libcaca/Makefile | |||||
test/Makefile | test/Makefile | ||||
src/Makefile | src/Makefile | ||||
autotools/Makefile | autotools/Makefile | ||||
@@ -1,12 +1,12 @@ | |||||
############################################################################### | ############################################################################### | ||||
# Automake targets and declarations for libee | |||||
# Automake targets and declarations for libcaca | |||||
############################################################################### | ############################################################################### | ||||
lib_LIBRARIES = libee.a | |||||
libee_a_SOURCES = \ | |||||
ee.c \ | |||||
ee.h \ | |||||
ee_internals.h \ | |||||
lib_LIBRARIES = libcaca.a | |||||
libcaca_a_SOURCES = \ | |||||
caca.c \ | |||||
caca.h \ | |||||
caca_internals.h \ | |||||
graphics.c \ | graphics.c \ | ||||
io.c \ | io.c \ | ||||
math.c \ | math.c \ |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -30,11 +30,11 @@ typedef unsigned char uint8_t; | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
#include <stdio.h> | #include <stdio.h> | ||||
void ee_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) | |||||
void caca_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) | |||||
{ | { | ||||
char foo[] = { ' ', '.', ':', ';', '=', '$', '%', '@', '#', '8', 'W' }; | char foo[] = { ' ', '.', ':', ';', '=', '$', '%', '@', '#', '8', 'W' }; | ||||
int x, y, pitch; | int x, y, pitch; | ||||
@@ -51,8 +51,8 @@ void ee_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) | |||||
pitch = (3 * w + 3) / 4 * 4; | pitch = (3 * w + 3) / 4 * 4; | ||||
for(y = y1 > 0 ? y1 : 0; y <= y2 && y <= ee_get_height(); y++) | |||||
for(x = x1 > 0 ? x1 : 0; x <= x2 && x <= ee_get_width(); x++) | |||||
for(y = y1 > 0 ? y1 : 0; y <= y2 && y <= caca_get_height(); y++) | |||||
for(x = x1 > 0 ? x1 : 0; x <= x2 && x <= caca_get_width(); x++) | |||||
{ | { | ||||
int fromx = w * (x - x1) / (x2 - x1 + 1); | int fromx = w * (x - x1) / (x2 - x1 + 1); | ||||
int fromy = h * (y - y1) / (y2 - y1 + 1); | int fromy = h * (y - y1) / (y2 - y1 + 1); | ||||
@@ -62,7 +62,7 @@ void ee_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) | |||||
if(r == g && g == b) | if(r == g && g == b) | ||||
{ | { | ||||
ee_set_color(EE_LIGHTGRAY); | |||||
caca_set_color(EE_LIGHTGRAY); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -88,15 +88,15 @@ void ee_blit(int x1, int y1, int x2, int y2, void *pixels, int w, int h) | |||||
if( hue < 0 ) | if( hue < 0 ) | ||||
hue += 360; | hue += 360; | ||||
ee_set_color(foo_colors[(int)(hue + 30) / 60]); | |||||
caca_set_color(foo_colors[(int)(hue + 30) / 60]); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
ee_set_color(EE_LIGHTGRAY); | |||||
caca_set_color(EE_LIGHTGRAY); | |||||
} | } | ||||
} | } | ||||
ee_putchar(x, y, foo[(r + g + b) / 3 / 25]); | |||||
caca_putchar(x, y, foo[(r + g + b) / 3 / 25]); | |||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -24,18 +24,18 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
void ee_draw_box(int x1, int y1, int x2, int y2, char c) | |||||
void caca_draw_box(int x1, int y1, int x2, int y2, char c) | |||||
{ | { | ||||
ee_draw_line(x1, y1, x1, y2, c); | |||||
ee_draw_line(x1, y2, x2, y2, c); | |||||
ee_draw_line(x2, y2, x2, y1, c); | |||||
ee_draw_line(x2, y1, x1, y1, c); | |||||
caca_draw_line(x1, y1, x1, y2, c); | |||||
caca_draw_line(x1, y2, x2, y2, c); | |||||
caca_draw_line(x2, y2, x2, y1, c); | |||||
caca_draw_line(x2, y1, x1, y1, c); | |||||
} | } | ||||
void ee_draw_thin_box(int x1, int y1, int x2, int y2) | |||||
void caca_draw_thin_box(int x1, int y1, int x2, int y2) | |||||
{ | { | ||||
int x, y, xmax, ymax; | int x, y, xmax, ymax; | ||||
@@ -51,8 +51,8 @@ void ee_draw_thin_box(int x1, int y1, int x2, int y2) | |||||
y1 = y2; y2 = tmp; | y1 = y2; y2 = tmp; | ||||
} | } | ||||
xmax = ee_get_width() - 1; | |||||
ymax = ee_get_height() - 1; | |||||
xmax = caca_get_width() - 1; | |||||
ymax = caca_get_height() - 1; | |||||
if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax) | if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax) | ||||
return; | return; | ||||
@@ -60,35 +60,35 @@ void ee_draw_thin_box(int x1, int y1, int x2, int y2) | |||||
/* Draw edges */ | /* Draw edges */ | ||||
if(y1 >= 0) | if(y1 >= 0) | ||||
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) | for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) | ||||
ee_putchar(x, y1, '-'); | |||||
caca_putchar(x, y1, '-'); | |||||
if(y2 <= ymax) | if(y2 <= ymax) | ||||
for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) | for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++) | ||||
ee_putchar(x, y2, '-'); | |||||
caca_putchar(x, y2, '-'); | |||||
if(x1 >= 0) | if(x1 >= 0) | ||||
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) | for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) | ||||
ee_putchar(x1, y, '|'); | |||||
caca_putchar(x1, y, '|'); | |||||
if(x2 <= xmax) | if(x2 <= xmax) | ||||
for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) | for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++) | ||||
ee_putchar(x2, y, '|'); | |||||
caca_putchar(x2, y, '|'); | |||||
/* Draw corners */ | /* Draw corners */ | ||||
if(x1 >= 0 && y1 >= 0) | if(x1 >= 0 && y1 >= 0) | ||||
ee_putchar(x1, y1, ','); | |||||
caca_putchar(x1, y1, ','); | |||||
if(x1 >= 0 && y2 <= ymax) | if(x1 >= 0 && y2 <= ymax) | ||||
ee_putchar(x1, y2, '`'); | |||||
caca_putchar(x1, y2, '`'); | |||||
if(x2 <= xmax && y1 >= 0) | if(x2 <= xmax && y1 >= 0) | ||||
ee_putchar(x2, y1, '.'); | |||||
caca_putchar(x2, y1, '.'); | |||||
if(x2 <= xmax && y2 <= ymax) | if(x2 <= xmax && y2 <= ymax) | ||||
ee_putchar(x2, y2, '\''); | |||||
caca_putchar(x2, y2, '\''); | |||||
} | } | ||||
void ee_fill_box(int x1, int y1, int x2, int y2, char c) | |||||
void caca_fill_box(int x1, int y1, int x2, int y2, char c) | |||||
{ | { | ||||
int x, y, xmax, ymax; | int x, y, xmax, ymax; | ||||
@@ -104,8 +104,8 @@ void ee_fill_box(int x1, int y1, int x2, int y2, char c) | |||||
y1 = y2; y2 = tmp; | y1 = y2; y2 = tmp; | ||||
} | } | ||||
xmax = ee_get_width() - 1; | |||||
ymax = ee_get_height() - 1; | |||||
xmax = caca_get_width() - 1; | |||||
ymax = caca_get_height() - 1; | |||||
if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax) | if(x2 < 0 || y2 < 0 || x1 > xmax || y1 > ymax) | ||||
return; | return; | ||||
@@ -117,6 +117,6 @@ void ee_fill_box(int x1, int y1, int x2, int y2, char c) | |||||
for(y = y1; y <= y2; y++) | for(y = y1; y <= y2; y++) | ||||
for(x = x1; x <= x2; x++) | for(x = x1; x <= x2; x++) | ||||
ee_putchar(x, y, c); | |||||
caca_putchar(x, y, c); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -42,24 +42,24 @@ | |||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <time.h> | #include <time.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
static unsigned int _ee_delay; | |||||
static unsigned int _ee_rendertime; | |||||
char *_ee_empty_line; | |||||
char *_ee_scratch_line; | |||||
static unsigned int _caca_delay; | |||||
static unsigned int _caca_rendertime; | |||||
char *_caca_empty_line; | |||||
char *_caca_scratch_line; | |||||
#if defined(USE_NCURSES) | #if defined(USE_NCURSES) | ||||
int _ee_attr[16]; | |||||
int _caca_attr[16]; | |||||
#endif | #endif | ||||
#if defined(USE_CONIO) | #if defined(USE_CONIO) | ||||
static struct text_info ti; | static struct text_info ti; | ||||
char *_ee_screen; | |||||
char *_caca_screen; | |||||
#endif | #endif | ||||
int ee_init(void) | |||||
int caca_init(void) | |||||
{ | { | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
static char *slang_colors[16] = | static char *slang_colors[16] = | ||||
@@ -143,38 +143,38 @@ int ee_init(void) | |||||
for(i = 0; i < 8; i++) | for(i = 0; i < 8; i++) | ||||
{ | { | ||||
_ee_attr[i] = COLOR_PAIR(1 + i); | |||||
_ee_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i); | |||||
_caca_attr[i] = COLOR_PAIR(1 + i); | |||||
_caca_attr[i + 8] = A_BOLD | COLOR_PAIR(1 + i); | |||||
} | } | ||||
#elif defined(USE_CONIO) | #elif defined(USE_CONIO) | ||||
gettextinfo(&ti); | gettextinfo(&ti); | ||||
_ee_screen = malloc(2 * ti.screenwidth * ti.screenheight); | |||||
if(_ee_screen == NULL) | |||||
_caca_screen = malloc(2 * ti.screenwidth * ti.screenheight); | |||||
if(_caca_screen == NULL) | |||||
return -1; | return -1; | ||||
_wscroll = 0; | _wscroll = 0; | ||||
_setcursortype(_NOCURSOR); | _setcursortype(_NOCURSOR); | ||||
clrscr(); | clrscr(); | ||||
# if defined(SCREENUPDATE_IN_PC_H) | # if defined(SCREENUPDATE_IN_PC_H) | ||||
ScreenRetrieve(_ee_screen); | |||||
ScreenRetrieve(_caca_screen); | |||||
# else | # else | ||||
/* FIXME */ | /* FIXME */ | ||||
# endif | # endif | ||||
#endif | #endif | ||||
_ee_empty_line = malloc(ee_get_width() + 1); | |||||
memset(_ee_empty_line, ' ', ee_get_width()); | |||||
_ee_empty_line[ee_get_width()] = '\0'; | |||||
_caca_empty_line = malloc(caca_get_width() + 1); | |||||
memset(_caca_empty_line, ' ', caca_get_width()); | |||||
_caca_empty_line[caca_get_width()] = '\0'; | |||||
_ee_scratch_line = malloc(ee_get_width() + 1); | |||||
_caca_scratch_line = malloc(caca_get_width() + 1); | |||||
_ee_delay = 0; | |||||
_ee_rendertime = 0; | |||||
_caca_delay = 0; | |||||
_caca_rendertime = 0; | |||||
return 0; | return 0; | ||||
} | } | ||||
unsigned int ee_get_width(void) | |||||
unsigned int caca_get_width(void) | |||||
{ | { | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
return SLtt_Screen_Cols; | return SLtt_Screen_Cols; | ||||
@@ -185,7 +185,7 @@ unsigned int ee_get_width(void) | |||||
#endif | #endif | ||||
} | } | ||||
unsigned int ee_get_height(void) | |||||
unsigned int caca_get_height(void) | |||||
{ | { | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
return SLtt_Screen_Rows; | return SLtt_Screen_Rows; | ||||
@@ -196,17 +196,17 @@ unsigned int ee_get_height(void) | |||||
#endif | #endif | ||||
} | } | ||||
void ee_set_delay(unsigned int usec) | |||||
void caca_set_delay(unsigned int usec) | |||||
{ | { | ||||
_ee_delay = usec; | |||||
_caca_delay = usec; | |||||
} | } | ||||
unsigned int ee_get_rendertime(void) | |||||
unsigned int caca_get_rendertime(void) | |||||
{ | { | ||||
return _ee_rendertime; | |||||
return _caca_rendertime; | |||||
} | } | ||||
const char *ee_get_color_name(unsigned int color) | |||||
const char *caca_get_color_name(unsigned int color) | |||||
{ | { | ||||
static const char *color_names[16] = | static const char *color_names[16] = | ||||
{ | { | ||||
@@ -234,7 +234,7 @@ const char *ee_get_color_name(unsigned int color) | |||||
return color_names[color]; | return color_names[color]; | ||||
} | } | ||||
static unsigned int _ee_getticks(void) | |||||
static unsigned int _caca_getticks(void) | |||||
{ | { | ||||
static unsigned int last_sec = 0, last_usec = 0; | static unsigned int last_sec = 0, last_usec = 0; | ||||
@@ -254,11 +254,11 @@ static unsigned int _ee_getticks(void) | |||||
return ticks; | return ticks; | ||||
} | } | ||||
void ee_refresh(void) | |||||
void caca_refresh(void) | |||||
{ | { | ||||
#define IDLE_USEC 10000 | #define IDLE_USEC 10000 | ||||
static unsigned int lastticks = 0; | static unsigned int lastticks = 0; | ||||
unsigned int ticks = lastticks + _ee_getticks(); | |||||
unsigned int ticks = lastticks + _caca_getticks(); | |||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
SLsmg_refresh(); | SLsmg_refresh(); | ||||
@@ -266,28 +266,28 @@ void ee_refresh(void) | |||||
refresh(); | refresh(); | ||||
#elif defined(USE_CONIO) | #elif defined(USE_CONIO) | ||||
# if defined(SCREENUPDATE_IN_PC_H) | # if defined(SCREENUPDATE_IN_PC_H) | ||||
ScreenUpdate(_ee_screen); | |||||
ScreenUpdate(_caca_screen); | |||||
# else | # else | ||||
/* FIXME */ | /* FIXME */ | ||||
# endif | # endif | ||||
#endif | #endif | ||||
/* Wait until _ee_delay + time of last call */ | |||||
ticks += _ee_getticks(); | |||||
for(; ticks < _ee_delay - IDLE_USEC; ticks += _ee_getticks()) | |||||
/* Wait until _caca_delay + time of last call */ | |||||
ticks += _caca_getticks(); | |||||
for(; ticks < _caca_delay - IDLE_USEC; ticks += _caca_getticks()) | |||||
usleep(IDLE_USEC); | usleep(IDLE_USEC); | ||||
/* Update the sliding mean of the render time */ | /* Update the sliding mean of the render time */ | ||||
_ee_rendertime = (7 * _ee_rendertime + ticks) / 8; | |||||
_caca_rendertime = (7 * _caca_rendertime + ticks) / 8; | |||||
lastticks = ticks - _ee_delay; | |||||
lastticks = ticks - _caca_delay; | |||||
/* If we drifted too much, it's bad, bad, bad. */ | /* If we drifted too much, it's bad, bad, bad. */ | ||||
if(lastticks > _ee_delay) | |||||
if(lastticks > _caca_delay) | |||||
lastticks = 0; | lastticks = 0; | ||||
} | } | ||||
void ee_end(void) | |||||
void caca_end(void) | |||||
{ | { | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
SLtt_set_cursor_visibility(1); | SLtt_set_cursor_visibility(1); | ||||
@@ -300,7 +300,7 @@ void ee_end(void) | |||||
_wscroll = 1; | _wscroll = 1; | ||||
textcolor((enum COLORS)WHITE); | textcolor((enum COLORS)WHITE); | ||||
textbackground((enum COLORS)BLACK); | textbackground((enum COLORS)BLACK); | ||||
gotoxy(ee_get_width(), ee_get_height()); | |||||
gotoxy(caca_get_width(), caca_get_height()); | |||||
cputs("\r\n"); | cputs("\r\n"); | ||||
_setcursortype(_NORMALCURSOR); | _setcursortype(_NORMALCURSOR); | ||||
#endif | #endif |
@@ -0,0 +1,116 @@ | |||||
/* | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | |||||
* All Rights Reserved | |||||
* | |||||
* $Id$ | |||||
* | |||||
* This program is free software; you can redistribute it and/or modify | |||||
* it under the terms of the GNU General Public License as published by | |||||
* the Free Software Foundation; either version 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this program; if not, write to the Free Software | |||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | |||||
#ifndef __EE_H__ | |||||
#define __EE_H__ | |||||
#ifdef __cplusplus | |||||
extern "C" | |||||
{ | |||||
#endif | |||||
/* | |||||
* Colors | |||||
*/ | |||||
enum caca_colors | |||||
{ | |||||
EE_BLACK = 0, | |||||
EE_BLUE = 1, | |||||
EE_GREEN = 2, | |||||
EE_CYAN = 3, | |||||
EE_RED = 4, | |||||
EE_MAGENTA = 5, | |||||
EE_BROWN = 6, | |||||
EE_LIGHTGRAY = 7, | |||||
EE_DARKGRAY = 8, | |||||
EE_LIGHTBLUE = 9, | |||||
EE_LIGHTGREEN = 10, | |||||
EE_LIGHTCYAN = 11, | |||||
EE_LIGHTRED = 12, | |||||
EE_LIGHTMAGENTA = 13, | |||||
EE_YELLOW = 14, | |||||
EE_WHITE = 15 | |||||
}; | |||||
/* | |||||
* Types | |||||
*/ | |||||
struct caca_sprite; | |||||
/* | |||||
* Prototypes | |||||
*/ | |||||
int caca_init(void); | |||||
void caca_set_delay(unsigned int); | |||||
unsigned int caca_get_rendertime(void); | |||||
unsigned int caca_get_width(void); | |||||
unsigned int caca_get_height(void); | |||||
const char *caca_get_color_name(unsigned int); | |||||
void caca_refresh(void); | |||||
void caca_end(void); | |||||
char caca_get_key(void); | |||||
void caca_set_color(int); | |||||
int caca_get_color(void); | |||||
void caca_putchar(int, int, char); | |||||
void caca_putstr(int, int, const char *); | |||||
void caca_printf(int, int, const char *, ...); | |||||
void caca_clear(void); | |||||
void caca_draw_line(int, int, int, int, char); | |||||
void caca_draw_polyline(const int[], const int[], int, char); | |||||
void caca_draw_thin_line(int, int, int, int); | |||||
void caca_draw_thin_polyline(const int[], const int[], int); | |||||
void caca_draw_circle(int, int, int, char); | |||||
void caca_draw_ellipse(int, int, int, int, char); | |||||
void caca_draw_thin_ellipse(int, int, int, int); | |||||
void caca_fill_ellipse(int, int, int, int, char); | |||||
void caca_draw_box(int, int, int, int, char); | |||||
void caca_draw_thin_box(int, int, int, int); | |||||
void caca_fill_box(int, int, int, int, char); | |||||
void caca_draw_triangle(int, int, int, int, int, int, char); | |||||
void caca_draw_thin_triangle(int, int, int, int, int, int); | |||||
void caca_fill_triangle(int, int, int, int, int, int, char); | |||||
int caca_rand(int, int); | |||||
unsigned int caca_sqrt(unsigned int); | |||||
struct caca_sprite * caca_load_sprite(const char *); | |||||
int caca_get_sprite_frames(struct caca_sprite *); | |||||
int caca_get_sprite_width(struct caca_sprite *, int); | |||||
int caca_get_sprite_height(struct caca_sprite *, int); | |||||
int caca_get_sprite_dx(struct caca_sprite *, int); | |||||
int caca_get_sprite_dy(struct caca_sprite *, int); | |||||
void caca_draw_sprite(int, int, struct caca_sprite *, int); | |||||
void caca_free_sprite(struct caca_sprite *); | |||||
void caca_blit(int, int, int, int, void *, int, int); | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif | |||||
#endif /* __EE_H__ */ |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -24,14 +24,14 @@ | |||||
#define __EE_INTERNALS_H__ | #define __EE_INTERNALS_H__ | ||||
#if defined(USE_NCURSES) | #if defined(USE_NCURSES) | ||||
extern int _ee_attr[]; | |||||
extern int _caca_attr[]; | |||||
#endif | #endif | ||||
#if defined(USE_CONIO) | #if defined(USE_CONIO) | ||||
extern char *_ee_screen; | |||||
extern char *_caca_screen; | |||||
#endif | #endif | ||||
extern char *_ee_empty_line; | |||||
extern char *_ee_scratch_line; | |||||
extern char *_caca_empty_line; | |||||
extern char *_caca_scratch_line; | |||||
#endif /* __EE_INTERNALS_H__ */ | #endif /* __EE_INTERNALS_H__ */ |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -30,12 +30,12 @@ typedef unsigned char uint8_t; | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
static void ellipsepoints(int, int, int, int, char); | static void ellipsepoints(int, int, int, int, char); | ||||
void ee_draw_circle(int x, int y, int r, char c) | |||||
void caca_draw_circle(int x, int y, int r, char c) | |||||
{ | { | ||||
int test, dx, dy; | int test, dx, dy; | ||||
@@ -49,7 +49,7 @@ void ee_draw_circle(int x, int y, int r, char c) | |||||
} | } | ||||
} | } | ||||
void ee_fill_ellipse(int xo, int yo, int a, int b, char c) | |||||
void caca_fill_ellipse(int xo, int yo, int a, int b, char c) | |||||
{ | { | ||||
int d2; | int d2; | ||||
int x = 0; | int x = 0; | ||||
@@ -65,15 +65,15 @@ void ee_fill_ellipse(int xo, int yo, int a, int b, char c) | |||||
else | else | ||||
{ | { | ||||
d1 += b*b*(2*x*1) + a*a*(-2*y+2); | d1 += b*b*(2*x*1) + a*a*(-2*y+2); | ||||
ee_draw_line(xo - x, yo - y, xo + x, yo - y, c); | |||||
ee_draw_line(xo - x, yo + y, xo + x, yo + y, c); | |||||
caca_draw_line(xo - x, yo - y, xo + x, yo - y, c); | |||||
caca_draw_line(xo - x, yo + y, xo + x, yo + y, c); | |||||
y--; | y--; | ||||
} | } | ||||
x++; | x++; | ||||
} | } | ||||
ee_draw_line(xo - x, yo - y, xo + x, yo - y, c); | |||||
ee_draw_line(xo - x, yo + y, xo + x, yo + y, c); | |||||
caca_draw_line(xo - x, yo - y, xo + x, yo - y, c); | |||||
caca_draw_line(xo - x, yo + y, xo + x, yo + y, c); | |||||
d2 = b*b*(x+0.5)*(x+0.5) + a*a*(y-1)*(y-1) - a*a*b*b; | d2 = b*b*(x+0.5)*(x+0.5) + a*a*(y-1)*(y-1) - a*a*b*b; | ||||
while(y > 0) | while(y > 0) | ||||
@@ -89,12 +89,12 @@ void ee_fill_ellipse(int xo, int yo, int a, int b, char c) | |||||
} | } | ||||
y--; | y--; | ||||
ee_draw_line(xo - x, yo - y, xo + x, yo - y, c); | |||||
ee_draw_line(xo - x, yo + y, xo + x, yo + y, c); | |||||
caca_draw_line(xo - x, yo - y, xo + x, yo - y, c); | |||||
caca_draw_line(xo - x, yo + y, xo + x, yo + y, c); | |||||
} | } | ||||
} | } | ||||
void ee_draw_ellipse(int xo, int yo, int a, int b, char c) | |||||
void caca_draw_ellipse(int xo, int yo, int a, int b, char c) | |||||
{ | { | ||||
int d2; | int d2; | ||||
int x = 0; | int x = 0; | ||||
@@ -136,7 +136,7 @@ void ee_draw_ellipse(int xo, int yo, int a, int b, char c) | |||||
} | } | ||||
} | } | ||||
void ee_draw_thin_ellipse(int xo, int yo, int a, int b) | |||||
void caca_draw_thin_ellipse(int xo, int yo, int a, int b) | |||||
{ | { | ||||
/* FIXME: this is not correct */ | /* FIXME: this is not correct */ | ||||
int d2; | int d2; | ||||
@@ -183,25 +183,25 @@ static void ellipsepoints(int xo, int yo, int x, int y, char c) | |||||
{ | { | ||||
uint8_t b = 0; | uint8_t b = 0; | ||||
if(xo + x >= 0 && xo + x < ee_get_width()) | |||||
if(xo + x >= 0 && xo + x < caca_get_width()) | |||||
b |= 0x1; | b |= 0x1; | ||||
if(xo - x >= 0 && xo - x < ee_get_width()) | |||||
if(xo - x >= 0 && xo - x < caca_get_width()) | |||||
b |= 0x2; | b |= 0x2; | ||||
if(yo + y >= 0 && yo + y < ee_get_height()) | |||||
if(yo + y >= 0 && yo + y < caca_get_height()) | |||||
b |= 0x4; | b |= 0x4; | ||||
if(yo - y >= 0 && yo - y < ee_get_height()) | |||||
if(yo - y >= 0 && yo - y < caca_get_height()) | |||||
b |= 0x8; | b |= 0x8; | ||||
if((b & (0x1|0x4)) == (0x1|0x4)) | if((b & (0x1|0x4)) == (0x1|0x4)) | ||||
ee_putchar(xo + x, yo + y, c); | |||||
caca_putchar(xo + x, yo + y, c); | |||||
if((b & (0x2|0x4)) == (0x2|0x4)) | if((b & (0x2|0x4)) == (0x2|0x4)) | ||||
ee_putchar(xo - x, yo + y, c); | |||||
caca_putchar(xo - x, yo + y, c); | |||||
if((b & (0x1|0x8)) == (0x1|0x8)) | if((b & (0x1|0x8)) == (0x1|0x8)) | ||||
ee_putchar(xo + x, yo - y, c); | |||||
caca_putchar(xo + x, yo - y, c); | |||||
if((b & (0x2|0x8)) == (0x2|0x8)) | if((b & (0x2|0x8)) == (0x2|0x8)) | ||||
ee_putchar(xo - x, yo - y, c); | |||||
caca_putchar(xo - x, yo - y, c); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -36,34 +36,34 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
static int _ee_color = 0; | |||||
static int _caca_color = 0; | |||||
void ee_set_color(int color) | |||||
void caca_set_color(int color) | |||||
{ | { | ||||
if(color < 0 || color > 15) | if(color < 0 || color > 15) | ||||
return; | return; | ||||
_ee_color = color; | |||||
_caca_color = color; | |||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
SLsmg_set_color(color + 1); | SLsmg_set_color(color + 1); | ||||
#elif defined(USE_NCURSES) | #elif defined(USE_NCURSES) | ||||
attrset(_ee_attr[color]); | |||||
attrset(_caca_attr[color]); | |||||
#elif defined(USE_CONIO) | #elif defined(USE_CONIO) | ||||
textcolor(color); | textcolor(color); | ||||
#endif | #endif | ||||
} | } | ||||
int ee_get_color(void) | |||||
int caca_get_color(void) | |||||
{ | { | ||||
return _ee_color; | |||||
return _caca_color; | |||||
} | } | ||||
void ee_putchar(int x, int y, char c) | |||||
void caca_putchar(int x, int y, char c) | |||||
{ | { | ||||
if(x < 0 || x >= ee_get_width() || y < 0 || y >= ee_get_height()) | |||||
if(x < 0 || x >= caca_get_width() || y < 0 || y >= caca_get_height()) | |||||
return; | return; | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
@@ -73,18 +73,18 @@ void ee_putchar(int x, int y, char c) | |||||
move(y, x); | move(y, x); | ||||
addch(c); | addch(c); | ||||
#elif defined(USE_CONIO) | #elif defined(USE_CONIO) | ||||
_ee_screen[2 * (x + y * ee_get_width())] = c; | |||||
_ee_screen[2 * (x + y * ee_get_width()) + 1] = _ee_color; | |||||
_caca_screen[2 * (x + y * caca_get_width())] = c; | |||||
_caca_screen[2 * (x + y * caca_get_width()) + 1] = _caca_color; | |||||
// gotoxy(x + 1, y + 1); | // gotoxy(x + 1, y + 1); | ||||
// putch(c); | // putch(c); | ||||
#endif | #endif | ||||
} | } | ||||
void ee_putstr(int x, int y, const char *s) | |||||
void caca_putstr(int x, int y, const char *s) | |||||
{ | { | ||||
int len; | int len; | ||||
if(y < 0 || y >= ee_get_height() || x >= ee_get_width()) | |||||
if(y < 0 || y >= caca_get_height() || x >= caca_get_width()) | |||||
return; | return; | ||||
len = strlen(s); | len = strlen(s); | ||||
@@ -98,11 +98,11 @@ void ee_putstr(int x, int y, const char *s) | |||||
x = 0; | x = 0; | ||||
} | } | ||||
if(x + len >= ee_get_width()) | |||||
if(x + len >= caca_get_width()) | |||||
{ | { | ||||
memcpy(_ee_scratch_line, s, ee_get_width() - x); | |||||
_ee_scratch_line[ee_get_width() - x] = '\0'; | |||||
s = _ee_scratch_line; | |||||
memcpy(_caca_scratch_line, s, caca_get_width() - x); | |||||
_caca_scratch_line[caca_get_width() - x] = '\0'; | |||||
s = _caca_scratch_line; | |||||
} | } | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
@@ -112,46 +112,46 @@ void ee_putstr(int x, int y, const char *s) | |||||
move(y, x); | move(y, x); | ||||
addstr(s); | addstr(s); | ||||
#elif defined(USE_CONIO) | #elif defined(USE_CONIO) | ||||
char *buf = _ee_screen + 2 * (x + y * ee_get_width()); | |||||
char *buf = _caca_screen + 2 * (x + y * caca_get_width()); | |||||
while(*s) | while(*s) | ||||
{ | { | ||||
*buf++ = *s++; | *buf++ = *s++; | ||||
*buf++ = _ee_color; | |||||
*buf++ = _caca_color; | |||||
} | } | ||||
// gotoxy(x + 1, y + 1); | // gotoxy(x + 1, y + 1); | ||||
// cputs(s); | // cputs(s); | ||||
#endif | #endif | ||||
} | } | ||||
void ee_printf(int x, int y, const char *format, ...) | |||||
void caca_printf(int x, int y, const char *format, ...) | |||||
{ | { | ||||
char tmp[BUFSIZ]; | char tmp[BUFSIZ]; | ||||
char *buf = tmp; | char *buf = tmp; | ||||
va_list args; | va_list args; | ||||
if(y < 0 || y >= ee_get_height() || x >= ee_get_width()) | |||||
if(y < 0 || y >= caca_get_height() || x >= caca_get_width()) | |||||
return; | return; | ||||
if(ee_get_width() - x + 1 > BUFSIZ) | |||||
buf = malloc(ee_get_width() - x + 1); | |||||
if(caca_get_width() - x + 1 > BUFSIZ) | |||||
buf = malloc(caca_get_width() - x + 1); | |||||
va_start(args, format); | va_start(args, format); | ||||
vsnprintf(buf, ee_get_width() - x + 1, format, args); | |||||
buf[ee_get_width() - x] = '\0'; | |||||
vsnprintf(buf, caca_get_width() - x + 1, format, args); | |||||
buf[caca_get_width() - x] = '\0'; | |||||
va_end(args); | va_end(args); | ||||
ee_putstr(x, y, buf); | |||||
caca_putstr(x, y, buf); | |||||
if(buf != tmp) | if(buf != tmp) | ||||
free(buf); | free(buf); | ||||
} | } | ||||
void ee_clear(void) | |||||
void caca_clear(void) | |||||
{ | { | ||||
/* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ | /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ | ||||
int y = ee_get_height(); | |||||
int y = caca_get_height(); | |||||
while(y--) | while(y--) | ||||
ee_putstr(0, y, _ee_empty_line); | |||||
caca_putstr(0, y, _caca_empty_line); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -32,10 +32,10 @@ | |||||
# error "no graphics library detected" | # error "no graphics library detected" | ||||
#endif | #endif | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
char ee_get_key(void) | |||||
char caca_get_key(void) | |||||
{ | { | ||||
#if defined(USE_SLANG) | #if defined(USE_SLANG) | ||||
return SLang_input_pending(0) ? SLang_getkey() : 0; | return SLang_input_pending(0) ? SLang_getkey() : 0; |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -30,8 +30,8 @@ typedef unsigned char uint8_t; | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
struct line | struct line | ||||
{ | { | ||||
@@ -56,7 +56,7 @@ static void draw_thin_line(struct line*); | |||||
* \param c Character to draw the line with. | * \param c Character to draw the line with. | ||||
* \return nothing | * \return nothing | ||||
*/ | */ | ||||
void ee_draw_line(int x1, int y1, int x2, int y2, char c) | |||||
void caca_draw_line(int x1, int y1, int x2, int y2, char c) | |||||
{ | { | ||||
struct line s; | struct line s; | ||||
s.x1 = x1; | s.x1 = x1; | ||||
@@ -68,7 +68,7 @@ void ee_draw_line(int x1, int y1, int x2, int y2, char c) | |||||
clip_line(&s); | clip_line(&s); | ||||
} | } | ||||
void ee_draw_polyline(const int x[], const int y[], int n, char c) | |||||
void caca_draw_polyline(const int x[], const int y[], int n, char c) | |||||
{ | { | ||||
int i; | int i; | ||||
struct line s; | struct line s; | ||||
@@ -94,7 +94,7 @@ void ee_draw_polyline(const int x[], const int y[], int n, char c) | |||||
* \param y2 Y coordinate of the second point. | * \param y2 Y coordinate of the second point. | ||||
* \return nothing | * \return nothing | ||||
*/ | */ | ||||
void ee_draw_thin_line(int x1, int y1, int x2, int y2) | |||||
void caca_draw_thin_line(int x1, int y1, int x2, int y2) | |||||
{ | { | ||||
struct line s; | struct line s; | ||||
s.x1 = x1; | s.x1 = x1; | ||||
@@ -105,7 +105,7 @@ void ee_draw_thin_line(int x1, int y1, int x2, int y2) | |||||
clip_line(&s); | clip_line(&s); | ||||
} | } | ||||
void ee_draw_thin_polyline(const int x[], const int y[], int n) | |||||
void caca_draw_thin_polyline(const int x[], const int y[], int n) | |||||
{ | { | ||||
int i; | int i; | ||||
struct line s; | struct line s; | ||||
@@ -163,7 +163,7 @@ static void clip_line(struct line* s) | |||||
} | } | ||||
else if(bits1 & (1<<1)) | else if(bits1 & (1<<1)) | ||||
{ | { | ||||
int xmax = ee_get_width() - 1; | |||||
int xmax = caca_get_width() - 1; | |||||
s->y1 = s->y2 - (s->x2 - xmax) * (s->y2 - s->y1) / (s->x2 - s->x1); | s->y1 = s->y2 - (s->x2 - xmax) * (s->y2 - s->y1) / (s->x2 - s->x1); | ||||
s->x1 = xmax; | s->x1 = xmax; | ||||
} | } | ||||
@@ -174,7 +174,7 @@ static void clip_line(struct line* s) | |||||
} | } | ||||
else if(bits1 & (1<<3)) | else if(bits1 & (1<<3)) | ||||
{ | { | ||||
int ymax = ee_get_height() - 1; | |||||
int ymax = caca_get_height() - 1; | |||||
s->x1 = s->x2 - (s->y2 - ymax) * (s->x2 - s->x1) / (s->y2 - s->y1); | s->x1 = s->x2 - (s->y2 - ymax) * (s->x2 - s->x1) / (s->y2 - s->y1); | ||||
s->y1 = ymax; | s->y1 = ymax; | ||||
} | } | ||||
@@ -195,12 +195,12 @@ static uint8_t clip_bits(int x, int y) | |||||
if(x < 0) | if(x < 0) | ||||
b |= (1<<0); | b |= (1<<0); | ||||
else if(x >= ee_get_width()) | |||||
else if(x >= caca_get_width()) | |||||
b |= (1<<1); | b |= (1<<1); | ||||
if(y < 0) | if(y < 0) | ||||
b |= (1<<2); | b |= (1<<2); | ||||
else if(y >= ee_get_height()) | |||||
else if(y >= caca_get_height()) | |||||
b |= (1<<3); | b |= (1<<3); | ||||
return b; | return b; | ||||
@@ -235,7 +235,7 @@ static void draw_solid_line(struct line* s) | |||||
for(; dx>=0; dx--) | for(; dx>=0; dx--) | ||||
{ | { | ||||
ee_putchar(x1, y1, s->c); | |||||
caca_putchar(x1, y1, s->c); | |||||
if(delta > 0) | if(delta > 0) | ||||
{ | { | ||||
x1 += xinc; | x1 += xinc; | ||||
@@ -257,7 +257,7 @@ static void draw_solid_line(struct line* s) | |||||
for(; dy >= 0; dy--) | for(; dy >= 0; dy--) | ||||
{ | { | ||||
ee_putchar(x1, y1, s->c); | |||||
caca_putchar(x1, y1, s->c); | |||||
if(delta > 0) | if(delta > 0) | ||||
{ | { | ||||
x1 += xinc; | x1 += xinc; | ||||
@@ -329,7 +329,7 @@ static void draw_thin_line(struct line* s) | |||||
{ | { | ||||
if(delta > 0) | if(delta > 0) | ||||
{ | { | ||||
ee_putchar(x1, y1, charmapy[1]); | |||||
caca_putchar(x1, y1, charmapy[1]); | |||||
x1++; | x1++; | ||||
y1 += yinc; | y1 += yinc; | ||||
delta += dpru; | delta += dpru; | ||||
@@ -338,9 +338,9 @@ static void draw_thin_line(struct line* s) | |||||
else | else | ||||
{ | { | ||||
if(prev) | if(prev) | ||||
ee_putchar(x1, y1, charmapy[0]); | |||||
caca_putchar(x1, y1, charmapy[0]); | |||||
else | else | ||||
ee_putchar(x1, y1, '-'); | |||||
caca_putchar(x1, y1, '-'); | |||||
x1++; | x1++; | ||||
delta += dpr; | delta += dpr; | ||||
prev = 0; | prev = 0; | ||||
@@ -357,15 +357,15 @@ static void draw_thin_line(struct line* s) | |||||
{ | { | ||||
if(delta > 0) | if(delta > 0) | ||||
{ | { | ||||
ee_putchar(x1, y1, charmapx[0]); | |||||
ee_putchar(x1 + 1, y1, charmapx[1]); | |||||
caca_putchar(x1, y1, charmapx[0]); | |||||
caca_putchar(x1 + 1, y1, charmapx[1]); | |||||
x1++; | x1++; | ||||
y1 += yinc; | y1 += yinc; | ||||
delta += dpru; | delta += dpru; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
ee_putchar(x1, y1, '|'); | |||||
caca_putchar(x1, y1, '|'); | |||||
y1 += yinc; | y1 += yinc; | ||||
delta += dpr; | delta += dpr; | ||||
} | } |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -24,15 +24,15 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
int ee_rand(int min, int max) | |||||
int caca_rand(int min, int max) | |||||
{ | { | ||||
return min + (int)((1.0*(max-min+1)) * rand() / (RAND_MAX+1.0)); | return min + (int)((1.0*(max-min+1)) * rand() / (RAND_MAX+1.0)); | ||||
} | } | ||||
unsigned int ee_sqrt(unsigned int a) | |||||
unsigned int caca_sqrt(unsigned int a) | |||||
{ | { | ||||
if(a == 0) | if(a == 0) | ||||
return 0; | return 0; | ||||
@@ -54,6 +54,6 @@ unsigned int ee_sqrt(unsigned int a) | |||||
return x; | return x; | ||||
} | } | ||||
return 2 * ee_sqrt(a / 4); | |||||
return 2 * caca_sqrt(a / 4); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -26,10 +26,10 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
struct ee_frame | |||||
struct caca_frame | |||||
{ | { | ||||
int w, h; | int w, h; | ||||
int dx, dy; | int dx, dy; | ||||
@@ -37,23 +37,23 @@ struct ee_frame | |||||
int *color; | int *color; | ||||
}; | }; | ||||
struct ee_sprite | |||||
struct caca_sprite | |||||
{ | { | ||||
int nf; | int nf; | ||||
struct ee_frame *frames; | |||||
struct caca_frame *frames; | |||||
}; | }; | ||||
struct ee_sprite *ee_load_sprite(const char *file) | |||||
struct caca_sprite *caca_load_sprite(const char *file) | |||||
{ | { | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
struct ee_sprite *sprite; | |||||
struct caca_sprite *sprite; | |||||
FILE *fd; | FILE *fd; | ||||
fd = fopen(file, "r"); | fd = fopen(file, "r"); | ||||
if(fd == NULL) | if(fd == NULL) | ||||
return NULL; | return NULL; | ||||
sprite = malloc(sizeof(struct ee_sprite)); | |||||
sprite = malloc(sizeof(struct caca_sprite)); | |||||
if(sprite == NULL) | if(sprite == NULL) | ||||
goto sprite_alloc_failed; | goto sprite_alloc_failed; | ||||
@@ -64,7 +64,7 @@ struct ee_sprite *ee_load_sprite(const char *file) | |||||
{ | { | ||||
int x, y; | int x, y; | ||||
int w = 0, h = 0, dx = 0, dy = 0; | int w = 0, h = 0, dx = 0, dy = 0; | ||||
struct ee_frame *frame; | |||||
struct caca_frame *frame; | |||||
/* Get width and height */ | /* Get width and height */ | ||||
if(!fgets(buf, BUFSIZ, fd)) | if(!fgets(buf, BUFSIZ, fd)) | ||||
@@ -77,7 +77,7 @@ struct ee_sprite *ee_load_sprite(const char *file) | |||||
if(sprite->nf) | if(sprite->nf) | ||||
{ | { | ||||
void *tmp = realloc(sprite->frames, | void *tmp = realloc(sprite->frames, | ||||
(sprite->nf + 1) * sizeof(struct ee_frame)); | |||||
(sprite->nf + 1) * sizeof(struct caca_frame)); | |||||
if(tmp == NULL) | if(tmp == NULL) | ||||
goto frame_failed; | goto frame_failed; | ||||
sprite->frames = tmp; | sprite->frames = tmp; | ||||
@@ -85,7 +85,7 @@ struct ee_sprite *ee_load_sprite(const char *file) | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
sprite->frames = malloc((sprite->nf + 1) * sizeof(struct ee_frame)); | |||||
sprite->frames = malloc((sprite->nf + 1) * sizeof(struct caca_frame)); | |||||
if(sprite->frames == NULL) | if(sprite->frames == NULL) | ||||
goto sprite_failed; | goto sprite_failed; | ||||
sprite->nf++; | sprite->nf++; | ||||
@@ -158,7 +158,7 @@ sprite_alloc_failed: | |||||
return NULL; | return NULL; | ||||
} | } | ||||
int ee_get_sprite_frames(struct ee_sprite *sprite) | |||||
int caca_get_sprite_frames(struct caca_sprite *sprite) | |||||
{ | { | ||||
if(sprite == NULL) | if(sprite == NULL) | ||||
return 0; | return 0; | ||||
@@ -166,7 +166,7 @@ int ee_get_sprite_frames(struct ee_sprite *sprite) | |||||
return sprite->nf; | return sprite->nf; | ||||
} | } | ||||
int ee_get_sprite_width(struct ee_sprite *sprite, int f) | |||||
int caca_get_sprite_width(struct caca_sprite *sprite, int f) | |||||
{ | { | ||||
if(sprite == NULL) | if(sprite == NULL) | ||||
return 0; | return 0; | ||||
@@ -177,7 +177,7 @@ int ee_get_sprite_width(struct ee_sprite *sprite, int f) | |||||
return sprite->frames[f].w; | return sprite->frames[f].w; | ||||
} | } | ||||
int ee_get_sprite_height(struct ee_sprite *sprite, int f) | |||||
int caca_get_sprite_height(struct caca_sprite *sprite, int f) | |||||
{ | { | ||||
if(sprite == NULL) | if(sprite == NULL) | ||||
return 0; | return 0; | ||||
@@ -188,7 +188,7 @@ int ee_get_sprite_height(struct ee_sprite *sprite, int f) | |||||
return sprite->frames[f].h; | return sprite->frames[f].h; | ||||
} | } | ||||
int ee_get_sprite_dx(struct ee_sprite *sprite, int f) | |||||
int caca_get_sprite_dx(struct caca_sprite *sprite, int f) | |||||
{ | { | ||||
if(sprite == NULL) | if(sprite == NULL) | ||||
return 0; | return 0; | ||||
@@ -199,7 +199,7 @@ int ee_get_sprite_dx(struct ee_sprite *sprite, int f) | |||||
return sprite->frames[f].dx; | return sprite->frames[f].dx; | ||||
} | } | ||||
int ee_get_sprite_dy(struct ee_sprite *sprite, int f) | |||||
int caca_get_sprite_dy(struct caca_sprite *sprite, int f) | |||||
{ | { | ||||
if(sprite == NULL) | if(sprite == NULL) | ||||
return 0; | return 0; | ||||
@@ -210,10 +210,10 @@ int ee_get_sprite_dy(struct ee_sprite *sprite, int f) | |||||
return sprite->frames[f].dy; | return sprite->frames[f].dy; | ||||
} | } | ||||
void ee_draw_sprite(int x, int y, struct ee_sprite *sprite, int f) | |||||
void caca_draw_sprite(int x, int y, struct caca_sprite *sprite, int f) | |||||
{ | { | ||||
int i, j, oldcol; | int i, j, oldcol; | ||||
struct ee_frame *frame; | |||||
struct caca_frame *frame; | |||||
if(sprite == NULL) | if(sprite == NULL) | ||||
return; | return; | ||||
@@ -223,7 +223,7 @@ void ee_draw_sprite(int x, int y, struct ee_sprite *sprite, int f) | |||||
frame = &sprite->frames[f]; | frame = &sprite->frames[f]; | ||||
oldcol = ee_get_color(); | |||||
oldcol = caca_get_color(); | |||||
for(j = 0; j < frame->h; j++) | for(j = 0; j < frame->h; j++) | ||||
{ | { | ||||
@@ -232,17 +232,17 @@ void ee_draw_sprite(int x, int y, struct ee_sprite *sprite, int f) | |||||
int col = frame->color[frame->w * j + i]; | int col = frame->color[frame->w * j + i]; | ||||
if(col >= 0) | if(col >= 0) | ||||
{ | { | ||||
ee_set_color(col); | |||||
ee_putchar(x + i - frame->dx, y + j - frame->dy, | |||||
caca_set_color(col); | |||||
caca_putchar(x + i - frame->dx, y + j - frame->dy, | |||||
frame->chars[frame->w * j + i]); | frame->chars[frame->w * j + i]); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
ee_set_color(oldcol); | |||||
caca_set_color(oldcol); | |||||
} | } | ||||
void ee_free_sprite(struct ee_sprite *sprite) | |||||
void caca_free_sprite(struct caca_sprite *sprite) | |||||
{ | { | ||||
int i; | int i; | ||||
@@ -251,7 +251,7 @@ void ee_free_sprite(struct ee_sprite *sprite) | |||||
for(i = sprite->nf; i--;) | for(i = sprite->nf; i--;) | ||||
{ | { | ||||
struct ee_frame *frame = &sprite->frames[i]; | |||||
struct caca_frame *frame = &sprite->frames[i]; | |||||
free(frame->chars); | free(frame->chars); | ||||
free(frame->color); | free(frame->color); | ||||
} | } |
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* libee ASCII-Art library | |||||
* libcaca ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -24,37 +24,37 @@ | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "ee.h" | |||||
#include "ee_internals.h" | |||||
#include "caca.h" | |||||
#include "caca_internals.h" | |||||
void ee_draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||||
void caca_draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||||
{ | { | ||||
ee_draw_line(x1, y1, x2, y2, c); | |||||
ee_draw_line(x2, y2, x3, y3, c); | |||||
ee_draw_line(x3, y3, x1, y1, c); | |||||
caca_draw_line(x1, y1, x2, y2, c); | |||||
caca_draw_line(x2, y2, x3, y3, c); | |||||
caca_draw_line(x3, y3, x1, y1, c); | |||||
} | } | ||||
void ee_draw_thin_triangle(int x1, int y1, int x2, int y2, int x3, int y3) | |||||
void caca_draw_thin_triangle(int x1, int y1, int x2, int y2, int x3, int y3) | |||||
{ | { | ||||
ee_draw_thin_line(x1, y1, x2, y2); | |||||
ee_draw_thin_line(x2, y2, x3, y3); | |||||
ee_draw_thin_line(x3, y3, x1, y1); | |||||
caca_draw_thin_line(x1, y1, x2, y2); | |||||
caca_draw_thin_line(x2, y2, x3, y3); | |||||
caca_draw_thin_line(x3, y3, x1, y1); | |||||
} | } | ||||
void ee_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||||
void caca_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||||
{ | { | ||||
int x, y, xa, xb, xmax, ymax; | int x, y, xa, xb, xmax, ymax; | ||||
/* Bubble-sort y1 <= y2 <= y3 */ | /* Bubble-sort y1 <= y2 <= y3 */ | ||||
if(y1 > y2) | if(y1 > y2) | ||||
{ | { | ||||
ee_fill_triangle(x2, y2, x1, y1, x3, y3, c); | |||||
caca_fill_triangle(x2, y2, x1, y1, x3, y3, c); | |||||
return; | return; | ||||
} | } | ||||
if(y2 > y3) | if(y2 > y3) | ||||
{ | { | ||||
ee_fill_triangle(x1, y1, x3, y3, x2, y2, c); | |||||
caca_fill_triangle(x1, y1, x3, y3, x2, y2, c); | |||||
return; | return; | ||||
} | } | ||||
@@ -63,8 +63,8 @@ void ee_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||||
x2 *= 4; | x2 *= 4; | ||||
x3 *= 4; | x3 *= 4; | ||||
xmax = ee_get_width() - 1; | |||||
ymax = ee_get_height() - 1; | |||||
xmax = caca_get_width() - 1; | |||||
ymax = caca_get_height() - 1; | |||||
/* Rasterize our triangle */ | /* Rasterize our triangle */ | ||||
for(y = y1 < 0 ? 0 : y1; y <= y3 && y <= ymax; y++) | for(y = y1 < 0 ? 0 : y1; y <= y3 && y <= ymax; y++) | ||||
@@ -96,7 +96,7 @@ void ee_fill_triangle(int x1, int y1, int x2, int y2, int x3, int y3, char c) | |||||
if(xb > xmax) xb = xmax; | if(xb > xmax) xb = xmax; | ||||
for(x = xa; x <= xb; x++) | for(x = xa; x <= xb; x++) | ||||
ee_putchar(x, y, c); | |||||
caca_putchar(x, y, c); | |||||
} | } | ||||
} | } | ||||
@@ -1,116 +0,0 @@ | |||||
/* | |||||
* libee ASCII-Art library | |||||
* Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org> | |||||
* All Rights Reserved | |||||
* | |||||
* $Id$ | |||||
* | |||||
* This program is free software; you can redistribute it and/or modify | |||||
* it under the terms of the GNU General Public License as published by | |||||
* the Free Software Foundation; either version 2 of the License, or | |||||
* (at your option) any later version. | |||||
* | |||||
* This program is distributed in the hope that it will be useful, | |||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
* GNU General Public License for more details. | |||||
* | |||||
* You should have received a copy of the GNU General Public License | |||||
* along with this program; if not, write to the Free Software | |||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
*/ | |||||
#ifndef __EE_H__ | |||||
#define __EE_H__ | |||||
#ifdef __cplusplus | |||||
extern "C" | |||||
{ | |||||
#endif | |||||
/* | |||||
* Colors | |||||
*/ | |||||
enum ee_colors | |||||
{ | |||||
EE_BLACK = 0, | |||||
EE_BLUE = 1, | |||||
EE_GREEN = 2, | |||||
EE_CYAN = 3, | |||||
EE_RED = 4, | |||||
EE_MAGENTA = 5, | |||||
EE_BROWN = 6, | |||||
EE_LIGHTGRAY = 7, | |||||
EE_DARKGRAY = 8, | |||||
EE_LIGHTBLUE = 9, | |||||
EE_LIGHTGREEN = 10, | |||||
EE_LIGHTCYAN = 11, | |||||
EE_LIGHTRED = 12, | |||||
EE_LIGHTMAGENTA = 13, | |||||
EE_YELLOW = 14, | |||||
EE_WHITE = 15 | |||||
}; | |||||
/* | |||||
* Types | |||||
*/ | |||||
struct ee_sprite; | |||||
/* | |||||
* Prototypes | |||||
*/ | |||||
int ee_init(void); | |||||
void ee_set_delay(unsigned int); | |||||
unsigned int ee_get_rendertime(void); | |||||
unsigned int ee_get_width(void); | |||||
unsigned int ee_get_height(void); | |||||
const char *ee_get_color_name(unsigned int); | |||||
void ee_refresh(void); | |||||
void ee_end(void); | |||||
char ee_get_key(void); | |||||
void ee_set_color(int); | |||||
int ee_get_color(void); | |||||
void ee_putchar(int, int, char); | |||||
void ee_putstr(int, int, const char *); | |||||
void ee_printf(int, int, const char *, ...); | |||||
void ee_clear(void); | |||||
void ee_draw_line(int, int, int, int, char); | |||||
void ee_draw_polyline(const int[], const int[], int, char); | |||||
void ee_draw_thin_line(int, int, int, int); | |||||
void ee_draw_thin_polyline(const int[], const int[], int); | |||||
void ee_draw_circle(int, int, int, char); | |||||
void ee_draw_ellipse(int, int, int, int, char); | |||||
void ee_draw_thin_ellipse(int, int, int, int); | |||||
void ee_fill_ellipse(int, int, int, int, char); | |||||
void ee_draw_box(int, int, int, int, char); | |||||
void ee_draw_thin_box(int, int, int, int); | |||||
void ee_fill_box(int, int, int, int, char); | |||||
void ee_draw_triangle(int, int, int, int, int, int, char); | |||||
void ee_draw_thin_triangle(int, int, int, int, int, int); | |||||
void ee_fill_triangle(int, int, int, int, int, int, char); | |||||
int ee_rand(int, int); | |||||
unsigned int ee_sqrt(unsigned int); | |||||
struct ee_sprite * ee_load_sprite(const char *); | |||||
int ee_get_sprite_frames(struct ee_sprite *); | |||||
int ee_get_sprite_width(struct ee_sprite *, int); | |||||
int ee_get_sprite_height(struct ee_sprite *, int); | |||||
int ee_get_sprite_dx(struct ee_sprite *, int); | |||||
int ee_get_sprite_dy(struct ee_sprite *, int); | |||||
void ee_draw_sprite(int, int, struct ee_sprite *, int); | |||||
void ee_free_sprite(struct ee_sprite *); | |||||
void ee_blit(int, int, int, int, void *, int, int); | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif | |||||
#endif /* __EE_H__ */ |
@@ -2,7 +2,7 @@ | |||||
# Automake targets and declarations for ttyvaders | # Automake targets and declarations for ttyvaders | ||||
############################################################################### | ############################################################################### | ||||
AM_CPPFLAGS = -I$(top_srcdir)/libee | |||||
AM_CPPFLAGS = -I$(top_srcdir)/libcaca | |||||
if USE_SLANG | if USE_SLANG | ||||
LDFLAGS_slang = -lslang | LDFLAGS_slang = -lslang | ||||
@@ -29,5 +29,5 @@ ttyvaders_SOURCES = \ | |||||
tunnel.c \ | tunnel.c \ | ||||
weapons.c \ | weapons.c \ | ||||
$(NULL) | $(NULL) | ||||
ttyvaders_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm | |||||
ttyvaders_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm | |||||
@@ -26,9 +26,9 @@ | |||||
#include "common.h" | #include "common.h" | ||||
struct ee_sprite *foo_sprite; | |||||
struct ee_sprite *bar_sprite; | |||||
struct ee_sprite *baz_sprite; | |||||
struct caca_sprite *foo_sprite; | |||||
struct caca_sprite *bar_sprite; | |||||
struct caca_sprite *baz_sprite; | |||||
void init_aliens(game *g, aliens *al) | void init_aliens(game *g, aliens *al) | ||||
{ | { | ||||
@@ -39,9 +39,9 @@ void init_aliens(game *g, aliens *al) | |||||
al->type[i] = ALIEN_NONE; | al->type[i] = ALIEN_NONE; | ||||
} | } | ||||
foo_sprite = ee_load_sprite("data/foofight.txt"); | |||||
bar_sprite = ee_load_sprite("data/barfight.txt"); | |||||
baz_sprite = ee_load_sprite("data/bazfight.txt"); | |||||
foo_sprite = caca_load_sprite("data/foofight.txt"); | |||||
bar_sprite = caca_load_sprite("data/barfight.txt"); | |||||
baz_sprite = caca_load_sprite("data/bazfight.txt"); | |||||
} | } | ||||
void draw_aliens(game *g, aliens *al) | void draw_aliens(game *g, aliens *al) | ||||
@@ -53,13 +53,13 @@ void draw_aliens(game *g, aliens *al) | |||||
switch(al->type[i]) | switch(al->type[i]) | ||||
{ | { | ||||
case ALIEN_FOO: | case ALIEN_FOO: | ||||
ee_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8); | |||||
caca_draw_sprite(al->x[i], al->y[i], foo_sprite, al->img[i] % 8); | |||||
break; | break; | ||||
case ALIEN_BAR: | case ALIEN_BAR: | ||||
ee_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2); | |||||
caca_draw_sprite(al->x[i], al->y[i], bar_sprite, al->img[i] % 2); | |||||
break; | break; | ||||
case ALIEN_BAZ: | case ALIEN_BAZ: | ||||
ee_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6); | |||||
caca_draw_sprite(al->x[i], al->y[i], baz_sprite, al->img[i] % 6); | |||||
break; | break; | ||||
case ALIEN_NONE: | case ALIEN_NONE: | ||||
break; | break; | ||||
@@ -78,7 +78,7 @@ void update_aliens(game *g, aliens *al) | |||||
{ | { | ||||
add_explosion(g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM); | add_explosion(g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM); | ||||
al->type[i] = ALIEN_NONE; | al->type[i] = ALIEN_NONE; | ||||
add_bonus(g, g->bo, al->x[i], al->y[i], ee_rand(0,4) ? BONUS_GREEN : BONUS_LIFE); | |||||
add_bonus(g, g->bo, al->x[i], al->y[i], caca_rand(0,4) ? BONUS_GREEN : BONUS_LIFE); | |||||
} | } | ||||
/* Update coordinates */ | /* Update coordinates */ | ||||
@@ -26,8 +26,8 @@ | |||||
#include "common.h" | #include "common.h" | ||||
struct ee_sprite *heart_sprite; | |||||
struct ee_sprite *gem_sprite; | |||||
struct caca_sprite *heart_sprite; | |||||
struct caca_sprite *gem_sprite; | |||||
void init_bonus(game *g, bonus *bo) | void init_bonus(game *g, bonus *bo) | ||||
{ | { | ||||
@@ -38,8 +38,8 @@ void init_bonus(game *g, bonus *bo) | |||||
bo->type[i] = BONUS_NONE; | bo->type[i] = BONUS_NONE; | ||||
} | } | ||||
heart_sprite = ee_load_sprite("data/bonheart.txt"); | |||||
gem_sprite = ee_load_sprite("data/bongem.txt"); | |||||
heart_sprite = caca_load_sprite("data/bonheart.txt"); | |||||
gem_sprite = caca_load_sprite("data/bongem.txt"); | |||||
} | } | ||||
void draw_bonus(game *g, bonus *bo) | void draw_bonus(game *g, bonus *bo) | ||||
@@ -51,11 +51,11 @@ void draw_bonus(game *g, bonus *bo) | |||||
switch(bo->type[i]) | switch(bo->type[i]) | ||||
{ | { | ||||
case BONUS_GREEN: | case BONUS_GREEN: | ||||
ee_draw_sprite(bo->x[i], bo->y[i], gem_sprite, | |||||
caca_draw_sprite(bo->x[i], bo->y[i], gem_sprite, | |||||
(bo->n[i]/2 % 3) ? 0 : 1); | (bo->n[i]/2 % 3) ? 0 : 1); | ||||
break; | break; | ||||
case BONUS_LIFE: | case BONUS_LIFE: | ||||
ee_draw_sprite(bo->x[i], bo->y[i], heart_sprite, | |||||
caca_draw_sprite(bo->x[i], bo->y[i], heart_sprite, | |||||
(bo->n[i] % 3) ? 0 : 1); | (bo->n[i] % 3) ? 0 : 1); | ||||
break; | break; | ||||
case BONUS_NONE: | case BONUS_NONE: | ||||
@@ -45,12 +45,12 @@ void draw_box(game *g, box *b) | |||||
{ | { | ||||
int j, frame; | int j, frame; | ||||
ee_set_color(EE_YELLOW); | |||||
caca_set_color(EE_YELLOW); | |||||
/* Draw the thin horizontal line */ | /* Draw the thin horizontal line */ | ||||
if(b->frame < 8) | if(b->frame < 8) | ||||
{ | { | ||||
ee_draw_line(b->x - b->w * b->frame / 16, b->y, | |||||
caca_draw_line(b->x - b->w * b->frame / 16, b->y, | |||||
b->x + b->w * b->frame / 16 - 1, b->y, 'X'); | b->x + b->w * b->frame / 16 - 1, b->y, 'X'); | ||||
return; | return; | ||||
} | } | ||||
@@ -58,23 +58,23 @@ void draw_box(game *g, box *b) | |||||
/* Draw the frame */ | /* Draw the frame */ | ||||
frame = b->frame < 12 ? b->frame : 12; | frame = b->frame < 12 ? b->frame : 12; | ||||
ee_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8, | |||||
caca_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8, | |||||
b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X'); | b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X'); | ||||
ee_draw_line(b->x - b->w / 2, b->y + b->h * (frame - 8) / 8, | |||||
caca_draw_line(b->x - b->w / 2, b->y + b->h * (frame - 8) / 8, | |||||
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X'); | b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X'); | ||||
ee_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8, | |||||
caca_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8, | |||||
b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X'); | b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X'); | ||||
ee_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, | |||||
caca_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, | |||||
b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X'); | b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X'); | ||||
ee_set_color(EE_BLACK); | |||||
caca_set_color(EE_BLACK); | |||||
for(j = b->y - b->h * (frame - 8) / 8 + 1; | for(j = b->y - b->h * (frame - 8) / 8 + 1; | ||||
j < b->y + b->h * (frame - 8) / 8; | j < b->y + b->h * (frame - 8) / 8; | ||||
j++) | j++) | ||||
{ | { | ||||
ee_draw_line(b->x - b->w / 2 + 1, j, | |||||
caca_draw_line(b->x - b->w / 2 + 1, j, | |||||
b->x + b->w / 2 - 2, j, 'X'); | b->x + b->w / 2 - 2, j, 'X'); | ||||
} | } | ||||
@@ -84,18 +84,18 @@ void draw_box(game *g, box *b) | |||||
} | } | ||||
/* Draw the text inside the frame */ | /* Draw the text inside the frame */ | ||||
ee_set_color(EE_YELLOW); | |||||
caca_set_color(EE_YELLOW); | |||||
/* FIXME: use a font */ | /* FIXME: use a font */ | ||||
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, | |||||
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2, | |||||
"XXXX. .XXXX X X .XXXX .XXXX XXXX."); | "XXXX. .XXXX X X .XXXX .XXXX XXXX."); | ||||
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3, | |||||
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3, | |||||
"X `X X' X X X X' X' X `X"); | "X `X X' X X X X' X' X `X"); | ||||
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4, | |||||
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4, | |||||
"XXXX' XXXXX X X `XXX XXXX X X"); | "XXXX' XXXXX X X `XXX XXXX X X"); | ||||
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5, | |||||
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5, | |||||
"X' X' `X X. ,X `X X' X ,X"); | "X' X' `X X. ,X `X X' X ,X"); | ||||
ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6, | |||||
caca_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6, | |||||
"X X X `XXXX XXXX' `XXXX XXXX'"); | "X X X `XXXX XXXX' `XXXX XXXX'"); | ||||
} | } | ||||
@@ -33,16 +33,16 @@ void ceo_alert(game *g) | |||||
while(!end) | while(!end) | ||||
{ | { | ||||
ee_clear(); | |||||
caca_clear(); | |||||
if(ee_get_key() == '\t') | |||||
if(caca_get_key() == '\t') | |||||
{ | { | ||||
end = 1; | end = 1; | ||||
} | } | ||||
fprintf(stderr, "foo\n"); | fprintf(stderr, "foo\n"); | ||||
ee_refresh(); | |||||
caca_refresh(); | |||||
usleep(40000); | usleep(40000); | ||||
} | } | ||||
@@ -127,12 +127,12 @@ void collide_weapons_tunnel(game *g, weapons *wp, tunnel *t, explosions *ex) | |||||
if(x - 2 <= t->left[y-j]) | if(x - 2 <= t->left[y-j]) | ||||
{ | { | ||||
add_explosion(g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL); | add_explosion(g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL); | ||||
t->left[y-j] -= ee_rand(0,2); | |||||
t->left[y-j] -= caca_rand(0,2); | |||||
} | } | ||||
else if(x + 3 >= t->right[y-j]) | else if(x + 3 >= t->right[y-j]) | ||||
{ | { | ||||
add_explosion(g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL); | add_explosion(g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL); | ||||
t->right[y-j] += ee_rand(0,2); | |||||
t->right[y-j] += caca_rand(0,2); | |||||
} | } | ||||
} | } | ||||
break; | break; | ||||
@@ -44,7 +44,7 @@ void intro(void); | |||||
/* | /* | ||||
* Graphics primitives | * Graphics primitives | ||||
*/ | */ | ||||
#include "ee.h" | |||||
#include "caca.h" | |||||
/* | /* | ||||
* Useful macros | * Useful macros | ||||
@@ -26,8 +26,8 @@ | |||||
#include "common.h" | #include "common.h" | ||||
struct ee_sprite *medium_sprite; | |||||
struct ee_sprite *small_sprite; | |||||
struct caca_sprite *medium_sprite; | |||||
struct caca_sprite *small_sprite; | |||||
void init_explosions(game *g, explosions *ex) | void init_explosions(game *g, explosions *ex) | ||||
{ | { | ||||
@@ -38,8 +38,8 @@ void init_explosions(game *g, explosions *ex) | |||||
ex->type[i] = EXPLOSION_NONE; | ex->type[i] = EXPLOSION_NONE; | ||||
} | } | ||||
medium_sprite = ee_load_sprite("data/xplmed.txt"); | |||||
small_sprite = ee_load_sprite("data/xplsmall.txt"); | |||||
medium_sprite = caca_load_sprite("data/xplmed.txt"); | |||||
small_sprite = caca_load_sprite("data/xplsmall.txt"); | |||||
} | } | ||||
void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type) | void add_explosion(game *g, explosions *ex, int x, int y, int vx, int vy, int type) | ||||
@@ -76,38 +76,38 @@ void draw_explosions(game *g, explosions *ex) | |||||
for(i = 0; i < EXPLOSIONS; i++) | for(i = 0; i < EXPLOSIONS; i++) | ||||
{ | { | ||||
#if 0 | #if 0 | ||||
ee_set_color(GREEN); | |||||
ee_goto(ex->x[i] + 3, ex->y[i]); | |||||
switch(ee_rand(0,2)) | |||||
caca_set_color(GREEN); | |||||
caca_goto(ex->x[i] + 3, ex->y[i]); | |||||
switch(caca_rand(0,2)) | |||||
{ | { | ||||
case 0: | case 0: | ||||
ee_putchar('p'); | |||||
ee_putchar('i'); | |||||
ee_putchar('f'); | |||||
caca_putchar('p'); | |||||
caca_putchar('i'); | |||||
caca_putchar('f'); | |||||
break; | break; | ||||
case 1: | case 1: | ||||
ee_putchar('p'); | |||||
ee_putchar('a'); | |||||
ee_putchar('f'); | |||||
caca_putchar('p'); | |||||
caca_putchar('a'); | |||||
caca_putchar('f'); | |||||
break; | break; | ||||
case 2: | case 2: | ||||
ee_putchar('p'); | |||||
ee_putchar('o'); | |||||
ee_putchar('u'); | |||||
ee_putchar('f'); | |||||
caca_putchar('p'); | |||||
caca_putchar('o'); | |||||
caca_putchar('u'); | |||||
caca_putchar('f'); | |||||
break; | break; | ||||
} | } | ||||
ee_putchar('!'); | |||||
caca_putchar('!'); | |||||
#endif | #endif | ||||
switch(ex->type[i]) | switch(ex->type[i]) | ||||
{ | { | ||||
case EXPLOSION_MEDIUM: | case EXPLOSION_MEDIUM: | ||||
ee_draw_sprite(ex->x[i], ex->y[i], medium_sprite, | |||||
caca_draw_sprite(ex->x[i], ex->y[i], medium_sprite, | |||||
10 - ex->n[i]); | 10 - ex->n[i]); | ||||
break; | break; | ||||
case EXPLOSION_SMALL: | case EXPLOSION_SMALL: | ||||
ee_draw_sprite(ex->x[i], ex->y[i], small_sprite, | |||||
caca_draw_sprite(ex->x[i], ex->y[i], small_sprite, | |||||
6 - ex->n[i]); | 6 - ex->n[i]); | ||||
break; | break; | ||||
case EXPLOSION_NONE: | case EXPLOSION_NONE: | ||||
@@ -30,27 +30,27 @@ | |||||
void intro(void) | void intro(void) | ||||
{ | { | ||||
struct ee_sprite *foo_sprite = ee_load_sprite("data/foofight.txt"); | |||||
struct ee_sprite *bar_sprite = ee_load_sprite("data/barfight.txt"); | |||||
struct ee_sprite *baz_sprite = ee_load_sprite("data/bazfight.txt"); | |||||
struct caca_sprite *foo_sprite = caca_load_sprite("data/foofight.txt"); | |||||
struct caca_sprite *bar_sprite = caca_load_sprite("data/barfight.txt"); | |||||
struct caca_sprite *baz_sprite = caca_load_sprite("data/bazfight.txt"); | |||||
int frame = 0; | int frame = 0; | ||||
while(ee_get_key() == 0) | |||||
while(caca_get_key() == 0) | |||||
{ | { | ||||
int i, xo, yo, x[5], y[5]; | int i, xo, yo, x[5], y[5]; | ||||
frame++; | frame++; | ||||
ee_clear(); | |||||
caca_clear(); | |||||
xo = ee_get_width() / 2; | |||||
yo = ee_get_height() / 2; | |||||
xo = caca_get_width() / 2; | |||||
yo = caca_get_height() / 2; | |||||
ee_set_color(EE_RED); | |||||
ee_fill_ellipse(xo, yo, 16, 8, '#'); | |||||
ee_set_color(EE_GREEN); | |||||
ee_draw_thin_ellipse(xo, yo, 16, 8); | |||||
caca_set_color(EE_RED); | |||||
caca_fill_ellipse(xo, yo, 16, 8, '#'); | |||||
caca_set_color(EE_GREEN); | |||||
caca_draw_thin_ellipse(xo, yo, 16, 8); | |||||
for(i = 0; i < 4; i ++) | for(i = 0; i < 4; i ++) | ||||
{ | { | ||||
@@ -60,16 +60,16 @@ void intro(void) | |||||
x[4] = x[0]; | x[4] = x[0]; | ||||
y[4] = y[0]; | y[4] = y[0]; | ||||
ee_set_color(EE_BLACK); | |||||
ee_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' '); | |||||
ee_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' '); | |||||
ee_draw_line(x[0], y[0], x[2], y[2], ' '); | |||||
ee_set_color(EE_GREEN); | |||||
ee_draw_thin_polyline(x, y, 4); | |||||
caca_set_color(EE_BLACK); | |||||
caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' '); | |||||
caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' '); | |||||
caca_draw_line(x[0], y[0], x[2], y[2], ' '); | |||||
caca_set_color(EE_GREEN); | |||||
caca_draw_thin_polyline(x, y, 4); | |||||
ee_draw_sprite(xo, yo, foo_sprite, frame % 5); | |||||
caca_draw_sprite(xo, yo, foo_sprite, frame % 5); | |||||
ee_refresh(); | |||||
caca_refresh(); | |||||
usleep(40000); | usleep(40000); | ||||
} | } | ||||
@@ -41,16 +41,16 @@ int main (int argc, char **argv) | |||||
srand(time(NULL)); | srand(time(NULL)); | ||||
if(ee_init()) | |||||
if(caca_init()) | |||||
{ | { | ||||
return 1; | return 1; | ||||
} | } | ||||
ee_set_delay(100000); | |||||
caca_set_delay(100000); | |||||
/* Initialize our program */ | /* Initialize our program */ | ||||
g->w = ee_get_width(); | |||||
g->h = ee_get_height(); | |||||
g->w = caca_get_width(); | |||||
g->h = caca_get_height(); | |||||
intro(); | intro(); | ||||
@@ -58,7 +58,7 @@ intro(); | |||||
start_game(g); | start_game(g); | ||||
/* Clean up */ | /* Clean up */ | ||||
ee_end(); | |||||
caca_end(); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -100,7 +100,7 @@ static void start_game (game *g) | |||||
{ | { | ||||
char key; | char key; | ||||
while((key = ee_get_key())) | |||||
while((key = caca_get_key())) | |||||
{ | { | ||||
switch(key) | switch(key) | ||||
{ | { | ||||
@@ -198,11 +198,11 @@ static void start_game (game *g) | |||||
skip = 0; | skip = 0; | ||||
/* XXX: to be removed */ | /* XXX: to be removed */ | ||||
if(ee_rand(0, 9) == 0) | |||||
if(caca_rand(0, 9) == 0) | |||||
{ | { | ||||
int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ }; | int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ }; | ||||
add_alien(g, g->al, 0, rand() % g->h / 2, list[ee_rand(0,2)]); | |||||
add_alien(g, g->al, 0, rand() % g->h / 2, list[caca_rand(0,2)]); | |||||
} | } | ||||
/* Update game rules */ | /* Update game rules */ | ||||
@@ -231,7 +231,7 @@ static void start_game (game *g) | |||||
} | } | ||||
/* Clear screen */ | /* Clear screen */ | ||||
ee_clear(); | |||||
caca_clear(); | |||||
/* Print starfield, tunnel, aliens, player and explosions */ | /* Print starfield, tunnel, aliens, player and explosions */ | ||||
draw_starfield(g, g->sf); | draw_starfield(g, g->sf); | ||||
@@ -251,7 +251,7 @@ static void start_game (game *g) | |||||
} | } | ||||
/* Refresh */ | /* Refresh */ | ||||
ee_refresh(); | |||||
caca_refresh(); | |||||
purcompteur++; | purcompteur++; | ||||
} | } | ||||
@@ -32,50 +32,50 @@ void draw_status(game *g) | |||||
static char dashes30[] = "=============================="; | static char dashes30[] = "=============================="; | ||||
/* Draw life jauge */ | /* Draw life jauge */ | ||||
ee_set_color(EE_DARKGRAY); | |||||
ee_putstr(4, 1, dots30); | |||||
caca_set_color(EE_DARKGRAY); | |||||
caca_putstr(4, 1, dots30); | |||||
if(g->p->life > MAX_LIFE * 7 / 10) | if(g->p->life > MAX_LIFE * 7 / 10) | ||||
{ | { | ||||
ee_set_color(EE_GREEN); | |||||
caca_set_color(EE_GREEN); | |||||
} | } | ||||
else if(g->p->life > MAX_LIFE * 3 / 10) | else if(g->p->life > MAX_LIFE * 3 / 10) | ||||
{ | { | ||||
ee_set_color(EE_YELLOW); | |||||
caca_set_color(EE_YELLOW); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
ee_set_color(EE_RED); | |||||
caca_set_color(EE_RED); | |||||
} | } | ||||
ee_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); | |||||
caca_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE); | |||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(1, 1, "L |"); | |||||
ee_putstr(34, 1, "|"); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(1, 1, "L |"); | |||||
caca_putstr(34, 1, "|"); | |||||
/* Draw weapon jauge */ | /* Draw weapon jauge */ | ||||
ee_set_color(EE_DARKGRAY); | |||||
ee_putstr(42, 1, dots30 + 10); | |||||
caca_set_color(EE_DARKGRAY); | |||||
caca_putstr(42, 1, dots30 + 10); | |||||
if(g->p->special > MAX_SPECIAL * 9 / 10) | if(g->p->special > MAX_SPECIAL * 9 / 10) | ||||
{ | { | ||||
ee_set_color(EE_WHITE); | |||||
caca_set_color(EE_WHITE); | |||||
} | } | ||||
else if(g->p->special > MAX_SPECIAL * 3 / 10) | else if(g->p->special > MAX_SPECIAL * 3 / 10) | ||||
{ | { | ||||
ee_set_color(EE_CYAN); | |||||
caca_set_color(EE_CYAN); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
ee_set_color(EE_BLUE); | |||||
caca_set_color(EE_BLUE); | |||||
} | } | ||||
ee_putstr(42, 1, dashes30 + 10 | |||||
caca_putstr(42, 1, dashes30 + 10 | |||||
+ (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); | + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL); | ||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(39, 1, "S |"); | |||||
ee_putstr(62, 1, "|"); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(39, 1, "S |"); | |||||
caca_putstr(62, 1, "|"); | |||||
} | } | ||||
@@ -26,7 +26,7 @@ | |||||
#include "common.h" | #include "common.h" | ||||
struct ee_sprite *ship_sprite; | |||||
struct caca_sprite *ship_sprite; | |||||
/* Init tunnel */ | /* Init tunnel */ | ||||
player * create_player(game *g) | player * create_player(game *g) | ||||
@@ -44,7 +44,7 @@ player * create_player(game *g) | |||||
p->life = MAX_LIFE; | p->life = MAX_LIFE; | ||||
p->dead = 0; | p->dead = 0; | ||||
ship_sprite = ee_load_sprite("data/ship.txt"); | |||||
ship_sprite = caca_load_sprite("data/ship.txt"); | |||||
return p; | return p; | ||||
} | } | ||||
@@ -59,7 +59,7 @@ void draw_player(game *g, player *p) | |||||
if(p->dead) | if(p->dead) | ||||
return; | return; | ||||
ee_draw_sprite(p->x, p->y, ship_sprite, 0); | |||||
caca_draw_sprite(p->x, p->y, ship_sprite, 0); | |||||
} | } | ||||
void update_player(game *g, player *p) | void update_player(game *g, player *p) | ||||
@@ -37,11 +37,11 @@ starfield * create_starfield(game *g) | |||||
for(i = 0; i < STARS; i++) | for(i = 0; i < STARS; i++) | ||||
{ | { | ||||
s[i].x = ee_rand(0, g->w - 1); | |||||
s[i].y = ee_rand(0, g->h - 1); | |||||
s[i].z = ee_rand(1, 3); | |||||
s[i].c = ee_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY; | |||||
s[i].ch = ee_rand(0, 1) ? '.' : '\''; | |||||
s[i].x = caca_rand(0, g->w - 1); | |||||
s[i].y = caca_rand(0, g->h - 1); | |||||
s[i].z = caca_rand(1, 3); | |||||
s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY; | |||||
s[i].ch = caca_rand(0, 1) ? '.' : '\''; | |||||
} | } | ||||
return s; | return s; | ||||
@@ -55,8 +55,8 @@ void draw_starfield(game *g, starfield *s) | |||||
{ | { | ||||
if(s[i].x >= 0) | if(s[i].x >= 0) | ||||
{ | { | ||||
ee_set_color(s[i].c); | |||||
ee_putchar(s[i].x, s[i].y, s[i].ch); | |||||
caca_set_color(s[i].c); | |||||
caca_putchar(s[i].x, s[i].y, s[i].ch); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -69,11 +69,11 @@ void update_starfield(game *g, starfield *s) | |||||
{ | { | ||||
if(s[i].x < 0) | if(s[i].x < 0) | ||||
{ | { | ||||
s[i].x = ee_rand(0, g->w - 1); | |||||
s[i].x = caca_rand(0, g->w - 1); | |||||
s[i].y = 0; | s[i].y = 0; | ||||
s[i].z = ee_rand(1, 2); | |||||
s[i].c = ee_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY; | |||||
s[i].ch = ee_rand(0, 1) ? '.' : '\''; | |||||
s[i].z = caca_rand(1, 2); | |||||
s[i].c = caca_rand(0, 1) ? EE_LIGHTGRAY : EE_DARKGRAY; | |||||
s[i].ch = caca_rand(0, 1) ? '.' : '\''; | |||||
} | } | ||||
else if(s[i].y < g->h-1) | else if(s[i].y < g->h-1) | ||||
{ | { | ||||
@@ -77,7 +77,7 @@ void draw_tunnel(game *g, tunnel *t) | |||||
int i, j; | int i, j; | ||||
char c; | char c; | ||||
ee_set_color(EE_GREEN); | |||||
caca_set_color(EE_GREEN); | |||||
/* Left border */ | /* Left border */ | ||||
for(i = 0; i < g->h ; i++) | for(i = 0; i < g->h ; i++) | ||||
@@ -90,11 +90,11 @@ void draw_tunnel(game *g, tunnel *t) | |||||
else | else | ||||
c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; | c = (i == 0 || t->left[i] > t->left[i-1]) ? '\\' : '<'; | ||||
ee_putchar(t->left[i] + 1, i, c); | |||||
caca_putchar(t->left[i] + 1, i, c); | |||||
if(i + 1 < g->h) | if(i + 1 < g->h) | ||||
for(j = 1; j < t->left[i+1] - t->left[i]; j++) | for(j = 1; j < t->left[i+1] - t->left[i]; j++) | ||||
ee_putchar(t->left[i] + j + 1, i, '_'); | |||||
caca_putchar(t->left[i] + j + 1, i, '_'); | |||||
} | } | ||||
/* Right border */ | /* Right border */ | ||||
@@ -110,22 +110,22 @@ void draw_tunnel(game *g, tunnel *t) | |||||
if(i + 1 < g->h) | if(i + 1 < g->h) | ||||
for(j = 1; j < t->right[i] - t->right[i+1]; j++) | for(j = 1; j < t->right[i] - t->right[i+1]; j++) | ||||
ee_putchar(t->right[i+1] + j - 1, i, '_'); | |||||
caca_putchar(t->right[i+1] + j - 1, i, '_'); | |||||
ee_putchar(t->right[i] - 1, i, c); | |||||
caca_putchar(t->right[i] - 1, i, c); | |||||
} | } | ||||
ee_set_color(EE_RED); | |||||
caca_set_color(EE_RED); | |||||
/* Left concrete */ | /* Left concrete */ | ||||
for(i = 0; i < g->h ; i++) | for(i = 0; i < g->h ; i++) | ||||
for(j = 0 ; j <= t->left[i]; j++) | for(j = 0 ; j <= t->left[i]; j++) | ||||
ee_putchar(j, i, '#'); | |||||
caca_putchar(j, i, '#'); | |||||
/* Right concrete */ | /* Right concrete */ | ||||
for(i = 0; i < g->h ; i++) | for(i = 0; i < g->h ; i++) | ||||
for(j = t->right[i] ; j < g->w ; j++) | for(j = t->right[i] ; j < g->w ; j++) | ||||
ee_putchar(j, i, '#'); | |||||
caca_putchar(j, i, '#'); | |||||
} | } | ||||
void update_tunnel(game *g, tunnel *t) | void update_tunnel(game *g, tunnel *t) | ||||
@@ -141,8 +141,8 @@ void update_tunnel(game *g, tunnel *t) | |||||
} | } | ||||
/* Generate new values */ | /* Generate new values */ | ||||
i = delta[ee_rand(0,5)]; | |||||
j = delta[ee_rand(0,5)]; | |||||
i = delta[caca_rand(0,5)]; | |||||
j = delta[caca_rand(0,5)]; | |||||
/* Check in which direction we need to alter tunnel */ | /* Check in which direction we need to alter tunnel */ | ||||
if(t->right[1] - t->left[1] < t->w) | if(t->right[1] - t->left[1] < t->w) | ||||
@@ -31,8 +31,8 @@ static void draw_nuke(int x, int y, int frame); | |||||
static void draw_beam(int x, int y, int frame); | static void draw_beam(int x, int y, int frame); | ||||
static void draw_fragbomb(int x, int y, int frame); | static void draw_fragbomb(int x, int y, int frame); | ||||
struct ee_sprite *bomb_sprite; | |||||
struct ee_sprite *fragbomb_sprite; | |||||
struct caca_sprite *bomb_sprite; | |||||
struct caca_sprite *fragbomb_sprite; | |||||
void init_weapons(game *g, weapons *wp) | void init_weapons(game *g, weapons *wp) | ||||
{ | { | ||||
@@ -43,8 +43,8 @@ void init_weapons(game *g, weapons *wp) | |||||
wp->type[i] = WEAPON_NONE; | wp->type[i] = WEAPON_NONE; | ||||
} | } | ||||
bomb_sprite = ee_load_sprite("data/wpnbomb.txt"); | |||||
fragbomb_sprite = ee_load_sprite("data/wpnfrag.txt"); | |||||
bomb_sprite = caca_load_sprite("data/wpnbomb.txt"); | |||||
fragbomb_sprite = caca_load_sprite("data/wpnfrag.txt"); | |||||
} | } | ||||
void draw_weapons(game *g, weapons *wp) | void draw_weapons(game *g, weapons *wp) | ||||
@@ -56,25 +56,25 @@ void draw_weapons(game *g, weapons *wp) | |||||
switch(wp->type[i]) | switch(wp->type[i]) | ||||
{ | { | ||||
case WEAPON_LASER: | case WEAPON_LASER: | ||||
ee_set_color(EE_WHITE); | |||||
ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|'); | |||||
ee_set_color(EE_CYAN); | |||||
ee_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '|'); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putchar(wp->x[i] >> 4, (wp->y[i] >> 4) + 1, '|'); | |||||
break; | break; | ||||
case WEAPON_SEEKER: | case WEAPON_SEEKER: | ||||
ee_set_color(EE_CYAN); | |||||
ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); | |||||
ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); | |||||
ee_set_color(EE_WHITE); | |||||
ee_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@'); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); | |||||
caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, 'o'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putchar(wp->x[i] >> 4, wp->y[i] >> 4, '@'); | |||||
break; | break; | ||||
case WEAPON_BOMB: | case WEAPON_BOMB: | ||||
ee_set_color(EE_DARKGRAY); | |||||
ee_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); | |||||
ee_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); | |||||
ee_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.'); | |||||
ee_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); | |||||
ee_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, '.'); | |||||
caca_set_color(EE_DARKGRAY); | |||||
caca_putchar((wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4, '.'); | |||||
caca_putchar((wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4, '.'); | |||||
caca_putchar((wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4, '.'); | |||||
caca_putchar(wp->x3[i] >> 4, wp->y3[i] >> 4, '.'); | |||||
caca_putchar(wp->x2[i] >> 4, wp->y2[i] >> 4, '.'); | |||||
draw_bomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]); | draw_bomb(wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i]); | ||||
break; | break; | ||||
case WEAPON_FRAGBOMB: | case WEAPON_FRAGBOMB: | ||||
@@ -169,7 +169,7 @@ void update_weapons(game *g, weapons *wp) | |||||
/* Normalize direction */ | /* Normalize direction */ | ||||
if(dx | dy) | if(dx | dy) | ||||
{ | { | ||||
unsigned int norm = ee_sqrt(dx * dx + 4 * dy * dy); | |||||
unsigned int norm = caca_sqrt(dx * dx + 4 * dy * dy); | |||||
dx = dx * 32 / norm; | dx = dx * 32 / norm; | ||||
dy = dy * 32 / norm; | dy = dy * 32 / norm; | ||||
} | } | ||||
@@ -181,7 +181,7 @@ void update_weapons(game *g, weapons *wp) | |||||
/* Normalize speed */ | /* Normalize speed */ | ||||
if(dx | dy) | if(dx | dy) | ||||
{ | { | ||||
unsigned int norm = ee_sqrt(dx * dx + 4 * dy * dy); | |||||
unsigned int norm = caca_sqrt(dx * dx + 4 * dy * dy); | |||||
wp->vx[i] = dx * 32 / norm; | wp->vx[i] = dx * 32 / norm; | ||||
wp->vy[i] = dy * 32 / norm; | wp->vy[i] = dy * 32 / norm; | ||||
} | } | ||||
@@ -333,16 +333,16 @@ static void draw_bomb(int x, int y, int vx, int vy) | |||||
} | } | ||||
} | } | ||||
ee_draw_sprite(x, y, bomb_sprite, frame); | |||||
caca_draw_sprite(x, y, bomb_sprite, frame); | |||||
} | } | ||||
static void draw_fragbomb(int x, int y, int frame) | static void draw_fragbomb(int x, int y, int frame) | ||||
{ | { | ||||
/* Draw the head */ | /* Draw the head */ | ||||
ee_draw_sprite(x, y, fragbomb_sprite, frame & 1); | |||||
caca_draw_sprite(x, y, fragbomb_sprite, frame & 1); | |||||
/* Draw the tail */ | /* Draw the tail */ | ||||
ee_draw_sprite(x, y, fragbomb_sprite, 2 + (frame % 4)); | |||||
caca_draw_sprite(x, y, fragbomb_sprite, 2 + (frame % 4)); | |||||
} | } | ||||
static void draw_beam(int x, int y, int frame) | static void draw_beam(int x, int y, int frame) | ||||
@@ -353,86 +353,86 @@ static void draw_beam(int x, int y, int frame) | |||||
switch(frame) | switch(frame) | ||||
{ | { | ||||
case 24: | case 24: | ||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x, y-3, "__"); | |||||
ee_putchar(x-1, y-2, '\''); | |||||
ee_putchar(x+2, y-2, '`'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x, y-3, "__"); | |||||
caca_putchar(x-1, y-2, '\''); | |||||
caca_putchar(x+2, y-2, '`'); | |||||
break; | break; | ||||
case 23: | case 23: | ||||
ee_set_color(EE_CYAN); | |||||
ee_putstr(x, y-3, "__"); | |||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x-2, y-2, "-'"); | |||||
ee_putstr(x+2, y-2, "`-"); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putstr(x, y-3, "__"); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x-2, y-2, "-'"); | |||||
caca_putstr(x+2, y-2, "`-"); | |||||
break; | break; | ||||
case 22: | case 22: | ||||
ee_set_color(EE_CYAN); | |||||
ee_putstr(x, y-3, "__"); | |||||
ee_putchar(x-1, y-2, '\''); | |||||
ee_putchar(x+2, y-2, '`'); | |||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x-3, y-2, ",-"); | |||||
ee_putstr(x+3, y-2, "-."); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putstr(x, y-3, "__"); | |||||
caca_putchar(x-1, y-2, '\''); | |||||
caca_putchar(x+2, y-2, '`'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x-3, y-2, ",-"); | |||||
caca_putstr(x+3, y-2, "-."); | |||||
break; | break; | ||||
case 21: | case 21: | ||||
ee_set_color(EE_CYAN); | |||||
ee_putstr(x-1, y-3, "____"); | |||||
ee_putchar(x-2, y-2, '\''); | |||||
ee_putchar(x+3, y-2, '`'); | |||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x-4, y-2, ",-"); | |||||
ee_putstr(x+4, y-2, "-."); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putstr(x-1, y-3, "____"); | |||||
caca_putchar(x-2, y-2, '\''); | |||||
caca_putchar(x+3, y-2, '`'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x-4, y-2, ",-"); | |||||
caca_putstr(x+4, y-2, "-."); | |||||
break; | break; | ||||
case 20: | case 20: | ||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x, y-3, "%%"); | |||||
ee_putchar(x-4, y-2, ','); | |||||
ee_putchar(x+5, y-2, '.'); | |||||
ee_set_color(EE_CYAN); | |||||
ee_putchar(x-1, y-3, ':'); | |||||
ee_putchar(x+2, y-3, ':'); | |||||
ee_putstr(x-3, y-2, "-'"); | |||||
ee_putstr(x+3, y-2, "`-"); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x, y-3, "%%"); | |||||
caca_putchar(x-4, y-2, ','); | |||||
caca_putchar(x+5, y-2, '.'); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putchar(x-1, y-3, ':'); | |||||
caca_putchar(x+2, y-3, ':'); | |||||
caca_putstr(x-3, y-2, "-'"); | |||||
caca_putstr(x+3, y-2, "`-"); | |||||
break; | break; | ||||
case 19: | case 19: | ||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x, y-4, "%%"); | |||||
ee_putstr(x, y-3, "##"); | |||||
ee_set_color(EE_CYAN); | |||||
ee_putchar(x-1, y-4, ':'); | |||||
ee_putchar(x+2, y-4, ':'); | |||||
ee_putchar(x-1, y-3, '%'); | |||||
ee_putchar(x+2, y-3, '%'); | |||||
ee_putstr(x-4, y-2, ",-'"); | |||||
ee_putstr(x+3, y-2, "`-."); | |||||
ee_set_color(EE_BLUE); | |||||
ee_putchar(x-2, y-3, ':'); | |||||
ee_putchar(x+3, y-3, ':'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x, y-4, "%%"); | |||||
caca_putstr(x, y-3, "##"); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putchar(x-1, y-4, ':'); | |||||
caca_putchar(x+2, y-4, ':'); | |||||
caca_putchar(x-1, y-3, '%'); | |||||
caca_putchar(x+2, y-3, '%'); | |||||
caca_putstr(x-4, y-2, ",-'"); | |||||
caca_putstr(x+3, y-2, "`-."); | |||||
caca_set_color(EE_BLUE); | |||||
caca_putchar(x-2, y-3, ':'); | |||||
caca_putchar(x+3, y-3, ':'); | |||||
break; | break; | ||||
case 18: | case 18: | ||||
default: | default: | ||||
r = (18 - frame) * (18 - frame); | r = (18 - frame) * (18 - frame); | ||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x-1, y-5-r, ":%%:"); | |||||
ee_putstr(x-1, y-4-r, "%##%"); | |||||
ee_set_color(EE_CYAN); | |||||
ee_putchar(x-2, y-4-r, ':'); | |||||
ee_putchar(x+3, y-4-r, ':'); | |||||
ee_putchar(x-2, y-2, '\''); | |||||
ee_putchar(x+3, y-2, '`'); | |||||
ee_set_color(EE_BLUE); | |||||
ee_putchar(x-3, y-2, ':'); | |||||
ee_putchar(x+4, y-2, ':'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x-1, y-5-r, ":%%:"); | |||||
caca_putstr(x-1, y-4-r, "%##%"); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putchar(x-2, y-4-r, ':'); | |||||
caca_putchar(x+3, y-4-r, ':'); | |||||
caca_putchar(x-2, y-2, '\''); | |||||
caca_putchar(x+3, y-2, '`'); | |||||
caca_set_color(EE_BLUE); | |||||
caca_putchar(x-3, y-2, ':'); | |||||
caca_putchar(x+4, y-2, ':'); | |||||
for(i = 0; i <= r; i++) | for(i = 0; i <= r; i++) | ||||
{ | { | ||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); | |||||
ee_set_color(EE_CYAN); | |||||
ee_putchar(x-2, y-3-i, '%'); | |||||
ee_putchar(x+3, y-3-i, '%'); | |||||
ee_set_color(EE_BLUE); | |||||
ee_putchar(x-3, y-3-i, ':'); | |||||
ee_putchar(x+4, y-3-i, ':'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(x-1, y-3-i, ((i+frame) % 5) ? "####" : "%%%%"); | |||||
caca_set_color(EE_CYAN); | |||||
caca_putchar(x-2, y-3-i, '%'); | |||||
caca_putchar(x+3, y-3-i, '%'); | |||||
caca_set_color(EE_BLUE); | |||||
caca_putchar(x-3, y-3-i, ':'); | |||||
caca_putchar(x+4, y-3-i, ':'); | |||||
} | } | ||||
break; | break; | ||||
} | } | ||||
@@ -443,16 +443,16 @@ static void draw_nuke(int x, int y, int frame) | |||||
int r = (29 - frame) * (29 - frame) / 8; | int r = (29 - frame) * (29 - frame) / 8; | ||||
/* Lots of duplicate pixels, but we don't care */ | /* Lots of duplicate pixels, but we don't care */ | ||||
ee_set_color(EE_BLUE); | |||||
ee_draw_ellipse(x, y, r, r / 2, ':'); | |||||
ee_draw_ellipse(x, y, r + 1, r / 2, ':'); | |||||
ee_draw_ellipse(x, y, r + 2, r / 2, ':'); | |||||
ee_set_color(EE_CYAN); | |||||
ee_draw_ellipse(x, y, r + 2, r / 2 + 1, '%'); | |||||
ee_draw_ellipse(x, y, r + 3, r / 2 + 1, '%'); | |||||
ee_set_color(EE_WHITE); | |||||
ee_draw_ellipse(x, y, r + 3, r / 2 + 2, '#'); | |||||
ee_draw_ellipse(x, y, r + 4, r / 2 + 2, '#'); | |||||
ee_draw_ellipse(x, y, r + 4, r / 2 + 3, '#'); | |||||
caca_set_color(EE_BLUE); | |||||
caca_draw_ellipse(x, y, r, r / 2, ':'); | |||||
caca_draw_ellipse(x, y, r + 1, r / 2, ':'); | |||||
caca_draw_ellipse(x, y, r + 2, r / 2, ':'); | |||||
caca_set_color(EE_CYAN); | |||||
caca_draw_ellipse(x, y, r + 2, r / 2 + 1, '%'); | |||||
caca_draw_ellipse(x, y, r + 3, r / 2 + 1, '%'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_draw_ellipse(x, y, r + 3, r / 2 + 2, '#'); | |||||
caca_draw_ellipse(x, y, r + 4, r / 2 + 2, '#'); | |||||
caca_draw_ellipse(x, y, r + 4, r / 2 + 3, '#'); | |||||
} | } | ||||
@@ -1,8 +1,8 @@ | |||||
############################################################################### | ############################################################################### | ||||
# Automake targets and declarations for libee tests | |||||
# Automake targets and declarations for libcaca tests | |||||
############################################################################### | ############################################################################### | ||||
AM_CPPFLAGS = -I$(top_srcdir)/libee | |||||
AM_CPPFLAGS = -I$(top_srcdir)/libcaca | |||||
if USE_SLANG | if USE_SLANG | ||||
LDFLAGS_slang = -lslang | LDFLAGS_slang = -lslang | ||||
@@ -14,10 +14,10 @@ endif | |||||
bin_PROGRAMS = demo spritedit | bin_PROGRAMS = demo spritedit | ||||
demo_SOURCES = demo.c | demo_SOURCES = demo.c | ||||
demo_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm | |||||
demo_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm | |||||
demo_CFLAGS = `pkg-config --cflags gtk+-2.0` | demo_CFLAGS = `pkg-config --cflags gtk+-2.0` | ||||
demo_LDFLAGS = `pkg-config --libs gtk+-2.0` | demo_LDFLAGS = `pkg-config --libs gtk+-2.0` | ||||
spritedit_SOURCES = spritedit.c | spritedit_SOURCES = spritedit.c | ||||
spritedit_LDADD = ../libee/libee.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm | |||||
spritedit_LDADD = ../libcaca/libcaca.a $(LDFLAGS_slang) $(LDFLAGS_ncurses) -lm | |||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* demo demo using libee | |||||
* demo demo using libcaca | |||||
* Copyright (c) 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -29,7 +29,7 @@ | |||||
#include <gdk/gdk.h> | #include <gdk/gdk.h> | ||||
#include <gdk/gdkpixbuf.h> | #include <gdk/gdkpixbuf.h> | ||||
#include "ee.h" | |||||
#include "caca.h" | |||||
static void display_menu(void); | static void display_menu(void); | ||||
@@ -46,7 +46,7 @@ static void demo_blit(void); | |||||
int bounds = 0; | int bounds = 0; | ||||
int outline = 0; | int outline = 0; | ||||
struct ee_sprite *sprite = NULL; | |||||
struct caca_sprite *sprite = NULL; | |||||
GdkPixbuf *pixbuf; | GdkPixbuf *pixbuf; | ||||
char *pixels; | char *pixels; | ||||
@@ -57,15 +57,15 @@ int main(int argc, char **argv) | |||||
void (*demo)(void) = NULL; | void (*demo)(void) = NULL; | ||||
int quit = 0; | int quit = 0; | ||||
if(ee_init()) | |||||
if(caca_init()) | |||||
{ | { | ||||
return 1; | return 1; | ||||
} | } | ||||
ee_set_delay(40000); | |||||
caca_set_delay(40000); | |||||
/* Initialize data */ | /* Initialize data */ | ||||
sprite = ee_load_sprite("data/barboss.txt"); | |||||
sprite = caca_load_sprite("data/barboss.txt"); | |||||
gdk_init (&argc, &argv); | gdk_init (&argc, &argv); | ||||
//pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/gally4.jpeg", NULL); | //pixbuf = gdk_pixbuf_new_from_file("/home/sam/pix/gally4.jpeg", NULL); | ||||
@@ -82,17 +82,17 @@ fprintf(stderr, "w %i, h %i, stride %i\n", bufx, bufy, bufpitch); | |||||
/* Main menu */ | /* Main menu */ | ||||
display_menu(); | display_menu(); | ||||
ee_refresh(); | |||||
caca_refresh(); | |||||
/* Go ! */ | /* Go ! */ | ||||
while(!quit) | while(!quit) | ||||
{ | { | ||||
char key = ee_get_key(); | |||||
char key = caca_get_key(); | |||||
if(key && demo) | if(key && demo) | ||||
{ | { | ||||
display_menu(); | display_menu(); | ||||
ee_refresh(); | |||||
caca_refresh(); | |||||
demo = NULL; | demo = NULL; | ||||
} | } | ||||
else if(key) | else if(key) | ||||
@@ -148,65 +148,65 @@ fprintf(stderr, "w %i, h %i, stride %i\n", bufx, bufy, bufpitch); | |||||
} | } | ||||
if(demo) | if(demo) | ||||
ee_clear(); | |||||
caca_clear(); | |||||
key = ee_get_key(); | |||||
key = caca_get_key(); | |||||
if(key) | if(key) | ||||
goto handle_key; | goto handle_key; | ||||
ee_refresh(); | |||||
caca_refresh(); | |||||
} | } | ||||
if(demo) | if(demo) | ||||
{ | { | ||||
demo(); | demo(); | ||||
ee_set_color(EE_WHITE); | |||||
ee_draw_thin_box(1, 1, ee_get_width() - 2, ee_get_height() - 2); | |||||
ee_printf(4, 1, "[%i.%i fps]----", | |||||
1000000 / ee_get_rendertime(), | |||||
(10000000 / ee_get_rendertime()) % 10); | |||||
ee_refresh(); | |||||
caca_set_color(EE_WHITE); | |||||
caca_draw_thin_box(1, 1, caca_get_width() - 2, caca_get_height() - 2); | |||||
caca_printf(4, 1, "[%i.%i fps]----", | |||||
1000000 / caca_get_rendertime(), | |||||
(10000000 / caca_get_rendertime()) % 10); | |||||
caca_refresh(); | |||||
} | } | ||||
} | } | ||||
/* Clean up */ | /* Clean up */ | ||||
ee_free_sprite(sprite); | |||||
ee_end(); | |||||
caca_free_sprite(sprite); | |||||
caca_end(); | |||||
return 0; | return 0; | ||||
} | } | ||||
static void display_menu(void) | static void display_menu(void) | ||||
{ | { | ||||
int xo = ee_get_width() - 2; | |||||
int yo = ee_get_height() - 2; | |||||
ee_clear(); | |||||
ee_set_color(EE_WHITE); | |||||
ee_draw_thin_box(1, 1, xo, yo); | |||||
ee_putstr((xo - strlen("libee demo")) / 2, 3, "libee demo"); | |||||
ee_putstr((xo - strlen("============")) / 2, 4, "============"); | |||||
ee_putstr(4, 6, "demos:"); | |||||
ee_putstr(4, 7, "'f': full"); | |||||
ee_putstr(4, 8, "'1': dots"); | |||||
ee_putstr(4, 9, "'2': lines"); | |||||
ee_putstr(4, 10, "'3': boxes"); | |||||
ee_putstr(4, 11, "'4': triangles"); | |||||
ee_putstr(4, 12, "'5': ellipses"); | |||||
ee_putstr(4, 13, "'s': sprites"); | |||||
ee_putstr(4, 14, "'c': color"); | |||||
ee_putstr(4, 15, "'i': image blit"); | |||||
ee_putstr(4, 17, "settings:"); | |||||
ee_printf(4, 18, "'o': outline: %s", | |||||
int xo = caca_get_width() - 2; | |||||
int yo = caca_get_height() - 2; | |||||
caca_clear(); | |||||
caca_set_color(EE_WHITE); | |||||
caca_draw_thin_box(1, 1, xo, yo); | |||||
caca_putstr((xo - strlen("libcaca demo")) / 2, 3, "libcaca demo"); | |||||
caca_putstr((xo - strlen("==============")) / 2, 4, "=============="); | |||||
caca_putstr(4, 6, "demos:"); | |||||
caca_putstr(4, 7, "'f': full"); | |||||
caca_putstr(4, 8, "'1': dots"); | |||||
caca_putstr(4, 9, "'2': lines"); | |||||
caca_putstr(4, 10, "'3': boxes"); | |||||
caca_putstr(4, 11, "'4': triangles"); | |||||
caca_putstr(4, 12, "'5': ellipses"); | |||||
caca_putstr(4, 13, "'s': sprites"); | |||||
caca_putstr(4, 14, "'c': color"); | |||||
caca_putstr(4, 15, "'i': image blit"); | |||||
caca_putstr(4, 17, "settings:"); | |||||
caca_printf(4, 18, "'o': outline: %s", | |||||
outline == 0 ? "none" : outline == 1 ? "solid" : "thin"); | outline == 0 ? "none" : outline == 1 ? "solid" : "thin"); | ||||
ee_printf(4, 19, "'b': drawing boundaries: %s", | |||||
caca_printf(4, 19, "'b': drawing boundaries: %s", | |||||
bounds == 0 ? "screen" : "infinite"); | bounds == 0 ? "screen" : "infinite"); | ||||
ee_putstr(4, yo - 2, "'q': quit"); | |||||
caca_putstr(4, yo - 2, "'q': quit"); | |||||
} | } | ||||
static void demo_all(void) | static void demo_all(void) | ||||
@@ -217,106 +217,106 @@ static void demo_all(void) | |||||
i++; | i++; | ||||
ee_clear(); | |||||
caca_clear(); | |||||
/* Draw the sun */ | /* Draw the sun */ | ||||
ee_set_color(EE_YELLOW); | |||||
xo = ee_get_width() / 4; | |||||
yo = ee_get_height() / 4 + 5 * sin(0.03*i); | |||||
caca_set_color(EE_YELLOW); | |||||
xo = caca_get_width() / 4; | |||||
yo = caca_get_height() / 4 + 5 * sin(0.03*i); | |||||
for(j = 0; j < 16; j++) | for(j = 0; j < 16; j++) | ||||
{ | { | ||||
xa = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8); | xa = xo - (30 + sin(0.03*i) * 8) * sin(0.03*i + M_PI*j/8); | ||||
ya = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8); | ya = yo + (15 + sin(0.03*i) * 4) * cos(0.03*i + M_PI*j/8); | ||||
ee_draw_thin_line(xo, yo, xa, ya); | |||||
caca_draw_thin_line(xo, yo, xa, ya); | |||||
} | } | ||||
j = 15 + sin(0.03*i) * 8; | j = 15 + sin(0.03*i) * 8; | ||||
ee_set_color(EE_WHITE); | |||||
ee_fill_ellipse(xo, yo, j, j / 2, '#'); | |||||
ee_set_color(EE_YELLOW); | |||||
ee_draw_ellipse(xo, yo, j, j / 2, '#'); | |||||
caca_set_color(EE_WHITE); | |||||
caca_fill_ellipse(xo, yo, j, j / 2, '#'); | |||||
caca_set_color(EE_YELLOW); | |||||
caca_draw_ellipse(xo, yo, j, j / 2, '#'); | |||||
/* Draw the pyramid */ | /* Draw the pyramid */ | ||||
xo = ee_get_width() * 5 / 8; | |||||
xo = caca_get_width() * 5 / 8; | |||||
yo = 2; | yo = 2; | ||||
xa = ee_get_width() / 8 + sin(0.03*i) * 5; | |||||
ya = ee_get_height() / 2 + cos(0.03*i) * 5; | |||||
xa = caca_get_width() / 8 + sin(0.03*i) * 5; | |||||
ya = caca_get_height() / 2 + cos(0.03*i) * 5; | |||||
xb = ee_get_width() - 10 - cos(0.02*i) * 10; | |||||
yb = ee_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5; | |||||
xb = caca_get_width() - 10 - cos(0.02*i) * 10; | |||||
yb = caca_get_height() * 3 / 4 - 5 + sin(0.02*i) * 5; | |||||
xc = ee_get_width() / 4 - sin(0.02*i) * 5; | |||||
yc = ee_get_height() * 3 / 4 + cos(0.02*i) * 5; | |||||
xc = caca_get_width() / 4 - sin(0.02*i) * 5; | |||||
yc = caca_get_height() * 3 / 4 + cos(0.02*i) * 5; | |||||
ee_set_color(EE_GREEN); | |||||
ee_fill_triangle(xo, yo, xb, yb, xa, ya, '%'); | |||||
ee_set_color(EE_YELLOW); | |||||
ee_draw_thin_triangle(xo, yo, xb, yb, xa, ya); | |||||
caca_set_color(EE_GREEN); | |||||
caca_fill_triangle(xo, yo, xb, yb, xa, ya, '%'); | |||||
caca_set_color(EE_YELLOW); | |||||
caca_draw_thin_triangle(xo, yo, xb, yb, xa, ya); | |||||
ee_set_color(EE_RED); | |||||
ee_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); | |||||
ee_set_color(EE_YELLOW); | |||||
ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc); | |||||
caca_set_color(EE_RED); | |||||
caca_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); | |||||
caca_set_color(EE_YELLOW); | |||||
caca_draw_thin_triangle(xa, ya, xb, yb, xc, yc); | |||||
ee_set_color(EE_BLUE); | |||||
ee_fill_triangle(xo, yo, xb, yb, xc, yc, '%'); | |||||
ee_set_color(EE_YELLOW); | |||||
ee_draw_thin_triangle(xo, yo, xb, yb, xc, yc); | |||||
caca_set_color(EE_BLUE); | |||||
caca_fill_triangle(xo, yo, xb, yb, xc, yc, '%'); | |||||
caca_set_color(EE_YELLOW); | |||||
caca_draw_thin_triangle(xo, yo, xb, yb, xc, yc); | |||||
/* Draw a background triangle */ | /* Draw a background triangle */ | ||||
xa = 2; | xa = 2; | ||||
ya = 2; | ya = 2; | ||||
xb = ee_get_width() - 3; | |||||
yb = ee_get_height() / 2; | |||||
xb = caca_get_width() - 3; | |||||
yb = caca_get_height() / 2; | |||||
xc = ee_get_width() / 3; | |||||
yc = ee_get_height() - 3; | |||||
xc = caca_get_width() / 3; | |||||
yc = caca_get_height() - 3; | |||||
ee_set_color(EE_CYAN); | |||||
ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc); | |||||
caca_set_color(EE_CYAN); | |||||
caca_draw_thin_triangle(xa, ya, xb, yb, xc, yc); | |||||
xo = ee_get_width() / 2 + cos(0.027*i) * ee_get_width() / 3; | |||||
yo = ee_get_height() / 2 - sin(0.027*i) * ee_get_height() / 2; | |||||
xo = caca_get_width() / 2 + cos(0.027*i) * caca_get_width() / 3; | |||||
yo = caca_get_height() / 2 - sin(0.027*i) * caca_get_height() / 2; | |||||
ee_draw_thin_line(xa, ya, xo, yo); | |||||
ee_draw_thin_line(xb, yb, xo, yo); | |||||
ee_draw_thin_line(xc, yc, xo, yo); | |||||
caca_draw_thin_line(xa, ya, xo, yo); | |||||
caca_draw_thin_line(xb, yb, xo, yo); | |||||
caca_draw_thin_line(xc, yc, xo, yo); | |||||
/* Draw a sprite on the pyramid */ | /* Draw a sprite on the pyramid */ | ||||
ee_draw_sprite(xo, yo, sprite, 0); | |||||
caca_draw_sprite(xo, yo, sprite, 0); | |||||
/* Draw a trail behind the foreground sprite */ | /* Draw a trail behind the foreground sprite */ | ||||
for(j = i - 60; j < i; j++) | for(j = i - 60; j < i; j++) | ||||
{ | { | ||||
int delta = ee_rand(-5, 5); | |||||
ee_set_color(ee_rand(0, 15)); | |||||
ee_putchar(ee_get_width() / 2 | |||||
+ cos(0.02*j) * (delta + ee_get_width() / 4), | |||||
ee_get_height() / 2 | |||||
+ sin(0.02*j) * (delta + ee_get_height() / 3), | |||||
int delta = caca_rand(-5, 5); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
caca_putchar(caca_get_width() / 2 | |||||
+ cos(0.02*j) * (delta + caca_get_width() / 4), | |||||
caca_get_height() / 2 | |||||
+ sin(0.02*j) * (delta + caca_get_height() / 3), | |||||
'#'); | '#'); | ||||
} | } | ||||
/* Draw foreground sprite */ | /* Draw foreground sprite */ | ||||
ee_draw_sprite(ee_get_width() / 2 + cos(0.02*i) * ee_get_width() / 4, | |||||
ee_get_height() / 2 + sin(0.02*i) * ee_get_height() / 3, | |||||
caca_draw_sprite(caca_get_width() / 2 + cos(0.02*i) * caca_get_width() / 4, | |||||
caca_get_height() / 2 + sin(0.02*i) * caca_get_height() / 3, | |||||
sprite, 0); | sprite, 0); | ||||
} | } | ||||
static void demo_dots(void) | static void demo_dots(void) | ||||
{ | { | ||||
int xmax = ee_get_width() - 1; | |||||
int ymax = ee_get_height() - 1; | |||||
int xmax = caca_get_width() - 1; | |||||
int ymax = caca_get_height() - 1; | |||||
int i; | int i; | ||||
for(i = 1000; i--;) | for(i = 1000; i--;) | ||||
{ | { | ||||
/* Putpixel */ | /* Putpixel */ | ||||
ee_set_color(ee_rand(0, 15)); | |||||
ee_putchar(ee_rand(0, xmax), ee_rand(0, ymax), '#'); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
caca_putchar(caca_rand(0, xmax), caca_rand(0, ymax), '#'); | |||||
} | } | ||||
} | } | ||||
@@ -325,138 +325,138 @@ static void demo_color(void) | |||||
int i; | int i; | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
ee_clear(); | |||||
caca_clear(); | |||||
for(i = 0; i < 16; i++) | for(i = 0; i < 16; i++) | ||||
{ | { | ||||
sprintf(buf, "'%c': %i (%s)", 'a' + i, i, ee_get_color_name(i)); | |||||
ee_set_color(EE_WHITE); | |||||
ee_putstr(4, i + 3, buf); | |||||
ee_set_color(i); | |||||
ee_putstr(40, i + 3, "XXXXXXXXXX-XX--X----------"); | |||||
sprintf(buf, "'%c': %i (%s)", 'a' + i, i, caca_get_color_name(i)); | |||||
caca_set_color(EE_WHITE); | |||||
caca_putstr(4, i + 3, buf); | |||||
caca_set_color(i); | |||||
caca_putstr(40, i + 3, "XXXXXXXXXX-XX--X----------"); | |||||
} | } | ||||
} | } | ||||
static void demo_lines(void) | static void demo_lines(void) | ||||
{ | { | ||||
int w = ee_get_width(); | |||||
int h = ee_get_height(); | |||||
int w = caca_get_width(); | |||||
int h = caca_get_height(); | |||||
int xa, ya, xb, yb; | int xa, ya, xb, yb; | ||||
if(bounds) | if(bounds) | ||||
{ | { | ||||
xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h); | |||||
xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h); | |||||
xa = caca_rand(- w, 2 * w); ya = caca_rand(- h, 2 * h); | |||||
xb = caca_rand(- w, 2 * w); yb = caca_rand(- h, 2 * h); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1); | |||||
xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1); | |||||
xa = caca_rand(0, w - 1); ya = caca_rand(0, h - 1); | |||||
xb = caca_rand(0, w - 1); yb = caca_rand(0, h - 1); | |||||
} | } | ||||
ee_set_color(ee_rand(0, 15)); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
if(outline > 1) | if(outline > 1) | ||||
ee_draw_thin_line(xa, ya, xb, yb); | |||||
caca_draw_thin_line(xa, ya, xb, yb); | |||||
else | else | ||||
ee_draw_line(xa, ya, xb, yb, '#'); | |||||
caca_draw_line(xa, ya, xb, yb, '#'); | |||||
} | } | ||||
static void demo_boxes(void) | static void demo_boxes(void) | ||||
{ | { | ||||
int w = ee_get_width(); | |||||
int h = ee_get_height(); | |||||
int w = caca_get_width(); | |||||
int h = caca_get_height(); | |||||
int xa, ya, xb, yb; | int xa, ya, xb, yb; | ||||
if(bounds) | if(bounds) | ||||
{ | { | ||||
xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h); | |||||
xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h); | |||||
xa = caca_rand(- w, 2 * w); ya = caca_rand(- h, 2 * h); | |||||
xb = caca_rand(- w, 2 * w); yb = caca_rand(- h, 2 * h); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1); | |||||
xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1); | |||||
xa = caca_rand(0, w - 1); ya = caca_rand(0, h - 1); | |||||
xb = caca_rand(0, w - 1); yb = caca_rand(0, h - 1); | |||||
} | } | ||||
ee_set_color(ee_rand(0, 15)); | |||||
ee_fill_box(xa, ya, xb, yb, '#'); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
caca_fill_box(xa, ya, xb, yb, '#'); | |||||
ee_set_color(ee_rand(0, 15)); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
if(outline == 2) | if(outline == 2) | ||||
ee_draw_thin_box(xa, ya, xb, yb); | |||||
caca_draw_thin_box(xa, ya, xb, yb); | |||||
else if(outline == 1) | else if(outline == 1) | ||||
ee_draw_box(xa, ya, xb, yb, '#'); | |||||
caca_draw_box(xa, ya, xb, yb, '#'); | |||||
} | } | ||||
static void demo_ellipses(void) | static void demo_ellipses(void) | ||||
{ | { | ||||
int w = ee_get_width(); | |||||
int h = ee_get_height(); | |||||
int w = caca_get_width(); | |||||
int h = caca_get_height(); | |||||
int x, y, a, b; | int x, y, a, b; | ||||
if(bounds) | if(bounds) | ||||
{ | { | ||||
x = ee_rand(- w, 2 * w); y = ee_rand(- h, 2 * h); | |||||
a = ee_rand(0, w); b = ee_rand(0, h); | |||||
x = caca_rand(- w, 2 * w); y = caca_rand(- h, 2 * h); | |||||
a = caca_rand(0, w); b = caca_rand(0, h); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
do | do | ||||
{ | { | ||||
x = ee_rand(0, w); y = ee_rand(0, h); | |||||
a = ee_rand(0, w); b = ee_rand(0, h); | |||||
x = caca_rand(0, w); y = caca_rand(0, h); | |||||
a = caca_rand(0, w); b = caca_rand(0, h); | |||||
} while(x - a < 0 || x + a >= w || y - b < 0 || y + b >= h); | } while(x - a < 0 || x + a >= w || y - b < 0 || y + b >= h); | ||||
} | } | ||||
ee_set_color(ee_rand(0, 15)); | |||||
ee_fill_ellipse(x, y, a, b, '#'); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
caca_fill_ellipse(x, y, a, b, '#'); | |||||
ee_set_color(ee_rand(0, 15)); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
if(outline == 2) | if(outline == 2) | ||||
ee_draw_thin_ellipse(x, y, a, b); | |||||
caca_draw_thin_ellipse(x, y, a, b); | |||||
else if(outline == 1) | else if(outline == 1) | ||||
ee_draw_ellipse(x, y, a, b, '#'); | |||||
caca_draw_ellipse(x, y, a, b, '#'); | |||||
} | } | ||||
static void demo_triangles(void) | static void demo_triangles(void) | ||||
{ | { | ||||
int w = ee_get_width(); | |||||
int h = ee_get_height(); | |||||
int w = caca_get_width(); | |||||
int h = caca_get_height(); | |||||
int xa, ya, xb, yb, xc, yc; | int xa, ya, xb, yb, xc, yc; | ||||
if(bounds) | if(bounds) | ||||
{ | { | ||||
xa = ee_rand(- w, 2 * w); ya = ee_rand(- h, 2 * h); | |||||
xb = ee_rand(- w, 2 * w); yb = ee_rand(- h, 2 * h); | |||||
xc = ee_rand(- w, 2 * w); yc = ee_rand(- h, 2 * h); | |||||
xa = caca_rand(- w, 2 * w); ya = caca_rand(- h, 2 * h); | |||||
xb = caca_rand(- w, 2 * w); yb = caca_rand(- h, 2 * h); | |||||
xc = caca_rand(- w, 2 * w); yc = caca_rand(- h, 2 * h); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
xa = ee_rand(0, w - 1); ya = ee_rand(0, h - 1); | |||||
xb = ee_rand(0, w - 1); yb = ee_rand(0, h - 1); | |||||
xc = ee_rand(0, w - 1); yc = ee_rand(0, h - 1); | |||||
xa = caca_rand(0, w - 1); ya = caca_rand(0, h - 1); | |||||
xb = caca_rand(0, w - 1); yb = caca_rand(0, h - 1); | |||||
xc = caca_rand(0, w - 1); yc = caca_rand(0, h - 1); | |||||
} | } | ||||
ee_set_color(ee_rand(0, 15)); | |||||
ee_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
caca_fill_triangle(xa, ya, xb, yb, xc, yc, '#'); | |||||
ee_set_color(ee_rand(0, 15)); | |||||
caca_set_color(caca_rand(0, 15)); | |||||
if(outline == 2) | if(outline == 2) | ||||
ee_draw_thin_triangle(xa, ya, xb, yb, xc, yc); | |||||
caca_draw_thin_triangle(xa, ya, xb, yb, xc, yc); | |||||
else if(outline == 1) | else if(outline == 1) | ||||
ee_draw_triangle(xa, ya, xb, yb, xc, yc, '#'); | |||||
caca_draw_triangle(xa, ya, xb, yb, xc, yc, '#'); | |||||
} | } | ||||
static void demo_sprites(void) | static void demo_sprites(void) | ||||
{ | { | ||||
ee_draw_sprite(ee_rand(0, ee_get_width() - 1), | |||||
ee_rand(0, ee_get_height() - 1), sprite, 0); | |||||
caca_draw_sprite(caca_rand(0, caca_get_width() - 1), | |||||
caca_rand(0, caca_get_height() - 1), sprite, 0); | |||||
} | } | ||||
static void demo_blit(void) | static void demo_blit(void) | ||||
{ | { | ||||
ee_set_color(EE_LIGHTGRAY); | |||||
ee_blit(6, 4, ee_get_width() - 6, ee_get_height() - 4, pixels, bufx, bufy); | |||||
caca_set_color(EE_LIGHTGRAY); | |||||
caca_blit(6, 4, caca_get_width() - 6, caca_get_height() - 4, pixels, bufx, bufy); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* spritedit sprite editor using libee | |||||
* spritedit sprite editor using libcaca | |||||
* Copyright (c) 2003 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2003 Sam Hocevar <sam@zoy.org> | ||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
@@ -24,12 +24,12 @@ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include "ee.h" | |||||
#include "caca.h" | |||||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||||
{ | { | ||||
int quit = 0; | int quit = 0; | ||||
struct ee_sprite *sprite; | |||||
struct caca_sprite *sprite; | |||||
int frame = 0; | int frame = 0; | ||||
if(argc < 2) | if(argc < 2) | ||||
@@ -38,14 +38,14 @@ int main(int argc, char **argv) | |||||
return 1; | return 1; | ||||
} | } | ||||
if(ee_init()) | |||||
if(caca_init()) | |||||
return 1; | return 1; | ||||
sprite = ee_load_sprite(argv[1]); | |||||
sprite = caca_load_sprite(argv[1]); | |||||
if(!sprite) | if(!sprite) | ||||
{ | { | ||||
ee_end(); | |||||
caca_end(); | |||||
fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); | fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]); | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -56,7 +56,7 @@ int main(int argc, char **argv) | |||||
int xa, ya, xb, yb; | int xa, ya, xb, yb; | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
switch(ee_get_key()) | |||||
switch(caca_get_key()) | |||||
{ | { | ||||
case 0: | case 0: | ||||
break; | break; | ||||
@@ -68,47 +68,47 @@ int main(int argc, char **argv) | |||||
frame--; | frame--; | ||||
break; | break; | ||||
case '+': | case '+': | ||||
if(frame < ee_get_sprite_frames(sprite) - 1) | |||||
if(frame < caca_get_sprite_frames(sprite) - 1) | |||||
frame++; | frame++; | ||||
break; | break; | ||||
} | } | ||||
ee_clear(); | |||||
caca_clear(); | |||||
ee_set_color(EE_WHITE); | |||||
ee_draw_thin_box(0, 0, ee_get_width() - 1, ee_get_height() - 1); | |||||
caca_set_color(EE_WHITE); | |||||
caca_draw_thin_box(0, 0, caca_get_width() - 1, caca_get_height() - 1); | |||||
ee_putstr(3, 0, "[ Sprite editor for libee ]"); | |||||
caca_putstr(3, 0, "[ Sprite editor for libcaca ]"); | |||||
sprintf(buf, "sprite `%s'", argv[1]); | sprintf(buf, "sprite `%s'", argv[1]); | ||||
ee_putstr(3, 2, buf); | |||||
sprintf(buf, "frame %i/%i", frame, ee_get_sprite_frames(sprite) - 1); | |||||
ee_putstr(3, 3, buf); | |||||
caca_putstr(3, 2, buf); | |||||
sprintf(buf, "frame %i/%i", frame, caca_get_sprite_frames(sprite) - 1); | |||||
caca_putstr(3, 3, buf); | |||||
/* Crosshair */ | /* Crosshair */ | ||||
ee_draw_thin_line(57, 2, 57, 18); | |||||
ee_draw_thin_line(37, 10, 77, 10); | |||||
ee_putchar(57, 10, '+'); | |||||
caca_draw_thin_line(57, 2, 57, 18); | |||||
caca_draw_thin_line(37, 10, 77, 10); | |||||
caca_putchar(57, 10, '+'); | |||||
/* Boxed sprite */ | /* Boxed sprite */ | ||||
xa = -1 - ee_get_sprite_dx(sprite, frame); | |||||
ya = -1 - ee_get_sprite_dy(sprite, frame); | |||||
xb = xa + 1 + ee_get_sprite_width(sprite, frame); | |||||
yb = ya + 1 + ee_get_sprite_height(sprite, frame); | |||||
ee_set_color(EE_BLACK); | |||||
ee_fill_box(57 + xa, 10 + ya, 57 + xb, 10 + yb, ' '); | |||||
ee_set_color(EE_WHITE); | |||||
ee_draw_thin_box(57 + xa, 10 + ya, 57 + xb, 10 + yb); | |||||
ee_draw_sprite(57, 10, sprite, frame); | |||||
xa = -1 - caca_get_sprite_dx(sprite, frame); | |||||
ya = -1 - caca_get_sprite_dy(sprite, frame); | |||||
xb = xa + 1 + caca_get_sprite_width(sprite, frame); | |||||
yb = ya + 1 + caca_get_sprite_height(sprite, frame); | |||||
caca_set_color(EE_BLACK); | |||||
caca_fill_box(57 + xa, 10 + ya, 57 + xb, 10 + yb, ' '); | |||||
caca_set_color(EE_WHITE); | |||||
caca_draw_thin_box(57 + xa, 10 + ya, 57 + xb, 10 + yb); | |||||
caca_draw_sprite(57, 10, sprite, frame); | |||||
/* Free sprite */ | /* Free sprite */ | ||||
ee_draw_sprite(20, 10, sprite, frame); | |||||
caca_draw_sprite(20, 10, sprite, frame); | |||||
ee_refresh(); | |||||
caca_refresh(); | |||||
} | } | ||||
/* Clean up */ | /* Clean up */ | ||||
ee_end(); | |||||
caca_end(); | |||||
return 0; | return 0; | ||||
} | } | ||||