Z80: avoid the need to invert the register values in Javascript

This commit is contained in:
David Banks 2018-10-12 12:40:59 +01:00
parent 3ae93282ba
commit 9760663cc1
2 changed files with 288 additions and 296 deletions

View File

@ -67,230 +67,230 @@ ex_dehl0: 625,
ex_dehl1: 629,
ex_dehl_combined: 626,
// Registers
reg_a0: 2271,
reg_a1: 2296,
reg_a2: 2384,
reg_a3: 2416,
reg_a4: 2489,
reg_a5: 2527,
reg_a6: 2610,
reg_a7: 2633,
reg_f0: 1854,
reg_f1: 1881,
reg_f2: 1958,
reg_f3: 1986,
reg_f4: 2058,
reg_f5: 2082,
reg_f6: 2155,
reg_f7: 2179,
reg_b0: 2268,
reg_b1: 2293,
reg_b2: 2381,
reg_b3: 2413,
reg_b4: 2486,
reg_b5: 2524,
reg_b6: 2607,
reg_b7: 2630,
reg_c0: 1851,
reg_c1: 1878,
reg_c2: 1955,
reg_c3: 1983,
reg_c4: 2055,
reg_c5: 2079,
reg_c6: 2152,
reg_c7: 2176,
reg_d0: 2264,
reg_d1: 2289,
reg_d2: 2377,
reg_d3: 2409,
reg_d4: 2482,
reg_d5: 2520,
reg_d6: 2603,
reg_d7: 2626,
reg_e0: 1847,
reg_e1: 1874,
reg_e2: 1951,
reg_e3: 1979,
reg_e4: 2051,
reg_e5: 2075,
reg_e6: 2148,
reg_e7: 2172,
reg_h0: 2266,
reg_h1: 2291,
reg_h2: 2379,
reg_h3: 2411,
reg_h4: 2484,
reg_h5: 2522,
reg_h6: 2605,
reg_h7: 2628,
reg_l0: 1849,
reg_l1: 1876,
reg_l2: 1953,
reg_l3: 1981,
reg_l4: 2053,
reg_l5: 2077,
reg_l6: 2150,
reg_l7: 2174,
reg_w0: 2260,
reg_w1: 2285,
reg_w2: 2373,
reg_w3: 2405,
reg_w4: 2478,
reg_w5: 2516,
reg_w6: 2599,
reg_w7: 2622,
reg_z0: 1843,
reg_z1: 1870,
reg_z2: 1947,
reg_z3: 1975,
reg_z4: 2047,
reg_z5: 2071,
reg_z6: 2144,
reg_z7: 2168,
reg_pch0: 2258,
reg_pch1: 2283,
reg_pch2: 2371,
reg_pch3: 2403,
reg_pch4: 2476,
reg_pch5: 2514,
reg_pch6: 2597,
reg_pch7: 2620,
reg_pcl0: 1841,
reg_pcl1: 1868,
reg_pcl2: 1945,
reg_pcl3: 1973,
reg_pcl4: 2045,
reg_pcl5: 2069,
reg_pcl6: 2142,
reg_pcl7: 2166,
reg_sph0: 2261,
reg_sph1: 2286,
reg_sph2: 2374,
reg_sph3: 2406,
reg_sph4: 2479,
reg_sph5: 2517,
reg_sph6: 2600,
reg_sph7: 2623,
reg_spl0: 1844,
reg_spl1: 1871,
reg_spl2: 1948,
reg_spl3: 1976,
reg_spl4: 2048,
reg_spl5: 2072,
reg_spl6: 2145,
reg_spl7: 2169,
reg_ixh0: 2263,
reg_ixh1: 2288,
reg_ixh2: 2376,
reg_ixh3: 2408,
reg_ixh4: 2481,
reg_ixh5: 2519,
reg_ixh6: 2602,
reg_ixh7: 2625,
reg_ixl0: 1846,
reg_ixl1: 1873,
reg_ixl2: 1950,
reg_ixl3: 1978,
reg_ixl4: 2050,
reg_ixl5: 2074,
reg_ixl6: 2147,
reg_ixl7: 2171,
reg_iyh0: 2262,
reg_iyh1: 2287,
reg_iyh2: 2375,
reg_iyh3: 2407,
reg_iyh4: 2480,
reg_iyh5: 2518,
reg_iyh6: 2601,
reg_iyh7: 2624,
reg_iyl0: 1845,
reg_iyl1: 1872,
reg_iyl2: 1949,
reg_iyl3: 1977,
reg_iyl4: 2049,
reg_iyl5: 2073,
reg_iyl6: 2146,
reg_iyl7: 2170,
reg_i0: 2259,
reg_i1: 2284,
reg_i2: 2372,
reg_i3: 2404,
reg_i4: 2477,
reg_i5: 2515,
reg_i6: 2598,
reg_i7: 2621,
reg_r0: 1842,
reg_r1: 1869,
reg_r2: 1946,
reg_r3: 1974,
reg_r4: 2046,
reg_r5: 2070,
reg_r6: 2143,
reg_r7: 2167,
reg_aa0: 2270,
reg_aa1: 2295,
reg_aa2: 2383,
reg_aa3: 2415,
reg_aa4: 2488,
reg_aa5: 2526,
reg_aa6: 2609,
reg_aa7: 2632,
reg_ff0: 1853,
reg_ff1: 1880,
reg_ff2: 1957,
reg_ff3: 1985,
reg_ff4: 2057,
reg_ff5: 2081,
reg_ff6: 2154,
reg_ff7: 2178,
reg_bb0: 2269,
reg_bb1: 2294,
reg_bb2: 2382,
reg_bb3: 2414,
reg_bb4: 2487,
reg_bb5: 2525,
reg_bb6: 2608,
reg_bb7: 2631,
reg_cc0: 1852,
reg_cc1: 1879,
reg_cc2: 1956,
reg_cc3: 1984,
reg_cc4: 2056,
reg_cc5: 2080,
reg_cc6: 2153,
reg_cc7: 2177,
reg_dd0: 2265,
reg_dd1: 2290,
reg_dd2: 2378,
reg_dd3: 2410,
reg_dd4: 2483,
reg_dd5: 2521,
reg_dd6: 2604,
reg_dd7: 2627,
reg_ee0: 1848,
reg_ee1: 1875,
reg_ee2: 1952,
reg_ee3: 1980,
reg_ee4: 2052,
reg_ee5: 2076,
reg_ee6: 2149,
reg_ee7: 2173,
reg_hh0: 2267,
reg_hh1: 2292,
reg_hh2: 2380,
reg_hh3: 2412,
reg_hh4: 2485,
reg_hh5: 2523,
reg_hh6: 2606,
reg_hh7: 2629,
reg_ll0: 1850,
reg_ll1: 1877,
reg_ll2: 1954,
reg_ll3: 1982,
reg_ll4: 2054,
reg_ll5: 2078,
reg_ll6: 2151,
reg_ll7: 2175,
reg_a0: 2245,
reg_a1: 2319,
reg_a2: 2357,
reg_a3: 2442,
reg_a4: 2463,
reg_a5: 2552,
reg_a6: 2586,
reg_a7: 2656,
reg_f0: 1827,
reg_f1: 1903,
reg_f2: 1928,
reg_f3: 2009,
reg_f4: 2032,
reg_f5: 2107,
reg_f6: 2132,
reg_f7: 2209,
reg_b0: 2242,
reg_b1: 2316,
reg_b2: 2354,
reg_b3: 2439,
reg_b4: 2460,
reg_b5: 2549,
reg_b6: 2583,
reg_b7: 2653,
reg_c0: 1824,
reg_c1: 1900,
reg_c2: 1925,
reg_c3: 2006,
reg_c4: 2029,
reg_c5: 2104,
reg_c6: 2129,
reg_c7: 2206,
reg_d0: 2238,
reg_d1: 2312,
reg_d2: 2350,
reg_d3: 2435,
reg_d4: 2456,
reg_d5: 2545,
reg_d6: 2579,
reg_d7: 2649,
reg_e0: 1820,
reg_e1: 1896,
reg_e2: 1921,
reg_e3: 2002,
reg_e4: 2025,
reg_e5: 2100,
reg_e6: 2125,
reg_e7: 2202,
reg_h0: 2240,
reg_h1: 2314,
reg_h2: 2352,
reg_h3: 2437,
reg_h4: 2458,
reg_h5: 2547,
reg_h6: 2581,
reg_h7: 2651,
reg_l0: 1822,
reg_l1: 1898,
reg_l2: 1923,
reg_l3: 2004,
reg_l4: 2027,
reg_l5: 2102,
reg_l6: 2127,
reg_l7: 2204,
reg_w0: 2234,
reg_w1: 2308,
reg_w2: 2346,
reg_w3: 2431,
reg_w4: 2452,
reg_w5: 2541,
reg_w6: 2575,
reg_w7: 2645,
reg_z0: 1816,
reg_z1: 1892,
reg_z2: 1917,
reg_z3: 1998,
reg_z4: 2021,
reg_z5: 2096,
reg_z6: 2121,
reg_z7: 2198,
reg_pch0: 2232,
reg_pch1: 2306,
reg_pch2: 2344,
reg_pch3: 2429,
reg_pch4: 2450,
reg_pch5: 2539,
reg_pch6: 2573,
reg_pch7: 2643,
reg_pcl0: 1814,
reg_pcl1: 1890,
reg_pcl2: 1915,
reg_pcl3: 1996,
reg_pcl4: 2019,
reg_pcl5: 2094,
reg_pcl6: 2119,
reg_pcl7: 2196,
reg_sph0: 2235,
reg_sph1: 2309,
reg_sph2: 2347,
reg_sph3: 2432,
reg_sph4: 2453,
reg_sph5: 2542,
reg_sph6: 2576,
reg_sph7: 2646,
reg_spl0: 1817,
reg_spl1: 1893,
reg_spl2: 1918,
reg_spl3: 1999,
reg_spl4: 2022,
reg_spl5: 2097,
reg_spl6: 2122,
reg_spl7: 2199,
reg_ixh0: 2237,
reg_ixh1: 2311,
reg_ixh2: 2349,
reg_ixh3: 2434,
reg_ixh4: 2455,
reg_ixh5: 2544,
reg_ixh6: 2578,
reg_ixh7: 2648,
reg_ixl0: 1819,
reg_ixl1: 1895,
reg_ixl2: 1920,
reg_ixl3: 2001,
reg_ixl4: 2024,
reg_ixl5: 2099,
reg_ixl6: 2124,
reg_ixl7: 2201,
reg_iyh0: 2236,
reg_iyh1: 2310,
reg_iyh2: 2348,
reg_iyh3: 2433,
reg_iyh4: 2454,
reg_iyh5: 2543,
reg_iyh6: 2577,
reg_iyh7: 2647,
reg_iyl0: 1818,
reg_iyl1: 1894,
reg_iyl2: 1919,
reg_iyl3: 2000,
reg_iyl4: 2023,
reg_iyl5: 2098,
reg_iyl6: 2123,
reg_iyl7: 2200,
reg_i0: 2233,
reg_i1: 2307,
reg_i2: 2345,
reg_i3: 2430,
reg_i4: 2451,
reg_i5: 2540,
reg_i6: 2574,
reg_i7: 2644,
reg_r0: 1815,
reg_r1: 1891,
reg_r2: 1916,
reg_r3: 1997,
reg_r4: 2020,
reg_r5: 2095,
reg_r6: 2120,
reg_r7: 2197,
reg_aa0: 2244,
reg_aa1: 2318,
reg_aa2: 2356,
reg_aa3: 2441,
reg_aa4: 2462,
reg_aa5: 2551,
reg_aa6: 2585,
reg_aa7: 2655,
reg_ff0: 1826,
reg_ff1: 1902,
reg_ff2: 1927,
reg_ff3: 2008,
reg_ff4: 2031,
reg_ff5: 2106,
reg_ff6: 2131,
reg_ff7: 2208,
reg_bb0: 2243,
reg_bb1: 2317,
reg_bb2: 2355,
reg_bb3: 2440,
reg_bb4: 2461,
reg_bb5: 2550,
reg_bb6: 2584,
reg_bb7: 2654,
reg_cc0: 1825,
reg_cc1: 1901,
reg_cc2: 1926,
reg_cc3: 2007,
reg_cc4: 2030,
reg_cc5: 2105,
reg_cc6: 2130,
reg_cc7: 2207,
reg_dd0: 2239,
reg_dd1: 2313,
reg_dd2: 2351,
reg_dd3: 2436,
reg_dd4: 2457,
reg_dd5: 2546,
reg_dd6: 2580,
reg_dd7: 2650,
reg_ee0: 1821,
reg_ee1: 1897,
reg_ee2: 1922,
reg_ee3: 2003,
reg_ee4: 2026,
reg_ee5: 2101,
reg_ee6: 2126,
reg_ee7: 2203,
reg_hh0: 2241,
reg_hh1: 2315,
reg_hh2: 2353,
reg_hh3: 2438,
reg_hh4: 2459,
reg_hh5: 2548,
reg_hh6: 2582,
reg_hh7: 2652,
reg_ll0: 1823,
reg_ll1: 1899,
reg_ll2: 1924,
reg_ll3: 2005,
reg_ll4: 2028,
reg_ll5: 2103,
reg_ll6: 2128,
reg_ll7: 2205,
// Data buses and control
dp_dl: 82,
dl_dp: 165,

