source: libcaca/trunk/caca/driver_raw.c @ 702

Last change on this file since 702 was 702, checked in by Sam Hocevar, 15 years ago
  • Implemented a proof-of-concept cacaplay program that can redisplay a single frame that was saved by the raw driver.
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1/*
2 *  libcaca       Colour ASCII-Art library
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the Do What The Fuck You Want To
8 *  Public License, Version 2, as published by Sam Hocevar. See
9 *  http://sam.zoy.org/wtfpl/COPYING for more details.
10 */
11
12/** \file driver_raw.c
13 *  \version \$Id: driver_raw.c 702 2006-03-27 21:33:29Z sam $
14 *  \author Sam Hocevar <sam@zoy.org>
15 *  \brief raw driver
16 *
17 *  This file contains the libcaca raw input and output driver
18 */
19
20#include "config.h"
21
22#if !defined(__KERNEL__)
23#   include <stdio.h>
24#endif
25
26#include "caca.h"
27#include "caca_internals.h"
28#include "cucul.h"
29#include "cucul_internals.h"
30
31static int raw_init_graphics(caca_t *kk)
32{
33    return 0;
34}
35
36static int raw_end_graphics(caca_t *kk)
37{
38    return 0;
39}
40
41static int raw_set_window_title(caca_t *kk, char const *title)
42{
43    return 0;
44}
45
46static unsigned int raw_get_window_width(caca_t *kk)
47{
48    return 0;
49}
50
51static unsigned int raw_get_window_height(caca_t *kk)
52{
53    return 0;
54}
55
56static void raw_display(caca_t *kk)
57{
58    uint8_t *attr = kk->qq->attr;
59    uint32_t *chars = kk->qq->chars;
60    uint32_t w, h;
61    unsigned int n;
62
63    w = kk->qq->width;
64    h = kk->qq->height;
65
66    fprintf(stdout, "CACA%c%c%c%c%c%c%c%c",
67                    (w >> 24), (w >> 16) & 0xff, (w >> 8) & 0xff, w & 0xff,
68                    (h >> 24), (h >> 16) & 0xff, (h >> 8) & 0xff, h & 0xff);
69
70    for(n = kk->qq->height * kk->qq->width; n--; )
71    {
72        uint32_t c = *chars++;
73        uint8_t a = *attr++;
74
75        fprintf(stdout, "%c%c%c%c%c", (c >> 24), (c >> 16) & 0xff,
76                                      (c >> 8) & 0xff, c & 0xff, a);
77    }
78
79    fprintf(stdout, "ACAC");
80    fflush(stdout);
81}
82
83static void raw_handle_resize(caca_t *kk)
84{
85    ;
86}
87
88static int raw_get_event(caca_t *kk, struct caca_event *ev)
89{
90    ev->type = CACA_EVENT_NONE;
91    return 0;
92}
93
94/*
95 * Driver initialisation
96 */
97
98int raw_install(caca_t *kk)
99{
100    kk->drv.driver = CACA_DRIVER_RAW;
101
102    kk->drv.init_graphics = raw_init_graphics;
103    kk->drv.end_graphics = raw_end_graphics;
104    kk->drv.set_window_title = raw_set_window_title;
105    kk->drv.get_window_width = raw_get_window_width;
106    kk->drv.get_window_height = raw_get_window_height;
107    kk->drv.display = raw_display;
108    kk->drv.handle_resize = raw_handle_resize;
109    kk->drv.get_event = raw_get_event;
110    kk->drv.set_mouse = NULL;
111
112    return 0;
113}
114
Note: See TracBrowser for help on using the repository browser.