source: buchla-68k/vlib/vsetpal.c@ 81a59aa

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

Volatile hardware accesses.

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