-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathcolors.c
100 lines (91 loc) · 3.11 KB
/
colors.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "colors.h"
// clang-format off
#define RGB333(r, g, b) (uint16_t)( \
(((((unsigned int)(r) * 256 / 36) + 128) / 256) << 6) | \
(((((unsigned int)(g) * 256 / 36) + 128) / 256) << 3) | \
((((unsigned int)(b) * 256 / 36) + 128) / 256) \
)
#define COLOR_BLACK RGB333(0x00, 0x00, 0x00)
#define COLOR_MAGENTA RGB333(0xdd, 0x00, 0x33)
#define COLOR_D_BLUE RGB333(0x00, 0x00, 0x99)
#define COLOR_H_VIOLET RGB333(0xdd, 0x22, 0xdd)
#define COLOR_D_GREEN RGB333(0x00, 0x77, 0x22)
#define COLOR_D_GRAY RGB333(0x55, 0x55, 0x55)
#define COLOR_H_BLUE RGB333(0x22, 0x22, 0xff)
#define COLOR_L_BLUE RGB333(0x66, 0xaa, 0xff)
#define COLOR_BROWN RGB333(0x88, 0x55, 0x00)
#define COLOR_H_ORANGE RGB333(0xff, 0x66, 0x00)
#define COLOR_L_GRAY RGB333(0xaa, 0xaa, 0xaa)
#define COLOR_PINK RGB333(0xff, 0x99, 0x88)
#define COLOR_H_GREEN RGB333(0x11, 0xdd, 0x00)
#define COLOR_YELLOW RGB333(0xff, 0xff, 0x00)
#define COLOR_AQUA RGB333(0x44, 0xff, 0x99)
#define COLOR_WHITE RGB333(0xff, 0xff, 0xff)
#define COLOR_MONO_AMBER_BG RGB333(0x12, 0x12, 0x00)
#define COLOR_MONO_AMBER_FG RGB333(0xff, 0xb0, 0x00)
#define COLOR_MONO_GREEN_BG RGB333(0x00, 0x12, 0x00)
#define COLOR_MONO_GREEN_FG RGB333(0x33, 0xff, 0x33)
// clang-format on
// This is the color palette generated by NTSC artifact color when shifted out LSB -> MSB
// and phase-synchronized with the color reference signal.
//
// Ref: Understanding the Apple II, page 8-24, or Understanding the Apple IIe, page 8-39
const uint16_t ntsc_palette[16] = {
COLOR_BLACK,
COLOR_MAGENTA,
COLOR_D_BLUE,
COLOR_H_VIOLET,
COLOR_D_GREEN,
COLOR_D_GRAY,
COLOR_H_BLUE,
COLOR_L_BLUE,
COLOR_BROWN,
COLOR_H_ORANGE,
COLOR_L_GRAY,
COLOR_PINK,
COLOR_H_GREEN,
COLOR_YELLOW,
COLOR_AQUA,
COLOR_WHITE,
};
// This is the color palette generated by NTSC artifact color when shifted out LSB -> MSB with phase
// offset by 90 degrees from the color reference signal. This is used by double-res modes because video
// out timing is shifted when AUX memory is being used.
//
// Ref: Understanding the Apple IIe, page 8-29
//
// The bits indexing this table are the same as ntsc_palette, but the 4 bit value is rotated right by 1
// to account for the 90-degree phase difference with the color reference signal. For example, violet is
// position 3 (0b0011) in the ntsc_palette, but in this phase-shifted palette it's at position 9 (0b1001).
const uint16_t ntsc90_palette[16] = {
COLOR_BLACK,
COLOR_D_BLUE,
COLOR_D_GREEN,
COLOR_H_BLUE,
COLOR_BROWN,
COLOR_L_GRAY,
COLOR_H_GREEN,
COLOR_AQUA,
COLOR_MAGENTA,
COLOR_H_VIOLET,
COLOR_D_GRAY,
COLOR_L_BLUE,
COLOR_H_ORANGE,
COLOR_PINK,
COLOR_YELLOW,
COLOR_WHITE,
};
const uint16_t mono_bg_colors[4] = {
COLOR_BLACK, // entry 0 is unusable
COLOR_BLACK,
COLOR_MONO_GREEN_BG,
COLOR_MONO_AMBER_BG,
};
const uint16_t mono_fg_colors[4] = {
COLOR_WHITE, // entry 0 is unusable
COLOR_WHITE,
COLOR_MONO_GREEN_FG,
COLOR_MONO_AMBER_FG,
};
uint16_t mono_bg_color = COLOR_BLACK;
uint16_t mono_fg_color = COLOR_WHITE;