aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx/gfx_test.cpp
blob: 2987aab47e5152c2bc53697796a3d000bab12370 (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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

/* gfx driver test and verification program */

#define DISABLE_SCI_MEMORY

#ifdef _MSC_VER
#  include <unistd.h>
#  include <sys/time.h>
#  include <windows.h>
#endif

#include <assert.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <string.h>
#include <gfx_resource.h>
#include <gfx_tools.h>
#include <gfx_operations.h>

namespace Sci {

int
sci0_palette;

gfx_pixmap_color_t gfx_sci0_image_colors[1][16];

gfx_pixmap_color_t *
gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) {
	return NULL;
}

int
sciprintf(const char *fmt, ...) {
	va_list argp;
	va_start(argp, fmt);
	vprintf(fmt, argp);
	va_end(argp);
	return 0;
}


void *
memdup(void *mem, size_t size) {
	void *r = malloc(size);
	if (r)
		memcpy(r, mem, size);
	return r;
}

#ifdef FREESCI_PRIMARY_RESOURCE_H_
#  include "../scicore/sci_memory.c"
#endif

void
sci_gettime(long *seconds, long *useconds) {
	struct timeval tv;

#ifdef WIN32
	timeBeginPeriod(0);
#endif

	assert(!gettimeofday(&tv, NULL));
	*seconds = time(NULL);
	*useconds = tv.tv_usec;

#ifdef WIN32
	timeEndPeriod(0);
#endif
}

static int xres = 1;
static int yres = 1;
static int color_mode = 1;
static char *driver = NULL;
static int set_mode = 0;
static int nowait = 0;
static int skip_intro = 0;

#define ALL_TESTS "abcdefghijkl"
static char tests[256];

gfx_state_t graphics_state;
gfx_state_t *state = &graphics_state;

gfx_options_t graphics_options;
gfx_options_t *options = &graphics_options;


#define CAPABILITY_IDS_NR 11

static struct {
	int mask;
	char *description;
} capability_ids[CAPABILITY_IDS_NR] = {
	{GFX_CAPABILITY_SHADING, "shaded boxes"},
	{GFX_CAPABILITY_MOUSE_POINTER, "mouse pointers"},
	{GFX_CAPABILITY_COLOR_MOUSE_POINTER, "multi-color mouse pointers"},
	{GFX_CAPABILITY_PIXMAP_REGISTRY, "pixmaps must be registered"},
	{GFX_CAPABILITY_SCALEABLE_PIXMAPS, "pixmap scaling"},
	{GFX_CAPABILITY_STIPPLED_LINES, "stippled lines"},
	{GFX_CAPABILITY_MOUSE_SUPPORT, "pointing device input"},
	{GFX_CAPABILITY_POINTER_PIXMAP_REGISTRY, "pointer pixmaps must be registered"},
	{GFX_CAPABILITY_FINE_LINES, "fine lines"},
	{GFX_CAPABILITY_WINDOWED, "windowed mode active"},
	{GFX_CAPABILITY_KEYTRANSLATE, "built-in keyboard translation"}
};

int
init_driver(gfx_driver_t *drv) {
	int i;

	state->driver = drv;
	options->dirty_frames = GFXOP_DIRTY_FRAMES_CLUSTERS;

	if (set_mode) {
		if (gfxop_init(state, xres, yres, color_mode, options, NULL)) {
			printf("Custom initialization failed\n");
			return 1;
		}
	} else {
		if (gfxop_init_default(state, options, NULL)) {
			printf("Default initialization failed\n");
			return 1;
		}
	}

	printf("Using graphics driver %s, version %s\n", drv->name, drv->version);
	printf("Graphics driver capabilities:\n");
	for (i = 0; i < CAPABILITY_IDS_NR; i++)
		if (drv->capabilities & capability_ids[i].mask)
			printf("\t%s\n", capability_ids[i].description);

	printf("\n");
	return 0;
}


/* ---------------------------------- */
/* Functions for the resource manager */
/* ---------------------------------- */

int multicolored_pointers = 1; /* Whether to test multicolored pointer support */

#define TEST_PICS_NR 2
#define TEST_VIEWS_NR 1
#define TEST_FONTS_NR 1
#define TEST_CURSORS_NR 2

int test_pics[TEST_PICS_NR] = {0, 1};
int test_views[TEST_VIEWS_NR] = {0};
int test_fonts[TEST_FONTS_NR] = {0};
int test_cursors[TEST_CURSORS_NR] = {0, 1};

int
gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) {
	return 0;
}


int *
arrdup(int *src, int count) {
	int *retval = sci_malloc(sizeof(int) * count);
	memcpy(retval, src, sizeof(int) * count);
	return retval;
}

int *
gfxr_interpreter_get_resources(gfx_resstate_t *resstate, gfx_resource_type_t type,
	int version, int *entries_nr, void *internal) {
	switch (type) {

	case GFX_RESOURCE_TYPE_VIEW:
		*entries_nr = TEST_VIEWS_NR;
		return arrdup(test_views, TEST_VIEWS_NR);

	case GFX_RESOURCE_TYPE_PIC:
		*entries_nr = TEST_PICS_NR;
		return arrdup(test_pics, TEST_PICS_NR);

	case GFX_RESOURCE_TYPE_FONT:
		*entries_nr = TEST_FONTS_NR;
		return arrdup(test_fonts, TEST_FONTS_NR);

	case GFX_RESOURCE_TYPE_CURSOR:
		*entries_nr = TEST_CURSORS_NR;
		return arrdup(test_cursors, TEST_CURSORS_NR);

	default:
		fprintf(stderr, "Attept to get resource list for invalid resource type %d\n", type);
		return NULL;
	}
}

