summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/SOURCES (follow)
Commit message (Expand)AuthorAge
* Pluginlib: Add support for general buttons. Add menu and quit buttons to Rev...Karl Kurbjun2009-08-02
* FS#10080Nils Wallménius2009-07-14
* Revert "Consolidate all fixed point math routines in one library (FS#10400) b...Maurus Cuelenaere2009-07-04
* Consolidate all fixed point math routines in one library (FS#10400) by Jeffre...Maurus Cuelenaere2009-07-04
* FS#10099: new lib, which displays formatted text on every target; also suppor...Johannes Schwarz2009-06-28
* Core JPEG decoder improvements:Andrew Mahone2009-06-19
* Accept FS#10094 by Teruaki Kawashima:Jonathan Gordon2009-06-16
* Add Bob Jenkins' lookup3 32-bit and 64-bit hashes to pluginlib.Andrew Mahone2009-06-01
* Plugin JPEG decoder for data in memory, along with test_mem_jpeg.c and bench_...Andrew Mahone2009-05-08
* Fix red on PlayerAndrew Mahone2009-05-04
* Make JPEG and BMP scaler optional with HAVE_JPEG and HAVE_BMP_SCALING, both d...Andrew Mahone2009-05-04
* Add read_<image>_fd functions to plugin API, add feature_wrappers.h handling ...Andrew Mahone2009-05-02
* Add read_jpeg_* to feature_wrappers.h, add import-from-core for jpeg_load.c o...Andrew Mahone2009-05-02
* Add exit() implementation for pluginsMaurus Cuelenaere2009-04-22
* FS#9916 buflib plugin memory allocatorAndrew Mahone2009-03-04
* remove MEM_FUNCTION_WRAPPERS, and private mem* implementations from plugins, ...Andrew Mahone2009-01-24
* fix yellow - don't build pluginlib_albumart.c on non-bitmap targetsAndrew Mahone2009-01-24
* albumart search in pluginlib when building without HAVE_ALBUMART (for later u...Andrew Mahone2009-01-24
* Include divide-by-zero handling within plugins and codecs for ARM processors.Michael Sevakis2009-01-24
* Added missing dependencies for codeclib and pluginlib. This required renaming...Björn Stenberg2009-01-12
* remove unneeded LCD_DEPTH test in lib/resize.h, add some comments explaining ...Andrew Mahone2009-01-08
* cleanup for core-file-in-pluginlib compilation:Andrew Mahone2009-01-08
* build a scaling-enabled bitmap loader in pluginlib for mono bitmap targets, a...Andrew Mahone2009-01-04
* Commit FS#9308: differentiate between TOUCHPAD & TOUCHSCREENMaurus Cuelenaere2008-08-23
* New md5sum plugin. Open a file, a directory or just launch it from the plugin...Antoine Cellerier2008-06-10
* 1) Implement generic touchscreen detection library for the pluginsMaurus Cuelenaere2008-06-06
* Oops. Fix red.Nicolas Pennequin2008-04-06
* Commit FS#8308 (Port of imlib2 based smooth scaling) by Jonas Hurrelmann. It ...Nicolas Pennequin2008-04-06
* iAudio M3: Optimised LCD driver, with more/better assembly code. Speedup is ~...Jens Arnold2008-03-25
* Revert accidental tree commit. /me needs a smaller enter key...Jens Arnold2008-03-25
* Cabbiev2 gigabeat background: reduce WPS backdrop filesize by storing it as 2...Jens Arnold2008-03-25
* Adapt most single-file plugins to the M3 keypad and screen. It's still prelim...Jens Arnold2008-03-22
* Greyscale library: Assembler optimised update function for SH1 (Archos record...Jens Arnold2008-03-05
* Greyscale library: Assembler optimised update for coldfire, ~73% speedup when...Jens Arnold2008-03-02
* Accept FS#7218 by Dave Hooper: Bitmap version of the sliding puzzle game.Nicolas Pennequin2008-01-26
* The old grayscale library is now officially dead.Jens Arnold2008-01-13
* All-new greyscale library, replacing the old one. Features: (1) Drawing/updat...Jens Arnold2008-01-04
* Also keep the backlight on in mpegplayer when plugged in. Fixes FS #7584. Cre...Peter D'Hoye2007-08-13
* Rewrote the clock plugin in a cleaner and more modular way so that it can sca...Kevin Ferrare2007-08-04
* Move the old api out of the core and into the plugin lib.Jonathan Gordon2007-05-08
* Beginnings of a fixed point math library for use in plugins. fsincos() only f...Jens Arnold2006-12-10
* * Move checkbox to plugin api (core never uses it)Jonathan Gordon2006-11-19
* implement actions in the plugins, bubbles and metronome converted.Jonathan Gordon2006-11-16
* Grayscale library ported to the grayscale iPods, first version. Added C refer...Jens Arnold2006-08-07
* Lib to save a bitmap struct to a bmp file. Only works/tested with color bitmaps.Antoine Cellerier2006-07-19
* RGB <-> HSV colorspace conversion libAntoine Cellerier2006-07-19
* Basic plugin playback control menu by Jonathan Gordon (Patch #4874)Linus Nielsen Feltzing2006-03-26
* LCD extension library: Implemented scrolling for LCD depths below 8 bit. * Os...Jens Arnold2006-03-08
* Finally - grayscale library support for the simulators. Currently SDL only, w...Jens Arnold2006-02-26
* Made the overlay loader code part of the plugin library.Jens Arnold2006-02-23
479'>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 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Pacbox - a Pacman Emulator for Rockbox
 *
 * Based on PIE - Pacman Instructional Emulator
 *
 * Copyright (c) 1997-2003,2004 Alessandro Scotti
 * http://www.ascotti.org/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include "plugin.h"
#include "hardware.h"
#include "z80.h"
#include "z80_internal.h"

// Table with parity, sign and zero flags precomputed for each byte value
unsigned char PSZ_[256] IDATA_ATTR = {
    Zero|Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, 
    0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, 
    0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, 
    Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, 
    0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, 
    Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, 
    Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, 
    0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, 
    Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, 
    Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, 
    Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, 
    Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, 
    Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, 
    Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, 
    Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, 
    Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity
};

// Interrupt flags
enum {
    IFF1    = 0x40,     // Interrupts enabled/disabled
    IFF2    = 0x20,     // Copy of IFF1 (used by non-maskable interrupts)
    Halted  = 0x10      // Internal use: signals that the CPU is halted
};

// Implements an opcode
typedef void (OpcodeHandler)(void);

typedef struct {
    OpcodeHandler*   handler;
    unsigned        cycles;
} OpcodeInfo;

// Implements an opcode for instructions that use the form (IX/IY + b)
typedef void (OpcodeHandlerXY)( unsigned );

typedef struct {
    OpcodeHandlerXY* handler;
    unsigned        cycles;
} OpcodeInfoXY;

/** */
void do_opcode_xy( OpcodeInfo * );

/** */
unsigned do_opcode_xycb( unsigned xy );

unsigned    iflags_ IBSS_ATTR;    // Interrupt mode (bits 0 and 1) and flags
unsigned    cycles_ IBSS_ATTR;    // Number of CPU cycles elapsed so far


// Registers
unsigned char   B  IBSS_ATTR;     //@- B register
unsigned char   C  IBSS_ATTR;     //@- C register
unsigned char   D  IBSS_ATTR;     //@- D register
unsigned char   E  IBSS_ATTR;     //@- E register
unsigned char   H  IBSS_ATTR;     //@- H register
unsigned char   L  IBSS_ATTR;     //@- L register
unsigned char   A  IBSS_ATTR;     //@- A register (accumulator)
unsigned char   F  IBSS_ATTR;     //@- Flags register
unsigned char   B1 IBSS_ATTR;     //@- Alternate B register (B')
unsigned char   C1 IBSS_ATTR;     //@- Alternate C register (C')
unsigned char   D1 IBSS_ATTR;     //@- Alternate D register (D')
unsigned char   E1 IBSS_ATTR;     //@- Alternate E register (E')
unsigned char   H1 IBSS_ATTR;     //@- Alternate H register (H')
unsigned char   L1 IBSS_ATTR;     //@- Alternate L register (L')
unsigned char   A1 IBSS_ATTR;     //@- Alternate A register (A')
unsigned char   F1 IBSS_ATTR;     //@- Alternate flags register (F')
unsigned        IX IBSS_ATTR;     //@- Index register X
unsigned        IY IBSS_ATTR;     //@- Index register Y
unsigned        PC IBSS_ATTR;     //@- Program counter
unsigned        SP IBSS_ATTR;     //@- Stack pointer
unsigned char   I  IBSS_ATTR;     //@- Interrupt register
unsigned char   R  IBSS_ATTR;     //@- Refresh register


/** Returns the 16 bit register BC. */
#define BC() (((unsigned)B << 8) | C)
#define DE() (((unsigned)D << 8) | E)
#define HL() (((unsigned)H << 8) | L)

/** 
    Returns the number of Z80 CPU cycles elapsed so far. 

    The cycle count is reset to zero when reset() is called, or
    it can be set to any value with setCycles(). It is updated after
    a CPU instruction is executed, for example by calling step()
    or interrupt().
*/
unsigned getCycles(void) {
    return cycles_;
}

/** Sets the CPU cycle counter to the specified value. */
void setCycles( unsigned value ) {
    cycles_ = value;
}

/** Returns the current interrupt mode. */
unsigned getInterruptMode(void) {
    return iflags_ & 0x03;
}

/** Sets the interrupt mode to the specified value. */
void setInterruptMode( unsigned mode );

/** Returns non-zero if the CPU is halted, otherwise zero. */
int isHalted(void) {
    return iflags_ & Halted;
}

/*
    Sets the interrupt mode to IM0, IM1 or IM2.
*/
void setInterruptMode( unsigned mode )
{
    if( mode <= 2 ) {
        iflags_ = (iflags_ & ~0x03) | mode;
    }
}

/*
    Calls a subroutine at the specified address.
*/
void callSub( unsigned addr )
{
    SP -= 2;
    writeWord( SP, PC ); // Save current program counter in the stack
    PC = addr & 0xFFFF; // Jump to the specified address
}

/*
    Decrements a byte value by one. 
    Note that this is different from subtracting one from the byte value,
    because flags behave differently.
*/
static inline unsigned char decByte( unsigned char b )
{
    F = Subtraction | (F & Carry); // Preserve the carry flag
    if( (b & 0x0F) == 0 ) F |= Halfcarry;
    --b;
    if( b == 0x7F ) F |= Overflow;
    if( b & 0x80 ) F |= Sign;
    if( b == 0 ) F |= Zero;

    return b;
}

/*
    Increments a byte value by one. 
    Note that this is different from adding one to the byte value,
    because flags behave differently.
*/
static inline unsigned char incByte( unsigned char b )
{
    ++b;
    F &= Carry; // Preserve the carry flag
    if( ! (b & 0x0F) ) F |= Halfcarry;
    if( b == 0x80 ) F |= Overflow;
    if( b & 0x80 ) F |= Sign;
    if( b == 0 ) F |= Zero;

    return b;
}

/*
    Reads one byte from port C, updating flags according to the rules of "IN r,(C)".
*/
static inline unsigned char inpReg(void)
{
    unsigned char   r = readPort( C );

    F = (F & Carry) | PSZ_[r];

    return r;
}

/*
    Performs a relative jump to the specified offset.
*/
static inline void relJump( unsigned char o )
{
    int offset = (int)((signed char)o);

    PC = (unsigned)((int)PC + offset) & 0xFFFF;
    cycles_++;
}

/*
    Returns from a subroutine, popping the saved Program Counter from the stack.
*/
static inline void retFromSub(void)
{
    PC = readWord( SP );
    SP += 2;
}

/*
    Rotates left one byte thru the carry flag.
*/
static inline unsigned char rotateLeft( unsigned char op )
{
    unsigned char f = F;

    F = 0;
    if( op & 0x80 ) F |= Carry;
    op <<= 1;
    if( f & Carry ) op |= 0x01;
    F |= PSZ_[op];
    
    return op;
}

/*
    Rotates left one byte copying the most significant bit (bit 7) in the carry flag.
*/
static inline unsigned char rotateLeftCarry( unsigned char op )
{
    F = 0;
    if( op & 0x80 ) F |= Carry;
    op = (op << 1) | (op >> 7);
    F |= PSZ_[op];
    
    return op;
}

/*
    Rotates right one byte thru the carry flag.
*/
static inline unsigned char rotateRight( unsigned char op )
{
    unsigned char f = F;

    F = 0;
    if( op & 0x01 ) F |= Carry;
    op >>= 1;
    if( f & Carry ) op |= 0x80;
    F |= PSZ_[op];
    
    return op;
}

/*
    Rotates right one byte copying the least significant bit (bit 0) in the carry flag.
*/
static inline unsigned char rotateRightCarry( unsigned char op )
{
    F = 0;
    if( op & 0x01 ) F |= Carry;
    op = (op >> 1) | (op << 7);
    F |= PSZ_[op];
    
    return op;
}

/*
    Shifts left one byte.
*/
static inline unsigned char shiftLeft( unsigned char op )
{
    F = 0;
    if( op & 0x80 ) F |= Carry;
    op <<= 1;
    F |= PSZ_[op];
    
    return op;
}

/*
    Shifts right one byte, preserving its sign (most significant bit).
*/
static inline unsigned char shiftRightArith( unsigned char op )
{
    F = 0;
    if( op & 0x01 ) F |= Carry;
    op = (op >> 1) | (op & 0x80);

    F |= PSZ_[op];
    
    return op;
}

/*
    Shifts right one byte.
*/
static inline unsigned char shiftRightLogical( unsigned char op )
{
    F = 0;
    if( op & 0x01 ) F |= Carry;
    op >>= 1;

    F |= PSZ_[op];
    
    return op;
}

/*
    Tests whether the specified bit of op is set.
*/
static inline void testBit( unsigned char bit, unsigned char op )
{
    // Flags for a bit test operation are:
    // S, P: unknown
    // Z: set if bit is zero, reset otherwise
    // N: reset
    // H: set
    // C: unaffected
    // However, it seems that parity is always set like Z, so we emulate that as well.
    F = (F & (Carry | Sign)) | Halfcarry;

    if( (op & (1 << bit)) == 0 ) {
        // Bit is not set, so set the zero flag
        F |= Zero | Parity;
    }
}

/*
    Adds the specified byte op to the accumulator, adding
    carry.
*/
static inline void addByte( unsigned char op, unsigned char cf )
{
    unsigned    x = A + op;

    if( cf ) x++; // Add carry

    F = 0;
    if( !(x & 0xFF) ) F |= Zero;
    if( x & 0x80 ) F |= Sign;
    if( x >= 0x100 ) F |= Carry;

    /*
        Halfcarry is set on carry from the low order four bits.

        To see how to compute it, let's take a look at the following table, which
        shows the binary addition of two binary numbers:

        A   B   A+B
        -----------
        0   0   0
        0   1   1
        1   0   1
        1   1   0

        Note that if only the lowest bit is used, then A+B, A-B and A^B yield the same 
        value. If we know A, B and the sum A+B+C, then C is easily derived:
            C = A+B+C - A - B,  that is
            C = A+B+C ^ A ^ B.

        For the halfcarry, A and B above are the fifth bit of a byte, which corresponds
        to the value 0x10. So:

            Halfcarry = ((accumulator+operand+halfcarry) ^ accumulator ^ operand) & 0x10

        Note that masking off all bits but one is important because we have worked all
        the math by using one bit only.
    */
    if( (A ^ op ^ x) & 0x10 ) F |= Halfcarry;

    /*
        The overflow bit is set when the result is too large to fit into the destination
        register, causing a change in the sign bit.

        For a sum, we can only have overflow when adding two numbers that are both positive
        or both negative. For example 0x5E + 0x4B (94 + 75) yields 0xA9 (169), which fits
        into an 8-bit register only if it is interpreted as an unsigned number. If we 
        consider the result as a signed integer, then 0xA9 corresponds to decimal -87 and
        we have overflow.
        Note that if we add two signed numbers of opposite sign then we cannot overflow
        the destination register, because the absolute value of the result will always fit
        in 7 bits, leaving the most significant bit free for use as a sign bit.

        We can code all the above concisely by noting that:

            ~(A ^ op) & 0x80

        is true if and only if A and op have the same sign. Also:

            (x ^ op) & 0x80

        is true if and only if the sum of A and op has taken a sign opposite to that
        of its operands.

        Thus the expression:

            ~(A ^ op) & (x ^ op) & 0x80

        reads "A has the same sign as op, and the opposite as x", where x is the sum of
        A and op (and an optional carry).
    */
    if( ~(A ^ op) & (x ^ op) & 0x80 ) F |= Overflow;

    A = x;
}

/*
    Subtracts the specified byte op from the accumulator, using carry as
    borrow from a previous operation.
*/
static inline unsigned char subByte( unsigned char op, unsigned char cf )
{
    unsigned char   x = A - op;

    if( cf ) x--;

    F = Subtraction;
    if( x == 0 ) F |= Zero;
    if( x & 0x80 ) F |= Sign;
    if( (x >= A) && (op | cf)) F |= Carry;

    // See addByte() for an explanation of the halfcarry bit
    if( (A ^ op ^ x) & 0x10 ) F |= Halfcarry;

    // See addByte() for an explanation of the overflow bit. The only difference here
    // is that for a subtraction we must check that the two operands have different
    // sign, because in fact A-B is A+(-B). Note however that since subtraction is not
    // symmetric, we have to use (x ^ A) to get the correct result, whereas for the
    // addition (x ^ A) is equivalent to (x ^ op)
    if( (A ^ op) & (x ^ A) & 0x80 ) F |= Overflow;

    return x;
}

static inline unsigned addDispl( unsigned addr, unsigned char displ ) {
    return (unsigned)((int)addr + (int)(signed char)displ);
}

/** Compares the accumulator and the specified operand (CP op) */
static inline void cmpByte( unsigned char op ) {
    subByte( op, 0 );
}

/** Fetches a byte from the program counter location */
static inline unsigned char fetchByte(void) {
    return readByte( PC++ );
}

/** Fetches a 16 bit word from the program counter location */
static inline unsigned fetchWord(void) {
    unsigned x = readWord( PC );
    PC += 2;
    return x;
}

/** Sets the parity, sign and zero flags from the accumulator value */
static inline void setFlagsPSZ(void) {
    F = Halfcarry | PSZ_[A];
}

/** Sets the parity, sign, zero, 3rd and 5th flag bits from the accumulator value */
static inline void setFlags35PSZ(void) {
    F = (F & (Carry | Halfcarry | Subtraction)) | PSZ_[A];
}

/** */
static inline void setFlags35PSZ000(void) {
    F = PSZ_[A];
}

/* Resets the CPU */
void z80_reset()
{
    PC = 0;         // Program counter is zero
    I = 0;          // Interrupt register cleared
    R = 0;          // Memory refresh register cleared
    iflags_ = 0;    // IFF1 and IFF2 cleared, IM0 enabled
    cycles_ = 0;    // Could that be 2 (according to some Zilog docs)?

    // There is no official documentation for the following!
    B = B1 = 0; 
    C = C1 = 0;
    D = D1 = 0; 
    E = E1 = 0;
    H = H1 = 0;
    L = L1 = 0;
    A = A1 = 0;
    F = F1 = 0;
    IX = 0;
    IY = 0;
    SP = 0xF000;
}

unsigned z80_getSizeOfSnapshotBuffer(void)
{
    unsigned result =
        8*2 +   // 8-bit registers
        1 +     // I
        1 +     // R
        2 +     // IX
        2 +     // IY
        2 +     // PC
        2 +     // SP
        4 +     // iflags_
        4;      // cycles_    

    return result;
}

static unsigned saveUint16( unsigned char * buffer, unsigned u )
{
    *buffer++ = (unsigned char) (u >> 8);
    *buffer   = (unsigned char) (u);

    return 2;
}

unsigned z80_takeSnapshot( unsigned char * buffer )
{
    unsigned char * buf = buffer;

    *buf++ = A; *buf++ = A1;
    *buf++ = B; *buf++ = B1;
    *buf++ = C; *buf++ = C1;
    *buf++ = D; *buf++ = D1;
    *buf++ = E; *buf++ = E1;
    *buf++ = H; *buf++ = H1;
    *buf++ = L; *buf++ = L1;
    *buf++ = F; *buf++ = F1;

    *buf++ = I;
    *buf++ = R;

    buf += saveUint16( buf, IX );
    buf += saveUint16( buf, IY );
    buf += saveUint16( buf, PC );
    buf += saveUint16( buf, SP );

    buf += saveUint16( buf, iflags_ >> 16 );
    buf += saveUint16( buf, iflags_ );
    buf += saveUint16( buf, cycles_ >> 16 );
    buf += saveUint16( buf, cycles_ );

    return buffer - buf;
}

static unsigned loadUint16( unsigned char ** buffer )
{
    unsigned char * buf = *buffer;
    unsigned result = *buf++;

    result = (result << 8) | *buf++;

    *buffer = buf;

    return result;
}

unsigned z80_restoreSnapshot( unsigned char * buffer )
{
    unsigned char * buf = buffer;

    A = *buf++; A1 = *buf++;
    B = *buf++; B1 = *buf++;
    C = *buf++; C1 = *buf++;
    D = *buf++; D1 = *buf++;
    E = *buf++; E1 = *buf++;
    H = *buf++; H1 = *buf++;
    L = *buf++; L1 = *buf++;
    F = *buf++; F1 = *buf++;

    I = *buf++;
    R = *buf++;

    IX = loadUint16( &buf );
    IY = loadUint16( &buf );
    PC = loadUint16( &buf );
    SP = loadUint16( &buf );

    iflags_ = loadUint16( &buf );
    iflags_ = (iflags_ << 16) | loadUint16(&buf);
    cycles_ = loadUint16( &buf );
    cycles_ = (cycles_ << 16) | loadUint16(&buf);

    return buf - buffer;
}

OpcodeInfo OpInfoCB_[256] = {
    { &opcode_cb_00,  8 }, // RLC B
    { &opcode_cb_01,  8 }, // RLC C
    { &opcode_cb_02,  8 }, // RLC D
    { &opcode_cb_03,  8 }, // RLC E
    { &opcode_cb_04,  8 }, // RLC H
    { &opcode_cb_05,  8 }, // RLC L
    { &opcode_cb_06, 15 }, // RLC (HL)
    { &opcode_cb_07,  8 }, // RLC A
    { &opcode_cb_08,  8 }, // RRC B
    { &opcode_cb_09,  8 }, // RRC C
    { &opcode_cb_0a,  8 }, // RRC D
    { &opcode_cb_0b,  8 }, // RRC E
    { &opcode_cb_0c,  8 }, // RRC H
    { &opcode_cb_0d,  8 }, // RRC L
    { &opcode_cb_0e, 15 }, // RRC (HL)
    { &opcode_cb_0f,  8 }, // RRC A
    { &opcode_cb_10,  8 }, // RL B
    { &opcode_cb_11,  8 }, // RL C
    { &opcode_cb_12,  8 }, // RL D
    { &opcode_cb_13,  8 }, // RL E
    { &opcode_cb_14,  8 }, // RL H
    { &opcode_cb_15,  8 }, // RL L
    { &opcode_cb_16, 15 }, // RL (HL)
    { &opcode_cb_17,  8 }, // RL A
    { &opcode_cb_18,  8 }, // RR B
    { &opcode_cb_19,  8 }, // RR C
    { &opcode_cb_1a,  8 }, // RR D
    { &opcode_cb_1b,  8 }, // RR E
    { &opcode_cb_1c,  8 }, // RR H
    { &opcode_cb_1d,  8 }, // RR L
    { &opcode_cb_1e, 15 }, // RR (HL)
    { &opcode_cb_1f,  8 }, // RR A
    { &opcode_cb_20,  8 }, // SLA B
    { &opcode_cb_21,  8 }, // SLA C
    { &opcode_cb_22,  8 }, // SLA D
    { &opcode_cb_23,  8 }, // SLA E
    { &opcode_cb_24,  8 }, // SLA H
    { &opcode_cb_25,  8 }, // SLA L
    { &opcode_cb_26, 15 }, // SLA (HL)
    { &opcode_cb_27,  8 }, // SLA A
    { &opcode_cb_28,  8 }, // SRA B
    { &opcode_cb_29,  8 }, // SRA C
    { &opcode_cb_2a,  8 }, // SRA D
    { &opcode_cb_2b,  8 }, // SRA E
    { &opcode_cb_2c,  8 }, // SRA H
    { &opcode_cb_2d,  8 }, // SRA L
    { &opcode_cb_2e, 15 }, // SRA (HL)
    { &opcode_cb_2f,  8 }, // SRA A
    { &opcode_cb_30,  8 }, // SLL B 
    { &opcode_cb_31,  8 }, // SLL C 
    { &opcode_cb_32,  8 }, // SLL D 
    { &opcode_cb_33,  8 }, // SLL E 
    { &opcode_cb_34,  8 }, // SLL H 
    { &opcode_cb_35,  8 }, // SLL L 
    { &opcode_cb_36, 15 }, // SLL (HL)
    { &opcode_cb_37,  8 }, // SLL A
    { &opcode_cb_38,  8 }, // SRL B
    { &opcode_cb_39,  8 }, // SRL C
    { &opcode_cb_3a,  8 }, // SRL D
    { &opcode_cb_3b,  8 }, // SRL E
    { &opcode_cb_3c,  8 }, // SRL H
    { &opcode_cb_3d,  8 }, // SRL L
    { &opcode_cb_3e, 15 }, // SRL (HL)
    { &opcode_cb_3f,  8 }, // SRL A
    { &opcode_cb_40,  8 }, // BIT 0, B
    { &opcode_cb_41,  8 }, // BIT 0, C
    { &opcode_cb_42,  8 }, // BIT 0, D
    { &opcode_cb_43,  8 }, // BIT 0, E
    { &opcode_cb_44,  8 }, // BIT 0, H
    { &opcode_cb_45,  8 }, // BIT 0, L
    { &opcode_cb_46, 12 }, // BIT 0, (HL)
    { &opcode_cb_47,  8 }, // BIT 0, A
    { &opcode_cb_48,  8 }, // BIT 1, B
    { &opcode_cb_49,  8 }, // BIT 1, C
    { &opcode_cb_4a,  8 }, // BIT 1, D
    { &opcode_cb_4b,  8 }, // BIT 1, E
    { &opcode_cb_4c,  8 }, // BIT 1, H
    { &opcode_cb_4d,  8 }, // BIT 1, L
    { &opcode_cb_4e, 12 }, // BIT 1, (HL)
    { &opcode_cb_4f,  8 }, // BIT 1, A
    { &opcode_cb_50,  8 }, // BIT 2, B
    { &opcode_cb_51,  8 }, // BIT 2, C
    { &opcode_cb_52,  8 }, // BIT 2, D
    { &opcode_cb_53,  8 }, // BIT 2, E
    { &opcode_cb_54,  8 }, // BIT 2, H
    { &opcode_cb_55,  8 }, // BIT 2, L
    { &opcode_cb_56, 12 }, // BIT 2, (HL)
    { &opcode_cb_57,  8 }, // BIT 2, A
    { &opcode_cb_58,  8 }, // BIT 3, B
    { &opcode_cb_59,  8 }, // BIT 3, C
    { &opcode_cb_5a,  8 }, // BIT 3, D
    { &opcode_cb_5b,  8 }, // BIT 3, E
    { &opcode_cb_5c,  8 }, // BIT 3, H
    { &opcode_cb_5d,  8 }, // BIT 3, L
    { &opcode_cb_5e, 12 }, // BIT 3, (HL)
    { &opcode_cb_5f,  8 }, // BIT 3, A
    { &opcode_cb_60,  8 }, // BIT 4, B
    { &opcode_cb_61,  8 }, // BIT 4, C
    { &opcode_cb_62,  8 }, // BIT 4, D
    { &opcode_cb_63,  8 }, // BIT 4, E
    { &opcode_cb_64,  8 }, // BIT 4, H
    { &opcode_cb_65,  8 }, // BIT 4, L
    { &opcode_cb_66, 12 }, // BIT 4, (HL)
    { &opcode_cb_67,  8 }, // BIT 4, A
    { &opcode_cb_68,  8 }, // BIT 5, B
    { &opcode_cb_69,  8 }, // BIT 5, C
    { &opcode_cb_6a,  8 }, // BIT 5, D
    { &opcode_cb_6b,  8 }, // BIT 5, E
    { &opcode_cb_6c,  8 }, // BIT 5, H
    { &opcode_cb_6d,  8 }, // BIT 5, L
    { &opcode_cb_6e, 12 }, // BIT 5, (HL)
    { &opcode_cb_6f,  8 }, // BIT 5, A
    { &opcode_cb_70,  8 }, // BIT 6, B
    { &opcode_cb_71,  8 }, // BIT 6, C
    { &opcode_cb_72,  8 }, // BIT 6, D
    { &opcode_cb_73,  8 }, // BIT 6, E
    { &opcode_cb_74,  8 }, // BIT 6, H
    { &opcode_cb_75,  8 }, // BIT 6, L
    { &opcode_cb_76, 12 }, // BIT 6, (HL)
    { &opcode_cb_77,  8 }, // BIT 6, A
    { &opcode_cb_78,  8 }, // BIT 7, B
    { &opcode_cb_79,  8 }, // BIT 7, C
    { &opcode_cb_7a,  8 }, // BIT 7, D
    { &opcode_cb_7b,  8 }, // BIT 7, E
    { &opcode_cb_7c,  8 }, // BIT 7, H
    { &opcode_cb_7d,  8 }, // BIT 7, L
    { &opcode_cb_7e, 12 }, // BIT 7, (HL)
    { &opcode_cb_7f,  8 }, // BIT 7, A
    { &opcode_cb_80,  8 }, // RES 0, B
    { &opcode_cb_81,  8 }, // RES 0, C
    { &opcode_cb_82,  8 }, // RES 0, D
    { &opcode_cb_83,  8 }, // RES 0, E
    { &opcode_cb_84,  8 }, // RES 0, H
    { &opcode_cb_85,  8 }, // RES 0, L
    { &opcode_cb_86, 15 }, // RES 0, (HL)
    { &opcode_cb_87,  8 }, // RES 0, A
    { &opcode_cb_88,  8 }, // RES 1, B
    { &opcode_cb_89,  8 }, // RES 1, C
    { &opcode_cb_8a,  8 }, // RES 1, D
    { &opcode_cb_8b,  8 }, // RES 1, E
    { &opcode_cb_8c,  8 }, // RES 1, H
    { &opcode_cb_8d,  8 }, // RES 1, L
    { &opcode_cb_8e, 15 }, // RES 1, (HL)
    { &opcode_cb_8f,  8 }, // RES 1, A
    { &opcode_cb_90,  8 }, // RES 2, B
    { &opcode_cb_91,  8 }, // RES 2, C
    { &opcode_cb_92,  8 }, // RES 2, D
    { &opcode_cb_93,  8 }, // RES 2, E
    { &opcode_cb_94,  8 }, // RES 2, H
    { &opcode_cb_95,  8 }, // RES 2, L
    { &opcode_cb_96, 15 }, // RES 2, (HL)
    { &opcode_cb_97,  8 }, // RES 2, A
    { &opcode_cb_98,  8 }, // RES 3, B
    { &opcode_cb_99,  8 }, // RES 3, C
    { &opcode_cb_9a,  8 }, // RES 3, D
    { &opcode_cb_9b,  8 }, // RES 3, E
    { &opcode_cb_9c,  8 }, // RES 3, H
    { &opcode_cb_9d,  8 }, // RES 3, L
    { &opcode_cb_9e, 15 }, // RES 3, (HL)
    { &opcode_cb_9f,  8 }, // RES 3, A
    { &opcode_cb_a0,  8 }, // RES 4, B
    { &opcode_cb_a1,  8 }, // RES 4, C
    { &opcode_cb_a2,  8 }, // RES 4, D
    { &opcode_cb_a3,  8 }, // RES 4, E
    { &opcode_cb_a4,  8 }, // RES 4, H
    { &opcode_cb_a5,  8 }, // RES 4, L
    { &opcode_cb_a6, 15 }, // RES 4, (HL)
    { &opcode_cb_a7,  8 }, // RES 4, A
    { &opcode_cb_a8,  8 }, // RES 5, B
    { &opcode_cb_a9,  8 }, // RES 5, C
    { &opcode_cb_aa,  8 }, // RES 5, D
    { &opcode_cb_ab,  8 }, // RES 5, E
    { &opcode_cb_ac,  8 }, // RES 5, H
    { &opcode_cb_ad,  8 }, // RES 5, L
    { &opcode_cb_ae, 15 }, // RES 5, (HL)
    { &opcode_cb_af,  8 }, // RES 5, A
    { &opcode_cb_b0,  8 }, // RES 6, B
    { &opcode_cb_b1,  8 }, // RES 6, C
    { &opcode_cb_b2,  8 }, // RES 6, D
    { &opcode_cb_b3,  8 }, // RES 6, E
    { &opcode_cb_b4,  8 }, // RES 6, H
    { &opcode_cb_b5,  8 }, // RES 6, L
    { &opcode_cb_b6, 15 }, // RES 6, (HL)
    { &opcode_cb_b7,  8 }, // RES 6, A
    { &opcode_cb_b8,  8 }, // RES 7, B
    { &opcode_cb_b9,  8 }, // RES 7, C
    { &opcode_cb_ba,  8 }, // RES 7, D
    { &opcode_cb_bb,  8 }, // RES 7, E
    { &opcode_cb_bc,  8 }, // RES 7, H
    { &opcode_cb_bd,  8 }, // RES 7, L
    { &opcode_cb_be, 15 }, // RES 7, (HL)
    { &opcode_cb_bf,  8 }, // RES 7, A
    { &opcode_cb_c0,  8 }, // SET 0, B
    { &opcode_cb_c1,  8 }, // SET 0, C
    { &opcode_cb_c2,  8 }, // SET 0, D
    { &opcode_cb_c3,  8 }, // SET 0, E
    { &opcode_cb_c4,  8 }, // SET 0, H
    { &opcode_cb_c5,  8 }, // SET 0, L
    { &opcode_cb_c6, 15 }, // SET 0, (HL)
    { &opcode_cb_c7,  8 }, // SET 0, A
    { &opcode_cb_c8,  8 }, // SET 1, B
    { &opcode_cb_c9,  8 }, // SET 1, C
    { &opcode_cb_ca,  8 }, // SET 1, D
    { &opcode_cb_cb,  8 }, // SET 1, E
    { &opcode_cb_cc,  8 }, // SET 1, H
    { &opcode_cb_cd,  8 }, // SET 1, L
    { &opcode_cb_ce, 15 }, // SET 1, (HL)
    { &opcode_cb_cf,  8 }, // SET 1, A
    { &opcode_cb_d0,  8 }, // SET 2, B
    { &opcode_cb_d1,  8 }, // SET 2, C
    { &opcode_cb_d2,  8 }, // SET 2, D
    { &opcode_cb_d3,  8 }, // SET 2, E
    { &opcode_cb_d4,  8 }, // SET 2, H
    { &opcode_cb_d5,  8 }, // SET 2, L
    { &opcode_cb_d6, 15 }, // SET 2, (HL)
    { &opcode_cb_d7,  8 }, // SET 2, A
    { &opcode_cb_d8,  8 }, // SET 3, B
    { &opcode_cb_d9,  8 }, // SET 3, C
    { &opcode_cb_da,  8 }, // SET 3, D
    { &opcode_cb_db,  8 }, // SET 3, E
    { &opcode_cb_dc,  8 }, // SET 3, H
    { &opcode_cb_dd,  8 }, // SET 3, L
    { &opcode_cb_de, 15 }, // SET 3, (HL)
    { &opcode_cb_df,  8 }, // SET 3, A
    { &opcode_cb_e0,  8 }, // SET 4, B
    { &opcode_cb_e1,  8 }, // SET 4, C
    { &opcode_cb_e2,  8 }, // SET 4, D
    { &opcode_cb_e3,  8 }, // SET 4, E
    { &opcode_cb_e4,  8 }, // SET 4, H
    { &opcode_cb_e5,  8 }, // SET 4, L
    { &opcode_cb_e6, 15 }, // SET 4, (HL)
    { &opcode_cb_e7,  8 }, // SET 4, A
    { &opcode_cb_e8,  8 }, // SET 5, B
    { &opcode_cb_e9,  8 }, // SET 5, C
    { &opcode_cb_ea,  8 }, // SET 5, D
    { &opcode_cb_eb,  8 }, // SET 5, E
    { &opcode_cb_ec,  8 }, // SET 5, H
    { &opcode_cb_ed,  8 }, // SET 5, L
    { &opcode_cb_ee, 15 }, // SET 5, (HL)
    { &opcode_cb_ef,  8 }, // SET 5, A
    { &opcode_cb_f0,  8 }, // SET 6, B
    { &opcode_cb_f1,  8 }, // SET 6, C
    { &opcode_cb_f2,  8 }, // SET 6, D
    { &opcode_cb_f3,  8 }, // SET 6, E
    { &opcode_cb_f4,  8 }, // SET 6, H
    { &opcode_cb_f5,  8 }, // SET 6, L
    { &opcode_cb_f6, 15 }, // SET 6, (HL)
    { &opcode_cb_f7,  8 }, // SET 6, A
    { &opcode_cb_f8,  8 }, // SET 7, B
    { &opcode_cb_f9,  8 }, // SET 7, C
    { &opcode_cb_fa,  8 }, // SET 7, D
    { &opcode_cb_fb,  8 }, // SET 7, E
    { &opcode_cb_fc,  8 }, // SET 7, H
    { &opcode_cb_fd,  8 }, // SET 7, L
    { &opcode_cb_fe, 15 }, // SET 7, (HL)
    { &opcode_cb_ff,  8 }  // SET 7, A
};
    
void opcode_cb_00()    // RLC B
{
    B = rotateLeftCarry( B );    
}

void opcode_cb_01()    // RLC C
{
    C = rotateLeftCarry( C );    
}

void opcode_cb_02()    // RLC D
{
    D = rotateLeftCarry( D );    
}

void opcode_cb_03()    // RLC E
{
    E = rotateLeftCarry( E );    
}

void opcode_cb_04()    // RLC H
{
    H = rotateLeftCarry( H );    
}

void opcode_cb_05()    // RLC L
{
    L = rotateLeftCarry( L );
}

void opcode_cb_06()    // RLC (HL)
{
    writeByte( HL(), rotateLeftCarry( readByte( HL() ) ) );
}

void opcode_cb_07()    // RLC A
{
    A = rotateLeftCarry( A );
}

void opcode_cb_08()    // RRC B
{
    B = rotateRightCarry( B );
}

void opcode_cb_09()    // RRC C
{
    C = rotateLeftCarry( C );
}

void opcode_cb_0a()    // RRC D
{
    D = rotateLeftCarry( D );
}

void opcode_cb_0b()    // RRC E
{
    E = rotateLeftCarry( E );
}

void opcode_cb_0c()    // RRC H
{
    H = rotateLeftCarry( H );
}

void opcode_cb_0d()    // RRC L
{
    L = rotateLeftCarry( L );
}

void opcode_cb_0e()    // RRC (HL)
{
    writeByte( HL(), rotateRightCarry( readByte( HL() ) ) );    
}

void opcode_cb_0f()    // RRC A
{
    A = rotateLeftCarry( A );
}

void opcode_cb_10()    // RL B
{
    B = rotateLeft( B );    
}

void opcode_cb_11()    // RL C
{
    C = rotateLeft( C );    
}

void opcode_cb_12()    // RL D
{
    D = rotateLeft( D );    
}

void opcode_cb_13()    // RL E
{
    E = rotateLeft( E );
}

void opcode_cb_14()    // RL H
{
    H = rotateLeft( H );    
}

void opcode_cb_15()    // RL L
{
    L = rotateLeft( L );    
}

void opcode_cb_16()    // RL (HL)
{
    writeByte( HL(), rotateLeft( readByte( HL() ) ) );    
}

void opcode_cb_17()    // RL A
{
    A = rotateLeft( A ); 
}

void opcode_cb_18()    // RR B
{
    B = rotateRight( B ); 
}

void opcode_cb_19()    // RR C
{
    C = rotateRight( C ); 
}

void opcode_cb_1a()    // RR D
{
    D = rotateRight( D ); 
}

void opcode_cb_1b()    // RR E
{
    E = rotateRight( E ); 
}

void opcode_cb_1c()    // RR H
{
    H = rotateRight( H ); 
}

void opcode_cb_1d()    // RR L
{
    L = rotateRight( L ); 
}

void opcode_cb_1e()    // RR (HL)
{
    writeByte( HL(), rotateRight( readByte( HL() ) ) );    
}

void opcode_cb_1f()    // RR A
{
    A = rotateRight( A ); 
}

void opcode_cb_20()    // SLA B
{
    B = shiftLeft( B );
}

void opcode_cb_21()    // SLA C
{
    C = shiftLeft( C );
}

void opcode_cb_22()    // SLA D
{
    D = shiftLeft( D );
}

void opcode_cb_23()    // SLA E
{
    E = shiftLeft( E );
}

void opcode_cb_24()    // SLA H
{
    H = shiftLeft( H );
}

void opcode_cb_25()    // SLA L
{
    L = shiftLeft( L );
}

void opcode_cb_26()    // SLA (HL)
{
    writeByte( HL(), shiftLeft( readByte( HL() ) ) );
}

void opcode_cb_27()    // SLA A
{
    A = shiftLeft( A );
}

void opcode_cb_28()    // SRA B
{
    B = shiftRightArith( B );
}

void opcode_cb_29()    // SRA C
{
    C = shiftRightArith( C );
}

void opcode_cb_2a()    // SRA D
{
    D = shiftRightArith( D );
}

void opcode_cb_2b()    // SRA E
{
    E = shiftRightArith( E );
}

void opcode_cb_2c()    // SRA H
{
    H = shiftRightArith( H );
}

void opcode_cb_2d()    // SRA L
{
    L = shiftRightArith( L );
}

void opcode_cb_2e()    // SRA (HL)
{
    writeByte( HL(), shiftRightArith( readByte( HL() ) ) );
}

void opcode_cb_2f()    // SRA A
{
    A = shiftRightArith( A );
}

void opcode_cb_30()    // SLL B
{
    B = shiftLeft( B ) | 0x01;
}

void opcode_cb_31()    // SLL C
{
    C = shiftLeft( C ) | 0x01;
}

void opcode_cb_32()    // SLL D
{
    D = shiftLeft( D ) | 0x01;
}

void opcode_cb_33()    // SLL E
{
    E = shiftLeft( E ) | 0x01;
}

void opcode_cb_34()    // SLL H
{
    H = shiftLeft( H ) | 0x01;
}

void opcode_cb_35()    // SLL L
{
    L = shiftLeft( L ) | 0x01;
}

void opcode_cb_36()    // SLL (HL)
{
    writeByte( HL(), shiftLeft( readByte( HL() ) ) | 0x01 );
}

void opcode_cb_37()    // SLL A
{
    A = shiftLeft( A ) | 0x01;
}

void opcode_cb_38()    // SRL B
{
    B = shiftRightLogical( B );
}

void opcode_cb_39()    // SRL C
{
    C = shiftRightLogical( C );
}

void opcode_cb_3a()    // SRL D
{
    D = shiftRightLogical( D );
}

void opcode_cb_3b()    // SRL E
{
    E = shiftRightLogical( E );
}

void opcode_cb_3c()    // SRL H
{
    H = shiftRightLogical( H );
}

void opcode_cb_3d()    // SRL L
{
    L = shiftRightLogical( L );
}

void opcode_cb_3e()    // SRL (HL)
{
    writeByte( HL(), shiftRightLogical( readByte( HL() ) ) );
}

void opcode_cb_3f()    // SRL A
{
    A = shiftRightLogical( A );
}

void opcode_cb_40()    // BIT 0, B
{
    testBit( 0, B );
}

void opcode_cb_41()    // BIT 0, C
{
    testBit( 0, C );
}

void opcode_cb_42()    // BIT 0, D
{
    testBit( 0, D );
}

void opcode_cb_43()    // BIT 0, E
{
    testBit( 0, E );
}

void opcode_cb_44()    // BIT 0, H
{
    testBit( 0, H );
}

void opcode_cb_45()    // BIT 0, L
{
    testBit( 0, L );
}

void opcode_cb_46()    // BIT 0, (HL)
{
    testBit( 0, readByte( HL() ) );
}

void opcode_cb_47()    // BIT 0, A
{
    testBit( 0, A );
}

void opcode_cb_48()    // BIT 1, B
{
    testBit( 1, B );
}

void opcode_cb_49()    // BIT 1, C
{
    testBit( 1, C );
}

void opcode_cb_4a()    // BIT 1, D
{
    testBit( 1, D );
}

void opcode_cb_4b()    // BIT 1, E
{
    testBit( 1, E );
}

void opcode_cb_4c()    // BIT 1, H
{
    testBit( 1, H );
}

void opcode_cb_4d()    // BIT 1, L
{
    testBit( 1, L );
}

void opcode_cb_4e()    // BIT 1, (HL)
{
    testBit( 1, readByte( HL() ) );
}

void opcode_cb_4f()    // BIT 1, A
{
    testBit( 1, A );
}

void opcode_cb_50()    // BIT 2, B
{
    testBit( 2, B );
}

void opcode_cb_51()    // BIT 2, C
{
    testBit( 2, C );
}

void opcode_cb_52()    // BIT 2, D
{
    testBit( 2, D );
}

void opcode_cb_53()    // BIT 2, E
{
    testBit( 2, E );
}

void opcode_cb_54()    // BIT 2, H
{
    testBit( 2, H );
}

void opcode_cb_55()    // BIT 2, L
{
    testBit( 2, L );
}

void opcode_cb_56()    // BIT 2, (HL)
{
    testBit( 2, readByte( HL() ) );
}

void opcode_cb_57()    // BIT 2, A
{
    testBit( 2, A );
}

void opcode_cb_58()    // BIT 3, B
{
    testBit( 3, B );
}

void opcode_cb_59()    // BIT 3, C
{
    testBit( 3, C );
}

void opcode_cb_5a()    // BIT 3, D
{
    testBit( 3, D );
}

void opcode_cb_5b()    // BIT 3, E
{
    testBit( 3, E );
}

void opcode_cb_5c()    // BIT 3, H
{
    testBit( 3, H );
}

void opcode_cb_5d()    // BIT 3, L
{
    testBit( 3, L );
}

void opcode_cb_5e()    // BIT 3, (HL)
{
    testBit( 3, readByte( HL() ) );
}

void opcode_cb_5f()    // BIT 3, A
{
    testBit( 3, A );
}

void opcode_cb_60()    // BIT 4, B
{
    testBit( 4, B );
}

void opcode_cb_61()    // BIT 4, C
{
    testBit( 4, C );
}

void opcode_cb_62()    // BIT 4, D
{
    testBit( 4, D );
}

void opcode_cb_63()    // BIT 4, E
{
    testBit( 4, E );
}

void opcode_cb_64()    // BIT 4, H
{
    testBit( 4, H );
}

void opcode_cb_65()    // BIT 4, L
{
    testBit( 4, L );
}

void opcode_cb_66()    // BIT 4, (HL)
{
    testBit( 4, readByte( HL() ) );
}

void opcode_cb_67()    // BIT 4, A
{
    testBit( 4, A );
}

void opcode_cb_68()    // BIT 5, B
{
    testBit( 5, B );
}

void opcode_cb_69()    // BIT 5, C
{
    testBit( 5, C );
}

void opcode_cb_6a()    // BIT 5, D
{
    testBit( 5, D );
}

void opcode_cb_6b()    // BIT 5, E
{
    testBit( 5, E );
}

void opcode_cb_6c()    // BIT 5, H
{
    testBit( 5, H );
}

void opcode_cb_6d()    // BIT 5, L
{
    testBit( 5, L );
}

void opcode_cb_6e()    // BIT 5, (HL)
{
    testBit( 5, readByte( HL() ) );
}

void opcode_cb_6f()    // BIT 5, A
{
    testBit( 5, A );
}

void opcode_cb_70()    // BIT 6, B
{
    testBit( 6, B );
}

void opcode_cb_71()    // BIT 6, C
{
    testBit( 6, C );
}

void opcode_cb_72()    // BIT 6, D
{
    testBit( 6, D );
}

void opcode_cb_73()    // BIT 6, E
{
    testBit( 6, E );
}

void opcode_cb_74()    // BIT 6, H
{
    testBit( 6, H );
}

void opcode_cb_75()    // BIT 6, L
{
    testBit( 6, L );
}

void opcode_cb_76()    // BIT 6, (HL)
{
    testBit( 6, readByte( HL() ) );
}

void opcode_cb_77()    // BIT 6, A
{
    testBit( 6, A );
}

void opcode_cb_78()    // BIT 7, B
{
    testBit( 7, B );
}

void opcode_cb_79()    // BIT 7, C
{
    testBit( 7, C );
}

void opcode_cb_7a()    // BIT 7, D
{
    testBit( 7, D );
}

void opcode_cb_7b()    // BIT 7, E
{
    testBit( 7, E );
}

void opcode_cb_7c()    // BIT 7, H
{
    testBit( 7, H );
}

void opcode_cb_7d()    // BIT 7, L
{
    testBit( 7, L );
}

void opcode_cb_7e()    // BIT 7, (HL)
{
    testBit( 7, readByte( HL() ) );
}

void opcode_cb_7f()    // BIT 7, A
{
    testBit( 7, A );
}

void opcode_cb_80()    // RES 0, B
{
    B &= ~(unsigned char) (1 << 0);
}

void opcode_cb_81()    // RES 0, C
{
    C &= ~(unsigned char) (1 << 0);
}

void opcode_cb_82()    // RES 0, D
{
    D &= ~(unsigned char) (1 << 0);
}

void opcode_cb_83()    // RES 0, E
{
    E &= ~(unsigned char) (1 << 0);
}

void opcode_cb_84()    // RES 0, H
{
    H &= ~(unsigned char) (1 << 0);
}

void opcode_cb_85()    // RES 0, L
{
    L &= ~(unsigned char) (1 << 0);
}

void opcode_cb_86()    // RES 0, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 0) );
}

void opcode_cb_87()    // RES 0, A
{
    A &= ~(unsigned char) (1 << 0);
}

void opcode_cb_88()    // RES 1, B
{
    B &= ~(unsigned char) (1 << 1);
}

void opcode_cb_89()    // RES 1, C
{
    C &= ~(unsigned char) (1 << 1);
}

void opcode_cb_8a()    // RES 1, D
{
    D &= ~(unsigned char) (1 << 1);
}

void opcode_cb_8b()    // RES 1, E
{
    E &= ~(unsigned char) (1 << 1);
}

void opcode_cb_8c()    // RES 1, H
{
    H &= ~(unsigned char) (1 << 1);
}

void opcode_cb_8d()    // RES 1, L
{
    L &= ~(unsigned char) (1 << 1);
}

void opcode_cb_8e()    // RES 1, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 1) );
}

void opcode_cb_8f()    // RES 1, A
{
    A &= ~(unsigned char) (1 << 1);
}

void opcode_cb_90()    // RES 2, B
{
    B &= ~(unsigned char) (1 << 2);
}

void opcode_cb_91()    // RES 2, C
{
    C &= ~(unsigned char) (1 << 2);
}

void opcode_cb_92()    // RES 2, D
{
    D &= ~(unsigned char) (1 << 2);
}

void opcode_cb_93()    // RES 2, E
{
    E &= ~(unsigned char) (1 << 2);
}

void opcode_cb_94()    // RES 2, H
{
    H &= ~(unsigned char) (1 << 2);
}

void opcode_cb_95()    // RES 2, L
{
    L &= ~(unsigned char) (1 << 2);
}

void opcode_cb_96()    // RES 2, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 2) );
}

