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
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
|
--- a/configure.in 2010-09-25 18:50:12.247566685 +0200
+++ b/configure.in 2010-09-25 18:49:59.867570133 +0200
@@ -430,7 +430,7 @@
AC_ARG_WITH(x, [ --without-x compile without X Window System graphics driver],[if test "$withval" = no; then disable_x=yes; else disable_x=no; fi])
AC_ARG_WITH(fb, [ --without-fb compile without Linux Framebuffer graphics driver],[if test "$withval" = no; then disable_fb=yes; else disable_fb=no; fi])
AC_ARG_WITH(directfb, [ --without-directfb compile without DirectFB graphics driver],[if test "$withval" = no; then disable_directfb=yes; else disable_directfb=no; fi])
-dnl AC_ARG_WITH(sdl, [ --without-sdl compile without SDL graphics driver],[if test "$withval" = no; then disable_sdl=yes; else disable_sdl=no; fi])
+AC_ARG_WITH(sdl, [ --without-sdl compile without SDL graphics driver],[if test "$withval" = no; then disable_sdl=yes; else disable_sdl=no; fi])
AC_ARG_WITH(pmshell, [ --without-pmshell compile without PMShell graphics driver],[if test "$withval" = no; then disable_pmshell=yes; else disable_pmshell=no; fi])
AC_ARG_WITH(atheos, [ --without-atheos compile without Atheos graphics driver],[if test "$withval" = no; then disable_atheos=yes; else disable_atheos; fi])
@@ -501,25 +501,25 @@
fi
fi
-dnl if test "$disable_sdl" != yes ; then
-dnl AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
-dnl if test "$SDL_CONFIG" != "no"; then
-dnl AC_MSG_CHECKING(for SDL >= 1.2.0)
-dnl sdl_version="`$SDL_CONFIG --version`"
-dnl if expr "$sdl_version" \>= 1.2.0 >/dev/null; then
-dnl AC_MSG_RESULT(yes)
-dnl SDL_CFLAGS="`$SDL_CONFIG --cflags`"
-dnl SDL_LIBS="`$SDL_CONFIG --libs`"
-dnl AC_DEFINE(GRDRV_SDL)
-dnl drivers="$drivers SDL"
-dnl CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
-dnl AC_CHECK_LIB(Xext, XextAddDisplay)
-dnl LIBS="$SDL_LIBS $LIBS"
-dnl else
-dnl AC_MSG_RESULT(no)
-dnl fi
-dnl fi
-dnl fi
+if test "$disable_sdl" != yes ; then
+ AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
+ if test "$SDL_CONFIG" != "no"; then
+ AC_MSG_CHECKING(for SDL >= 1.2.0)
+ sdl_version="`$SDL_CONFIG --version`"
+ if expr "$sdl_version" \>= 1.2.0 >/dev/null; then
+ AC_MSG_RESULT(yes)
+ SDL_CFLAGS="`$SDL_CONFIG --cflags`"
+ SDL_LIBS="`$SDL_CONFIG --libs`"
+ AC_DEFINE(GRDRV_SDL)
+ drivers="$drivers SDL"
+ CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
+ AC_CHECK_LIB(Xext, XextAddDisplay)
+ LIBS="$SDL_LIBS $LIBS"
+ else
+ AC_MSG_RESULT(no)
+ fi
+ fi
+fi
if test "$disable_pmshell" != yes ; then
AC_CACHE_CHECK([for pmshell], ac_cv_have_pmshell,
--- a/Makefile.am 2010-09-25 18:42:40.087568555 +0200
+++ b/Makefile.am 2010-09-25 18:42:51.917570410 +0200
@@ -13,7 +13,7 @@
else
endif
-links_SOURCES=af_unix.c auth.c beos.c bfu.c block.c bookmarks.c cache.c charsets.c connect.c cookies.c default.c dip.c directfb.c directfb_cursors.h dither.c dns.c drivers.c error.c file.c finger.c font_include.c framebuffer.c ftp.c gif.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c links_icon.c listedit.c lru.c mailto.c main.c menu.c memory.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c x.c xbm.c links.h cfg.h os_dep.h os_depx.h setup.h codepage.h language.h codepage.inc entity.inc uni_7b.inc language.inc upcase.inc arrow.inc bits.h
+links_SOURCES=af_unix.c auth.c beos.c bfu.c block.c bookmarks.c cache.c charsets.c connect.c cookies.c default.c dip.c directfb.c directfb_cursors.h dither.c dns.c drivers.c error.c file.c finger.c font_include.c framebuffer.c ftp.c gif.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c links_icon.c listedit.c lru.c mailto.c main.c menu.c memory.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c x.c xbm.c links.h cfg.h os_dep.h os_depx.h setup.h codepage.h language.h codepage.inc entity.inc uni_7b.inc language.inc upcase.inc arrow.inc bits.h sdl.c sdl_data.inc
dist-hook:
#remove the symlinka:
--- a/sdl.c 1970-01-01 01:00:00.000000000 +0100
+++ b/sdl.c 2010-09-25 18:38:37.887567087 +0200
@@ -0,0 +1,1161 @@
+/*sdl.c
+ -- SDL graphic driver for Links (version 0.2.0)
+
+ Copyright (C) 2004 Samuel Behan <sam(at)frida(dot)fri(dot)utc(dot)sk>
+
+ This driver 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 driver 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.
+
+ ---
+ I've wrote this driver just as a proof of concept for using SDL library. I wanted
+ to use something easy, so i've decided for the world's best web browser :)
+
+ TODO:
+ - keyboard input system doesn't handles all characters, because sdl ignores any
+ system mappings and provides something like `raw keyboard access'
+ - *_strip functions are possibly bad implemented, actualy i don't understand what
+ they should do, or better i'm too lazy to find it out :)
+ - BUGBUG: aa-lib nor caca lib, dont display nicely - they actualy display nothing ;(
+ This needs to be fixed, becase links over aa-lib as that what i've been
+ dreaming of [ try set env SDL_VIDEODRIVER="aalib" ]
+ ...and many more, not found yet :)
+*/
+
+
+#include "cfg.h"
+
+#ifdef GRDRV_SDL
+
+#ifdef TEXT
+#undef TEXT
+#endif
+
+#include "links.h"
+#include <signal.h>
+/* #include "arrow.inc" */
+
+/*sdl inclusions*/
+#include <SDL.h>
+/*#include <SDL_gfxPrimitives.h>*/
+
+
+/* ------ some config options -------- */
+/*#define sdl_HAVE_DOUBLEBUF */
+
+
+/* ---------- helper tools ----------- */
+/* FIXME: enabled debug mode */
+#undef DEBUG
+#ifdef DEBUG
+#include <assert.h>
+#define S_ASSERT(code) assert((code))
+#define S_ON_DEBUG(code) code
+#define S_ON_DEBUG_TRACE(str) fprintf(stderr, "[%s:%s:%d] %s\n", __FILE__, __PRETTY_FUNCTION__, __LINE__, str);
+#else
+#define S_ASSERT(code)
+#define S_ON_DEBUG(code)
+#define S_ON_DEBUG_TRACE(str)
+#endif
+
+/* internal types */
+typedef unsigned char u_char_t;
+typedef unsigned short int u_short_t;
+struct graphics_driver sdl_driver;
+
+/* keysyms */
+#include "sdl_data.inc"
+
+static struct t_sdl_driver_data {
+ u_char_t *video_drv; /* used video driver name */
+ SDL_VideoInfo *video_info; /* video informations */
+ SDL_Cursor *cursor; /* cursor */
+ int event_timer; /* event timer id */
+ int input_encoding; /* input encoding codepage */
+ struct {
+ long int flags; /* video flags */
+ short int width;
+ short int height;
+ short int depth;
+ short int bpp; /* bytes per pixel */
+ } video;
+} sdl_data = {
+ NULL,
+ NULL,
+ NULL,
+ -1,
+ 0,
+ { 0, 0, 0, 0, 0 },
+};
+#define sdl_VIDEO_WIDTH sdl_DATA.video.width
+#define sdl_VIDEO_HEIGHT sdl_DATA.video.height
+#define sdl_VIDEO_DEPTH sdl_DATA.video.depth
+#define sdl_VIDEO_BPP sdl_DATA.video.bpp
+#define sdl_VIDEO_FLAGS sdl_DATA.video.flags
+
+/* DRIVER DATA HELPERS */
+#define sdl_DATA sdl_data
+#define sdl_DATA_pfmt (sdl_DATA.video_info->vfmt) /* pixel format */
+#define sdl_DATA_FREE() if(sdl_DATA.video_drv != NULL) mem_free(sdl_DATA.video_drv); \
+ if(sdl_DATA.video_info != NULL) mem_free(sdl_DATA.video_info);
+
+struct t_sdl_device_data {
+ SDL_Surface *p_surf; /* primary surface */
+ struct graphics_device *g_dev; /* draphic device */
+ short u_pending; /* update pending */
+ SDL_Rect u_rect; /* update rectangle */
+};
+#define sdl_SURFACE(ptr) (ptr)->p_surf
+#define sdl_GD(ptr) (ptr)->g_dev
+#define sdl_URECT(ptr) (ptr)->u_rect
+#define sdl_UPENDING(ptr) (ptr)->u_pending
+
+/* HELPER FUNCTIONS */
+#define sdl_COLOR(col) (((col) << 2) | 0x00)
+
+#define sdl_SETUP_TIMER(dev) \
+ if (sdl_DATA.event_timer == -1) sdl_DATA.event_timer = install_timer(20, sdl_catch_event, (dev))
+#define sdl_KILL_TIMER() \
+ if (sdl_DATA.event_timer != -1) kill_timer(sdl_DATA.event_timer), sdl_DATA.event_timer = -1
+
+/* event catch helpers */
+#define sdl_CATCH_EVENTS_NUM 30
+#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
+#define sdl_MOUSE_STATE(var_in, var_out, def) \
+ if(var_in == SDL_BUTTON(SDL_BUTTON_LEFT)) \
+ var_out |= B_LEFT; \
+ else if(var_in == SDL_BUTTON(SDL_BUTTON_RIGHT)) \
+ var_out |= B_RIGHT; \
+ else if(var_in == SDL_BUTTON(SDL_BUTTON_MIDDLE)) \
+ var_out |= B_MIDDLE; \
+ else if(var_in == SDL_BUTTON(SDL_BUTTON_WHEELUP)) \
+ var_out |= B_WHEELUP; \
+ else if(var_in == SDL_BUTTON(SDL_BUTTON_WHEELDOWN)) \
+ var_out |= B_WHEELDOWN; \
+ else var_out = (def);
+#else
+#define sdl_MOUSE_STATE(var_in, var_out, def) \
+ if(var_in == SDL_BUTTON(SDL_BUTTON_LEFT)) \
+ var_out |= B_LEFT; \
+ else if(var_in == SDL_BUTTON(SDL_BUTTON_RIGHT)) \
+ var_out |= B_RIGHT; \
+ else if(var_in == SDL_BUTTON(SDL_BUTTON_MIDDLE)) \
+ var_out |= B_MIDDLE; \
+ else var_out = (def);
+#endif
+
+
+/* tha event handler */
+static void sdl_catch_event(void *data)
+{
+ register int i = 0;
+ register int ev_num = 0;
+ register u_short_t fl = 0;
+ register struct t_sdl_device_data *dev = NULL;
+ SDL_Event events[sdl_CATCH_EVENTS_NUM];
+
+ /* speedup (BUGGY, not thread safe !?!) */
+ static u_short_t o_x = 0, o_y = 0, o_fl = 0;
+
+ sdl_DATA.event_timer = -1;
+
+ SDL_PumpEvents();
+ ev_num = SDL_PeepEvents(events, sdl_CATCH_EVENTS_NUM, SDL_GETEVENT, SDL_ALLEVENTS);
+
+ S_ASSERT(ev_num != -1);
+ /* get dev data */
+ dev = (struct t_sdl_device_data *) data;
+ for(i = 0; i < ev_num; i++)
+ {
+#define event events[i]
+ switch (event.type)
+ {
+/* case SDL_ACTIVEEVENT: */
+ /* mouse motion */
+ case SDL_MOUSEMOTION:
+ /* mose btn state */
+ /* S_ON_DEBUG_TRACE("event: mouse motion"); */
+ fl = B_DRAG;
+ sdl_MOUSE_STATE(event.motion.state, fl, B_MOVE);
+ /* save som calls (SDL generates many similar events) */
+ if(event.motion.x == o_x && event.motion.y == o_y && fl == o_fl)
+ break;
+ /* call handler */
+ sdl_GD(dev)->mouse_handler(sdl_GD(dev), event.motion.x, event.motion.y, fl);
+ o_x = event.motion.x;
+ o_y = event.motion.y;
+ o_fl = fl;
+ break;
+ /* mouse click */
+ case SDL_MOUSEBUTTONUP:
+ case SDL_MOUSEBUTTONDOWN:
+#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
+ if(event.button.button == SDL_BUTTON_WHEELUP)
+ fl = B_WHEELUP | B_MOVE;
+ else if(event.button.button == SDL_BUTTON_WHEELDOWN)
+ fl = B_WHEELDOWN | B_MOVE;
+ else
+#endif
+ {
+ if(event.type == SDL_MOUSEBUTTONDOWN)
+ fl = B_DOWN;
+ else
+ fl = B_UP;
+ }
+
+ /* S_ON_DEBUG_TRACE("event: mouse click"); */
+ /* sdl_MOUSE_STATE(event.button.state, fl, fl); */
+ sdl_GD(dev)->mouse_handler(sdl_GD(dev), event.button.x, event.button.y, fl);
+ break;
+
+ /* keyboard */
+ case SDL_KEYUP:
+ /* S_ON_DEBUG_TRACE("event: key up"); */
+ break;
+ case SDL_KEYDOWN:
+ { /*translate */
+ int k = 0;
+ int key = 0;
+/*
+* //////////////////////////
+* //FIXME: needs rework !!!
+* // -- sdl works at low-level ignoring any system keymappings
+* // i've no idea how to do it (easily):(
+* //////////////////////////
+*/
+ /* S_ON_DEBUG_TRACE("event: key down"); */
+ while(sdl_keysyms[k].sym != event.key.keysym.sym && sdl_keysyms[k].sym != SDLK_LAST)
+ k++;
+ S_ASSERT(sdl_keysyms[k].sym != SDLK_LAST);
+ /* FIXME: hope nobody changes enumeration values in SDL libs */
+ if(sdl_keysyms[k].sym >= SDLK_NUMLOCK && sdl_keysyms[k].sym <= SDLK_COMPOSE)
+ break; /* aka ignore modifiers */
+ /* find modifiers */
+ fl = 0;
+ if(event.key.keysym.mod & KMOD_SHIFT)
+ fl |= KBD_SHIFT;
+ if(event.key.keysym.mod & KMOD_ALT)
+ fl |= KBD_ALT;
+ if(event.key.keysym.mod & KMOD_CTRL)
+ fl |= KBD_CTRL;
+ /* key re-map */
+ key = sdl_keysyms[k].key;
+ /* upper letters fix (not handled directly by SDL) */
+ if(key >= 97 && key <= 122 && fl & KBD_SHIFT)
+ { key -= 32;
+ fl &= ~KBD_SHIFT; }
+ /* find modifiers */
+ fl = 0;
+ if(event.key.keysym.mod & KMOD_SHIFT)
+ fl |= KBD_SHIFT;
+ if(event.key.keysym.mod & KMOD_ALT)
+ fl |= KBD_ALT;
+ if(event.key.keysym.mod & KMOD_CTRL)
+ fl |= KBD_CTRL;
+ /* send keyb */
+ /* S_ON_DEBUG(fprintf(stderr, "KEY(%d) = %c&%d\n", k, key, fl);); */
+ if(fl & KBD_CTRL && sdl_keysyms[k].sym == SDLK_c)
+ sdl_GD(dev)->keyboard_handler(sdl_GD(dev), KBD_CTRL_C, 0);
+ else
+ sdl_GD(dev)->keyboard_handler(sdl_GD(dev), key, fl);
+ }break;
+ case SDL_VIDEORESIZE:
+ /* new dims */
+ sdl_GD(dev)->size.x2 = event.resize.w;
+ sdl_GD(dev)->size.y2 = event.resize.h;
+ sdl_driver.x = event.resize.w;
+ sdl_driver.y = event.resize.h;
+ /* resize */
+ /*
+ S_ON_DEBUG(fprintf(stderr, "RESIZE(%dx%d)\n", event.resize.w, event.resize.h));
+ */
+ /* info resize */
+ sdl_GD(dev)->resize_handler(sdl_GD(dev));
+ break;
+/*
+ case SDL_VIDEOEXPOSE:
+*/
+ case SDL_QUIT:
+ sdl_GD(dev)->keyboard_handler(sdl_GD(dev), KBD_CLOSE, 0);
+ break;
+ default:
+ /* printf("Unhandled event: %d !\n", event.type); */
+ break;
+ }
+ }
+#undef event
+ sdl_SETUP_TIMER((void *)dev);
+ return;
+}
+
+static void sdl_update_sc(void *data)
+{
+ register struct t_sdl_device_data *dev;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ /* assign struct */
+ if(data == NULL)
+ return;
+ dev = (struct t_sdl_device_data *)data;
+ /* check if update neccesary */
+#ifdef __NOT_DEF
+ if(dev == NULL || sdl_SURFACE(dev) == NULL)
+ return;
+ if(sdl_UPENDING(dev) == 0)
+ return;
+#endif
+
+#ifndef sdl_HAVE_DOUBLEBUF
+ /*update screen*/
+ S_ON_DEBUG(fprintf(stderr, "rel-update(%dx%dX%dx%d)\n", sdl_URECT(dev).x, sdl_URECT(dev).y, sdl_URECT(dev).w, sdl_URECT(dev).h));
+ /* bound check */
+ if(sdl_URECT(dev).x + sdl_URECT(dev).w > sdl_VIDEO_WIDTH)
+ sdl_URECT(dev).w = sdl_VIDEO_WIDTH - sdl_URECT(dev).x;
+ if(sdl_URECT(dev).y + sdl_URECT(dev).h > sdl_VIDEO_HEIGHT)
+ sdl_URECT(dev).h = sdl_VIDEO_HEIGHT - sdl_URECT(dev).y;
+ /* perform screen update */
+ SDL_UpdateRect(sdl_SURFACE(dev), sdl_URECT(dev).x, sdl_URECT(dev).y, sdl_URECT(dev).w, sdl_URECT(dev).h);
+#else
+ SDL_Flip(sdl_SURFACE(dev));
+#endif
+ /* remove pending flag */
+ sdl_UPENDING(dev) = 0;
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+
+/* quite stuppit function */
+#define sdl_NORM_UPDATE 0
+#define sdl_FULL_UPDATE 1
+static inline void sdl_register_update(struct t_sdl_device_data *dev,
+ const int x, const int y, const int w, const int h, const int opt)
+{
+#ifdef __NOT_DEF
+ if (x < 0 || y < 0 || w < 1 || h < 1)
+ return;
+#endif
+#ifndef sdl_HAVE_DOUBLEBUF
+
+ if (sdl_UPENDING(dev))
+ {
+/* S_ON_DEBUG(fprintf(stderr, "<<rect-in1(%dx%dX%dx%d)\t[%dx%dX%dx%d]\n", sdl_URECT(dev).x,sdl_URECT(dev).y, sdl_URECT(dev).x + sdl_URECT(dev).w, sdl_URECT(dev).y + sdl_URECT(dev).h,
+ sdl_URECT(dev).x,sdl_URECT(dev).y, sdl_URECT(dev).x, sdl_URECT(dev).y));
+ S_ON_DEBUG(fprintf(stderr, "<<rect-in2(%dx%dX%dx%d)\t[%dx%dX%dx%d]\n", x, y, x + w, y + h,
+ x, y, w, h));
+*/
+ /* compute correct update rectangle */
+ if(sdl_URECT(dev).w < w)
+ sdl_URECT(dev).w = w;
+ if(sdl_URECT(dev).h < h)
+ sdl_URECT(dev).h = h;
+ if(sdl_URECT(dev).x > x)
+ { sdl_URECT(dev).w += sdl_URECT(dev).x - x;
+ sdl_URECT(dev).x = x; }
+ if(sdl_URECT(dev).y > y)
+ { sdl_URECT(dev).h += sdl_URECT(dev).y - y;
+ sdl_URECT(dev).y = y; }
+ if(x + w > sdl_URECT(dev).w)
+ sdl_URECT(dev).w = x + w - 1;
+ if(y + h > sdl_URECT(dev).h)
+ sdl_URECT(dev).h = y + h - 1;
+/* S_ON_DEBUG(fprintf(stderr, ">>rect-out(%dx%dX%dx%d)\t[%dx%dX%dx%d]\n", sdl_URECT(dev).x,sdl_URECT(dev).y, sdl_URECT(dev).x + sdl_URECT(dev).w, sdl_URECT(dev).y + sdl_URECT(dev).h,
+ sdl_URECT(dev).x,sdl_URECT(dev).y, sdl_URECT(dev).x, sdl_URECT(dev).y));
+*/
+ return;
+ }
+ /* create update rectangle */
+ sdl_URECT(dev).x = x;
+ sdl_URECT(dev).y = y;
+ sdl_URECT(dev).w = w;
+ sdl_URECT(dev).h = h;
+#else
+ if(sdl_UPENDING(dev))
+ return;
+#endif
+ sdl_UPENDING(dev) = 1;
+ /* register update */
+ register_bottom_half(sdl_update_sc, dev);
+ return;
+}
+
+/* partialy stolen from documentation :)
+ XXX: we can quite easily add here alpha blending :))) */
+static inline void sdl_putpixel(const SDL_Surface *s, const int x, const int y, const unsigned long pixel)
+{
+ register Uint8 *p;
+
+ /* check our clip rect */
+ if(!((s->clip_rect.x < x && (s->clip_rect.x + s->clip_rect.w) > x)
+ && (s->clip_rect.y < y && (s->clip_rect.y + s->clip_rect.h) > y)))
+ return;
+ /* our sanity (fight int overflow :) */
+/*
+ pixel &= (1<<(s->format->BytesPerPixel)) - 1;
+*/
+ /* our point */
+ p = (Uint8 *)s->pixels + y * s->pitch + x * s->format->BytesPerPixel;
+ switch(s->format->BytesPerPixel) {
+ case 1:
+ *p = pixel;
+ break;
+ case 2:
+ *(Uint16 *)p = pixel;
+ break;
+
+ case 3:
+ if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ p[0] = (pixel >> 16) & 0xff;
+ p[1] = (pixel >> 8) & 0xff;
+ p[2] = pixel & 0xff;
+ } else {
+ p[0] = pixel & 0xff;
+ p[1] = (pixel >> 8) & 0xff;
+ p[2] = (pixel >> 16) & 0xff;
+ }
+ break;
+ case 4:
+ *(Uint32 *)p = pixel;
+ break;
+ }
+ return;
+}
+
+
+/* DRIVER FUNCTIONS */
+
+ /* findout avibles video mode */
+static u_char_t *sdl_list_videomodes(void)
+{
+ SDL_Rect **modes;
+
+ modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
+ /* check if any mode avaible */
+ if(modes == (SDL_Rect **) 0)
+ return stracpy("No modes available!\n");
+ /* any dimenstion possible */
+ else if(modes == (SDL_Rect **) -1)
+ return stracpy("All resolutions available.\n");
+ else /* list possible modes */
+ {
+ int i;
+ printf("Available Modes: \n");
+ for(i = 0; modes[i] != NULL; ++i)
+ printf("\t%dx%d\n", modes[i]->w, modes[i]->h);
+ }
+ return NULL;
+}
+
+#define sdl_DRV_MAXLEN 15
+#define sdl_RES_MAXLEN 5
+#define sdl_DEPTH_MAXLEN 2
+/* init driver */
+static u_char_t *sdl_init_driver(u_char_t *param, u_char_t *display)
+{
+ unsigned long video_bw_suggest = 0;
+
+ S_ON_DEBUG_TRACE("in");
+
+ /* determine required video mode (we are going to parse input string -- BE AWARE !!!)
+ LITTLE BIT PARANOID IMPLEMENTATION :) */
+ if(param != NULL)
+ {
+ int p_pos = 0;
+ u_char_t *m = NULL;
+ u_char_t *m2 = NULL;
+ u_char_t *p = NULL;
+ unsigned long res_x = 0;
+ unsigned long res_y = 0;
+ unsigned long res_bw = 0;
+ u_char_t drv[sdl_DRV_MAXLEN] = "";
+
+ m = stracpy(param);
+ m2 = m;
+
+ /* S_ON_DEBUG(fprintf(stderr, "parse> input = %s\n", m)); */
+
+ /* look for driver name to use */
+ p = strchr(m2, ':');
+ if(p != NULL)
+ { /* calc length */
+ p_pos = (int) p - (int) m2;
+ if(p_pos > sdl_DRV_MAXLEN)
+ goto bugbug;
+ strncpy(drv, m2, p_pos);
+ drv[p_pos] = '\0';
+ /* move fwd */
+ m2 = (u_char_t *) (m2 + p_pos + 1);
+ }
+
+ /* find 'x' character (FOR X_RES)*/
+ p = strchr(m2, 'x');
+ /* calculate length*/
+ if(p != NULL)
+ p_pos = (int) p - (int) m2;
+ else
+ p_pos = strlen(m2);
+ /*check max length*/
+ if(p_pos > sdl_RES_MAXLEN)
+ goto bugbug;
+
+ /* S_ON_DEBUG(fprintf(stderr,"parse> input(x) = %s\n", m2)); */
+ res_x = atoi(m2);
+ /* S_ON_DEBUG(fprintf(stderr,"parse> res_x = %d\n", res_x)); */
+ /* move fwd */
+
+ if(m2[p_pos] == 'x')
+ m2 = (u_char_t *) (m2 + p_pos + 1);
+ else
+ goto bugbug;
+
+ /* find 'x' character (FOR Y_RES)*/
+ p = strchr(m2, 'x');
+ /* calculate length*/
+ if(p != NULL)
+ p_pos = (int) p - (int) m2;
+ else
+ p_pos = strlen(m2);
+ /*check max length*/
+ if(p_pos > sdl_RES_MAXLEN)
+ goto bugbug;
+
+ /* S_ON_DEBUG(fprintf(stderr,"parse> input(y) = %s\n", m2)); */
+ res_y = atoi(m2);
+ /* S_ON_DEBUG(fprintf(stderr,"parse> res_y = %d\n", res_y)); */
+ /* move fwd */
+ if(m2[p_pos] == 'x')
+ { /* findout bits-per-pixel*/
+ m2 = (u_char_t *) (m2 + p_pos + 1);
+
+ /* S_ON_DEBUG(fprintf(stderr,"parse> input(bw) = %s\n", m2)); */
+
+ /* check length */
+ if(strlen(m) - (int) (m2 - m) == 0)
+ goto no_bugbug;
+ if(strlen(m) - (int) (m2 - m) > sdl_DEPTH_MAXLEN)
+ goto bugbug;
+
+ res_bw = atoi(m2);
+ }
+
+ /* S_ON_DEBUG(fprintf(stderr,"parse> depth = %d\n", res_bw)); */
+ goto no_bugbug;
+
+ bugbug:
+ mem_free(m);
+ return stracpy("ERROR: bad mode given for `-mode' param (use: [<sdl_driver>:]<width>x<height>[x<bpp>])\n");
+ no_bugbug:
+ mem_free(m);
+ /*
+ if(drv[0] != '\0')
+ fprintf(stderr, "VIDEO(%s):\t %ldx%ldx%ldbpp [requested]\n", drv, res_x, res_y, res_bw);
+ else fprintf(stderr, "VIDEO(auto):\t %ldx%ldx%ldbpp [requested]\n", res_x, res_y, res_bw);
+ */
+
+ /* set them */
+ sdl_VIDEO_WIDTH = res_x;
+ sdl_VIDEO_HEIGHT = res_y;
+ sdl_VIDEO_DEPTH = res_bw; /* 0 - means current depth */
+ if(drv[0] != '\0') /* set driver name to env */
+ { u_char_t en[20 + sdl_DRV_MAXLEN];
+
+ sprintf(en, "%s=%s", "SDL_VIDEODRIVER", drv);
+ putenv(en); }
+ }
+
+ /* pass some opts to sdl via enviroment*/
+ putenv("SDL_VIDEO_CENTERED=1");
+
+ /* init sdl video */
+ if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) != 0) {
+ u_char_t *u = stracpy((u_char_t *)SDL_GetError());
+ add_to_strn(&u, "\n");
+ return u;
+ }
+
+ /* fetch current video hw informations */
+ sdl_DATA.video_info = (SDL_VideoInfo *) mem_alloc(sizeof(SDL_VideoInfo));
+ S_ASSERT(sdl_DATA.video_info != NULL);
+ memcpy(sdl_DATA.video_info, SDL_GetVideoInfo(), (sizeof(SDL_VideoInfo)));
+ /* fetch driver name */
+ sdl_DATA.video_drv = (u_char_t *)mem_alloc(sizeof(u_char_t) * 11);
+ S_ASSERT(sdl_DATA.video_drv != NULL);
+ SDL_VideoDriverName((char *)sdl_DATA.video_drv, 11);
+
+ /* setup defaults */
+ sdl_VIDEO_FLAGS |= SDL_HWSURFACE | SDL_HWPALETTE | SDL_RESIZABLE | SDL_RLEACCEL | SDL_ASYNCBLIT;
+#ifdef sdl_HAVE_DOUBLEBUF
+ sdl_VIDEO_FLAGS |= SDL_DOUBLEBUF;
+#endif
+ if(sdl_VIDEO_WIDTH == 0)
+ sdl_VIDEO_WIDTH = 800;
+ if(sdl_VIDEO_HEIGHT == 0)
+ sdl_VIDEO_HEIGHT= 600;
+ if(sdl_VIDEO_DEPTH == 0)
+ sdl_VIDEO_DEPTH = sdl_DATA.video_info->vfmt->BitsPerPixel;
+
+ /* FIXME: not sure if this is correct !!!*/
+ sdl_VIDEO_BPP = (sdl_VIDEO_DEPTH / 8);
+ if(sdl_VIDEO_DEPTH % 8 != 0)
+ sdl_VIDEO_BPP += 1;
+
+ /* set driv config */
+ sdl_driver.x = sdl_VIDEO_WIDTH;
+ sdl_driver.y = sdl_VIDEO_HEIGHT;
+/* sdl_driver.depth = ((sdl_DATA.video_info->vfmt->BytesPerPixel & 0x7) |
+ (((sdl_DATA.video_info->vfmt->BitsPerPixel > 24 ? 24 : sdl_DATA.video_info->vfmt->BitsPerPixel) & 0x1F) << 3));
+*/
+ sdl_driver.depth = ((sdl_VIDEO_BPP & 0x7) |
+ (((sdl_VIDEO_DEPTH > 24 ? 24 : sdl_VIDEO_DEPTH) & 0x1F) << 3));
+
+ S_ON_DEBUG(fprintf(stderr, "display = %d@%d [%d] (requested)\n", sdl_VIDEO_DEPTH, sdl_VIDEO_BPP, sdl_driver.depth));
+
+
+ /* check if video mode ok*/
+ video_bw_suggest = SDL_VideoModeOK(sdl_VIDEO_WIDTH, sdl_VIDEO_HEIGHT, sdl_VIDEO_DEPTH, sdl_VIDEO_FLAGS);
+ if(video_bw_suggest == 0)
+ {
+ sdl_list_videomodes();
+ sdl_DATA_FREE();
+ return stracpy("ERROR: Requested video mode not OK !\n");
+ }
+
+ /* check */
+ if(video_bw_suggest != (unsigned long)sdl_VIDEO_DEPTH)
+ fprintf(stderr, "WARNING: Video driver suggested '%ldbpp' video depth...\n", video_bw_suggest);
+
+
+ /* endianness (stolen from directfb.c) */
+ if (htons (0x1234) == 0x1234)
+ sdl_driver.depth |= 0x100;
+
+ switch (sdl_driver.depth) {
+ case 33:
+ case 65:
+ case 122:
+ case 130:
+ case 386:
+ case 451:
+ case 195:
+ case 452:
+ case 196:
+ case 708:
+ break;
+ default:
+ sdl_DATA_FREE();
+ SDL_Quit();
+ return stracpy("ERROR: Unsupported display pixel format\n");
+ }
+
+ /* create cursor :) (need nice one) */
+#ifdef sdl_HAVE_CURSOR
+ if(sdl_DATA.cursor == NULL)
+ {
+ /* sdl_DATA.cursor = SDL_CreateCursor((void *)arrow, (void *)arrow, 32, 32, 0, 0);
+ */
+ S_ASSERT(sdl_DATA.cursor != NULL);
+ }
+#endif
+ /* key repeat */
+ SDL_EnableUNICODE(1);
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+
+
+ sdl_DATA.input_encoding = -1;
+#if defined(HAVE_NL_LANGINFO) && defined(HAVE_LANGINFO_H) && defined(CODESET)
+ {
+ unsigned char *cp;
+ cp = nl_langinfo(CODESET);
+ sdl_DATA.input_encoding = get_cp_index(cp);
+ }
+#endif
+ return NULL;
+}
+
+/* shutdown driver */
+static void sdl_shutdown_driver(void)
+{
+ S_ON_DEBUG_TRACE("in");
+ sdl_KILL_TIMER();
+ sdl_DATA_FREE();
+ SDL_Quit();
+ return;
+}
+
+/* create new graph device */
+static struct graphics_device *sdl_init_device(void)
+{
+ struct graphics_device *dev = NULL;
+ struct t_sdl_device_data *data = NULL;
+
+ S_ON_DEBUG_TRACE("in");
+
+ /* device data */
+ data = (struct t_sdl_device_data *) mem_alloc(sizeof(struct t_sdl_device_data));
+ S_ASSERT(data != NULL);
+ memset(data, 0, sizeof(struct t_sdl_device_data));
+
+ /* init video mode */
+ sdl_SURFACE(data) = SDL_SetVideoMode(sdl_VIDEO_WIDTH, sdl_VIDEO_HEIGHT, sdl_VIDEO_DEPTH,
+ sdl_VIDEO_FLAGS);
+
+ if(sdl_SURFACE(data) == NULL)
+ return NULL;
+ /* set display alpha */
+ /* SDL_SetAlpha(sdl_SURFACE(data), SDL_SRCALPHA, 0xff); */
+
+ /* re-updating video mode informations */
+ memcpy(sdl_DATA.video_info, SDL_GetVideoInfo(), (sizeof(SDL_VideoInfo)));
+
+ /* re-update depth (to use the one we realy got from SDL) */
+#ifdef __NOT_DEF
+ sdl_driver.depth = ((sdl_DATA.video_info->vfmt->BytesPerPixel & 0x7) |
+ (((sdl_DATA.video_info->vfmt->BitsPerPixel > 24 ? 24 : sdl_DATA.video_info->vfmt->BitsPerPixel) & 0x1F) << 3));
+#endif
+ S_ON_DEBUG(fprintf(stderr, "display = %d@%d [%d]\n", sdl_DATA.video_info->vfmt->BitsPerPixel, sdl_DATA.video_info->vfmt->BytesPerPixel, sdl_driver.depth));
+
+ /* alloc gd */
+ dev = (struct graphics_device *) mem_alloc(sizeof(struct graphics_device));
+ S_ASSERT(dev != NULL);
+
+ /* setup gdS */
+ dev->size.x1 = 0;
+ dev->size.y1 = 0;
+ dev->size.x2 = sdl_VIDEO_WIDTH;
+ dev->size.y2 = sdl_VIDEO_HEIGHT;
+ dev->clip = dev->size;
+
+ /*driver */
+ sdl_GD(data) = dev;
+
+ /* input encoding flags */
+ if (sdl_DATA.input_encoding < 0)
+ sdl_driver.flags |= GD_NEED_CODEPAGE;
+
+ /*driver */
+ dev->drv = &sdl_driver;
+ dev->driver_data = (void *) data;
+ dev->user_data = NULL;
+
+ /*set my cursor */
+ if(sdl_DATA.cursor != NULL)
+ SDL_SetCursor(sdl_DATA.cursor);
+
+ /*init timer */
+ sdl_SETUP_TIMER((void *)data);
+ /* print device video info */
+ /*fprintf(stderr, "VIDEO(%s):\t %dx%dx%dbpp [%d]\n", sdl_DATA.video_drv,
+ sdl_VIDEO_WIDTH, sdl_VIDEO_HEIGHT, sdl_VIDEO_DEPTH, sdl_driver.depth);*/
+
+ S_ON_DEBUG_TRACE("out");
+ return dev;
+}
+
+/* destroy device */
+static void sdl_shutdown_device(struct graphics_device *drv)
+{
+ struct t_sdl_device_data *dev = NULL;
+
+ S_ON_DEBUG_TRACE("in");
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+ S_ASSERT(dev != NULL);
+
+ /* unregister bh */
+ unregister_bottom_half(sdl_update_sc, dev);
+
+ /* deinit video */
+ SDL_FreeSurface(sdl_SURFACE(dev));
+ sdl_SURFACE(dev) = NULL;
+ mem_free(dev);
+ drv->driver_data = NULL;
+ mem_free(drv);
+ S_ON_DEBUG_TRACE("out");
+ return;
+}
+
+/* get driver parameters
+ XXX: what is this fx() for ??? */
+static u_char_t *sdl_get_driver_param(void)
+{
+ S_ON_DEBUG_TRACE("in");
+ S_ASSERT(0);
+ return NULL;
+}
+
+/* GRAPHICS */
+
+/* create empty bitmap */
+static int sdl_get_empty_bitmap(struct bitmap *bmp)
+{
+ SDL_Surface *s = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+
+ /* null */
+ bmp->data = bmp->flags = bmp->user = NULL;
+ bmp->skip = 0;
+
+ /* alloc surface */
+ /* FIXED: ignoring byteorder here (taking from video info) */
+ s = (SDL_Surface *)SDL_CreateRGBSurface(sdl_VIDEO_FLAGS, bmp->x, bmp->y, sdl_VIDEO_DEPTH,
+ sdl_DATA.video_info->vfmt->Rmask, sdl_DATA.video_info->vfmt->Gmask,
+ sdl_DATA.video_info->vfmt->Bmask, sdl_DATA.video_info->vfmt->Amask);
+ S_ASSERT(s != NULL);
+
+ /* copy data */
+ bmp->data = (void *)s->pixels;
+ bmp->skip = s->pitch;
+ bmp->flags = (void *)s;
+
+ /* lock if required */
+ if(SDL_MUSTLOCK(s))
+ SDL_LockSurface(s);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return 0;
+}
+
+/* create filled bitmap */
+/*
+int sdl_get_filled_bitmap(struct bitmap *bmp, long color)
+{
+ S_ASSERT(0);
+ return 0;
+}
+*/
+
+/* register bitmap */
+static void sdl_register_bitmap(struct bitmap *bmp)
+{
+ SDL_Surface *s = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+
+ /* unlock surface */
+ s = (SDL_Surface *)bmp->flags;
+ if(SDL_MUSTLOCK(s))
+ SDL_UnlockSurface(s);
+ /* hide pixel mem */
+ bmp->data = NULL;
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+
+/* prepare strip */
+static void *sdl_prepare_strip(struct bitmap *bmp, int top, int lines)
+{
+ SDL_Surface *s = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+
+ /* unlock surface */
+ s = (SDL_Surface *)bmp->flags;
+ if(SDL_MUSTLOCK(s))
+ SDL_LockSurface(s);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return (void *)(s->pixels + (top * s->pitch));
+}
+
+/* commit strip */
+static void sdl_commit_strip(struct bitmap *bmp, int top, int lines)
+{
+ SDL_Surface *s = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+
+ /* unlock surface */
+ s = (SDL_Surface *)bmp->flags;
+ if(SDL_MUSTLOCK(s))
+ SDL_UnlockSurface(s);
+ return;
+}
+
+/* unregister bitmap */
+static void sdl_unregister_bitmap(struct bitmap *bmp)
+{
+ SDL_Surface *s = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+
+ s = (SDL_Surface *)bmp->flags;
+ S_ASSERT(s != 0);
+ /* delete data */
+ SDL_FreeSurface(s);
+ /* null data */
+ bmp->data = NULL;
+ bmp->flags = NULL;
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+/* draw bmp */
+static void sdl_draw_bitmap(struct graphics_device *drv, struct bitmap *bmp, int x, int y)
+{
+ SDL_Surface *s = NULL;
+ struct t_sdl_device_data *dev = NULL;
+ SDL_Rect rect;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+ s = (SDL_Surface *)bmp->flags;
+ memset(&rect, 0, sizeof(SDL_Rect));
+
+ /* blit :) */
+ rect.x = x;
+ rect.y = y;
+ SDL_BlitSurface(s, NULL, sdl_SURFACE(dev), &rect);
+ sdl_register_update(dev, rect.x, rect.y, rect.w, rect.h, 0);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+/* draw more bmps */
+static void sdl_draw_bitmaps(struct graphics_device *drv, struct bitmap **bmps, int n, int x, int y)
+{
+ int i = 0;
+
+ struct t_sdl_device_data *dev = NULL;
+ SDL_Rect rect;
+
+ /* FIXME: this functions seems not to be correct !!! */
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ /* check */
+ if(n < 1)
+ return;
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+ memset(&rect, 0, sizeof(SDL_Rect));
+
+ /* blit */
+ rect.x = x;
+ rect.y = y;
+ for(i = 0; i < n; i++)
+ { SDL_BlitSurface((SDL_Surface *)bmps[i]->flags, NULL, sdl_SURFACE(dev), &rect);
+ rect.x += bmps[i]->x; }
+ /* FIXME: this should care about updating area, and possibly not update everythink */
+ sdl_register_update(dev, 0, 0, sdl_VIDEO_WIDTH, sdl_VIDEO_HEIGHT, 0);
+ return;
+}
+
+/* fill some area */
+static void sdl_fill_area(struct graphics_device *drv, int x1, int y1, int x2, int y2, long color)
+{
+ struct t_sdl_device_data *dev = NULL;
+ SDL_Rect rect;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+
+
+ rect.x = x1;
+ rect.y = y1;
+ rect.w = x2 - x1;
+ rect.h = y2 - y1;
+ if(SDL_MUSTLOCK(sdl_SURFACE(dev)))
+ SDL_LockSurface(sdl_SURFACE(dev));
+ SDL_FillRect(sdl_SURFACE(dev), &rect, color);
+ if(SDL_MUSTLOCK(sdl_SURFACE(dev)))
+ SDL_UnlockSurface(sdl_SURFACE(dev));
+ /* S_ON_DEBUG(fprintf(stderr, "sdl_fill_area-update(%dx%dx%dx%d)\n", rect.x, rect.y, rect.w, rect.h)); */
+ sdl_register_update(dev, rect.x, rect.y, rect.w, rect.h, 0);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+/* draw horizontal line */
+static void sdl_draw_hline(struct graphics_device *drv, int left, int y, int right, long color)
+{
+ register int i = 0;
+ struct t_sdl_device_data *dev = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+ if(SDL_MUSTLOCK(sdl_SURFACE(dev)))
+ SDL_LockSurface(sdl_SURFACE(dev));
+ for(i = left; i <= right; i++)
+ sdl_putpixel(sdl_SURFACE(dev), i, y, color);
+ if(SDL_MUSTLOCK(sdl_SURFACE(dev)))
+ SDL_UnlockSurface(sdl_SURFACE(dev));
+ sdl_register_update(dev, left, y, right - left + 1, 1, 0);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+/* draw vertical line */
+static void sdl_draw_vline(struct graphics_device *drv, int x, int top, int bottom, long color)
+{
+ register int i = 0;
+ struct t_sdl_device_data *dev = NULL;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ /* get ptr */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+ if(SDL_MUSTLOCK(sdl_SURFACE(dev)))
+ SDL_LockSurface(sdl_SURFACE(dev));
+ for(i = top; i <= bottom; i++)
+ sdl_putpixel(sdl_SURFACE(dev), x, i, color);
+ if(SDL_MUSTLOCK(sdl_SURFACE(dev)))
+ SDL_UnlockSurface(sdl_SURFACE(dev));
+
+ sdl_register_update(dev, x, top, 1, bottom - top + 1, 0);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+/* horizontal scroll */
+static int sdl_hscroll(struct graphics_device *drv, struct rect_set **set, int sc)
+{
+ struct t_sdl_device_data *dev = NULL;
+ SDL_Rect rect1, rect2;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+
+ /* rect1 */
+ rect1.x = drv->clip.x1;
+ rect1.y = drv->clip.y1;
+ rect1.w = drv->clip.x2 - rect1.x;
+ rect1.h = drv->clip.y2 - rect1.y;
+
+ /* rect2 */
+ rect2.x = drv->clip.x1 + sc;
+ rect2.y = drv->clip.y1;
+#ifdef __NOT_DEF
+ rect2.w = drv->clip.x2 - rect1.x;
+ rect2.h = drv->clip.y2 - rect1.y;
+#endif
+
+ SDL_BlitSurface(sdl_SURFACE(dev), &rect1, sdl_SURFACE(dev), &rect2);
+ sdl_register_update(dev, rect1.x, rect1.y, rect1.w, rect1.h, 0);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return 1;
+}
+
+/* vertical scroll */
+static int sdl_vscroll(struct graphics_device *drv, struct rect_set **set, int sc)
+{
+ struct t_sdl_device_data *dev = NULL;
+ SDL_Rect rect1, rect2;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ /* get ptr */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+
+ /* rect1 */
+ rect1.x = drv->clip.x1;
+ rect1.y = drv->clip.y1;
+ rect1.w = drv->clip.x2 - rect1.x;
+ rect1.h = drv->clip.y2 - rect1.y;
+
+ /* rect2 */
+ rect2.x = drv->clip.x1;
+ rect2.y = drv->clip.y1 + sc;
+#ifdef __NOT_DEF
+ rect2.w = drv->clip.x2 - rect1.x;
+ rect2.h = drv->clip.y2 - rect1.y;
+#endif
+
+ SDL_BlitSurface(sdl_SURFACE(dev), &rect1, sdl_SURFACE(dev), &rect2);
+ sdl_register_update(dev, rect1.x, rect1.y, rect1.w, rect1.h, 0);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return 1;
+}
+
+/* set cliping area */
+static void sdl_set_clip_area(struct graphics_device *drv, struct rect *r)
+{
+ struct t_sdl_device_data *dev = NULL;
+ SDL_Rect rect;
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ /* get ptr */
+ dev = (struct t_sdl_device_data *) drv->driver_data;
+ /* set rect */
+ rect.x = r->x1;
+ rect.y = r->y1;
+ rect.w = r->x2 - r->x1;
+ rect.h = r->y2 - r->y1;
+ /* dev clipp */
+ drv->clip = *r;
+ /* clipp */
+ SDL_SetClipRect(sdl_SURFACE(dev), &rect);
+ /* S_ON_DEBUG_TRACE("out"); */
+ return;
+}
+
+/* return rgb color */
+static long sdl_get_color(int rgb)
+{
+ /* call depth specific function (going like this enables us to use multiple screens with various depths) [someday] */
+ static long (*gc)(int rgb) = NULL;
+
+ if(gc == NULL)
+ gc = get_color_fn(sdl_driver.depth);
+ /*return rgb specific*/
+ if(gc != NULL)
+ return gc(rgb);
+ else
+ return (rgb);
+}
+
+/* set window title (tittle utf-8 encoded !!!!) */
+static void sdl_set_title(struct graphics_device *drv, u_char_t *title)
+{
+ struct conv_table *ct = get_translation_table(utf8_table, sdl_DATA.input_encoding >= 0 ? sdl_DATA.input_encoding:0);
+ unsigned char *t;
+
+ /* convert tittle */
+ t = convert_string(ct, title, strlen(title), NULL);
+
+ /* S_ON_DEBUG_TRACE("in"); */
+ SDL_WM_SetCaption((const char *)t, NULL);
+ mem_free(t);
+ return;
+}
+
+
+
+/* driver definition data */
+struct graphics_driver sdl_driver={
+ "sdl",
+ sdl_init_driver,
+ sdl_init_device,
+ sdl_shutdown_device,
+ sdl_shutdown_driver,
+ sdl_get_driver_param,
+ sdl_get_empty_bitmap,
+ /*sdl_get_filled_bitmap,*/
+ sdl_register_bitmap,
+ sdl_prepare_strip,
+ sdl_commit_strip,
+ sdl_unregister_bitmap,
+ sdl_draw_bitmap,
+ sdl_draw_bitmaps,
+ sdl_get_color, /* sdl_get_color */
+ sdl_fill_area,
+ sdl_draw_hline,
+ sdl_draw_vline,
+ sdl_hscroll,
+ sdl_vscroll,
+ sdl_set_clip_area,
+ dummy_block,
+ dummy_unblock,
+ sdl_set_title, /* set_title */
+ NULL, /* exec */
+ 0, /* depth (filled in sdl_init_driver function) */
+ 0, 0, /* size (in X is empty) */
+ GD_ONLY_1_WINDOW | GD_NOAUTO, /* flags */
+ 0, /* codepage */
+ NULL /* shell */
+};
+
+
+
+#endif /* GRDRV_SDL */
+
--- a/sdl_data.inc 1970-01-01 01:00:00.000000000 +0100
+++ b/sdl_data.inc 2010-09-25 18:38:37.887567087 +0200
@@ -0,0 +1,276 @@
+/**
+ sdl key syms
+
+ XXX: i'know this is stupit but i'm preparing for some good solution :)
+
+*/
+
+
+#ifndef _SDL_KEYS_INC
+#define _SDL_KEYS_INC
+
+struct t_sdl_keysym
+{
+ unsigned short sym;
+ int key;
+};
+
+/* big mapping SDL->LINKS */
+static struct t_sdl_keysym sdl_keysyms[] =
+{
+ { SDLK_UNKNOWN ,0 },
+ { SDLK_FIRST ,0 },
+ { SDLK_BACKSPACE ,KBD_BS },
+ { SDLK_TAB ,KBD_TAB },
+ { SDLK_CLEAR ,12 },
+ { SDLK_RETURN ,KBD_ENTER },
+ { SDLK_PAUSE ,19 },
+ { SDLK_ESCAPE ,KBD_ESC },
+ { SDLK_SPACE ,32 },
+ { SDLK_EXCLAIM ,33 },
+ { SDLK_QUOTEDBL ,34 },
+ { SDLK_HASH ,35 },
+ { SDLK_DOLLAR ,36 },
+ { SDLK_AMPERSAND ,38 },
+ { SDLK_QUOTE ,39 },
+ { SDLK_LEFTPAREN ,40 },
+ { SDLK_RIGHTPAREN ,41 },
+ { SDLK_ASTERISK ,42 },
+ { SDLK_PLUS ,43 },
+ { SDLK_COMMA ,44 },
+ { SDLK_MINUS ,45 },
+ { SDLK_PERIOD ,46 },
+ { SDLK_SLASH ,47 },
+ { SDLK_0 ,48 },
+ { SDLK_1 ,49 },
+ { SDLK_2 ,50 },
+ { SDLK_3 ,51 },
+ { SDLK_4 ,52 },
+ { SDLK_5 ,53 },
+ { SDLK_6 ,54 },
+ { SDLK_7 ,55 },
+ { SDLK_8 ,56 },
+ { SDLK_9 ,57 },
+ { SDLK_COLON ,58 },
+ { SDLK_SEMICOLON ,59 },
+ { SDLK_LESS ,60 },
+ { SDLK_EQUALS ,61 },
+ { SDLK_GREATER ,62 },
+ { SDLK_QUESTION ,63 },
+ { SDLK_AT ,64 },
+ /*
+ Skip uppercase letters
+ */
+ { SDLK_LEFTBRACKET ,91 },
+ { SDLK_BACKSLASH ,92 },
+ { SDLK_RIGHTBRACKET ,93 },
+ { SDLK_CARET ,94 },
+ { SDLK_UNDERSCORE ,95 },
+ { SDLK_BACKQUOTE ,96 },
+ { SDLK_a ,97 },
+ { SDLK_b ,98 },
+ { SDLK_c ,99 },
+ { SDLK_d ,100 },
+ { SDLK_e ,101 },
+ { SDLK_f ,102 },
+ { SDLK_g ,103 },
+ { SDLK_h ,104 },
+ { SDLK_i ,105 },
+ { SDLK_j ,106 },
+ { SDLK_k ,107 },
+ { SDLK_l ,108 },
+ { SDLK_m ,109 },
+ { SDLK_n ,110 },
+ { SDLK_o ,111 },
+ { SDLK_p ,112 },
+ { SDLK_q ,113 },
+ { SDLK_r ,114 },
+ { SDLK_s ,115 },
+ { SDLK_t ,116 },
+ { SDLK_u ,117 },
+ { SDLK_v ,118 },
+ { SDLK_w ,119 },
+ { SDLK_x ,120 },
+ { SDLK_y ,121 },
+ { SDLK_z ,122 },
+ { SDLK_DELETE ,127 },
+ /* End of ASCII mapped keysyms */
+
+ /* International keyboard syms */
+ { SDLK_WORLD_0 ,160 }, /* 0xA0 */
+ { SDLK_WORLD_1 ,161 },
+ { SDLK_WORLD_2 ,162 },
+ { SDLK_WORLD_3 ,163 },
+ { SDLK_WORLD_4 ,164 },
+ { SDLK_WORLD_5 ,165 },
+ { SDLK_WORLD_6 ,166 },
+ { SDLK_WORLD_7 ,167 },
+ { SDLK_WORLD_8 ,168 },
+ { SDLK_WORLD_9 ,169 },
+ { SDLK_WORLD_10 ,170 },
+ { SDLK_WORLD_11 ,171 },
+ { SDLK_WORLD_12 ,172 },
+ { SDLK_WORLD_13 ,173 },
+ { SDLK_WORLD_14 ,174 },
+ { SDLK_WORLD_15 ,175 },
+ { SDLK_WORLD_16 ,176 },
+ { SDLK_WORLD_17 ,177 },
+ { SDLK_WORLD_18 ,178 },
+ { SDLK_WORLD_19 ,179 },
+ { SDLK_WORLD_20 ,180 },
+ { SDLK_WORLD_21 ,181 },
+ { SDLK_WORLD_22 ,182 },
+ { SDLK_WORLD_23 ,183 },
+ { SDLK_WORLD_24 ,184 },
+ { SDLK_WORLD_25 ,185 },
+ { SDLK_WORLD_26 ,186 },
+ { SDLK_WORLD_27 ,187 },
+ { SDLK_WORLD_28 ,188 },
+ { SDLK_WORLD_29 ,189 },
+ { SDLK_WORLD_30 ,190 },
+ { SDLK_WORLD_31 ,191 },
+ { SDLK_WORLD_32 ,192 },
+ { SDLK_WORLD_33 ,193 },
+ { SDLK_WORLD_34 ,194 },
+ { SDLK_WORLD_35 ,195 },
+ { SDLK_WORLD_36 ,196 },
+ { SDLK_WORLD_37 ,197 },
+ { SDLK_WORLD_38 ,198 },
+ { SDLK_WORLD_39 ,199 },
+ { SDLK_WORLD_40 ,200 },
+ { SDLK_WORLD_41 ,201 },
+ { SDLK_WORLD_42 ,202 },
+ { SDLK_WORLD_43 ,203 },
+ { SDLK_WORLD_44 ,204 },
+ { SDLK_WORLD_45 ,205 },
+ { SDLK_WORLD_46 ,206 },
+ { SDLK_WORLD_47 ,207 },
+ { SDLK_WORLD_48 ,208 },
+ { SDLK_WORLD_49 ,209 },
+ { SDLK_WORLD_50 ,210 },
+ { SDLK_WORLD_51 ,211 },
+ { SDLK_WORLD_52 ,212 },
+ { SDLK_WORLD_53 ,213 },
+ { SDLK_WORLD_54 ,214 },
+ { SDLK_WORLD_55 ,215 },
+ { SDLK_WORLD_56 ,216 },
+ { SDLK_WORLD_57 ,217 },
+ { SDLK_WORLD_58 ,218 },
+ { SDLK_WORLD_59 ,219 },
+ { SDLK_WORLD_60 ,220 },
+ { SDLK_WORLD_61 ,221 },
+ { SDLK_WORLD_62 ,222 },
+ { SDLK_WORLD_63 ,223 },
+ { SDLK_WORLD_64 ,224 },
+ { SDLK_WORLD_65 ,225 },
+ { SDLK_WORLD_66 ,226 },
+ { SDLK_WORLD_67 ,227 },
+ { SDLK_WORLD_68 ,228 },
+ { SDLK_WORLD_69 ,229 },
+ { SDLK_WORLD_70 ,230 },
+ { SDLK_WORLD_71 ,231 },
+ { SDLK_WORLD_72 ,232 },
+ { SDLK_WORLD_73 ,233 },
+ { SDLK_WORLD_74 ,234 },
+ { SDLK_WORLD_75 ,235 },
+ { SDLK_WORLD_76 ,236 },
+ { SDLK_WORLD_77 ,237 },
+ { SDLK_WORLD_78 ,238 },
+ { SDLK_WORLD_79 ,239 },
+ { SDLK_WORLD_80 ,240 },
+ { SDLK_WORLD_81 ,241 },
+ { SDLK_WORLD_82 ,242 },
+ { SDLK_WORLD_83 ,243 },
+ { SDLK_WORLD_84 ,244 },
+ { SDLK_WORLD_85 ,245 },
+ { SDLK_WORLD_86 ,246 },
+ { SDLK_WORLD_87 ,247 },
+ { SDLK_WORLD_88 ,248 },
+ { SDLK_WORLD_89 ,249 },
+ { SDLK_WORLD_90 ,250 },
+ { SDLK_WORLD_91 ,251 },
+ { SDLK_WORLD_92 ,252 },
+ { SDLK_WORLD_93 ,253 },
+ { SDLK_WORLD_94 ,254 },
+ { SDLK_WORLD_95 ,255 }, /* 0xFF */
+
+ /* Numeric keypad */
+ { SDLK_KP0 ,256 },
+ { SDLK_KP1 ,257 },
+ { SDLK_KP2 ,258 },
+ { SDLK_KP3 ,259 },
+ { SDLK_KP4 ,260 },
+ { SDLK_KP5 ,261 },
+ { SDLK_KP6 ,262 },
+ { SDLK_KP7 ,263 },
+ { SDLK_KP8 ,264 },
+ { SDLK_KP9 ,265 },
+ { SDLK_KP_PERIOD ,266 },
+ { SDLK_KP_DIVIDE ,267 },
+ { SDLK_KP_MULTIPLY ,268 },
+ { SDLK_KP_MINUS ,269 },
+ { SDLK_KP_PLUS ,270 },
+ { SDLK_KP_ENTER ,KBD_ENTER },
+ { SDLK_KP_EQUALS ,272 },
+
+ /* Arrows + Home/End pad */
+ { SDLK_UP ,KBD_UP },
+ { SDLK_DOWN ,KBD_DOWN },
+ { SDLK_RIGHT ,KBD_RIGHT },
+ { SDLK_LEFT ,KBD_LEFT },
+ { SDLK_INSERT ,KBD_INS },
+ { SDLK_HOME ,KBD_HOME },
+ { SDLK_END ,KBD_END },
+ { SDLK_PAGEUP ,KBD_PAGE_UP },
+ { SDLK_PAGEDOWN ,KBD_PAGE_DOWN },
+
+ /* Function keys */
+ { SDLK_F1 ,KBD_F1 },
+ { SDLK_F2 ,KBD_F2 },
+ { SDLK_F3 ,KBD_F3 },
+ { SDLK_F4 ,KBD_F4 },
+ { SDLK_F5 ,KBD_F5 },
+ { SDLK_F6 ,KBD_F6 },
+ { SDLK_F7 ,KBD_F7 },
+ { SDLK_F8 ,KBD_F8 },
+ { SDLK_F9 ,KBD_F9 },
+ { SDLK_F10 ,KBD_F10 },
+ { SDLK_F11 ,KBD_F11 },
+ { SDLK_F12 ,KBD_F12 },
+ { SDLK_F13 ,294 },
+ { SDLK_F14 ,295 },
+ { SDLK_F15 ,296 },
+
+ /* Key state modifier keys */
+ { SDLK_NUMLOCK ,300 },
+ { SDLK_CAPSLOCK ,301 },
+ { SDLK_SCROLLOCK ,302 },
+ { SDLK_RSHIFT ,303 },
+ { SDLK_LSHIFT ,304 },
+ { SDLK_RCTRL ,305 },
+ { SDLK_LCTRL ,306 },
+ { SDLK_RALT ,307 },
+ { SDLK_LALT ,308 },
+ { SDLK_RMETA ,309 },
+ { SDLK_LMETA ,310 },
+ { SDLK_LSUPER ,311 }, /* Left "Windows" key */
+ { SDLK_RSUPER ,312 }, /* Right "Windows" key */
+ { SDLK_MODE ,313 }, /* "Alt Gr" key */
+ { SDLK_COMPOSE ,314 }, /* Multi-key compose key */
+
+ /* Miscellaneous function keys */
+ { SDLK_HELP ,315 },
+ { SDLK_PRINT ,316 },
+ { SDLK_SYSREQ ,317 },
+ { SDLK_BREAK ,318 },
+ { SDLK_MENU ,KBD_F9 },
+ { SDLK_POWER ,320 }, /* Power Macintosh power key */
+ { SDLK_EURO ,321 }, /* Some european keyboards */
+ { SDLK_UNDO ,322 }, /* Atari keyboard has Undo */
+
+ /* Add any other keys here */
+
+ { SDLK_LAST ,0 },
+};
+
+#endif
|