Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
169 giacomo 1
/* VGAlib version 1.2 - (c) 1993 Tommy Frandsen                    */
2
/*                                                                 */
3
/* This library is free software; you can redistribute it and/or   */
4
/* modify it without any restrictions. This library is distributed */
5
/* in the hope that it will be useful, but without any warranty.   */
6
 
7
/* Multi-chipset support Copyright 1993 Harm Hanemaayer */
8
/* partially copyrighted (C) 1993 by Hartmut Schirmer */
9
 
10
#include <stdlib.h>
11
 
12
#include "vga.h"
13
#include "libvga.h"
14
 
15
int vga_setrgbcolor(int r, int g, int b)
16
{
17
    switch (CI.colors) {
18
    case 32768:
19
        COL =
20
            (b >> 3) +
21
            ((g >> 3) << 5) +
22
            ((r >> 3) << 10);
23
        break;
24
    case 65536:
25
        COL =
26
            (b >> 3) +
27
            ((g >> 2) << 5) +
28
            ((r >> 3) << 11);
29
        break;
30
    case 1 << 24:
31
        COL = b + (g << 8) + (r << 16);
32
        break;
33
    default:
34
        return 0;
35
    }
36
    return COL;
37
}
38
 
39
static const unsigned char ega_red[16] =
40
{0, 0, 0, 0, 168, 168, 168, 168, 84, 84, 84, 84, 255, 255, 255, 255};
41
static const unsigned char ega_green[16] =
42
{0, 0, 168, 168, 0, 0, 84, 168, 84, 84, 255, 255, 84, 84, 255, 255};
43
static const unsigned char ega_blue[16] =
44
{0, 168, 0, 168, 0, 168, 0, 168, 84, 255, 84, 255, 84, 255, 84, 255};
45
 
46
int vga_setegacolor(int c)
47
{
48
    if (c < 0)
49
        c = 0;
50
    else if (c > 15)
51
        c = 15;
52
    switch (CI.colors) {
53
    case 1 << 15:
54
    case 1 << 16:
55
    case 1 << 24:
56
        return vga_setrgbcolor(ega_red[c], ega_green[c], ega_blue[c]);
57
    }
58
    vga_setcolor(c);
59
    return c;
60
}