* Merged caca_show_cursor() and caca_hide_cursor() into caca_set_mouse() so
that we have one function less.
* Fixed coding style.
* Removed FUCKING TABS. ____.------.___
_______.----'`` ``` `` ``` ``-.
_.--' ` ```` ` ` ` ``` `` `` ``.
_.-' ' ` `` ``` `` ` `' `. _
.-'' ` H A H A H A `' M A I S \/.)
. . .-' / ` ` ` `` ||
|`-.(``-. ` ` ` ' ` ` ``` |\
`. '\```\ `` ` V I E U X ' ' `` `-`` -|\\
`/''````) `` ` - - ````` ' '.' |\_)
|`'_._` ``` ''` P O R C . . ```` /
// @) \ ` `` ''' . ``` '/
/''''' | ` \).`.'-. ''' _ _ .`` ` '/
.''''- `-'`. . // )-- '/,,',,' ,,,,''__,._`' ' /
.' ` `- ` ' .' / ' /,;;;, ,___.---' \ '' / \
(`. .'` __',`''''.--'/ ' /'-----' | ' / ))
`'-'/ `'''_.---' \;;|- '/ ,,, | ''|`- |
`'--'---' |;| / ,,,,;;;;;;;;;;,,,,, |-' /` |
|;|-'| ,;;;;;;;;;;;;;;;; ;;;/ /|`'''
''',,,''',,,,,,,,,,,,,,,' /,,'''
''''
18 lat temu |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /*
- * libcaca Colour ASCII-Art library
- * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
- * All Rights Reserved
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the Do What The Fuck You Want To
- * Public License, Version 2, as published by Sam Hocevar. See
- * http://sam.zoy.org/wtfpl/COPYING for more details.
- */
-
- /** \file driver_vga.c
- * \version \$Id$
- * \author Sam Hocevar <sam@zoy.org>
- * \brief VGA driver
- *
- * This file contains the libcaca VGA input and output driver
- */
-
- #include "config.h"
-
- #if defined(USE_VGA)
-
- #include "caca.h"
- #include "caca_internals.h"
- #include "cucul.h"
- #include "cucul_internals.h"
-
- /* Address of the VGA screen */
- #define VGA_SCREEN ((char *)(intptr_t)0x000b8000)
-
- static uint8_t const vga_colors[][4] =
- {
- /* Colour values range from 0x00 to 0x3f */
- { 0, 0x00, 0x00, 0x00 },
- { 1, 0x00, 0x00, 0x1f },
- { 2, 0x00, 0x1f, 0x00 },
- { 3, 0x00, 0x1f, 0x1f },
- { 4, 0x1f, 0x00, 0x00 },
- { 5, 0x1f, 0x00, 0x1f },
- { 0x14, 0x1f, 0x1f, 0x00 },
- { 7, 0x1f, 0x1f, 0x1f },
-
- { 0x38, 0x0f, 0x0f, 0x0f },
- { 0x39, 0x0f, 0x0f, 0x3f },
- { 0x3a, 0x0f, 0x3f, 0x0f },
- { 0x3b, 0x0f, 0x3f, 0x3f },
- { 0x3c, 0x3f, 0x0f, 0x0f },
- { 0x3d, 0x3f, 0x0f, 0x3f },
- { 0x3e, 0x3f, 0x3f, 0x0f },
- { 0x3f, 0x3f, 0x3f, 0x3f },
- };
-
- static int vga_init_graphics(caca_t *kk)
- {
- int i;
- uint8_t tmp;
-
- /* Blank screen */
- memset(VGA_SCREEN, 0, 80 * 25 * 2);
-
- /* Fill VGA palette */
- for(i = 0; i < 16; i++)
- {
- outb(vga_colors[i][0], 0x3c8);
- outb(vga_colors[i][1], 0x3c9);
- outb(vga_colors[i][2], 0x3c9);
- outb(vga_colors[i][3], 0x3c9);
- }
-
- /* Hide cursor */
- outb(0x0a, 0x3d4);
- tmp = inb(0x3d5);
- tmp |= 0x20;
- outb(0x0a, 0x3d4);
- outb(tmp, 0x3d5);
-
- /* We don't have much choice */
- _cucul_set_size(kk->qq, 80, 25);
-
- return 0;
- }
-
- static int vga_end_graphics(caca_t *kk)
- {
- uint8_t tmp;
-
- /* Show cursor again */
- outb(0x0a, 0x3d4);
- tmp = inb(0x3d5);
- tmp &= 0xdf;
- outb(0x0a, 0x3d4);
- outb(tmp, 0x3d5);
-
- return 0;
- }
-
- static int vga_set_window_title(caca_t *kk, char const *title)
- {
- /* Unsupported, of course. */
- return 0;
- }
-
- static unsigned int vga_get_window_width(caca_t *kk)
- {
- /* Fallback to a 320x200 screen */
- return 320;
- }
-
- static unsigned int vga_get_window_height(caca_t *kk)
- {
- /* Fallback to a 320x200 screen */
- return 200;
- }
-
- static void vga_display(caca_t *kk)
- {
- char *screen = (char *)(intptr_t)0x000b8000;
- uint32_t *attr = kk->qq->attr;
- uint32_t *chars = kk->qq->chars;
- int n;
-
- for(n = kk->qq->height * kk->qq->width; n--; )
- {
- *screen++ = _cucul_utf32_to_cp437(*chars++);
- *screen++ = _cucul_argb32_to_ansi8(*attr++);
- }
- }
-
- static void vga_handle_resize(caca_t *kk)
- {
- /* We know nothing about our window */
- kk->resize.w = kk->qq->width;
- kk->resize.h = kk->qq->height;
- }
-
- static int vga_get_event(caca_t *kk, struct caca_event *ev)
- {
- /* FIXME */
- ev->type = CACA_EVENT_NONE;
- return 0;
- }
-
- /*
- * Driver initialisation
- */
-
- int vga_install(caca_t *kk)
- {
- kk->drv.driver = CACA_DRIVER_VGA;
-
- kk->drv.init_graphics = vga_init_graphics;
- kk->drv.end_graphics = vga_end_graphics;
- kk->drv.set_window_title = vga_set_window_title;
- kk->drv.get_window_width = vga_get_window_width;
- kk->drv.get_window_height = vga_get_window_height;
- kk->drv.display = vga_display;
- kk->drv.handle_resize = vga_handle_resize;
- kk->drv.get_event = vga_get_event;
- kk->drv.set_mouse = NULL;
-
- return 0;
- }
-
- #endif /* USE_VGA */
-
|