SDL2c.patch 149 KB
Newer Older
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 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637
Index: buildings.cpp
===================================================================
--- buildings.cpp	(revision 3442)
+++ buildings.cpp	(working copy)
@@ -277,7 +277,6 @@
 //--------------------------------------------------------------------------
 void cBuilding::draw (SDL_Rect* screenPos, cGameGUI& gameGUI)
 {
-	SDL_Rect dest, tmp;
 	float factor = (float) gameGUI.getTileSize() / 64.0f;
 	cPlayer* activePlayer = gameGUI.getClient()->getActivePlayer();
 	// draw the damage effects
@@ -296,7 +295,7 @@
 		}
 	}
 
-	dest.x = dest.y = 0;
+	SDL_Rect dest = {0, 0, 0, 0};
 	bool bDraw = false;
 	SDL_Surface* drawingSurface = gameGUI.getDCache()->getCachedImage (*this);
 	if (drawingSurface == NULL)
@@ -342,8 +341,8 @@
 	// draw the effect if necessary
 	if (data.powerOnGraphic && cSettings::getInstance().isAnimations() && (IsWorking || !data.canWork))
 	{
-		tmp = dest;
-		SDL_SetAlpha (uiData->eff, SDL_SRCALPHA, EffectAlpha);
+		SDL_Rect tmp = dest;
+		SDL_SetSurfaceAlphaMod (uiData->eff, EffectAlpha);
 
 		CHECK_SCALING (uiData->eff, uiData->eff_org, factor);
 		SDL_BlitSurface (uiData->eff, NULL, buffer, &tmp);
@@ -356,7 +355,7 @@
 
 				if (EffectAlpha > 220)
 				{
-					EffectAlpha = 255;
+					EffectAlpha = 254;
 					EffectInc = false;
 				}
 			}
@@ -376,7 +375,7 @@
 	// draw the mark, when a build order is finished
 	if ( ( (!BuildList.empty() && !IsWorking && BuildList[0].metall_remaining <= 0) || (data.canResearch && owner->researchFinished)) && owner == gameGUI.getClient()->getActivePlayer())
 	{
-		const Uint32 color = 0xFF00 - (0x1000 * (gameGUI.getAnimationSpeed() % 0x8));
+		const Uint32 color = 0xFF00FF00 - (0x1000 * (gameGUI.getAnimationSpeed() % 0x8));
 		const Uint16 max = data.isBig ? 2 * gameGUI.getTileSize() - 3 : gameGUI.getTileSize() - 3;
 		SDL_Rect d = {Sint16 (dest.x + 2), Sint16 (dest.y + 2), max, max};
 
@@ -392,7 +391,7 @@
 	// draw a colored frame if necessary
 	if (gameGUI.colorChecked())
 	{
-		const Uint32 color = *static_cast<Uint32*> (owner->getColorSurface()->pixels);
+		const Uint32 color = 0xFF000000 | *static_cast<Uint32*> (owner->getColorSurface()->pixels);
 		const Uint16 max = data.isBig ? 2 * gameGUI.getTileSize() - 1 : gameGUI.getTileSize() - 1;
 		SDL_Rect d = {Sint16 (dest.x + 1), Sint16 (dest.y + 1), max, max};
 
@@ -406,7 +405,7 @@
 		const int len = max / 4;
 		max -= 3;
 		SDL_Rect d = {Sint16 (dest.x + 2), Sint16 (dest.y + 2), max, max};
-		DrawSelectionCorner(buffer, d, len, gameGUI.getBlinkColor());
+		DrawSelectionCorner(buffer, d, len, 0xFF000000 | gameGUI.getBlinkColor());
 	}
 
 	// draw health bar
@@ -493,9 +492,9 @@
 		CHECK_SCALING (GraphicsData.gfx_big_beton, GraphicsData.gfx_big_beton_org, zoomFactor);
 
 		if (StartUp && cSettings::getInstance().isAlphaEffects())
-			SDL_SetAlpha (GraphicsData.gfx_big_beton, SDL_SRCALPHA, StartUp);
+			SDL_SetSurfaceAlphaMod (GraphicsData.gfx_big_beton, StartUp);
 		else
-			SDL_SetAlpha (GraphicsData.gfx_big_beton, SDL_SRCALPHA, 255);
+			SDL_SetSurfaceAlphaMod (GraphicsData.gfx_big_beton, 254);
 
 		SDL_BlitSurface (GraphicsData.gfx_big_beton, NULL, surface, &tmp);
 	}
@@ -503,12 +502,12 @@
 	{
 		CHECK_SCALING (UnitsData.ptr_small_beton, UnitsData.ptr_small_beton_org, zoomFactor);
 		if (StartUp && cSettings::getInstance().isAlphaEffects())
-			SDL_SetAlpha (UnitsData.ptr_small_beton, SDL_SRCALPHA, StartUp);
+			SDL_SetSurfaceAlphaMod (UnitsData.ptr_small_beton, StartUp);
 		else
-			SDL_SetAlpha (UnitsData.ptr_small_beton, SDL_SRCALPHA, 255);
+			SDL_SetSurfaceAlphaMod (UnitsData.ptr_small_beton, 254);
 
 		SDL_BlitSurface (UnitsData.ptr_small_beton, NULL, surface, &tmp);
-		SDL_SetAlpha (UnitsData.ptr_small_beton, SDL_SRCALPHA, 255);
+		SDL_SetSurfaceAlphaMod (UnitsData.ptr_small_beton, 254);
 	}
 }
 
@@ -531,7 +530,7 @@
 
 	// blit the players color and building graphic
 	if (data.hasPlayerColor) SDL_BlitSurface (owner->getColorSurface(), NULL, GraphicsData.gfx_tmp, NULL);
-	else SDL_FillRect (GraphicsData.gfx_tmp, NULL, 0x00FF00FF);
+	else SDL_FillRect (GraphicsData.gfx_tmp, NULL, 0xFFFF00FF);
 
 	if (data.hasFrames)
 	{
@@ -566,7 +565,7 @@
 	src.x = 0;
 	src.y = 0;
 
-	SDL_SetAlpha (GraphicsData.gfx_tmp, SDL_SRCALPHA, alpha);
+	SDL_SetSurfaceAlphaMod (GraphicsData.gfx_tmp, alpha);
 	SDL_BlitSurface (GraphicsData.gfx_tmp, &src, surface, &tmp);
 }
 
@@ -588,7 +587,6 @@
 	{
 		render_beton (surface, dest, zoomFactor);
 	}
-
 	// draw the connector slots:
 	if ( (this->SubBase && !StartUp) || data.isConnectorGraphic)
 	{
@@ -601,9 +599,9 @@
 	{
 		SDL_Rect tmp = dest;
 		if (StartUp && cSettings::getInstance().isAlphaEffects())
-			SDL_SetAlpha (uiData->shw, SDL_SRCALPHA, StartUp / 5);
+			SDL_SetSurfaceAlphaMod (uiData->shw, StartUp / 5);
 		else
-			SDL_SetAlpha (uiData->shw, SDL_SRCALPHA, 50);
+			SDL_SetSurfaceAlphaMod (uiData->shw, 50);
 
 		CHECK_SCALING (uiData->shw, uiData->shw_org, zoomFactor);
 		blittAlphaSurface (uiData->shw, NULL, surface, &tmp);
@@ -616,7 +614,7 @@
 		frameNr = (gameGUI->getAnimationSpeed() % data.hasFrames);
 	}
 
-	int alpha = 255;
+	int alpha = 254;
 	if (StartUp && cSettings::getInstance().isAlphaEffects()) alpha = StartUp;
 	render_simple (surface, dest, zoomFactor, frameNr, alpha);
 }
@@ -668,7 +666,6 @@
 	}
 	else
 	{
-
 		CHECK_NEIGHBOUR (PosX    , PosY - 1, BaseN)
 		CHECK_NEIGHBOUR (PosX + 1, PosY - 1, BaseBN)
 		CHECK_NEIGHBOUR (PosX + 2, PosY    , BaseE)
@@ -690,8 +687,8 @@
 	CHECK_SCALING (UnitsData.ptr_connector, UnitsData.ptr_connector_org, zoomFactor);
 	CHECK_SCALING (UnitsData.ptr_connector_shw, UnitsData.ptr_connector_shw_org, zoomFactor);
 
-	if (StartUp) SDL_SetAlpha (UnitsData.ptr_connector, SDL_SRCALPHA, StartUp);
-	else SDL_SetAlpha (UnitsData.ptr_connector, SDL_SRCALPHA, 255);
+	if (StartUp) SDL_SetSurfaceAlphaMod (UnitsData.ptr_connector, StartUp);
+	else SDL_SetSurfaceAlphaMod (UnitsData.ptr_connector, 254);
 
 	src.y = 0;
 	src.x = 0;
@@ -1346,6 +1343,7 @@
 	dest.x = x;
 	dest.y = y;
 
+	Uint32 color = SDL_MapRGB (sf->format, 0xFC, 0, 0);
 	for (int i = 0; i < value; i++)
 	{
 		if (i == orgvalue)
@@ -1356,7 +1354,7 @@
 			mark.y = dest.y;
 			mark.w = 1;
 			mark.h = src.h;
-			SDL_FillRect (sf, &mark, 0xFC0000);
+			SDL_FillRect (sf, &mark, color);
 		}
 
 		SDL_BlitSurface (GraphicsData.gfx_hud_stuff, &src, sf, &dest);
Index: buildings.h
===================================================================
--- buildings.h	(revision 3442)
+++ buildings.h	(working copy)
@@ -220,7 +220,7 @@
 	* draws the main image of the building onto the given surface
 	*/
 	void render (const cGameGUI* gameGUI, SDL_Surface* surface, const SDL_Rect& dest, float zoomFactor, bool drawShadow, bool drawConcrete);
-	void render_simple (SDL_Surface* surface, const SDL_Rect& dest, float zoomFactor, int frameNr, int alpha = 255);
+	void render_simple (SDL_Surface* surface, const SDL_Rect& dest, float zoomFactor, int frameNr, int alpha = 254);
 
 	void executeUpdateBuildingCommmand (const cClient& client, bool updateAllOfSameType);
 	void executeSelfDestroyCommand (cClient& client);
Index: client.cpp
===================================================================
--- client.cpp	(revision 3442)
+++ client.cpp	(working copy)
@@ -2005,7 +2005,7 @@
 #endif
 	// reset the screen
 	gameGUI->deselectUnit();
-	SDL_Surface* sf = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, Video.getResolutionX(), Video.getResolutionY(), 32, 0, 0, 0, 0);
+	SDL_Surface* sf = SDL_CreateRGBSurface (0, Video.getResolutionX(), Video.getResolutionY(), 32, 0, 0, 0, 0);
 	SDL_Rect scr = { 15, 356, 112u, 112u};
 	SDL_BlitSurface (sf, NULL, buffer, NULL);
 	SDL_BlitSurface (sf, &scr, buffer, &scr);
Index: defines.h
===================================================================
--- defines.h	(revision 3446)
+++ defines.h	(working copy)
@@ -20,12 +20,12 @@
 #define definesH
 #include "settings.h"
 
-#define GRID_COLOR         0x00305C04 // color of the grid
-#define SCAN_COLOR         0x00E3E300 // color of scan circles
-#define RANGE_GROUND_COLOR 0x00E20000 // color of range circles for ground attack
-#define RANGE_AIR_COLOR    0x00FCA800 // color of range circles for air attack
-#define PFEIL_COLOR        0x000000FF // color of a waypointarrow
-#define PFEILS_COLOR       0x0000FF00 // color of a special waypointarrow
+#define GRID_COLOR         0xFF305C04 // color of the grid
+#define SCAN_COLOR         0xFFE3E300 // color of scan circles
+#define RANGE_GROUND_COLOR 0xFFE20000 // color of range circles for ground attack
+#define RANGE_AIR_COLOR    0xFFFCA800 // color of range circles for air attack
+#define PFEIL_COLOR        0xFF0000FF // color of a waypointarrow
+#define PFEILS_COLOR       0xFF00FF00 // color of a special waypointarrow
 #define MOVE_SPEED 2     // speed of vehiclemovements
 #define MSG_TICKS  30000 // number of ticks for how long a message will be displayed
 #define LANDING_DISTANCE_WARNING   28
@@ -33,7 +33,7 @@
 #define MAX_PLANES_PER_FIELD 5
 
 // minimap configuration
-#define MINIMAP_COLOR 0x00FC0000 // color of the screen borders on the minimap
+#define MINIMAP_COLOR 0xFFFC0000 // color of the screen borders on the minimap
 #define MINIMAP_POS_X 15         // the position of the map on the screen
 #define MINIMAP_POS_Y 356        // the position of the map on the screen
 #define MINIMAP_SIZE  112        // the size of the minimap in pixels
Index: dialog.cpp
===================================================================
--- dialog.cpp	(revision 3442)
+++ dialog.cpp	(working copy)
@@ -71,7 +71,7 @@
 	menuItems.push_back (&noButton);
 }
 
-void cDialogYesNo::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cDialogYesNo::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	switch (key.keysym.sym)
 	{
@@ -106,7 +106,7 @@
 	menuItems.push_back (&okButton);
 }
 
-void cDialogOK::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cDialogOK::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	if (key.keysym.sym == SDLK_RETURN)
 	{
@@ -248,7 +248,7 @@
 	draw();
 }
 
-void cDialogLicence::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cDialogLicence::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	if (key.keysym.sym == SDLK_RETURN)
 	{
@@ -632,13 +632,13 @@
 {
 	const int UNIT_IMAGE_SIZE = 64;
 
-	SDL_Surface* unitImage1 = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_Surface* unitImage1 = SDL_CreateRGBSurface (0, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
 	SDL_FillRect (unitImage1, NULL, 0xFF00FF);
-	SDL_SetColorKey (unitImage1, SDL_SRCCOLORKEY, 0xFF00FF);
+	SDL_SetColorKey (unitImage1, SDL_TRUE, 0xFF00FF);
 
-	SDL_Surface* unitImage2 = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_Surface* unitImage2 = SDL_CreateRGBSurface (0, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
 	SDL_FillRect (unitImage2, NULL, 0xFF00FF);
-	SDL_SetColorKey (unitImage2, SDL_SRCCOLORKEY, 0xFF00FF);
+	SDL_SetColorKey (unitImage2, SDL_TRUE, 0xFF00FF);
 
 	SDL_Rect dest = {0, 0, 0, 0};
 
@@ -777,7 +777,7 @@
 		// little hack: flip part of the image that represent the arrow
 		const unsigned int w = 40;
 		const unsigned int h = 20;
-		SDL_Surface* arrowSurface = SDL_CreateRGBSurface (Video.getSurfaceType(), w, h, Video.getColDepth(), 0, 0, 0, 0);
+		SDL_Surface* arrowSurface = SDL_CreateRGBSurface (0, w, h, Video.getColDepth(), 0, 0, 0, 0);
 		const Sint16 x = arrowImage.getPosition().x - position.x; // 140
 		const Sint16 y = arrowImage.getPosition().y - position.y; //  77
 		SDL_Rect src = {x, y, w, h};
@@ -791,7 +791,7 @@
 	resBar->setCurrentValue ( (int) (223.f * (destCargo + transferValue) / maxDestCargo));
 }
 
-void cDialogTransfer::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cDialogTransfer::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	switch (key.keysym.sym)
 	{
@@ -994,7 +994,7 @@
 	}
 }
 
-void cDialogResearch::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cDialogResearch::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	switch (key.keysym.sym)
 	{
Index: dialog.h
===================================================================
--- dialog.h	(revision 3442)
+++ dialog.h	(working copy)
@@ -32,7 +32,7 @@
 	explicit cDialogYesNo (const std::string& text);
 
 private:
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 
 private:
 	cMenuLabel textLabel;
@@ -49,7 +49,7 @@
 	explicit cDialogOK (const std::string& text);
 
 private:
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 
 private:
 	cMenuLabel textLabel;
@@ -80,7 +80,7 @@
 	cDialogLicence();
 
 private:
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 
 private:
 	static void upReleased (void* parent);
@@ -201,7 +201,7 @@
 	~cDialogTransfer();
 
 private:
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 	virtual void handleDestroyUnit (cUnit& destroyedUnit);
 
 private:
@@ -244,7 +244,7 @@
 	explicit cDialogResearch (cClient& client_);
 
 private:
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 	virtual void handleDestroyUnit (cUnit& destroyedUnit);
 
 private:
Index: drawingcache.cpp
===================================================================
--- drawingcache.cpp	(revision 3442)
+++ drawingcache.cpp	(working copy)
@@ -77,10 +77,10 @@
 		width  = 130;
 		height = 130;
 	}
-	surface = SDL_CreateRGBSurface (SDL_SWSURFACE, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
+	surface = SDL_CreateRGBSurface (0, width, height, 32,
+									0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
 
-	SDL_FillRect (surface, NULL, SDL_MapRGBA (surface->format, 255, 0, 255, 0));
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGBA (surface->format, 255, 0, 255, 0));
+	SDL_FillRect (surface, NULL, SDL_MapRGBA (surface->format, 0, 0, 0, 0));
 }
 
 void sDrawingCacheEntry::init (const cGameGUI& gameGUI, const cBuilding& building)
@@ -106,10 +106,10 @@
 	int width  = (int) std::max (building.uiData->img_org->w * zoom, building.uiData->shw_org->w * zoom);
 	if (building.data.hasFrames) width = (int) (building.uiData->shw_org->w * zoom);
 
-	surface = SDL_CreateRGBSurface (SDL_SWSURFACE, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
+	surface = SDL_CreateRGBSurface (0, width, height, 32,
+									0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
 
-	SDL_FillRect (surface, NULL, SDL_MapRGBA (surface->format, 255, 0, 255, 0));
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGBA (surface->format, 255, 0, 255, 0));
+	SDL_FillRect (surface, NULL, SDL_MapRGBA (surface->format, 0, 0, 0, 0));
 }
 
 cDrawingCache::cDrawingCache()
@@ -346,7 +346,7 @@
 		return false;
 	}
 
-	if (vehicle.IsBuilding && vehicle.data.isBig && vehicle.BigBetonAlpha < 255)
+	if (vehicle.IsBuilding && vehicle.data.isBig && vehicle.BigBetonAlpha < 254u)
 	{
 		notCached++;
 		return false;
Index: events.cpp
===================================================================
--- events.cpp	(revision 3442)
+++ events.cpp	(working copy)
@@ -60,17 +60,6 @@
 	return screenshotfile;
 }
 
-static void HandleInputEvent_SDL_ACTIVEEVENT (SDL_Event& event)
-{
-	assert (event.type == SDL_ACTIVEEVENT);
-#if 1
-	// This is an workaround for a SDL bug.
-	// See Ticket #86 on bugtracker.
-	// will hopefully not be required anymore in SDL 1.3
-	if (event.active.state & SDL_APPINPUTFOCUS) SDL_SetModState (KMOD_NONE);
-#endif
-}
-
 static void HandleInputEvent_KEY (cMenu& activeMenu, SDL_Event& event, cClient* client)
 {
 	assert (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP);
@@ -96,12 +85,14 @@
 {
 	switch (event.type)
 	{
-		case SDL_ACTIVEEVENT: HandleInputEvent_SDL_ACTIVEEVENT (event); break;
 		case SDL_KEYDOWN:
 		case SDL_KEYUP: HandleInputEvent_KEY (activeMenu, event, client); break;
 		case SDL_MOUSEBUTTONDOWN:
 		case SDL_MOUSEBUTTONUP: InputHandler->inputMouseButton (activeMenu, event.button); break;
+		case SDL_MOUSEWHEEL: InputHandler->inputMouseButton (activeMenu, event.wheel); break;
 		case SDL_QUIT: Quit(); break;
+		case SDL_MOUSEMOTION: break;
+		case SDL_WINDOWEVENT: Video.draw(); break;
 		default: break;
 	}
 }
Index: fxeffects.cpp
===================================================================
--- fxeffects.cpp	(revision 3442)
+++ fxeffects.cpp	(working copy)
@@ -293,7 +293,7 @@
 	CHECK_SCALING (images[1], images[0], gameGUI.getZoom());
 
 	const int alpha = (alphaEnd - alphaStart) * tick / length + alphaStart;
-	SDL_SetAlpha (images[1], SDL_SRCALPHA, alpha);
+	SDL_SetSurfaceAlphaMod (images[1], alpha);
 
 	SDL_Rect dest;
 	dest = gameGUI.calcScreenPos (posX - images[0]->w / 2, posY - images[0]->h / 2);
@@ -338,7 +338,7 @@
 	CHECK_SCALING (images[1], images[0], gameGUI.getZoom());
 
 	const int alpha = (alphaEnd - alphaStart) * tick / length + alphaStart;
-	SDL_SetAlpha (images[1], SDL_SRCALPHA, alpha);
+	SDL_SetSurfaceAlphaMod (images[1], alpha);
 
 	SDL_Rect src, dest;
 	src.y = 0;
@@ -473,6 +473,6 @@
 	dest = gameGUI.calcScreenPos ( (int) (posX + tick * dx), (int) (posY + tick * dy));
 
 	const int alpha = (alphaEnd - alphaStart) * tick / length + alphaStart;
-	SDL_SetAlpha (images[1], SDL_SRCALPHA, alpha);
+	SDL_SetSurfaceAlphaMod (images[1], alpha);
 	SDL_BlitSurface (images[1], &src, buffer, &dest);
 }
Index: hud.cpp
===================================================================
--- hud.cpp	(revision 3442)
+++ hud.cpp	(working copy)
@@ -151,7 +151,7 @@
 				string sTmpLine = " " + playerList[i]->getName() + ", nr: " + iToStr (playerList[i]->getNr()) + " << you! ";
 				// black out background for better recognizing
 				rBlackOut.w = font->getTextWide (sTmpLine, FONT_LATIN_SMALL_WHITE);
-				SDL_FillRect (buffer, &rBlackOut, 0x00000000);
+				SDL_FillRect (buffer, &rBlackOut, 0xFF000000);
 				font->showText (rBlackOut.x, debugOff + 1, sTmpLine, FONT_LATIN_SMALL_WHITE);
 			}
 			else
