summaryrefslogtreecommitdiff
path: root/games-engines/frotz/files/frotz-2.53-uint32.patch
blob: 18e7d244c272fed9805258d519caf62d5bba8523 (plain)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
Description: Use uint32_t instead of ulong
Author: Stephen Kitt <skitt@debian.org>

When built with hardening enabled, there’s a ulong/uint32_t definition
conflict; since the type is supposed to be uint32_t, use that
directly.

--- a/src/sdl/sf_frotz.h
+++ b/src/sdl/sf_frotz.h
@@ -12,13 +12,13 @@
 #include "../blorb/blorb.h"
 
 #include <stdint.h>
+#include <sys/types.h>
 typedef uint8_t byte;
 typedef uint16_t word;
-#define ulong uint32_t
 
 typedef struct {
 	bb_result_t bbres;
-	ulong type;
+	uint32_t type;
 	FILE *file;
 } myresource;
 
@@ -54,7 +54,7 @@
 #endif
 
 /* this assumes RGBA with lsb = R */
-static inline ulong RGB5ToTrue(word w)
+static inline uint32_t RGB5ToTrue(word w)
 {
 	int _r = w & 0x001F;
 	int _g = (w & 0x03E0) >> 5;
@@ -62,10 +62,10 @@
 	_r = (_r << 3) | (_r >> 2);
 	_g = (_g << 3) | (_g >> 2);
 	_b = (_b << 3) | (_b >> 2);
-	return (ulong) (_r | (_g << 8) | (_b << 16));
+	return (uint32_t) (_r | (_g << 8) | (_b << 16));
 }
 