#define PIC_COLORS_NR 32

gfx_pixmap_color_t pic_colors[PIC_COLORS_NR] = {
	{GFX_COLOR_INDEX_UNMAPPED, 0x0f, 0x0f, 0x0f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x1f, 0x1f, 0x1f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x2f, 0x2f, 0x2f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x3f, 0x3f, 0x3f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x4f, 0x4f, 0x4f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x5f, 0x5f, 0x5f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x6f, 0x6f, 0x6f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x7f, 0x7f, 0x7f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x8f, 0x8f, 0x8f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x9f, 0x9f, 0x9f},
	{GFX_COLOR_INDEX_UNMAPPED, 0xaf, 0xaf, 0xaf},
	{GFX_COLOR_INDEX_UNMAPPED, 0xbf, 0xbf, 0xbf},
	{GFX_COLOR_INDEX_UNMAPPED, 0xcf, 0xcf, 0xcf},
	{GFX_COLOR_INDEX_UNMAPPED, 0xdf, 0xdf, 0xdf},
	{GFX_COLOR_INDEX_UNMAPPED, 0xef, 0xef, 0xef},
	{GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x0f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x1f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x2f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x3f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x4f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x5f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x6f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x7f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x8f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x9f},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xaf},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xbf},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xcf},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xdf},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xef},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xff}
};

gfxr_pic_t *
gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) {
	gfxr_pic_t *pic = sci_malloc(sizeof(gfxr_pic_t));

	pic->mode = mode;
	pic->undithered_buffer = NULL;
	pic->internal = NULL;

	pic->control_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 2, 0));
	pic->priority_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320 * mode->xfact,
	                    200 * mode->yfact, ID, 1, 0));
	pic->visual_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 0, 0));

	pic->visual_map->colors = pic_colors;
	pic->visual_map->colors_nr = PIC_COLORS_NR;

	pic->visual_map->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
	pic->priority_map->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
	pic->control_map->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;

	pic->priority_map->colors = pic_colors;
	pic->priority_map->colors_nr = PIC_COLORS_NR;
	pic->control_map->colors = pic_colors;
	pic->control_map->colors_nr = PIC_COLORS_NR;

	return pic;
}



void
gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) {
	memset(pic->visual_map->index_data, 0x00, 320 * 200);
	memset(pic->priority_map->index_data, 0, 320 * pic->mode->xfact * 200 * pic->mode->yfact);
	memset(pic->control_map->index_data, 0, GFXR_AUX_MAP_SIZE);
	memset(pic->aux_map, 0, GFXR_AUX_MAP_SIZE);
}


int
gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic,
	int flags, int default_palette, int nr, void *internal) {
	gfxr_pic_t *pic = scaled_pic;
	int i, x, y, pos;
	int xfact = pic->mode->xfact;
	int yfact = pic->mode->yfact;

	if (nr < 0 || nr > TEST_PICS_NR)
		return GFX_ERROR;

	switch (nr) {
	case 0:
		pos = 0;
		for (y = 0; y < 200; y++) {
			for (x = 0; x < 32; x++) {
				memset(pic->visual_map->index_data + pos, x, 5);
				memset(pic->visual_map->index_data + 315 + pos - x*10, x, 5);
				pos += 5;
			}
			pos += 160;
		}

		for (y = 0; y < 200*yfact; y++) {
			memset(pic->priority_map->index_data + y * 320*xfact + (100*xfact), 10, 120*xfact);
			memset(pic->priority_map->index_data + y * 320*xfact + (150*xfact), 20, 20*xfact);
		}
		break;

	case 1:
		memset(pic->visual_map->index_data + 80*320, 15, 120*320);
		memset(pic->priority_map->index_data + 80*xfact * 320*yfact, 20,
		       120*320*xfact*yfact);

		for (i = 40; i < 80; i++) {
			int j;

			memset(pic->visual_map->index_data + i*320 + 140, 15, 80);
			for (j = 0; j < pic->mode->yfact; j++)
				memset(pic->priority_map->index_data + (i*yfact + j)*320*xfact
				       + 140*xfact , 20, 80*xfact);
		}
		break;

	default:
		fprintf(stderr, "Attempt to reference invalid pic #%d\n", nr);
	}

	printf(">> resource manager retrieved pic #%d\n", nr);
	return GFX_OK;
}


#define VIEW_COLORS_NR 16

gfx_pixmap_color_t view_colors[VIEW_COLORS_NR] = {
	{GFX_COLOR_INDEX_UNMAPPED, 0x0f, 0x00, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x2f, 0x20, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x4f, 0x40, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x6f, 0x60, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x8f, 0x80, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0xaf, 0xa0, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0xcf, 0xc0, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0xef, 0xe0, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x1f, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x3f, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x5f, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x7f, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x9f, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0xbf, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0xdf, 0x00},
	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0xff, 0x00}
};