void opcode_cb_97()    // RES 2, A
{
    A &= ~(unsigned char) (1 << 2);
}

void opcode_cb_98()    // RES 3, B
{
    B &= ~(unsigned char) (1 << 3);
}

void opcode_cb_99()    // RES 3, C
{
    C &= ~(unsigned char) (1 << 3);
}

void opcode_cb_9a()    // RES 3, D
{
    D &= ~(unsigned char) (1 << 3);
}

void opcode_cb_9b()    // RES 3, E
{
    E &= ~(unsigned char) (1 << 3);
}

void opcode_cb_9c()    // RES 3, H
{
    H &= ~(unsigned char) (1 << 3);
}

void opcode_cb_9d()    // RES 3, L
{
    L &= ~(unsigned char) (1 << 3);
}

void opcode_cb_9e()    // RES 3, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 3) );
}

void opcode_cb_9f()    // RES 3, A
{
    A &= ~(unsigned char) (1 << 3);
}

void opcode_cb_a0()    // RES 4, B
{
    B &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a1()    // RES 4, C
{
    C &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a2()    // RES 4, D
{
    D &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a3()    // RES 4, E
{
    E &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a4()    // RES 4, H
{
    H &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a5()    // RES 4, L
{
    L &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a6()    // RES 4, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 4) );
}

void opcode_cb_a7()    // RES 4, A
{
    A &= ~(unsigned char) (1 << 4);
}

void opcode_cb_a8()    // RES 5, B
{
    B &= ~(unsigned char) (1 << 5);
}

void opcode_cb_a9()    // RES 5, C
{
    C &= ~(unsigned char) (1 << 5);
}

void opcode_cb_aa()    // RES 5, D
{
    D &= ~(unsigned char) (1 << 5);
}

void opcode_cb_ab()    // RES 5, E
{
    E &= ~(unsigned char) (1 << 5);
}

void opcode_cb_ac()    // RES 5, H
{
    H &= ~(unsigned char) (1 << 5);
}

void opcode_cb_ad()    // RES 5, L
{
    L &= ~(unsigned char) (1 << 5);
}

void opcode_cb_ae()    // RES 5, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 5) );
}

void opcode_cb_af()    // RES 5, A
{
    A &= ~(unsigned char) (1 << 5);
}

void opcode_cb_b0()    // RES 6, B
{
    B &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b1()    // RES 6, C
{
    C &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b2()    // RES 6, D
{
    D &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b3()    // RES 6, E
{
    E &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b4()    // RES 6, H
{
    H &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b5()    // RES 6, L
{
    L &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b6()    // RES 6, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 6) );
}

void opcode_cb_b7()    // RES 6, A
{
    A &= ~(unsigned char) (1 << 6);
}

void opcode_cb_b8()    // RES 7, B
{
    B &= ~(unsigned char) (1 << 7);
}

void opcode_cb_b9()    // RES 7, C
{
    C &= ~(unsigned char) (1 << 7);
}

void opcode_cb_ba()    // RES 7, D
{
    D &= ~(unsigned char) (1 << 7);
}

void opcode_cb_bb()    // RES 7, E
{
    E &= ~(unsigned char) (1 << 7);
}

void opcode_cb_bc()    // RES 7, H
{
    H &= ~(unsigned char) (1 << 7);
}

void opcode_cb_bd()    // RES 7, L
{
    L &= ~(unsigned char) (1 << 7);
}

void opcode_cb_be()    // RES 7, (HL)
{
    writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 7) );
}

void opcode_cb_bf()    // RES 7, A
{
    A &= ~(unsigned char) (1 << 7);
}

void opcode_cb_c0()    // SET 0, B
{
    B |= (unsigned char) (1 << 0);
}

void opcode_cb_c1()    // SET 0, C
{
    C |= (unsigned char) (1 << 0);
}

void opcode_cb_c2()    // SET 0, D
{
    D |= (unsigned char) (1 << 0);
}

void opcode_cb_c3()    // SET 0, E
{
    E |= (unsigned char) (1 << 0);
}

void opcode_cb_c4()    // SET 0, H
{
    H |= (unsigned char) (1 << 0);
}

void opcode_cb_c5()    // SET 0, L
{
    L |= (unsigned char) (1 << 0);
}

void opcode_cb_c6()    // SET 0, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 0) );
}

void opcode_cb_c7()    // SET 0, A
{
    A |= (unsigned char) (1 << 0);
}

void opcode_cb_c8()    // SET 1, B
{
    B |= (unsigned char) (1 << 1);
}

void opcode_cb_c9()    // SET 1, C
{
    C |= (unsigned char) (1 << 1);
}

void opcode_cb_ca()    // SET 1, D
{
    D |= (unsigned char) (1 << 1);
}

void opcode_cb_cb()    // SET 1, E
{
    E |= (unsigned char) (1 << 1);
}

void opcode_cb_cc()    // SET 1, H
{
    H |= (unsigned char) (1 << 1);
}

void opcode_cb_cd()    // SET 1, L
{
    L |= (unsigned char) (1 << 1);
}

void opcode_cb_ce()    // SET 1, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 1) );
}

void opcode_cb_cf()    // SET 1, A
{
    A |= (unsigned char) (1 << 1);
}

void opcode_cb_d0()    // SET 2, B
{
    B |= (unsigned char) (1 << 2);
}

void opcode_cb_d1()    // SET 2, C
{
    C |= (unsigned char) (1 << 2);
}

void opcode_cb_d2()    // SET 2, D
{
    D |= (unsigned char) (1 << 2);
}

void opcode_cb_d3()    // SET 2, E
{
    E |= (unsigned char) (1 << 2);
}

void opcode_cb_d4()    // SET 2, H
{
    H |= (unsigned char) (1 << 2);
}

void opcode_cb_d5()    // SET 2, L
{
    L |= (unsigned char) (1 << 2);
}

void opcode_cb_d6()    // SET 2, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 2) );
}

void opcode_cb_d7()    // SET 2, A
{
    A |= (unsigned char) (1 << 2);
}

void opcode_cb_d8()    // SET 3, B
{
    B |= (unsigned char) (1 << 3);
}

void opcode_cb_d9()    // SET 3, C
{
    C |= (unsigned char) (1 << 3);
}

void opcode_cb_da()    // SET 3, D
{
    D |= (unsigned char) (1 << 3);
}

void opcode_cb_db()    // SET 3, E
{
    E |= (unsigned char) (1 << 3);
}

void opcode_cb_dc()    // SET 3, H
{
    H |= (unsigned char) (1 << 3);
}

void opcode_cb_dd()    // SET 3, L
{
    L |= (unsigned char) (1 << 3);
}

void opcode_cb_de()    // SET 3, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 3) );
}

void opcode_cb_df()    // SET 3, A
{
    A |= (unsigned char) (1 << 3);
}

void opcode_cb_e0()    // SET 4, B
{
    B |= (unsigned char) (1 << 4);
}

void opcode_cb_e1()    // SET 4, C
{
    C |= (unsigned char) (1 << 4);
}

void opcode_cb_e2()    // SET 4, D
{
    D |= (unsigned char) (1 << 4);
}

void opcode_cb_e3()    // SET 4, E
{
    E |= (unsigned char) (1 << 4);
}

void opcode_cb_e4()    // SET 4, H
{
    H |= (unsigned char) (1 << 4);
}

void opcode_cb_e5()    // SET 4, L
{
    L |= (unsigned char) (1 << 4);
}

void opcode_cb_e6()    // SET 4, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 4) );
}

void opcode_cb_e7()    // SET 4, A
{
    A |= (unsigned char) (1 << 4);
}

void opcode_cb_e8()    // SET 5, B
{
    B |= (unsigned char) (1 << 5);
}

void opcode_cb_e9()    // SET 5, C
{
    C |= (unsigned char) (1 << 5);
}

void opcode_cb_ea()    // SET 5, D
{
    D |= (unsigned char) (1 << 5);
}

void opcode_cb_eb()    // SET 5, E
{
    E |= (unsigned char) (1 << 5);
}

void opcode_cb_ec()    // SET 5, H
{
    H |= (unsigned char) (1 << 5);
}

void opcode_cb_ed()    // SET 5, L
{
    L |= (unsigned char) (1 << 5);
}

void opcode_cb_ee()    // SET 5, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 5) );
}

void opcode_cb_ef()    // SET 5, A
{
    A |= (unsigned char) (1 << 5);
}

void opcode_cb_f0()    // SET 6, B
{
    B |= (unsigned char) (1 << 6);
}

void opcode_cb_f1()    // SET 6, C
{
    C |= (unsigned char) (1 << 6);
}

void opcode_cb_f2()    // SET 6, D
{
    D |= (unsigned char) (1 << 6);
}

void opcode_cb_f3()    // SET 6, E
{
    E |= (unsigned char) (1 << 6);
}

void opcode_cb_f4()    // SET 6, H
{
    H |= (unsigned char) (1 << 6);
}

void opcode_cb_f5()    // SET 6, L
{
    L |= (unsigned char) (1 << 6);
}

void opcode_cb_f6()    // SET 6, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 6) );
}