@@ -159,7 +159,7 @@
 				string sTmpLine = " " + playerList[i]->getName() + ", nr: " + iToStr (playerList[i]->getNr()) + " ";
 				// black out background for better recognizing
 				rBlackOut.w = font->getTextWide (sTmpLine, FONT_LATIN_SMALL_WHITE);
-				SDL_FillRect (buffer, &rBlackOut, 0x00000000);
+				SDL_FillRect (buffer, &rBlackOut, 0xFF000000);
 				font->showText (rBlackOut.x, debugOff + 1, sTmpLine, FONT_LATIN_SMALL_WHITE);
 			}
 			// use 10 for pixel high of dots instead of text high
@@ -823,8 +823,6 @@
 
 int cGameGUI::show (cClient* client)
 {
-	drawnEveryFrame = true;
-
 	// do startup actions
 	openPanel();
 	startup = true;
@@ -838,7 +836,7 @@
 		cEventHandling::handleInputEvents (*this, client);
 		client->gameTimer.run (this);
 
-		mouse->GetPos();
+		mouse->updatePos();
 		if (mouse->moved())
 		{
 			handleMouseMove();
@@ -1021,10 +1019,10 @@
 
 SDL_Surface* cGameGUI::generateSurface()
 {
-	SDL_Surface* surface = SDL_CreateRGBSurface (SDL_HWSURFACE, Video.getResolutionX(), Video.getResolutionY(), Video.getColDepth(), 0, 0, 0, 0);
+	SDL_Surface* surface = SDL_CreateRGBSurface (0, Video.getResolutionX(), Video.getResolutionY(), Video.getColDepth(), 0, 0, 0, 0);
 
 	SDL_FillRect (surface, NULL, 0x00FF00FF);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0x00FF00FF);
+	SDL_SetColorKey (surface, SDL_TRUE, 0x00FF00FF);
 
 	const std::string gfxPath = cSettings::getInstance().getGfxPath() + PATH_DELIMITER;
 	{
@@ -1260,7 +1258,7 @@
 
 SDL_Surface* cGameGUI::generateMiniMapSurface()
 {
-	SDL_Surface* minimapSurface = SDL_CreateRGBSurface (SDL_SWSURFACE, MINIMAP_SIZE, MINIMAP_SIZE, 32, 0, 0, 0, 0);
+	SDL_Surface* minimapSurface = SDL_CreateRGBSurface (0, MINIMAP_SIZE, MINIMAP_SIZE, 32, 0, 0, 0, 0);
 
 	// set zoom factor
 	const int displayedMapWidth = (int) ( (Video.getResolutionX() - HUD_TOTAL_WIDTH) / getZoom());
@@ -2940,7 +2938,7 @@
 	return true;
 }
 
-void cGameGUI::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cGameGUI::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	if (key.keysym.sym == SDLK_LSHIFT || key.keysym.sym == SDLK_RSHIFT)
 	{
@@ -2981,7 +2979,7 @@
 		cDialogYesNo yesNoDialog (lngPack.i18n ("Text~Comp~End_Game"));
 		if (yesNoDialog.show (client) == 0) end = true;
 	}
-	else if (activeItem && !activeItem->isDisabled() && activeItem->handleKeyInput (key.keysym, ch, this))
+	else if (activeItem && !activeItem->isDisabled() && activeItem->handleKeyInput (key.keysym, this))
 	{}
 	else if (key.keysym.sym == KeysList.KeyJumpToAction)
 	{
@@ -3970,7 +3968,7 @@
 	const int mouseTopY = static_cast<int> (min (mouseBox.startY, mouseBox.endY) * getTileSize());
 	const int mouseBottomX = static_cast<int> (max (mouseBox.startX, mouseBox.endX) * getTileSize());
 	const int mouseBottomY = static_cast<int> (max (mouseBox.startY, mouseBox.endY) * getTileSize());
-	const Uint32 color = 0x00FFFF00;
+	const Uint32 color = 0xFFFFFF00;
 	SDL_Rect d;
 
 	d.x = mouseTopX - zoomOffX + HUD_LEFT_WIDTH;
@@ -4115,7 +4113,6 @@
 	while (top.y > -479)
 	{
 		Video.draw();
-		mouse->draw (false, screen);
 		SDL_Delay (10);
 		top.y -= 10;
 		bottom.y += 10;
@@ -4134,7 +4131,6 @@
 	while (bottom.y > Video.getResolutionY() / 2)
 	{
 		Video.draw();
-		mouse->draw (false, screen);
 		SDL_Delay (10);
 		top.y += 10;
 		if (top.y > (Video.getResolutionY() / 2) - 479 - 9) top.y = (Video.getResolutionY() / 2) - 479;
@@ -4147,7 +4143,6 @@
 		SDL_BlitSurface (GraphicsData.gfx_panel_bottom, NULL, buffer, &tmp);
 	}
 	Video.draw();
-	mouse->draw (false, screen);
 	SDL_Delay (100);
 }
 
@@ -5209,14 +5204,14 @@
 	r2.w = (int) ( ( (float) (r1.w - 2) / unit.data.ammoMax) * unit.data.ammoCur);
 	r2.h = r1.h - 2;
 
-	SDL_FillRect (buffer, &r1, 0);
+	SDL_FillRect (buffer, &r1, 0xFF000000);
 
 	if (unit.data.ammoCur > unit.data.ammoMax / 2)
-		SDL_FillRect (buffer, &r2, 0x0004AE04);
+		SDL_FillRect (buffer, &r2, 0xFF04AE04);
 	else if (unit.data.ammoCur > unit.data.ammoMax / 4)
-		SDL_FillRect (buffer, &r2, 0x00DBDE00);
+		SDL_FillRect (buffer, &r2, 0xFFDBDE00);
 	else
-		SDL_FillRect (buffer, &r2, 0x00E60000);
+		SDL_FillRect (buffer, &r2, 0xFFE60000);
 }
 
 //------------------------------------------------------------------------------
@@ -5245,15 +5240,15 @@
 	r2.w = (int) ( ( (float) (r1.w - 2) / unit.data.hitpointsMax) * unit.data.hitpointsCur);
 	r2.h = r1.h - 2;
 
-	SDL_FillRect (buffer, &r1, 0);
+	SDL_FillRect (buffer, &r1, 0xFF000000);
 
 	Uint32 color;
 	if (unit.data.hitpointsCur > unit.data.hitpointsMax / 2)
-		color = 0x0004AE04; // green
+		color = 0xFF04AE04; // green
 	else if (unit.data.hitpointsCur > unit.data.hitpointsMax / 4)
-		color = 0x00DBDE00; // orange
+		color = 0xFFDBDE00; // orange
 	else
-		color = 0x00E60000; // red
+		color = 0xFFE60000; // red
 	SDL_FillRect (buffer, &r2, color);
 }
 
Index: hud.h
===================================================================
--- hud.h	(revision 3442)
+++ hud.h	(working copy)
@@ -466,7 +466,7 @@
 
 	void updateInfoTexts();
 
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 
 	const cClient* getClient() const { return client; }
 	cClient* getClient() { return client; }
Index: input.cpp
===================================================================
--- input.cpp	(revision 3450)
+++ input.cpp	(working copy)
@@ -35,13 +35,15 @@
 cInput::cInput() :
 	LastClickTicks (0)
 {
+#if 0 // TODO: [SDL2]: setting for repeat key ?
 	// enables that SDL puts the unicode values to the keyevents.
 	SDL_EnableUNICODE (1);
 	// enables keyrepetition
 	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+#endif
 }
 
-void cInput::inputkey (cMenu& activeMenu, SDL_KeyboardEvent& key)
+void cInput::inputkey (cMenu& activeMenu, const SDL_KeyboardEvent& key)
 {
 	// give the key to the active menu
 	// But do not send events to a menu,
@@ -50,7 +52,7 @@
 	// after clicking the exit button
 	if (!activeMenu.exiting())
 	{
-		activeMenu.handleKeyInput (key, getUTF16Char (key.keysym.unicode));
+		activeMenu.handleKeyInput (key);
 	}
 }
 
@@ -86,8 +88,7 @@
 	}
 }
 
-
-void cInput::inputMouseButton (cMenu& activeMenu, SDL_MouseButtonEvent& button)
+void cInput::inputMouseButton (cMenu& activeMenu, const SDL_MouseButtonEvent& button)
 {
 	MouseState.x = button.x;
 	MouseState.y = button.y;
@@ -106,27 +107,7 @@
 			MouseState.rightButtonReleased = false;
 			MouseState.leftButtonReleased = false;
 		}
-		else if (button.button == SDL_BUTTON_WHEELUP)
-		{
-			MouseState.wheelUp = true;
-			MouseState.leftButtonReleased = false;
-			MouseState.rightButtonReleased = false;
-		}
-		else if (button.button == SDL_BUTTON_WHEELDOWN)
-		{
-			MouseState.wheelDown = true;
-			MouseState.leftButtonReleased = false;
-			MouseState.rightButtonReleased = false;
-		}
-
-		if (IsDoubleClicked())
-		{
-			MouseState.isDoubleClick = true;
-		}
-		else
-		{
-			MouseState.isDoubleClick = false;
-		}
+		MouseState.isDoubleClick = IsDoubleClicked();
 	}
 	else if (button.state == SDL_RELEASED)
 	{
@@ -142,8 +123,6 @@
 			MouseState.rightButtonReleased = true;
 			MouseState.leftButtonReleased = false;
 		}
-		else if (button.button == SDL_BUTTON_WHEELUP) MouseState.wheelUp = false;
-		else if (button.button == SDL_BUTTON_WHEELDOWN) MouseState.wheelDown = false;
 	}
 
 	// do not send events to a menu, after an event triggered the termination
@@ -155,6 +134,24 @@
 	}
 }
 
+void cInput::inputMouseButton (cMenu& activeMenu, const SDL_MouseWheelEvent& wheel)
+{
+	MouseState.wheelUp = false;
+	MouseState.wheelDown = false;
+	if (wheel.y > 0)
+	{
+		MouseState.wheelUp = true;
+		MouseState.leftButtonReleased = false;
+		MouseState.rightButtonReleased = false;
+	}
+	else if (wheel.y < 0)
+	{
+		MouseState.wheelDown = true;
+		MouseState.leftButtonReleased = false;
+		MouseState.rightButtonReleased = false;
+	}
+}
+
 std::string cInput::getUTF16Char (Uint16 ch)
 {
 	// convert from UTF-16 to UTF-8
Index: input.h
===================================================================
--- input.h	(revision 3442)
+++ input.h	(working copy)
@@ -45,14 +45,8 @@
 class cInput
 {
 private:
+	sMouseState MouseState;
 
-	sMouseState MouseState;
-	/**
-	 * Decodes the character from UTF-16 to UTF-8 and adds him to the input string.
-	 * @author alzi alias DoctorDeath
-	 * @param ch character which is to be added.
-	 */
-	std::string getUTF16Char (Uint16 ch);
 public:
 	cInput();
 	/**
@@ -60,13 +54,22 @@
 	 * If input is active the character will be added to the inpput string,
 	 * else the information will be given to the client to handle hotkeys.
 	 * @author alzi alias DoctorDeath
-	 * @param keysym SDL_keysym with pressed key information.
+	 * @param keysym SDL_Keysym with pressed key information.
 	 */
-	void inputkey (cMenu& activeMenu, SDL_KeyboardEvent& key);
+	void inputkey (cMenu& activeMenu, const SDL_KeyboardEvent& key);
 
 	long LastClickTicks;
-	void inputMouseButton (cMenu& avtiveMenu, SDL_MouseButtonEvent& button);
+	void inputMouseButton (cMenu& avtiveMenu, const SDL_MouseButtonEvent& button);
+	void inputMouseButton (cMenu& activeMenu, const SDL_MouseWheelEvent& wheel);
 	bool IsDoubleClicked();
+
+public:
+	/**
+	 * Decodes the character from UTF-16 to UTF-8 and adds him to the input string.
+	 * @author alzi alias DoctorDeath
+	 * @param ch character which is to be added.
+	 */
+	static std::string getUTF16Char (Uint16 ch);
 };
 
 EX cInput* InputHandler;
Index: keys.cpp
===================================================================
--- keys.cpp	(revision 3442)
+++ keys.cpp	(working copy)
@@ -139,6 +139,16 @@
 	return 1;
 }
 
+#if 0 // TODO: [SDL2]: obsolete keys... use scancode ?
+SDLK_KP0;SDLK_KP1;SDLK_KP2;SDLK_KP3;SDLK_KP4;
+SDLK_KP5;SDLK_KP6;SDLK_KP7;SDLK_KP8;SDLK_KP9;
+SDLK_NUMLOCK;SDLK_SCROLLOCK;
+SDLK_RMETA;SDLK_LMETA;
+SDLK_LSUPER;SDLK_RSUPER;
+SDLK_COMPOSE;SDLK_PRINT;SDLK_BREAK;SDLK_EURO;
+#endif
+
+
 // Liefert einen String mit dem Namen der Taste zurueck:
 const char* GetKeyString (SDLKey key)
 {
@@ -216,16 +226,6 @@
 		case SDLK_y: return "Y";
 		case SDLK_z: return "Z";
 		case SDLK_DELETE: return "DELETE";
-		case SDLK_KP0: return "KP0";
-		case SDLK_KP1: return "KP1";
-		case SDLK_KP2: return "KP2";
-		case SDLK_KP3: return "KP3";
-		case SDLK_KP4: return "KP4";
-		case SDLK_KP5: return "KP5";
-		case SDLK_KP6: return "KP6";
-		case SDLK_KP7: return "KP7";
-		case SDLK_KP8: return "KP8";
-		case SDLK_KP9: return "KP9";
 		case SDLK_KP_PERIOD: return "KP_PERIOD";
 		case SDLK_KP_DIVIDE: return "KP_DIVIDE";
 		case SDLK_KP_MULTIPLY: return "KP_MULTIPLY";
@@ -257,9 +257,7 @@
 		case SDLK_F13: return "F13";
 		case SDLK_F14: return "F14";
 		case SDLK_F15: return "F15";
-		case SDLK_NUMLOCK: return "NUMLOCK";
 		case SDLK_CAPSLOCK: return "CAPSLOCK";
-		case SDLK_SCROLLOCK: return "SCROLLOCK";
 		case SDLK_RSHIFT: return "RSHIFT";
 		case SDLK_LSHIFT: return "LSHIFT";
 		case SDLK_RCTRL: return "RCTRL";
@@ -266,19 +264,11 @@
 		case SDLK_LCTRL: return "LCTRL";
 		case SDLK_RALT: return "RALT";
 		case SDLK_LALT: return "LALT";
-		case SDLK_RMETA: return "RMETA";
-		case SDLK_LMETA: return "LMETA";
-		case SDLK_LSUPER: return "LSUPER";
-		case SDLK_RSUPER: return "RSUPER";
 		case SDLK_MODE: return "MODE";
-		case SDLK_COMPOSE: return "COMPOSE";
 		case SDLK_HELP: return "HELP";
-		case SDLK_PRINT: return "PRINT";
 		case SDLK_SYSREQ: return "SYSREQ";
-		case SDLK_BREAK: return "BREAK";
 		case SDLK_MENU: return "MENU";
 		case SDLK_POWER: return "POWER";
-		case SDLK_EURO: return "EURO";
 		case SDLK_UNDO: return "UNDO";
 		default: return "?";
 	}