gfxr_view_t *
gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) {
	gfxr_view_t *view;
	gfxr_loop_t *loop;
	int i;

	if (nr < 0 || nr > TEST_VIEWS_NR)
		return NULL;

	view = sci_malloc(sizeof(gfxr_view_t));
	view->ID = nr | 2048;
	view->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;

	view->colors_nr = VIEW_COLORS_NR;
	view->colors = view_colors;

	view->loops_nr = 1;
	view->loops = loop = sci_malloc(sizeof(gfxr_loop_t));

	loop->cels_nr = 3;
	loop->cels = sci_malloc(sizeof(gfx_pixmap_t *) * loop->cels_nr);

	for (i = 0; i < 3; i++) {
		gfx_pixmap_t *pxm = gfx_pixmap_alloc_index_data(gfx_new_pixmap(16, 16, 2048 | nr, 0, i));
		int offset = (i == 1) ? 8 : 0;
		int x, y;

		pxm->colors_nr = VIEW_COLORS_NR;
		pxm->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
		pxm->colors = view_colors;
		pxm->xoffset = 8;
		pxm->yoffset = 8;

		for (y = 0; y < 16; y++)
			for (x = 0; x < 16; x++) {
				int dx = (8 - x);
				int dy = (8 - y);
				int dist = dx * dx + dy * dy;
				int index = (dist * 8) / 64;
				int pos = x + y * 16;

				if (i == 2) {
					offset = (!dx || !dy) ? 8 : 0;
					if (offset == 8) index <<= 1;
				}

				index = 7 - index;
				if (index < 0)
					pxm->index_data[pos] = 0xff;
				else
					pxm->index_data[pos] = index + offset;
			}

		loop->cels[i] = pxm;
	}

	printf(">> resource manager retrieved view #%d\n", nr);

	return view;
}

#define BUILTIN_CHARS_NR 256
#define BUILTIN_CHARS_HEIGHT 8
#define BUILTIN_CHARS_WIDTH 8

extern byte builtin_font[];

gfx_bitmap_font_t *
gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) {
	gfx_bitmap_font_t *font;
	int i;
	if (nr < 0 || nr > TEST_FONTS_NR)
		return NULL;

	font = sci_malloc(sizeof(gfx_bitmap_font_t));
	font->ID = nr;
	font->chars_nr = BUILTIN_CHARS_NR;
	font->widths = sci_malloc(sizeof(int) * BUILTIN_CHARS_NR);
	for (i = 0; i < BUILTIN_CHARS_NR; i++)
		font->widths[i] = BUILTIN_CHARS_WIDTH;
	font->row_size = (BUILTIN_CHARS_WIDTH + 7) >> 3;
	font->height = font->line_height = BUILTIN_CHARS_HEIGHT;
	font->char_size = ((BUILTIN_CHARS_WIDTH + 7) >> 3) * BUILTIN_CHARS_HEIGHT;
	font->data = memdup(builtin_font, font->char_size * BUILTIN_CHARS_NR);

	printf(">> resource manager retrieved font #%d\n", nr);

	return font;
}

gfx_pixmap_color_t _cursor_colors[3] = {
	{GFX_COLOR_INDEX_UNMAPPED, 0, 0, 0},
	{GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff},
	{GFX_COLOR_INDEX_UNMAPPED, 0x80, 0x80, 0x80}
};

gfx_pixmap_t *
gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) {
	gfx_pixmap_t *cursor;
	int xl, yl, x, y;

	if (nr < 0 || nr > TEST_CURSORS_NR)
		return NULL;

	if (!nr)
		xl = yl = 31;
	else {
		xl = 8;
		yl = 16;
	}


	cursor = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, 1024 + nr, 0, 0));
	cursor->colors = _cursor_colors;
	cursor->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;

	memset(cursor->index_data, 0xff, xl * yl);

	switch (nr) {
	case 0:
		cursor->colors_nr = multicolored_pointers ? 3 : 2;
		cursor->xoffset = 16;
		cursor->yoffset = 16;

		for (x = 0; x < 31; x++) if (x != 16) {
				cursor->index_data[31*x + 16] = 1;
				cursor->index_data[31*16 + x] = 1;

				if (multicolored_pointers && ((x < 8) || (x > 23))) {
					cursor->index_data[31*x + 14] = 0;
					cursor->index_data[31*x + 15] = 2;
					cursor->index_data[31*x + 17] = 2;
					cursor->index_data[31*x + 18] = 0;

					cursor->index_data[31*14 + x] = 0;
					cursor->index_data[31*15 + x] = 2;
					cursor->index_data[31*17 + x] = 2;
					cursor->index_data[31*18 + x] = 0;
				} else {
					cursor->index_data[31*x + 15] = 0;
					cursor->index_data[31*x + 17] = 0;

					cursor->index_data[31*15 + x] = 0;
					cursor->index_data[31*17 + x] = 0;
				}
			}
		break;

	case 1:
		cursor->colors_nr = 2;
		cursor->xoffset = 0;
		cursor->yoffset = 0;
		for (y = 0; y < yl; y++)
			for (x = 0; x <= (y >> 1); x++)
				cursor->index_data[x + y*xl] = 1;
		break;

	default:
		fprintf(stderr, "Attempt to load invalid pointer %d\n", nr);
		gfx_free_pixmap(state->driver, cursor);
		return NULL;
	}

	printf(">> resource manager retrieved cursor #%d\n", nr);

	return cursor;
}

gfx_pixmap_color_t *
gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr) {
	return NULL;
}

int
gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) {
	return multicolored_pointers;
}

gfx_color_t red, green, blue, dblue, white, white8, white16, white24, black, transparent;

