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
101
102
103
104
105
106
107
|
diff -ru card.C card.C
--- card.C 2011-07-10 00:22:25.000000000 -0600
+++ card.C 2018-02-02 12:07:16.045153000 -0700
@@ -58,7 +58,7 @@
CardRec::CardRec(int s, int v, unsigned long fore, unsigned long back,
- const char *bitmap) {
+ const unsigned char *bitmap) {
suit = s;
value = v;
XSetWindowAttributes attributes;
@@ -284,15 +284,15 @@
////////////////////////////////////////////////////////////////
static const int BM_WIDTH = (CARDWIDTH-2+7)/8;
-static char bitmap[BM_WIDTH*(CARDHEIGHT-2)];
+static char unsigned bitmap[BM_WIDTH*(CARDHEIGHT-2)];
// or a bitmap into current card image:
-static void draw(const char* from, int x, int y, int w, int h) {
- char* to1 = bitmap+y*BM_WIDTH+x/8;
+static void draw(const unsigned char* from, int x, int y, int w, int h) {
+ unsigned char* to1 = bitmap+y*BM_WIDTH+x/8;
int shift = x%8;
for (int j = 0; j < h; j++) {
- char* to = to1; to1 += BM_WIDTH;
- char wrap = 0;
+ unsigned char* to = to1; to1 += BM_WIDTH;
+ unsigned char wrap = 0;
for (int i = 0; i < w; i += 8) {
unsigned char v = *from++;
*to++ |= (wrap | (v << shift));
@@ -339,14 +339,14 @@
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
-static void draw180(const char* from, int x, int y, int w, int h) {
+static void draw180(const unsigned char* from, int x, int y, int w, int h) {
x = CARDWIDTH-3-x;
y = CARDHEIGHT-3-y;
- char* to1 = bitmap+y*BM_WIDTH+x/8;
+ unsigned char* to1 = bitmap+y*BM_WIDTH+x/8;
int shift = 7-x%8;
for (int j = 0; j < h; j++) {
- char* to = to1; to1 -= BM_WIDTH;
- char wrap = 0;
+ unsigned char* to = to1; to1 -= BM_WIDTH;
+ unsigned char wrap = 0;
for (int i = 0; i < w; i += 8) {
unsigned char v = _reverse_byte[(unsigned char)(*from++)];
*to-- |= (wrap | (v >> shift));
@@ -357,13 +357,13 @@
}
static void draw_box(int x, int y, int w, int h) {
- char* to1 = bitmap+y*BM_WIDTH+x/8;
- char* to2 = bitmap+y*BM_WIDTH+(x+w-1)/8;
- char v1 = 1 << (x%8);
- char v2 = 1 << ((x+w-1)%8);
+ unsigned char* to1 = bitmap+y*BM_WIDTH+x/8;
+ unsigned char* to2 = bitmap+y*BM_WIDTH+(x+w-1)/8;
+ unsigned char v1 = 1 << (x%8);
+ unsigned char v2 = 1 << ((x+w-1)%8);
*to1 = *(to1+(h-1)*BM_WIDTH) = ~(v1-1);
*to2 = *(to2+(h-1)*BM_WIDTH) = (v2<<1)-1;
- for (char* t = to1+1; t < to2; t++) *t = *(t+(h-1)*BM_WIDTH) = 255;
+ for (unsigned char* t = to1+1; t < to2; t++) *t = *(t+(h-1)*BM_WIDTH) = 255;
for (int j = 2; j < h; j++) {
to1 += BM_WIDTH; *to1 |= v1;
to2 += BM_WIDTH; *to2 |= v2;
@@ -375,30 +375,30 @@
#include "suit.bm"
#include "spade_lg.bm"
-static const char* faces[4][3] = {
+static const unsigned char* faces[4][3] = {
{ jack_h_bits, queen_h_bits, king_h_bits },
{ jack_d_bits, queen_d_bits, king_d_bits },
{ jack_c_bits, queen_c_bits, king_c_bits },
{ jack_s_bits, queen_s_bits, king_s_bits }
};
-static const char* small_suit[4] = {
+static const unsigned char* small_suit[4] = {
heart_sm_bits, diamond_sm_bits, club_sm_bits, spade_sm_bits};
static const int small_suit_width[4] = {
heart_sm_width, diamond_sm_width, club_sm_width, spade_sm_width};
static const int small_suit_height[4] = {
heart_sm_height, diamond_sm_height, club_sm_height, spade_sm_height};
-static const char* suit[4] = {
+static const unsigned char* suit[4] = {
heart_bits, diamond_bits, club_bits, spade_bits};
static const int suit_width[4] = {
heart_width, diamond_width, club_width, spade_width};
static const int suit_height[4] = {
heart_height, diamond_height, club_height, spade_height};
-static char* make_bitmap(int s, int v) {
+static unsigned char* make_bitmap(int s, int v) {
memset(bitmap, 0, BM_WIDTH*(CARDHEIGHT-2)); // erase
if (v <= 9) {
- const char* b = suit[s];
+ const unsigned char* b = suit[s];
int w = suit_width[s];
int h = suit_height[s];
if (s == 3 && v == 0) { // ace of spades
|