@@ -359,16 +349,6 @@
 	if (!key.compare ("Y")) return SDLK_y;
 	if (!key.compare ("Z")) return SDLK_z;
 	if (!key.compare ("DELETE")) return SDLK_DELETE;
-	if (!key.compare ("KP0")) return SDLK_KP0;
-	if (!key.compare ("KP1")) return SDLK_KP1;
-	if (!key.compare ("KP2")) return SDLK_KP2;
-	if (!key.compare ("KP3")) return SDLK_KP3;
-	if (!key.compare ("KP4")) return SDLK_KP4;
-	if (!key.compare ("KP5")) return SDLK_KP5;
-	if (!key.compare ("KP6")) return SDLK_KP6;
-	if (!key.compare ("KP7")) return SDLK_KP7;
-	if (!key.compare ("KP8")) return SDLK_KP8;
-	if (!key.compare ("KP9")) return SDLK_KP9;
 	if (!key.compare ("KP_PERIOD")) return SDLK_KP_PERIOD;
 	if (!key.compare ("KP_DIVIDE")) return SDLK_KP_DIVIDE;
 	if (!key.compare ("KP_MULTIPLY")) return SDLK_KP_MULTIPLY;
@@ -400,9 +380,7 @@
 	if (!key.compare ("F13")) return SDLK_F13;
 	if (!key.compare ("F14")) return SDLK_F14;
 	if (!key.compare ("F15")) return SDLK_F15;
-	if (!key.compare ("NUMLOCK")) return SDLK_NUMLOCK;
 	if (!key.compare ("CAPSLOCK")) return SDLK_CAPSLOCK;
-	if (!key.compare ("SCROLLOCK")) return SDLK_SCROLLOCK;
 	if (!key.compare ("RSHIFT")) return SDLK_RSHIFT;
 	if (!key.compare ("LSHIFT")) return SDLK_LSHIFT;
 	if (!key.compare ("RCTRL")) return SDLK_RCTRL;
@@ -409,19 +387,11 @@
 	if (!key.compare ("LCTRL")) return SDLK_LCTRL;
 	if (!key.compare ("RALT")) return SDLK_RALT;
 	if (!key.compare ("LALT")) return SDLK_LALT;
-	if (!key.compare ("RMETA")) return SDLK_RMETA;
-	if (!key.compare ("LMETA")) return SDLK_LMETA;
-	if (!key.compare ("LSUPER")) return SDLK_LSUPER;
-	if (!key.compare ("RSUPER")) return SDLK_RSUPER;
 	if (!key.compare ("MODE")) return SDLK_MODE;
-	if (!key.compare ("COMPOSE")) return SDLK_COMPOSE;
 	if (!key.compare ("HELP")) return SDLK_HELP;
-	if (!key.compare ("PRINT")) return SDLK_PRINT;
 	if (!key.compare ("SYSREQ")) return SDLK_SYSREQ;
-	if (!key.compare ("BREAK")) return SDLK_BREAK;
 	if (!key.compare ("MENU")) return SDLK_MENU;
 	if (!key.compare ("POWER")) return SDLK_POWER;
-	if (!key.compare ("EURO")) return SDLK_EURO;
 	if (!key.compare ("UNDO")) return SDLK_UNDO;
 	return SDLK_UNKNOWN;
 }
Index: keys.h
===================================================================
--- keys.h	(revision 3442)
+++ keys.h	(working copy)
@@ -22,6 +22,10 @@
 #include <string>
 #include "defines.h"
 
+#if 1 // TODO [SDL2]: use scancode or keycode ?
+typedef SDL_Keycode SDLKey;
+#endif
+
 // Globale Daten /////////////////////////////////////////////////////////////
 class cKeysList
 {
Index: loaddata.cpp
===================================================================
--- loaddata.cpp	(revision 3442)
+++ loaddata.cpp	(working copy)
@@ -357,12 +357,12 @@
 			if (pos == 0)   //need full line for first entry version information
 			{
 				SDL_BlitSurface (buffer, NULL, screen, NULL);
-				SDL_UpdateRect (screen, rDest.x, rDest.y + rDest.h * pos, rDest.w + rDest2.w, rDest.h);
+				Video.draw();
 			}
 			else
 			{
 				SDL_BlitSurface (buffer, &rSrc, screen, &rSrc);
-				SDL_UpdateRect (screen, rDest.x, rDest.y + rDest.h * pos, rDest.w, rDest.h);
+				Video.draw();
 			}
 			break;
 
@@ -380,7 +380,7 @@
 		rSrc = rDest2;
 		rSrc.y = rDest2.y + rDest2.h * pos;
 		SDL_BlitSurface (buffer, &rSrc, screen, &rSrc);
-		SDL_UpdateRect (screen, rDest2.x, rDest2.y + rDest2.h * pos, rDest2.w, rDest2.h);
+		Video.draw();
 	}
 }
 
@@ -474,8 +474,8 @@
 
 	dest[0] = LoadPCX (filepath);
 	dest[1] = CloneSDLSurface (dest[0]);
-	SDL_SetAlpha (dest[0], SDL_SRCALPHA, alpha);
-	SDL_SetAlpha (dest[1], SDL_SRCALPHA, alpha);
+	SDL_SetSurfaceAlphaMod (dest[0], alpha);
+	SDL_SetSurfaceAlphaMod (dest[1], alpha);
 
 	filepath.insert (0, "Effectalpha loaded: ");
 	Log.write (filepath.c_str(), LOG_TYPE_DEBUG);
@@ -607,7 +607,7 @@
 	LoadEffectGraphicToSurface (fx_rocket, path, "rocket.pcx");
 	LoadEffectAlphaToSurface (fx_dark_smoke, path, "dark_smoke.pcx", 100);
 	LoadEffectAlphaToSurface (fx_tracks, path, "tracks.pcx", 100);
-	LoadEffectAlphaToSurface (fx_corpse, path, "corpse.pcx", 255);
+	LoadEffectAlphaToSurface (fx_corpse, path, "corpse.pcx", 254);
 	LoadEffectAlphaToSurface (fx_absorb, path, "absorb.pcx", 150);
 }
 
@@ -855,17 +855,17 @@
 
 	Log.write ("Shadowgraphics...", LOG_TYPE_DEBUG);
 	// Shadow:
-	GraphicsData.gfx_shadow = SDL_CreateRGBSurface (Video.getSurfaceType(), Video.getResolutionX(),
-													Video.getResolutionY(), Video.getColDepth(), 0, 0, 0, 0);
+	GraphicsData.gfx_shadow = SDL_CreateRGBSurface (0, Video.getResolutionX(), Video.getResolutionY(),
+													Video.getColDepth(), 0, 0, 0, 0);
 	SDL_FillRect (GraphicsData.gfx_shadow, NULL, 0x0);
-	SDL_SetAlpha (GraphicsData.gfx_shadow, SDL_SRCALPHA, 50);
-	GraphicsData.gfx_tmp = SDL_CreateRGBSurface (Video.getSurfaceType(), 128, 128, Video.getColDepth(), 0, 0, 0, 0);
-	SDL_SetColorKey (GraphicsData.gfx_tmp, SDL_SRCCOLORKEY, 0xFF00FF);
+	SDL_SetSurfaceAlphaMod (GraphicsData.gfx_shadow, 50);
+	GraphicsData.gfx_tmp = SDL_CreateRGBSurface (0, 128, 128, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_SetColorKey (GraphicsData.gfx_tmp, SDL_TRUE, 0xFF00FF);
 
 	// Glas:
 	Log.write ("Glassgraphic...", LOG_TYPE_DEBUG);
 	LoadGraphicToSurface (GraphicsData.gfx_destruction_glas, path, "destruction_glas.pcx");
-	SDL_SetAlpha (GraphicsData.gfx_destruction_glas, SDL_SRCALPHA, 150);
+	SDL_SetSurfaceAlphaMod (GraphicsData.gfx_destruction_glas, 150);
 
 	// Waypoints:
 	Log.write ("Waypointgraphics...", LOG_TYPE_DEBUG);
@@ -922,7 +922,7 @@
 	if (LoadGraphicToSurface (res_metal_org, path, "res.pcx") == 1)
 	{
 		res_metal = CloneSDLSurface (res_metal_org);
-		SDL_SetColorKey (res_metal, SDL_SRCCOLORKEY, 0xFF00FF);
+		SDL_SetColorKey (res_metal, SDL_TRUE, 0xFF00FF);
 	}
 
 	// gold
@@ -929,7 +929,7 @@
 	if (LoadGraphicToSurface (res_gold_org, path, "gold.pcx") == 1)
 	{
 		res_gold = CloneSDLSurface (res_gold_org);
-		SDL_SetColorKey (res_gold, SDL_SRCCOLORKEY, 0xFF00FF);
+		SDL_SetColorKey (res_gold, SDL_TRUE, 0xFF00FF);
 	}
 
 	// fuel
@@ -936,7 +936,7 @@
 	if (LoadGraphicToSurface (res_oil_org, path, "fuel.pcx") == 1)
 	{
 		res_oil = CloneSDLSurface (res_oil_org);
-		SDL_SetColorKey (res_oil, SDL_SRCCOLORKEY, 0xFF00FF);
+		SDL_SetColorKey (res_oil, SDL_TRUE, 0xFF00FF);
 	}
 }
 
@@ -1040,8 +1040,8 @@
 			SDL_Rect rcDest;
 			for (int n = 0; n < 8; n++)
 			{
-				ui.img[n] = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
-				SDL_SetColorKey (ui.img[n], SDL_SRCCOLORKEY, 0x00FFFFFF);
+				ui.img[n] = SDL_CreateRGBSurface (0, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
+				SDL_SetColorKey (ui.img[n], SDL_TRUE, 0x00FFFFFF);
 				SDL_FillRect (ui.img[n], NULL, 0x00FF00FF);
 
 				for (int j = 0; j < 13; j++)
@@ -1066,16 +1066,16 @@
 						}
 					}
 				}
-				ui.img_org[n] = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
-				SDL_SetColorKey (ui.img[n], SDL_SRCCOLORKEY, 0x00FFFFFF);
+				ui.img_org[n] = SDL_CreateRGBSurface (0, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
+				SDL_SetColorKey (ui.img[n], SDL_TRUE, 0x00FFFFFF);
 				SDL_FillRect (ui.img_org[n], NULL, 0x00FFFFFF);
 				SDL_BlitSurface (ui.img[n], NULL, ui.img_org[n], NULL);
 
-				ui.shw[n] = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
-				SDL_SetColorKey (ui.shw[n], SDL_SRCCOLORKEY, 0x00FF00FF);
+				ui.shw[n] = SDL_CreateRGBSurface (0, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
+				SDL_SetColorKey (ui.shw[n], SDL_TRUE, 0x00FF00FF);
 				SDL_FillRect (ui.shw[n], NULL, 0x00FF00FF);
-				ui.shw_org[n] = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
-				SDL_SetColorKey (ui.shw_org[n], SDL_SRCCOLORKEY, 0x00FF00FF);
+				ui.shw_org[n] = SDL_CreateRGBSurface (0, 64 * 13, 64, Video.getColDepth(), 0, 0, 0, 0);
+				SDL_SetColorKey (ui.shw_org[n], SDL_TRUE, 0x00FF00FF);
 				SDL_FillRect (ui.shw_org[n], NULL, 0x00FF00FF);
 
 				rcDest.x = 3;
@@ -1091,8 +1091,8 @@
 				}
 				SDL_UnlockSurface (ui.shw_org[n]);
 				SDL_BlitSurface (ui.shw_org[n], NULL, ui.shw[n], NULL);
-				SDL_SetAlpha (ui.shw_org[n], SDL_SRCALPHA, 50);
-				SDL_SetAlpha (ui.shw[n], SDL_SRCALPHA, 50);
+				SDL_SetSurfaceAlphaMod (ui.shw_org[n], 50);
+				SDL_SetSurfaceAlphaMod (ui.shw[n], 50);
 			}
 		}
 		// load other vehicle graphics
