source: buchla-68k/vlib/vsetpal.c@ 7258c6a

Last change on this file since 7258c6a was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Use standard integer types.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 =============================================================================
3 vsetpal.c -- Buchla 700 color palette setup
4 Version 2 -- 1987-11-20 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define PALETTE ((uint16_t *)0x280000L)
9
10int16_t dfltpal[16][3] = {
11
12/* R G B color */
13
14 {0, 0, 0}, /* 0: Black */
15 {0, 1, 0}, /* 1: Dark Gray */
16 {0, 0, 2}, /* 2: Dark Blue */
17 {0, 0, 3}, /* 3: Light Blue */
18 {0, 2, 0}, /* 4: Dark Green */
19 {0, 3, 0}, /* 5: Light Green */
20 {0, 2, 2}, /* 6: Dark Cyan */
21 {0, 3, 3}, /* 7: Light Cyan */
22 {3, 0, 0}, /* 8: Red */
23 {3, 1, 0}, /* 9: Orange */
24 {3, 0, 3}, /* 10: Purple */
25 {3, 1, 2}, /* 11: Magenta */
26 {3, 2, 0}, /* 12: Brown */
27 {2, 3, 0}, /* 13: Yellow */
28 {2, 2, 2}, /* 14: Light Gray */
29 {3, 3, 3}, /* 15: White */
30};
31
32/*
33
34*/
35
36/*
37 =============================================================================
38 vsetpal() -- set a palette RAM entry to a specific color
39
40 slot 0..15 color entry number
41 red 0..3 red value
42 grn 0..3 green value
43 blu 0..3 blue value
44 =============================================================================
45*/
46
47void vsetpal(uint16_t slot, uint16_t red, uint16_t grn, uint16_t blu)
48{
49 register uint16_t palval;
50 uint16_t *pal;
51
52 pal = PALETTE;
53
54 palval = (slot << 6) |
55 ((red & 1) << 5) | ((red & 2) << 1) |
56 ((grn & 1) << 4) | (grn & 2) |
57 ((blu & 1) << 3) | ((blu & 2) >> 1);
58
59 *pal = palval ^ 0x003F;
60}
61
62/*
63
64*/
65
66/*
67 =============================================================================
68 vsndpal() -- send a palette table to the video palette RAM
69
70 pp pointer to a short [16][3] array,
71
72 where:
73 pp[n][0] = blue value
74 pp[n][1] = green value
75 pp[n][2] = red value
76
77 n = slot number (0..15)
78 =============================================================================
79*/
80
81void vsndpal(int16_t pp[16][3])
82{
83 register int16_t i;
84
85 for (i = 0; i < 16; i++)
86 vsetpal(i, pp[i][0], pp[i][1], pp[i][2]);
87}
Note: See TracBrowser for help on using the repository browser.