summary refs log tree commit diff
path: root/cards/cards.3
blob: fd460514586c4cc89614664669ee565d7548b97c (plain) (blame)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
.Dd August 22, 2019
.Dt CARDS 3
.Os
.
.Sh NAME
.Nm Cards_LoadCards ,
.Nm Cards_LoadFreeCell ,
.Nm Cards_InvertSurface
.Nd bitmap resource loader
.
.Sh SYNOPSIS
.In cards.h
.
.Ft int
.Fo Cards_LoadCards
.Fa "SDL_Surface *surfaces[]"
.Fa "size_t count"
.Fa "SDL_RWops *rw"
.Fa "enum Cards_Flag flags"
.Fc
.
.Ft int
.Fo Cards_LoadFreeCell
.Fa "SDL_Surface *surfaces[]"
.Fa "size_t count"
.Fa "SDL_RWops *rw"
.Fa "enum Cards_Flag flags"
.Fc
.
.Ft int
.Fn Cards_InvertSurface "SDL_Surface *surface"
.
.Sh DESCRIPTION
.Fn Cards_LoadCards
and
.Fn Cards_LoadFreeCell
load bitmap resources
into an array of
.Fa count
surfaces.
Resources can be loaded
from 16-bit NE executables
or from 32-bit PE executables.
.
.Pp
.Fn Cards_LoadCards
loads card bitmaps from a
.Pa CARDS.DLL
or Windows 3.0
.Pa SOL.EXE
file
.Fa rw .
.
.Pp
Indices of loaded surfaces
are defined by the following:
.Bl -tag -width Ds -offset indent
.It Suit
.Dv Cards_Club ,
.Dv Cards_Diamond ,
.Dv Cards_Heart ,
.Dv Cards_Spade .
.It Rank
.Dv Cards_A ,
.Dv Cards_2 ,
.Dv Cards_3 ,
.Dv Cards_4 ,
.Dv Cards_5 ,
.Dv Cards_6 ,
.Dv Cards_7 ,
.Dv Cards_8 ,
.Dv Cards_9 ,
.Dv Cards_10 ,
.Dv Cards_J ,
.Dv Cards_Q ,
.Dv Cards_K .
.It Back
.Dv Cards_Back1 ,
.Dv Cards_Back2 ,
.Dv Cards_Back3 ,
.Dv Cards_Back4 ,
.Dv Cards_Back5 ,
.Dv Cards_Back6 ,
.Dv Cards_Back7 ,
.Dv Cards_Back8 ,
.Dv Cards_Back9 ,
.Dv Cards_Back10 ,
.Dv Cards_Back11 ,
.Dv Cards_Back12 .
.It Other
.Dv Cards_Empty ,
.Dv Cards_X ,
.Dv Cards_O .
.El
.
.Pp
Where suit and rank constants
are added together to form an index.
Note that there are gaps in the indices
and some surface pointers will be set to
.Dv NULL .
The maximum number of surfaces
is defined by
.Dv Cards_CardCount .
.
.Pp
The dimensions of the loaded surfaces
are defined by
.Dv Cards_CardWidth
and
.Dv Cards_CardHeight .
.
.Pp
.Fn Cards_LoadCards
accepts the following flags:
.Bl -tag -width "Cards_BlackBorders" -offset indent
.It Dv Cards_ColorKey
Use color key transparency for the
.Dv Cards_Empty ,
.Dv Cards_X
and
.Dv Cards_O
surfaces.
.It Dv Cards_AlphaCorners
Make the rounded card corners transparent.
.It Dv Cards_BlackBorders
Make all card borders black.
.El
.
.Pp
.Fn Cards_LoadFreeCell
loads bitmaps from a
.Pa FREECELL.EXE
file
.Fa rw .
.
.Pp
Indices of loaded surfaces
are defined by
.Dv Cards_KingRight ,
.Dv Cards_KingLeft
and
.Dv Cards_KingWin .
Note that there are gaps in the indices
and some surface pointers will be set to
.Dv NULL .
The maximum number of surfaces
is defined by
.Dv Cards_FreeCellCount .
.
.Pp
The dimensions of the loaded surfaces
are defined by
.Dv Cards_KingWidth
and
.Dv Cards_KingHeight .
.
.Pp
.Fn Cards_LoadFreeCell
accepts the following flags:
.Bl -tag -width "Cards_ColorKey" -offset indent
.It Dv Cards_ColorKey
Use color key transparency.
.El
.
.Pp
.Fn Cards_InvertSurface
inverts the colors of a surface loaded by
.Fn Cards_LoadCards .
.
.Sh RETURN VALUES
Upon successful completion,
the value 0 is returned;
otherwise the value -1 is returned.
.
.Sh FILES
The
.Lk https://code.causal.agency/june/cards.dll "cards.dll repository"
contains various versions
of the files
.Pa CARDS.DLL ,
.Pa FREECELL.EXE
and
.Pa SOL.EXE .
.
.Sh EXAMPLES
See
.Pa example.c .
.
.Sh ERRORS
Error messages are set with
.Fn SDL_SetError
and can be retrieved with
.Fn SDL_GetError .
.
.Pp
.Fn Cards_LoadCards
and
.Fn Cards_LoadFreeCell
may fail for the following reasons:
any
.Vt SDL_RWops
or
.Vt SDL_Surface
error;
invalid MZ, NE or PE signatures;
missing resource table;
invalid resource hierarchy;
missing resource.
.
.Pp
.Fn Cards_InvertSurface
may fail for any
.Vt SDL_Surface
error
or if the surface format is not supported.
.
.Sh STANDARDS
.Bl -item
.It
The New Executable format,
documented in
.Pa exefmt.txt .
.It
The Portable Executable format,
documented at
.Lk https://docs.microsoft.com/en-us/windows/desktop/Debug/pe-format .
.El
.
.Sh AUTHORS
.An June McEnroe Aq Mt june@causal.agency