void opcode_cb_f7()    // SET 6, A
{
    A |= (unsigned char) (1 << 6);
}

void opcode_cb_f8()    // SET 7, B
{
    B |= (unsigned char) (1 << 7);
}

void opcode_cb_f9()    // SET 7, C
{
    C |= (unsigned char) (1 << 7);
}

void opcode_cb_fa()    // SET 7, D
{
    D |= (unsigned char) (1 << 7);
}

void opcode_cb_fb()    // SET 7, E
{
    E |= (unsigned char) (1 << 7);
}

void opcode_cb_fc()    // SET 7, H
{
    H |= (unsigned char) (1 << 7);
}

void opcode_cb_fd()    // SET 7, L
{
    L |= (unsigned char) (1 << 7);
}

void opcode_cb_fe()    // SET 7, (HL)
{
    writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 7) );
}

void opcode_cb_ff()    // SET 7, A
{
    A |= (unsigned char) (1 << 7);
}

OpcodeInfo OpInfoDD_[256] = {
    { 0, 0 }, // 0x00
    { 0, 0 }, // 0x01
    { 0, 0 }, // 0x02
    { 0, 0 }, // 0x03
    { 0, 0 }, // 0x04
    { 0, 0 }, // 0x05
    { 0, 0 }, // 0x06
    { 0, 0 }, // 0x07
    { 0, 0 }, // 0x08
    { &opcode_dd_09, 15 }, // ADD IX, BC
    { 0, 0 }, // 0x0A
    { 0, 0 }, // 0x0B
    { 0, 0 }, // 0x0C
    { 0, 0 }, // 0x0D
    { 0, 0 }, // 0x0E
    { 0, 0 }, // 0x0F
    { 0, 0 }, // 0x10
    { 0, 0 }, // 0x11
    { 0, 0 }, // 0x12
    { 0, 0 }, // 0x13
    { 0, 0 }, // 0x14
    { 0, 0 }, // 0x15
    { 0, 0 }, // 0x16
    { 0, 0 }, // 0x17
    { 0, 0 }, // 0x18
    { &opcode_dd_19, 15 }, // ADD IX, DE
    { 0, 0 }, // 0x1A
    { 0, 0 }, // 0x1B
    { 0, 0 }, // 0x1C
    { 0, 0 }, // 0x1D
    { 0, 0 }, // 0x1E
    { 0, 0 }, // 0x1F
    { 0, 0 }, // 0x20
    { &opcode_dd_21, 14 }, // LD IX, nn
    { &opcode_dd_22, 20 }, // LD (nn), IX
    { &opcode_dd_23, 10 }, // INC IX
    { &opcode_dd_24,  9 }, // INC IXH
    { &opcode_dd_25,  9 }, // DEC IXH
    { &opcode_dd_26,  9 }, // LD IXH, n
    { 0, 0 }, // 0x27
    { 0, 0 }, // 0x28
    { &opcode_dd_29, 15 }, // ADD IX, IX
    { &opcode_dd_2a, 20 }, // LD IX, (nn)
    { &opcode_dd_2b, 10 }, // DEC IX
    { &opcode_dd_2c,  9 }, // INC IXL
    { &opcode_dd_2d,  9 }, // DEC IXL
    { &opcode_dd_2e,  9 }, // LD IXL, n
    { 0, 0 }, // 0x2F
    { 0, 0 }, // 0x30
    { 0, 0 }, // 0x31
    { 0, 0 }, // 0x32
    { 0, 0 }, // 0x33
    { &opcode_dd_34, 23 }, // INC (IX + d)
    { &opcode_dd_35, 23 }, // DEC (IX + d)
    { &opcode_dd_36, 19 }, // LD (IX + d), n
    { 0, 0 }, // 0x37
    { 0, 0 }, // 0x38
    { &opcode_dd_39, 15 }, // ADD IX, SP
    { 0, 0 }, // 0x3A
    { 0, 0 }, // 0x3B
    { 0, 0 }, // 0x3C
    { 0, 0 }, // 0x3D
    { 0, 0 }, // 0x3E
    { 0, 0 }, // 0x3F
    { 0, 0 }, // 0x40
    { 0, 0 }, // 0x41
    { 0, 0 }, // 0x42
    { 0, 0 }, // 0x43
    { &opcode_dd_44,  9 }, // LD B, IXH
    { &opcode_dd_45,  9 }, // LD B, IXL
    { &opcode_dd_46, 19 }, // LD B, (IX + d)
    { 0, 0 }, // 0x47
    { 0, 0 }, // 0x48
    { 0, 0 }, // 0x49
    { 0, 0 }, // 0x4A
    { 0, 0 }, // 0x4B
    { &opcode_dd_4c,  9 }, // LD C, IXH
    { &opcode_dd_4d,  9 }, // LD C, IXL
    { &opcode_dd_4e, 19 }, // LD C, (IX + d)
    { 0, 0 }, // 0x4F
    { 0, 0 }, // 0x50
    { 0, 0 }, // 0x51
    { 0, 0 }, // 0x52
    { 0, 0 }, // 0x53
    { &opcode_dd_54,  9 }, // LD D, IXH
    { &opcode_dd_55,  9 }, // LD D, IXL
    { &opcode_dd_56, 19 }, // LD D, (IX + d)
    { 0, 0 }, // 0x57
    { 0, 0 }, // 0x58
    { 0, 0 }, // 0x59
    { 0, 0 }, // 0x5A
    { 0, 0 }, // 0x5B
    { &opcode_dd_5c,  9 }, // LD E, IXH
    { &opcode_dd_5d,  9 }, // LD E, IXL
    { &opcode_dd_5e, 19 }, // LD E, (IX + d)
    { 0, 0 }, // 0x5F
    { &opcode_dd_60,  9 }, // LD IXH, B
    { &opcode_dd_61,  9 }, // LD IXH, C
    { &opcode_dd_62,  9 }, // LD IXH, D
    { &opcode_dd_63,  9 }, // LD IXH, E
    { &opcode_dd_64,  9 }, // LD IXH, IXH
    { &opcode_dd_65,  9 }, // LD IXH, IXL
    { &opcode_dd_66,  9 }, // LD H, (IX + d)
    { &opcode_dd_67,  9 }, // LD IXH, A
    { &opcode_dd_68,  9 }, // LD IXL, B
    { &opcode_dd_69,  9 }, // LD IXL, C
    { &opcode_dd_6a,  9 }, // LD IXL, D
    { &opcode_dd_6b,  9 }, // LD IXL, E
    { &opcode_dd_6c,  9 }, // LD IXL, IXH
    { &opcode_dd_6d,  9 }, // LD IXL, IXL
    { &opcode_dd_6e,  9 }, // LD L, (IX + d)
    { &opcode_dd_6f,  9 }, // LD IXL, A
    { &opcode_dd_70, 19 }, // LD (IX + d), B
    { &opcode_dd_71, 19 }, // LD (IX + d), C
    { &opcode_dd_72, 19 }, // LD (IX + d), D
    { &opcode_dd_73, 19 }, // LD (IX + d), E
    { &opcode_dd_74, 19 }, // LD (IX + d), H
    { &opcode_dd_75, 19 }, // LD (IX + d), L
    { 0,19 }, // 0x76
    { &opcode_dd_77, 19 }, // LD (IX + d), A
    { 0, 0 }, // 0x78
    { 0, 0 }, // 0x79
    { 0, 0 }, // 0x7A
    { 0, 0 }, // 0x7B
    { &opcode_dd_7c,  9 }, // LD A, IXH
    { &opcode_dd_7d,  9 }, // LD A, IXL
    { &opcode_dd_7e, 19 }, // LD A, (IX + d)
    { 0, 0 }, // 0x7F
    { 0, 0 }, // 0x80
    { 0, 0 }, // 0x81
    { 0, 0 }, // 0x82
    { 0, 0 }, // 0x83
    { &opcode_dd_84,  9 }, // ADD A, IXH
    { &opcode_dd_85,  9 }, // ADD A, IXL
    { &opcode_dd_86, 19 }, // ADD A, (IX + d)
    { 0, 0 }, // 0x87
    { 0, 0 }, // 0x88
    { 0, 0 }, // 0x89
    { 0, 0 }, // 0x8A
    { 0, 0 }, // 0x8B
    { &opcode_dd_8c,  9 }, // ADC A, IXH
    { &opcode_dd_8d,  9 }, // ADC A, IXL
    { &opcode_dd_8e, 19 }, // ADC A, (IX + d)
    { 0, 0 }, // 0x8F
    { 0, 0 }, // 0x90
    { 0, 0 }, // 0x91
    { 0, 0 }, // 0x92
    { 0, 0 }, // 0x93
    { &opcode_dd_94,  9 }, // SUB IXH
    { &opcode_dd_95,  9 }, // SUB IXL
    { &opcode_dd_96, 19 }, // SUB (IX + d)
    { 0, 0 }, // 0x97
    { 0, 0 }, // 0x98
    { 0, 0 }, // 0x99
    { 0, 0 }, // 0x9A
    { 0, 0 }, // 0x9B
    { &opcode_dd_9c,  9 }, // SBC A, IXH
    { &opcode_dd_9d,  9 }, // SBC A, IXL
    { &opcode_dd_9e, 19 }, // SBC A, (IX + d)
    { 0, 0 }, // 0x9F
    { 0, 0 }, // 0xA0
    { 0, 0 }, // 0xA1
    { 0, 0 }, // 0xA2
    { 0, 0 }, // 0xA3
    { &opcode_dd_a4,  9 }, // AND IXH
    { &opcode_dd_a5,  9 }, // AND IXL
    { &opcode_dd_a6, 19 }, // AND (IX + d)
    { 0, 0 }, // 0xA7
    { 0, 0 }, // 0xA8
    { 0, 0 }, // 0xA9
    { 0, 0 }, // 0xAA
    { 0, 0 }, // 0xAB
    { &opcode_dd_ac,  9 }, // XOR IXH
    { &opcode_dd_ad,  9 }, // XOR IXL
    { &opcode_dd_ae, 19 }, // XOR (IX + d)
    { 0, 0 }, // 0xAF
    { 0, 0 }, // 0xB0
    { 0, 0 }, // 0xB1
    { 0, 0 }, // 0xB2
    { 0, 0 }, // 0xB3
    { &opcode_dd_b4,  9 }, // OR IXH
    { &opcode_dd_b5,  9 }, // OR IXL
    { &opcode_dd_b6, 19 }, // OR (IX + d)
    { 0, 0 }, // 0xB7
    { 0, 0 }, // 0xB8
    { 0, 0 }, // 0xB9
    { 0, 0 }, // 0xBA
    { 0, 0 }, // 0xBB
    { &opcode_dd_bc,  9 }, // CP IXH
    { &opcode_dd_bd,  9 }, // CP IXL
    { &opcode_dd_be, 19 }, // CP (IX + d)
    { 0, 0 }, // 0xBF
    { 0, 0 }, // 0xC0
    { 0, 0 }, // 0xC1
    { 0, 0 }, // 0xC2
    { 0, 0 }, // 0xC3
    { 0, 0 }, // 0xC4
    { 0, 0 }, // 0xC5
    { 0, 0 }, // 0xC6
    { 0, 0 }, // 0xC7
    { 0, 0 }, // 0xC8
    { 0, 0 }, // 0xC9
    { 0, 0 }, // 0xCA
    { &opcode_dd_cb,  0 }, // 
    { 0, 0 }, // 0xCC
    { 0, 0 }, // 0xCD
    { 0, 0 }, // 0xCE
    { 0, 0 }, // 0xCF
    { 0, 0 }, // 0xD0
    { 0, 0 }, // 0xD1
    { 0, 0 }, // 0xD2
    { 0, 0 }, // 0xD3
    { 0, 0 }, // 0xD4
    { 0, 0 }, // 0xD5
    { 0, 0 }, // 0xD6
    { 0, 0 }, // 0xD7
    { 0, 0 }, // 0xD8
    { 0, 0 }, // 0xD9
    { 0, 0 }, // 0xDA
    { 0, 0 }, // 0xDB
    { 0, 0 }, // 0xDC
    { 0, 0 }, // 0xDD
    { 0, 0 }, // 0xDE
    { 0, 0 }, // 0xDF
    { 0, 0 }, // 0xE0
    { &opcode_dd_e1, 14 }, // POP IX
    { 0, 0 }, // 0xE2
    { &opcode_dd_e3, 23 }, // EX (SP), IX
    { 0, 0 }, // 0xE4
    { &opcode_dd_e5, 15 }, // PUSH IX
    { 0, 0 }, // 0xE6
    { 0, 0 }, // 0xE7
    { 0, 0 }, // 0xE8
    { &opcode_dd_e9,  8 }, // JP (IX)
    { 0, 0 }, // 0xEA
    { 0, 0 }, // 0xEB
    { 0, 0 }, // 0xEC
    { 0, 0 }, // 0xED
    { 0, 0 }, // 0xEE
    { 0, 0 }, // 0xEF
    { 0, 0 }, // 0xF0
    { 0, 0 }, // 0xF1
    { 0, 0 }, // 0xF2
    { 0, 0 }, // 0xF3
    { 0, 0 }, // 0xF4
    { 0, 0 }, // 0xF5
    { 0, 0 }, // 0xF6
    { 0, 0 }, // 0xF7
    { 0, 0 }, // 0xF8
    { &opcode_dd_f9, 10 }, // LD SP, IX
    { 0, 0 }, // 0xFA
    { 0, 0 }, // 0xFB
    { 0, 0 }, // 0xFC
    { 0, 0 }, // 0xFD
    { 0, 0 }, // 0xFE
    { 0, 0 }  // 0xFF
};