void
init_colors() {
	gfxop_set_color(state, &red,         0xff, 0x00, 0x00, 0x00, -1, -1);
	gfxop_set_color(state, &green,       0x00, 0xff, 0x00, 0x00, -1, -1);
	gfxop_set_color(state, &blue,        0x00, 0x00, 0xff, 0x00, -1, -1);
	gfxop_set_color(state, &dblue,       0x00, 0x00, 0x40, 0x00, -1, -1);
	gfxop_set_color(state, &white,       0xff, 0xff, 0xff, 0x00, -1, -1);
	gfxop_set_color(state, &white8,      0xff, 0xff, 0xff, 0x00,  8, -1);
	gfxop_set_color(state, &white16,     0xff, 0xff, 0xff, 0x00, 16, -1);
	gfxop_set_color(state, &white24,     0xff, 0xff, 0xff, 0x00, 24, -1);
	gfxop_set_color(state, &black,       0x00, 0x00, 0x00, 0x00, -1, -1);
	gfxop_set_color(state, &transparent, -1  , -1  , -1  , 0x00, -1, -1);
}


#define MESSAGE(foo) if (message(foo)) { fprintf(stderr,"Message '%s' could not be print!\n", foo); return;}
#define MESSAGE1(foo,a) { char buf[1024]; sprintf(buf,foo,a); if (message(buf)) { fprintf(stderr,"Message '%s' could not be print!\n", buf); return;}}
#define MESSAGE2(foo,a,b) { char buf[1024]; sprintf(buf,foo,a,b); if (message(buf)) { fprintf(stderr,"Message '%s' could not be print!\n", buf); return;}}
#define MESSAGE3(foo,a,b,c) { char buf[1024]; sprintf(buf,foo,a,b,c); if (message(buf)) { fprintf(stderr,"Message '%s' could not be print!\n", buf); return;}}
#define MESSAGE4(foo,a,b,c,d) { char buf[1024]; sprintf(buf,foo,a,b,c,d); if (message(buf)) { fprintf(stderr,"Message '%s' could not be print!\n", buf); return;}}


int
waitkey(void) {
	int count = 100000;
	sci_event_t event;

	while (count--) {
		event = gfxop_get_event(state, SCI_EVT_ANY);

		if (event.type)
			return 0;

		gfxop_usleep(state, 1000);
	}
	return 1;
}

int
wait_specific_key(int key) {
	int count = 20000;
	sci_event_t event;

	while (count--) {
		event = gfxop_get_event(state, SCI_EVT_ANY);

		if (event.type == SCI_EVT_KEYBOARD
		        && event.data == key)
			return 0;

		gfxop_usleep(state, 1000);
	}
	return 1;
}


int
message(char *msg) {
	gfx_text_handle_t *handle;
	rect_t text_rect = gfx_rect(0, 150, 320, 50);


	handle = gfxop_new_text(state, 0, msg, 320, ALIGN_CENTER, ALIGN_TOP,
	                        white, white, black, 0);

	if (!handle) return 1;

	printf("-----------------------------------------\n%s\n-----------------------------------------\n", msg);

	gfxop_fill_box(state, text_rect, black);
	gfxop_draw_text(state, handle, text_rect);
	gfxop_free_text(state, handle);
	gfxop_update(state);
	return 0;
}

void
update(void) {
	/*	gfxop_update_box(state, gfx_rect(0, 0, 320, 150)); */
	gfxop_update(state);
}

void
explicit_clear_buffer(void) {
	gfxop_clear_box(state, gfx_rect(0, 0, 320, 150));
	gfxop_update(state);
}

void
clear_buffer(void) {
	gfxop_disable_dirty_frames(state);
	gfxop_clear_box(state, gfx_rect(0, 0, 320, 150));
	gfxop_enable_dirty_frames(state);
}

void
clear(void) {
	gfxop_fill_box(state, gfx_rect(0, 0, 320, 150), black);
}

void
identify_event(sci_event_t event) {
	switch (event.type) {

	case SCI_EVT_NONE:
		MESSAGE("No event");
		break;

	case SCI_EVT_MOUSE_PRESS:
		MESSAGE4("Mouse press at (%d,%d)\ndata/modifiers (%d/%d)",
		         state->pointer_pos.x, state->pointer_pos.y, event.data, event.buckybits);
		break;

	case SCI_EVT_MOUSE_RELEASE:
		MESSAGE4("Mouse release at (%d,%d)\ndata/modifiers (%d/%d)",
		         state->pointer_pos.x, state->pointer_pos.y, event.data, event.buckybits);
		break;

	case SCI_EVT_KEYBOARD:
		if (event.data > 127) {
			MESSAGE2("Key 0x%04x\nmodifiers %04x", event.data, event.buckybits);
		} else
			MESSAGE3("Key '%c' (0x%02x)\nmodifiers %04x", event.data, event.data, event.buckybits);
		break;

	case SCI_EVT_JOYSTICK:
		MESSAGE1("Joystick direction %d", event.data);
		break;

	case SCI_EVT_ERROR:
		MESSAGE("Error event");
		break;

	default:
		MESSAGE1("Unknown event type %d!\n", event.type);
	}
}


int
test_a(void) {
	if (message("-- Test A --\nText display and basic input\nPlease press 'space' within 20 seconds"))
		return 1;

	return (wait_specific_key(' '));
}


#define TEST_LINE(x, y, xl, yl) \
	gfxop_draw_line(state, gfx_point(x, y), gfx_point((x)+(xl), (y)+(yl)), blue, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL); \
	gfxop_set_clip_zone(state, gfx_rect(140, 60, 40, 40)); \
	gfxop_draw_line(state, gfx_point(x, y), gfx_point((x)+(xl), (y)+(yl)), red, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL); \
	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));