View File

@ -260,48 +260,48 @@ function handleBusWrite(){
function readA() {
if (!isNodeHigh(nodenames['ex_af'])) {
return 0xFF ^ readBits('reg_aa', 8);
return readBits('reg_aa', 8);
} else {
return 0xFF ^ readBits('reg_a', 8);
return readBits('reg_a', 8);
}
}
function readF() {
if (!isNodeHigh(nodenames['ex_af'])) {
return 0xFF ^ readBits('reg_ff', 8);
return readBits('reg_ff', 8);
} else {
return 0xFF ^ readBits('reg_f', 8);
return readBits('reg_f', 8);
}
}
function readB() {
if (isNodeHigh(nodenames['ex_bcdehl'])) {
return 0xFF ^ readBits('reg_bb', 8);
return readBits('reg_bb', 8);
} else {
return 0xFF ^ readBits('reg_b', 8);
return readBits('reg_b', 8);
}
}
function readC() {
if (isNodeHigh(nodenames['ex_bcdehl'])) {
return 0xFF ^ readBits('reg_cc', 8);
return readBits('reg_cc', 8);
} else {
return 0xFF ^ readBits('reg_c', 8);
return readBits('reg_c', 8);
}
}
function readD() {
if (isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_hh', 8);
return readBits('reg_hh', 8);
} else {
return 0xFF ^ readBits('reg_dd', 8);
return readBits('reg_dd', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_h', 8);
return readBits('reg_h', 8);
} else {
return 0xFF ^ readBits('reg_d', 8);
return readBits('reg_d', 8);
}
}
}
@ -309,15 +309,15 @@ function readD() {
function readE() {
if (isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_ll', 8);
return readBits('reg_ll', 8);
} else {
return 0xFF ^ readBits('reg_ee', 8);
return readBits('reg_ee', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_l', 8);
return readBits('reg_l', 8);
} else {
return 0xFF ^ readBits('reg_e', 8);
return readBits('reg_e', 8);
}
}
}
@ -325,15 +325,15 @@ function readE() {
function readH() {
if (isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_dd', 8);
return readBits('reg_dd', 8);
} else {
return 0xFF ^ readBits('reg_hh', 8);
return readBits('reg_hh', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_d', 8);
return readBits('reg_d', 8);
} else {
return 0xFF ^ readBits('reg_h', 8);
return readBits('reg_h', 8);
}
}
}
@ -341,63 +341,63 @@ function readH() {
function readL() {
if (isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_ee', 8);
return readBits('reg_ee', 8);
} else {
return 0xFF ^ readBits('reg_ll', 8);
return readBits('reg_ll', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_e', 8);
return readBits('reg_e', 8);
} else {
return 0xFF ^ readBits('reg_l', 8);
return readBits('reg_l', 8);
}
}
}
function readA2() {
if (isNodeHigh(nodenames['ex_af'])) {
return 0xFF ^ readBits('reg_aa', 8);
return readBits('reg_aa', 8);
} else {
return 0xFF ^ readBits('reg_a', 8);
return readBits('reg_a', 8);
}
}
function readF2() {
if (isNodeHigh(nodenames['ex_af'])) {
return 0xFF ^ readBits('reg_ff', 8);
return readBits('reg_ff', 8);
} else {
return 0xFF ^ readBits('reg_f', 8);
return readBits('reg_f', 8);
}
}
function readB2() {
if (!isNodeHigh(nodenames['ex_bcdehl'])) {
return 0xFF ^ readBits('reg_bb', 8);
return readBits('reg_bb', 8);
} else {
return 0xFF ^ readBits('reg_b', 8);
return readBits('reg_b', 8);
}
}
function readC2() {
if (!isNodeHigh(nodenames['ex_bcdehl'])) {
return 0xFF ^ readBits('reg_cc', 8);
return readBits('reg_cc', 8);
} else {
return 0xFF ^ readBits('reg_c', 8);
return readBits('reg_c', 8);
}
}
function readD2() {
if (!isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_hh', 8);
return readBits('reg_hh', 8);
} else {
return 0xFF ^ readBits('reg_dd', 8);
return readBits('reg_dd', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_h', 8);
return readBits('reg_h', 8);
} else {
return 0xFF ^ readBits('reg_d', 8);
return readBits('reg_d', 8);
}
}
}
@ -405,15 +405,15 @@ function readD2() {
function readE2() {
if (!isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_ll', 8);
return readBits('reg_ll', 8);
} else {
return 0xFF ^ readBits('reg_ee', 8);
return readBits('reg_ee', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_l', 8);
return readBits('reg_l', 8);
} else {
return 0xFF ^ readBits('reg_e', 8);
return readBits('reg_e', 8);
}
}
}
@ -421,15 +421,15 @@ function readE2() {
function readH2() {
if (!isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_dd', 8);
return readBits('reg_dd', 8);
} else {
return 0xFF ^ readBits('reg_hh', 8);
return readBits('reg_hh', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_d', 8);
return readBits('reg_d', 8);
} else {
return 0xFF ^ readBits('reg_h', 8);
return readBits('reg_h', 8);
}
}
}
@ -437,30 +437,30 @@ function readH2() {
function readL2() {
if (!isNodeHigh(nodenames['ex_bcdehl'])) {
if (isNodeHigh(nodenames['ex_dehl1'])) {
return 0xFF ^ readBits('reg_ee', 8);
return readBits('reg_ee', 8);
} else {
return 0xFF ^ readBits('reg_ll', 8);
return readBits('reg_ll', 8);
}
} else {
if (isNodeHigh(nodenames['ex_dehl0'])) {
return 0xFF ^ readBits('reg_e', 8);
return readBits('reg_e', 8);
} else {
return 0xFF ^ readBits('reg_l', 8);
return readBits('reg_l', 8);
}
}
}
function readI(){return 0xFF ^ readBits('reg_i', 8);}
function readR(){return 0xFF ^ readBits('reg_r', 8);}
function readW(){return 0xFF ^ readBits('reg_w', 8);}
function readZ(){return 0xFF ^ readBits('reg_z', 8);}
function readI(){return readBits('reg_i', 8);}
function readR(){return readBits('reg_r', 8);}
function readW(){return readBits('reg_w', 8);}
function readZ(){return readBits('reg_z', 8);}
function readIX(){return 0xFFFF ^ ((readBits('reg_ixh', 8)<<8) + readBits('reg_ixl', 8));}
function readIY(){return 0xFFFF ^ ((readBits('reg_iyh', 8)<<8) + readBits('reg_iyl', 8));}
function readSP(){return 0xFFFF ^ ((readBits('reg_sph', 8)<<8) + readBits('reg_spl', 8));}
function readPC(){return 0xFFFF ^ ((readBits('reg_pch', 8)<<8) + readBits('reg_pcl', 8));}
function readPCL(){return 0xFF ^ readBits('reg_pcl', 8);}
function readPCH(){return 0xFF ^ readBits('reg_pch', 8);}
function readIX(){return (readBits('reg_ixh', 8)<<8) + readBits('reg_ixl', 8);}
function readIY(){return (readBits('reg_iyh', 8)<<8) + readBits('reg_iyl', 8);}
function readSP(){return (readBits('reg_sph', 8)<<8) + readBits('reg_spl', 8);}
function readPC(){return (readBits('reg_pch', 8)<<8) + readBits('reg_pcl', 8);}
function readPCL(){return readBits('reg_pcl', 8);}
function readPCH(){return readBits('reg_pch', 8);}
function formatFstring(f){
var result;
@ -492,14 +492,6 @@ function listActiveTCStates() {
return s.join(" ");
}
function busToHexInv(busname){
var value=busToHex(busname)
if (typeof value != "undefined")
return value.replace(/./g,function(x){return (15-parseInt(x,16)).toString(16)});
else
return undefined;;
}
function busToString(busname){
// takes a signal name or prefix
// returns an appropriate string representation
@ -527,17 +519,17 @@ function busToString(busname){
if(busname=='hl2')
return hexByte(readH2()) + hexByte(readL2());
if(busname=='ir')
return busToHexInv('reg_i') + busToHexInv('reg_r');
return busToHex('reg_i') + busToHex('reg_r');
if(busname=='wz')
return busToHexInv('reg_w') + busToHexInv('reg_z');
return busToHex('reg_w') + busToHex('reg_z');
if(busname=='pc')
return busToHexInv('reg_pch') + busToHexInv('reg_pcl');
return busToHex('reg_pch') + busToHex('reg_pcl');
if(busname=='sp')
return busToHexInv('reg_sph') + busToHexInv('reg_spl');
return busToHex('reg_sph') + busToHex('reg_spl');
if(busname=='ix')
return busToHexInv('reg_ixh') + busToHexInv('reg_ixl');
return busToHex('reg_ixh') + busToHex('reg_ixl');
if(busname=='iy')
return busToHexInv('reg_iyh') + busToHexInv('reg_iyl');
return busToHex('reg_iyh') + busToHex('reg_iyl');
if(busname=='State')
return listActiveTCStates();
// DMB: TODO