void opcode_dd_09()    // ADD IX, BC
{
    unsigned rr = BC();

    F &= (Zero | Sign | Parity);
    if( ((IX & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry;
    IX += rr;
    if( IX & 0x10000 ) F |= Carry;
}

void opcode_dd_19()    // ADD IX, DE
{
    unsigned rr = DE();

    F &= (Zero | Sign | Parity);
    if( ((IX & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry;
    IX += rr;
    if( IX & 0x10000 ) F |= Carry;
}

void opcode_dd_21()    // LD IX, nn
{
    IX = fetchWord();
}

void opcode_dd_22()    // LD (nn), IX
{
    writeWord( fetchWord(), IX );
}

void opcode_dd_23()    // INC IX
{
    IX++;
}

void opcode_dd_24()    // INC IXH
{
    IX = (IX & 0xFF) | ((unsigned)incByte( IX >> 8 ) << 8);
}

void opcode_dd_25()    // DEC IXH
{
    IX = (IX & 0xFF) | ((unsigned)decByte( IX >> 8 ) << 8);
}

void opcode_dd_26()    // LD IXH, n
{
    IX = (IX & 0xFF) | ((unsigned)fetchByte() << 8);
}

void opcode_dd_29()    // ADD IX, IX
{
    F &= (Zero | Sign | Parity);
    if( IX & 0x800 ) F |= Halfcarry;
    IX += IX;
    if( IX & 0x10000 ) F |= Carry;
}

void opcode_dd_2a()    // LD IX, (nn)
{
    IX = readWord( fetchWord() );
}

void opcode_dd_2b()    // DEC IX
{
    IX--;
}

void opcode_dd_2c()    // INC IXL
{
    IX = (IX & 0xFF00) | incByte( IX & 0xFF );
}

void opcode_dd_2d()    // DEC IXL
{
    IX = (IX & 0xFF00) | decByte( IX & 0xFF );
}

void opcode_dd_2e()    // LD IXL, n
{
    IX = (IX & 0xFF00) | fetchByte();
}

void opcode_dd_34()    // INC (IX + d)
{
    unsigned    addr = addDispl( IX, fetchByte() );

    writeByte( addr, incByte( readByte( addr ) ) );
}

void opcode_dd_35()    // DEC (IX + d)
{
    unsigned    addr = addDispl( IX, fetchByte() );

    writeByte( addr, decByte( readByte( addr ) ) );
}

void opcode_dd_36()    // LD (IX + d), n
{
    unsigned    addr = addDispl( IX, fetchByte() );

    writeByte( addr, fetchByte() );
}

void opcode_dd_39()    // ADD IX, SP
{
    F &= (Zero | Sign | Parity);
    if( ((IX & 0xFFF)+(SP & 0xFFF)) > 0xFFF ) F |= Halfcarry;
    IX += SP;
    if( IX & 0x10000 ) F |= Carry;
}

void opcode_dd_44()    // LD B, IXH
{
    B = IX >> 8;
}

void opcode_dd_45()    // LD B, IXL
{
    B = IX & 0xFF;
}

void opcode_dd_46()    // LD B, (IX + d)
{
    B = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_4c()    // LD C, IXH
{
    C = IX >> 8;
}

void opcode_dd_4d()    // LD C, IXL
{
    C = IX & 0xFF;
}

void opcode_dd_4e()    // LD C, (IX + d)
{
    C = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_54()    // LD D, IXH
{
    D = IX >> 8;
}

void opcode_dd_55()    // LD D, IXL
{
    D = IX & 0xFF;
}

void opcode_dd_56()    // LD D, (IX + d)
{
    D = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_5c()    // LD E, IXH
{
    E = IX >> 8;
}

void opcode_dd_5d()    // LD E, IXL
{
    E = IX & 0xFF;
}

void opcode_dd_5e()    // LD E, (IX + d)
{
    E = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_60()    // LD IXH, B
{
    IX = (IX & 0xFF) | ((unsigned)B << 8);
}

void opcode_dd_61()    // LD IXH, C
{
    IX = (IX & 0xFF) | ((unsigned)C << 8);
}

void opcode_dd_62()    // LD IXH, D
{
    IX = (IX & 0xFF) | ((unsigned)D << 8);
}

void opcode_dd_63()    // LD IXH, E
{
    IX = (IX & 0xFF) | ((unsigned)E << 8);
}

void opcode_dd_64()    // LD IXH, IXH
{
}

void opcode_dd_65()    // LD IXH, IXL
{
    IX = (IX & 0xFF) | ((IX << 8) & 0xFF00);
}

void opcode_dd_66()    // LD H, (IX + d)
{
    H = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_67()    // LD IXH, A
{
    IX = (IX & 0xFF) | ((unsigned)A << 8);
}

void opcode_dd_68()    // LD IXL, B
{
    IX = (IX & 0xFF00) | B;
}

void opcode_dd_69()    // LD IXL, C
{
    IX = (IX & 0xFF00) | C;
}

void opcode_dd_6a()    // LD IXL, D
{
    IX = (IX & 0xFF00) | D;
}

void opcode_dd_6b()    // LD IXL, E
{
    IX = (IX & 0xFF00) | E;
}

void opcode_dd_6c()    // LD IXL, IXH
{
    IX = (IX & 0xFF00) | ((IX >> 8) & 0xFF);
}

void opcode_dd_6d()    // LD IXL, IXL
{
}

void opcode_dd_6e()    // LD L, (IX + d)
{
    L = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_6f()    // LD IXL, A
{
    IX = (IX & 0xFF00) | A;
}

void opcode_dd_70()    // LD (IX + d), B
{
    writeByte( addDispl(IX,fetchByte()), B );
}

void opcode_dd_71()    // LD (IX + d), C
{
    writeByte( addDispl(IX,fetchByte()), C );
}

void opcode_dd_72()    // LD (IX + d), D
{
    writeByte( addDispl(IX,fetchByte()), D );
}

void opcode_dd_73()    // LD (IX + d), E
{
    writeByte( addDispl(IX,fetchByte()), E );
}

void opcode_dd_74()    // LD (IX + d), H
{
    writeByte( addDispl(IX,fetchByte()), H );
}

void opcode_dd_75()    // LD (IX + d), L
{
    writeByte( addDispl(IX,fetchByte()), L );
}

void opcode_dd_77()    // LD (IX + d), A
{
    writeByte( addDispl(IX,fetchByte()), A );
}

void opcode_dd_7c()    // LD A, IXH
{
    A = IX >> 8;
}

void opcode_dd_7d()    // LD A, IXL
{
    A = IX & 0xFF;
}

void opcode_dd_7e()    // LD A, (IX + d)
{
    A = readByte( addDispl(IX,fetchByte()) );
}

void opcode_dd_84()    // ADD A, IXH
{
    addByte( IX >> 8, 0 );
}

void opcode_dd_85()    // ADD A, IXL
{
    addByte( IX & 0xFF, 0 );
}

void opcode_dd_86()    // ADD A, (IX + d)
{
    addByte( readByte( addDispl(IX,fetchByte()) ), 0 );
}

void opcode_dd_8c()    // ADC A, IXH
{
    addByte( IX >> 8, F & Carry );
}

void opcode_dd_8d()    // ADC A, IXL
{
    addByte( IX & 0xFF, F & Carry );
}

void opcode_dd_8e()    // ADC A, (IX + d)
{
    addByte( readByte( addDispl(IX,fetchByte()) ), F & Carry );
}

void opcode_dd_94()    // SUB IXH
{
    A = subByte( IX >> 8, 0 );
}

void opcode_dd_95()    // SUB IXL
{
    A = subByte( IX & 0xFF, 0 );
}

void opcode_dd_96()    // SUB (IX + d)
{
    A = subByte( readByte( addDispl(IX,fetchByte()) ), 0 );
}

void opcode_dd_9c()    // SBC A, IXH
{
    A = subByte( IX >> 8, F & Carry );
}

void opcode_dd_9d()    // SBC A, IXL
{
    A = subByte( IX & 0xFF, F & Carry );
}

void opcode_dd_9e()    // SBC A, (IX + d)
{
    A = subByte( readByte( addDispl(IX,fetchByte()) ), F & Carry );
}

void opcode_dd_a4()    // AND IXH
{
    A &= IX >> 8;
    setFlags35PSZ000();
    F |= Halfcarry;
}

void opcode_dd_a5()    // AND IXL
{
    A &= IX & 0xFF;
    setFlags35PSZ000();
    F |= Halfcarry;
}

void opcode_dd_a6()    // AND (IX + d)
{
    A &= readByte( addDispl(IX,fetchByte()) );
    setFlags35PSZ000();
    F |= Halfcarry;
}

void opcode_dd_ac()    // XOR IXH
{
    A ^= IX >> 8;
    setFlags35PSZ000();
}

void opcode_dd_ad()    // XOR IXL
{
    A ^= IX & 0xFF;
    setFlags35PSZ000();
}

void opcode_dd_ae()    // XOR (IX + d)
{
    A ^= readByte( addDispl(IX,fetchByte()) );
    setFlags35PSZ000();
}

void opcode_dd_b4()    // OR IXH
{
    A |= IX >> 8;
    setFlags35PSZ000();
}

void opcode_dd_b5()    // OR IXL
{
    A |= IX & 0xFF;
    setFlags35PSZ000();
}

void opcode_dd_b6()    // OR (IX + d)
{
    A |= readByte( addDispl(IX,fetchByte()) );
    setFlags35PSZ000();
}

void opcode_dd_bc()    // CP IXH
{
    cmpByte( IX >> 8 );
}

void opcode_dd_bd()    // CP IXL
{
    cmpByte( IX & 0xFF );
}

void opcode_dd_be()    // CP (IX + d)
{
    cmpByte( readByte( addDispl(IX,fetchByte()) ) );
}

void opcode_dd_cb()    // 
{
    do_opcode_xycb( IX );
}

void opcode_dd_e1()    // POP IX
{
    IX = readWord( SP );
    SP += 2;
}

void opcode_dd_e3()    // EX (SP), IX
{
    unsigned    ix = IX;

    IX = readWord( SP );
    writeWord( SP, ix );
}

void opcode_dd_e5()    // PUSH IX
{
    SP -= 2;
    writeWord( SP, IX );
}

void opcode_dd_e9()    // JP (IX)
{
    PC = IX;
}

void opcode_dd_f9()    // LD SP, IX
{
    SP = IX;
}

OpcodeInfo OpInfoED_[256] = {
    { 0, 0 }, // 0x00
    { 0, 0 }, // 0x01
    { 0, 0 }, // 0x02
    { 0, 0 }, // 0x03
    { 0, 0 }, // 0x04
    { 0, 0 }, // 0x05
    { 0, 0 }, // 0x06
    { 0, 0 }, // 0x07
    { 0, 0 }, // 0x08
    { 0, 0 }, // 0x09
    { 0, 0 }, // 0x0A
    { 0, 0 }, // 0x0B
    { 0, 0 }, // 0x0C
    { 0, 0 }, // 0x0D
    { 0, 0 }, // 0x0E
    { 0, 0 }, // 0x0F
    { 0, 0 }, // 0x10
    { 0, 0 }, // 0x11
    { 0, 0 }, // 0x12
    { 0, 0 }, // 0x13
    { 0, 0 }, // 0x14
    { 0, 0 }, // 0x15
    { 0, 0 }, // 0x16
    { 0, 0 }, // 0x17
    { 0, 0 }, // 0x18
    { 0, 0 }, // 0x19
    { 0, 0 }, // 0x1A
    { 0, 0 }, // 0x1B
    { 0, 0 }, // 0x1C
    { 0, 0 }, // 0x1D
    { 0, 0 }, // 0x1E
    { 0, 0 }, // 0x1F
    { 0, 0 }, // 0x20
    { 0, 0 }, // 0x21
    { 0, 0 }, // 0x22
    { 0, 0 }, // 0x23
    { 0, 0 }, // 0x24
    { 0, 0 }, // 0x25
    { 0, 0 }, // 0x26
    { 0, 0 }, // 0x27
    { 0, 0 }, // 0x28
    { 0, 0 }, // 0x29
    { 0, 0 }, // 0x2A
    { 0, 0 }, // 0x2B
    { 0, 0 }, // 0x2C
    { 0, 0 }, // 0x2D
    { 0, 0 }, // 0x2E
    { 0, 0 }, // 0x2F
    { 0, 0 }, // 0x30
    { 0, 0 }, // 0x31
    { 0, 0 }, // 0x32
    { 0, 0 }, // 0x33
    { 0, 0 }, // 0x34
    { 0, 0 }, // 0x35
    { 0, 0 }, // 0x36
    { 0, 0 }, // 0x37
    { 0, 0 }, // 0x38
    { 0, 0 }, // 0x39
    { 0, 0 }, // 0x3A
    { 0, 0 }, // 0x3B
    { 0, 0 }, // 0x3C
    { 0, 0 }, // 0x3D
    { 0, 0 }, // 0x3E
    { 0, 0 }, // 0x3F
    { &opcode_ed_40, 12 }, // IN B, (C)
    { &opcode_ed_41, 12 }, // OUT (C), B
    { &opcode_ed_42, 15 }, // SBC HL, BC
    { &opcode_ed_43, 20 }, // LD (nn), BC
    { &opcode_ed_44,  8 }, // NEG
    { &opcode_ed_45, 14 }, // RETN
    { &opcode_ed_46,  8 }, // IM 0
    { &opcode_ed_47,  9 }, // LD I, A
    { &opcode_ed_48, 12 }, // IN C, (C)
    { &opcode_ed_49, 12 }, // OUT (C), C
    { &opcode_ed_4a, 15 }, // ADC HL, BC
    { &opcode_ed_4b, 20 }, // LD BC, (nn)
    { &opcode_ed_4c,  8 }, // NEG
    { &opcode_ed_4d, 14 }, // RETI
    { &opcode_ed_4e,  8 }, // IM 0/1
    { &opcode_ed_4f,  9 }, // LD R, A
    { &opcode_ed_50, 12 }, // IN D, (C)
    { &opcode_ed_51, 12 }, // OUT (C), D
    { &opcode_ed_52, 15 }, // SBC HL, DE
    { &opcode_ed_53, 20 }, // LD (nn), DE
    { &opcode_ed_54,  8 }, // NEG
    { &opcode_ed_55, 14 }, // RETN
    { &opcode_ed_56,  8 }, // IM 1
    { &opcode_ed_57,  9 }, // LD A, I
    { &opcode_ed_58, 12 }, // IN E, (C)
    { &opcode_ed_59, 12 }, // OUT (C), E
    { &opcode_ed_5a, 15 }, // ADC HL, DE
    { &opcode_ed_5b, 20 }, // LD DE, (nn)
    { &opcode_ed_5c,  8 }, // NEG
    { &opcode_ed_5d, 14 }, // RETN
    { &opcode_ed_5e,  8 }, // IM 2
    { &opcode_ed_5f,  9 }, // LD A, R
    { &opcode_ed_60, 12 }, // IN H, (C)
    { &opcode_ed_61, 12 }, // OUT (C), H
    { &opcode_ed_62, 15 }, // SBC HL, HL
    { &opcode_ed_63, 20 }, // LD (nn), HL
    { &opcode_ed_64,  8 }, // NEG
    { &opcode_ed_65, 14 }, // RETN
    { &opcode_ed_66,  8 }, // IM 0
    { &opcode_ed_67, 18 }, // RRD
    { &opcode_ed_68, 12 }, // IN L, (C)
    { &opcode_ed_69, 12 }, // OUT (C), L
    { &opcode_ed_6a, 15 }, // ADC HL, HL
    { &opcode_ed_6b, 20 }, // LD HL, (nn)
    { &opcode_ed_6c,  8 }, // NEG
    { &opcode_ed_6d, 14 }, // RETN
    { &opcode_ed_6e,  8 }, // IM 0/1
    { &opcode_ed_6f, 18 }, // RLD
    { &opcode_ed_70, 12 }, // IN (C) / IN F, (C)
    { &opcode_ed_71, 12 }, // OUT (C), 0
    { &opcode_ed_72, 15 }, // SBC HL, SP
    { &opcode_ed_73, 20 }, // LD (nn), SP
    { &opcode_ed_74,  8 }, // NEG
    { &opcode_ed_75, 14 }, // RETN
    { &opcode_ed_76,  8 }, // IM 1
    { 0, 0 }, // 0x77
    { &opcode_ed_78, 12 }, // IN A, (C)
    { &opcode_ed_79, 12 }, // OUT (C), A
    { &opcode_ed_7a, 15 }, // ADC HL, SP
    { &opcode_ed_7b, 20 }, // LD SP, (nn)
    { &opcode_ed_7c,  8 }, // NEG
    { &opcode_ed_7d, 14 }, // RETN
    { &opcode_ed_7e,  8 }, // IM 2
    { 0, 0 }, // 0x7F
    { 0, 0 }, // 0x80
    { 0, 0 }, // 0x81
    { 0, 0 }, // 0x82
    { 0, 0 }, // 0x83
    { 0, 0 }, // 0x84
    { 0, 0 }, // 0x85
    { 0, 0 }, // 0x86
    { 0, 0 }, // 0x87
    { 0, 0 }, // 0x88
    { 0, 0 }, // 0x89
    { 0, 0 }, // 0x8A
    { 0, 0 }, // 0x8B
    { 0, 0 }, // 0x8C
    { 0, 0 }, // 0x8D
    { 0, 0 }, // 0x8E
    { 0, 0 }, // 0x8F
    { 0, 0 }, // 0x90
    { 0, 0 }, // 0x91
    { 0, 0 }, // 0x92
    { 0, 0 }, // 0x93
    { 0, 0 }, // 0x94
    { 0, 0 }, // 0x95
    { 0, 0 }, // 0x96
    { 0, 0 }, // 0x97
    { 0, 0 }, // 0x98
    { 0, 0 }, // 0x99
    { 0, 0 }, // 0x9A
    { 0, 0 }, // 0x9B
    { 0, 0 }, // 0x9C
    { 0, 0 }, // 0x9D
    { 0, 0 }, // 0x9E
    { 0, 0 }, // 0x9F
    { &opcode_ed_a0, 16 }, // LDI
    { &opcode_ed_a1, 16 }, // CPI
    { &opcode_ed_a2, 16 }, // INI
    { &opcode_ed_a3, 16 }, // OUTI
    { 0, 0 }, // 0xA4
    { 0, 0 }, // 0xA5
    { 0, 0 }, // 0xA6
    { 0, 0 }, // 0xA7
    { &opcode_ed_a8, 16 }, // LDD
    { &opcode_ed_a9, 16 }, // CPD
    { &opcode_ed_aa, 16 }, // IND
    { &opcode_ed_ab, 16 }, // OUTD
    { 0, 0 }, // 0xAC
    { 0, 0 }, // 0xAD
    { 0, 0 }, // 0xAE
    { 0, 0 }, // 0xAF
    { &opcode_ed_b0,  0 }, // LDIR
    { &opcode_ed_b1,  0 }, // CPIR
    { &opcode_ed_b2,  0 }, // INIR
    { &opcode_ed_b3,  0 }, // OTIR
    { 0, 0 }, // 0xB4
    { 0, 0 }, // 0xB5
    { 0, 0 }, // 0xB6
    { 0, 0 }, // 0xB7
    { &opcode_ed_b8,  0 }, // LDDR
    { &opcode_ed_b9,  0 }, // CPDR
    { &opcode_ed_ba,  0 }, // INDR
    { &opcode_ed_bb,  0 }, // OTDR
    { 0, 0 }, // 0xBC
    { 0, 0 }, // 0xBD
    { 0, 0 }, // 0xBE
    { 0, 0 }, // 0xBF
    { 0, 0 }, // 0xC0
    { 0, 0 }, // 0xC1
    { 0, 0 }, // 0xC2
    { 0, 0 }, // 0xC3
    { 0, 0 }, // 0xC4
    { 0, 0 }, // 0xC5
    { 0, 0 }, // 0xC6
    { 0, 0 }, // 0xC7
    { 0, 0 }, // 0xC8
    { 0, 0 }, // 0xC9
    { 0, 0 }, // 0xCA
    { 0, 0 }, // 0xCB
    { 0, 0 }, // 0xCC
    { 0, 0 }, // 0xCD
    { 0, 0 }, // 0xCE
    { 0, 0 }, // 0xCF
    { 0, 0 }, // 0xD0
    { 0, 0 }, // 0xD1
    { 0, 0 }, // 0xD2
    { 0, 0 }, // 0xD3
    { 0, 0 }, // 0xD4
    { 0, 0 }, // 0xD5
    { 0, 0 }, // 0xD6
    { 0, 0 }, // 0xD7
    { 0, 0 }, // 0xD8
    { 0, 0 }, // 0xD9
    { 0, 0 }, // 0xDA
    { 0, 0 }, // 0xDB
    { 0, 0 }, // 0xDC
    { 0, 0 }, // 0xDD
    { 0, 0 }, // 0xDE
    { 0, 0 }, // 0xDF
    { 0, 0 }, // 0xE0
    { 0, 0 }, // 0xE1
    { 0, 0 }, // 0xE2
    { 0, 0 }, // 0xE3
    { 0, 0 }, // 0xE4
    { 0, 0 }, // 0xE5
    { 0, 0 }, // 0xE6
    { 0, 0 }, // 0xE7
    { 0, 0 }, // 0xE8
    { 0, 0 }, // 0xE9
    { 0, 0 }, // 0xEA
    { 0, 0 }, // 0xEB
    { 0, 0 }, // 0xEC
    { 0, 0 }, // 0xED
    { 0, 0 }, // 0xEE
    { 0, 0 }, // 0xEF
    { 0, 0 }, // 0xF0
    { 0, 0 }, // 0xF1
    { 0, 0 }, // 0xF2
    { 0, 0 }, // 0xF3
    { 0, 0 }, // 0xF4
    { 0, 0 }, // 0xF5
    { 0, 0 }, // 0xF6
    { 0, 0 }, // 0xF7
    { 0, 0 }, // 0xF8
    { 0, 0 }, // 0xF9
    { 0, 0 }, // 0xFA
    { 0, 0 }, // 0xFB
    { 0, 0 }, // 0xFC
    { 0, 0 }, // 0xFD
    { 0, 0 }, // 0xFE
    { 0, 0 }  // 0xFF
};

void opcode_ed_40()    // IN B, (C)
{
    B = inpReg();
}

void opcode_ed_41()    // OUT (C), B
{
    writePort( C, B );
}

void opcode_ed_42()    // SBC HL, BC
{
    unsigned char a;

    a = A;
    A = L; L = subByte( C, F & Carry );
    A = H; H = subByte( B, F & Carry );
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_43()    // LD (nn), BC
{
    unsigned addr = fetchWord();

    writeByte( addr, C );
    writeByte( addr+1, B );
}

void opcode_ed_44()    // NEG
{
    unsigned char   a = A;

    A = 0;
    A = subByte( a, 0 );
}

void opcode_ed_45()    // RETN
{
    retFromSub();
    iflags_ &= ~IFF1; 
    if( iflags_ & IFF2 ) iflags_ |= IFF1;
}

void opcode_ed_46()    // IM 0
{
    setInterruptMode( 0 );
}

void opcode_ed_47()    // LD I, A
{
    I = A;
}

void opcode_ed_48()    // IN C, (C)
{
    C = inpReg();
}

void opcode_ed_49()    // OUT (C), C
{
    writePort( C, C );
}

void opcode_ed_4a()    // ADC HL, BC
{
    unsigned char a;

    a = A;
    A = L; addByte( C, F & Carry ); L = A;
    A = H; addByte( B, F & Carry ); H = A;
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_4b()    // LD BC, (nn)
{
    unsigned    addr = fetchWord();

    C = readByte( addr );
    B = readByte( addr+1 );
}

void opcode_ed_4c()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_4d()    // RETI
{
    retFromSub();
    //onReturnFromInterrupt();
}

void opcode_ed_4e()    // IM 0/1
{
    setInterruptMode( 0 );
}

void opcode_ed_4f()    // LD R, A
{
    R = A;
}

void opcode_ed_50()    // IN D, (C)
{
    D = inpReg();
}

void opcode_ed_51()    // OUT (C), D
{
    writePort( C, D );
}

void opcode_ed_52()    // SBC HL, DE
{
    unsigned char a;

    a = A;
    A = L; L = subByte( E, F & Carry );
    A = H; H = subByte( D, F & Carry );
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_53()    // LD (nn), DE
{
    unsigned addr = fetchWord();

    writeByte( addr, E );
    writeByte( addr+1, D );
}

void opcode_ed_54()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_55()    // RETN
{
    opcode_ed_45();
}

void opcode_ed_56()    // IM 1
{
    setInterruptMode( 1 );
}

void opcode_ed_57()    // LD A, I
{
    A = I;
    setFlags35PSZ();
    F &= ~(Halfcarry | Parity | AddSub);
    if( iflags_ & IFF2 ) F |= Parity;
}

void opcode_ed_58()    // IN E, (C)
{
    E = inpReg();
}

void opcode_ed_59()    // OUT (C), E
{
    writePort( C, E );
}

void opcode_ed_5a()    // ADC HL, DE
{
    unsigned char a;

    a = A;
    A = L; addByte( E, F & Carry ); L = A;
    A = H; addByte( D, F & Carry ); H = A;
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_5b()    // LD DE, (nn)
{
    unsigned    addr = fetchWord();

    E = readByte( addr );
    D = readByte( addr+1 );
}

void opcode_ed_5c()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_5d()    // RETN
{
    opcode_ed_45();
}

void opcode_ed_5e()    // IM 2
{
    setInterruptMode( 2 );
}

void opcode_ed_5f()    // LD A, R
{
    A = R;
    setFlags35PSZ();
    F &= ~(Halfcarry | Parity | AddSub);
    if( iflags_ & IFF2 ) F |= Parity;
}

void opcode_ed_60()    // IN H, (C)
{
    H = inpReg();
}

void opcode_ed_61()    // OUT (C), H
{
    writePort( C, H );
}

void opcode_ed_62()    // SBC HL, HL
{
    unsigned char a;

    a = A;
    A = L; L = subByte( L, F & Carry );
    A = H; H = subByte( H, F & Carry );
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_63()    // LD (nn), HL
{
    unsigned addr = fetchWord();

    writeByte( addr, L );
    writeByte( addr+1, H );
}

void opcode_ed_64()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_65()    // RETN
{
    opcode_ed_45();
}

void opcode_ed_66()    // IM 0
{
    setInterruptMode( 0 );
}

void opcode_ed_67()    // RRD
{
    unsigned char   x = readByte( HL() );

    writeByte( HL(), (A << 4) | (x >> 4) );
    A = (A & 0xF0) | (x & 0x0F);
    setFlags35PSZ();
    F &= ~(Halfcarry | AddSub);
}

void opcode_ed_68()    // IN L, (C)
{
    L = inpReg();
}

void opcode_ed_69()    // OUT (C), L
{
    writePort( C, L );
}

void opcode_ed_6a()    // ADC HL, HL
{
    unsigned char a;

    a = A;
    A = L; addByte( L, F & Carry ); L = A;
    A = H; addByte( H, F & Carry ); H = A;
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_6b()    // LD HL, (nn)
{
    unsigned    addr = fetchWord();

    L = readByte( addr );
    H = readByte( addr+1 );
}

void opcode_ed_6c()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_6d()    // RETN
{
    opcode_ed_45();
}

void opcode_ed_6e()    // IM 0/1
{
    setInterruptMode( 0 );
}

void opcode_ed_6f()    // RLD
{
    unsigned char   x = readByte( HL() );

    writeByte( HL(), (x << 4) | (A & 0x0F) );
    A = (A & 0xF0) | (x >> 4);
    setFlags35PSZ();
    F &= ~(Halfcarry | AddSub);
}

void opcode_ed_70()    // IN (C) / IN F, (C)
{
    inpReg();
}

void opcode_ed_71()    // OUT (C), 0
{
    writePort( C, 0 );
}

void opcode_ed_72()    // SBC HL, SP
{
    unsigned char a;

    a = A;
    A = L; L = subByte( SP & 0xFF, F & Carry );
    A = H; H = subByte( (SP >> 8) & 0xFF, F & Carry );
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_73()    // LD (nn), SP
{
    writeWord( fetchWord(), SP );
}

void opcode_ed_74()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_75()    // RETN
{
    opcode_ed_45();
}

void opcode_ed_76()    // IM 1
{
    setInterruptMode( 1 );
}

void opcode_ed_78()    // IN A, (C)
{
    A = inpReg();
}

void opcode_ed_79()    // OUT (C), A
{
    writePort( C, A );
}

void opcode_ed_7a()    // ADC HL, SP
{
    unsigned char a;

    a = A;
    A = L; addByte( SP & 0xFF, F & Carry ); L = A;
    A = H; addByte( (SP >> 8) & 0xFF, F & Carry ); H = A;
    A = a;
    if( HL() == 0 ) F |= Zero; else F &= ~Zero;
}

void opcode_ed_7b()    // LD SP, (nn)
{
    SP = readWord( fetchWord() );
}

void opcode_ed_7c()    // NEG
{
    opcode_ed_44();
}

void opcode_ed_7d()    // RETN
{
    opcode_ed_45();
}

void opcode_ed_7e()    // IM 2
{
    setInterruptMode( 2 );
}

void opcode_ed_a0()    // LDI
{
    writeByte( DE(), readByte( HL() ) );
    if( ++L == 0 ) ++H; // HL++
    if( ++E == 0 ) ++D; // DE++
    if( C-- == 0 ) --B; // BC--
    F &= ~(Halfcarry | Subtraction | Parity);
    if( BC() ) F |= Parity;
}

void opcode_ed_a1()    // CPI
{
    unsigned char f = F;

    cmpByte( readByte( HL() ) );
    if( ++L == 0 ) ++H; // HL++
    if( C-- == 0 ) --B; // BC--
    F = (F & ~(Carry | Parity)) | (f & Carry);
    if( BC() ) F |= Parity;
}

void opcode_ed_a2()    // INI
{
    writeByte( HL(), readPort( C ) );
    if( ++L == 0 ) ++H; // HL++
    B = decByte( B );
}

void opcode_ed_a3()    // OUTI
{
    writePort( C, readByte( HL() ) );
    if( ++L == 0 ) ++H; // HL++
    B = decByte( B );
}

void opcode_ed_a8()    // LDD
{
    writeByte( DE(), readByte( HL() ) );
    if( L-- == 0 ) --H; // HL--
    if( E-- == 0 ) --D; // DE--
    if( C-- == 0 ) --B; // BC--
    F &= ~(Halfcarry | Subtraction | Parity);
    if( BC() ) F |= Parity;
}

void opcode_ed_a9()    // CPD
{
    unsigned char f = F;

    cmpByte( readByte( HL() ) );
    if( L-- == 0 ) --H; // HL--
    if( C-- == 0 ) --B; // BC--
    F = (F & ~(Carry | Parity)) | (f & Carry);
    if( BC() ) F |= Parity;
}

void opcode_ed_aa()    // IND
{
    writeByte( HL(), readPort( C ) );
    if( L-- == 0 ) --H; // HL--
    B = decByte( B );
}

void opcode_ed_ab()    // OUTD
{
    writePort( C, readByte( HL() ) );
    if( L-- == 0 ) --H; // HL--
    B = decByte( B );
}

void opcode_ed_b0()    // LDIR
{
    opcode_ed_a0(); // LDI
    if( F & Parity ) { // After LDI, the Parity flag will be zero when BC=0
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

void opcode_ed_b1()    // CPIR
{
    opcode_ed_a1(); // CPI
    if( (F & Parity) && !(F & Zero) ) { // Parity clear when BC=0, Zero set when A=(HL)
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

void opcode_ed_b2()    // INIR
{
    opcode_ed_a2(); // INI
    if( B != 0 ) {
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

void opcode_ed_b3()    // OTIR
{
    opcode_ed_a3(); // OUTI
    if( B != 0 ) {
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

void opcode_ed_b8()    // LDDR
{
    opcode_ed_a8(); // LDD
    if( F & Parity ) { // After LDD, the Parity flag will be zero when BC=0
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

void opcode_ed_b9()    // CPDR
{
    opcode_ed_a9(); // CPD
    if( (F & Parity) && !(F & Zero) ) { // Parity clear when BC=0, Zero set when A=(HL)
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

void opcode_ed_ba()    // INDR
{
    opcode_ed_aa(); // IND
    if( B != 0 ) {
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}
                            
void opcode_ed_bb()    // OTDR
{
    opcode_ed_ab(); // OUTD
    if( B != 0 ) {
        cycles_ += 5;
        PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur)
    }
}

OpcodeInfo OpInfoFD_[256] = {
    { 0, 0 }, // 0x00
    { 0, 0 }, // 0x01
    { 0, 0 }, // 0x02
    { 0, 0 }, // 0x03
    { 0, 0 }, // 0x04
    { 0, 0 }, // 0x05
    { 0, 0 }, // 0x06
    { 0, 0 }, // 0x07
    { 0, 0 }, // 0x08
    { &opcode_fd_09, 15 }, // ADD IY, BC
    { 0, 0 }, // 0x0A
    { 0, 0 }, // 0x0B
    { 0, 0 }, // 0x0C
    { 0, 0 }, // 0x0D
    { 0, 0 }, // 0x0E
    { 0, 0 }, // 0x0F
    { 0, 0 }, // 0x10
    { 0, 0 }, // 0x11
    { 0, 0 }, // 0x12
    { 0, 0 }, // 0x13
    { 0, 0 }, // 0x14
    { 0, 0 }, // 0x15
    { 0, 0 }, // 0x16
    { 0, 0 }, // 0x17
    { 0, 0 }, // 0x18
    { &opcode_fd_19, 15 }, // ADD IY, DE
    { 0, 0 }, // 0x1A
    { 0, 0 }, // 0x1B
    { 0, 0 }, // 0x1C
    { 0, 0 }, // 0x1D
    { 0, 0 }, // 0x1E
    { 0, 0 }, // 0x1F
    { 0, 0 }, // 0x20
    { &opcode_fd_21, 14 }, // LD IY, nn
    { &opcode_fd_22, 20 }, // LD (nn), IY
    { &opcode_fd_23, 10 }, // INC IY
    { &opcode_fd_24,  9 }, // INC IYH
    { &opcode_fd_25,  9 }, // DEC IYH
    { &opcode_fd_26,  9 }, // LD IYH, n
    { 0, 0 }, // 0x27
    { 0, 0 }, // 0x28
    { &opcode_fd_29, 15 }, // ADD IY, IY
    { &opcode_fd_2a, 20 }, // LD IY, (nn)
    { &opcode_fd_2b, 10 }, // DEC IY
    { &opcode_fd_2c,  9 }, // INC IYL
    { &opcode_fd_2d,  9 }, // DEC IYL
    { &opcode_fd_2e,  9 }, // LD IYL, n
    { 0, 0 }, // 0x2F
    { 0, 0 }, // 0x30
    { 0, 0 }, // 0x31
    { 0, 0 }, // 0x32
    { 0, 0 }, // 0x33
    { &opcode_fd_34, 23 }, // INC (IY + d)
    { &opcode_fd_35, 23 }, // DEC (IY + d)
    { &opcode_fd_36, 19 }, // LD (IY + d), n
    { 0, 0 }, // 0x37
    { 0, 0 }, // 0x38
    { &opcode_fd_39, 15 }, // ADD IY, SP
    { 0, 0 }, // 0x3A
    { 0, 0 }, // 0x3B
    { 0, 0 }, // 0x3C
    { 0, 0 }, // 0x3D
    { 0, 0 }, // 0x3E
    { 0, 0 }, // 0x3F
    { 0, 0 }, // 0x40
    { 0, 0 }, // 0x41
    { 0, 0 }, // 0x42
    { 0, 0 }, // 0x43
    { &opcode_fd_44,  9 }, // LD B, IYH
    { &opcode_fd_45,  9 }, // LD B, IYL
    { &opcode_fd_46, 19 }, // LD B, (IY + d)
    { 0, 0 }, // 0x47
    { 0, 0 }, // 0x48
    { 0, 0 }, // 0x49
    { 0, 0 }, // 0x4A
    { 0, 0 }, // 0x4B
    { &opcode_fd_4c,  9 }, // LD C, IYH
    { &opcode_fd_4d,  9 }, // LD C, IYL
    { &opcode_fd_4e, 19 }, // LD C, (IY + d)
    { 0, 0 }, // 0x4F
    { 0, 0 }, // 0x50
    { 0, 0 }, // 0x51
    { 0, 0 }, // 0x52
    { 0, 0 }, // 0x53
    { &opcode_fd_54,  9 }, // LD D, IYH
    { &opcode_fd_55,  9 }, // LD D, IYL
    { &opcode_fd_56, 19 }, // LD D, (IY + d)
    { 0, 0 }, // 0x57
    { 0, 0 }, // 0x58
    { 0, 0 }, // 0x59
    { 0, 0 }, // 0x5A
    { 0, 0 }, // 0x5B
    { &opcode_fd_5c,  9 }, // LD E, IYH
    { &opcode_fd_5d,  9 }, // LD E, IYL
    { &opcode_fd_5e, 19 }, // LD E, (IY + d)
    { 0, 0 }, // 0x5F
    { &opcode_fd_60,  9 }, // LD IYH, B
    { &opcode_fd_61,  9 }, // LD IYH, C
    { &opcode_fd_62,  9 }, // LD IYH, D
    { &opcode_fd_63,  9 }, // LD IYH, E
    { &opcode_fd_64,  9 }, // LD IYH, IYH
    { &opcode_fd_65,  9 }, // LD IYH, IYL
    { &opcode_fd_66,  9 }, // LD H, (IY + d)
    { &opcode_fd_67,  9 }, // LD IYH, A
    { &opcode_fd_68,  9 }, // LD IYL, B
    { &opcode_fd_69,  9 }, // LD IYL, C
    { &opcode_fd_6a,  9 }, // LD IYL, D
    { &opcode_fd_6b,  9 }, // LD IYL, E
    { &opcode_fd_6c,  9 }, // LD IYL, IYH
    { &opcode_fd_6d,  9 }, // LD IYL, IYL
    { &opcode_fd_6e,  9 }, // LD L, (IY + d)
    { &opcode_fd_6f,  9 }, // LD IYL, A
    { &opcode_fd_70, 19 }, // LD (IY + d), B
    { &opcode_fd_71, 19 }, // LD (IY + d), C
    { &opcode_fd_72, 19 }, // LD (IY + d), D
    { &opcode_fd_73, 19 }, // LD (IY + d), E
    { &opcode_fd_74, 19 }, // LD (IY + d), H
    { &opcode_fd_75, 19 }, // LD (IY + d), L
    { 0,19 }, // 0x76
    { &opcode_fd_77, 19 }, // LD (IY + d), A
    { 0, 0 }, // 0x78
    { 0, 0 }, // 0x79
    { 0, 0 }, // 0x7A
    { 0, 0 }, // 0x7B
    { &opcode_fd_7c,  9 }, // LD A, IYH
    { &opcode_fd_7d,  9 }, // LD A, IYL
    { &opcode_fd_7e, 19 }, // LD A, (IY + d)
    { 0, 0 }, // 0x7F
    { 0, 0 }, // 0x80
    { 0, 0 }, // 0x81
    { 0, 0 }, // 0x82
    { 0, 0 }, // 0x83
    { &opcode_fd_84,  9 }, // ADD A, IYH
    { &opcode_fd_85,  9 }, // ADD A, IYL
    { &opcode_fd_86, 19 }, // ADD A, (IY + d)
    { 0, 0 }, // 0x87
    { 0, 0 }, // 0x88
    { 0, 0 }, // 0x89
    { 0, 0 }, // 0x8A
    { 0, 0 }, // 0x8B
    { &opcode_fd_8c,  9 }, // ADC A, IYH
    { &opcode_fd_8d,  9 }, // ADC A, IYL
    { &opcode_fd_8e, 19 }, // ADC A, (IY + d)
    { 0, 0 }, // 0x8F
    { 0, 0 }, // 0x90
    { 0, 0 }, // 0x91
    { 0, 0 }, // 0x92
    { 0, 0 }, // 0x93
    { &opcode_fd_94,  9 }, // SUB IYH
    { &opcode_fd_95,  9 }, // SUB IYL
    { &opcode_fd_96, 19 }, // SUB (IY + d)
    { 0, 0 }, // 0x97
    { 0, 0 }, // 0x98
    { 0, 0 }, // 0x99
    { 0, 0 }, // 0x9A
    { 0, 0 }, // 0x9B
    { &opcode_fd_9c,  9 }, // SBC A, IYH
    { &opcode_fd_9d,  9 }, // SBC A, IYL
    { &opcode_fd_9e, 19 }, // SBC A, (IY + d)
    { 0, 0 }, // 0x9F
    { 0, 0 }, // 0xA0
    { 0, 0 }, // 0xA1
    { 0, 0 }, // 0xA2
    { 0, 0 }, // 0xA3
    { &opcode_fd_a4,  9 }, // AND IYH
    { &opcode_fd_a5,  9 }, // AND IYL
    { &opcode_fd_a6, 19 }, // AND (IY + d)
    { 0, 0 }, // 0xA7
    { 0, 0 }, // 0xA8
    { 0, 0 }, // 0xA9
    { 0, 0 }, // 0xAA
    { 0, 0 }, // 0xAB
    { &opcode_fd_ac,  9 }, // XOR IYH
    { &opcode_fd_ad,  9 }, // XOR IYL
    { &opcode_fd_ae, 19 }, // XOR (IY + d)
    { 0, 0 }, // 0xAF
    { 0, 0 }, // 0xB0
    { 0, 0 }, // 0xB1
    { 0, 0 }, // 0xB2
    { 0, 0 }, // 0xB3
    { &opcode_fd_b4,  9 }, // OR IYH
    { &opcode_fd_b5,  9 }, // OR IYL
    { &opcode_fd_b6, 19 }, // OR (IY + d)
    { 0, 0 }, // 0xB7
    { 0, 0 }, // 0xB8
    { 0, 0 }, // 0xB9
    { 0, 0 }, // 0xBA
    { 0, 0 }, // 0xBB
    { &opcode_fd_bc,  9 }, // CP IYH
    { &opcode_fd_bd,  9 }, // CP IYL
    { &opcode_fd_be, 19 }, // CP (IY + d)
    { 0, 0 }, // 0xBF
    { 0, 0 }, // 0xC0
    { 0, 0 }, // 0xC1
    { 0, 0 }, // 0xC2
    { 0, 0 }, // 0xC3
    { 0, 0 }, // 0xC4
    { 0, 0 }, // 0xC5
    { 0, 0 }, // 0xC6
    { 0, 0 }, // 0xC7
    { 0, 0 }, // 0xC8
    { 0, 0 }, // 0xC9
    { 0, 0 }, // 0xCA
    { &opcode_fd_cb,  0 }, // 
    { 0, 0 }, // 0xCC
    { 0, 0 }, // 0xCD
    { 0, 0 }, // 0xCE
    { 0, 0 }, // 0xCF
    { 0, 0 }, // 0xD0
    { 0, 0 }, // 0xD1
    { 0, 0 }, // 0xD2
    { 0, 0 }, // 0xD3
    { 0, 0 }, // 0xD4
    { 0, 0 }, // 0xD5
    { 0, 0 }, // 0xD6
    { 0, 0 }, // 0xD7
    { 0, 0 }, // 0xD8
    { 0, 0 }, // 0xD9
    { 0, 0 }, // 0xDA
    { 0, 0 }, // 0xDB
    { 0, 0 }, // 0xDC
    { 0, 0 }, // 0xDD
    { 0, 0 }, // 0xDE
    { 0, 0 }, // 0xDF
    { 0, 0 }, // 0xE0
    { &opcode_fd_e1, 14 }, // POP IY
    { 0, 0 }, // 0xE2
    { &opcode_fd_e3, 23 }, // EX (SP), IY
    { 0, 0 }, // 0xE4
    { &opcode_fd_e5, 15 }, // PUSH IY
    { 0, 0 }, // 0xE6
    { 0, 0 }, // 0xE7
    { 0, 0 }, // 0xE8
    { &opcode_fd_e9,  8 }, // JP (IY)
    { 0, 0 }, // 0xEA
    { 0, 0 }, // 0xEB
    { 0, 0 }, // 0xEC
    { 0, 0 }, // 0xED
    { 0, 0 }, // 0xEE
    { 0, 0 }, // 0xEF
    { 0, 0 }, // 0xF0
    { 0, 0 }, // 0xF1
    { 0, 0 }, // 0xF2
    { 0, 0 }, // 0xF3
    { 0, 0 }, // 0xF4
    { 0, 0 }, // 0xF5
    { 0, 0 }, // 0xF6
    { 0, 0 }, // 0xF7
    { 0, 0 }, // 0xF8
    { &opcode_fd_f9, 10 }, // LD SP, IY
    { 0, 0 }, // 0xFA
    { 0, 0 }, // 0xFB
    { 0, 0 }, // 0xFC
    { 0, 0 }, // 0xFD
    { 0, 0 }, // 0xFE
    { 0, 0 }  // 0xFF
};

void opcode_fd_09()    // ADD IY, BC
{
    unsigned rr = BC();

    F &= (Zero | Sign | Parity);
    if( ((IY & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry;
    IY += rr;
    if( IY & 0x10000 ) F |= Carry;
}

void opcode_fd_19()    // ADD IY, DE
{
    unsigned rr = DE();

    F &= (Zero | Sign | Parity);
    if( ((IY & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry;
    IY += rr;
    if( IY & 0x10000 ) F |= Carry;
}

void opcode_fd_21()    // LD IY, nn
{
    IY = fetchWord();
}

void opcode_fd_22()    // LD (nn), IY
{
    writeWord( fetchWord(), IY );
}

void opcode_fd_23()    // INC IY
{
    IY++;
}

void opcode_fd_24()    // INC IYH
{
    IY = (IY & 0xFF) | ((unsigned)incByte( IY >> 8 ) << 8);
}

void opcode_fd_25()    // DEC IYH
{
    IY = (IY & 0xFF) | ((unsigned)decByte( IY >> 8 ) << 8);
}

void opcode_fd_26()    // LD IYH, n
{
    IY = (IY & 0xFF) | ((unsigned)fetchByte() << 8);
}

void opcode_fd_29()    // ADD IY, IY
{
    F &= (Zero | Sign | Parity);
    if( IY & 0x800 ) F |= Halfcarry;
    IY += IY;
    if( IY & 0x10000 ) F |= Carry;
}

void opcode_fd_2a()    // LD IY, (nn)
{
    IY = readWord( fetchWord() );
}

void opcode_fd_2b()    // DEC IY
{
    IY--;
}

void opcode_fd_2c()    // INC IYL
{
    IY = (IY & 0xFF00) | incByte( IY & 0xFF );
}

void opcode_fd_2d()    // DEC IYL
{
    IY = (IY & 0xFF00) | decByte( IY & 0xFF );
}

void opcode_fd_2e()    // LD IYL, n
{
    IY = (IY & 0xFF00) | fetchByte();
}

void opcode_fd_34()    // INC (IY + d)
{
    unsigned    addr = addDispl( IY, fetchByte() );

    writeByte( addr, incByte( readByte( addr ) ) );
}

void opcode_fd_35()    // DEC (IY + d)
{
    unsigned    addr = addDispl( IY, fetchByte() );

    writeByte( addr, decByte( readByte( addr ) ) );
}

void opcode_fd_36()    // LD (IY + d), n
{
    unsigned    addr = addDispl( IY, fetchByte() );

    writeByte( addr, fetchByte() );
}

void opcode_fd_39()    // ADD IY, SP
{
    F &= (Zero | Sign | Parity);
    if( ((IY & 0xFFF)+(SP & 0xFFF)) > 0xFFF ) F |= Halfcarry;
    IY += SP;
    if( IY & 0x10000 ) F |= Carry;
}

void opcode_fd_44()    // LD B, IYH
{
    B = IY >> 8;
}

void opcode_fd_45()    // LD B, IYL
{
    B = IY & 0xFF;
}

void opcode_fd_46()    // LD B, (IY + d)
{
    B = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_4c()    // LD C, IYH
{
    C = IY >> 8;
}

void opcode_fd_4d()    // LD C, IYL
{
    C = IY & 0xFF;
}

void opcode_fd_4e()    // LD C, (IY + d)
{
    C = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_54()    // LD D, IYH
{
    D = IY >> 8;
}

void opcode_fd_55()    // LD D, IYL
{
    D = IY & 0xFF;
}

void opcode_fd_56()    // LD D, (IY + d)
{
    D = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_5c()    // LD E, IYH
{
    E = IY >> 8;
}

void opcode_fd_5d()    // LD E, IYL
{
    E = IY & 0xFF;
}

void opcode_fd_5e()    // LD E, (IY + d)
{
    E = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_60()    // LD IYH, B
{
    IY = (IY & 0xFF) | ((unsigned)B << 8);
}

void opcode_fd_61()    // LD IYH, C
{
    IY = (IY & 0xFF) | ((unsigned)C << 8);
}

void opcode_fd_62()    // LD IYH, D
{
    IY = (IY & 0xFF) | ((unsigned)D << 8);
}

void opcode_fd_63()    // LD IYH, E
{
    IY = (IY & 0xFF) | ((unsigned)E << 8);
}

void opcode_fd_64()    // LD IYH, IYH
{
}

void opcode_fd_65()    // LD IYH, IYL
{
    IY = (IY & 0xFF) | ((IY << 8) & 0xFF00);
}

void opcode_fd_66()    // LD H, (IY + d)
{
    H = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_67()    // LD IYH, A
{
    IY = (IY & 0xFF) | ((unsigned)A << 8);
}

void opcode_fd_68()    // LD IYL, B
{
    IY = (IY & 0xFF00) | B;
}

void opcode_fd_69()    // LD IYL, C
{
    IY = (IY & 0xFF00) | C;
}

void opcode_fd_6a()    // LD IYL, D
{
    IY = (IY & 0xFF00) | D;
}

void opcode_fd_6b()    // LD IYL, E
{
    IY = (IY & 0xFF00) | E;
}

void opcode_fd_6c()    // LD IYL, IYH
{
    IY = (IY & 0xFF00) | ((IY >> 8) & 0xFF);
}

void opcode_fd_6d()    // LD IYL, IYL
{
}

void opcode_fd_6e()    // LD L, (IY + d)
{
    L = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_6f()    // LD IYL, A
{
    IY = (IY & 0xFF00) | A;
}

void opcode_fd_70()    // LD (IY + d), B
{
    writeByte( addDispl(IY,fetchByte()), B );
}

void opcode_fd_71()    // LD (IY + d), C
{
    writeByte( addDispl(IY,fetchByte()), C );
}

void opcode_fd_72()    // LD (IY + d), D
{
    writeByte( addDispl(IY,fetchByte()), D );
}

void opcode_fd_73()    // LD (IY + d), E
{
    writeByte( addDispl(IY,fetchByte()), E );
}

void opcode_fd_74()    // LD (IY + d), H
{
    writeByte( addDispl(IY,fetchByte()), H );
}

void opcode_fd_75()    // LD (IY + d), L
{
    writeByte( addDispl(IY,fetchByte()), L );
}

void opcode_fd_77()    // LD (IY + d), A
{
    writeByte( addDispl(IY,fetchByte()), A );
}

void opcode_fd_7c()    // LD A, IYH
{
    A = IY >> 8;
}

void opcode_fd_7d()    // LD A, IYL
{
    A = IY & 0xFF;
}

void opcode_fd_7e()    // LD A, (IY + d)
{
    A = readByte( addDispl(IY,fetchByte()) );
}

void opcode_fd_84()    // ADD A, IYH
{
    addByte( IY >> 8, 0 );
}

void opcode_fd_85()    // ADD A, IYL
{
    addByte( IY & 0xFF, 0 );
}

void opcode_fd_86()    // ADD A, (IY + d)
{
    addByte( readByte( addDispl(IY,fetchByte()) ), 0 );
}

void opcode_fd_8c()    // ADC A, IYH
{
    addByte( IY >> 8, F & Carry );
}

void opcode_fd_8d()    // ADC A, IYL
{
    addByte( IY & 0xFF, F & Carry );
}

void opcode_fd_8e()    // ADC A, (IY + d)
{
    addByte( readByte( addDispl(IY,fetchByte()) ), F & Carry );
}

void opcode_fd_94()    // SUB IYH
{
    A = subByte( IY >> 8, 0 );
}

void opcode_fd_95()    // SUB IYL
{
    A = subByte( IY & 0xFF, 0 );
}

void opcode_fd_96()    // SUB (IY + d)
{
    A = subByte( readByte( addDispl(IY,fetchByte()) ), 0 );
}

void opcode_fd_9c()    // SBC A, IYH
{
    A = subByte( IY >> 8, F & Carry );
}

void opcode_fd_9d()    // SBC A, IYL
{
    A = subByte( IY & 0xFF, F & Carry );
}

void opcode_fd_9e()    // SBC A, (IY + d)
{
    A = subByte( readByte( addDispl(IY,fetchByte()) ), F & Carry );
}

void opcode_fd_a4()    // AND IYH
{
    A &= IY >> 8;
    setFlags35PSZ000();
    F |= Halfcarry;
}

void opcode_fd_a5()    // AND IYL
{
    A &= IY & 0xFF;
    setFlags35PSZ000();
    F |= Halfcarry;
}

void opcode_fd_a6()    // AND (IY + d)
{
    A &= readByte( addDispl(IY,fetchByte()) );
    setFlags35PSZ000();
    F |= Halfcarry;
}

void opcode_fd_ac()    // XOR IYH
{
    A ^= IY >> 8;
    setFlags35PSZ000();
}

void opcode_fd_ad()    // XOR IYL
{
    A ^= IY & 0xFF;
    setFlags35PSZ000();
}

void opcode_fd_ae()    // XOR (IY + d)
{
    A ^= readByte( addDispl(IY,fetchByte()) );
    setFlags35PSZ000();
}

void opcode_fd_b4()    // OR IYH
{
    A |= IY >> 8;
    setFlags35PSZ000();
}

void opcode_fd_b5()    // OR IYL
{
    A |= IY & 0xFF;
    setFlags35PSZ000();
}

void opcode_fd_b6()    // OR (IY + d)
{
    A |= readByte( addDispl(IY,fetchByte()) );
    setFlags35PSZ000();
}

void opcode_fd_bc()    // CP IYH
{
    cmpByte( IY >> 8 );
}

void opcode_fd_bd()    // CP IYL
{
    cmpByte( IY & 0xFF );
}

void opcode_fd_be()    // CP (IY + d)
{
    cmpByte( readByte( addDispl(IY,fetchByte()) ) );
}

void opcode_fd_cb()    // 
{
    do_opcode_xycb( IY );
}

void opcode_fd_e1()    // POP IY
{
    IY = readWord( SP );
    SP += 2;
}

void opcode_fd_e3()    // EX (SP), IY
{
    unsigned    iy = IY;

    IY = readWord( SP );
    writeWord( SP, iy );
}

void opcode_fd_e5()    // PUSH IY
{
    SP -= 2;
    writeWord( SP, IY );
}

void opcode_fd_e9()    // JP (IY)
{
    PC = IY;
}

void opcode_fd_f9()    // LD SP, IY
{
    SP = IY;
}

OpcodeInfoXY OpInfoXYCB_[256] = {
    { &opcode_xycb_00, 20 }, // LD B, RLC (IX + d)
    { &opcode_xycb_01, 20 }, // LD C, RLC (IX + d)
    { &opcode_xycb_02, 20 }, // LD D, RLC (IX + d)
    { &opcode_xycb_03, 20 }, // LD E, RLC (IX + d)
    { &opcode_xycb_04, 20 }, // LD H, RLC (IX + d)
    { &opcode_xycb_05, 20 }, // LD L, RLC (IX + d)
    { &opcode_xycb_06, 20 }, // RLC (IX + d)
    { &opcode_xycb_07, 20 }, // LD A, RLC (IX + d)
    { &opcode_xycb_08, 20 }, // LD B, RRC (IX + d)
    { &opcode_xycb_09, 20 }, // LD C, RRC (IX + d)
    { &opcode_xycb_0a, 20 }, // LD D, RRC (IX + d)
    { &opcode_xycb_0b, 20 }, // LD E, RRC (IX + d)
    { &opcode_xycb_0c, 20 }, // LD H, RRC (IX + d)
    { &opcode_xycb_0d, 20 }, // LD L, RRC (IX + d)
    { &opcode_xycb_0e, 20 }, // RRC (IX + d)
    { &opcode_xycb_0f, 20 }, // LD A, RRC (IX + d)
    { &opcode_xycb_10, 20 }, // LD B, RL (IX + d)
    { &opcode_xycb_11, 20 }, // LD C, RL (IX + d)
    { &opcode_xycb_12, 20 }, // LD D, RL (IX + d)
    { &opcode_xycb_13, 20 }, // LD E, RL (IX + d)
    { &opcode_xycb_14, 20 }, // LD H, RL (IX + d)
    { &opcode_xycb_15, 20 }, // LD L, RL (IX + d)
    { &opcode_xycb_16, 20 }, // RL (IX + d)
    { &opcode_xycb_17, 20 }, // LD A, RL (IX + d)
    { &opcode_xycb_18, 20 }, // LD B, RR (IX + d)
    { &opcode_xycb_19, 20 }, // LD C, RR (IX + d)
    { &opcode_xycb_1a, 20 }, // LD D, RR (IX + d)
    { &opcode_xycb_1b, 20 }, // LD E, RR (IX + d)
    { &opcode_xycb_1c, 20 }, // LD H, RR (IX + d)
    { &opcode_xycb_1d, 20 }, // LD L, RR (IX + d)
    { &opcode_xycb_1e, 20 }, // RR (IX + d)
    { &opcode_xycb_1f, 20 }, // LD A, RR (IX + d)
    { &opcode_xycb_20, 20 }, // LD B, SLA (IX + d)
    { &opcode_xycb_21, 20 }, // LD C, SLA (IX + d)
    { &opcode_xycb_22, 20 }, // LD D, SLA (IX + d)
    { &opcode_xycb_23, 20 }, // LD E, SLA (IX + d)
    { &opcode_xycb_24, 20 }, // LD H, SLA (IX + d)
    { &opcode_xycb_25, 20 }, // LD L, SLA (IX + d)
    { &opcode_xycb_26, 20 }, // SLA (IX + d)
    { &opcode_xycb_27, 20 }, // LD A, SLA (IX + d)
    { &opcode_xycb_28, 20 }, // LD B, SRA (IX + d)
    { &opcode_xycb_29, 20 }, // LD C, SRA (IX + d)
    { &opcode_xycb_2a, 20 }, // LD D, SRA (IX + d)
    { &opcode_xycb_2b, 20 }, // LD E, SRA (IX + d)
    { &opcode_xycb_2c, 20 }, // LD H, SRA (IX + d)
    { &opcode_xycb_2d, 20 }, // LD L, SRA (IX + d)
    { &opcode_xycb_2e, 20 }, // SRA (IX + d)
    { &opcode_xycb_2f, 20 }, // LD A, SRA (IX + d)
    { &opcode_xycb_30, 20 }, // LD B, SLL (IX + d)
    { &opcode_xycb_31, 20 }, // LD C, SLL (IX + d)
    { &opcode_xycb_32, 20 }, // LD D, SLL (IX + d)
    { &opcode_xycb_33, 20 }, // LD E, SLL (IX + d)
    { &opcode_xycb_34, 20 }, // LD H, SLL (IX + d)
    { &opcode_xycb_35, 20 }, // LD L, SLL (IX + d)
    { &opcode_xycb_36, 20 }, // SLL (IX + d)
    { &opcode_xycb_37, 20 }, // LD A, SLL (IX + d)
    { &opcode_xycb_38, 20 }, // LD B, SRL (IX + d)
    { &opcode_xycb_39, 20 }, // LD C, SRL (IX + d)
    { &opcode_xycb_3a, 20 }, // LD D, SRL (IX + d)
    { &opcode_xycb_3b, 20 }, // LD E, SRL (IX + d)
    { &opcode_xycb_3c, 20 }, // LD H, SRL (IX + d)
    { &opcode_xycb_3d, 20 }, // LD L, SRL (IX + d)
    { &opcode_xycb_3e, 20 }, // SRL (IX + d)
    { &opcode_xycb_3f, 20 }, // LD A, SRL (IX + d)
    { &opcode_xycb_40, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_41, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_42, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_43, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_44, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_45, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_46, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_47, 20 }, // BIT 0, (IX + d)
    { &opcode_xycb_48, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_49, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_4a, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_4b, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_4c, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_4d, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_4e, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_4f, 20 }, // BIT 1, (IX + d)
    { &opcode_xycb_50, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_51, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_52, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_53, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_54, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_55, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_56, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_57, 20 }, // BIT 2, (IX + d)
    { &opcode_xycb_58, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_59, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_5a, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_5b, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_5c, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_5d, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_5e, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_5f, 20 }, // BIT 3, (IX + d)
    { &opcode_xycb_60, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_61, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_62, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_63, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_64, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_65, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_66, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_67, 20 }, // BIT 4, (IX + d)
    { &opcode_xycb_68, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_69, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_6a, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_6b, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_6c, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_6d, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_6e, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_6f, 20 }, // BIT 5, (IX + d)
    { &opcode_xycb_70, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_71, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_72, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_73, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_74, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_75, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_76, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_77, 20 }, // BIT 6, (IX + d)
    { &opcode_xycb_78, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_79, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_7a, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_7b, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_7c, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_7d, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_7e, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_7f, 20 }, // BIT 7, (IX + d)
    { &opcode_xycb_80, 20 }, // LD B, RES 0, (IX + d)
    { &opcode_xycb_81, 20 }, // LD C, RES 0, (IX + d)
    { &opcode_xycb_82, 20 }, // LD D, RES 0, (IX + d)
    { &opcode_xycb_83, 20 }, // LD E, RES 0, (IX + d)
    { &opcode_xycb_84, 20 }, // LD H, RES 0, (IX + d)
    { &opcode_xycb_85, 20 }, // LD L, RES 0, (IX + d)
    { &opcode_xycb_86, 20 }, // RES 0, (IX + d)
    { &opcode_xycb_87, 20 }, // LD A, RES 0, (IX + d)
    { &opcode_xycb_88, 20 }, // LD B, RES 1, (IX + d)
    { &opcode_xycb_89, 20 }, // LD C, RES 1, (IX + d)
    { &opcode_xycb_8a, 20 }, // LD D, RES 1, (IX + d)
    { &opcode_xycb_8b, 20 }, // LD E, RES 1, (IX + d)
    { &opcode_xycb_8c, 20 }, // LD H, RES 1, (IX + d)
    { &opcode_xycb_8d, 20 }, // LD L, RES 1, (IX + d)
    { &opcode_xycb_8e, 20 }, // RES 1, (IX + d)
    { &opcode_xycb_8f, 20 }, // LD A, RES 1, (IX + d)
    { &opcode_xycb_90, 20 }, // LD B, RES 2, (IX + d)
    { &opcode_xycb_91, 20 }, // LD C, RES 2, (IX + d)
    { &opcode_xycb_92, 20 }, // LD D, RES 2, (IX + d)
    { &opcode_xycb_93, 20 }, // LD E, RES 2, (IX + d)
    { &opcode_xycb_94, 20 }, // LD H, RES 2, (IX + d)
    { &opcode_xycb_95, 20 }, // LD L, RES 2, (IX + d)
    { &opcode_xycb_96, 20 }, // RES 2, (IX + d)
    { &opcode_xycb_97, 20 }, // LD A, RES 2, (IX + d)
    { &opcode_xycb_98, 20 }, // LD B, RES 3, (IX + d)
    { &opcode_xycb_99, 20 }, // LD C, RES 3, (IX + d)
    { &opcode_xycb_9a, 20 }, // LD D, RES 3, (IX + d)
    { &opcode_xycb_9b, 20 }, // LD E, RES 3, (IX + d)
    { &opcode_xycb_9c, 20 }, // LD H, RES 3, (IX + d)
    { &opcode_xycb_9d, 20 }, // LD L, RES 3, (IX + d)
    { &opcode_xycb_9e, 20 }, // RES 3, (IX + d)
    { &opcode_xycb_9f, 20 }, // LD A, RES 3, (IX + d)
    { &opcode_xycb_a0, 20 }, // LD B, RES 4, (IX + d)
    { &opcode_xycb_a1, 20 }, // LD C, RES 4, (IX + d)
    { &opcode_xycb_a2, 20 }, // LD D, RES 4, (IX + d)
    { &opcode_xycb_a3, 20 }, // LD E, RES 4, (IX + d)
    { &opcode_xycb_a4, 20 }, // LD H, RES 4, (IX + d)
    { &opcode_xycb_a5, 20 }, // LD L, RES 4, (IX + d)
    { &opcode_xycb_a6, 20 }, // RES 4, (IX + d)
    { &opcode_xycb_a7, 20 }, // LD A, RES 4, (IX + d)
    { &opcode_xycb_a8, 20 }, // LD B, RES 5, (IX + d)
    { &opcode_xycb_a9, 20 }, // LD C, RES 5, (IX + d)
    { &opcode_xycb_aa, 20 }, // LD D, RES 5, (IX + d)
    { &opcode_xycb_ab, 20 }, // LD E, RES 5, (IX + d)
    { &opcode_xycb_ac, 20 }, // LD H, RES 5, (IX + d)
    { &opcode_xycb_ad, 20 }, // LD L, RES 5, (IX + d)
    { &opcode_xycb_ae, 20 }, // RES 5, (IX + d)
    { &opcode_xycb_af, 20 }, // LD A, RES 5, (IX + d)
    { &opcode_xycb_b0, 20 }, // LD B, RES 6, (IX + d)
    { &opcode_xycb_b1, 20 }, // LD C, RES 6, (IX + d)
    { &opcode_xycb_b2, 20 }, // LD D, RES 6, (IX + d)
    { &opcode_xycb_b3, 20 }, // LD E, RES 6, (IX + d)
    { &opcode_xycb_b4, 20 }, // LD H, RES 6, (IX + d)
    { &opcode_xycb_b5, 20 }, // LD L, RES 6, (IX + d)
    { &opcode_xycb_b6, 20 }, // RES 6, (IX + d)
    { &opcode_xycb_b7, 20 }, // LD A, RES 6, (IX + d)
    { &opcode_xycb_b8, 20 }, // LD B, RES 7, (IX + d)
    { &opcode_xycb_b9, 20 }, // LD C, RES 7, (IX + d)
    { &opcode_xycb_ba, 20 }, // LD D, RES 7, (IX + d)
    { &opcode_xycb_bb, 20 }, // LD E, RES 7, (IX + d)
    { &opcode_xycb_bc, 20 }, // LD H, RES 7, (IX + d)
    { &opcode_xycb_bd, 20 }, // LD L, RES 7, (IX + d)
    { &opcode_xycb_be, 20 }, // RES 7, (IX + d)
    { &opcode_xycb_bf, 20 }, // LD A, RES 7, (IX + d)
    { &opcode_xycb_c0, 20 }, // LD B, SET 0, (IX + d)
    { &opcode_xycb_c1, 20 }, // LD C, SET 0, (IX + d)
    { &opcode_xycb_c2, 20 }, // LD D, SET 0, (IX + d)
    { &opcode_xycb_c3, 20 }, // LD E, SET 0, (IX + d)
    { &opcode_xycb_c4, 20 }, // LD H, SET 0, (IX + d)
    { &opcode_xycb_c5, 20 }, // LD L, SET 0, (IX + d)
    { &opcode_xycb_c6, 20 }, // SET 0, (IX + d)
    { &opcode_xycb_c7, 20 }, // LD A, SET 0, (IX + d)
    { &opcode_xycb_c8, 20 }, // LD B, SET 1, (IX + d)
    { &opcode_xycb_c9, 20 }, // LD C, SET 1, (IX + d)
    { &opcode_xycb_ca, 20 }, // LD D, SET 1, (IX + d)
    { &opcode_xycb_cb, 20 }, // LD E, SET 1, (IX + d)
    { &opcode_xycb_cc, 20 }, // LD H, SET 1, (IX + d)
    { &opcode_xycb_cd, 20 }, // LD L, SET 1, (IX + d)
    { &opcode_xycb_ce, 20 }, // SET 1, (IX + d)
    { &opcode_xycb_cf, 20 }, // LD A, SET 1, (IX + d)
    { &opcode_xycb_d0, 20 }, // LD B, SET 2, (IX + d)
    { &opcode_xycb_d1, 20 }, // LD C, SET 2, (IX + d)
    { &opcode_xycb_d2, 20 }, // LD D, SET 2, (IX + d)
    { &opcode_xycb_d3, 20 }, // LD E, SET 2, (IX + d)
    { &opcode_xycb_d4, 20 }, // LD H, SET 2, (IX + d)
    { &opcode_xycb_d5, 20 }, // LD L, SET 2, (IX + d)
    { &opcode_xycb_d6, 20 }, // SET 2, (IX + d)
    { &opcode_xycb_d7, 20 }, // LD A, SET 2, (IX + d)
    { &opcode_xycb_d8, 20 }, // LD B, SET 3, (IX + d)
    { &opcode_xycb_d9, 20 }, // LD C, SET 3, (IX + d)
    { &opcode_xycb_da, 20 }, // LD D, SET 3, (IX + d)
    { &opcode_xycb_db, 20 }, // LD E, SET 3, (IX + d)
    { &opcode_xycb_dc, 20 }, // LD H, SET 3, (IX + d)
    { &opcode_xycb_dd, 20 }, // LD L, SET 3, (IX + d)
    { &opcode_xycb_de, 20 }, // SET 3, (IX + d)
    { &opcode_xycb_df, 20 }, // LD A, SET 3, (IX + d)
    { &opcode_xycb_e0, 20 }, // LD B, SET 4, (IX + d)
    { &opcode_xycb_e1, 20 }, // LD C, SET 4, (IX + d)
    { &opcode_xycb_e2, 20 }, // LD D, SET 4, (IX + d)
    { &opcode_xycb_e3, 20 }, // LD E, SET 4, (IX + d)
    { &opcode_xycb_e4, 20 }, // LD H, SET 4, (IX + d)
    { &opcode_xycb_e5, 20 }, // LD L, SET 4, (IX + d)
    { &opcode_xycb_e6, 20 }, // SET 4, (IX + d)
    { &opcode_xycb_e7, 20 }, // LD A, SET 4, (IX + d)
    { &opcode_xycb_e8, 20 }, // LD B, SET 5, (IX + d)
    { &opcode_xycb_e9, 20 }, // LD C, SET 5, (IX + d)
    { &opcode_xycb_ea, 20 }, // LD D, SET 5, (IX + d)
    { &opcode_xycb_eb, 20 }, // LD E, SET 5, (IX + d)
    { &opcode_xycb_ec, 20 }, // LD H, SET 5, (IX + d)
    { &opcode_xycb_ed, 20 }, // LD L, SET 5, (IX + d)
    { &opcode_xycb_ee, 20 }, // SET 5, (IX + d)
    { &opcode_xycb_ef, 20 }, // LD A, SET 5, (IX + d)
    { &opcode_xycb_f0, 20 }, // LD B, SET 6, (IX + d)
    { &opcode_xycb_f1, 20 }, // LD C, SET 6, (IX + d)
    { &opcode_xycb_f2, 20 }, // LD D, SET 6, (IX + d)
    { &opcode_xycb_f3, 20 }, // LD E, SET 6, (IX + d)
    { &opcode_xycb_f4, 20 }, // LD H, SET 6, (IX + d)
    { &opcode_xycb_f5, 20 }, // LD L, SET 6, (IX + d)
    { &opcode_xycb_f6, 20 }, // SET 6, (IX + d)
    { &opcode_xycb_f7, 20 }, // LD A, SET 6, (IX + d)
    { &opcode_xycb_f8, 20 }, // LD B, SET 7, (IX + d)
    { &opcode_xycb_f9, 20 }, // LD C, SET 7, (IX + d)
    { &opcode_xycb_fa, 20 }, // LD D, SET 7, (IX + d)
    { &opcode_xycb_fb, 20 }, // LD E, SET 7, (IX + d)
    { &opcode_xycb_fc, 20 }, // LD H, SET 7, (IX + d)
    { &opcode_xycb_fd, 20 }, // LD L, SET 7, (IX + d)
    { &opcode_xycb_fe, 20 }, // SET 7, (IX + d)
    { &opcode_xycb_ff, 20 }  // LD A, SET 7, (IX + d)
};

unsigned do_opcode_xycb( unsigned xy )
{
    xy = addDispl( xy, fetchByte() );

    unsigned    op = fetchByte();

    cycles_ += OpInfoXYCB_[ op ].cycles;

    OpInfoXYCB_[ op ].handler( xy );

    return xy;
}

void opcode_xycb_00( unsigned xy ) // LD B, RLC (IX + d)
{
    B = rotateLeftCarry( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_01( unsigned xy ) // LD C, RLC (IX + d)
{
    C = rotateLeftCarry( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_02( unsigned xy ) // LD D, RLC (IX + d)
{
    D = rotateLeftCarry( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_03( unsigned xy ) // LD E, RLC (IX + d)
{
    E = rotateLeftCarry( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_04( unsigned xy ) // LD H, RLC (IX + d)
{
    H = rotateLeftCarry( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_05( unsigned xy ) // LD L, RLC (IX + d)
{
    L = rotateLeftCarry( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_06( unsigned xy ) // RLC (IX + d)
{
    writeByte( xy, rotateLeftCarry( readByte(xy) ) );
}

void opcode_xycb_07( unsigned xy ) // LD A, RLC (IX + d)
{
    A = rotateLeftCarry( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_08( unsigned xy ) // LD B, RRC (IX + d)
{
    B = rotateRightCarry( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_09( unsigned xy ) // LD C, RRC (IX + d)
{
    C = rotateRightCarry( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_0a( unsigned xy ) // LD D, RRC (IX + d)
{
    D = rotateRightCarry( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_0b( unsigned xy ) // LD E, RRC (IX + d)
{
    E = rotateRightCarry( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_0c( unsigned xy ) // LD H, RRC (IX + d)
{
    H = rotateRightCarry( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_0d( unsigned xy ) // LD L, RRC (IX + d)
{
    L = rotateRightCarry( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_0e( unsigned xy ) // RRC (IX + d)
{
    writeByte( xy, rotateRightCarry( readByte(xy) ) );
}

void opcode_xycb_0f( unsigned xy ) // LD A, RRC (IX + d)
{
    A = rotateRightCarry( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_10( unsigned xy ) // LD B, RL (IX + d)
{
    B = rotateLeft( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_11( unsigned xy ) // LD C, RL (IX + d)
{
    C = rotateLeft( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_12( unsigned xy ) // LD D, RL (IX + d)
{
    D = rotateLeft( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_13( unsigned xy ) // LD E, RL (IX + d)
{
    E = rotateLeft( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_14( unsigned xy ) // LD H, RL (IX + d)
{
    H = rotateLeft( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_15( unsigned xy ) // LD L, RL (IX + d)
{
    L = rotateLeft( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_16( unsigned xy ) // RL (IX + d)
{
    writeByte( xy, rotateLeft( readByte(xy) ) );
}

void opcode_xycb_17( unsigned xy ) // LD A, RL (IX + d)
{
    A = rotateLeft( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_18( unsigned xy ) // LD B, RR (IX + d)
{
    B = rotateRight( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_19( unsigned xy ) // LD C, RR (IX + d)
{
    C = rotateRight( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_1a( unsigned xy ) // LD D, RR (IX + d)
{
    D = rotateRight( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_1b( unsigned xy ) // LD E, RR (IX + d)
{
    E = rotateRight( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_1c( unsigned xy ) // LD H, RR (IX + d)
{
    H = rotateRight( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_1d( unsigned xy ) // LD L, RR (IX + d)
{
    L = rotateRight( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_1e( unsigned xy ) // RR (IX + d)
{
    writeByte( xy, rotateRight( readByte(xy) ) );
}

void opcode_xycb_1f( unsigned xy ) // LD A, RR (IX + d)
{
    A = rotateRight( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_20( unsigned xy ) // LD B, SLA (IX + d)
{
    B = shiftLeft( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_21( unsigned xy ) // LD C, SLA (IX + d)
{
    C = shiftLeft( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_22( unsigned xy ) // LD D, SLA (IX + d)
{
    D = shiftLeft( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_23( unsigned xy ) // LD E, SLA (IX + d)
{
    E = shiftLeft( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_24( unsigned xy ) // LD H, SLA (IX + d)
{
    H = shiftLeft( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_25( unsigned xy ) // LD L, SLA (IX + d)
{
    L = shiftLeft( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_26( unsigned xy ) // SLA (IX + d)
{
    writeByte( xy, shiftLeft( readByte(xy) ) );
}

void opcode_xycb_27( unsigned xy ) // LD A, SLA (IX + d)
{
    A = shiftLeft( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_28( unsigned xy ) // LD B, SRA (IX + d)
{
    B = shiftRightArith( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_29( unsigned xy ) // LD C, SRA (IX + d)
{
    C = shiftRightArith( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_2a( unsigned xy ) // LD D, SRA (IX + d)
{
    D = shiftRightArith( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_2b( unsigned xy ) // LD E, SRA (IX + d)
{
    E = shiftRightArith( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_2c( unsigned xy ) // LD H, SRA (IX + d)
{
    H = shiftRightArith( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_2d( unsigned xy ) // LD L, SRA (IX + d)
{
    L = shiftRightArith( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_2e( unsigned xy ) // SRA (IX + d)
{
    writeByte( xy, shiftRightArith( readByte(xy) ) );
}

void opcode_xycb_2f( unsigned xy ) // LD A, SRA (IX + d)
{
    A = shiftRightArith( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_30( unsigned xy ) // LD B, SLL (IX + d)
{
    B = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, B );
}

void opcode_xycb_31( unsigned xy ) // LD C, SLL (IX + d)
{
    C = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, C );
}

void opcode_xycb_32( unsigned xy ) // LD D, SLL (IX + d)
{
    D = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, D );
}

void opcode_xycb_33( unsigned xy ) // LD E, SLL (IX + d)
{
    E = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, E );
}

void opcode_xycb_34( unsigned xy ) // LD H, SLL (IX + d)
{
    H = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, H );
}

void opcode_xycb_35( unsigned xy ) // LD L, SLL (IX + d)
{
    L = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, L );
}

void opcode_xycb_36( unsigned xy ) // SLL (IX + d)
{
    writeByte( xy, shiftLeft( readByte(xy) ) | 0x01 );
}

void opcode_xycb_37( unsigned xy ) // LD A, SLL (IX + d)
{
    A = shiftLeft( readByte(xy) ) | 0x01;
    writeByte( xy, A );
}

void opcode_xycb_38( unsigned xy ) // LD B, SRL (IX + d)
{
    B = shiftRightLogical( readByte(xy) );
    writeByte( xy, B );
}

void opcode_xycb_39( unsigned xy ) // LD C, SRL (IX + d)
{
    C = shiftRightLogical( readByte(xy) );
    writeByte( xy, C );
}

void opcode_xycb_3a( unsigned xy ) // LD D, SRL (IX + d)
{
    D = shiftRightLogical( readByte(xy) );
    writeByte( xy, D );
}

void opcode_xycb_3b( unsigned xy ) // LD E, SRL (IX + d)
{
    E = shiftRightLogical( readByte(xy) );
    writeByte( xy, E );
}

void opcode_xycb_3c( unsigned xy ) // LD H, SRL (IX + d)
{
    H = shiftRightLogical( readByte(xy) );
    writeByte( xy, H );
}

void opcode_xycb_3d( unsigned xy ) // LD L, SRL (IX + d)
{
    L = shiftRightLogical( readByte(xy) );
    writeByte( xy, L );
}

void opcode_xycb_3e( unsigned xy ) // SRL (IX + d)
{
    writeByte( xy, shiftRightLogical( readByte(xy) ) );
}

void opcode_xycb_3f( unsigned xy ) // LD A, SRL (IX + d)
{
    A = shiftRightLogical( readByte(xy) );
    writeByte( xy, A );
}

void opcode_xycb_40( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_41( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_42( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_43( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_44( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_45( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_46( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_47( unsigned xy ) // BIT 0, (IX + d)
{
    testBit( 0, readByte( xy ) );
}

void opcode_xycb_48( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_49( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_4a( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_4b( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_4c( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_4d( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_4e( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_4f( unsigned xy ) // BIT 1, (IX + d)
{
    testBit( 1, readByte( xy ) );
}

void opcode_xycb_50( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_51( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_52( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_53( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_54( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_55( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_56( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_57( unsigned xy ) // BIT 2, (IX + d)
{
    testBit( 2, readByte( xy ) );
}

void opcode_xycb_58( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_59( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_5a( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_5b( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_5c( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_5d( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_5e( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_5f( unsigned xy ) // BIT 3, (IX + d)
{
    testBit( 3, readByte( xy ) );
}

void opcode_xycb_60( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_61( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_62( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_63( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_64( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_65( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_66( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_67( unsigned xy ) // BIT 4, (IX + d)
{
    testBit( 4, readByte( xy ) );
}

void opcode_xycb_68( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_69( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_6a( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_6b( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_6c( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_6d( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_6e( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_6f( unsigned xy ) // BIT 5, (IX + d)
{
    testBit( 5, readByte( xy ) );
}

void opcode_xycb_70( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_71( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_72( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_73( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_74( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_75( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_76( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_77( unsigned xy ) // BIT 6, (IX + d)
{
    testBit( 6, readByte( xy ) );
}

void opcode_xycb_78( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_79( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_7a( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_7b( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_7c( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_7d( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_7e( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_7f( unsigned xy ) // BIT 7, (IX + d)
{
    testBit( 7, readByte( xy ) );
}

void opcode_xycb_80( unsigned xy ) // LD B, RES 0, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, B );
}

void opcode_xycb_81( unsigned xy ) // LD C, RES 0, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, C );
}

void opcode_xycb_82( unsigned xy ) // LD D, RES 0, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, D );
}

void opcode_xycb_83( unsigned xy ) // LD E, RES 0, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, E );
}

void opcode_xycb_84( unsigned xy ) // LD H, RES 0, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, H );
}

void opcode_xycb_85( unsigned xy ) // LD L, RES 0, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, L );
}

void opcode_xycb_86( unsigned xy ) // RES 0, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 0) );
}

void opcode_xycb_87( unsigned xy ) // LD A, RES 0, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 0);
    writeByte( xy, A );
}

void opcode_xycb_88( unsigned xy ) // LD B, RES 1, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, B );
}

void opcode_xycb_89( unsigned xy ) // LD C, RES 1, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, C );
}

void opcode_xycb_8a( unsigned xy ) // LD D, RES 1, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, D );
}

void opcode_xycb_8b( unsigned xy ) // LD E, RES 1, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, E );
}

void opcode_xycb_8c( unsigned xy ) // LD H, RES 1, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, H );
}

void opcode_xycb_8d( unsigned xy ) // LD L, RES 1, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, L );
}

void opcode_xycb_8e( unsigned xy ) // RES 1, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 1) );
}

void opcode_xycb_8f( unsigned xy ) // LD A, RES 1, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 1);
    writeByte( xy, A );
}

void opcode_xycb_90( unsigned xy ) // LD B, RES 2, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, B );
}

void opcode_xycb_91( unsigned xy ) // LD C, RES 2, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, C );
}

void opcode_xycb_92( unsigned xy ) // LD D, RES 2, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, D );
}

void opcode_xycb_93( unsigned xy ) // LD E, RES 2, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, E );
}

void opcode_xycb_94( unsigned xy ) // LD H, RES 2, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, H );
}

void opcode_xycb_95( unsigned xy ) // LD L, RES 2, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, L );
}

void opcode_xycb_96( unsigned xy ) // RES 2, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 2) );
}

void opcode_xycb_97( unsigned xy ) // LD A, RES 2, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 2);
    writeByte( xy, A );
}

void opcode_xycb_98( unsigned xy ) // LD B, RES 3, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, B );
}

void opcode_xycb_99( unsigned xy ) // LD C, RES 3, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, C );
}

void opcode_xycb_9a( unsigned xy ) // LD D, RES 3, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, D );
}

void opcode_xycb_9b( unsigned xy ) // LD E, RES 3, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, E );
}

void opcode_xycb_9c( unsigned xy ) // LD H, RES 3, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, H );
}

void opcode_xycb_9d( unsigned xy ) // LD L, RES 3, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, L );
}

void opcode_xycb_9e( unsigned xy ) // RES 3, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 3) );
}

void opcode_xycb_9f( unsigned xy ) // LD A, RES 3, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 3);
    writeByte( xy, A );
}

void opcode_xycb_a0( unsigned xy ) // LD B, RES 4, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, B );
}

void opcode_xycb_a1( unsigned xy ) // LD C, RES 4, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, C );
}

void opcode_xycb_a2( unsigned xy ) // LD D, RES 4, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, D );
}

void opcode_xycb_a3( unsigned xy ) // LD E, RES 4, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, E );
}

void opcode_xycb_a4( unsigned xy ) // LD H, RES 4, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, H );
}

void opcode_xycb_a5( unsigned xy ) // LD L, RES 4, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, L );
}

void opcode_xycb_a6( unsigned xy ) // RES 4, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 4) );
}

void opcode_xycb_a7( unsigned xy ) // LD A, RES 4, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 4);
    writeByte( xy, A );
}

void opcode_xycb_a8( unsigned xy ) // LD B, RES 5, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, B );
}

void opcode_xycb_a9( unsigned xy ) // LD C, RES 5, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, C );
}

void opcode_xycb_aa( unsigned xy ) // LD D, RES 5, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, D );
}

void opcode_xycb_ab( unsigned xy ) // LD E, RES 5, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, E );
}

void opcode_xycb_ac( unsigned xy ) // LD H, RES 5, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, H );
}

void opcode_xycb_ad( unsigned xy ) // LD L, RES 5, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, L );
}

void opcode_xycb_ae( unsigned xy ) // RES 5, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 5) );
}

void opcode_xycb_af( unsigned xy ) // LD A, RES 5, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 5);
    writeByte( xy, A );
}

void opcode_xycb_b0( unsigned xy ) // LD B, RES 6, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, B );
}

void opcode_xycb_b1( unsigned xy ) // LD C, RES 6, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, C );
}

void opcode_xycb_b2( unsigned xy ) // LD D, RES 6, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, D );
}

void opcode_xycb_b3( unsigned xy ) // LD E, RES 6, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, E );
}

void opcode_xycb_b4( unsigned xy ) // LD H, RES 6, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, H );
}

void opcode_xycb_b5( unsigned xy ) // LD L, RES 6, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, L );
}

void opcode_xycb_b6( unsigned xy ) // RES 6, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 6) );
}

void opcode_xycb_b7( unsigned xy ) // LD A, RES 6, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 6);
    writeByte( xy, A );
}

void opcode_xycb_b8( unsigned xy ) // LD B, RES 7, (IX + d)
{
    B = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, B );
}

void opcode_xycb_b9( unsigned xy ) // LD C, RES 7, (IX + d)
{
    C = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, C );
}

void opcode_xycb_ba( unsigned xy ) // LD D, RES 7, (IX + d)
{
    D = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, D );
}

void opcode_xycb_bb( unsigned xy ) // LD E, RES 7, (IX + d)
{
    E = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, E );
}

void opcode_xycb_bc( unsigned xy ) // LD H, RES 7, (IX + d)
{
    H = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, H );
}

void opcode_xycb_bd( unsigned xy ) // LD L, RES 7, (IX + d)
{
    L = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, L );
}

void opcode_xycb_be( unsigned xy ) // RES 7, (IX + d)
{
    writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 7) );
}

void opcode_xycb_bf( unsigned xy ) // LD A, RES 7, (IX + d)
{
    A = readByte(xy) & (unsigned char) ~(1 << 7);
    writeByte( xy, A );
}

void opcode_xycb_c0( unsigned xy ) // LD B, SET 0, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, B );
}

void opcode_xycb_c1( unsigned xy ) // LD C, SET 0, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, C );
}

void opcode_xycb_c2( unsigned xy ) // LD D, SET 0, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, D );
}

void opcode_xycb_c3( unsigned xy ) // LD E, SET 0, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, E );
}

void opcode_xycb_c4( unsigned xy ) // LD H, SET 0, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, H );
}

void opcode_xycb_c5( unsigned xy ) // LD L, SET 0, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, L );
}

void opcode_xycb_c6( unsigned xy ) // SET 0, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 0) );
}

void opcode_xycb_c7( unsigned xy ) // LD A, SET 0, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 0);
    writeByte( xy, A );
}

void opcode_xycb_c8( unsigned xy ) // LD B, SET 1, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, B );
}

void opcode_xycb_c9( unsigned xy ) // LD C, SET 1, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, C );
}

void opcode_xycb_ca( unsigned xy ) // LD D, SET 1, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, D );
}

void opcode_xycb_cb( unsigned xy ) // LD E, SET 1, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, E );
}

void opcode_xycb_cc( unsigned xy ) // LD H, SET 1, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, H );
}

void opcode_xycb_cd( unsigned xy ) // LD L, SET 1, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, L );
}

void opcode_xycb_ce( unsigned xy ) // SET 1, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 1) );
}

void opcode_xycb_cf( unsigned xy ) // LD A, SET 1, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 1);
    writeByte( xy, A );
}

void opcode_xycb_d0( unsigned xy ) // LD B, SET 2, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, B );
}

void opcode_xycb_d1( unsigned xy ) // LD C, SET 2, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, C );
}

void opcode_xycb_d2( unsigned xy ) // LD D, SET 2, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, D );
}

void opcode_xycb_d3( unsigned xy ) // LD E, SET 2, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, E );
}

void opcode_xycb_d4( unsigned xy ) // LD H, SET 2, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, H );
}

void opcode_xycb_d5( unsigned xy ) // LD L, SET 2, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, L );
}

void opcode_xycb_d6( unsigned xy ) // SET 2, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 2) );
}

void opcode_xycb_d7( unsigned xy ) // LD A, SET 2, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 2);
    writeByte( xy, A );
}

void opcode_xycb_d8( unsigned xy ) // LD B, SET 3, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, B );
}

void opcode_xycb_d9( unsigned xy ) // LD C, SET 3, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, C );
}

void opcode_xycb_da( unsigned xy ) // LD D, SET 3, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, D );
}

void opcode_xycb_db( unsigned xy ) // LD E, SET 3, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, E );
}

void opcode_xycb_dc( unsigned xy ) // LD H, SET 3, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, H );
}

void opcode_xycb_dd( unsigned xy ) // LD L, SET 3, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, L );
}

void opcode_xycb_de( unsigned xy ) // SET 3, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 3) );
}

void opcode_xycb_df( unsigned xy ) // LD A, SET 3, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 3);
    writeByte( xy, A );
}

void opcode_xycb_e0( unsigned xy ) // LD B, SET 4, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, B );
}

void opcode_xycb_e1( unsigned xy ) // LD C, SET 4, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, C );
}

void opcode_xycb_e2( unsigned xy ) // LD D, SET 4, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, D );
}

void opcode_xycb_e3( unsigned xy ) // LD E, SET 4, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, E );
}

void opcode_xycb_e4( unsigned xy ) // LD H, SET 4, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, H );
}

void opcode_xycb_e5( unsigned xy ) // LD L, SET 4, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, L );
}

void opcode_xycb_e6( unsigned xy ) // SET 4, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 4) );
}

void opcode_xycb_e7( unsigned xy ) // LD A, SET 4, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 4);
    writeByte( xy, A );
}

void opcode_xycb_e8( unsigned xy ) // LD B, SET 5, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, B );
}

void opcode_xycb_e9( unsigned xy ) // LD C, SET 5, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, C );
}

void opcode_xycb_ea( unsigned xy ) // LD D, SET 5, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, D );
}

void opcode_xycb_eb( unsigned xy ) // LD E, SET 5, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, E );
}

void opcode_xycb_ec( unsigned xy ) // LD H, SET 5, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, H );
}

void opcode_xycb_ed( unsigned xy ) // LD L, SET 5, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, L );
}

void opcode_xycb_ee( unsigned xy ) // SET 5, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 5) );
}

void opcode_xycb_ef( unsigned xy ) // LD A, SET 5, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 5);
    writeByte( xy, A );
}

void opcode_xycb_f0( unsigned xy ) // LD B, SET 6, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, B );
}

void opcode_xycb_f1( unsigned xy ) // LD C, SET 6, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, C );
}

void opcode_xycb_f2( unsigned xy ) // LD D, SET 6, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, D );
}

void opcode_xycb_f3( unsigned xy ) // LD E, SET 6, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, E );
}

void opcode_xycb_f4( unsigned xy ) // LD H, SET 6, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, H );
}

void opcode_xycb_f5( unsigned xy ) // LD L, SET 6, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, L );
}

void opcode_xycb_f6( unsigned xy ) // SET 6, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 6) );
}

void opcode_xycb_f7( unsigned xy ) // LD A, SET 6, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 6);
    writeByte( xy, A );
}

void opcode_xycb_f8( unsigned xy ) // LD B, SET 7, (IX + d)
{
    B = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, B );
}

void opcode_xycb_f9( unsigned xy ) // LD C, SET 7, (IX + d)
{
    C = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, C );
}

void opcode_xycb_fa( unsigned xy ) // LD D, SET 7, (IX + d)
{
    D = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, D );
}

void opcode_xycb_fb( unsigned xy ) // LD E, SET 7, (IX + d)
{
    E = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, E );
}

void opcode_xycb_fc( unsigned xy ) // LD H, SET 7, (IX + d)
{
    H = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, H );
}

void opcode_xycb_fd( unsigned xy ) // LD L, SET 7, (IX + d)
{
    L = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, L );
}

void opcode_xycb_fe( unsigned xy ) // SET 7, (IX + d)
{
    writeByte( xy, readByte(xy) | (unsigned char) (1 << 7) );
}

void opcode_xycb_ff( unsigned xy ) // LD A, SET 7, (IX + d)
{
    A = readByte(xy) | (unsigned char) (1 << 7);
    writeByte( xy, A );
}

OpcodeInfo OpInfo_[256] = {
    { &opcode_00,  4 }, // NOP
    { &opcode_01, 10 }, // LD   BC,nn
    { &opcode_02,  7 }, // LD   (BC),A
    { &opcode_03,  6 }, // INC  BC
    { &opcode_04,  4 }, // INC  B
    { &opcode_05,  4 }, // DEC  B
    { &opcode_06,  7 }, // LD   B,n
    { &opcode_07,  4 }, // RLCA
    { &opcode_08,  4 }, // EX   AF,AF'
    { &opcode_09, 11 }, // ADD  HL,BC
    { &opcode_0a,  7 }, // LD   A,(BC)
    { &opcode_0b,  6 }, // DEC  BC
    { &opcode_0c,  4 }, // INC  C
    { &opcode_0d,  4 }, // DEC  C
    { &opcode_0e,  7 }, // LD   C,n
    { &opcode_0f,  4 }, // RRCA
    { &opcode_10,  8 }, // DJNZ d
    { &opcode_11, 10 }, // LD   DE,nn
    { &opcode_12,  7 }, // LD   (DE),A
    { &opcode_13,  6 }, // INC  DE
    { &opcode_14,  4 }, // INC  D
    { &opcode_15,  4 }, // DEC  D
    { &opcode_16,  7 }, // LD   D,n
    { &opcode_17,  4 }, // RLA
    { &opcode_18, 12 }, // JR   d
    { &opcode_19, 11 }, // ADD  HL,DE
    { &opcode_1a,  7 }, // LD   A,(DE)
    { &opcode_1b,  6 }, // DEC  DE
    { &opcode_1c,  4 }, // INC  E
    { &opcode_1d,  4 }, // DEC  E
    { &opcode_1e,  7 }, // LD   E,n
    { &opcode_1f,  4 }, // RRA
    { &opcode_20,  7 }, // JR   NZ,d
    { &opcode_21, 10 }, // LD   HL,nn
    { &opcode_22, 16 }, // LD   (nn),HL
    { &opcode_23,  6 }, // INC  HL
    { &opcode_24,  4 }, // INC  H
    { &opcode_25,  4 }, // DEC  H
    { &opcode_26,  7 }, // LD   H,n
    { &opcode_27,  4 }, // DAA
    { &opcode_28,  7 }, // JR   Z,d
    { &opcode_29, 11 }, // ADD  HL,HL
    { &opcode_2a, 16 }, // LD   HL,(nn)
    { &opcode_2b,  6 }, // DEC  HL
    { &opcode_2c,  4 }, // INC  L
    { &opcode_2d,  4 }, // DEC  L
    { &opcode_2e,  7 }, // LD   L,n
    { &opcode_2f,  4 }, // CPL
    { &opcode_30,  7 }, // JR   NC,d
    { &opcode_31, 10 }, // LD   SP,nn
    { &opcode_32, 13 }, // LD   (nn),A
    { &opcode_33,  6 }, // INC  SP
    { &opcode_34, 11 }, // INC  (HL)
    { &opcode_35, 11 }, // DEC  (HL)
    { &opcode_36, 10 }, // LD   (HL),n
    { &opcode_37,  4 }, // SCF
    { &opcode_38,  7 }, // JR   C,d
    { &opcode_39, 11 }, // ADD  HL,SP
    { &opcode_3a, 13 }, // LD   A,(nn)
    { &opcode_3b,  6 }, // DEC  SP
    { &opcode_3c,  4 }, // INC  A
    { &opcode_3d,  4 }, // DEC  A
    { &opcode_3e,  7 }, // LD   A,n
    { &opcode_3f,  4 }, // CCF
    { &opcode_40,  4 }, // LD   B,B
    { &opcode_41,  4 }, // LD   B,C
    { &opcode_42,  4 }, // LD   B,D
    { &opcode_43,  4 }, // LD   B,E
    { &opcode_44,  4 }, // LD   B,H
    { &opcode_45,  4 }, // LD   B,L
    { &opcode_46,  7 }, // LD   B,(HL)
    { &opcode_47,  4 }, // LD   B,A
    { &opcode_48,  4 }, // LD   C,B
    { &opcode_49,  4 }, // LD   C,C
    { &opcode_4a,  4 }, // LD   C,D
    { &opcode_4b,  4 }, // LD   C,E
    { &opcode_4c,  4 }, // LD   C,H
    { &opcode_4d,  4 }, // LD   C,L
    { &opcode_4e,  7 }, // LD   C,(HL)
    { &opcode_4f,  4 }, // LD   C,A
    { &opcode_50,  4 }, // LD   D,B
    { &opcode_51,  4 }, // LD   D,C
    { &opcode_52,  4 }, // LD   D,D
    { &opcode_53,  4 }, // LD   D,E
    { &opcode_54,  4 }, // LD   D,H
    { &opcode_55,  4 }, // LD   D,L
    { &opcode_56,  7 }, // LD   D,(HL)
    { &opcode_57,  4 }, // LD   D,A
    { &opcode_58,  4 }, // LD   E,B
    { &opcode_59,  4 }, // LD   E,C
    { &opcode_5a,  4 }, // LD   E,D
    { &opcode_5b,  4 }, // LD   E,E
    { &opcode_5c,  4 }, // LD   E,H
    { &opcode_5d,  4 }, // LD   E,L
    { &opcode_5e,  7 }, // LD   E,(HL)
    { &opcode_5f,  4 }, // LD   E,A
    { &opcode_60,  4 }, // LD   H,B
    { &opcode_61,  4 }, // LD   H,C
    { &opcode_62,  4 }, // LD   H,D
    { &opcode_63,  4 }, // LD   H,E
    { &opcode_64,  4 }, // LD   H,H
    { &opcode_65,  4 }, // LD   H,L
    { &opcode_66,  7 }, // LD   H,(HL)
    { &opcode_67,  4 }, // LD   H,A
    { &opcode_68,  4 }, // LD   L,B
    { &opcode_69,  4 }, // LD   L,C
    { &opcode_6a,  4 }, // LD   L,D
    { &opcode_6b,  4 }, // LD   L,E
    { &opcode_6c,  4 }, // LD   L,H
    { &opcode_6d,  4 }, // LD   L,L
    { &opcode_6e,  7 }, // LD   L,(HL)
    { &opcode_6f,  4 }, // LD   L,A
    { &opcode_70,  7 }, // LD   (HL),B
    { &opcode_71,  7 }, // LD   (HL),C
    { &opcode_72,  7 }, // LD   (HL),D
    { &opcode_73,  7 }, // LD   (HL),E
    { &opcode_74,  7 }, // LD   (HL),H
    { &opcode_75,  7 }, // LD   (HL),L
    { &opcode_76,  4 }, // HALT
    { &opcode_77,  7 }, // LD   (HL),A
    { &opcode_78,  4 }, // LD   A,B
    { &opcode_79,  4 }, // LD   A,C
    { &opcode_7a,  4 }, // LD   A,D
    { &opcode_7b,  4 }, // LD   A,E
    { &opcode_7c,  4 }, // LD   A,H
    { &opcode_7d,  4 }, // LD   A,L
    { &opcode_7e,  7 }, // LD   A,(HL)
    { &opcode_7f,  4 }, // LD   A,A
    { &opcode_80,  4 }, // ADD  A,B
    { &opcode_81,  4 }, // ADD  A,C
    { &opcode_82,  4 }, // ADD  A,D
    { &opcode_83,  4 }, // ADD  A,E
    { &opcode_84,  4 }, // ADD  A,H
    { &opcode_85,  4 }, // ADD  A,L
    { &opcode_86,  7 }, // ADD  A,(HL)
    { &opcode_87,  4 }, // ADD  A,A
    { &opcode_88,  4 }, // ADC  A,B
    { &opcode_89,  4 }, // ADC  A,C
    { &opcode_8a,  4 }, // ADC  A,D
    { &opcode_8b,  4 }, // ADC  A,E
    { &opcode_8c,  4 }, // ADC  A,H
    { &opcode_8d,  4 }, // ADC  A,L
    { &opcode_8e,  7 }, // ADC  A,(HL)
    { &opcode_8f,  4 }, // ADC  A,A
    { &opcode_90,  4 }, // SUB  B
    { &opcode_91,  4 }, // SUB  C
    { &opcode_92,  4 }, // SUB  D
    { &opcode_93,  4 }, // SUB  E
    { &opcode_94,  4 }, // SUB  H
    { &opcode_95,  4 }, // SUB  L
    { &opcode_96,  7 }, // SUB  (HL)
    { &opcode_97,  4 }, // SUB  A
    { &opcode_98,  4 }, // SBC  A,B
    { &opcode_99,  4 }, // SBC  A,C
    { &opcode_9a,  4 }, // SBC  A,D
    { &opcode_9b,  4 }, // SBC  A,E
    { &opcode_9c,  4 }, // SBC  A,H
    { &opcode_9d,  4 }, // SBC  A,L
    { &opcode_9e,  7 }, // SBC  A,(HL)
    { &opcode_9f,  4 }, // SBC  A,A
    { &opcode_a0,  4 }, // AND  B
    { &opcode_a1,  4 }, // AND  C
    { &opcode_a2,  4 }, // AND  D
    { &opcode_a3,  4 }, // AND  E
    { &opcode_a4,  4 }, // AND  H
    { &opcode_a5,  4 }, // AND  L
    { &opcode_a6,  7 }, // AND  (HL)
    { &opcode_a7,  4 }, // AND  A
    { &opcode_a8,  4 }, // XOR  B
    { &opcode_a9,  4 }, // XOR  C
    { &opcode_aa,  4 }, // XOR  D
    { &opcode_ab,  4 }, // XOR  E
    { &opcode_ac,  4 }, // XOR  H
    { &opcode_ad,  4 }, // XOR  L
    { &opcode_ae,  7 }, // XOR  (HL)
    { &opcode_af,  4 }, // XOR  A
    { &opcode_b0,  4 }, // OR   B
    { &opcode_b1,  4 }, // OR   C
    { &opcode_b2,  4 }, // OR   D
    { &opcode_b3,  4 }, // OR   E
    { &opcode_b4,  4 }, // OR   H
    { &opcode_b5,  4 }, // OR   L
    { &opcode_b6,  7 }, // OR   (HL)
    { &opcode_b7,  4 }, // OR   A
    { &opcode_b8,  4 }, // CP   B
    { &opcode_b9,  4 }, // CP   C
    { &opcode_ba,  4 }, // CP   D
    { &opcode_bb,  4 }, // CP   E
    { &opcode_bc,  4 }, // CP   H
    { &opcode_bd,  4 }, // CP   L
    { &opcode_be,  7 }, // CP   (HL)
    { &opcode_bf,  4 }, // CP   A
    { &opcode_c0,  5 }, // RET  NZ
    { &opcode_c1, 10 }, // POP  BC
    { &opcode_c2, 10 }, // JP   NZ,nn
    { &opcode_c3, 10 }, // JP   nn
    { &opcode_c4, 10 }, // CALL NZ,nn
    { &opcode_c5, 11 }, // PUSH BC
    { &opcode_c6,  7 }, // ADD  A,n
    { &opcode_c7, 11 }, // RST  0
    { &opcode_c8,  5 }, // RET  Z
    { &opcode_c9, 10 }, // RET
    { &opcode_ca, 10 }, // JP   Z,nn
    { &opcode_cb,  0 }, // [Prefix]
    { &opcode_cc, 10 }, // CALL Z,nn
    { &opcode_cd, 17 }, // CALL nn
    { &opcode_ce,  7 }, // ADC  A,n
    { &opcode_cf, 11 }, // RST  8
    { &opcode_d0,  5 }, // RET  NC
    { &opcode_d1, 10 }, // POP  DE
    { &opcode_d2, 10 }, // JP   NC,nn
    { &opcode_d3, 11 }, // OUT  (n),A
    { &opcode_d4, 10 }, // CALL NC,nn
    { &opcode_d5, 11 }, // PUSH DE
    { &opcode_d6,  7 }, // SUB  n
    { &opcode_d7, 11 }, // RST  10H
    { &opcode_d8,  5 }, // RET  C
    { &opcode_d9,  4 }, // EXX
    { &opcode_da, 10 }, // JP   C,nn
    { &opcode_db, 11 }, // IN   A,(n)
    { &opcode_dc, 10 }, // CALL C,nn
    { &opcode_dd,  0 }, // [IX Prefix]
    { &opcode_de,  7 }, // SBC  A,n
    { &opcode_df, 11 }, // RST  18H
    { &opcode_e0,  5 }, // RET  PO
    { &opcode_e1, 10 }, // POP  HL
    { &opcode_e2, 10 }, // JP   PO,nn
    { &opcode_e3, 19 }, // EX   (SP),HL
    { &opcode_e4, 10 }, // CALL PO,nn
    { &opcode_e5, 11 }, // PUSH HL
    { &opcode_e6,  7 }, // AND  n
    { &opcode_e7, 11 }, // RST  20H
    { &opcode_e8,  5 }, // RET  PE
    { &opcode_e9,  4 }, // JP   (HL)
    { &opcode_ea, 10 }, // JP   PE,nn
    { &opcode_eb,  4 }, // EX   DE,HL
    { &opcode_ec, 10 }, // CALL PE,nn
    { &opcode_ed,  0 }, // [Prefix]
    { &opcode_ee,  7 }, // XOR  n
    { &opcode_ef, 11 }, // RST  28H
    { &opcode_f0,  5 }, // RET  P
    { &opcode_f1, 10 }, // POP  AF
    { &opcode_f2, 10 }, // JP   P,nn
    { &opcode_f3,  4 }, // DI
    { &opcode_f4, 10 }, // CALL P,nn
    { &opcode_f5, 11 }, // PUSH AF
    { &opcode_f6,  7 }, // OR   n
    { &opcode_f7, 11 }, // RST  30H
    { &opcode_f8,  5 }, // RET  M
    { &opcode_f9,  6 }, // LD   SP,HL
    { &opcode_fa, 10 }, // JP   M,nn
    { &opcode_fb,  4 }, // EI
    { &opcode_fc, 10 }, // CALL M,nn
    { &opcode_fd,  0 }, // [IY Prefix]
    { &opcode_fe,  7 }, // CP   n
    { &opcode_ff, 11 }  // RST  38H
};                          

void opcode_00()    // NOP
{
}

void opcode_01()    // LD   BC,nn
{
    C = fetchByte();
    B = fetchByte();
}

void opcode_02()    // LD   (BC),A
{
    writeByte( BC(), A );
}

void opcode_03()    // INC  BC
{
    if( ++C == 0 ) ++B;
}

void opcode_04()    // INC  B
{
    B = incByte( B );
}

void opcode_05()    // DEC  B
{
    B = decByte( B );
}

void opcode_06()    // LD   B,n
{
    B = fetchByte();
}

void opcode_07()    // RLCA
{
    A = (A << 1) | (A >> 7);
    F = F & ~(AddSub | Halfcarry | Carry);
    if( A & 0x01 ) F |= Carry;
}

void opcode_08()    // EX   AF,AF'
{
    unsigned char x;

    x = A; A = A1; A1 = x;
    x = F; F = F1; F1 = x;
}

void opcode_09()    // ADD  HL,BC
{
    unsigned hl = HL();
    unsigned rp = BC();
    unsigned x  = hl + rp;

    F &= Sign | Zero | Parity;
    if( x > 0xFFFF ) F |= Carry;
    if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry;

    L = x & 0xFF;
    H = (x >> 8) & 0xFF;
}

void opcode_0a()    // LD   A,(BC)
{
    A = readByte( BC() );
}

void opcode_0b()    // DEC  BC
{
    if( C-- == 0 ) --B;
}

void opcode_0c()    // INC  C
{
    C = incByte( C );
}

void opcode_0d()    // DEC  C
{
    C = decByte( C );
}

void opcode_0e()    // LD   C,n
{
    C = fetchByte();
}

void opcode_0f()    // RRCA
{
    A = (A >> 1) | (A << 7);
    F = F & ~(AddSub | Halfcarry | Carry);
    if( A & 0x80 ) F |= Carry;
}

void opcode_10()    // DJNZ d
{
    unsigned char o = fetchByte();
    
    if( --B != 0 ) relJump( o ); 
}

void opcode_11()    // LD   DE,nn
{
    E = fetchByte();
    D = fetchByte();
}

void opcode_12()    // LD   (DE),A
{
    writeByte( DE(), A );
}

void opcode_13()    // INC  DE
{
    if( ++E == 0 ) ++D;
}

void opcode_14()    // INC  D
{
    D = incByte( D );
}

void opcode_15()    // DEC  D
{
    D = decByte( D );
}

void opcode_16()    // LD   D,n
{
    D = fetchByte();
}

void opcode_17()    // RLA
{
    unsigned char a = A;

    A <<= 1;
    if( F & Carry ) A |= 0x01;
    F = F & ~(AddSub | Halfcarry | Carry);
    if( a & 0x80 ) F |= Carry;
}

void opcode_18()    // JR   d
{
    relJump( fetchByte() );
}

void opcode_19()    // ADD  HL,DE
{
    unsigned hl = HL();
    unsigned rp = DE();
    unsigned x  = hl + rp;

    F &= Sign | Zero | Parity;
    if( x > 0xFFFF ) F |= Carry;
    if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry;

    L = x & 0xFF;
    H = (x >> 8) & 0xFF;
}

void opcode_1a()    // LD   A,(DE)
{
    A = readByte( DE() );
}

void opcode_1b()    // DEC  DE
{
    if( E-- == 0 ) --D;
}

void opcode_1c()    // INC  E
{
    E = incByte( E );
}

void opcode_1d()    // DEC  E
{
    E = decByte( E );
}

void opcode_1e()    // LD   E,n
{
    E = fetchByte();
}

void opcode_1f()    // RRA
{
    unsigned char a = A;

    A >>= 1;
    if( F & Carry ) A |= 0x80;
    F = F & ~(AddSub | Halfcarry | Carry);
    if( a & 0x01 ) F |= Carry;
}

void opcode_20()    // JR   NZ,d
{
    unsigned char o = fetchByte();
    
    if( ! (F & Zero) ) relJump( o );
}

void opcode_21()    // LD   HL,nn
{
    L = fetchByte();
    H = fetchByte();
}

void opcode_22()    // LD   (nn),HL
{
    unsigned x = fetchWord();

    writeByte( x  , L );
    writeByte( x+1, H );
}

void opcode_23()    // INC  HL
{
    if( ++L == 0 ) ++H;
}

void opcode_24()    // INC  H
{
    H = incByte( H );
}

void opcode_25()    // DEC  H
{
    H = decByte( H );
}

void opcode_26()    // LD   H,n
{
    H = fetchByte();
}

/*
    DAA is computed using the following table to get a diff value
    that is added to or subtracted (according to the N flag) from A:

        C Upper H Lower Diff
        -+-----+-+-----+----
        1   *   0  0-9   60
        1   *   1  0-9   66
        1   *   *  A-F   66
        0  0-9  0  0-9   00
        0  0-9  1  0-9   06
        0  0-8  *  A-F   06
        0  A-F  0  0-9   60
        0  9-F  *  A-F   66
        0  A-F  1  0-9   66

    The carry and halfcarry flags are then updated using similar tables.

    These tables were found by Stefano Donati of Ramsoft and are
    published in the "Undocumented Z80 Documented" paper by Sean Young,
    the following is an algorithmical implementation with no lookups.
*/
void opcode_27()    // DAA
{
    unsigned char diff;
    unsigned char hf = F & Halfcarry;
    unsigned char cf = F & Carry;
    unsigned char lower = A & 0x0F;

    if( cf ) {
        diff = (lower >= 0x0A) || hf ? 0x66 : 0x60;
    }
    else {
        diff = (A >= 0x9A) ? 0x60 : 0x00;

        if( hf || (lower >= 0x0A) ) diff += 0x06;
    }

    if( A >= 0x9A ) cf = Carry;

    if( F & Subtraction ) {
        A -= diff;
        F = PSZ_[A] | Subtraction | cf;
        if( hf && (lower <= 0x05) ) F |= Halfcarry;
    }
    else {
        A += diff;
        F = PSZ_[A] | cf;
        if( lower >= 0x0A ) F |= Halfcarry;
    }
}

void opcode_28()    // JR   Z,d
{
    unsigned char   o = fetchByte();
    
    if( F & Zero ) relJump( o );
}

void opcode_29()    // ADD  HL,HL
{
    unsigned hl = HL();
    unsigned rp = hl;
    unsigned x  = hl + rp;

    F &= Sign | Zero | Parity;
    if( x > 0xFFFF ) F |= Carry;
    if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry;

    L = x & 0xFF;
    H = (x >> 8) & 0xFF;
}

void opcode_2a()    // LD   HL,(nn)
{
    unsigned x = fetchWord();

    L = readByte( x );
    H = readByte( x+1 );
}

void opcode_2b()    // DEC  HL
{
    if( L-- == 0 ) --H;
}

void opcode_2c()    // INC  L
{
    L = incByte( L );
}

void opcode_2d()    // DEC  L
{
    L = decByte( L );
}

void opcode_2e()    // LD   L,n
{
    L = fetchByte();
}

void opcode_2f()    // CPL
{
    A ^= 0xFF;
    F |= AddSub | Halfcarry;
}

void opcode_30()    // JR   NC,d
{
    unsigned char o = fetchByte();
    
    if( ! (F & Carry) ) relJump( o );
}

void opcode_31()    // LD   SP,nn
{
    SP = fetchWord();
}

void opcode_32()    // LD   (nn),A
{
    writeByte( fetchWord(), A );
}

void opcode_33()    // INC  SP
{
    SP = (SP + 1) & 0xFFFF;
}

void opcode_34()    // INC  (HL)
{
    writeByte( HL(), incByte( readByte( HL() ) ) );
}

void opcode_35()    // DEC  (HL)
{
    writeByte( HL(), decByte( readByte( HL() ) ) );
}

void opcode_36()    // LD   (HL),n
{
    writeByte( HL(), fetchByte() );
}

void opcode_37()    // SCF
{
    F = (F & (Parity | Sign | Zero)) | Carry;
}

void opcode_38()    // JR   C,d
{
    unsigned char o = fetchByte();
    
    if( F & Carry ) relJump( o );
}

void opcode_39()    // ADD  HL,SP
{
    unsigned hl = HL();
    unsigned rp = SP;
    unsigned x  = hl + rp;

    F &= Sign | Zero | Parity;
    if( x > 0xFFFF ) F |= Carry;
    if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry;

    L = x & 0xFF;
    H = (x >> 8) & 0xFF;
}

void opcode_3a()    // LD   A,(nn)
{
    A = readByte( fetchWord() );
}

void opcode_3b()    // DEC  SP
{
    SP = (SP - 1) & 0xFFFF;
}

void opcode_3c()    // INC  A
{
    A = incByte( A );
}

void opcode_3d()    // DEC  A
{
    A = decByte( A );
}

void opcode_3e()    // LD   A,n
{
    A = fetchByte();
}

void opcode_3f()    // CCF
{
    if( F & Carry ) {
        F = (F & (Parity | Sign | Zero)) | Halfcarry; // Halfcarry holds previous carry
    }
    else {
        F = (F & (Parity | Sign | Zero)) | Carry;
    }
}

void opcode_40()    // LD   B,B
{
}

void opcode_41()    // LD   B,C
{
    B = C;
}

void opcode_42()    // LD   B,D
{
    B = D;
}

void opcode_43()    // LD   B,E
{
    B = E;
}

void opcode_44()    // LD   B,H
{
    B = H;
}

void opcode_45()    // LD   B,L
{
    B = L;
}

void opcode_46()    // LD   B,(HL)
{
    B = readByte( HL() );
}

void opcode_47()    // LD   B,A
{
    B = A;
}

void opcode_48()    // LD   C,B
{
    C = B;
}

void opcode_49()    // LD   C,C
{
}

void opcode_4a()    // LD   C,D
{
    C = D;
}

void opcode_4b()    // LD   C,E
{
    C = E;
}

void opcode_4c()    // LD   C,H
{
    C = H;
}

void opcode_4d()    // LD   C,L
{
    C = L;
}

void opcode_4e()    // LD   C,(HL)
{
    C = readByte( HL() );
}

void opcode_4f()    // LD   C,A
{
    C = A;
}

void opcode_50()    // LD   D,B
{
    D = B;
}

void opcode_51()    // LD   D,C
{
    D = C;
}

void opcode_52()    // LD   D,D
{
}

void opcode_53()    // LD   D,E
{
    D = E;
}

void opcode_54()    // LD   D,H
{
    D = H;
}

void opcode_55()    // LD   D,L
{
    D = L;
}

void opcode_56()    // LD   D,(HL)
{
    D = readByte( HL() );
}

void opcode_57()    // LD   D,A
{
    D = A;
}

void opcode_58()    // LD   E,B
{
    E = B;
}

void opcode_59()    // LD   E,C
{
    E = C;
}

void opcode_5a()    // LD   E,D
{
    E = D;
}

void opcode_5b()    // LD   E,E
{
}

void opcode_5c()    // LD   E,H
{
    E = H;
}

void opcode_5d()    // LD   E,L
{
    E = L;
}

void opcode_5e()    // LD   E,(HL)
{
    E = readByte( HL() );
}

void opcode_5f()    // LD   E,A
{
    E = A;
}

void opcode_60()    // LD   H,B
{
    H = B;
}

void opcode_61()    // LD   H,C
{
    H = C;
}

void opcode_62()    // LD   H,D
{
    H = D;
}

void opcode_63()    // LD   H,E
{
    H = E;
}

void opcode_64()    // LD   H,H
{
}

void opcode_65()    // LD   H,L
{
    H = L;
}

void opcode_66()    // LD   H,(HL)
{
    H = readByte( HL() );
}

void opcode_67()    // LD   H,A
{
    H = A;
}

void opcode_68()    // LD   L,B
{
    L = B;
}

void opcode_69()    // LD   L,C
{
    L = C;
}

void opcode_6a()    // LD   L,D
{
    L = D;
}

void opcode_6b()    // LD   L,E
{
    L = E;
}

void opcode_6c()    // LD   L,H
{
    L = H;
}

void opcode_6d()    // LD   L,L
{
}

void opcode_6e()    // LD   L,(HL)
{
    L = readByte( HL() );
}

void opcode_6f()    // LD   L,A
{
    L = A;
}

void opcode_70()    // LD   (HL),B
{
    writeByte( HL(), B );
}

void opcode_71()    // LD   (HL),C
{
    writeByte( HL(), C );
}

void opcode_72()    // LD   (HL),D
{
    writeByte( HL(), D );
}

void opcode_73()    // LD   (HL),E
{
    writeByte( HL(), E );
}

void opcode_74()    // LD   (HL),H
{
    writeByte( HL(), H );
}

void opcode_75()    // LD   (HL),L
{
    writeByte( HL(), L );
}

void opcode_76()    // HALT
{
    iflags_ |= Halted;
}

void opcode_77()    // LD   (HL),A
{
    writeByte( HL(), A );
}

void opcode_78()    // LD   A,B
{
    A = B;
}

void opcode_79()    // LD   A,C
{
    A = C;
}

void opcode_7a()    // LD   A,D
{
    A = D;
}

void opcode_7b()    // LD   A,E
{
    A = E;
}

void opcode_7c()    // LD   A,H
{
    A = H;
}

void opcode_7d()    // LD   A,L
{
    A = L;
}

void opcode_7e()    // LD   A,(HL)
{
    A = readByte( HL() );
}

void opcode_7f()    // LD   A,A
{
}

void opcode_80()    // ADD  A,B
{
    addByte( B, 0 );
}

void opcode_81()    // ADD  A,C
{
    addByte( C, 0 );
}

void opcode_82()    // ADD  A,D
{
    addByte( D, 0 );
}

void opcode_83()    // ADD  A,E
{
    addByte( E, 0 );
}

void opcode_84()    // ADD  A,H
{
    addByte( H, 0 );
}

void opcode_85()    // ADD  A,L
{
    addByte( L, 0 );
}

void opcode_86()    // ADD  A,(HL)
{
    addByte( readByte( HL() ), 0 );
}

void opcode_87()    // ADD  A,A
{
    addByte( A, 0 );
}

void opcode_88()    // ADC  A,B
{
    addByte( B, F & Carry );
}

void opcode_89()    // ADC  A,C
{
    addByte( C, F & Carry );
}

void opcode_8a()    // ADC  A,D
{
    addByte( D, F & Carry );
}

void opcode_8b()    // ADC  A,E
{
    addByte( E, F & Carry );
}

void opcode_8c()    // ADC  A,H
{
    addByte( H, F & Carry );
}

void opcode_8d()    // ADC  A,L
{
    addByte( L, F & Carry );
}

void opcode_8e()    // ADC  A,(HL)
{
    addByte( readByte( HL() ), F & Carry );
}

void opcode_8f()    // ADC  A,A
{
    addByte( A, F & Carry );
}

void opcode_90()    // SUB  B
{
    A = subByte( B, 0 );
}

void opcode_91()    // SUB  C
{
    A = subByte( C, 0 );
}

void opcode_92()    // SUB  D
{
    A = subByte( D, 0 );
}

void opcode_93()    // SUB  E
{
    A = subByte( E, 0 );
}

void opcode_94()    // SUB  H
{
    A = subByte( H, 0 );
}

void opcode_95()    // SUB  L
{
    A = subByte( L, 0 );
}

void opcode_96()    // SUB  (HL)
{
    A = subByte( readByte( HL() ), 0 );
}

void opcode_97()    // SUB  A
{
    A = subByte( A, 0 );
}

void opcode_98()    // SBC  A,B
{
    A = subByte( B, F & Carry );
}

void opcode_99()    // SBC  A,C
{
    A = subByte( C, F & Carry );
}

void opcode_9a()    // SBC  A,D
{
    A = subByte( D, F & Carry );
}

void opcode_9b()    // SBC  A,E
{
    A = subByte( E, F & Carry );
}

void opcode_9c()    // SBC  A,H
{
    A = subByte( H, F & Carry );
}

void opcode_9d()    // SBC  A,L
{
    A = subByte( L, F & Carry );
}

void opcode_9e()    // SBC  A,(HL)
{
    A = subByte( readByte( HL() ), F & Carry );
}

void opcode_9f()    // SBC  A,A
{
    A = subByte( A, F & Carry );
}

void opcode_a0()    // AND  B
{
    A &= B;
    setFlagsPSZ();
}

void opcode_a1()    // AND  C
{
    A &= C;
    setFlagsPSZ();
}

void opcode_a2()    // AND  D
{
    A &= D;
    setFlagsPSZ();
}

void opcode_a3()    // AND  E
{
    A &= E;
    setFlagsPSZ();
}

void opcode_a4()    // AND  H
{
    A &= H;
    setFlagsPSZ();
}

void opcode_a5()    // AND  L
{
    A &= L;
    setFlagsPSZ();
}

void opcode_a6()    // AND  (HL)
{
    A &= readByte( HL() );
    setFlagsPSZ();
}

void opcode_a7()    // AND  A
{
    setFlagsPSZ();
}

void opcode_a8()    // XOR  B
{
    A ^= B;
    setFlags35PSZ000();
}

void opcode_a9()    // XOR  C
{
    A ^= C;
    setFlags35PSZ000();
}

void opcode_aa()    // XOR  D
{
    A ^= D;
    setFlags35PSZ000();
}

void opcode_ab()    // XOR  E
{
    A ^= E;
    setFlags35PSZ000();
}

void opcode_ac()    // XOR  H
{
    A ^= H;
    setFlags35PSZ000();
}

void opcode_ad()    // XOR  L
{
    A ^= L;
    setFlags35PSZ000();
}

void opcode_ae()    // XOR  (HL)
{
    A ^= readByte( HL() );
    setFlags35PSZ000();
}

void opcode_af()    // XOR  A
{
    A = 0;
    setFlags35PSZ000();
}

void opcode_b0()    // OR   B
{
    A |= B;
    setFlags35PSZ000();
}

void opcode_b1()    // OR   C
{
    A |= C;
    setFlags35PSZ000();
}

void opcode_b2()    // OR   D
{
    A |= D;
    setFlags35PSZ000();
}

void opcode_b3()    // OR   E
{
    A |= E;
    setFlags35PSZ000();
}

void opcode_b4()    // OR   H
{
    A |= H;
    setFlags35PSZ000();
}

void opcode_b5()    // OR   L
{
    A |= L;
    setFlags35PSZ000();
}

void opcode_b6()    // OR   (HL)
{
    A |= readByte( HL() );
    setFlags35PSZ000();
}

void opcode_b7()    // OR   A
{
    setFlags35PSZ000();
}

void opcode_b8()    // CP   B
{
    cmpByte( B );
}

void opcode_b9()    // CP   C
{
    cmpByte( C );
}

void opcode_ba()    // CP   D
{
    cmpByte( D );
}

void opcode_bb()    // CP   E
{
    cmpByte( E );
}

void opcode_bc()    // CP   H
{
    cmpByte( H );
}

void opcode_bd()    // CP   L
{
    cmpByte( L );
}

void opcode_be()    // CP   (HL)
{
    cmpByte( readByte( HL() ) );
}

void opcode_bf()    // CP   A
{
    cmpByte( A );
}

void opcode_c0()    // RET  NZ
{
    if( ! (F & Zero) ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_c1()    // POP  BC
{
    C = readByte( SP++ );
    B = readByte( SP++ );
}

void opcode_c2()    // JP   NZ,nn
{
    if( ! (F & Zero) )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_c3()    // JP   nn
{
     PC = readWord( PC );
}

void opcode_c4()    // CALL NZ,nn
{
    if( ! (F & Zero) ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_c5()    // PUSH BC
{
    writeByte( --SP, B );
    writeByte( --SP, C );
}

void opcode_c6()    // ADD  A,n
{
    addByte( fetchByte(), 0 );
}

void opcode_c7()    // RST  0
{
    callSub( 0x00 );
}

void opcode_c8()    // RET  Z
{
    if( F & Zero ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_c9()    // RET
{
     retFromSub();
}

void opcode_ca()    // JP   Z,nn
{
    if( F & Zero )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_cb()    // [Prefix]
{
    unsigned op = fetchByte();

    cycles_ += OpInfoCB_[ op ].cycles;
    OpInfoCB_[ op ].handler();
}

void opcode_cc()    // CALL Z,nn
{
    if( F & Zero ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_cd()    // CALL nn
{
    callSub( fetchWord() );
}

void opcode_ce()    // ADC  A,n
{
    addByte( fetchByte(), F & Carry );
}

void opcode_cf()    // RST  8
{
    callSub( 0x08 );
}

void opcode_d0()    // RET  NC
{
    if( ! (F & Carry) ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_d1()    // POP  DE
{
    E = readByte( SP++ );
    D = readByte( SP++ );
}

void opcode_d2()    // JP   NC,nn
{
    if( ! (F & Carry) )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_d3()    // OUT  (n),A
{
    writePort( fetchByte(), A );
}

void opcode_d4()    // CALL NC,nn
{
    if( ! (F & Carry) ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_d5()    // PUSH DE
{
    writeByte( --SP, D );
    writeByte( --SP, E );
}

void opcode_d6()    // SUB  n
{
    A = subByte( fetchByte(), 0 );
}

void opcode_d7()    // RST  10H
{
    callSub( 0x10 );
}

void opcode_d8()    // RET  C
{
    if( F & Carry ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_d9()    // EXX
{
    unsigned char x;

    x = B; B = B1; B1 = x;
    x = C; C = C1; C1 = x;
    x = D; D = D1; D1 = x;
    x = E; E = E1; E1 = x;
    x = H; H = H1; H1 = x;
    x = L; L = L1; L1 = x;
}

void opcode_da()    // JP   C,nn
{
    if( F & Carry )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_db()    // IN   A,(n)
{
    A = readPort( fetchByte() );
}

void opcode_dc()    // CALL C,nn
{
    if( F & Carry ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_dd()    // [IX Prefix]
{
    do_opcode_xy( OpInfoDD_ );
    IX &= 0xFFFF;
}

void opcode_de()    // SBC  A,n
{
    A = subByte( fetchByte(), F & Carry );
}

void opcode_df()    // RST  18H
{
    callSub( 0x18 );
}

void opcode_e0()    // RET  PO
{
    if( ! (F & Parity) ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_e1()    // POP  HL
{
    L = readByte( SP++ );
    H = readByte( SP++ );
}

void opcode_e2()    // JP   PO,nn
{
    if( ! (F & Parity) )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_e3()    // EX   (SP),HL
{
    unsigned char x;

    x = readByte( SP   ); writeByte( SP,   L ); L = x;
    x = readByte( SP+1 ); writeByte( SP+1, H ); H = x;
}

void opcode_e4()    // CALL PO,nn
{
    if( ! (F & Parity) ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_e5()    // PUSH HL
{
    writeByte( --SP, H );
    writeByte( --SP, L );
}

void opcode_e6()    // AND  n
{
    A &= fetchByte();
    setFlagsPSZ();
}

void opcode_e7()    // RST  20H
{
    callSub( 0x20 );
}

void opcode_e8()    // RET  PE
{
    if( F & Parity ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_e9()    // JP   (HL)
{
    PC = HL();
}

void opcode_ea()    // JP   PE,nn
{
    if( F & Parity )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_eb()    // EX   DE,HL
{
    unsigned char x;

    x = D; D = H; H = x;
    x = E; E = L; L = x;
}

void opcode_ec()    // CALL PE,nn
{
    if( F & Parity ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_ed()    // [Prefix]
{
    unsigned op = fetchByte();

    if( OpInfoED_[ op ].handler ) {
        OpInfoED_[ op ].handler();
        cycles_ += OpInfoED_[ op ].cycles;
    }
    else {
        cycles_ += OpInfo_[ 0 ].cycles; // NOP
    }
}

void opcode_ee()    // XOR  n
{
    A ^= fetchByte();
    setFlags35PSZ000();
}

void opcode_ef()    // RST  28H
{
    callSub( 0x28 );
}

void opcode_f0()    // RET  P
{
    if( ! (F & Sign) ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_f1()    // POP  AF
{
    F = readByte( SP++ );
    A = readByte( SP++ );
}

void opcode_f2()    // JP   P,nn
{
    if( ! (F & Sign) )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_f3()    // DI
{
    iflags_ &= ~(IFF1 | IFF2);
}

void opcode_f4()    // CALL P,nn
{
    if( ! (F & Sign) ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_f5()    // PUSH AF
{
    writeByte( --SP, A );
    writeByte( --SP, F );
}

void opcode_f6()    // OR   n
{
    A |= fetchByte();
    setFlags35PSZ000();
}

void opcode_f7()    // RST  30H
{
    callSub( 0x30 );
}

void opcode_f8()    // RET  M
{
    if( F & Sign ) {
        retFromSub();
        cycles_ += 2;
    }
}

void opcode_f9()    // LD   SP,HL
{
    SP = HL();
}

void opcode_fa()    // JP   M,nn
{
    if( F & Sign )
        PC = fetchWord();
    else
        PC += 2;
}

void opcode_fb()    // EI
{
    iflags_ |= IFF1 | IFF2;
}

void opcode_fc()    // CALL M,nn
{
    if( F & Sign ) {
        callSub( fetchWord() );
        cycles_ += 2;
    }
    else {
        PC += 2;
    }
}

void opcode_fd()    // [IY Prefix]
{
    do_opcode_xy( OpInfoFD_ );
    IY &= 0xFFFF;
}


void opcode_fe()    // CP   n
{
    subByte( fetchByte(), 0 );
}

void opcode_ff()    // RST  38H
{
    callSub( 0x38 );
}


/* Executes one instruction */
void step(void)
{
    // Update memory refresh register (not strictly needed but...)
    R = (R+1) & 0x7F; 

    if( iflags_ & Halted ) {
        // CPU is halted, do a NOP instruction
        cycles_ += OpInfo_[0].cycles; // NOP
    }
    else {
        // Get the opcode to execute
        unsigned op = fetchByte();

        // Update the cycles counter with the number of cycles for this opcode
        cycles_ += OpInfo_[ op ].cycles;

        // Execute the opcode handler
        OpInfo_[ op ].handler();

        // Update registers
        PC &= 0xFFFF; // Clip program counter
        SP &= 0xFFFF; // Clip stack pointer
    }
}

/*
    Runs the CPU for the specified number of cycles.

    Note: the memory refresh register is not updated!
*/
unsigned z80_run( unsigned runCycles )
{
    unsigned target_cycles = cycles_ + runCycles;

    // Execute instructions until the specified number of
    // cycles has elapsed
    while( cycles_ < target_cycles ) {
        if( iflags_ & Halted ) {
            // CPU is halted, do NOPs for the rest of cycles
            // (this may be off by a few cycles)
            cycles_ = target_cycles;
        }
        else {
            // Get the opcode to execute
            unsigned op = fetchByte();

            // Update the cycles counter with the number of cycles for this opcode
            cycles_ += OpInfo_[ op ].cycles; 

            // Execute the opcode handler
            OpInfo_[ op ].handler();
        }
    }

    // Update registers
    PC &= 0xFFFF; // Clip program counter
    SP &= 0xFFFF; // Clip stack pointer

    // Return the number of extra cycles executed
    return cycles_ - target_cycles;
}

/* Interrupt */
void z80_interrupt( unsigned char data )
{
    // Execute interrupt only if interrupts are enabled
    if( iflags_ & IFF1 ) {
        // Disable maskable interrupts and restart the CPU if halted
        iflags_ &= ~(IFF1 | IFF2 | Halted); 

        switch( getInterruptMode() ) {
        case 0:
            OpInfo_[ data ].handler();
            cycles_ += 11;
            break;
        case 1:
            callSub( 0x38 );
            cycles_ += 11;
            break;
        case 2:
            callSub( readWord( ((unsigned)I) << 8 | (data & 0xFE) ) );
            cycles_ += 19;
            break;
        }
    }
}

/* Non-maskable interrupt */
void nmi(void)
{
    // Disable maskable interrupts but preserve IFF2 (that is a copy of IFF1),
    // also restart the CPU if halted
    iflags_ &= ~(IFF1 | Halted);

    callSub( 0x66 );

    cycles_ += 11;
}

void do_opcode_xy( OpcodeInfo * info )
{
    unsigned op = fetchByte();

    if( (op == 0xDD) || (op == 0xFD) ) {
        // Exit now, to avoid possible infinite loops
        PC--;
        cycles_ += OpInfo_[ 0 ].cycles; // NOP
    }
    else if( op == 0xED ) {
        // IX or IY prefix is ignored for this opcode
        opcode_ed();
    }
    else {
        // Handle IX or IY prefix if possible
        if( info[ op ].handler ) {
            // Extended opcode is valid
            cycles_ += info[ op ].cycles;
            info[ op ].handler();
        }
        else {
            // Extended opcode not valid, fall back to standard opcode
            cycles_ += OpInfo_[ op ].cycles;
            OpInfo_[ op ].handler();
        }
    }
}