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

Last change on this file since 811 was 811, checked in by Sam Hocevar, 15 years ago
  • Renamed caca_t into caca_display_t.
  • Renamed canvas handle variables from "c" to "cv". Eh ouais mon gros.
  • 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 *  $Id: driver_raw.c 811 2006-04-18 15:11:25Z sam $
7 *
8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 *  This file contains the libcaca raw input and output driver
16 */
17
18#include "config.h"
19
20#if !defined(__KERNEL__)
21#   include <stdio.h>
22#endif
23
24#include "caca.h"
25#include "caca_internals.h"
26#include "cucul.h"
27#include "cucul_internals.h"
28
29static int raw_init_graphics(caca_display_t *dp)
30{
31    return 0;
32}
33
34static int raw_end_graphics(caca_display_t *dp)
35{
36    return 0;
37}
38
39static int raw_set_window_title(caca_display_t *dp, char const *title)
40{
41    return 0;
42}
43
44static unsigned int raw_get_window_width(caca_display_t *dp)
45{
46    return 0;
47}
48
49static unsigned int raw_get_window_height(caca_display_t *dp)
50{
51    return 0;
52}
53
54static void raw_display(caca_display_t *dp)
55{
56    uint32_t *attr = dp->cv->attr;
57    uint32_t *chars = dp->cv->chars;
58    uint32_t w, h;
59    unsigned int n;
60
61    w = dp->cv->width;
62    h = dp->cv->height;
63
64    fprintf(stdout, "CACA%c%c%c%c%c%c%c%c",
65                    (w >> 24), (w >> 16) & 0xff, (w >> 8) & 0xff, w & 0xff,
66                    (h >> 24), (h >> 16) & 0xff, (h >> 8) & 0xff, h & 0xff);
67
68    for(n = dp->cv->height * dp->cv->width; n--; )
69    {
70        uint32_t ch = *chars++;
71        uint32_t a = *attr++;
72
73        fprintf(stdout, "%c%c%c%c%c%c%c%c",
74                (ch >> 24), (ch >> 16) & 0xff, (ch >> 8) & 0xff, ch & 0xff,
75                (a >> 24), (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff);
76    }
77
78    fprintf(stdout, "ACAC");
79    fflush(stdout);
80}
81
82static void raw_handle_resize(caca_display_t *dp)
83{
84    ;
85}
86
87static int raw_get_event(caca_display_t *dp, caca_event_t *ev)
88{
89    ev->type = CACA_EVENT_NONE;
90    return 0;
91}
92
93/*
94 * Driver initialisation
95 */
96
97int raw_install(caca_display_t *dp)
98{
99    dp->drv.driver = CACA_DRIVER_RAW;
100
101    dp->drv.init_graphics = raw_init_graphics;
102    dp->drv.end_graphics = raw_end_graphics;
103    dp->drv.set_window_title = raw_set_window_title;
104    dp->drv.get_window_width = raw_get_window_width;
105    dp->drv.get_window_height = raw_get_window_height;
106    dp->drv.display = raw_display;
107    dp->drv.handle_resize = raw_handle_resize;
108    dp->drv.get_event = raw_get_event;
109    dp->drv.set_mouse = NULL;
110
111    return 0;
112}
113
Note: See TracBrowser for help on using the repository browser.