[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcaca] Re: a conversion script, and patches for libcaca, and ttyvaders
- To: libcaca@lists.zoy.org
- Subject: [libcaca] Re: a conversion script, and patches for libcaca, and ttyvaders
- From: "Ben Wiley Sittler" <bsittler@gmail.com>
- Date: Sun, 24 Jun 2007 02:02:19 -0700
- Delivered-to: list-libcaca@zoy.org
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=B6N1wqri3lyDNP+DmkoGVACdhvQ74ZXTtUFUQqKi0+kS7eCuLCZqI8jmUu2K220JjWtNbIpi5Yr/aDSNsZXgdTTGIGjegsQ+7uhNVOpJfgYb2r8eP+KCdM23rXpYsQqYGUuZhIyjx0zsLWEb1epM3gtW/kBlnsdeC3LPP9+Meuk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GZtp8S0wuWg9ikdHzl/x0VKdCalG/g7UCviFyQN+zan7gXbYMUJWb/UJoqDoxnEeXe0FzVug0xv2s56xeP2yaKvK3naIj9hP0q33Q7OvAfxAeQnZOFvHYaX7JdY78Q+FHwD9Krfxl4LIygjiEzd5KNXTkDVSwWJVMD2vDZsY1Vs=
- In-reply-to: <c05211120706240157s12f6ee54le0657343b3cdb7d7@mail.gmail.com>
- References: <1169276494.9366.28.camel@localhost.localdomain> <20070120135315.GY28089@zoy.org> <c05211120706240157s12f6ee54le0657343b3cdb7d7@mail.gmail.com>
- Reply-to: libcaca@lists.zoy.org
- Sender: libcaca-bounce@lists.zoy.org
should have mentioned: to build myman with libcaca backend, do this:
./configure --with-libcaca --enable-variants=myman
make
also, since myman was originally written to use curses, the port was
accomplished with the following glue code which others might find
useful as a starting point in porting from curses to caca:
#ifdef CACA_API_VERSION_1
/* libcaca 1.0+ */
#define USE_PALETTE 1
typedef unsigned long int chtype;
static cucul_canvas_t *cv;
static caca_display_t *dp;
static int cacacurses_x, cacacurses_y;
static chtype pal[16];
#ifndef OK
#define OK (0)
#endif
#ifndef ERR
#define ERR (-1)
#endif
#define clear erase
#define cbreak()
#define noecho()
#define nonl()
#define nodelay(stdscr, x)
#define intrflush(stdscr, x)
#define idlok(stdscr, x)
#define clearok(stdscr, x)
#define leaveok(stdscr, x)
#define getyx(stdscr, y, x) ((y) = cacacurses_y), ((x) = cacacurses_x)
#define wrefresh(stdscr) refresh()
#define beep() addch('\7')
#define echo()
#define attrset(a) cucul_set_color_ansi(cv, CUCUL_DEFAULT,
CUCUL_TRANSPARENT), cucul_set_attr(cv, (a))
#define curs_set(x)
#define keypad(stdscr, x)
#define can_change_color() 1
#define has_colors() 1
#define start_color()
#define COLOR_PAIR(i) (pal[(i)])
#define LINES (cucul_get_canvas_height(cv))
#define COLS (cucul_get_canvas_width(cv))
#define COLOR_BLACK CUCUL_BLACK
#define COLOR_BLUE CUCUL_BLUE
#define COLOR_GREEN CUCUL_GREEN
#define COLOR_CYAN CUCUL_CYAN
#define COLOR_RED CUCUL_RED
#define COLOR_MAGENTA CUCUL_MAGENTA
#define COLOR_YELLOW CUCUL_BROWN
#define COLOR_WHITE CUCUL_LIGHTGRAY
#define COLORS 16
#define COLOR_PAIRS 16
#define A_BOLD CUCUL_BOLD
#define A_UNDERLINE CUCUL_UNDERLINE
#define A_STANDOUT CUCUL_BLINK
#define KEY_LEFT CACA_KEY_LEFT
#define KEY_RIGHT CACA_KEY_RIGHT
#define KEY_UP CACA_KEY_UP
#define KEY_DOWN CACA_KEY_DOWN
static void initscr(int h, int w) {
if (w < 60) w = 60;
if (w > 128) w = 128;
if (h > 50) h = 50;
cv = cucul_create_canvas(w, h);
dp = caca_create_display(cv);
if (! dp)
{
perror("caca_create_display");
exit(1);
}
cucul_put_char(cv, 0, 0, ' ');
pal[0] = cucul_get_attr(cv, 0, 0);
caca_set_display_title(dp, "MyMan [" MYMAN " " VERSION "]");
}
static void endwin(void) {
caca_free_display(dp);
cucul_free_canvas(cv);
}
static int erase(void) {
cucul_clear_canvas(cv);
cucul_gotoxy(cv, -1, -1);
cacacurses_x = 0;
cacacurses_y = 0;
return OK;
}
static int refresh(void) {
caca_refresh_display(dp);
return OK;
}
static chtype getch(void) {
caca_event_t ev;
if (caca_get_event(dp, CACA_EVENT_KEY_PRESS |
CACA_EVENT_KEY_RELEASE | CACA_EVENT_QUIT, & ev, 0))
{
if (ev.type == CACA_EVENT_QUIT) return 'Q';
if (ev.type == CACA_EVENT_KEY_PRESS) return ev.data.key.ch;
}
return ERR;
}
static void standout() {
cucul_set_attr(cv, CUCUL_BLINK);
cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
}
static void standend() {
cucul_set_attr(cv, 0);
}
static void move(y, x) {
cacacurses_y = y;
cacacurses_x = x;
}
static int addch(const chtype ch) {
cucul_put_char(cv, cacacurses_x, cacacurses_y, ch);
cacacurses_x ++;
return OK;
}
static int addstr(const char *s) {
while (*s)
{
addch(*s++);
}
return OK;
}
static int mvprintw(int y, int x, const char *s) {
move(y, x);
return addstr(s);
}
static int init_color(int i, short r, short g, short b) {
cucul_set_color_argb(cv, 0xf000 | ((r * 0xf / 1000) << 8) | ((g *
0xf / 1000) << g) | (b * 0xf / 1000), 0xf000);
cucul_put_char(cv, 0, 0, ' ');
pal[i] = cucul_get_attr(cv, 0, 0) | ((i > 7) ? CUCUL_BOLD : 0);
return OK;
}
static int color_content(int i, short *r, short *g, short *b) {
*r = (i & 1) ? ((i & 8) ? 1000 : 500 ) : 0;
*g = (i & 2) ? ((i & 8) ? 1000 : 500 ) : 0;
*b = (i & 4) ? ((i & 8) ? 1000 : 500 ) : 0;
return OK;
}
static int init_pair(int i, short fg, short bg) {
cucul_set_color_ansi(cv, fg, bg);
cucul_put_char(cv, 0, 0, ' ');
pal[i] = cucul_get_attr(cv, 0, 0) | ((i > 7) ? CUCUL_BOLD : 0);
return OK;
}
static int pair_content(int i, short *fg, short *bg) {
*fg = CUCUL_DEFAULT;
*bg = CUCUL_TRANSPARENT;
return OK;
}
#else
/* older (pre-1.0) libcaca */
#define USE_COLOR 1
#define USE_PALETTE 1
#define SWAPDOTS 1
typedef unsigned long int chtype;
static int cacacurses_x, cacacurses_y;
static chtype pal[16];
#ifndef OK
#define OK (0)
#endif
#ifndef ERR
#define ERR (-1)
#endif
#define clear erase
#define cbreak()
#define noecho()
#define nonl()
#define nodelay(stdscr, x)
#define intrflush(stdscr, x)
#define idlok(stdscr, x)
#define clearok(stdscr, x)
#define leaveok(stdscr, x)
#define getyx(stdscr, y, x) ((y) = cacacurses_y), ((x) = cacacurses_x)
#define wrefresh(stdscr) refresh()
#define beep() addch('\7')
#define echo()
#define attrset(a) caca_set_color(a ? a : CACA_COLOR_LIGHTGRAY,
CACA_COLOR_BLACK)
#define curs_set(x)
#define keypad(stdscr, x)
#define can_change_color() 1
#define has_colors() 1
#define start_color()
#define COLOR_PAIR(i) (pal[(i)])
#define LINES (caca_get_height())
#define COLS (caca_get_width())
#define COLOR_BLACK CACA_COLOR_BLACK
#define COLOR_BLUE CACA_COLOR_BLUE
#define COLOR_GREEN CACA_COLOR_GREEN
#define COLOR_CYAN CACA_COLOR_CYAN
#define COLOR_RED CACA_COLOR_RED
#define COLOR_MAGENTA CACA_COLOR_MAGENTA
#define COLOR_YELLOW CACA_COLOR_BROWN
#define COLOR_WHITE CACA_COLOR_LIGHTGRAY
#define COLORS 16
#define COLOR_PAIRS 16
#define A_BOLD CACA_COLOR_WHITE
#define A_UNDERLINE CACA_COLOR_BLUE
#define ACS_LRCORNER ('j' - '_')
#define ACS_URCORNER ('k' - '_')
#define ACS_ULCORNER ('l' - '_')
#define ACS_LLCORNER ('m' - '_')
#define ACS_HLINE ('q' - '_')
#define ACS_LTEE ('t' - '_')
#define ACS_RTEE ('u' - '_')
#define ACS_BTEE ('v' - '_')
#define ACS_TTEE ('w' - '_')
#define ACS_VLINE ('x' - '_')
#define ACS_BULLET ('~' - '_')
#define PEN_BRIGHT 8
#define KEY_LEFT CACA_KEY_LEFT
#define KEY_RIGHT CACA_KEY_RIGHT
#define KEY_UP CACA_KEY_UP
#define KEY_DOWN CACA_KEY_DOWN
static int use_acs;
static int swapdots;
static void initscr(int h, int w) {
char g[80];
if (w < 60) w = 60;
if (w > 128) w = 128;
if (h > 50) h = 50;
sprintf(g, "CACA_GEOMETRY=%dx%d", w, h);
if ((! getenv("CACA_GEOMETRY")) || ! *(getenv("CACA_GEOMETRY"))) putenv(g);
if (caca_init())
{
fprintf(stderr, "caca_init() failed\n");
fflush(stderr);
exit(1);
}
if (getenv("DISPLAY") && *getenv("DISPLAY") && (!
getenv("CACA_DRIVER") || ! strcasecmp(getenv("CACA_DRIVER"), "x11")))
{
use_acs = 1;
swapdots = 1;
}
else
{
use_acs = 0;
swapdots = 0;
}
caca_set_feature(CACA_BACKGROUND_BLACK);
pal[0] = (CACA_COLOR_LIGHTGRAY << 4) | CACA_COLOR_BLACK;
caca_set_window_title("MyMan [" MYMAN " " VERSION "]");
}
static void endwin(void) {
caca_end();
}
static int erase(void) {
caca_clear();
cacacurses_x = 0;
cacacurses_y = 0;
return OK;
}
static int refresh(void) {
caca_refresh();
return OK;
}
static chtype getch(void) {
unsigned int ev;
ev = caca_get_event(CACA_EVENT_KEY_PRESS);
if (ev & ~CACA_EVENT_ANY)
{
return ev & ~CACA_EVENT_ANY;
}
return ERR;
}
static void standout() {
caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_WHITE);
}
static void standend() {
caca_set_color(CACA_COLOR_LIGHTGRAY, CACA_COLOR_BLACK);
}
static void move(y, x) {
cacacurses_y = y;
cacacurses_x = x;
}
static int addch(const chtype ch) {
caca_putchar(cacacurses_x, cacacurses_y, ch);
cacacurses_x ++;
return OK;
}
static int addstr(const char *s) {
while (*s)
{
addch(*s++);
}
return OK;
}
static int mvprintw(int y, int x, const char *s) {
move(y, x);
return addstr(s);
}
static int init_color(int i, short r, short g, short b) {
pal[i] = i;
return OK;
}
static int color_content(int i, short *r, short *g, short *b) {
*r = (i & 1) ? ((i & 8) ? 1000 : 500 ) : 0;
*g = (i & 2) ? ((i & 8) ? 1000 : 500 ) : 0;
*b = (i & 4) ? ((i & 8) ? 1000 : 500 ) : 0;
return OK;
}
static int init_pair(int i, short fg, short bg) {
pal[i] = i;
return OK;
}
static int pair_content(int i, short *fg, short *bg) {
*fg = i;
*bg = CACA_COLOR_BLACK;
return OK;
}
#endif
#endif
On 6/24/07, Ben Wiley Sittler <bsittler@gmail.com> wrote:
just finished an experimental port of MyMan to libcaca, and it's at:
http://zoehep.xent.com/~bsittler/myman-0.7pre1.tar.gz
to make it work well with current versions of libcaca required some
patching. i added more cp437 support in the x11 driver (all of box
drawings are now emulated) and required adding one character in the gl
driver (u+25a0). i also added support for latin-1 and unicode fonts in
the x11 driver, so e.g.
export CACA_FONT='-unknown-freemono-medium-r-normal--0-0-0-0-c-0-iso10646-1'
will permit fairly complete unicode text display. here's the updated patch:
http://zoehep.xent.com/~bsittler/libcaca-trunk-1104.diff
this also includes the older patch for multi-frame sprite loading.
On 1/20/07, Sam Hocevar <sam@zoy.org> wrote:
> On Fri, Jan 19, 2007, Benjamin C. Wiley Sittler wrote:
>
> > i checked out the latest svn revisions of libcaca and ttyvaders, and lo
> > and behold -- ttyvaders had been replaced by the "rofl|rofl"
> > side-scroller! this would not do, so i revived(?) the regular game,
> > leaving the side-scroller as a pre-intro. this required patches to
> > libcaca and ttyvaders, and the creation of a new utility -- txt2caca.py
> > (sorry, it's python rather than c) for conversion from ttyvaders old
> > text-based animation format to the modern "caca" animation file format.
> > anyhow, here they are:
>
> Thanks for your contributions! It's nice to see some interest from
> new people.
>
> The main reason I'd like to change ttyvaders from a top-down scroller
> to a side scroller is that most terminals have 80 columns but only 24 or
> 25 lines, thus allowing for smoother horizontal scrolling. The ugly
> sprites are, as you may have guessed, because I did not convert previous
> sprites to the new format.
>
> I'll review your patches and get back to you later.
>
> Regards,
> --
> Sam.
> --
> This is the libcaca mailing-list, see http://libcaca.zoy.org/
> Trouble unsubscribing? Please contact <sam@zoy.org>
> List archives are at http://libcaca.zoy.org/list/
>
>
--
This is the libcaca mailing-list, see http://libcaca.zoy.org/
Trouble unsubscribing? Please contact <sam@zoy.org>
List archives are at http://libcaca.zoy.org/list/