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

Last change on this file since 724 was 724, checked in by Sam Hocevar, 14 years ago
  • Store colour information on 32 bits, for future 12-bit colour support.
  • Property svn:keywords set to Id
File size: 2.5 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 724 2006-04-06 13:41:56Z 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    uint32_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        uint32_t a = *attr++;
74
75        fprintf(stdout, "%c%c%c%c%c%c%c%c",
76                (c >> 24), (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff,
77                (a >> 24), (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff);
78    }
79
80    fprintf(stdout, "ACAC");
81    fflush(stdout);
82}
83
84static void raw_handle_resize(caca_t *kk)
85{
86    ;
87}
88
89static int raw_get_event(caca_t *kk, struct caca_event *ev)
90{
91    ev->type = CACA_EVENT_NONE;
92    return 0;
93}
94
95/*
96 * Driver initialisation
97 */
98
99int raw_install(caca_t *kk)
100{
101    kk->drv.driver = CACA_DRIVER_RAW;
102
103    kk->drv.init_graphics = raw_init_graphics;
104    kk->drv.end_graphics = raw_end_graphics;
105    kk->drv.set_window_title = raw_set_window_title;
106    kk->drv.get_window_width = raw_get_window_width;
107    kk->drv.get_window_height = raw_get_window_height;
108    kk->drv.display = raw_display;
109    kk->drv.handle_resize = raw_handle_resize;
110    kk->drv.get_event = raw_get_event;
111    kk->drv.set_mouse = NULL;
112
113    return 0;
114}
115
Note: See TracBrowser for help on using the repository browser.