-static inline word TrueToRGB5(ulong u)
+static inline word TrueToRGB5(uint32_t u)
 {
 	return (word) (((u >> 3) & 0x001f) | ((u >> 6) & 0x03e0) |
 		       ((u >> 9) & 0x7c00));
@@ -81,10 +81,10 @@
 extern int m_v6scale;
 extern double m_gfxScale_w;
 extern double m_gfxScale_h;
-extern ulong m_defaultFore;
-extern ulong m_defaultBack;
-extern ulong m_colours[11];
-extern ulong m_nonStdColours[NON_STD_COLS];
+extern uint32_t m_defaultFore;
+extern uint32_t m_defaultBack;
+extern uint32_t m_colours[11];
+extern uint32_t m_nonStdColours[NON_STD_COLS];
 extern int m_nonStdIndex;
 extern bool m_exitPause;
 extern bool m_lineInput;
@@ -118,7 +118,7 @@
 	int number;	/* 0 means unallocated */
 	int width, height;
 	byte *pixels;
-	ulong palette[16];
+	uint32_t palette[16];
 	int palette_entries;
 	int transparentcolor;
 	bool adaptive;
@@ -190,9 +190,9 @@
 
 void sf_readsettings();
 
-ulong sf_GetColour(int colour);
-ulong sf_GetDefaultColour(bool fore);
-int sf_GetColourIndex(ulong colour);
+uint32_t sf_GetColour(int colour);
+uint32_t sf_GetDefaultColour(bool fore);
+int sf_GetColourIndex(uint32_t colour);
 
 void sf_initvideo(int w, int h, int full);
 
@@ -221,7 +221,7 @@
 
 bool sf_IsInfocomV6(void);
 
-ulong sf_blend(int a, ulong s, ulong d);
+uint32_t sf_blend(int a, uint32_t s, uint32_t d);
 
 void sf_sleep(int millisecs);
 
@@ -234,8 +234,8 @@
 
 int sf_pkread(FILE * f, int foffs, void **out, int *size);
 
-ulong *sf_savearea(int x, int y, int w, int h);
-void sf_restoreareaandfree(ulong * s);
+uint32_t *sf_savearea(int x, int y, int w, int h);
+void sf_restoreareaandfree(uint32_t * s);
 #define SF_NOTIMP (-9999)
 
 zword sf_read_key(int timeout, bool cursor, bool allowed, bool text);
@@ -243,7 +243,7 @@
 int sf_user_fdialog(bool exist, const char *def, const char *filt,
 		    const char *title, char **res);
 extern int (*sf_osdialog)(bool ex, const char *def, const char *filt,
-			  const char *tit, char **res, ulong * sbuf, int sbp,
+			  const char *tit, char **res, uint32_t * sbuf, int sbp,
 			  int ew, int eh, int isfull);
 
 void sf_checksound(void);
@@ -255,13 +255,13 @@
 
 char *sf_searchfile(char *, int, char *, char *);
 
-void sf_chline(int x, int y, ulong c, int n);
-void sf_cvline(int x, int y, ulong c, int n);
+void sf_chline(int x, int y, uint32_t c, int n);
+void sf_cvline(int x, int y, uint32_t c, int n);
 bool sf_flushdisplay(void);
 void sf_getclip(int *x, int *y, int *w, int *h);
 void sf_rect(unsigned long color, int x, int y, int w, int h);
 void sf_setclip(int x, int y, int w, int h);
-void sf_wpixel(int x, int y, ulong c);
+void sf_wpixel(int x, int y, uint32_t c);
 
 void sf_InitProfile(const char *fn);
 void sf_FinishProfile(void);
--- a/src/sdl/sf_resource.c
+++ b/src/sdl/sf_resource.c
@@ -51,10 +51,10 @@
 int m_v6scale_y;
 double m_gfxScale_w = 1.0;
 double m_gfxScale_h = 1.0;
-ulong m_defaultFore;
-ulong m_defaultBack;
-ulong m_colours[11];
-ulong m_nonStdColours[NON_STD_COLS];
+uint32_t m_defaultFore;
+uint32_t m_defaultBack;
+uint32_t m_colours[11];
+uint32_t m_nonStdColours[NON_STD_COLS];
 int m_nonStdIndex;
 bool m_exitPause = 0;
 bool m_lineInput = 0;
@@ -478,7 +478,7 @@
 
 
 /* Get a colour */
-ulong sf_GetColour(int colour)
+uint32_t sf_GetColour(int colour)
 {
 	/* Standard colours */
 	if ((colour >= BLACK_COLOUR) && (colour <= DARKGREY_COLOUR))
@@ -500,7 +500,7 @@
 
 
 /* Get a default colour */
-ulong sf_GetDefaultColour(bool fore)
+uint32_t sf_GetDefaultColour(bool fore)
 {
 	if (m_IsInfocomV6)
 		return sf_GetColour(fore ? WHITE_COLOUR : BLACK_COLOUR);
@@ -509,7 +509,7 @@
 
 
 /* Get an index for a non-standard colour */
-int sf_GetColourIndex(ulong colour)
+int sf_GetColourIndex(uint32_t colour)
 {
 	int i, index = -1;
 	/* Is this a standard colour? */
@@ -950,7 +950,7 @@
 int sf_getresource(int num, int ispic, int method, myresource * res)
 {
 	int st;
-	ulong usage;
+	uint32_t usage;
 
 	res->bbres.data.ptr = NULL;
 	res->file = NULL;
@@ -981,7 +981,7 @@
 typedef struct {
 	void *next;
 	int num, ispic;
-	ulong type;
+	uint32_t type;
 	char *name;
 } LLENTRY;
 
@@ -989,7 +989,7 @@
 
 static int numlocal = 0, numlocalpic = 0, numlocalsnd = 0;
 static int p_ispic, p_num;
-static ulong p_type;
+static uint32_t p_type;
 static char *p_name;
 
 
--- a/src/sdl/sf_video.c
+++ b/src/sdl/sf_video.c
@@ -31,7 +31,7 @@
 
 static char banner[256];
 static int isfullscreen;
-static ulong *sbuffer = NULL;
+static uint32_t *sbuffer = NULL;
 static int sbpitch;		/* in longs */
 static int dirty = 0;
 static int ewidth, eheight;
@@ -45,7 +45,7 @@
 static void sf_quitconf();
 
 static bool ApplyPalette(sf_picture *);
-static ulong screen_palette[16];
+static uint32_t screen_palette[16];
 
 extern z_header_t z_header;
 
@@ -99,7 +99,7 @@
 }
 
 
-void sf_wpixel(int x, int y, ulong c)
+void sf_wpixel(int x, int y, uint32_t c)
 {
 	if (x < xmin || x >= xmax || y < ymin || y >= ymax)
 		return;
@@ -108,7 +108,7 @@
 }
 
 
-ulong sf_rpixel(int x, int y)
+uint32_t sf_rpixel(int x, int y)
 {
 	if (x < 0 || x >= ewidth || y < 0 || y >= eheight)
 		return 0;
@@ -116,7 +116,7 @@
 }
 
 #define MAXCUR 64
-static ulong savedcur[MAXCUR];
+static uint32_t savedcur[MAXCUR];
 
 static void drawthecursor(int x, int y, int onoff)
 {
@@ -156,9 +156,9 @@
 }
 
 
-void sf_chline(int x, int y, ulong c, int n)
+void sf_chline(int x, int y, uint32_t c, int n)
 {
-	ulong *s;
+	uint32_t *s;
 	if (y < ymin || y >= ymax)
 		return;
 	if (x < xmin) {
@@ -176,9 +176,9 @@
 }
 
 
-void sf_cvline(int x, int y, ulong c, int n)
+void sf_cvline(int x, int y, uint32_t c, int n)
 {
-	ulong *s;
+	uint32_t *s;
 	if (x < xmin || x >= xmax)
 		return;
 	if (y < xmin) {
@@ -198,9 +198,9 @@
 }
 
 
-ulong sf_blendlinear(int a, ulong s, ulong d)
+uint32_t sf_blendlinear(int a, uint32_t s, uint32_t d)
 {
-	ulong r;
+	uint32_t r;
 	r = ((s & 0xff) * a + (d & 0xff) * (256 - a)) >> 8;
 	s >>= 8;
 	d >>= 8;
@@ -234,7 +234,7 @@
 	int height = ts->font->height(ts->font);
 	int width;
 
-	ulong color, bc;
+	uint32_t color, bc;
 
 	if ((ts->style & REVERSE_STYLE) != 0) {
 		bc = ts->fore;
@@ -262,7 +262,7 @@
 				int t = *bmp++;
 				if (xx < byw) {
 					if (t) {
-						ulong sval = color;
+						uint32_t sval = color;
 						if (t < 255)
 							sval = sf_blend((int) (t + (t >> 7)), sval, sf_rpixel(x + xx, y));
 						sf_wpixel(x + xx, y, sval);
@@ -292,7 +292,7 @@
 
 void sf_fillrect(unsigned long color, int x, int y, int w, int h)
 {
-	ulong *dst;
+	uint32_t *dst;
 	int i;
 	if (x < xmin) {
 		w += x - xmin;
@@ -380,7 +380,7 @@
 
 static void scroll(int x, int y, int w, int h, int n)
 {
-	ulong *src, *dst;
+	uint32_t *src, *dst;
 	int nmove, step;
 	if (n > 0) {
 		dst = sbuffer + x + sbpitch * y;
@@ -397,7 +397,7 @@
 		return;
 	if (nmove > 0) {
 		while (nmove--) {
-			memmove(dst, src, w * sizeof(ulong));
+			memmove(dst, src, w * sizeof(uint32_t));
 			dst += step;
 			src += step;
 		}
@@ -414,7 +414,7 @@
 {
 	if (dirty) {
 		SDL_UpdateTexture(texture, NULL, sbuffer,
-				  sbpitch * sizeof(ulong));
+				  sbpitch * sizeof(uint32_t));
 		myGrefresh();
 		dirty = 0;
 		return true;
@@ -537,7 +537,7 @@
 					  SDL_TEXTUREACCESS_STREAMING, W, H)))
 		os_fatal("Failed to create texture: %s", SDL_GetError());
 
-	sbuffer = calloc(W * H, sizeof(ulong));
+	sbuffer = calloc(W * H, sizeof(uint32_t));
 	if (!sbuffer)
 		os_fatal("Could not create gc");
 
@@ -564,7 +564,7 @@
 	int ox, oy, ow, oh;
 	Zwindow *winpars;
 	sf_picture *pic = sf_getpic(picture);
-	ulong *src, *dst, sval, dval, alpha;
+	uint32_t *src, *dst, sval, dval, alpha;
 
 	sf_flushtext();
 
@@ -572,7 +572,7 @@
 		return;
 	if (!pic->pixels)
 		return;
-	src = (ulong *) pic->pixels;
+	src = (uint32_t *) pic->pixels;
 
 	x--;
 	y--;
@@ -673,7 +673,7 @@
 }
 
 
-static ulong mytimeout;
+static uint32_t mytimeout;
 int mouse_button;
 static int numAltQ = 0;
 
@@ -1238,9 +1238,9 @@
 }
 
 
-ulong *sf_savearea(int x, int y, int w, int h)
+uint32_t *sf_savearea(int x, int y, int w, int h)
 {
-	ulong *r, *p, *s;
+	uint32_t *r, *p, *s;
 	int i;
 
 	if (x < 0) {
@@ -1261,7 +1261,7 @@
 	if (h <= 0)
 		return NULL;
 
-	r = p = malloc((w * h + 4) * sizeof(ulong));
+	r = p = malloc((w * h + 4) * sizeof(uint32_t));
 	if (!r)
 		return NULL;
 
@@ -1272,7 +1272,7 @@
 
 	s = sbuffer + x + y * sbpitch;
 	for (i = 0; i < h; i++) {
-		memmove(p, s, w * sizeof(ulong));
+		memmove(p, s, w * sizeof(uint32_t));
 		p += w;
 		s += sbpitch;
 	}
@@ -1280,9 +1280,9 @@
 }
 
 
-void sf_restoreareaandfree(ulong * s)
+void sf_restoreareaandfree(uint32_t * s)
 {
-	ulong *p, *d;
+	uint32_t *p, *d;
 	int i, x, y, w, h;
 	if (!s)
 		return;
@@ -1295,7 +1295,7 @@
 
 	d = sbuffer + x + y * sbpitch;
 	for (i = 0; i < h; i++) {
-		memmove(d, p, w * sizeof(ulong));
+		memmove(d, p, w * sizeof(uint32_t));
 		p += w;
 		d += sbpitch;
 	}
@@ -1307,7 +1307,7 @@
 
 
 int (*sf_osdialog)(bool ex, const char *def, const char *filt, const char *tit,
-		   char **res, ulong * sbuf, int sbp, int ew, int eh,
+		   char **res, uint32_t * sbuf, int sbp, int ew, int eh,
 		   int isfull) = NULL;
 
 
@@ -1322,7 +1322,7 @@
 }
 
 
-void sf_videodata(ulong ** sb, int *sp, int *ew, int *eh)
+void sf_videodata(uint32_t ** sb, int *sp, int *ew, int *eh)
 {
 	*sb = sbuffer;
 	*sp = sbpitch;
@@ -1367,7 +1367,7 @@
 	bool changed = FALSE;
 	int i, colors;
 
-	memset(&screen_palette, 0, sizeof(ulong));
+	memset(&screen_palette, 0, sizeof(uint32_t));
 
 	if (graphic->usespalette) {
 		colors = graphic->palette_entries;
--- a/src/sdl/sf_images.c
+++ b/src/sdl/sf_images.c
@@ -38,9 +38,9 @@
 static byte fromLinear[256];
 extern bool m_adaptiveMode;
 
-ulong sf_blend(int a, ulong s, ulong d)
+uint32_t sf_blend(int a, uint32_t s, uint32_t d)
 {
-	ulong r;
+	uint32_t r;
 	r = fromLinear[(toLinear[s & 0xff] * a +
 			toLinear[d & 0xff] * (256 - a)) >> 8];
 	s >>= 8;
@@ -186,7 +186,7 @@
 		if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) {
 			graphic->palette_entries = num_palette;
 			for (int i = 0; i < num_palette; i++) {
-				ulong color =
+				uint32_t color =
 				    palette[i].red | (palette[i].
 						      green << 8) | (palette[i].
 								     blue <<