#define LINES_NR 19

int test_b_lines[LINES_NR][4]  = {
	{10, 10, 300, 0},
	{160, 30, 0, 100},
	{162, 20, 0, 50},
	{162, 90, 0, 50},
	{110, 80, 100, 0},
	{100, 82, 50, 0},
	{170, 82, 50, 0},
	{135, 70, 20, -20},
	{135, 90, 20, 20},
	{185, 70, -20, -20},
	{185, 90, -20, 20},
	{150, 70, -20, -10},
	{150, 70, -10, -20},
	{170, 70, 20, -10},
	{170, 70, 10, -20},
	{150, 90, -20, 10},
	{150, 90, -10, 20},
	{170, 90, 10, 20},
	{170, 90, 20, 10}
};

void
test_b(void) {
	int i;

	MESSAGE("-- Test B --\nLines");
	waitkey();
	MESSAGE("Some tests will include 'fine' lines.\nNote that support for those is\noptional.");
	waitkey();

	gfxop_draw_line(state, gfx_point(30, 30), gfx_point(290, 30), red, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_line(state, gfx_point(30, 40), gfx_point(290, 40), blue, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_line(state, gfx_point(30, 50), gfx_point(290, 50), green, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_STIPPLED);
	gfxop_draw_line(state, gfx_point(30, 60), gfx_point(290, 60), white, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED);
	update();
	MESSAGE("B.0: horizontal lines:\nYou should now be seeing (top-down):\nred-fine, blue-normal,\ngreen-fine-stippled, white-stippled");
	waitkey();

	clear();
	gfxop_draw_line(state, gfx_point(30, 30), gfx_point(290, 130), blue, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_line(state, gfx_point(30, 130), gfx_point(290, 30), blue, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_set_clip_zone(state, gfx_rect(140, 60, 40, 40));
	gfxop_draw_line(state, gfx_point(30, 30), gfx_point(290, 130), red, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_line(state, gfx_point(30, 130), gfx_point(290, 30), red, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
	update();
	MESSAGE("B.1: line clipping:\nTwo identical pairs of lines.\nblue lines are unclipped,\nred ones are clipped.");
	waitkey();

	clear();
	for (i = 0; i < LINES_NR; i++) {
		TEST_LINE(test_b_lines[i][0], test_b_lines[i][1], test_b_lines[i][2], test_b_lines[i][3]);
	}
	update();
	MESSAGE1("B.2: line clipping:\n%d lines.", LINES_NR);
	waitkey();

	clear();
	gfxop_draw_rectangle(state, gfx_rect(30, 30, 260, 100), red, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_rectangle(state, gfx_rect(40, 40, 240, 80), red, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED);
	update();
	MESSAGE("B.3: Rectangles:\nNormal rectangle (outside)\nStippled rectangle (inside)");
	waitkey();

	gfxop_draw_rectangle(state, gfx_rect(30, 30, 260, 100), green, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_rectangle(state, gfx_rect(40, 40, 240, 80), green, GFX_LINE_MODE_FINE, GFX_LINE_STYLE_STIPPLED);
	update();
	MESSAGE("B.4: Fine rectangles (optional):\nTwo green rectangles should now have\noverwritten the _inner_ bounds\nof the red ones");
	waitkey();
}


void
test_c(void) {
	int i;
	clear();
	update();
	MESSAGE("-- Test C: Boxes and updates --");
	waitkey();

	gfxop_fill_box(state, gfx_rect(50, 50, 210, 80), red);
	update();
	MESSAGE("C.0: Simple box");
	waitkey();

	gfxop_disable_dirty_frames(state);
	clear();
	gfxop_fill_box(state, gfx_rect(30, 30, 260, 100), white);
	gfxop_fill_box(state, gfx_rect(50, 50, 210, 80), blue);
	gfxop_enable_dirty_frames(state);

	MESSAGE("C.1: Partial propagation\nA white box containing a blue box\nhas been written to the back buffer.\nPress a key to propagate it.");

	for (i = 0; i <= 40; i++) {
		gfxop_update_box(state, gfx_rect(i*4, 0 , 4, 150));
		gfxop_update_box(state, gfx_rect(317 - i*4, 0 , 4, 150));
		gfxop_usleep(state, 4000);
	}

	gfxop_disable_dirty_frames(state);
	clear();
	gfxop_fill_box(state, gfx_rect(30, 30, 260, 100), red);
	gfxop_enable_dirty_frames(state);

	MESSAGE("C.2: Single line propagation\nPress a key to propagate a red box.\nNote that dirty frame\naccounting must be dis-\n"
	        "abled for manual updates\nto work like this.");
	waitkey();
	for (i = 159; i >= 0; i--) {
		gfxop_update_box(state, gfx_rect(i, 0 , 1, 150));
		gfxop_update_box(state, gfx_rect(319 - i, 0 , 1, 150));
		gfxop_usleep(state, 1000);
	}

	clear();
	gfxop_draw_box(state, gfx_rect(150, 70, 20, 20), red, green, GFX_BOX_SHADE_FLAT);
	gfxop_draw_box(state, gfx_rect(120, 70, 20, 20), red, green, GFX_BOX_SHADE_LEFT);
	gfxop_draw_box(state, gfx_rect(180, 70, 20, 20), red, green, GFX_BOX_SHADE_RIGHT);
	gfxop_draw_box(state, gfx_rect(150, 40, 20, 20), red, green, GFX_BOX_SHADE_UP);
	gfxop_draw_box(state, gfx_rect(150, 100, 20, 20), red, green, GFX_BOX_SHADE_DOWN);
	update();
	MESSAGE("C.3: Gradient boxes\nIf your driver supports gradient\nboxes, you should now see\nthe four outer boxes being\nred on the inside,--more--");
	waitkey();
	MESSAGE("C.3: Gradient boxes\n(cont.)and green on the\n outside.\n\nIf unsupported, all should be red.");
	waitkey();
}


void
test_d(void) {
	rect_t line;
	int pressed = 0;
	sci_event_t event;

	event.type = 0;

	MESSAGE("-- Test D: Pointers and input --");
	clear();
	gfxop_fill_box(state, gfx_rect(30, 30, 260, 100), white);
	gfxop_fill_box(state, gfx_rect(50, 50, 210, 80), blue);
	waitkey();
	update();

	gfxop_set_pointer_cursor(state, 1);
	MESSAGE("D.0: Simple mouse pointer\nThis pointer's hot spot is at the\ntop left");
	waitkey();

	gfxop_set_pointer_cursor(state, 0);
	MESSAGE("D.1: Crosshair pointer\nHot spot is in the center.\nThis is a 'multicolor' pointer.");
	waitkey();

	MESSAGE("D.2: Mouse clicks\nPress and release buttons to\ndraw lines\nPress any key to continue");

	while (event.type != SCI_EVT_KEYBOARD) {
		event = gfxop_get_event(state, SCI_EVT_ANY);

		if (event.type == SCI_EVT_MOUSE_PRESS) {

			pressed = 1;
			line.x = state->pointer_pos.x;
			line.y = state->pointer_pos.y;

		} else if (event.type == SCI_EVT_MOUSE_RELEASE)

			if (pressed) {
				point_t line_pt = gfx_point(line.x, line.y);
				pressed = 0;
				line.xl = state->pointer_pos.x - line.x;
				line.yl = state->pointer_pos.y - line.y;
				gfxop_draw_line(state, state->pointer_pos, line_pt, red, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);

				if (line.xl < 0) {
					line.x += line.xl;
					line.xl = - line.xl;
				}

				if (line.yl < 0) {
					line.y += line.yl;
					line.yl = - line.yl;
				}

				gfxop_update_box(state, line);
			}

		gfxop_usleep(state, 1000);
	}

	event.type = 0;

	MESSAGE("D.3 Event test\nPress the space bar when finished");
	waitkey();

	while (event.type != SCI_EVT_KEYBOARD || event.data != ' ') {
		event = gfxop_get_event(state, SCI_EVT_ANY);

		if (event.type)
			identify_event(event);
	}
}


void
test_e(void) {
	int x;

	gfxop_set_pointer_cursor(state, 1);

	MESSAGE("-- Test E: Pics and Views --");
	waitkey();

	gfxop_new_pic(state, 0, 0, 0);

	explicit_clear_buffer();
	update();
	MESSAGE("E.0: Static buffer\nYou should now see a gray and\nblue background image now.\nIt is stored in the static\nbuffer, and --more--");
	waitkey();
	MESSAGE("E.0: Static buffer\n(cont.)then propagated to\nthe back buffer and then to\nthe front buffer.");
	waitkey();

	MESSAGE("E.1: Views and animation\nPress a key to see a cel move\nacross the screen\n(doing _full_ updates)");
	waitkey();

	for (x = -20; x < 340; x++) {
		clear_buffer();
		gfxop_draw_cel(state, 0, 0, 0, gfx_point(x, 40), white, 0);
		update();
		gfxop_usleep(state, 10000);
	}

	MESSAGE("E.2: Pic views\nFour pic views will now be added to\nthe static buffer");
	waitkey();

	gfxop_draw_cel_static(state, 0, 0, 1, gfx_point(50, 100), white24, 0);
	gfxop_draw_cel_static(state, 0, 0, 1, gfx_point(50, 20), white24, 0);
	gfxop_draw_cel_static(state, 0, 0, 1, gfx_point(220, 20), white16, 0);
	gfxop_draw_cel_static(state, 0, 0, 1, gfx_point(220, 100), white16, 0);

	update();
	MESSAGE("E.2: Pic views\nThe pic views should NOT\nbe visible yet!\n");
	waitkey();

	explicit_clear_buffer();
	update();
	MESSAGE("E.2: Pic views\nNow they should be.\n");
	waitkey();

	MESSAGE("E.3: Priority buffer\nPress a key to see two cels move\nacross the screen and re-\nspecting the Z buffer");
	waitkey();

	for (x = -20; x < 340; x++) {
		clear_buffer();
		gfxop_draw_cel(state, 0, 0, 2, gfx_point(x, 20), white8, 0);
		gfxop_draw_cel(state, 0, 0, 2, gfx_point(x, 100), white16, 0);
		update();
		gfxop_usleep(state, 10000);
	}

	gfxop_add_to_pic(state, 1, 0, 0);
	explicit_clear_buffer();
	update();
	MESSAGE("E.4: Adding to a pic\nSome new stuff should\nhave been added to the\nbackground pic now");
	waitkey();
	MESSAGE("E.5: Animation with partial updates\nIf you're running high-res,\nthis should be considerably\nfaster.");
	waitkey();
	for (x = -20; x < 340; x++) {
		gfxop_clear_box(state, gfx_rect(x - 9, 40 - 8, 17, 16));
		gfxop_clear_box(state, gfx_rect(x - 9, 70 - 8, 17, 16));
		gfxop_draw_cel(state, 0, 0, 2, gfx_point(x, 40), white16, 0);
		gfxop_draw_cel(state, 0, 0, 2, gfx_point(x, 70), white16, 0);
		gfxop_update(state);
		/*		gfxop_update_box(state, gfx_rect(x-1, 40, 17, 16)); */
		/*		gfxop_update_box(state, gfx_rect(x-1, 70, 17, 16)); */
		gfxop_usleep(state, 10000);
	}
	waitkey();
}

void
test_wrap(int width, char *text) {
	rect_t rect = gfx_rect(0, 0, width, 120);
	gfx_text_handle_t *handle = gfxop_new_text(state, 0,
	                            text,
	                            width, ALIGN_LEFT, ALIGN_TOP, white, white, transparent, 0);

	gfxop_fill_box(state, rect, dblue);
	gfxop_draw_rectangle(state, rect, blue, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL);
	gfxop_draw_text(state, handle, gfx_rect(0, 0, 320, 150));
	gfxop_free_text(state, handle);
}

void
test_f(void) {
	int i;
	int x, y;
	gfx_text_handle_t *handle;
	MESSAGE("-- Test F: Full font test --");
	waitkey();

	handle = gfxop_new_text(state, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890",
	                        320, ALIGN_LEFT, ALIGN_TOP, white, white, transparent, 0);
	gfxop_draw_text(state, handle, gfx_rect(0, 0, 320, 150));
	gfxop_free_text(state, handle);
	update();

	MESSAGE("F.0: Font wrap\nYou should now see the alphabet\n(capitals, then small letters),\nand the numbers from 1 to 0"
	        "\nwrapped with a maxwidth of\n320 (screen width)");
	waitkey();

	MESSAGE("F.1: Font wrap:\nMisc. wrap widths\nAll text should be /within/ the\nblue box (it may touch\nthe border, though)");
	waitkey();
	for (i = 200; i > 50; i -= 7) {
		clear_buffer();
		test_wrap(i, "\"Far out in the uncharted regions of the western spiral arm of the galaxy...\"");
		update();
		MESSAGE1("\nwidth=%d", i);
		waitkey();
	}

	handle = gfxop_new_text(state, 0, "And now for something completely different.",
	                        320, ALIGN_LEFT, ALIGN_TOP, red, green, black, 0);
	gfxop_draw_text(state, handle, gfx_rect(0, 0, 320, 150));
	gfxop_free_text(state, handle);
	update();
	MESSAGE("F.2: Dithered text\nThis text should now be dithered\nred/green on black background");
	waitkey();

	clear_buffer();
	handle = gfxop_new_text(state, 0, "foo!",
	                        320, ALIGN_CENTER, ALIGN_CENTER, blue, blue, transparent, 0);
	x = 10;
	y = 10;

	for (i = 0; i < 1000; i++) {
		x = (x + (70 + (i / y) + y * y * x / (i + 1)));
		y = (y + (30 + (i / x) + x * x * y / (i + 1)));
		gfxop_draw_text(state, handle, gfx_rect(x % 320, y % 140, 0, 0));
	}

	gfxop_free_text(state, handle);
	update();
	MESSAGE("F.3: Multiple draws\nText handles may be used more\nthan once\n(1000 times here)");
	waitkey();
}

void
do_tests(char *conf) {
	init_colors();


	if (strchr(conf, 'a'))
		if (test_a())
			return;

	if (strchr(conf, 'b'))
		test_b();

	if (strchr(conf, 'c'))
		test_c();

	if (strchr(conf, 'd'))
		test_d();

	if (strchr(conf, 'e'))
		test_e();

	if (strchr(conf, 'f'))
		test_f();
}

int
c_quit(void *S) {
	exit(0);
	return 0; /* hahaha */
}

int
main(int argc, char **argv) {
	gfx_driver_t *drv = NULL;
	char c;

	strcpy(tests, ALL_TESTS);

	printf("gfx_test Copyright (C) 2000 Christoph Reichenbach\nThis program is provided WITHOUT WARRANTY of any kind. Please\n"
	       "refer to the file COPYING that should have come with this\ndistribution for licensing details.\n\n");

	while ((c = getopt(argc, argv, "nhslc:g:x:y:t:")) > -1)
		switch (c) {

		case 'h':
			printf("Usage: gfx_test [-l] [-h] [-g driver] [-x xfact] [-y yfact] [-c bpp]\n"
			       "-l: List all graphics targets\n"
			       "-x: Set x resolution scale factor\n"
			       "-y: Set y resolution scale factor\n"
			       "-s: Skip intro text and getchar()\n"
			       "-c: Set bytes per pixel\n"
			       "-h: Display this help message\n"
			       "-n: Immediately stop after displaying (for performance tests)\n"
			       "-g: Select any of the graphics drivers shown with -l\n"
			       "-t: Select the tests to run:\n"
			       "\ta: Text display and basic input\n"
			       "\tb: Lines\n"
			       "\tc: Boxes and updates\n"
			       "\td: Pointers and input\n"
			       "\te: Pics and Views\n"
			       "  -- for example, use \"-t abc\" to run tests A, B, and C\n"
			      );
			return 0;

		case 'n':
			nowait = 1;
			break;

		case 's':
			skip_intro = 1;
			break;

		case 'g':
			if (driver) sci_free(driver);
			driver = sci_strdup(optarg);
			break;

		case 'l': {
			int first = 1;
			int i = 0;

			printf("Available graphics drivers: ");
			while (gfx_get_driver_name(i)) {
				if (!first)
					printf(", ");
				first = 0;
				printf("%s", gfx_get_driver_name(i++));
			}
			printf("\n");
		}
		break;

		case 't':
			strcpy(tests, optarg);
			break;

		case 'x':
			set_mode = xres = atoi(optarg);
			if (xres < 1) {
				fprintf(stderr, "Invalid x scale factor!\n");
				return 1;
			}
			break;

		case 'y':
			set_mode = yres = atoi(optarg);
			if (yres < 1) {
				fprintf(stderr, "Invalid y scale factor!\n");
				return 1;
			}
			break;

		case 'c':
			set_mode = color_mode = atoi(optarg);
			if (color_mode < 1 || color_mode > 4) {
				fprintf(stderr, "Invalid number of bytes per pixel!\n");
				return 1;
			}
			break;

		default:
			fprintf(stderr, "Run 'gfx_test -h' for help\n");
			return 1;
		}

	drv = gfx_find_driver("/tmp", driver);

	if (drv) {
		printf("Using graphics driver '%s'\n", drv->name);

		if (!skip_intro) {
			printf("Testing will now start. The first test will check whether displaying\n"
			       "text and reading input works; it will display a message and wait for twenty\n"
			       "seconds for you to press the space bar. If it does not register a space bar\n"
			       "keypress, it will abort.\n"
			       "Note that it can happen that no text is displayed, but you still are able\n"
			       "to proceed to the next test by pressing the space bar. However, unless you\n"
			       "are running in windowed mode, you will not be able to read which kinds of\n"
			       "tests are being run, so it is recommended that you fix pixmap displaying\n"
			       "and back-to-front-buffer updating first, so that the text can be displayed\n"
			       "correctly.\n"
			       "-- Press any key to start the first test or Ctrl-C to abort --\n");
			getchar();
		}

		if (init_driver(drv)) {
			fprintf(stderr, "Initialization failed!\n");
			return 1;
		}

		do_tests(tests);

		if (gfxop_exit(state)) {
			fprintf(stderr, "Something weird happened while exitting...\n");
		}
	} else {
		fprintf(stderr, "No graphics driver found!\n");
		return 1;
	}

	return 0;
}



byte builtin_font[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
	0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
	0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
	0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00,
	0x38, 0x7c, 0x38, 0xfe, 0xfe, 0xd6, 0x10, 0x38,
	0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x7c, 0x10, 0x38,
	0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00,
	0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff,
	0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00,
	0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff,
	0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
	0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18,
	0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0,
	0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0,
	0x18, 0xdb, 0x3c, 0xe7, 0xe7, 0x3c, 0xdb, 0x18,
	0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00,
	0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
	0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18,
	0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00,
	0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00,
	0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c,
	0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00,
	0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff,
	0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00,
	0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00,
	0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00,
	0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00,
	0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00,
	0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00,
	0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00,
	0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00,
	0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
	0x18, 0x3e, 0x60, 0x3c, 0x06, 0x7c, 0x18, 0x00,
	0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00,
	0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00,
	0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x0c, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00,
	0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00,
	0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00,
	0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30,
	0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
	0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00,
	0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
	0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00,
	0x7c, 0xc6, 0x06, 0x1c, 0x30, 0x66, 0xfe, 0x00,
	0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00,
	0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00,
	0xfe, 0xc0, 0xc0, 0xfc, 0x06, 0xc6, 0x7c, 0x00,
	0x38, 0x60, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00,
	0xfe, 0xc6, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00,
	0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00,
	0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0x78, 0x00,
	0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
	0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30,
	0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00,
	0x00, 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00,
	0x60, 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xe6, 0x00,
	0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
	0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0x00,
	0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00,
	0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
	0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0,
	0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
	0x00, 0x00, 0xdc, 0x76, 0x60, 0x60, 0xf0, 0x00,
	0x00, 0x00, 0x7e, 0xc0, 0x7c, 0x06, 0xfc, 0x00,
	0x30, 0x30, 0xfc, 0x30, 0x30, 0x36, 0x1c, 0x00,
	0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
	0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00,
	0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
	0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00,
	0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc,
	0x00, 0x00, 0x7e, 0x4c, 0x18, 0x32, 0x7e, 0x00,
	0x0e, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0e, 0x00,
	0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
	0x70, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x70, 0x00,
	0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00,
	0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18,
	0x38, 0x6c, 0x64, 0xf0, 0x60, 0x66, 0xfc, 0x00,
	0x00, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0x00,
	0x66, 0x66, 0x3c, 0x7e, 0x18, 0x7e, 0x18, 0x18,
	0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18,
	0x3e, 0x61, 0x3c, 0x66, 0x66, 0x3c, 0x86, 0x7c,
	0x00, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x7e, 0x81, 0x9d, 0xa1, 0xa1, 0x9d, 0x81, 0x7e,
	0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00,
	0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00,
	0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
	0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e,
	0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00,
	0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00,
	0x78, 0x0c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00,
	0x78, 0x0c, 0x38, 0x0c, 0x78, 0x00, 0x00, 0x00,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 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80,
	0x60, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
	0x18, 0x30, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
	0x78, 0x84, 0x00, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
	0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00,
	0x18, 0x30, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc,
	0xe0, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xf0,
	0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0xfc
};

} // End of namespace Sci