@@ -1110,8 +1110,8 @@
 				{
 					ui.img_org[n] = LoadPCX (sTmpString);
 					ui.img[n] = CloneSDLSurface (ui.img_org[n]);
-					SDL_SetColorKey (ui.img_org[n], SDL_SRCCOLORKEY, 0xFFFFFF);
-					SDL_SetColorKey (ui.img[n], SDL_SRCCOLORKEY, 0xFFFFFF);
+					SDL_SetColorKey (ui.img_org[n], SDL_TRUE, 0xFFFFFF);
+					SDL_SetColorKey (ui.img[n], SDL_TRUE, 0xFFFFFF);
 				}
 				else
 				{
@@ -1125,7 +1125,7 @@
 				{
 					ui.shw_org[n] = LoadPCX (sTmpString);
 					ui.shw[n] = CloneSDLSurface (ui.shw_org[n]);
-					SDL_SetAlpha (ui.shw[n], SDL_SRCALPHA, 50);
+					SDL_SetSurfaceAlphaMod (ui.shw[n], 50);
 				}
 				else
 				{
@@ -1210,8 +1210,8 @@
 			{
 				ui.build_org = LoadPCX (sTmpString);
 				ui.build = CloneSDLSurface (ui.build_org);
-				SDL_SetColorKey (ui.build_org, SDL_SRCCOLORKEY, 0xFFFFFF);
-				SDL_SetColorKey (ui.build, SDL_SRCCOLORKEY, 0xFFFFFF);
+				SDL_SetColorKey (ui.build_org, SDL_TRUE, 0xFFFFFF);
+				SDL_SetColorKey (ui.build, SDL_TRUE, 0xFFFFFF);
 			}
 			else
 			{
@@ -1227,7 +1227,7 @@
 			{
 				ui.build_shw_org = LoadPCX (sTmpString);
 				ui.build_shw = CloneSDLSurface (ui.build_shw_org);
-				SDL_SetAlpha (ui.build_shw, SDL_SRCALPHA, 50);
+				SDL_SetSurfaceAlphaMod (ui.build_shw, 50);
 			}
 			else
 			{
@@ -1255,8 +1255,8 @@
 			{
 				ui.clear_small_org = LoadPCX (sTmpString);
 				ui.clear_small = CloneSDLSurface (ui.clear_small_org);
-				SDL_SetColorKey (ui.clear_small_org, SDL_SRCCOLORKEY, 0xFFFFFF);
-				SDL_SetColorKey (ui.clear_small, SDL_SRCCOLORKEY, 0xFFFFFF);
+				SDL_SetColorKey (ui.clear_small_org, SDL_TRUE, 0xFFFFFF);
+				SDL_SetColorKey (ui.clear_small, SDL_TRUE, 0xFFFFFF);
 			}
 			else
 			{
@@ -1272,7 +1272,7 @@
 			{
 				ui.clear_small_shw_org = LoadPCX (sTmpString);
 				ui.clear_small_shw = CloneSDLSurface (ui.clear_small_shw_org);
-				SDL_SetAlpha (ui.clear_small_shw, SDL_SRCALPHA, 50);
+				SDL_SetSurfaceAlphaMod (ui.clear_small_shw, 50);
 			}
 			else
 			{
@@ -1288,8 +1288,8 @@
 			{
 				ui.build_org = LoadPCX (sTmpString);
 				ui.build = CloneSDLSurface (ui.build_org);
-				SDL_SetColorKey (ui.build_org, SDL_SRCCOLORKEY, 0xFFFFFF);
-				SDL_SetColorKey (ui.build, SDL_SRCCOLORKEY, 0xFFFFFF);
+				SDL_SetColorKey (ui.build_org, SDL_TRUE, 0xFFFFFF);
+				SDL_SetColorKey (ui.build, SDL_TRUE, 0xFFFFFF);
 			}
 			else
 			{
@@ -1305,7 +1305,7 @@
 			{
 				ui.build_shw_org = LoadPCX (sTmpString);
 				ui.build_shw = CloneSDLSurface (ui.build_shw_org);
-				SDL_SetAlpha (ui.build_shw, SDL_SRCALPHA, 50);
+				SDL_SetSurfaceAlphaMod (ui.build_shw, 50);
 			}
 			else
 			{
@@ -1594,8 +1594,8 @@
 		{
 			ui.img_org = LoadPCX (sTmpString);
 			ui.img = CloneSDLSurface (ui.img_org);
-			SDL_SetColorKey (ui.img_org, SDL_SRCCOLORKEY, 0xFFFFFF);
-			SDL_SetColorKey (ui.img, SDL_SRCCOLORKEY, 0xFFFFFF);
+			SDL_SetColorKey (ui.img_org, SDL_TRUE, 0xFFFFFF);
+			SDL_SetColorKey (ui.img, SDL_TRUE, 0xFFFFFF);
 		}
 		else
 		{
@@ -1609,7 +1609,7 @@
 		{
 			ui.shw_org = LoadPCX (sTmpString);
 			ui.shw     = CloneSDLSurface (ui.shw_org);
-			SDL_SetAlpha (ui.shw, SDL_SRCALPHA, 50);
+			SDL_SetSurfaceAlphaMod (ui.shw, 50);
 		}
 
 		// load video
@@ -1633,7 +1633,7 @@
 			{
 				ui.eff_org = LoadPCX (sTmpString);
 				ui.eff = CloneSDLSurface (ui.eff_org);
-				SDL_SetAlpha (ui.eff, SDL_SRCALPHA, 10);
+				SDL_SetSurfaceAlphaMod (ui.eff, 10);
 			}
 		}
 		else
@@ -1655,16 +1655,16 @@
 			b.isConnectorGraphic = true;
 			UnitsData.ptr_connector = ui.img;
 			UnitsData.ptr_connector_org = ui.img_org;
-			SDL_SetColorKey (UnitsData.ptr_connector, SDL_SRCCOLORKEY, 0xFF00FF);
+			SDL_SetColorKey (UnitsData.ptr_connector, SDL_TRUE, 0xFF00FF);
 			UnitsData.ptr_connector_shw = ui.shw;
 			UnitsData.ptr_connector_shw_org = ui.shw_org;
-			SDL_SetColorKey (UnitsData.ptr_connector_shw, SDL_SRCCOLORKEY, 0xFF00FF);
+			SDL_SetColorKey (UnitsData.ptr_connector_shw, SDL_TRUE, 0xFF00FF);
 		}
 		else if (b.ID == UnitsData.specialIDSmallBeton)
 		{
 			UnitsData.ptr_small_beton = ui.img;
 			UnitsData.ptr_small_beton_org = ui.img_org;
-			SDL_SetColorKey (UnitsData.ptr_small_beton, SDL_SRCCOLORKEY, 0xFF00FF);
+			SDL_SetColorKey (UnitsData.ptr_small_beton, SDL_TRUE, 0xFF00FF);
 		}
 
 		// Check if there is more than one frame
@@ -1680,12 +1680,12 @@
 		UnitsData.dirt_big = CloneSDLSurface (UnitsData.dirt_big_org);
 		LoadGraphicToSurface (UnitsData.dirt_big_shw_org, cSettings::getInstance().getBuildingsPath().c_str(), "dirt_big_shw.pcx");
 		UnitsData.dirt_big_shw = CloneSDLSurface (UnitsData.dirt_big_shw_org);
-		if (UnitsData.dirt_big_shw) SDL_SetAlpha (UnitsData.dirt_big_shw, SDL_SRCALPHA, 50);
+		if (UnitsData.dirt_big_shw) SDL_SetSurfaceAlphaMod (UnitsData.dirt_big_shw, 50);
 		LoadGraphicToSurface (UnitsData.dirt_small_org, cSettings::getInstance().getBuildingsPath().c_str(), "dirt_small.pcx");
 		UnitsData.dirt_small = CloneSDLSurface (UnitsData.dirt_small_org);
 		LoadGraphicToSurface (UnitsData.dirt_small_shw_org, cSettings::getInstance().getBuildingsPath().c_str(), "dirt_small_shw.pcx");
 		UnitsData.dirt_small_shw = CloneSDLSurface (UnitsData.dirt_small_shw_org);
-		if (UnitsData.dirt_small_shw) SDL_SetAlpha (UnitsData.dirt_small_shw, SDL_SRCALPHA, 50);
+		if (UnitsData.dirt_small_shw) SDL_SetSurfaceAlphaMod (UnitsData.dirt_small_shw, 50);
 	}
 	return 1;
 }
Index: log.cpp
===================================================================
--- log.cpp	(revision 3449)
+++ log.cpp	(working copy)
@@ -104,7 +104,7 @@
 		fprintf (stderr, "(EE): Couldn't open maxr.log!\n Please check file/directory permissions\n");
 		return false;
 	}
-	if (blocks < 0)
+	if (blocks <= 0)
 	{
 		fprintf (stderr, "(EE): Couldn't read maxr.log!\n Please check file/directory permissions\n");
 
@@ -173,9 +173,9 @@
 {
 	if (logfile)
 	{
-		int const wrote = SDL_RWwrite (logfile, str.c_str(), 1, (int) str.length());
+		const int wrote = SDL_RWwrite (logfile, str.c_str(), 1, (int) str.length());
 		std::cout << str;
-		if (wrote < 0)   //sanity check - was file writable?
+		if (wrote <= 0)   //sanity check - was file writable?
 		{
 			fprintf (stderr, "Couldn't write to maxr.log\nPlease check permissions for maxr.log\nLog message was:\n%s", str.c_str());
 			return -1;
Index: main.cpp
===================================================================
--- main.cpp	(revision 3442)
+++ main.cpp	(working copy)
@@ -27,7 +27,6 @@
 #include <SDL_thread.h>
 #include <SDL_net.h>
 #include <SDL_mixer.h>
-#include <SDL_getenv.h>
 
 #define __main__
 #include "main.h"
@@ -111,7 +110,7 @@
 
 	// load files
 	int loadingState = LOAD_GOING;
-	SDL_Thread* dataThread = SDL_CreateThread (LoadData, &loadingState);
+	SDL_Thread* dataThread = SDL_CreateThread (LoadData, "loadingData", &loadingState);
 
 	SDL_Event event;
 	while (loadingState != LOAD_FINISHED)
@@ -124,8 +123,12 @@
 		}
 		while (SDL_PollEvent (&event))
 		{
-			if (event.type == SDL_ACTIVEEVENT && !DEDICATED_SERVER)
-				SDL_UpdateRect (screen, 0, 0, 0, 0);
+			if (!DEDICATED_SERVER
+				&& event.type == SDL_WINDOWEVENT
+				&& event.window.event == SDL_WINDOWEVENT_EXPOSED)
+			{
+				Video.draw();
+			}
 		}
 		SDL_Delay (100);
 	}
@@ -172,7 +175,6 @@
 	else
 	{
 		Video.setResolution (Video.getResolutionX(), Video.getResolutionY(), true);
-		SDL_ShowCursor (0);
 		Video.clearBuffer();
 
 		mouse = new cMouse;
@@ -335,7 +337,7 @@
 	if (height > scr->h && dest) height = scr->h;
 
 	// generate new surface if necessary
-	if (dest == NULL) surface = SDL_CreateRGBSurface (scr->flags, width, height, scr->format->BitsPerPixel, scr->format->Rmask, scr->format->Gmask, scr->format->Bmask, scr->format->Amask);
+	if (dest == NULL) surface = SDL_CreateRGBSurface (0, width, height, scr->format->BitsPerPixel, scr->format->Rmask, scr->format->Gmask, scr->format->Bmask, scr->format->Amask);
 	else
 	{
 		// else set the size of the old one
@@ -421,8 +423,8 @@
 SDL_Surface* CreatePfeil (int p1x, int p1y, int p2x, int p2y, int p3x, int p3y, unsigned int color, int size)
 {
 	SDL_Surface* sf;
-	sf = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, size, size, Video.getColDepth(), 0, 0, 0, 0);
-	SDL_SetColorKey (sf, SDL_SRCCOLORKEY, 0x00FF00FF);
+	sf = SDL_CreateRGBSurface (0, size, size, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_SetColorKey (sf, SDL_TRUE, 0x00FF00FF);
 	SDL_FillRect (sf, NULL, 0x00FF00FF);
 	SDL_LockSurface (sf);
 
@@ -974,8 +976,8 @@
 	if (!dst || !src) return;
 
 	//check surface formats
-	if (!dst->format->Amask) return;
-	if (src->format->Amask || ! (src->flags & SDL_SRCALPHA)) return;
+	if (!dst->format->Amask || src->format->Amask) return;
+	if (SDL_GetSurfaceAlphaMod(src, NULL) != 0) return;
 
 	if (srcrect == NULL)
 	{
@@ -1037,7 +1039,8 @@
 	if (SDL_MUSTLOCK (dst)) SDL_LockSurface (dst);
 
 	//setup needed variables
-	const Uint32 srcAlpha = src->format->alpha;
+	Uint8 srcAlpha = 0;
+	SDL_GetSurfaceAlphaMod (src, &srcAlpha);
 	const int srmask = src->format->Rmask;
 	const int sgmask = src->format->Gmask;
 	const int sbmask = src->format->Bmask;
@@ -1049,8 +1052,8 @@
 	const int gshift = src->format->Gshift - dst->format->Gshift;
 	const int bshift = src->format->Bshift - dst->format->Bshift;
 	const int ashift = dst->format->Ashift;
-	const Uint32 colorKey = src->format->colorkey;
-	const bool useColorKey = (src->flags & SDL_SRCCOLORKEY) != 0;
+	Uint32 colorKey = 0;
+	const bool useColorKey = SDL_GetColorKey (src, &colorKey) == 0;
 
 	Uint32* dstPixel = static_cast<Uint32*> (dst->pixels) + dstrect->x + dstrect->y * dst->w;
 	Uint32* srcPixel = static_cast<Uint32*> (src->pixels) + srcrect->x + srcrect->y * src->w;
@@ -1107,7 +1110,8 @@
 
 void blittAlphaSurface (SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect)
 {
-	if (dst->format->Amask && (src->flags & SDL_SRCALPHA))
+	// TODO: [SDL2] special blitSurface seems useless.
+	if (dst->format->Amask && SDL_GetSurfaceAlphaMod(src, NULL) == 0)
 		blittPerSurfaceAlphaToAlphaChannel (src, srcrect, dst, dstrect);
 	else
 		SDL_BlitSurface (src, srcrect, dst, dstrect);
Index: map.cpp
===================================================================
--- map.cpp	(revision 3450)
+++ map.cpp	(working copy)
@@ -28,6 +28,14 @@
 #include "vehicles.h"
 #include "video.h"
 
+#if 1 // TODO: [SDL2]: SDL_SetColors
+inline void SDL_SetColors (SDL_Surface* surface, SDL_Color* colors, int index, int size)
+{
+	SDL_SetPaletteColors (surface->format->palette, colors, index, size);
+}
+#endif
+
+
 sTerrain::sTerrain() :
 	water (false),
 	coast (false),
@@ -250,6 +258,8 @@
 		palette_shw[i].r = (unsigned char) (palette[i].r * 0.6f);
 		palette_shw[i].g = (unsigned char) (palette[i].g * 0.6f);
 		palette_shw[i].b = (unsigned char) (palette[i].b * 0.6f);
+		palette[i].a = 255;
+		palette_shw[i].a = 255;
 	}
 
 	// Load necessary Terrain Graphics
@@ -314,13 +324,13 @@
 	return true;
 }
 
-/*static*/SDL_Surface* cStaticMap::loadTerrGraph (SDL_RWops* fpMapFile, int iGraphicsPos, SDL_Color* Palette, int iNum)
+/*static*/SDL_Surface* cStaticMap::loadTerrGraph (SDL_RWops* fpMapFile, int iGraphicsPos, const SDL_Color (&colors)[256], int iNum)
 {
 	// Create new surface and copy palette
-	AutoSurface surface (SDL_CreateRGBSurface (SDL_SWSURFACE, 64, 64, 8, 0, 0, 0, 0));
+	AutoSurface surface (SDL_CreateRGBSurface (0, 64, 64, 8, 0, 0, 0, 0));
 	surface->pitch = surface->w;
 
-	SDL_SetColors (surface, Palette, 0, 256);
+	SDL_SetPaletteColors (surface->format->palette, colors, 0, 256);
 
 	// Go to position of filedata
 	SDL_RWseek (fpMapFile, iGraphicsPos + 64 * 64 * (iNum), SEEK_SET);
@@ -353,7 +363,7 @@
 	SDL_RWseek (mapFile, 64 * 64 * sGraphCount, SEEK_CUR);
 	SDL_RWread (mapFile, &Palette, 3, 256);
 
-	AutoSurface mapSurface (SDL_CreateRGBSurface (SDL_SWSURFACE, size, size, 8, 0, 0, 0, 0));
+	AutoSurface mapSurface (SDL_CreateRGBSurface (0, size, size, 8, 0, 0, 0, 0));
 	mapSurface->pitch = mapSurface->w;
 
 	mapSurface->format->palette->ncolors = 256;
@@ -388,20 +398,20 @@
 	//This is needed to make sure, that the pixeldata is copied 1:1
 
 	//copy the normal terrains
-	terrains[iNum].sf_org = SDL_CreateRGBSurface (Video.getSurfaceType(), 64, 64, 8, 0, 0, 0, 0);
-	SDL_SetColors (terrains[iNum].sf_org, surface->format->palette->colors, 0, 256);
+	terrains[iNum].sf_org = SDL_CreateRGBSurface (0, 64, 64, 8, 0, 0, 0, 0);
+	SDL_SetPaletteColors (terrains[iNum].sf_org->format->palette, surface->format->palette->colors, 0, 256);
 	SDL_BlitSurface (surface, NULL, terrains[iNum].sf_org, NULL);
 
-	terrains[iNum].sf = SDL_CreateRGBSurface (Video.getSurfaceType(), 64, 64, 8, 0, 0, 0, 0);
-	SDL_SetColors (terrains[iNum].sf, surface->format->palette->colors, 0, 256);
+	terrains[iNum].sf = SDL_CreateRGBSurface (0, 64, 64, 8, 0, 0, 0, 0);
+	SDL_SetPaletteColors (terrains[iNum].sf->format->palette, surface->format->palette->colors, 0, 256);
 	SDL_BlitSurface (surface, NULL, terrains[iNum].sf, NULL);
 
 	//copy the terrains with fog
-	terrains[iNum].shw_org = SDL_CreateRGBSurface (Video.getSurfaceType(), 64, 64, 8, 0, 0, 0, 0);
+	terrains[iNum].shw_org = SDL_CreateRGBSurface (0, 64, 64, 8, 0, 0, 0, 0);
 	SDL_SetColors (terrains[iNum].shw_org, surface->format->palette->colors, 0, 256);
 	SDL_BlitSurface (surface, NULL, terrains[iNum].shw_org, NULL);
 
-	terrains[iNum].shw = SDL_CreateRGBSurface (Video.getSurfaceType(), 64, 64, 8, 0, 0, 0, 0);
+	terrains[iNum].shw = SDL_CreateRGBSurface (0, 64, 64, 8, 0, 0, 0, 0);
 	SDL_SetColors (terrains[iNum].shw, surface->format->palette->colors, 0, 256);
 	SDL_BlitSurface (surface, NULL, terrains[iNum].shw, NULL);
 
@@ -451,7 +461,7 @@
 
 SDL_Surface* cStaticMap::createBigSurface (int sizex, int sizey) const
 {
-	SDL_Surface* mapSurface = SDL_CreateRGBSurface (Video.getSurfaceType(), sizex, sizey, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_Surface* mapSurface = SDL_CreateRGBSurface (0, sizex, sizey, Video.getColDepth(), 0, 0, 0, 0);
 
 	if (SDL_MUSTLOCK (mapSurface)) SDL_LockSurface (mapSurface);
 	for (int x = 0; x < mapSurface->w; ++x)
Index: map.h
===================================================================
--- map.h	(revision 3442)
+++ map.h	(working copy)
@@ -127,7 +127,7 @@
 	void scaleSurfaces (int pixelSize);
 	static SDL_Surface* loadMapPreview(const std::string& mapPath, int* mapSize = NULL);
 private:
-	static SDL_Surface* loadTerrGraph (SDL_RWops* fpMapFile, int iGraphicsPos, SDL_Color* Palette, int iNum);
+	static SDL_Surface* loadTerrGraph (SDL_RWops* fpMapFile, int iGraphicsPos, const SDL_Color (&colors)[256], int iNum);
 	void copySrfToTerData (SDL_Surface* surface, int iNum);
 private:
 	std::string filename;   // Name of the current map
Index: mapdownload.cpp
===================================================================
--- mapdownload.cpp	(revision 3450)
+++ mapdownload.cpp	(working copy)
@@ -269,7 +269,7 @@
 void cMapSender::runInThread()
 {
 	// the thread will quit, when it finished uploading the map
-	thread = SDL_CreateThread (mapSenderThreadFunction, this);
+	thread = SDL_CreateThread (mapSenderThreadFunction, "mapSender", this);
 }
 
 //------------------------------------------------------------------------------
Index: menuitems.cpp
===================================================================
--- menuitems.cpp	(revision 3446)
+++ menuitems.cpp	(working copy)
@@ -442,10 +442,10 @@
 {
 	if (image_ != NULL)
 	{
-		image = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, image_->w, image_->h, Video.getColDepth(), 0, 0, 0, 0);
+		image = SDL_CreateRGBSurface (0, image_->w, image_->h, Video.getColDepth(), 0, 0, 0, 0);
 
 		SDL_FillRect (image, NULL, 0xFF00FF);
-		SDL_SetColorKey (image, SDL_SRCCOLORKEY, 0xFF00FF);
+		SDL_SetColorKey (image, SDL_TRUE, 0xFF00FF);
 
 		SDL_BlitSurface (image_, NULL, image, NULL);
 
@@ -702,8 +702,8 @@
 			src.y = isClicked ? 0 : 132;
 			break;
 	}
-	surface = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0xFF00FF);
+	surface = SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_SetColorKey (surface, SDL_TRUE, 0xFF00FF);
 	SDL_FillRect (surface, NULL, 0xFF00FF);
 	if (buttonType >= BUTTON_TYPE_HUD_HELP && buttonType <= BUTTON_TYPE_HUD_STOP) SDL_BlitSurface (GraphicsData.gfx_hud_stuff, &src, surface, NULL);
 	else SDL_BlitSurface (GraphicsData.gfx_menu_stuff, &src, surface, NULL);
@@ -716,7 +716,6 @@
 	renewButtonSurface();
 	draw();
 	Video.draw();
-	mouse->draw (false, screen);
 }
 
 int cMenuButton::getTextYOffset() const
@@ -899,7 +898,6 @@
 	}
 
 	Video.draw();
-	mouse->draw (false, screen);
 }
 
 void cMenuDestroyButton::animationCallback()
@@ -1048,7 +1046,7 @@
 	}
 	if (src.w > 0)
 	{
-		surface = SDL_CreateRGBSurface (Video.getSurfaceType(), src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
+		surface = SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
 		if (buttonType >= CHECKBOX_HUD_INDEX_00 && buttonType <= CHECKBOX_HUD_PLAYERS) SDL_BlitSurface (GraphicsData.gfx_hud_stuff, &src, surface, NULL);
 		else SDL_BlitSurface (GraphicsData.gfx_menu_stuff, &src, surface, NULL);
 	}
@@ -1070,7 +1068,6 @@
 	}
 	draw();
 	Video.draw();
-	mouse->draw (false, screen);
 	return true;
 }
 
@@ -1112,7 +1109,7 @@
 			font->showText (position.x, position.y, text, fontType);
 			if (checked)
 			{
-				const Uint32 selection_color (0x00E3DACF);
+				const Uint32 selection_color (0xFFE3DACF);
 				const SDL_Rect dest = {Sint16 (position.x - 2), Sint16 (position.y - 1), Uint16 (position.w + 5), Uint16 (position.h + 2) };
 				DrawRectangle (buffer, dest, selection_color);
 			}
@@ -1209,7 +1206,7 @@
 
 void cMenuRadioGroup::clicked (void* parent)
 {
-	mouse->GetPos();
+	mouse->updatePos();
 	for (unsigned int i = 0; i < buttonList.size(); i++)
 	{
 		if (buttonList[i]->overItem (mouse->x, mouse->y))
@@ -1252,8 +1249,8 @@
 void cMenuUnitListItem::init()
 {
 	const int UNIT_IMAGE_SIZE = 32;
-	surface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0x00FF00FF);
+	surface = SDL_CreateRGBSurface (0, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_SetColorKey (surface, SDL_TRUE, 0x00FF00FF);
 	SDL_FillRect (surface, NULL, 0x00FF00FF);
 	SDL_Rect dest = {0, 0, 0, 0};
 
@@ -1288,7 +1285,7 @@
 	if (selected)
 	{
 		const SDL_Rect dest = { Sint16 (position.x - 4), Sint16 (position.y - 4), 38, 38};
-		DrawSelectionCorner (buffer, dest, 8, 0x00E0E0E0);
+		DrawSelectionCorner (buffer, dest, 8, 0xFFE0E0E0);
 	}
 
 	switch (displayType)
@@ -1484,7 +1481,7 @@
 
 void cMenuUnitsList::released (void* parent)
 {
-	mouse->GetPos();
+	mouse->updatePos();
 	for (int i = offset; i < offset + maxDisplayUnits; i++)
 	{
 		if (i >= (int) unitsList.size()) break;
@@ -1674,7 +1671,7 @@
 	dest.x += src.w + 3;
 	SDL_Rect mark = { Sint16 (dest.x - src.w / 2), dest.y, 1, src.h };
 
-	SDL_FillRect (buffer, &mark, 0xFC0000);
+	SDL_FillRect (buffer, &mark, 0xFFFC0000);
 
 	if (symType == MENU_SYMBOLS_METAL)
 	{
@@ -1905,11 +1902,11 @@
 	if (drawLines)
 	{
 		SDL_Rect lineRect = { Sint16 (position.x + 2), Sint16 (position.y + 14), 153, 1 };
-		SDL_FillRect (buffer, &lineRect, 0x743904);
+		SDL_FillRect (buffer, &lineRect, 0xFF743904);
 		lineRect.y += 12;
-		SDL_FillRect (buffer, &lineRect, 0x743904);
+		SDL_FillRect (buffer, &lineRect, 0xFF743904);
 		lineRect.y += 12;
-		SDL_FillRect (buffer, &lineRect, 0x743904);
+		SDL_FillRect (buffer, &lineRect, 0xFF743904);
 	}
 	if (unit == NULL) return;
 	const sUnitData* data = &unit->data;
@@ -2127,7 +2124,7 @@
 	const int DETAIL_COLUMN_1 = dest.x + 27;
 	const int DETAIL_COLUMN_2 = dest.x + 42;
 	const int DETAIL_COLUMN_3 = dest.x + 95;
-#define DETAIL_DOLINEBREAK dest.y = y + 14; SDL_FillRect (buffer, &dest, 0xFC0000); y += 19;
+#define DETAIL_DOLINEBREAK dest.y = y + 14; SDL_FillRect (buffer, &dest, 0xFFFC0000); y += 19;
 
 	if (data->canAttack)
 	{
@@ -2349,8 +2346,8 @@
 void cMenuMaterialBar::generateSurface()
 {
 	SDL_Rect src = { 114, 336, position.w, position.h };
-	surface = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0xFF00FF);
+	surface = SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_SetColorKey (surface, SDL_TRUE, 0xFF00FF);
 	SDL_FillRect (surface, NULL, 0xFF00FF);
 
 	switch (materialType)
@@ -2568,11 +2565,11 @@
 	position.h = src.h;
 	mouseXOff = mouseYOff = 0;
 
-	surface = SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, position.w, position.h, Video.getColDepth(), 0, 0, 0, 0);
+	surface = SDL_CreateRGBSurface (0, position.w, position.h, Video.getColDepth(), 0, 0, 0, 0);
 	SDL_FillRect (surface, NULL, 0xFF00FF);
 	if (scrollerType == SCROLLER_TYPE_HUD_ZOOM) SDL_BlitSurface (GraphicsData.gfx_hud_stuff, &src, surface, NULL);
 	else SDL_BlitSurface (GraphicsData.gfx_menu_stuff, &src, surface, NULL);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0xFF00FF);
+	SDL_SetColorKey (surface, SDL_TRUE, 0xFF00FF);
 }
 
 void cMenuScroller::draw()
@@ -2663,7 +2660,7 @@
 {
 	SDL_Rect src = { 234, 1, 16, 48};
 	SDL_Rect dest = { 0, 0, 0, 0 };
-	surface = SDL_CreateRGBSurface (Video.getSurfaceType(), 16, position.h - 28, Video.getColDepth(), 0, 0, 0, 0);
+	surface = SDL_CreateRGBSurface (0, 16, position.h - 28, Video.getColDepth(), 0, 0, 0, 0);
 	do
 	{
 		if (position.h - 28 - dest.y < 48) src.h = position.h - 28 - dest.x;
@@ -2961,7 +2958,7 @@
 	}
 }
 
-bool cMenuLineEdit::handleKeyInput (SDL_keysym keysym, const string& ch, void* parent)
+bool cMenuLineEdit::handleKeyInput (const SDL_Keysym& keysym, cMenu* parent)
 {
 	if (readOnly) return false;
 
@@ -2995,28 +2992,7 @@
 			if (wasKeyInput) wasKeyInput (parent);
 			break;
 		default: // no special key - handle as normal character:
-			if (keysym.unicode >= 32)
-			{
-				if (keysym.unicode >= 48 && keysym.unicode <= 57)
-				{
-					if (!takeNumerics) break;
-				}
-				else if (!takeChars) break;
-
-				text.insert (cursorPos, ch);
-				if (cursorPos < (int) text.length()) doPosIncrease (cursorPos, cursorPos);
-				if (cursorPos >= endOffset)
-				{
-					doPosIncrease (endOffset, endOffset);
-					while (font->getTextWide (text.substr (startOffset, endOffset - startOffset), fontType) > position.w - getBorderSize()) doPosIncrease (startOffset, startOffset);
-				}
-				else
-				{
-					if (font->getTextWide (text.substr (startOffset, endOffset - startOffset), fontType) > position.w - getBorderSize()) doPosDecrease (endOffset);
-					else doPosIncrease (endOffset, cursorPos);
-				}
-				if (wasKeyInput) wasKeyInput (parent);
-			}
+			addText (keysym, parent);
 			break;
 	}
 	parentMenu->draw();
@@ -3023,6 +2999,34 @@
 	return true;
 }
 
+void cMenuLineEdit::addText (const SDL_Keysym& keysym, cMenu* parent)
+{
+	if (keysym.sym >= 32)
+	{
+		if (keysym.sym >= 48 && keysym.sym <= 57)
+		{
+			if (!takeNumerics) return;
+		}
+		else if (!takeChars) return;
+
+		std::string ch = cInput::getUTF16Char (keysym.sym);
+
+		text.insert (cursorPos, ch);
+		if (cursorPos < (int) text.length()) doPosIncrease (cursorPos, cursorPos);
+		if (cursorPos >= endOffset)
+		{
+			doPosIncrease (endOffset, endOffset);
+			while (font->getTextWide (text.substr (startOffset, endOffset - startOffset), fontType) > position.w - getBorderSize()) doPosIncrease (startOffset, startOffset);
+		}
+		else
+		{
+			if (font->getTextWide (text.substr (startOffset, endOffset - startOffset), fontType) > position.w - getBorderSize()) doPosDecrease (endOffset);
+			else doPosIncrease (endOffset, cursorPos);
+		}
+		if (wasKeyInput) wasKeyInput (parent);
+	}
+}
+
 void cMenuLineEdit::setReturnPressedFunc (void (*returnPressed_) (void*))
 {
 	returnPressed = returnPressed_;
@@ -3038,9 +3042,9 @@
 {
 	if (Video.getResolutionX() - HUD_TOTAL_WIDTH - 20 < 60) return;
 
-	surface = SDL_CreateRGBSurface (Video.getSurfaceType(), Video.getResolutionX() - HUD_TOTAL_WIDTH - 20, 48, Video.getColDepth(), 0, 0, 0, 0);
+	surface = SDL_CreateRGBSurface (0, Video.getResolutionX() - HUD_TOTAL_WIDTH - 20, 48, Video.getColDepth(), 0, 0, 0, 0);
 	SDL_FillRect (surface, NULL, 0xFF00FF);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0xFF00FF);
+	SDL_SetColorKey (surface, SDL_TRUE, 0xFF00FF);
 
 	SDL_Rect src = { 0, 0, 30, 48 };
 	SDL_Rect dest = { 0, 0, 0, 0 };
@@ -3118,14 +3122,14 @@
 {
 	SDL_Rect src = { 10, 0, 10, 10 };
 
-	AutoSurface readySurface (SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
-	SDL_SetColorKey (readySurface, SDL_SRCCOLORKEY, 0xFF00FF);
+	AutoSurface readySurface (SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
+	SDL_SetColorKey (readySurface, SDL_TRUE, 0xFF00FF);
 	SDL_FillRect (readySurface, NULL, 0xFF00FF);
 	SDL_BlitSurface (GraphicsData.gfx_player_ready, &src, readySurface, NULL);
 
 	src.x -= 10;
-	AutoSurface notReadySurface (SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
-	SDL_SetColorKey (notReadySurface, SDL_SRCCOLORKEY, 0xFF00FF);
+	AutoSurface notReadySurface (SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
+	SDL_SetColorKey (notReadySurface, SDL_TRUE, 0xFF00FF);
 	SDL_FillRect (notReadySurface, NULL, 0xFF00FF);
 	SDL_BlitSurface (GraphicsData.gfx_player_ready, &src, notReadySurface, NULL);
 
@@ -3137,7 +3141,7 @@
 			if ( (*players) [i]->isReady()) playerReadys[index]->setImage (readySurface);
 			else playerReadys[index]->setImage (notReadySurface);
 
-			AutoSurface colorSurface (SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
+			AutoSurface colorSurface (SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
 			SDL_BlitSurface ( (*players) [i]->getColorSurface(), &src, colorSurface, NULL);
 			playerColors[index]->setImage (colorSurface);
 
@@ -3420,7 +3424,7 @@
 			position.w = src.w;
 			position.h = src.h;
 
-			surface = SDL_CreateRGBSurface (Video.getSurfaceType(), src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
+			surface = SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0);
 			SDL_BlitSurface (GraphicsData.gfx_menu_stuff, &src, surface, NULL);
 
 			scroller = new cMenuScroller (x - 7, y - 7, cMenuScroller::SCROLLER_TYPE_HORI, this, &scrollerMoved);
@@ -3612,7 +3616,7 @@
 	{
 		const int selIndex = selected - index * maxItems;
 		const SDL_Rect rect = {Sint16 (position.x + 13), Sint16 (position.y + 26 + 55 * selIndex), 38, 38};
-		DrawSelectionCorner (buffer, rect, 8, 0x00E0E0E0);
+		DrawSelectionCorner (buffer, rect, 8, 0xFFE0E0E0);
 	}
 }
 
@@ -3941,7 +3945,7 @@
 		{
 			int selIndex = selected - index * maxItems;
 			const SDL_Rect rect = {Sint16 (position.x + 15), Sint16 (position.y + 23 + 55 * selIndex), 450, 53 };
-			DrawRectangle (buffer, rect, 0x00E0E0E0);
+			DrawRectangle (buffer, rect, 0xFFE0E0E0);
 		}
 	}
 }
@@ -4112,8 +4116,8 @@
 	float zoomFactor = (float) UNIT_IMAGE_SIZE / (unit->data.isBig ? 128.0f : 64.0f);
 	SDL_Rect dest = { 0, 0, 0, 0};
 
-	SDL_Surface* surface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
-	SDL_SetColorKey (surface, SDL_SRCCOLORKEY, 0xFF00FF);
+	SDL_Surface* surface = SDL_CreateRGBSurface (0, UNIT_IMAGE_SIZE, UNIT_IMAGE_SIZE, Video.getColDepth(), 0, 0, 0, 0);
+	SDL_SetColorKey (surface, SDL_TRUE, 0xFF00FF);
 	//SDL_FillRect (surface, NULL, 0xFF00FF);
 
 	if (unit->isABuilding())
Index: menuitems.h
===================================================================
--- menuitems.h	(revision 3446)
+++ menuitems.h	(working copy)
@@ -212,7 +212,7 @@
 	 *@param ch the encoded key
 	 *@param parent pointer to the calling menu
 	 */
-	virtual bool handleKeyInput (SDL_keysym keysym, const std::string& ch, void* parent) { return false; }
+	virtual bool handleKeyInput (const SDL_Keysym& keysym, cMenu* parent) { return false; }
 
 
 	/**
@@ -1028,6 +1028,7 @@
 	bool readOnly;
 	bool takeChars, takeNumerics;
 
+	void addText (const SDL_Keysym& keysym, cMenu* parent);
 	void resetTextPosition();
 	void doPosIncrease (int& value, int pos);
 	void doPosDecrease (int& pos);
@@ -1055,7 +1056,7 @@
 	void setText (const std::string& text_);
 	const std::string& getText() const;
 	void setSize (int w, int h);
-	virtual bool handleKeyInput (SDL_keysym keysym, const std::string& ch, void* parent);
+	virtual bool handleKeyInput (const SDL_Keysym& keysym, cMenu* parent);
 
 	void setReturnPressedFunc (void (*returnPressed_) (void*));
 };
Index: menus.cpp
===================================================================
--- menus.cpp	(revision 3450)
+++ menus.cpp	(working copy)
@@ -234,7 +234,6 @@
 	end = false;
 	terminate = false;
 	activeItem = NULL;
-	drawnEveryFrame = false;
 
 	lastScreenResX = Video.getResolutionX();
 	lastScreenResY = Video.getResolutionY();
@@ -292,10 +291,13 @@
 		case MNU_BG_BLACK:
 			// fill the whole screen with black to prevent
 			// old garbage from menus that don't support resolutions > 640x480
-			SDL_FillRect (buffer, NULL, 0x000000);
+			SDL_FillRect (buffer, NULL, 0xFF000000);
 			break;
 		case MNU_BG_ALPHA:
-			if (cSettings::getInstance().isAlphaEffects() && firstDraw) SDL_BlitSurface (GraphicsData.gfx_shadow, NULL, buffer, NULL);
+			if (cSettings::getInstance().isAlphaEffects() && firstDraw)
+				SDL_BlitSurface (GraphicsData.gfx_shadow, NULL, buffer, NULL);
+			else
+				SDL_FillRect (buffer, NULL, SDL_MapRGBA (buffer->format, 0, 0, 0, 0));
 			break;
 		case MNU_BG_TRANSPARENT:
 			// do nothing here
@@ -318,9 +320,7 @@
 
 	if (showScreen)
 	{
-		if (drawnEveryFrame) mouse->draw (true, buffer);
 		Video.draw();
-		if (!drawnEveryFrame) mouse->draw (false, screen);
 	}
 }
 
@@ -327,8 +327,6 @@
 //------------------------------------------------------------------------------
 int cMenu::show (cClient* client)
 {
-	drawnEveryFrame = false;
-
 	mouse->SetCursor (CHand);
 	draw (true);
 
@@ -357,11 +355,9 @@
 			lastResY = Video.getResolutionY();
 		}
 
-		mouse->GetPos();
+		mouse->updatePos();
 		if (mouse->moved())
 		{
-			mouse->draw (true, screen);
-
 			for (unsigned int i = 0; i < menuItems.size(); i++)
 			{
 				cMenuItem* menuItem = menuItems[i];
@@ -406,7 +402,7 @@
 //------------------------------------------------------------------------------
 void cMenu::handleMouseInput (sMouseState mouseState)
 {
-	mouse->GetPos();
+	mouse->updatePos();
 	mouse->isDoubleClick = mouseState.isDoubleClick;
 
 	for (size_t i = 0; i != menuItems.size(); ++i)
@@ -434,9 +430,9 @@
 }
 
 //------------------------------------------------------------------------------
-void cMenu::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cMenu::handleKeyInput (const SDL_KeyboardEvent& key)
 {
-	if (activeItem && key.state == SDL_PRESSED) activeItem->handleKeyInput (key.keysym, ch, this);
+	if (activeItem && key.state == SDL_PRESSED) activeItem->handleKeyInput (key.keysym, this);
 }
 
 //------------------------------------------------------------------------------
@@ -539,7 +535,6 @@
 	menu->infoImage->setImage (surface);
 	menu->infoImage->draw();
 	Video.draw();
-	mouse->draw (false, screen);
 }
 
 //------------------------------------------------------------------------------
@@ -1312,7 +1307,7 @@
 			const int MAPWINSIZE = 112;
 			const int SELECTED = 0x00C000;
 			const int UNSELECTED = 0x000000;
-			AutoSurface imageSurface (SDL_CreateRGBSurface (Video.getSurfaceType(), MAPWINSIZE + 8, MAPWINSIZE + 8, Video.getColDepth(), 0, 0, 0, 0));
+			AutoSurface imageSurface (SDL_CreateRGBSurface (0, MAPWINSIZE + 8, MAPWINSIZE + 8, Video.getColDepth(), 0, 0, 0, 0));
 
 			if (selectedMapIndex == i + offset)
 			{
@@ -1461,7 +1456,7 @@
 			yCount = 1;
 		}
 		SDL_Surface* img = LoadPCX (clanLogoPaths[i].c_str());
-		SDL_SetColorKey (img, SDL_SRCCOLORKEY, 0xFF00FF);
+		SDL_SetColorKey (img, SDL_TRUE, 0xFF00FF);
 		clanImages[i] = new cMenuImage (position.x + 88 + xCount * 154 - (img ? (img->w / 2) : 0), position.y + 48 + yCount * 150, img);
 		clanImages[i]->setReleasedFunction (&clanSelected);
 		menuItems.push_back (clanImages[i]);
@@ -2215,9 +2210,9 @@
 	menu->landData.landingState = LANDING_POSITION_OK;
 	menu->backButton->setLocked (true);
 	{
-		AutoSurface circleSurface (SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, Video.getResolutionX() - 192, Video.getResolutionY() - 32, Video.getColDepth(), 0, 0, 0, 0));
+		AutoSurface circleSurface (SDL_CreateRGBSurface (0, Video.getResolutionX() - 192, Video.getResolutionY() - 32, Video.getColDepth(), 0, 0, 0, 0));
 		SDL_FillRect (circleSurface, NULL, 0xFF00FF);
-		SDL_SetColorKey (circleSurface, SDL_SRCCOLORKEY, 0xFF00FF);
+		SDL_SetColorKey (circleSurface, SDL_TRUE, 0xFF00FF);
 
 		int posX = (int) (menu->landData.iLandX * fakx);
 		int posY = (int) (menu->landData.iLandY * faky);
@@ -2231,7 +2226,6 @@
 
 	Video.draw();
 	mouse->SetCursor (CHand);
-	mouse->draw (false, screen);
 
 	menu->hitPosition();
 }
@@ -2251,7 +2245,7 @@
 }
 
 //------------------------------------------------------------------------------
-void cLandingMenu::handleKeyInput (SDL_KeyboardEvent& key, const string& ch)
+void cLandingMenu::handleKeyInput (const SDL_KeyboardEvent& key)
 {
 	if (key.keysym.sym == SDLK_ESCAPE && key.state == SDL_PRESSED)
 	{
@@ -2610,7 +2604,7 @@
 void cNetworkMenu::setColor (int color)
 {
 	SDL_Rect src = { 0, 0, 83, 10 };
-	AutoSurface colorSurface (SDL_CreateRGBSurface (Video.getSurfaceType() | SDL_SRCCOLORKEY, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
+	AutoSurface colorSurface (SDL_CreateRGBSurface (0, src.w, src.h, Video.getColDepth(), 0, 0, 0, 0));
 	SDL_BlitSurface (OtherData.colors[color], &src, colorSurface, NULL);
 	colorImage->setImage (colorSurface);
 }
@@ -4608,7 +4602,7 @@
 				upgradeButtons[pos]->setLocked (true);
 			}
 
-			SDL_Surface* surface = SDL_CreateRGBSurface (Video.getSurfaceType(), srcSurface->w, srcSurface->h, Video.getColDepth(), 0, 0, 0, 0);
+			SDL_Surface* surface = SDL_CreateRGBSurface (0, srcSurface->w, srcSurface->h, Video.getColDepth(), 0, 0, 0, 0);
 			SDL_BlitSurface (srcSurface, NULL, surface, NULL);
 			unitImages[pos]->setImage (surface);
 
Index: menus.h
===================================================================
--- menus.h	(revision 3446)
+++ menus.h	(working copy)
@@ -192,7 +192,6 @@
 class cMenu
 {
 protected:
-	bool drawnEveryFrame;
 	/** When this is true the show-loop will be end and give 0 as return.
 	 * Should be used when the menu is closed by ok or done.
 	 */
@@ -276,7 +275,7 @@
 	 * delegates the keyinput to the active menuitem.
 	 *@author alzi
 	 */
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 
 	/**
 	 * sends a netmessage to the given player.
@@ -657,7 +656,7 @@
 	cLandingMenu (cClient& client_, cStaticMap& map_);
 
 private:
-	virtual void handleKeyInput (SDL_KeyboardEvent& key, const std::string& ch);
+	virtual void handleKeyInput (const SDL_KeyboardEvent& key);
 	virtual void handleNetMessages();
 
 	void handleNetMessage (cNetMessage* message);
Index: mouse.cpp
===================================================================
--- mouse.cpp	(revision 3442)
+++ mouse.cpp	(working copy)
@@ -16,68 +16,33 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
 #include "mouse.h"
+
 #include "main.h"
 #include "client.h"
 #include "settings.h"
 #include "hud.h"
 
+#include <SDL.h>
 
-cMouse::cMouse()
+cMouse::cMouse() : sdlCursor (NULL)
 {
-	visible = false;
 	cur = NULL;
-	LastX = -100;
-	LastY = -100;
 	x = 0;
 	y = 0;
 	isDoubleClick = false;
-	prevScreenX = 0;
-	prevScreenY = 0;
-
-	DrawX = 0;
-	DrawY = 0;
 }
 
-// Malt die Maus, und wenn draw_back gesetzt ist, auch den alten Hintergrund:
-void cMouse::draw (bool draw_back, SDL_Surface* sf)
+cMouse::~cMouse()
 {
-	if (!visible || cur == NULL) return;
-	GetPos();
-
-	// restore old background
-	if (back && draw_back && LastX != -100)
-	{
-		SDL_Rect dest;
-		dest.x = LastX;
-		dest.y = LastY;
-		SDL_BlitSurface (back, NULL, sf, &dest);
-
-		SDL_UpdateRect (sf, dest.x, dest.y, dest.w, dest.h);
-	}
-
-	//change size of back surface if necessary, e.g. when the mouse cursor has changed
-	if (!back || back->h != cur->h || back->w != cur->w)
-	{
-		back = SDL_CreateRGBSurface (Video.getSurfaceType(), cur->w, cur->h, 32, 0, 0, 0, 0);
-	}
-
-	// store new background
-	GetBack (sf);
-	SDL_Rect dest;
-	dest.x = DrawX;
-	dest.y = DrawY;
-	LastX = DrawX;
-	LastY = DrawY;
-
-	//draw mouse
-	SDL_BlitSurface (cur, NULL, sf, &dest);
-	SDL_UpdateRect (sf, dest.x, dest.y, dest.w, dest.h);
+	if (sdlCursor) SDL_FreeCursor (sdlCursor);
 }
 
 bool cMouse::SetCursor (eCursor const typ)
 {
 	const SDL_Surface* const lastCur = cur;
+
 	switch (typ)
 	{
 		default:
@@ -106,56 +71,50 @@
 		case CDisable:   cur = GraphicsData.gfx_Cdisable;    break;
 		case CActivate:  cur = GraphicsData.gfx_Cactivate;   break;
 	}
-	return lastCur != cur;
+	if (lastCur == cur)
+	{
+		return false;
+	}
+	if (sdlCursor) SDL_FreeCursor (sdlCursor);
+	int hotx = 0;
+	int hoty = 0;
+	getCursorOffset (hotx, hoty);
+	sdlCursor = SDL_CreateColorCursor (cur, hotx, hoty);
+	SDL_SetCursor (sdlCursor);
+	return true;
 }
 
-// Liest den Hintergrund in das Back-Surface ein:
-void cMouse::GetBack (SDL_Surface* sf)
-{
-	SDL_Rect scr;
-	GetPos();
-	scr.x = DrawX;
-	scr.y = DrawY;
-	scr.w = back->w;
-	scr.h = back->h;
-	SDL_BlitSurface (sf, &scr, back, NULL);
-}
-
-void cMouse::restoreBack (SDL_Surface* sf)
-{
-	SDL_Rect dest;
-	dest.x = LastX;
-	dest.y = LastY;
-	SDL_BlitSurface (back, NULL, sf, &dest);
-}
-
 //updates the internal mouse position
-void cMouse::GetPos()
+void cMouse::updatePos()
 {
 	SDL_GetMouseState (&x, &y);
-
-	// Cursor Offset bestimmen:
-	int offX;
-	int offY;
-
-	getCursorOffset (offX, offY);
-
-	DrawX = x + offX;
-	DrawY = y + offY;
 }
 
 // gets the cursor offset. transforms screenspace to clickspace
 void cMouse::getCursorOffset (int& x, int& y) const
 {
-	if (cur == GraphicsData.gfx_Cselect || cur == GraphicsData.gfx_Chelp || cur == GraphicsData.gfx_Cmove || cur == GraphicsData.gfx_Cmove_draft || cur == GraphicsData.gfx_Cno || cur == GraphicsData.gfx_Ctransf || cur == GraphicsData.gfx_Cband || cur == GraphicsData.gfx_Cload || cur == GraphicsData.gfx_Cmuni || cur == GraphicsData.gfx_Crepair || cur == GraphicsData.gfx_Cactivate)
+	if (cur == GraphicsData.gfx_Cselect
+		|| cur == GraphicsData.gfx_Chelp
+		|| cur == GraphicsData.gfx_Cmove
+		|| cur == GraphicsData.gfx_Cmove_draft
+		|| cur == GraphicsData.gfx_Cno
+		|| cur == GraphicsData.gfx_Ctransf
+		|| cur == GraphicsData.gfx_Cband
+		|| cur == GraphicsData.gfx_Cload
+		|| cur == GraphicsData.gfx_Cmuni
+		|| cur == GraphicsData.gfx_Crepair
+		|| cur == GraphicsData.gfx_Cactivate)
 	{
-		x = -12;
-		y = -12;
+		x = 12;
+		y = 12;
 	}
-	else if (cur == GraphicsData.gfx_Cattack || cur == GraphicsData.gfx_Csteal || cur == GraphicsData.gfx_Cdisable || cur == GraphicsData.gfx_Cattackoor)
+	else if (cur == GraphicsData.gfx_Cattack
+			 || cur == GraphicsData.gfx_Csteal
+			 || cur == GraphicsData.gfx_Cdisable
+			 || cur == GraphicsData.gfx_Cattackoor)
 	{
-		x = -19;
-		y = -16;
+		x = 19;
+		y = 16;
 	}
 	else
 	{
@@ -175,6 +134,16 @@
 	return moved;
 }
 
+void cMouse::Show()
+{
+	SDL_ShowCursor (true);
+}
+
+void cMouse::Hide()
+{
+	SDL_ShowCursor (false);
+}
+
 // Liefert die Koordinaten der Kachel unter der Maus:
 int cMouse::getKachelX (const cGameGUI& gameGUI) const
 {
Index: mouse.h
===================================================================
--- mouse.h	(revision 3442)
+++ mouse.h	(working copy)
@@ -19,12 +19,13 @@
 #ifndef mouseH
 #define mouseH
 
-#include "autosurface.h"
 #include "defines.h"
-#include <SDL.h>
 
 class cGameGUI;
+struct SDL_Surface;
+struct SDL_Cursor;
 
+
 // Die Mauszeigertypen ///////////////////////////////////////////////////////
 enum eCursor {CHand, CNo, CSelect, CMove, CPfeil1, CPfeil2, CPfeil3, CPfeil4, CPfeil6, CPfeil7, CPfeil8, CPfeil9, CHelp, CAttack, CBand, CTransf, CLoad, CMuni, CRepair, CSteal, CDisable, CActivate, CMoveDraft, CAttackOOR};
 
@@ -33,22 +34,16 @@
 {
 public:
 	cMouse();
+	~cMouse();
 
-	void draw (bool draw_back, SDL_Surface* sf);
-
 	// Set a new cursor.
 	bool SetCursor (eCursor);
 
-	void GetBack (SDL_Surface* sf);
-	/**
-	* Draws the currently stored background to sf
-	*/
-	void restoreBack (SDL_Surface* sf);
-	void GetPos();
+	void updatePos();
 	void getCursorOffset (int& x, int& y) const;
 	bool moved();
-	void Show() {LastX = -100; visible = true;}
-	void Hide() {visible = false;}
+	void Show();
+	void Hide();
 	/**
 	* return the X Coordinate of the Cursor on the map
 	*/
@@ -57,19 +52,14 @@
 	* return the Y Coordinate of the Cursor on the map
 	*/
 	int getKachelY (const cGameGUI& gameGUI) const;
-private:
-	bool visible; // Gibt an, ob die Maus angezeigt werden soll.
+
 public:
 	SDL_Surface* cur; // Current Cursor.
 private:
-	AutoSurface back; // Zum Speichern des Maushintergrundes.
+	SDL_Cursor* sdlCursor;
 public:
 	int x, y; /** the pixel position of the cursor on the map */
 	bool isDoubleClick;
-private:
-	int prevScreenX, prevScreenY;
-	int LastX, LastY; // Die letzte Position der Maus.
-	int DrawX, DrawY; // Die Position, an die die Maus gezeichnet werden soll.
 };
 
 // Die Maus //////////////////////////////////////////////////////////////////
Index: mveplayer.cpp
===================================================================
--- mveplayer.cpp	(revision 3442)
+++ mveplayer.cpp	(working copy)
@@ -24,18 +24,19 @@
 /*	MVEPlayer.c - Plays 8-bit Interplay MVE multimedia files.
 	Author: jarli
 */
-#include "autosurface.h"
+
 #include "mveplayer.h"
-#include <assert.h>
+
 #include "main.h"
+#include "autoptr.h"
+#include "autosurface.h"
 #include "video.h"
 
-#ifdef _MSC_VER
 #include <SDL.h>
-#else
-#include <SDL.h>
-#endif
 
+#include <cassert>
+#include <vector>
+
 /* define (potentially) handled opcode types */
 #define STOP_PLAYBACK			0x00
 #define FETCH_NEXT_CHUNK		0x01
@@ -50,6 +51,13 @@
 #define SET_DECODING_MAP		0x0F
 #define VIDEO_DATA				0x11
 
+#if 1 // TODO: [SDL2]: SDL_SetColors
+inline void SDL_SetColors(SDL_Surface* surface, SDL_Color* colors, int index, int size)
+{
+	SDL_SetPaletteColors(surface->format->palette, colors, index, size);
+}
+#endif
+
 /**************************/
 /* internally used macros */
 /**************************/
@@ -61,24 +69,23 @@
 /* internally used structures */
 /******************************/
 
-typedef struct CHUNK
+struct chunk
 {
 	Uint16 length;
 	Uint16 type;
-} chunk;
+};
 
-typedef struct OPCODE
+struct opcode
 {
 	Uint16 length;
 	Uint8 type;
 	Uint8 version;
-} opcode;
+};
 
-typedef struct BUFSTRUCT
+struct mvebuffer
 {
-	Uint32 length;
-	Uint8* data;
-} mvebuffer;
+	std::vector<Uint8> data;
+};
 
 /********************/
 /* global variables */
@@ -85,19 +92,26 @@
 /********************/
 
 /* flow control flags */
-Uint8 QUITTING = 0, PAUSED = 0;
+static Uint8 QUITTING = 0;
+static Uint8 PAUSED = 0;
 
 /* timer flags */
-Uint8 TIMER_CREATED	= 0, TIMER_INIT = 0;
+static Uint8 TIMER_CREATED = 0;
+static Uint8 TIMER_INIT = 0;
 
 /* audio flags */
-Uint8 AUDIO_PLAYING = 0, AUDIO_COMPRESSED = 0, AUDIO_STEREO = 0, SAMPLESIZE16 = 0;
+static Uint8 AUDIO_PLAYING = 0;
+static Uint8 AUDIO_COMPRESSED = 0;
+static Uint8 AUDIO_STEREO = 0;
+static Uint8 SAMPLESIZE16 = 0;
 
 /* screen mvebuffers */
-Uint8* v_backbuf = NULL, *frame_hot = NULL, *frame_cold = NULL;
+static std::vector<Uint8> v_backbuf;
+static Uint8* frame_hot = NULL;
+static Uint8* frame_cold = NULL;
 
 /* target time between frames */
-float ms_per_frame = 0;
+static float ms_per_frame = 0;
 
 /***********************/
 /* function prototypes */
@@ -125,22 +139,24 @@
 	char fileTestString[26];
 
 	/* timer vars */
-	Uint32 timer_rate = 0, current_time = 0;
-	Uint16 timer_subdivision = 0;
+	Uint32 current_time = 0;
 	float start_time = 0;
 
 	/* audio variables */
-	SDL_AudioSpec* desired = NULL;
+	AutoPtr<SDL_AudioSpec> desired;
 	Uint16 file_audio_flags = 0;
-	mvebuffer audio_mvebuffer, audio_data_read, temp_audio_mvebuffer;
+	mvebuffer audio_mvebuffer;
+	mvebuffer audio_data_read;
 
 	/* video variables */
 	Uint32 screen_mvebuffer_size = 0;
-	Uint16 width_blocks = 0, height_blocks = 0;
-	Uint8* map = NULL, *video = NULL, *temp = NULL;
-	SDL_Surface* screen = NULL;
-	SDL_Rect movie_screen;
-	const SDL_VideoInfo* initial_vid_state;
+	Uint16 width_blocks = 0;
+	Uint16 height_blocks = 0;
+	std::vector<Uint8> map;
+	std::vector<Uint8> video;
+	SDL_Window* sdlWindow = NULL;
+	SDL_Renderer* sdlRenderer = NULL;
+	SDL_Texture* sdlTexture = NULL;
 
 	/* file handle */
 	SDL_RWops* mve = NULL;
@@ -149,17 +165,6 @@
 	chunk ch;
 	opcode op;
 
-	/* a counting var */
-	Uint16 i = 0;
-
-	/* initialize audio mvebuffers */
-	audio_mvebuffer.data = NULL;
-	audio_mvebuffer.length = 0;
-	audio_data_read.data = NULL;
-	audio_data_read.length = 0;
-	temp_audio_mvebuffer.data = NULL;
-	temp_audio_mvebuffer.length = 0;
-
 	/******************************************/
 	/* validate MVE, init SDL, and begin read */
 	/******************************************/
@@ -172,7 +177,7 @@
 		return UNABLE_TO_OPEN_FILE;
 
 	/* read the first 26 bytes */
-	if (SDL_RWread (mve, fileTestString, sizeof (char), idlen) < 0)
+	if (!SDL_RWread (mve, fileTestString, sizeof (char), idlen))
 		return FILE_TOO_SHORT;
 
 	/* validate MVE idstring */
@@ -191,10 +196,6 @@
 	if (op.type > 0x15 || op.version > 3)
 		return MVE_CORRUPT;
 
-	//set window to center of screen
-	static char cVideoPos[] = "SDL_VIDEO_CENTERED=1";
-	putenv (cVideoPos);
-
 	/* See if SDL is already initialized by MAXR main (audio shouldn't be) */
 	if (audio)
 	{
@@ -209,10 +210,6 @@
 		if (SDL_WasInit (SDL_INIT_VIDEO | SDL_INIT_TIMER) != (SDL_INIT_VIDEO | SDL_INIT_TIMER))
 			return SDL_INIT_FAILURE;
 
-	/* save initial video state; we'll restore at the end */
-	if (!fullscreen)
-		initial_vid_state = SDL_GetVideoInfo();
-
 	// hide mouse in fullscreen
 	if (fullscreen)
 		SDL_ShowCursor (SDL_DISABLE);
@@ -241,35 +238,33 @@
 		switch (op.type)
 		{
 			case STOP_PLAYBACK:
-
+			{
 				QUITTING = !QUITTING;
-
 				break;
-
+			}
 			case FETCH_NEXT_CHUNK:
-
+			{
 				if (!SDL_RWread (mve, &ch, sizeof (ch), 1))
 					return CHUNK_READ_FAILED;
-
 				break;
-
+			}
 			case CREATE_TIMER:
-
+			{
 				/* get timer rate (uint32) */
-				timer_rate = SDL_ReadLE32 (mve);
+				const Uint32 timer_rate = SDL_ReadLE32 (mve);
 
 				/* get timer subdivision (uint16) */
-				timer_subdivision = SDL_ReadLE16 (mve);
+				const Uint16 timer_subdivision = SDL_ReadLE16 (mve);
 
-				ms_per_frame = (float) (timer_rate * timer_subdivision / 1000.0);
+				ms_per_frame = timer_rate * timer_subdivision / 1000.0f;
 
 				TIMER_CREATED = 1;
 				TIMER_INIT = 1;
 
 				break;
-
+			}
 			case INIT_AUDIO_BUFFERS:
-
+			{
 				if (!audio)
 				{
 					/* strip opcode data; don't know how to catch errors here */
@@ -277,9 +272,8 @@
 					break;
 				}
 
-
 				/* init sdl audio settings */
-				desired = (SDL_AudioSpec*) malloc (sizeof (SDL_AudioSpec));
+				desired = new SDL_AudioSpec;
 
 				/* strip the unknown word out */
 				SDL_ReadLE16 (mve);
@@ -315,8 +309,10 @@
 				if (op.version == 1)
 					AUDIO_COMPRESSED = (file_audio_flags & 0x04 ? 1 : 0);
 
-				/* we're going to abort if is compressed and (not stereo or not AUDIO_S16) because we don't know what to do */
-				/* besides, we've never seen such an MVE before... */
+				// we're going to abort if is compressed
+				// and (not stereo or not AUDIO_S16)
+				// because we don't know what to do
+				// besides, we've never seen such an MVE before...
 				if (AUDIO_COMPRESSED && (!AUDIO_STEREO || !SAMPLESIZE16))
 					return CANNOT_PROCESS_AUDIO;
 
@@ -327,9 +323,9 @@
 					SDL_ReadLE16 (mve);
 
 				break;
-
+			}
 			case START_AUDIO:
-
+			{
 				if (!audio)
 					break;
 
@@ -339,15 +335,16 @@
 					SDL_PauseAudio (0);
 				}
 				break;
-
+			}
 			case INIT_VIDEO_BUFFERS:
-
-				/* get the requested dimensions
-				note: this is in 8x8 pixel chunks so multiply by 8 to get requested screen pixels*/
+			{
+				// get the requested dimensions
+				// note: this is in 8x8 pixel chunks
+				// so multiply by 8 to get requested screen pixels
 				width_blocks = SDL_ReadLE16 (mve);
 				height_blocks = SDL_ReadLE16 (mve);
 
-				/* ditch the rest of the opcode data*/
+				// ditch the rest of the opcode data
 				if (op.version > 0)
 				{
 					SDL_ReadLE16 (mve);
@@ -362,63 +359,56 @@
 				}
 
 				/* initialize video mvebuffer to the actual movie dimensions */
-				frame_buf = SDL_CreateRGBSurface (Video.getSurfaceType(), width_blocks << 3, height_blocks << 3, 8, 0, 0, 0, 0);
+				frame_buf = SDL_CreateRGBSurface (0, width_blocks << 3, height_blocks << 3, 8, 0, 0, 0, 0);
 
 				/* init movie screen rect for fullscreen purposes */
-				movie_screen.x = (screen->w - frame_buf->w) >> 1;
-				movie_screen.y = (screen->h - frame_buf->h) >> 1;
+				//movie_screen.x = (screen->w - frame_buf->w) >> 1;
+				//movie_screen.y = (screen->h - frame_buf->h) >> 1;
 
-				/* erase old video backmvebuffer */
-				free (v_backbuf);
-
-				/* allocate memory for the backmvebuffers sufficient for the screen pixel mvebuffer */
+				// allocate memory for the backmvebuffers sufficient
+				// for the screen pixel mvebuffer
 				screen_mvebuffer_size = frame_buf->h * frame_buf->w;
 
-				v_backbuf = (Uint8*) calloc (1, screen_mvebuffer_size << 1);
-				assert (v_backbuf);
+				v_backbuf.resize (screen_mvebuffer_size << 1);
 
-				frame_hot = v_backbuf;
-				frame_cold = v_backbuf + screen_mvebuffer_size;
+				frame_hot = v_backbuf.data();
+				frame_cold = v_backbuf.data() + screen_mvebuffer_size;
 
 				break;
-
+			}
 			case SEND_BUFFER_TO_DISPLAY:
-
+			{
 				/* write the decoded data to the frame_buf */
 				memcpy (frame_buf->pixels, frame_hot, screen_mvebuffer_size);
 
-				/* send the mvebuffer to the screen mvebuffer */
-				if (SDL_MUSTLOCK (screen))
-					SDL_LockSurface (screen);
+				// TODO: [SDL2] replace SDL_CreateTextureFromSurface ?
+				sdlTexture = SDL_CreateTextureFromSurface(sdlRenderer, frame_buf);
+				//SDL_UpdateTexture(sdlTexture, NULL, frame_buf->pixels, frame_buf->pitch);
 
-				if (fullscreen)
-					SDL_SoftStretch (frame_buf, NULL, screen, NULL);
-				else
-					SDL_BlitSurface (frame_buf, NULL, screen, &movie_screen);
+				SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
 
-				if (SDL_MUSTLOCK (screen))
-					SDL_UnlockSurface (screen);
-
-				/* increment start time - this is now our target frame output time */
+				// increment start time
+				// this is now our target frame output time
 				start_time += ms_per_frame;
 
 				/* what time is it now? */
 				current_time = SDL_GetTicks();
 
-				/* if there's time to next scheduled update, force delay to our target output time */
+				// if there's time to next scheduled update,
+				// force delay to our target output time
 				if (current_time < start_time)
 					SDL_Delay ( (Uint32) (start_time - current_time));
 
 				/* update the screen */
-				SDL_UpdateRect (screen, 0, 0, 0, 0);
+				SDL_RenderPresent(sdlRenderer);
 
 				/* strip opcode data; don't know how to catch errors here */
 				mve->seek (mve, op.length, SEEK_CUR);
 
 				break;
-
+			}
 			case AUDIO_FRAME:
-
+			{
 				if (!audio)
 				{
 					/* strip opcode data; don't know how to catch errors here */
@@ -430,18 +420,22 @@
 				SDL_ReadLE16 (mve);
 				SDL_ReadLE16 (mve);
 
-				/* lock SDL out of the audio_mvebuffer; we'll release at the end */
+				// lock SDL out of the audio_mvebuffer;
+				// we'll release at the end
 				SDL_LockAudio();
 
 				if (AUDIO_COMPRESSED)
 				{
-					/* send in the raw data via audio_data_read; it will be returned the same way */
-					/* read in the compressed data (should be op.length - 4 [the 4 being seq-index and stream-mask]) */
-					audio_data_read.length =  op.length - 4;
-					audio_data_read.data = (Uint8*) malloc (audio_data_read.length);
-					assert (audio_data_read.data != NULL);
+					// send in the raw data via audio_data_read;
+					// it will be returned the same way
 
-					if (SDL_RWread (mve, audio_data_read.data, audio_data_read.length, 1) < 0)
+					// read in the compressed data
+					// (should be op.length - 4
+					//  [the 4 being seq-index and stream-mask])
+					const Uint32 length = op.length - 4;
+					audio_data_read.data.resize(length);
+
+					if (!SDL_RWread (mve, audio_data_read.data.data(), length, 1))
 						return AUDIO_FRAME_READ_FAILURE;
 					MVEPlayerDecodeAudio (&audio_data_read);
 				}
@@ -448,84 +442,96 @@
 				else
 				{
 					/* get the stream length */
-					audio_data_read.length = SDL_ReadLE16 (mve);
+					const Uint32 length = SDL_ReadLE16 (mve);
 
 					/* allocate memory sufficient for the data read */
-					audio_data_read.data = (Uint8*) malloc (audio_data_read.length);
-					assert (audio_data_read.data != NULL);
+					audio_data_read.data.resize (length);
 
 					/* get audio data */
-					if (SDL_RWread (mve, audio_data_read.data, audio_data_read.length, 1) < 0)
+					if (!SDL_RWread (mve, audio_data_read.data.data(), length, 1))
 						return AUDIO_FRAME_READ_FAILURE;
 				}
-				/* at this point, we have uncompressed audio in audio_data_read, along with appropriate lengths */
+				// at this point, we have uncompressed audio in audio_data_read,
+				// along with appropriate lengths
 
-				/* create temp_audio_mvebuffer the size of old audio mvebuffer + new audio data */
-				temp_audio_mvebuffer.length = audio_data_read.length + audio_mvebuffer.length;
-				temp_audio_mvebuffer.data = (Uint8*) malloc (temp_audio_mvebuffer.length);
-				assert (temp_audio_mvebuffer.data != NULL);
+				// create temp_audio_mvebuffer
+				// the size of old audio mvebuffer + new audio data
+				mvebuffer temp_audio_mvebuffer;
+				temp_audio_mvebuffer.data.resize (audio_data_read.data.size() + audio_mvebuffer.data.size());
 
 				/* copy old audio mvebuffer to temp_audio_mvebuffer */
-				memcpy (temp_audio_mvebuffer.data, audio_mvebuffer.data, audio_mvebuffer.length);
+				std::copy(audio_mvebuffer.data.begin(), audio_mvebuffer.data.end(),
+						  temp_audio_mvebuffer.data.begin());
 
 				/* append new data to temp_audio_mvebuffer */
-				memcpy (temp_audio_mvebuffer.data + audio_mvebuffer.length, audio_data_read.data, audio_data_read.length);
+				std::copy (audio_data_read.data.begin(), audio_data_read.data.end(),
+						   temp_audio_mvebuffer.data.begin() + audio_mvebuffer.data.size());
 
-				/* free audio mvebuffer */
-				free (audio_mvebuffer.data);
-
-				/* temp_audio_mvebuffer has the requested data, and audio_mvebuffer needs to have it. */
+				// temp_audio_mvebuffer has the requested data,
+				// and audio_mvebuffer needs to have it.
 				audio_mvebuffer.data = temp_audio_mvebuffer.data;
-				audio_mvebuffer.length = temp_audio_mvebuffer.length;
 
 				/* let SDL have access to the audio_mvebuffer */
 				SDL_UnlockAudio();
 
 				/* close off temp_audio_mvebuffer */
-				temp_audio_mvebuffer.data = NULL;
-				temp_audio_mvebuffer.length = 0;
+				temp_audio_mvebuffer.data.clear();
 
 				/* close off audio_data_read */
-				free (audio_data_read.data);
-				audio_data_read.data = NULL;
-				audio_data_read.length = 0;
+				audio_data_read.data.clear();
 
 				break;
-
+			}
 			case INIT_VIDEO_MODE:
-				/* Skip unused width and height. */
-				SDL_ReadLE16 (mve);
-				SDL_ReadLE16 (mve);
+			{
+				/*const Uint16 width =*/ SDL_ReadLE16 (mve);
+				/*onst Uint16 height =*/ SDL_ReadLE16 (mve);
 
 				/* if we've been here before */
-				if (screen)
-					SDL_FreeSurface (screen);
+				if (sdlTexture) SDL_DestroyTexture (sdlTexture);
+				if (sdlRenderer) SDL_DestroyRenderer (sdlRenderer);
+				if (sdlWindow) SDL_DestroyWindow (sdlWindow);
 
 				if (fullscreen)
-					screen = SDL_SetVideoMode (dwidth, dheight, 8, Video.getSurfaceType() | SDL_FULLSCREEN);
+				{
+					sdlWindow = SDL_CreateWindow("Video",
+												 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+												 0, 0,
+												 SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN_DESKTOP);
+				}
 				else
-					screen = SDL_SetVideoMode (dwidth, dheight, 8, Video.getSurfaceType());
+				{
+					sdlWindow = SDL_CreateWindow("Video",
+												 SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+												 dwidth, dheight,
+												 SDL_WINDOW_OPENGL);
+					SDL_SetWindowIcon (sdlWindow, AutoSurface (SDL_LoadBMP (MAXR_ICON)));
+				}
+				sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
+				//sdlTexture = SDL_CreateTexture(sdlRenderer,
+				//							   SDL_PIXELFORMAT_INDEX4MSB,
+				//							   SDL_TEXTUREACCESS_STREAMING,
+				//							   width, height);
 
-				//SDL_WM_SetCaption(filename, NULL);
-
 				/* strip unknown flag word */
 				SDL_ReadLE16 (mve);
 
 				break;
-
+			}
 			case SET_PALETTE:
 			{
-				Uint8 r = 0, g = 0, b = 0;
-				Uint16 palette_start = 0, numPalColors = 0;
+				Uint8 r = 0;
+				Uint8 g = 0;
+				Uint8 b = 0;
 
 				/* get # of first entry to fill */
-				palette_start = SDL_ReadLE16 (mve);
+				const Uint16 palette_start = SDL_ReadLE16 (mve);
 
 				/* get number of entries in palette */
-				numPalColors = SDL_ReadLE16 (mve);
+				const Uint16 numPalColors = SDL_ReadLE16 (mve);
 
 				/* fill the palette */
-				for (i = 0; i < 256; i++)
+				for (int i = 0; i < 256; i++)
 				{
 					if (i < palette_start)
 					{
@@ -540,7 +546,8 @@
 						SDL_RWread (mve, &r, sizeof (Uint8), 1);
 						SDL_RWread (mve, &g, sizeof (Uint8), 1);
 						SDL_RWread (mve, &b, sizeof (Uint8), 1);
-						/* interplay divides the palette entries by 4; must multiply by 4. */
+						// interplay divides the palette entries by 4;
+						// must multiply by 4.
 						r <<= 2;
 						g <<= 2;
 						b <<= 2;
@@ -548,51 +555,38 @@
 					frame_buf->format->palette->colors[i].r = r;
 					frame_buf->format->palette->colors[i].g = g;
 					frame_buf->format->palette->colors[i].b = b;
-					frame_buf->format->palette->colors[i].unused = 0;
+					frame_buf->format->palette->colors[i].a = 255;
 				}
 
 				/* install the palette in the screen surface */
-				SDL_SetColors (screen, frame_buf->format->palette->colors, 0, 256);
-
+				break;
 			}
-
-			break;
-
 			case SET_DECODING_MAP:
-
-				/* kill previous map */
-				free (map);
-
+			{
 				/* get new map */
-				map = (Uint8*) malloc (sizeof (Uint8) * op.length);
-				assert (map != NULL);
-				SDL_RWread (mve, map, op.length, 1);
+				map.resize (op.length);
+				SDL_RWread (mve, map.data(), op.length, 1);
 				break;
-
+			}
 			case VIDEO_DATA:
-
-				/* free the previously allocated video data array */
-				free (video);
-
+			{
 				/* allocate enough memory for the video data array */
-				video = (Uint8*) malloc (op.length);
-				assert (video != NULL);
+				video.resize (op.length);
 
-				/* swap the frames so we draw next on the frame that was onscreen 1 frame ago */
-				temp = frame_cold;
-				frame_cold = frame_hot;
-				frame_hot = temp;
+				// swap the frames so we draw next on the frame
+				// that was onscreen 1 frame ago */
+				std::swap (frame_cold, frame_hot);
 
 				/* read the data */
-				SDL_RWread (mve, video, op.length, 1);
+				SDL_RWread (mve, video.data(), op.length, 1);
 
 				/* decode the video data and update the frame_hot pixel data */
-				MVEPlayerDecodeVideo (width_blocks, height_blocks, video, map);
+				MVEPlayerDecodeVideo (width_blocks, height_blocks, video.data(), map.data());
 
 				break;
-
+			}
 			default:
-
+			{
 				/* are opcode parameters within known bounds? */
 				if (op.type > 0x15 || op.version > 3)
 					return MVE_CORRUPT;
@@ -601,6 +595,7 @@
 				mve->seek (mve, op.length, SEEK_CUR);
 
 				break;
+			}
 		}
 
 		/************************/
@@ -610,7 +605,6 @@
 		/* read opcode (trailing read) */
 		if (!SDL_RWread (mve, &op, sizeof (op), 1))
 			return OPCODE_READ_FAILED;
-
 	}
 	/***********/
 	/* cleanup */
@@ -624,37 +618,16 @@
 			SDL_PauseAudio (1);
 			SDL_CloseAudio();
 		}
-
-		/* free audio mvebuffers */
-		free (audio_mvebuffer.data);
-
-		free (audio_data_read.data);
-
-		free (temp_audio_mvebuffer.data);
-
-		/* free the audio_spec */
-		free (desired);
 	}
 
-	/* free the decoding map */
-	free (map);
-
-	/* free the video data */
-	free (video);
-
-	/* free the video mvebuffers */
-	free (v_backbuf);
-
-	if (screen)
-		SDL_FreeSurface (screen);
-
 	/* close the file handle */
 	if (mve)
 		SDL_RWclose (mve);
 
 	/* reset video mode to original */
-	if (!fullscreen)
-		SDL_SetVideoMode (initial_vid_state->current_w, initial_vid_state->current_h, initial_vid_state->vfmt->BitsPerPixel, SDL_ANYFORMAT);
+	if (sdlTexture) SDL_DestroyTexture (sdlTexture);
+	if (sdlRenderer) SDL_DestroyRenderer (sdlRenderer);
+	if (sdlWindow) SDL_DestroyWindow (sdlWindow);
 
 	/* seems to have worked. */
 	return SUCCESS;
@@ -666,41 +639,11 @@
 
 void MVEPlayerAudioCB (void* userdata, Uint8* stream, int len)
 {
-	Uint8* temp;
 	mvebuffer* audio_mvebuffer = reinterpret_cast<mvebuffer*> (userdata);
 
-	if ( (Uint32) len > audio_mvebuffer->length)
-	{
-		/* give SDL what we have */
-		memcpy (stream, audio_mvebuffer->data, audio_mvebuffer->length);
-		/* and now we have nothing */
-		audio_mvebuffer->length = 0;
-	}
-	else
-	{
-		/* copy len bytes to stream */
-		memcpy (stream, audio_mvebuffer->data, len);
-
-		/* our mvebuffer length is now whatever we started with minus len */
-		audio_mvebuffer->length -= len;
-
-		/* now we need to store the data that wasn't read */
-		temp = (Uint8*) malloc (audio_mvebuffer->length);
-		assert (temp != NULL);
-
-		/* copy from data address + len length bytes
-		(which should be the start of the data that wasn't copied to stream) */
-		memcpy (temp, audio_mvebuffer->data + len, audio_mvebuffer->length);
-
-		/* free the memory of the audio_mvebuffer */
-		free (audio_mvebuffer->data);
-
-		/* assign the address of our stored data to the audio_mvebuffer's data */
-		audio_mvebuffer->data = temp;
-
-		/* close off temp */
-		temp = NULL;
-	}
+	len = std::min<size_t>(len, audio_mvebuffer->data.size());
+	std::copy(audio_mvebuffer->data.begin(), audio_mvebuffer->data.begin() + len, stream);
+	audio_mvebuffer->data.erase(audio_mvebuffer->data.begin(), audio_mvebuffer->data.begin() + len);
 }
 
 /* Interplay DPCM table */
@@ -732,43 +675,40 @@
 	/* this only works for stereo dpcm at present */
 
 	Sint16 sample[2];
-	Uint16 in_pos = 0, out_pos = 0;
+	Uint16 in_pos = 0;
+	Uint16 out_pos = 0;
 	Uint8 channel = 0;
 	mvebuffer out;
 
 	/* in->data includes initial stream-len word */
 	/* uncompressed streamlen is stream-len bytes */
-	out.length = LE16 (in->data);
+	out.data.resize (LE16 (in->data.data()));
 	in_pos += 2;
-	out.data = (Uint8*) malloc (out.length);
-	assert (out.data != NULL);
 
-	/* each byte in the input mvebuffer after the first four (two words: initial L and R values)
-	will be expanded to fill a word in the return mvebuffer after decompression.
-	The initial two words will be stored in return mvebuffer as-is. */
-	sample[0] = LE16 (in->data + in_pos);
+	// each byte in the input mvebuffer after the first four
+	// (two words: initial L and R values)
+	// will be expanded to fill a word
+	// in the return mvebuffer after decompression.
+	// The initial two words will be stored in return mvebuffer as-is.
+	sample[0] = LE16 (in->data.data() + in_pos);
 	in_pos += 2;
-	* (Sint16*) (out.data + out_pos) = sample[0];
+	* (Sint16*) (out.data.data() + out_pos) = sample[0];
 	out_pos += 2;
-	sample[1] = LE16 (in->data + in_pos);
+	sample[1] = LE16 (in->data.data() + in_pos);
 	in_pos += 2;
-	* (Sint16*) (out.data + out_pos) = sample[1];
+	* (Sint16*) (out.data.data() + out_pos) = sample[1];
 	out_pos += 2;
 
-	while (in_pos < in->length)
+	while (in_pos < in->data.size())
 	{
-		sample[channel] += interplay_delta_table[* (in->data + in_pos++)];
-		* (Sint16*) (out.data + out_pos) = sample[channel];
+		sample[channel] += interplay_delta_table[* (in->data.data() + in_pos++)];
+		* (Sint16*) (out.data.data() + out_pos) = sample[channel];
 		out_pos += 2;
 		channel = !channel;
 	}
 
-	/* free the original mvebuffer*/
-	free (in->data);
-
 	/* assign the incoming mvebuffer the outgoing data for return */
-	in->data = out.data;
-	in->length = out.length;
+	std::swap(in->data, out.data);
 }
 
 /**************************************/
@@ -776,40 +716,46 @@
 /**************************************/
 void MVEPlayerDecodeVideo (Uint16 wblocks, Uint16 hblocks, Uint8* pData, Uint8* pMap)
 {
-	Uint8 encoding = 0, *map = NULL, *data = NULL, *new_frame = NULL, *current = NULL, *temp = NULL;
-	Uint16 pitch = 0;
-	Sint32 x, y, i, j;
+	Uint8 encoding = 0, *new_frame = NULL, *current = NULL, *temp = NULL;
+	Uint8* map = pMap;
 
-	map = pMap;
-
 	/* there are 14 undocumented bytes at head of video stream */
-	data = pData + 14;
+	Uint8* data = pData + 14;
 
-	pitch = wblocks << 3;
+	Uint16 pitch = wblocks << 3;
 
 	/* for each row (of 8x8 pixel blocks) */
-	for (y = 0; y < hblocks; y++)
+	for (Sint16 y = 0; y < hblocks; y++)
 	{
 		/* for each column (of 8x8 pixel blocks) */
-		for (x = 0; x < wblocks; x++)
+		for (Sint16 x = 0; x < wblocks; x++)
 		{
-			/* assign the frame mvebuffer pointers to the addresses of the screen
-			mvebuffers so we can do pointer arithmetic on them such as incrementing.
-			current is the frame currently onscreen; new_frame is the frame under construction. */
+			// assign the frame mvebuffer pointers
+			// to the addresses of the screen
+			// mvebuffers so we can do pointer arithmetic on them
+			// such as incrementing.
+			// current is the frame currently onscreen;
+			// new_frame is the frame under construction.
 
 			new_frame = frame_hot;
 			current = frame_cold;
 
-			/* increment pixel pointer past the rendered area on the screen
-			y = number of rows, wblocks = number of blocks per row, 8 * 8 = pixel area of the block;
-			y * wblocks * 8 * 8 = all the complete rows of 8x8 pixel blocks rendered.
-			x * 8 = upper left pixel of the 8x8 block in this new row to be rendered at this time.
-			I felt like replacing the multiplications throughout this function with shift operations. */
+			// increment pixel pointer past the rendered area on the screen
+			// y = number of rows,
+			// wblocks = number of blocks per row,
+			// 8 * 8 = pixel area of the block;
+			// y * wblocks * 8 * 8 = all the complete rows
+			//  of 8x8 pixel blocks rendered.
+			// x * 8 = upper left pixel of the 8x8 block
+			// in this new row to be rendered at this time.
+			// I felt like replacing the multiplications
+			// throughout this function with shift operations.
 
 			new_frame += (y * wblocks << 6) + (x << 3);
 			current += (y * wblocks << 6) + (x << 3);
 
-			/* get the decoding map info for this block; low 4 bits if x is even, high 4 bits if x is odd */
+			// get the decoding map info for this block;
+			// low 4 bits if x is even, high 4 bits if x is odd
 			encoding = (*map >> ( (x & 1) << 2)) & 0x0f;
 
 			/* if x is odd, increment the decoding map */
@@ -820,7 +766,7 @@
 			{
 				case 0x0:
 
-					for (j = 0; j < 8; j++)
+					for (int j = 0; j < 8; j++)
 					{
 						memcpy (new_frame + j * pitch, current + j * pitch, 8);
 					}
@@ -832,6 +778,8 @@
 					break;
 
 				case 0x2:
+				{
+					Sint32 i, j;
 
 					temp = new_frame;
 					if (*data < 56)
@@ -848,15 +796,16 @@
 
 					temp += j * pitch + i;
 
-					for (j = 0; j < 8; j++)
+					for (int j = 0; j < 8; j++)
 					{
 						memcpy (new_frame + j * pitch, temp + j * pitch, 8);
 					}
 
 					break;
-
+				}
 				case 0x3:
-
+				{
+					Sint32 i, j;
 					temp = new_frame;
 					if (*data < 56)
 					{
@@ -872,40 +821,40 @@
 
 					temp += j * pitch + i;
 
-					for (j = 0; j < 8; j++)
+					for (int j = 0; j < 8; j++)
 					{
 						memcpy (new_frame + j * pitch, temp + j * pitch, 8);
 					}
 
 					break;
-
+				}
 				case 0x4:
-
-					i = -8 + (*data & 0xF);
-					j = -8 + (*data >> 4);
+				{
+					Sint32 i = -8 + (*data & 0xF);
+					Sint32 j = -8 + (*data >> 4);
 					data++;
 
 					current += j * pitch + i;
 
-					for (j = 0; j < 8; j++)
+					for (int j = 0; j < 8; j++)
 					{
 						memcpy (new_frame + j * pitch, current + j * pitch, 8);
 					}
 
 					break;
-
+				}
 				case 0x5:
-
+				{
 					current += (Sint8) data[1] * pitch + (Sint8) data[0];
 					data += 2;
 
-					for (j = 0; j < 8; j++)
+					for (int j = 0; j < 8; j++)
 					{
 						memcpy (new_frame + j * pitch, current + j * pitch, 8);
 					}
 
 					break;
-
+				}
 				case 0x6:
 
 					x += 2;
@@ -925,13 +874,13 @@
 
 					if (p[0] <= p[1])
 					{
-						for (i = 0; i < 8; i++)
+						for (int i = 0; i < 8; i++)
 						{
 							b[i] = *data++;
 						}
-						for (j = 0; j < 8; j++)
+						for (int j = 0; j < 8; j++)
 						{
-							for (i = 0, mask = 1; i < 8; i++, mask <<= 1)
+							for (int i = 0, mask = 1; i < 8; i++, mask <<= 1)
 							{
 								new_frame[i] = p[!! (b[j] & mask)];
 							}
@@ -943,11 +892,11 @@
 						b[0] = *data++;
 						b[1] = *data++;
 
-						for (j = 0; j < 4; j++)
+						for (int j = 0; j < 4; j++)
 						{
 							if (! (j % 2))
 								mask = 0x01;
-							for (i = 0; i < 4; i++, mask <<= 1)
+							for (int i = 0; i < 4; i++, mask <<= 1)
 							{
 								new_frame[i << 1] =
 									new_frame[ (i << 1) + 1] =
@@ -963,22 +912,22 @@
 
 				case 0x8:
 				{
-					Uint8 p[8], b[8], mask = 1, k;
+					Uint8 p[8], b[8], mask = 1;
 					if (data[0] <= data[1])
 					{
-						for (j = 0; j < 4; j++)
+						for (int j = 0; j < 4; j++)
 						{
-							for (i = 0; i < 2; i++)
+							for (int i = 0; i < 2; i++)
 							{
 								p[i + (j << 1)] = *data++;
 							}
-							for (i = 0; i < 2; i++)
+							for (int i = 0; i < 2; i++)
 							{
 								b[i + (j << 1)] = *data++;
 							}
 						}
 
-						for (k = 0; k < 4; k++)
+						for (int k = 0; k < 4; k++)
 						{
 							if (k == 2)
 							{
@@ -985,11 +934,11 @@
 								new_frame -= pitch << 3;
 								new_frame += 4;
 							}
-							for (j = 0; j < 4; j++)
+							for (int j = 0; j < 4; j++)
 							{
 								if (! (j & 1))
 									mask = 1;
-								for (i = 0; i < 4; i++)
+								for (int i = 0; i < 4; i++)
 								{
 									new_frame[i] = p[!! (b[ (j >> 1) + (k << 1)] & mask) + (k << 1)];
 									mask <<= 1;
@@ -1000,13 +949,13 @@
 					} /* if p0 <= p1 */
 					else
 					{
-						for (j = 0; j < 2; j++)
+						for (int j = 0; j < 2; j++)
 						{
-							for (i = 0; i < 2; i++)
+							for (int i = 0; i < 2; i++)
 							{
 								p[ (j << 1) + i] = *data++;
 							}
-							for (i = 0; i < 4; i++)
+							for (int i = 0; i < 4; i++)
 							{
 								b[ (j << 2) + i] = *data++;
 							}
@@ -1014,9 +963,9 @@
 						if (p[2] > p[3])
 						{
 							/* horizontally split block */
-							for (j = 0; j < 8; j++)
+							for (int j = 0; j < 8; j++)
 							{
-								for (i = 0, mask = 1; i < 8; i++, mask <<= 1)
+								for (int i = 0, mask = 1; i < 8; i++, mask <<= 1)
 								{
 									new_frame[i] = p[!! (b[j] & mask) + (j > 3 ? 2 : 0)];
 								}
@@ -1026,7 +975,7 @@
 						else
 						{
 							/* vertically split block */
-							for (k = 0; k < 2; k++)
+							for (int k = 0; k < 2; k++)
 							{
 								if (k == 1)
 								{
@@ -1033,10 +982,10 @@
 									new_frame -= pitch << 3;
 									new_frame += 4;
 								}
-								for (j = 0; j < 4; j++)
+								for (int j = 0; j < 4; j++)
 								{
 									mask = 1;
-									for (i = 0; i < 8; i++)
+									for (int i = 0; i < 8; i++)
 									{
 										new_frame[i % 4] = p[!! (b[j + (k << 2)] & mask) + (k << 1)];
 										mask <<= 1;
@@ -1055,20 +1004,20 @@
 				case 0x9:
 				{
 					Uint8 p[4], b[16];
-					for (i = 0; i < 4; i++)
+					for (int i = 0; i < 4; i++)
 					{
 						p[i] = *data++;
 					}
 					if (p[0] <= p[1] && p[2] <= p[3])
 					{
-						Uint16 mask;
-						for (i = 0; i < 16; i++)
+						for (int i = 0; i < 16; i++)
 						{
 							b[i] = *data++;
 						}
-						for (j = 0; j < 8; j++)
+						for (int j = 0; j < 8; j++)
 						{
-							for (i = 0, mask = 3; i < 8; i++, mask <<= 2)
+
+							for (Uint16 i = 0, mask = 3; i < 8; i++, mask <<= 2)
 							{
 								new_frame[i] = p[ (mask & (b[ (j << 1) + 1] << 8 | b[j << 1])) >> (i << 1)];
 							}
@@ -1078,14 +1027,14 @@
 					if (p[0] <= p[1] && p[2] > p[3])
 					{
 						Uint8 mask;
-						for (i = 0; i < 4; i++)
+						for (int i = 0; i < 4; i++)
 						{
 							b[i] = *data++;
 						}
-						for (j = 0; j < 8; j++)
+						for (int j = 0; j < 8; j++)
 						{
 							mask = 3;
-							for (i = 0; i < 8; i++)
+							for (int i = 0; i < 8; i++)
 							{
 								new_frame[i] = p[ (b[j >> 1] & mask) >> ( (i >> 1) << 1)];
 								if (i & 1)
@@ -1097,14 +1046,14 @@
 					if (p[0] > p[1] && p[2] <= p[3])
 					{
 						Uint8 mask;
-						for (i = 0; i < 8; i++)
+						for (int i = 0; i < 8; i++)
 						{
 							b[i] = *data++;
 						}
-						for (j = 0; j < 8; j++)
+						for (int j = 0; j < 8; j++)
 						{
 							mask = 3;
-							for (i = 0; i < 8; i++)
+							for (int i = 0; i < 8; i++)
 							{
 								new_frame[i] = p[ (b[j] & mask) >> ( (i >> 1) << 1)];
 								if (i & 1)
@@ -1116,14 +1065,14 @@
 					if (p[0] > p[1] && p[2] > p[3])
 					{
 						Uint16 mask;
-						for (i = 0; i < 8; i++)
+						for (int i = 0; i < 8; i++)
 						{
 							b[i] = *data++;
 						}
-						for (j = 0; j < 4; j++)
+						for (int j = 0; j < 4; j++)
 						{
 							mask = 3;
-							for (i = 0; i < 8; i++)
+							for (int i = 0; i < 8; i++)
 							{
 								new_frame[i] =
 									new_frame[i + pitch] = p[ ( (b[ (j << 1) + 1] << 8 | b[j << 1]) & mask) >> (i << 1)];
@@ -1138,25 +1087,25 @@
 
 				case 0xA:
 				{
-					Uint8 p[16], b[16], mask, k;
+					Uint8 p[16], b[16];
 					if (data[0] <= data[1])
 					{
-						for (i = 0; i < 4; i++)
+						for (int i = 0; i < 4; i++)
 						{
-							for (j = 0; j < 4; j++)
+							for (int j = 0; j < 4; j++)
 							{
 								p[ (i << 2) + j] = *data++;
 							}
-							for (j = 0; j < 4; j++)
+							for (int j = 0; j < 4; j++)
 							{
 								b[ (i << 2) + j] = *data++;
 							}
 						}
-						for (k = 0; k < 4; k++)
+						for (int k = 0; k < 4; k++)
 						{
-							for (j = 0; j < 4; j++)
+							for (int j = 0; j < 4; j++)
 							{
-								for (i = 0, mask = 3