Advertisement
xX4m4zingXx

Texture.java

Oct 19th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 76.23 KB | None | 0 0
  1. package client;
  2.  
  3. public final class Texture extends DrawingArea {
  4.  
  5. public static void nullLoader() {
  6. anIntArray1468 = null;
  7. anIntArray1468 = null;
  8. anIntArray1470 = null;
  9. anIntArray1471 = null;
  10. anIntArray1472 = null;
  11. aBackgroundArray1474s = null;
  12. aBooleanArray1475 = null;
  13. anIntArray1476 = null;
  14. anIntArrayArray1478 = null;
  15. anIntArrayArray1479 = null;
  16. anIntArray1480 = null;
  17. anIntArray1482 = null;
  18. anIntArrayArray1483 = null;
  19. }
  20.  
  21. public static void method364() {
  22. anIntArray1472 = new int[DrawingArea.height];
  23. for (int j = 0; j < DrawingArea.height; j++)
  24. anIntArray1472[j] = DrawingArea.width * j;
  25.  
  26. textureInt1 = DrawingArea.width / 2;
  27. textureInt2 = DrawingArea.height / 2;
  28. }
  29.  
  30. public static void method365(int j, int k) {
  31. anIntArray1472 = new int[k];
  32. for (int l = 0; l < k; l++)
  33. anIntArray1472[l] = j * l;
  34.  
  35. textureInt1 = j / 2;
  36. textureInt2 = k / 2;
  37. }
  38.  
  39. public static void method366() {
  40. anIntArrayArray1478 = null;
  41. for (int j = 0; j < 52; j++)
  42. anIntArrayArray1479[j] = null;
  43.  
  44. }
  45.  
  46. public static void method367() {
  47. if (anIntArrayArray1478 == null) {
  48. anInt1477 = 20;// was parameter
  49. if (lowMem)
  50. anIntArrayArray1478 = new int[anInt1477][16384];
  51. else
  52. anIntArrayArray1478 = new int[anInt1477][0x10000];
  53. for (int k = 0; k < 52; k++)
  54. anIntArrayArray1479[k] = null;
  55.  
  56. }
  57. }
  58.  
  59. public static void unpack(StreamLoader streamLoader) {
  60. anInt1473 = 0;
  61. for (int j = 0; j < 52; j++)
  62. try {
  63. aBackgroundArray1474s[j] = new Background(streamLoader,
  64. String.valueOf(j), 0);
  65. if (lowMem && aBackgroundArray1474s[j].anInt1456 == 128)
  66. aBackgroundArray1474s[j].method356();
  67. else
  68. aBackgroundArray1474s[j].method357();
  69. anInt1473++;
  70. } catch (Exception _ex) {
  71. }
  72.  
  73. }
  74.  
  75. public static void method368(StreamLoader streamLoader) {
  76. anInt1473 = 0;
  77. for (int j = 0; j < 52; j++)
  78. try {
  79. aBackgroundArray1474s[j] = new Background(streamLoader,
  80. String.valueOf(j), 0);
  81. if (lowMem && aBackgroundArray1474s[j].anInt1456 == 128)
  82. aBackgroundArray1474s[j].method356();
  83. else
  84. aBackgroundArray1474s[j].method357();
  85. anInt1473++;
  86. } catch (Exception _ex) {
  87. }
  88.  
  89. }
  90.  
  91. public static int method369(int i) {
  92. if (anIntArray1476[i] != 0)
  93. return anIntArray1476[i];
  94. int k = 0;
  95. int l = 0;
  96. int i1 = 0;
  97. int j1 = anIntArrayArray1483[i].length;
  98. for (int k1 = 0; k1 < j1; k1++) {
  99. k += anIntArrayArray1483[i][k1] >> 16 & 0xff;
  100. l += anIntArrayArray1483[i][k1] >> 8 & 0xff;
  101. i1 += anIntArrayArray1483[i][k1] & 0xff;
  102. }
  103.  
  104. int l1 = (k / j1 << 16) + (l / j1 << 8) + i1 / j1;
  105. l1 = method373(l1, 1.3999999999999999D);
  106. if (l1 == 0)
  107. l1 = 1;
  108. anIntArray1476[i] = l1;
  109. return l1;
  110. }
  111.  
  112. public static void method370(int i) {
  113. if (anIntArrayArray1479[i] == null)
  114. return;
  115. anIntArrayArray1478[anInt1477++] = anIntArrayArray1479[i];
  116. anIntArrayArray1479[i] = null;
  117. }
  118.  
  119. private static int[] getTexturePixels(int textureId) {
  120. anIntArray1480[textureId] = anInt1481++;
  121. if (anIntArrayArray1479[textureId] != null)
  122. return anIntArrayArray1479[textureId];
  123. int ai[];
  124. if (anInt1477 > 0) {
  125. ai = anIntArrayArray1478[--anInt1477];
  126. anIntArrayArray1478[anInt1477] = null;
  127. } else {
  128. int j = 0;
  129. int k = -1;
  130. for (int l = 0; l < anInt1473; l++)
  131. if (anIntArrayArray1479[l] != null
  132. && (anIntArray1480[l] < j || k == -1)) {
  133. j = anIntArray1480[l];
  134. k = l;
  135. }
  136.  
  137. ai = anIntArrayArray1479[k];
  138. anIntArrayArray1479[k] = null;
  139. }
  140. anIntArrayArray1479[textureId] = ai;
  141. Background background = aBackgroundArray1474s[textureId];
  142. int ai1[] = anIntArrayArray1483[textureId];
  143. if (lowMem) {
  144. aBooleanArray1475[textureId] = false;
  145. for (int i1 = 0; i1 < 4096; i1++) {
  146. int i2 = ai[i1] = ai1[background.aByteArray1450[i1]] & 0xf8f8ff;
  147. if (i2 == 0)
  148. aBooleanArray1475[textureId] = true;
  149. ai[4096 + i1] = i2 - (i2 >>> 3) & 0xf8f8ff;
  150. ai[8192 + i1] = i2 - (i2 >>> 2) & 0xf8f8ff;
  151. ai[12288 + i1] = i2 - (i2 >>> 2) - (i2 >>> 3) & 0xf8f8ff;
  152. }
  153.  
  154. } else {
  155. if (background.anInt1452 == 64) {
  156. for (int j1 = 0; j1 < 128; j1++) {
  157. for (int j2 = 0; j2 < 128; j2++)
  158. ai[j2 + (j1 << 7)] = ai1[background.aByteArray1450[(j2 >> 1)
  159. + ((j1 >> 1) << 6)]];
  160.  
  161. }
  162.  
  163. } else {
  164. for (int k1 = 0; k1 < 16384; k1++)
  165. ai[k1] = ai1[background.aByteArray1450[k1]];
  166.  
  167. }
  168. aBooleanArray1475[textureId] = false;
  169. for (int l1 = 0; l1 < 16384; l1++) {
  170. ai[l1] &= 0xf8f8ff;
  171. int k2 = ai[l1];
  172. if (k2 == 0)
  173. aBooleanArray1475[textureId] = true;
  174. ai[16384 + l1] = k2 - (k2 >>> 3) & 0xf8f8ff;
  175. ai[32768 + l1] = k2 - (k2 >>> 2) & 0xf8f8ff;
  176. ai[49152 + l1] = k2 - (k2 >>> 2) - (k2 >>> 3) & 0xf8f8ff;
  177. }
  178.  
  179. }
  180. return ai;
  181. }
  182.  
  183. public static void method372(double d) {
  184. d += Math.random() * 0.029999999999999999D - 0.014999999999999999D;
  185. int j = 0;
  186. for (int k = 0; k < 512; k++) {
  187. double d1 = k / 8 / 64D + 0.0078125D;
  188. double d2 = (k & 7) / 8D + 0.0625D;
  189. for (int k1 = 0; k1 < 128; k1++) {
  190. double d3 = k1 / 128D;
  191. double d4 = d3;
  192. double d5 = d3;
  193. double d6 = d3;
  194. if (d2 != 0.0D) {
  195. double d7;
  196. if (d3 < 0.5D)
  197. d7 = d3 * (1.0D + d2);
  198. else
  199. d7 = (d3 + d2) - d3 * d2;
  200. double d8 = 2D * d3 - d7;
  201. double d9 = d1 + 0.33333333333333331D;
  202. if (d9 > 1.0D)
  203. d9--;
  204. double d10 = d1;
  205. double d11 = d1 - 0.33333333333333331D;
  206. if (d11 < 0.0D)
  207. d11++;
  208. if (6D * d9 < 1.0D)
  209. d4 = d8 + (d7 - d8) * 6D * d9;
  210. else if (2D * d9 < 1.0D)
  211. d4 = d7;
  212. else if (3D * d9 < 2D)
  213. d4 = d8 + (d7 - d8) * (0.66666666666666663D - d9) * 6D;
  214. else
  215. d4 = d8;
  216. if (6D * d10 < 1.0D)
  217. d5 = d8 + (d7 - d8) * 6D * d10;
  218. else if (2D * d10 < 1.0D)
  219. d5 = d7;
  220. else if (3D * d10 < 2D)
  221. d5 = d8 + (d7 - d8) * (0.66666666666666663D - d10) * 6D;
  222. else
  223. d5 = d8;
  224. if (6D * d11 < 1.0D)
  225. d6 = d8 + (d7 - d8) * 6D * d11;
  226. else if (2D * d11 < 1.0D)
  227. d6 = d7;
  228. else if (3D * d11 < 2D)
  229. d6 = d8 + (d7 - d8) * (0.66666666666666663D - d11) * 6D;
  230. else
  231. d6 = d8;
  232. }
  233. int l1 = (int) (d4 * 256D);
  234. int i2 = (int) (d5 * 256D);
  235. int j2 = (int) (d6 * 256D);
  236. int k2 = (l1 << 16) + (i2 << 8) + j2;
  237. k2 = method373(k2, d);
  238. if (k2 == 0)
  239. k2 = 1;
  240. anIntArray1482[j++] = k2;
  241. }
  242.  
  243. }
  244.  
  245. for (int l = 0; l < 52; l++)
  246. if (aBackgroundArray1474s[l] != null) {
  247. int ai[] = aBackgroundArray1474s[l].anIntArray1451;
  248. anIntArrayArray1483[l] = new int[ai.length];
  249. for (int j1 = 0; j1 < ai.length; j1++) {
  250. anIntArrayArray1483[l][j1] = method373(ai[j1], d);
  251. if ((anIntArrayArray1483[l][j1] & 0xf8f8ff) == 0 && j1 != 0)
  252. anIntArrayArray1483[l][j1] = 1;
  253. }
  254.  
  255. }
  256.  
  257. for (int i1 = 0; i1 < 52; i1++)
  258. method370(i1);
  259.  
  260. }
  261.  
  262. private static int method373(int i, double d) {
  263. double d1 = (i >> 16) / 256D;
  264. double d2 = (i >> 8 & 0xff) / 256D;
  265. double d3 = (i & 0xff) / 256D;
  266. d1 = Math.pow(d1, d);
  267. d2 = Math.pow(d2, d);
  268. d3 = Math.pow(d3, d);
  269. int j = (int) (d1 * 256D);
  270. int k = (int) (d2 * 256D);
  271. int l = (int) (d3 * 256D);
  272. return (j << 16) + (k << 8) + l;
  273. }
  274.  
  275. public static void drawShadedTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int hsl1, int hsl2, int hsl3, float z_a, float z_b, float z_c) {
  276. if (z_a < 0 || z_b < 0 || z_c < 0)
  277. return;
  278. int a_to_b = 0;
  279. int k2 = 0;
  280. if (y_b != y_a) {
  281. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  282. k2 = (hsl2 - hsl1 << 15) / (y_b - y_a);
  283. }
  284. int b_to_c = 0;
  285. int i3 = 0;
  286. if (y_c != y_b) {
  287. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  288. i3 = (hsl3 - hsl2 << 15) / (y_c - y_b);
  289. }
  290. int c_to_a = 0;
  291. int k3 = 0;
  292. if (y_c != y_a) {
  293. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  294. k3 = (hsl1 - hsl3 << 15) / (y_a - y_c);
  295. }
  296. float b_aX = x_b - x_a;
  297. float b_aY = y_b - y_a;
  298. float c_aX = x_c - x_a;
  299. float c_aY = y_c - y_a;
  300. float b_aZ = z_b - z_a;
  301. float c_aZ = z_c - z_a;
  302.  
  303. float div = b_aX * c_aY - c_aX * b_aY;
  304. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  305. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  306. if (y_a <= y_b && y_a <= y_c) {
  307. if (y_a >= DrawingArea.bottomY)
  308. return;
  309. if (y_b > DrawingArea.bottomY)
  310. y_b = DrawingArea.bottomY;
  311. if (y_c > DrawingArea.bottomY)
  312. y_c = DrawingArea.bottomY;
  313. z_a = z_a - depth_slope * x_a + depth_slope;
  314. if (y_b < y_c) {
  315. x_c = x_a <<= 16;
  316. hsl3 = hsl1 <<= 15;
  317. if (y_a < 0) {
  318. x_c -= c_to_a * y_a;
  319. x_a -= a_to_b * y_a;
  320. hsl3 -= k3 * y_a;
  321. hsl1 -= k2 * y_a;
  322. z_a -= depth_increment * y_a;
  323. y_a = 0;
  324. }
  325. x_b <<= 16;
  326. hsl2 <<= 15;
  327. if (y_b < 0) {
  328. x_b -= b_to_c * y_b;
  329. hsl2 -= i3 * y_b;
  330. y_b = 0;
  331. }
  332. if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  333. y_c -= y_b;
  334. y_b -= y_a;
  335. for (y_a = anIntArray1472[y_a]; --y_b >= 0; y_a += DrawingArea.width) {
  336. drawShadedScanline(DrawingArea.pixels, y_a, x_c >> 16, x_a >> 16, hsl3 >> 7, hsl1 >> 7, z_a, depth_slope);
  337. x_c += c_to_a;
  338. x_a += a_to_b;
  339. hsl3 += k3;
  340. hsl1 += k2;
  341. z_a += depth_increment;
  342. }
  343.  
  344. while (--y_c >= 0) {
  345. drawShadedScanline(DrawingArea.pixels, y_a, x_c >> 16, x_b >> 16, hsl3 >> 7, hsl2 >> 7, z_a, depth_slope);
  346. x_c += c_to_a;
  347. x_b += b_to_c;
  348. hsl3 += k3;
  349. hsl2 += i3;
  350. y_a += DrawingArea.width;
  351. z_a += depth_increment;
  352. }
  353. return;
  354. }
  355. y_c -= y_b;
  356. y_b -= y_a;
  357. for (y_a = anIntArray1472[y_a]; --y_b >= 0; y_a += DrawingArea.width) {
  358. drawShadedScanline(DrawingArea.pixels, y_a, x_a >> 16, x_c >> 16, hsl1 >> 7, hsl3 >> 7, z_a, depth_slope);
  359. x_c += c_to_a;
  360. x_a += a_to_b;
  361. hsl3 += k3;
  362. hsl1 += k2;
  363. z_a += depth_increment;
  364. }
  365.  
  366. while (--y_c >= 0) {
  367. drawShadedScanline(DrawingArea.pixels, y_a, x_b >> 16, x_c >> 16, hsl2 >> 7, hsl3 >> 7, z_a, depth_slope);
  368. x_c += c_to_a;
  369. x_b += b_to_c;
  370. hsl3 += k3;
  371. hsl2 += i3;
  372. y_a += DrawingArea.width;
  373. z_a += depth_increment;
  374. }
  375. return;
  376. }
  377. x_b = x_a <<= 16;
  378. hsl2 = hsl1 <<= 15;
  379. if (y_a < 0) {
  380. x_b -= c_to_a * y_a;
  381. x_a -= a_to_b * y_a;
  382. hsl2 -= k3 * y_a;
  383. hsl1 -= k2 * y_a;
  384. z_a -= depth_increment * y_a;
  385. y_a = 0;
  386. }
  387. x_c <<= 16;
  388. hsl3 <<= 15;
  389. if (y_c < 0) {
  390. x_c -= b_to_c * y_c;
  391. hsl3 -= i3 * y_c;
  392. y_c = 0;
  393. }
  394. if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  395. y_b -= y_c;
  396. y_c -= y_a;
  397. for (y_a = anIntArray1472[y_a]; --y_c >= 0; y_a += DrawingArea.width) {
  398. drawShadedScanline(DrawingArea.pixels, y_a, x_b >> 16, x_a >> 16, hsl2 >> 7, hsl1 >> 7, z_a, depth_slope);
  399. x_b += c_to_a;
  400. x_a += a_to_b;
  401. hsl2 += k3;
  402. hsl1 += k2;
  403. z_a += depth_increment;
  404. }
  405.  
  406. while (--y_b >= 0) {
  407. drawShadedScanline(DrawingArea.pixels, y_a, x_c >> 16, x_a >> 16, hsl3 >> 7, hsl1 >> 7, z_a, depth_slope);
  408. x_c += b_to_c;
  409. x_a += a_to_b;
  410. hsl3 += i3;
  411. hsl1 += k2;
  412. y_a += DrawingArea.width;
  413. z_a += depth_increment;
  414. }
  415. return;
  416. }
  417. y_b -= y_c;
  418. y_c -= y_a;
  419. for (y_a = anIntArray1472[y_a]; --y_c >= 0; y_a += DrawingArea.width) {
  420. drawShadedScanline(DrawingArea.pixels, y_a, x_a >> 16, x_b >> 16, hsl1 >> 7, hsl2 >> 7, z_a, depth_slope);
  421. x_b += c_to_a;
  422. x_a += a_to_b;
  423. hsl2 += k3;
  424. hsl1 += k2;
  425. z_a += depth_increment;
  426. }
  427.  
  428. while (--y_b >= 0) {
  429. drawShadedScanline(DrawingArea.pixels, y_a, x_a >> 16, x_c >> 16, hsl1 >> 7, hsl3 >> 7, z_a, depth_slope);
  430. x_c += b_to_c;
  431. x_a += a_to_b;
  432. hsl3 += i3;
  433. hsl1 += k2;
  434. y_a += DrawingArea.width;
  435. z_a += depth_increment;
  436. }
  437. return;
  438. }
  439. if (y_b <= y_c) {
  440. if (y_b >= DrawingArea.bottomY)
  441. return;
  442. if (y_c > DrawingArea.bottomY)
  443. y_c = DrawingArea.bottomY;
  444. if (y_a > DrawingArea.bottomY)
  445. y_a = DrawingArea.bottomY;
  446. z_b = z_b - depth_slope * x_b + depth_slope;
  447. if (y_c < y_a) {
  448. x_a = x_b <<= 16;
  449. hsl1 = hsl2 <<= 15;
  450. if (y_b < 0) {
  451. x_a -= a_to_b * y_b;
  452. x_b -= b_to_c * y_b;
  453. hsl1 -= k2 * y_b;
  454. hsl2 -= i3 * y_b;
  455. z_b -= depth_increment * y_b;
  456. y_b = 0;
  457. }
  458. x_c <<= 16;
  459. hsl3 <<= 15;
  460. if (y_c < 0) {
  461. x_c -= c_to_a * y_c;
  462. hsl3 -= k3 * y_c;
  463. y_c = 0;
  464. }
  465. if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  466. y_a -= y_c;
  467. y_c -= y_b;
  468. for (y_b = anIntArray1472[y_b]; --y_c >= 0; y_b += DrawingArea.width) {
  469. drawShadedScanline(DrawingArea.pixels, y_b, x_a >> 16, x_b >> 16, hsl1 >> 7, hsl2 >> 7, z_b, depth_slope);
  470. x_a += a_to_b;
  471. x_b += b_to_c;
  472. hsl1 += k2;
  473. hsl2 += i3;
  474. z_b += depth_increment;
  475. }
  476.  
  477. while (--y_a >= 0) {
  478. drawShadedScanline(DrawingArea.pixels, y_b, x_a >> 16, x_c >> 16, hsl1 >> 7, hsl3 >> 7, z_b, depth_slope);
  479. x_a += a_to_b;
  480. x_c += c_to_a;
  481. hsl1 += k2;
  482. hsl3 += k3;
  483. y_b += DrawingArea.width;
  484. z_b += depth_increment;
  485. }
  486. return;
  487. }
  488. y_a -= y_c;
  489. y_c -= y_b;
  490. for (y_b = anIntArray1472[y_b]; --y_c >= 0; y_b += DrawingArea.width) {
  491. drawShadedScanline(DrawingArea.pixels, y_b, x_b >> 16, x_a >> 16, hsl2 >> 7, hsl1 >> 7, z_b, depth_slope);
  492. x_a += a_to_b;
  493. x_b += b_to_c;
  494. hsl1 += k2;
  495. hsl2 += i3;
  496. z_b += depth_increment;
  497. }
  498.  
  499. while (--y_a >= 0) {
  500. drawShadedScanline(DrawingArea.pixels, y_b, x_c >> 16, x_a >> 16, hsl3 >> 7, hsl1 >> 7, z_b, depth_slope);
  501. x_a += a_to_b;
  502. x_c += c_to_a;
  503. hsl1 += k2;
  504. hsl3 += k3;
  505. y_b += DrawingArea.width;
  506. z_b += depth_increment;
  507. }
  508. return;
  509. }
  510. x_c = x_b <<= 16;
  511. hsl3 = hsl2 <<= 15;
  512. if (y_b < 0) {
  513. x_c -= a_to_b * y_b;
  514. x_b -= b_to_c * y_b;
  515. hsl3 -= k2 * y_b;
  516. hsl2 -= i3 * y_b;
  517. z_b -= depth_increment * y_b;
  518. y_b = 0;
  519. }
  520. x_a <<= 16;
  521. hsl1 <<= 15;
  522. if (y_a < 0) {
  523. x_a -= c_to_a * y_a;
  524. hsl1 -= k3 * y_a;
  525. y_a = 0;
  526. }
  527. if (a_to_b < b_to_c) {
  528. y_c -= y_a;
  529. y_a -= y_b;
  530. for (y_b = anIntArray1472[y_b]; --y_a >= 0; y_b += DrawingArea.width) {
  531. drawShadedScanline(DrawingArea.pixels, y_b, x_c >> 16, x_b >> 16, hsl3 >> 7, hsl2 >> 7, z_b, depth_slope);
  532. x_c += a_to_b;
  533. x_b += b_to_c;
  534. hsl3 += k2;
  535. hsl2 += i3;
  536. z_b += depth_increment;
  537. }
  538.  
  539. while (--y_c >= 0) {
  540. drawShadedScanline(DrawingArea.pixels, y_b, x_a >> 16, x_b >> 16, hsl1 >> 7, hsl2 >> 7, z_b, depth_slope);
  541. x_a += c_to_a;
  542. x_b += b_to_c;
  543. hsl1 += k3;
  544. hsl2 += i3;
  545. y_b += DrawingArea.width;
  546. z_b += depth_increment;
  547. }
  548. return;
  549. }
  550. y_c -= y_a;
  551. y_a -= y_b;
  552. for (y_b = anIntArray1472[y_b]; --y_a >= 0; y_b += DrawingArea.width) {
  553. drawShadedScanline(DrawingArea.pixels, y_b, x_b >> 16, x_c >> 16, hsl2 >> 7, hsl3 >> 7, z_b, depth_slope);
  554. x_c += a_to_b;
  555. x_b += b_to_c;
  556. hsl3 += k2;
  557. hsl2 += i3;
  558. z_b += depth_increment;
  559. }
  560.  
  561. while (--y_c >= 0) {
  562. drawShadedScanline(DrawingArea.pixels, y_b, x_b >> 16, x_a >> 16, hsl2 >> 7, hsl1 >> 7, z_b, depth_slope);
  563. x_a += c_to_a;
  564. x_b += b_to_c;
  565. hsl1 += k3;
  566. hsl2 += i3;
  567. y_b += DrawingArea.width;
  568. z_b += depth_increment;
  569. }
  570. return;
  571. }
  572. if (y_c >= DrawingArea.bottomY)
  573. return;
  574. if (y_a > DrawingArea.bottomY)
  575. y_a = DrawingArea.bottomY;
  576. if (y_b > DrawingArea.bottomY)
  577. y_b = DrawingArea.bottomY;
  578. z_c = z_c - depth_slope * x_c + depth_slope;
  579. if (y_a < y_b) {
  580. x_b = x_c <<= 16;
  581. hsl2 = hsl3 <<= 15;
  582. if (y_c < 0) {
  583. x_b -= b_to_c * y_c;
  584. x_c -= c_to_a * y_c;
  585. hsl2 -= i3 * y_c;
  586. hsl3 -= k3 * y_c;
  587. z_c -= depth_increment * y_c;
  588. y_c = 0;
  589. }
  590. x_a <<= 16;
  591. hsl1 <<= 15;
  592. if (y_a < 0) {
  593. x_a -= a_to_b * y_a;
  594. hsl1 -= k2 * y_a;
  595. y_a = 0;
  596. }
  597. if (b_to_c < c_to_a) {
  598. y_b -= y_a;
  599. y_a -= y_c;
  600. for (y_c = anIntArray1472[y_c]; --y_a >= 0; y_c += DrawingArea.width) {
  601. drawShadedScanline(DrawingArea.pixels, y_c, x_b >> 16, x_c >> 16, hsl2 >> 7, hsl3 >> 7, z_c, depth_slope);
  602. x_b += b_to_c;
  603. x_c += c_to_a;
  604. hsl2 += i3;
  605. hsl3 += k3;
  606. z_c += depth_increment;
  607. }
  608.  
  609. while (--y_b >= 0) {
  610. drawShadedScanline(DrawingArea.pixels, y_c, x_b >> 16, x_a >> 16, hsl2 >> 7, hsl1 >> 7, z_c, depth_slope);
  611. x_b += b_to_c;
  612. x_a += a_to_b;
  613. hsl2 += i3;
  614. hsl1 += k2;
  615. y_c += DrawingArea.width;
  616. z_c += depth_increment;
  617. }
  618. return;
  619. }
  620. y_b -= y_a;
  621. y_a -= y_c;
  622. for (y_c = anIntArray1472[y_c]; --y_a >= 0; y_c += DrawingArea.width) {
  623. drawShadedScanline(DrawingArea.pixels, y_c, x_c >> 16, x_b >> 16, hsl3 >> 7, hsl2 >> 7, z_c, depth_slope);
  624. x_b += b_to_c;
  625. x_c += c_to_a;
  626. hsl2 += i3;
  627. hsl3 += k3;
  628. z_c += depth_increment;
  629. }
  630.  
  631. while (--y_b >= 0) {
  632. drawShadedScanline(DrawingArea.pixels, y_c, x_a >> 16, x_b >> 16, hsl1 >> 7, hsl2 >> 7, z_c, depth_slope);
  633. x_b += b_to_c;
  634. x_a += a_to_b;
  635. hsl2 += i3;
  636. hsl1 += k2;
  637. z_c += depth_increment;
  638. y_c += DrawingArea.width;
  639. }
  640. return;
  641. }
  642. x_a = x_c <<= 16;
  643. hsl1 = hsl3 <<= 15;
  644. if (y_c < 0) {
  645. x_a -= b_to_c * y_c;
  646. x_c -= c_to_a * y_c;
  647. hsl1 -= i3 * y_c;
  648. hsl3 -= k3 * y_c;
  649. z_c -= depth_increment * y_c;
  650. y_c = 0;
  651. }
  652. x_b <<= 16;
  653. hsl2 <<= 15;
  654. if (y_b < 0) {
  655. x_b -= a_to_b * y_b;
  656. hsl2 -= k2 * y_b;
  657. y_b = 0;
  658. }
  659. if (b_to_c < c_to_a) {
  660. y_a -= y_b;
  661. y_b -= y_c;
  662. for (y_c = anIntArray1472[y_c]; --y_b >= 0; y_c += DrawingArea.width) {
  663. drawShadedScanline(DrawingArea.pixels, y_c, x_a >> 16, x_c >> 16, hsl1 >> 7, hsl3 >> 7, z_c, depth_slope);
  664. x_a += b_to_c;
  665. x_c += c_to_a;
  666. hsl1 += i3;
  667. hsl3 += k3;
  668. z_c += depth_increment;
  669. }
  670.  
  671. while (--y_a >= 0) {
  672. drawShadedScanline(DrawingArea.pixels, y_c, x_b >> 16, x_c >> 16, hsl2 >> 7, hsl3 >> 7, z_c, depth_slope);
  673. x_b += a_to_b;
  674. x_c += c_to_a;
  675. hsl2 += k2;
  676. hsl3 += k3;
  677. z_c += depth_increment;
  678. y_c += DrawingArea.width;
  679. }
  680. return;
  681. }
  682. y_a -= y_b;
  683. y_b -= y_c;
  684. for (y_c = anIntArray1472[y_c]; --y_b >= 0; y_c += DrawingArea.width) {
  685. drawShadedScanline(DrawingArea.pixels, y_c, x_c >> 16, x_a >> 16, hsl3 >> 7, hsl1 >> 7, z_c, depth_slope);
  686. x_a += b_to_c;
  687. x_c += c_to_a;
  688. hsl1 += i3;
  689. hsl3 += k3;
  690. z_c += depth_increment;
  691. }
  692.  
  693. while (--y_a >= 0) {
  694. drawShadedScanline(DrawingArea.pixels, y_c, x_c >> 16, x_b >> 16, hsl3 >> 7, hsl2 >> 7, z_c, depth_slope);
  695. x_b += a_to_b;
  696. x_c += c_to_a;
  697. hsl2 += k2;
  698. hsl3 += k3;
  699. y_c += DrawingArea.width;
  700. z_c += depth_increment;
  701. }
  702. }
  703.  
  704. public static void drawShadedScanline(int[] dest, int offset, int x1, int x2, int j1, int k1, float depth, float depth_slope) {
  705. int j;
  706. int k;
  707. int l1 = 0;
  708. if (aBoolean1462) {
  709. if (x2 > DrawingArea.centerX)
  710. x2 = DrawingArea.centerX;
  711. if (x1 < 0) {
  712. j1 -= x1 * l1;
  713. x1 = 0;
  714. }
  715. }
  716. if (x1 < x2) {
  717. offset += x1;
  718. j1 += l1 * x1;
  719. if (aBoolean1464) {
  720. k = x2 - x1 >> 2;
  721. if (k > 0)
  722. l1 = (k1 - j1) * anIntArray1468[k] >> 15;
  723. else
  724. l1 = 0;
  725. if (anInt1465 == 0) {
  726. if (k > 0) {
  727. do {
  728. j = anIntArray1482[j1 >> 8];
  729. j1 += l1;
  730. dest[offset] = j;
  731. offset++;
  732. dest[offset] = j;
  733. offset++;
  734. dest[offset] = j;
  735. offset++;
  736. dest[offset] = j;
  737. offset++;
  738. } while (--k > 0);
  739. }
  740. k = x2 - x1 & 0x3;
  741. if (k > 0) {
  742. j = anIntArray1482[j1 >> 8];
  743. do
  744. dest[offset++] = j;
  745. while (--k > 0);
  746. }
  747. } else {
  748. int j2 = anInt1465;
  749. int l2 = 256 - anInt1465;
  750. if (k > 0) {
  751. do {
  752. j = anIntArray1482[j1 >> 8];
  753. j1 += l1;
  754. j = (((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00)
  755. * l2 >> 8 & 0xff00));
  756. int h = dest[offset];
  757. dest[offset] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
  758. * j2 >> 8 & 0xff00));
  759. offset++;
  760. h = dest[offset];
  761. dest[offset] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
  762. * j2 >> 8 & 0xff00));
  763. offset++;
  764. h = dest[offset];
  765. dest[offset] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
  766. * j2 >> 8 & 0xff00));
  767. offset++;
  768. h = dest[offset];
  769. dest[offset] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00)
  770. * j2 >> 8 & 0xff00));
  771. offset++;
  772. } while (--k > 0);
  773. }
  774. k = x2 - x1 & 0x3;
  775. if (k > 0) {
  776. j = anIntArray1482[j1 >> 8];
  777. j = (((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00)
  778. * l2 >> 8 & 0xff00));
  779. do {
  780. int i_61_ = dest[offset];
  781. dest[offset] = (j
  782. + ((i_61_ & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((i_61_ & 0xff00)
  783. * j2 >> 8 & 0xff00));
  784. offset++;
  785. } while (--k > 0);
  786. }
  787. }
  788. } else {
  789. int i2 = (k1 - j1) / (x2 - x1);
  790. k = x2 - x1;
  791. depth += depth_slope * (float) x1;
  792. if (anInt1465 == 0) {
  793. do {
  794. dest[offset] = anIntArray1482[j1 >> 8];
  795. DrawingArea.depthBuffer[offset] = depth;
  796. depth += depth_slope;
  797. offset++;
  798. j1 += i2;
  799. } while (--k > 0);
  800. } else {
  801. int i_62_ = anInt1465;
  802. int i_63_ = 256 - anInt1465;
  803. do {
  804. j = anIntArray1482[j1 >> 8];
  805. j1 += i2;
  806. j = (((j & 0xff00ff) * i_63_ >> 8 & 0xff00ff) + ((j & 0xff00) * i_63_ >> 8 & 0xff00));
  807. int i_64_ = dest[offset];
  808. dest[offset] = (j + ((i_64_ & 0xff00ff) * i_62_ >> 8 & 0xff00ff) + ((i_64_ & 0xff00) * i_62_ >> 8 & 0xff00));
  809. DrawingArea.depthBuffer[offset] = depth;
  810. depth += depth_slope;
  811. offset++;
  812. } while (--k > 0);
  813. }
  814. }
  815. }
  816. }
  817.  
  818. public static void drawFlatTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int k1, float z_a, float z_b, float z_c) {
  819. if (z_a < 0 || z_b < 0 || z_c < 0) {
  820. return;
  821. }
  822. int a_to_b = 0;
  823. if (y_b != y_a)
  824. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  825. int b_to_c = 0;
  826. if (y_c != y_b)
  827. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  828. int c_to_a = 0;
  829. if (y_c != y_a)
  830. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  831. float b_aX = x_b - x_a;
  832. float b_aY = y_b - y_a;
  833. float c_aX = x_c - x_a;
  834. float c_aY = y_c - y_a;
  835. float b_aZ = z_b - z_a;
  836. float c_aZ = z_c - z_a;
  837.  
  838. float div = b_aX * c_aY - c_aX * b_aY;
  839. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  840. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  841. if (y_a <= y_b && y_a <= y_c) {
  842. if (y_a >= DrawingArea.bottomY)
  843. return;
  844. if (y_b > DrawingArea.bottomY)
  845. y_b = DrawingArea.bottomY;
  846. if (y_c > DrawingArea.bottomY)
  847. y_c = DrawingArea.bottomY;
  848. z_a = z_a - depth_slope * x_a + depth_slope;
  849. if (y_b < y_c) {
  850. x_c = x_a <<= 16;
  851. if (y_a < 0) {
  852. x_c -= c_to_a * y_a;
  853. x_a -= a_to_b * y_a;
  854. z_a -= depth_increment * y_a;
  855. y_a = 0;
  856. }
  857. x_b <<= 16;
  858. if (y_b < 0) {
  859. x_b -= b_to_c * y_b;
  860. y_b = 0;
  861. }
  862. if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  863. y_c -= y_b;
  864. y_b -= y_a;
  865. for (y_a = anIntArray1472[y_a]; --y_b >= 0; y_a += DrawingArea.width) {
  866. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_c >> 16, x_a >> 16, z_a, depth_slope);
  867. x_c += c_to_a;
  868. x_a += a_to_b;
  869. z_a += depth_increment;
  870. }
  871.  
  872. while (--y_c >= 0) {
  873. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_c >> 16, x_b >> 16, z_a, depth_slope);
  874. x_c += c_to_a;
  875. x_b += b_to_c;
  876. y_a += DrawingArea.width;
  877. z_a += depth_increment;
  878. }
  879. return;
  880. }
  881. y_c -= y_b;
  882. y_b -= y_a;
  883. for (y_a = anIntArray1472[y_a]; --y_b >= 0; y_a += DrawingArea.width) {
  884. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_a >> 16, x_c >> 16, z_a, depth_slope);
  885. x_c += c_to_a;
  886. x_a += a_to_b;
  887. z_a += depth_increment;
  888. }
  889.  
  890. while (--y_c >= 0) {
  891. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_b >> 16, x_c >> 16, z_a, depth_slope);
  892. x_c += c_to_a;
  893. x_b += b_to_c;
  894. y_a += DrawingArea.width;
  895. z_a += depth_increment;
  896. }
  897. return;
  898. }
  899. x_b = x_a <<= 16;
  900. if (y_a < 0) {
  901. x_b -= c_to_a * y_a;
  902. x_a -= a_to_b * y_a;
  903. z_a -= depth_increment * y_a;
  904. y_a = 0;
  905. }
  906. x_c <<= 16;
  907. if (y_c < 0) {
  908. x_c -= b_to_c * y_c;
  909. y_c = 0;
  910. }
  911. if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  912. y_b -= y_c;
  913. y_c -= y_a;
  914. for (y_a = anIntArray1472[y_a]; --y_c >= 0; y_a += DrawingArea.width) {
  915. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_b >> 16, x_a >> 16, z_a, depth_slope);
  916. z_a += depth_increment;
  917. x_b += c_to_a;
  918. x_a += a_to_b;
  919. }
  920.  
  921. while (--y_b >= 0) {
  922. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_c >> 16, x_a >> 16, z_a, depth_slope);
  923. z_a += depth_increment;
  924. x_c += b_to_c;
  925. x_a += a_to_b;
  926. y_a += DrawingArea.width;
  927. }
  928. return;
  929. }
  930. y_b -= y_c;
  931. y_c -= y_a;
  932. for (y_a = anIntArray1472[y_a]; --y_c >= 0; y_a += DrawingArea.width) {
  933. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_a >> 16, x_b >> 16, z_a, depth_slope);
  934. z_a += depth_increment;
  935. x_b += c_to_a;
  936. x_a += a_to_b;
  937. }
  938.  
  939. while (--y_b >= 0) {
  940. drawFlatTexturedScanline(DrawingArea.pixels, y_a, k1, x_a >> 16, x_c >> 16, z_a, depth_slope);
  941. z_a += depth_increment;
  942. x_c += b_to_c;
  943. x_a += a_to_b;
  944. y_a += DrawingArea.width;
  945. }
  946. return;
  947. }
  948. if (y_b <= y_c) {
  949. if (y_b >= DrawingArea.bottomY)
  950. return;
  951. if (y_c > DrawingArea.bottomY)
  952. y_c = DrawingArea.bottomY;
  953. if (y_a > DrawingArea.bottomY)
  954. y_a = DrawingArea.bottomY;
  955. z_b = z_b - depth_slope * x_b + depth_slope;
  956. if (y_c < y_a) {
  957. x_a = x_b <<= 16;
  958. if (y_b < 0) {
  959. x_a -= a_to_b * y_b;
  960. x_b -= b_to_c * y_b;
  961. z_b -= depth_increment * y_b;
  962. y_b = 0;
  963. }
  964. x_c <<= 16;
  965. if (y_c < 0) {
  966. x_c -= c_to_a * y_c;
  967. y_c = 0;
  968. }
  969. if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  970. y_a -= y_c;
  971. y_c -= y_b;
  972. for (y_b = anIntArray1472[y_b]; --y_c >= 0; y_b += DrawingArea.width) {
  973. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_a >> 16, x_b >> 16, z_b, depth_slope);
  974. z_b += depth_increment;
  975. x_a += a_to_b;
  976. x_b += b_to_c;
  977. }
  978.  
  979. while (--y_a >= 0) {
  980. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_a >> 16, x_c >> 16, z_b, depth_slope);
  981. z_b += depth_increment;
  982. x_a += a_to_b;
  983. x_c += c_to_a;
  984. y_b += DrawingArea.width;
  985. }
  986. return;
  987. }
  988. y_a -= y_c;
  989. y_c -= y_b;
  990. for (y_b = anIntArray1472[y_b]; --y_c >= 0; y_b += DrawingArea.width) {
  991. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_b >> 16, x_a >> 16, z_b, depth_slope);
  992. z_b += depth_increment;
  993. x_a += a_to_b;
  994. x_b += b_to_c;
  995. }
  996.  
  997. while (--y_a >= 0) {
  998. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_c >> 16, x_a >> 16, z_b, depth_slope);
  999. z_b += depth_increment;
  1000. x_a += a_to_b;
  1001. x_c += c_to_a;
  1002. y_b += DrawingArea.width;
  1003. }
  1004. return;
  1005. }
  1006. x_c = x_b <<= 16;
  1007. if (y_b < 0) {
  1008. x_c -= a_to_b * y_b;
  1009. x_b -= b_to_c * y_b;
  1010. z_b -= depth_increment * y_b;
  1011. y_b = 0;
  1012. }
  1013. x_a <<= 16;
  1014. if (y_a < 0) {
  1015. x_a -= c_to_a * y_a;
  1016. y_a = 0;
  1017. }
  1018. if (a_to_b < b_to_c) {
  1019. y_c -= y_a;
  1020. y_a -= y_b;
  1021. for (y_b = anIntArray1472[y_b]; --y_a >= 0; y_b += DrawingArea.width) {
  1022. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_c >> 16, x_b >> 16, z_b, depth_slope);
  1023. z_b += depth_increment;
  1024. x_c += a_to_b;
  1025. x_b += b_to_c;
  1026. }
  1027.  
  1028. while (--y_c >= 0) {
  1029. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_a >> 16, x_b >> 16, z_b, depth_slope);
  1030. z_b += depth_increment;
  1031. x_a += c_to_a;
  1032. x_b += b_to_c;
  1033. y_b += DrawingArea.width;
  1034. }
  1035. return;
  1036. }
  1037. y_c -= y_a;
  1038. y_a -= y_b;
  1039. for (y_b = anIntArray1472[y_b]; --y_a >= 0; y_b += DrawingArea.width) {
  1040. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_b >> 16, x_c >> 16, z_b, depth_slope);
  1041. z_b += depth_increment;
  1042. x_c += a_to_b;
  1043. x_b += b_to_c;
  1044. }
  1045.  
  1046. while (--y_c >= 0) {
  1047. drawFlatTexturedScanline(DrawingArea.pixels, y_b, k1, x_b >> 16, x_a >> 16, z_b, depth_slope);
  1048. z_b += depth_increment;
  1049. x_a += c_to_a;
  1050. x_b += b_to_c;
  1051. y_b += DrawingArea.width;
  1052. }
  1053. return;
  1054. }
  1055. if (y_c >= DrawingArea.bottomY)
  1056. return;
  1057. if (y_a > DrawingArea.bottomY)
  1058. y_a = DrawingArea.bottomY;
  1059. if (y_b > DrawingArea.bottomY)
  1060. y_b = DrawingArea.bottomY;
  1061. z_c = z_c - depth_slope * x_c + depth_slope;
  1062. if (y_a < y_b) {
  1063. x_b = x_c <<= 16;
  1064. if (y_c < 0) {
  1065. x_b -= b_to_c * y_c;
  1066. x_c -= c_to_a * y_c;
  1067. z_c -= depth_increment * y_c;
  1068. y_c = 0;
  1069. }
  1070. x_a <<= 16;
  1071. if (y_a < 0) {
  1072. x_a -= a_to_b * y_a;
  1073. y_a = 0;
  1074. }
  1075. if (b_to_c < c_to_a) {
  1076. y_b -= y_a;
  1077. y_a -= y_c;
  1078. for (y_c = anIntArray1472[y_c]; --y_a >= 0; y_c += DrawingArea.width) {
  1079. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_b >> 16, x_c >> 16, z_c, depth_slope);
  1080. z_c += depth_increment;
  1081. x_b += b_to_c;
  1082. x_c += c_to_a;
  1083. }
  1084.  
  1085. while (--y_b >= 0) {
  1086. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_b >> 16, x_a >> 16, z_c, depth_slope);
  1087. z_c += depth_increment;
  1088. x_b += b_to_c;
  1089. x_a += a_to_b;
  1090. y_c += DrawingArea.width;
  1091. }
  1092. return;
  1093. }
  1094. y_b -= y_a;
  1095. y_a -= y_c;
  1096. for (y_c = anIntArray1472[y_c]; --y_a >= 0; y_c += DrawingArea.width) {
  1097. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_c >> 16, x_b >> 16, z_c, depth_slope);
  1098. z_c += depth_increment;
  1099. x_b += b_to_c;
  1100. x_c += c_to_a;
  1101. }
  1102.  
  1103. while (--y_b >= 0) {
  1104. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_a >> 16, x_b >> 16, z_c, depth_slope);
  1105. z_c += depth_increment;
  1106. x_b += b_to_c;
  1107. x_a += a_to_b;
  1108. y_c += DrawingArea.width;
  1109. }
  1110. return;
  1111. }
  1112. x_a = x_c <<= 16;
  1113. if (y_c < 0) {
  1114. x_a -= b_to_c * y_c;
  1115. x_c -= c_to_a * y_c;
  1116. z_c -= depth_increment * y_c;
  1117. y_c = 0;
  1118. }
  1119. x_b <<= 16;
  1120. if (y_b < 0) {
  1121. x_b -= a_to_b * y_b;
  1122. y_b = 0;
  1123. }
  1124. if (b_to_c < c_to_a) {
  1125. y_a -= y_b;
  1126. y_b -= y_c;
  1127. for (y_c = anIntArray1472[y_c]; --y_b >= 0; y_c += DrawingArea.width) {
  1128. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_a >> 16, x_c >> 16, z_c, depth_slope);
  1129. z_c += depth_increment;
  1130. x_a += b_to_c;
  1131. x_c += c_to_a;
  1132. }
  1133.  
  1134. while (--y_a >= 0) {
  1135. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_b >> 16, x_c >> 16, z_c, depth_slope);
  1136. z_c += depth_increment;
  1137. x_b += a_to_b;
  1138. x_c += c_to_a;
  1139. y_c += DrawingArea.width;
  1140. }
  1141. return;
  1142. }
  1143. y_a -= y_b;
  1144. y_b -= y_c;
  1145. for (y_c = anIntArray1472[y_c]; --y_b >= 0; y_c += DrawingArea.width) {
  1146. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_c >> 16, x_a >> 16, z_c, depth_slope);
  1147. z_c += depth_increment;
  1148. x_a += b_to_c;
  1149. x_c += c_to_a;
  1150. }
  1151.  
  1152. while (--y_a >= 0) {
  1153. drawFlatTexturedScanline(DrawingArea.pixels, y_c, k1, x_c >> 16, x_b >> 16, z_c, depth_slope);
  1154. z_c += depth_increment;
  1155. x_b += a_to_b;
  1156. x_c += c_to_a;
  1157. y_c += DrawingArea.width;
  1158. }
  1159. }
  1160.  
  1161. private static void drawFlatTexturedScanline(int dest[], int dest_off, int loops, int start_x, int end_x, float depth, float depth_slope) {
  1162. int rgb;// was parameter
  1163. if (aBoolean1462) {
  1164. if (end_x > DrawingArea.centerX)
  1165. end_x = DrawingArea.centerX;
  1166. if (start_x < 0)
  1167. start_x = 0;
  1168. }
  1169. if (start_x >= end_x)
  1170. return;
  1171. dest_off += start_x;
  1172. rgb = end_x - start_x >> 2;
  1173. depth += depth_slope * (float) start_x;
  1174. if (anInt1465 == 0) {
  1175. while (--rgb >= 0) {
  1176. for (int i = 0; i < 4; i++) {
  1177. dest[dest_off] = loops;
  1178. DrawingArea.depthBuffer[dest_off] = depth;
  1179. dest_off++;
  1180. depth += depth_slope;
  1181. }
  1182. }
  1183. for (rgb = end_x - start_x & 3; --rgb >= 0;) {
  1184. dest[dest_off] = loops;
  1185. DrawingArea.depthBuffer[dest_off] = depth;
  1186. dest_off++;
  1187. depth += depth_slope;
  1188. }
  1189. return;
  1190. }
  1191. int dest_alpha = anInt1465;
  1192. int src_alpha = 256 - anInt1465;
  1193. loops = ((loops & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
  1194. + ((loops & 0xff00) * src_alpha >> 8 & 0xff00);
  1195. while (--rgb >= 0) {
  1196. for (int i = 0; i < 4; i++) {
  1197. dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
  1198. DrawingArea.depthBuffer[dest_off] = depth;
  1199. dest_off++;
  1200. depth += depth_slope;
  1201. }
  1202. }
  1203. for (rgb = end_x - start_x & 3; --rgb >= 0;) {
  1204. dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
  1205. DrawingArea.depthBuffer[dest_off] = depth;
  1206. dest_off++;
  1207. depth += depth_slope;
  1208. }
  1209.  
  1210. }
  1211.  
  1212. public static void drawTexturedTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c,
  1213. int k1, int l1, int i2, int Px, int Mx, int Nx, int Pz, int Mz,
  1214. int Nz, int Py, int My, int Ny, int k4, float z_a, float z_b, float z_c) {
  1215. if (z_a < 0 || z_b < 0 || z_c < 0)
  1216. return;
  1217. int texture[] = getTexturePixels(k4);
  1218. aBoolean1463 = !aBooleanArray1475[k4];
  1219. Mx = Px - Mx;
  1220. Mz = Pz - Mz;
  1221. My = Py - My;
  1222. Nx -= Px;
  1223. Nz -= Pz;
  1224. Ny -= Py;
  1225. int Oa = Nx * Pz - Nz * Px << (Client.viewDistance == 9 ? 14 : 15);
  1226. int Ha = Nz * Py - Ny * Pz << 8;
  1227. int Va = Ny * Px - Nx * Py << 5;
  1228. int Ob = Mx * Pz - Mz * Px << (Client.viewDistance == 9 ? 14 : 15);
  1229. int Hb = Mz * Py - My * Pz << 8;
  1230. int Vb = My * Px - Mx * Py << 5;
  1231. int Oc = Mz * Nx - Mx * Nz << (Client.viewDistance == 9 ? 14 : 15);
  1232. int Hc = My * Nz - Mz * Ny << 8;
  1233. int Vc = Mx * Ny - My * Nx << 5;
  1234. int a_to_b = 0;
  1235. int grad_a_off = 0;
  1236. if (y_b != y_a) {
  1237. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  1238. grad_a_off = (l1 - k1 << 16) / (y_b - y_a);
  1239. }
  1240. int b_to_c = 0;
  1241. int grad_b_off = 0;
  1242. if (y_c != y_b) {
  1243. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  1244. grad_b_off = (i2 - l1 << 16) / (y_c - y_b);
  1245. }
  1246. int c_to_a = 0;
  1247. int grad_c_off = 0;
  1248. if (y_c != y_a) {
  1249. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  1250. grad_c_off = (k1 - i2 << 16) / (y_a - y_c);
  1251. }
  1252. float b_aX = x_b - x_a;
  1253. float b_aY = y_b - y_a;
  1254. float c_aX = x_c - x_a;
  1255. float c_aY = y_c - y_a;
  1256. float b_aZ = z_b - z_a;
  1257. float c_aZ = z_c - z_a;
  1258.  
  1259. float div = b_aX * c_aY - c_aX * b_aY;
  1260. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  1261. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  1262. if (y_a <= y_b && y_a <= y_c) {
  1263. if (y_a >= DrawingArea.bottomY)
  1264. return;
  1265. if (y_b > DrawingArea.bottomY)
  1266. y_b = DrawingArea.bottomY;
  1267. if (y_c > DrawingArea.bottomY)
  1268. y_c = DrawingArea.bottomY;
  1269. z_a = z_a - depth_slope * x_a + depth_slope;
  1270. if (y_b < y_c) {
  1271. x_c = x_a <<= 16;
  1272. i2 = k1 <<= 16;
  1273. if (y_a < 0) {
  1274. x_c -= c_to_a * y_a;
  1275. x_a -= a_to_b * y_a;
  1276. z_a -= depth_increment * y_a;
  1277. i2 -= grad_c_off * y_a;
  1278. k1 -= grad_a_off * y_a;
  1279. y_a = 0;
  1280. }
  1281. x_b <<= 16;
  1282. l1 <<= 16;
  1283. if (y_b < 0) {
  1284. x_b -= b_to_c * y_b;
  1285. l1 -= grad_b_off * y_b;
  1286. y_b = 0;
  1287. }
  1288. int k8 = y_a - textureInt2;
  1289. Oa += Va * k8;
  1290. Ob += Vb * k8;
  1291. Oc += Vc * k8;
  1292. if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  1293. y_c -= y_b;
  1294. y_b -= y_a;
  1295. y_a = anIntArray1472[y_a];
  1296. while (--y_b >= 0) {
  1297. method379(DrawingArea.pixels, texture, y_a, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1298. x_c += c_to_a;
  1299. x_a += a_to_b;
  1300. z_a += depth_increment;
  1301. i2 += grad_c_off;
  1302. k1 += grad_a_off;
  1303. y_a += DrawingArea.width;
  1304. Oa += Va;
  1305. Ob += Vb;
  1306. Oc += Vc;
  1307. }
  1308. while (--y_c >= 0) {
  1309. method379(DrawingArea.pixels, texture, y_a, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1310. x_c += c_to_a;
  1311. x_b += b_to_c;
  1312. z_a += depth_increment;
  1313. i2 += grad_c_off;
  1314. l1 += grad_b_off;
  1315. y_a += DrawingArea.width;
  1316. Oa += Va;
  1317. Ob += Vb;
  1318. Oc += Vc;
  1319. }
  1320. return;
  1321. }
  1322. y_c -= y_b;
  1323. y_b -= y_a;
  1324. y_a = anIntArray1472[y_a];
  1325. while (--y_b >= 0) {
  1326. method379(DrawingArea.pixels, texture, y_a, x_a >> 16, x_c >> 16,
  1327. k1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1328. x_c += c_to_a;
  1329. x_a += a_to_b;
  1330. z_a += depth_increment;
  1331. i2 += grad_c_off;
  1332. k1 += grad_a_off;
  1333. y_a += DrawingArea.width;
  1334. Oa += Va;
  1335. Ob += Vb;
  1336. Oc += Vc;
  1337. }
  1338. while (--y_c >= 0) {
  1339. method379(DrawingArea.pixels, texture, y_a, x_b >> 16, x_c >> 16,
  1340. l1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1341. x_c += c_to_a;
  1342. x_b += b_to_c;
  1343. z_a += depth_increment;
  1344. i2 += grad_c_off;
  1345. l1 += grad_b_off;
  1346. y_a += DrawingArea.width;
  1347. Oa += Va;
  1348. Ob += Vb;
  1349. Oc += Vc;
  1350. }
  1351. return;
  1352. }
  1353. x_b = x_a <<= 16;
  1354. l1 = k1 <<= 16;
  1355. if (y_a < 0) {
  1356. x_b -= c_to_a * y_a;
  1357. x_a -= a_to_b * y_a;
  1358. z_a -= depth_increment * y_a;
  1359. l1 -= grad_c_off * y_a;
  1360. k1 -= grad_a_off * y_a;
  1361. y_a = 0;
  1362. }
  1363. x_c <<= 16;
  1364. i2 <<= 16;
  1365. if (y_c < 0) {
  1366. x_c -= b_to_c * y_c;
  1367. i2 -= grad_b_off * y_c;
  1368. y_c = 0;
  1369. }
  1370. int l8 = y_a - textureInt2;
  1371. Oa += Va * l8;
  1372. Ob += Vb * l8;
  1373. Oc += Vc * l8;
  1374. if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  1375. y_b -= y_c;
  1376. y_c -= y_a;
  1377. y_a = anIntArray1472[y_a];
  1378. while (--y_c >= 0) {
  1379. method379(DrawingArea.pixels, texture, y_a, x_b >> 16, x_a >> 16,
  1380. l1 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1381. x_b += c_to_a;
  1382. x_a += a_to_b;
  1383. l1 += grad_c_off;
  1384. k1 += grad_a_off;
  1385. z_a += depth_increment;
  1386. y_a += DrawingArea.width;
  1387. Oa += Va;
  1388. Ob += Vb;
  1389. Oc += Vc;
  1390. }
  1391. while (--y_b >= 0) {
  1392. method379(DrawingArea.pixels, texture, y_a, x_c >> 16, x_a >> 16,
  1393. i2 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1394. x_c += b_to_c;
  1395. x_a += a_to_b;
  1396. i2 += grad_b_off;
  1397. k1 += grad_a_off;
  1398. z_a += depth_increment;
  1399. y_a += DrawingArea.width;
  1400. Oa += Va;
  1401. Ob += Vb;
  1402. Oc += Vc;
  1403. }
  1404. return;
  1405. }
  1406. y_b -= y_c;
  1407. y_c -= y_a;
  1408. y_a = anIntArray1472[y_a];
  1409. while (--y_c >= 0) {
  1410. method379(DrawingArea.pixels, texture, y_a, x_a >> 16, x_b >> 16,
  1411. k1 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1412. x_b += c_to_a;
  1413. x_a += a_to_b;
  1414. l1 += grad_c_off;
  1415. k1 += grad_a_off;
  1416. z_a += depth_increment;
  1417. y_a += DrawingArea.width;
  1418. Oa += Va;
  1419. Ob += Vb;
  1420. Oc += Vc;
  1421. }
  1422. while (--y_b >= 0) {
  1423. method379(DrawingArea.pixels, texture, y_a, x_a >> 16, x_c >> 16,
  1424. k1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1425. x_c += b_to_c;
  1426. x_a += a_to_b;
  1427. i2 += grad_b_off;
  1428. k1 += grad_a_off;
  1429. z_a += depth_increment;
  1430. y_a += DrawingArea.width;
  1431. Oa += Va;
  1432. Ob += Vb;
  1433. Oc += Vc;
  1434. }
  1435. return;
  1436. }
  1437. if (y_b <= y_c) {
  1438. if (y_b >= DrawingArea.bottomY)
  1439. return;
  1440. if (y_c > DrawingArea.bottomY)
  1441. y_c = DrawingArea.bottomY;
  1442. if (y_a > DrawingArea.bottomY)
  1443. y_a = DrawingArea.bottomY;
  1444. z_b = z_b - depth_slope * x_b + depth_slope;
  1445. if (y_c < y_a) {
  1446. x_a = x_b <<= 16;
  1447. k1 = l1 <<= 16;
  1448. if (y_b < 0) {
  1449. x_a -= a_to_b * y_b;
  1450. x_b -= b_to_c * y_b;
  1451. z_b -= depth_increment * y_b;
  1452. k1 -= grad_a_off * y_b;
  1453. l1 -= grad_b_off * y_b;
  1454. y_b = 0;
  1455. }
  1456. x_c <<= 16;
  1457. i2 <<= 16;
  1458. if (y_c < 0) {
  1459. x_c -= c_to_a * y_c;
  1460. i2 -= grad_c_off * y_c;
  1461. y_c = 0;
  1462. }
  1463. int i9 = y_b - textureInt2;
  1464. Oa += Va * i9;
  1465. Ob += Vb * i9;
  1466. Oc += Vc * i9;
  1467. if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  1468. y_a -= y_c;
  1469. y_c -= y_b;
  1470. y_b = anIntArray1472[y_b];
  1471. while (--y_c >= 0) {
  1472. method379(DrawingArea.pixels, texture, y_b, x_a >> 16, x_b >> 16,
  1473. k1 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1474. x_a += a_to_b;
  1475. x_b += b_to_c;
  1476. k1 += grad_a_off;
  1477. l1 += grad_b_off;
  1478. z_b += depth_increment;
  1479. y_b += DrawingArea.width;
  1480. Oa += Va;
  1481. Ob += Vb;
  1482. Oc += Vc;
  1483. }
  1484. while (--y_a >= 0) {
  1485. method379(DrawingArea.pixels, texture, y_b, x_a >> 16, x_c >> 16,
  1486. k1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1487. x_a += a_to_b;
  1488. x_c += c_to_a;
  1489. k1 += grad_a_off;
  1490. i2 += grad_c_off;
  1491. z_b += depth_increment;
  1492. y_b += DrawingArea.width;
  1493. Oa += Va;
  1494. Ob += Vb;
  1495. Oc += Vc;
  1496. }
  1497. return;
  1498. }
  1499. y_a -= y_c;
  1500. y_c -= y_b;
  1501. y_b = anIntArray1472[y_b];
  1502. while (--y_c >= 0) {
  1503. method379(DrawingArea.pixels, texture, y_b, x_b >> 16, x_a >> 16,
  1504. l1 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1505. x_a += a_to_b;
  1506. x_b += b_to_c;
  1507. k1 += grad_a_off;
  1508. l1 += grad_b_off;
  1509. z_b += depth_increment;
  1510. y_b += DrawingArea.width;
  1511. Oa += Va;
  1512. Ob += Vb;
  1513. Oc += Vc;
  1514. }
  1515. while (--y_a >= 0) {
  1516. method379(DrawingArea.pixels, texture, y_b, x_c >> 16, x_a >> 16,
  1517. i2 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1518. x_a += a_to_b;
  1519. x_c += c_to_a;
  1520. k1 += grad_a_off;
  1521. i2 += grad_c_off;
  1522. z_b += depth_increment;
  1523. y_b += DrawingArea.width;
  1524. Oa += Va;
  1525. Ob += Vb;
  1526. Oc += Vc;
  1527. }
  1528. return;
  1529. }
  1530. x_c = x_b <<= 16;
  1531. i2 = l1 <<= 16;
  1532. if (y_b < 0) {
  1533. x_c -= a_to_b * y_b;
  1534. x_b -= b_to_c * y_b;
  1535. z_b -= depth_increment * y_b;
  1536. i2 -= grad_a_off * y_b;
  1537. l1 -= grad_b_off * y_b;
  1538. y_b = 0;
  1539. }
  1540. x_a <<= 16;
  1541. k1 <<= 16;
  1542. if (y_a < 0) {
  1543. x_a -= c_to_a * y_a;
  1544. k1 -= grad_c_off * y_a;
  1545. y_a = 0;
  1546. }
  1547. int j9 = y_b - textureInt2;
  1548. Oa += Va * j9;
  1549. Ob += Vb * j9;
  1550. Oc += Vc * j9;
  1551. if (a_to_b < b_to_c) {
  1552. y_c -= y_a;
  1553. y_a -= y_b;
  1554. y_b = anIntArray1472[y_b];
  1555. while (--y_a >= 0) {
  1556. method379(DrawingArea.pixels, texture, y_b, x_c >> 16, x_b >> 16,
  1557. i2 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1558. x_c += a_to_b;
  1559. x_b += b_to_c;
  1560. i2 += grad_a_off;
  1561. l1 += grad_b_off;
  1562. z_b += depth_increment;
  1563. y_b += DrawingArea.width;
  1564. Oa += Va;
  1565. Ob += Vb;
  1566. Oc += Vc;
  1567. }
  1568. while (--y_c >= 0) {
  1569. method379(DrawingArea.pixels, texture, y_b, x_a >> 16, x_b >> 16,
  1570. k1 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1571. x_a += c_to_a;
  1572. x_b += b_to_c;
  1573. k1 += grad_c_off;
  1574. l1 += grad_b_off;
  1575. z_b += depth_increment;
  1576. y_b += DrawingArea.width;
  1577. Oa += Va;
  1578. Ob += Vb;
  1579. Oc += Vc;
  1580. }
  1581. return;
  1582. }
  1583. y_c -= y_a;
  1584. y_a -= y_b;
  1585. y_b = anIntArray1472[y_b];
  1586. while (--y_a >= 0) {
  1587. method379(DrawingArea.pixels, texture, y_b, x_b >> 16, x_c >> 16,
  1588. l1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1589. x_c += a_to_b;
  1590. x_b += b_to_c;
  1591. i2 += grad_a_off;
  1592. l1 += grad_b_off;
  1593. z_b += depth_increment;
  1594. y_b += DrawingArea.width;
  1595. Oa += Va;
  1596. Ob += Vb;
  1597. Oc += Vc;
  1598. }
  1599. while (--y_c >= 0) {
  1600. method379(DrawingArea.pixels, texture, y_b, x_b >> 16, x_a >> 16,
  1601. l1 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1602. x_a += c_to_a;
  1603. x_b += b_to_c;
  1604. k1 += grad_c_off;
  1605. l1 += grad_b_off;
  1606. z_b += depth_increment;
  1607. y_b += DrawingArea.width;
  1608. Oa += Va;
  1609. Ob += Vb;
  1610. Oc += Vc;
  1611. }
  1612. return;
  1613. }
  1614. if (y_c >= DrawingArea.bottomY)
  1615. return;
  1616. if (y_a > DrawingArea.bottomY)
  1617. y_a = DrawingArea.bottomY;
  1618. if (y_b > DrawingArea.bottomY)
  1619. y_b = DrawingArea.bottomY;
  1620. z_c = z_c - depth_slope * x_c + depth_slope;
  1621. if (y_a < y_b) {
  1622. x_b = x_c <<= 16;
  1623. l1 = i2 <<= 16;
  1624. if (y_c < 0) {
  1625. x_b -= b_to_c * y_c;
  1626. x_c -= c_to_a * y_c;
  1627. z_c -= depth_increment * y_c;
  1628. l1 -= grad_b_off * y_c;
  1629. i2 -= grad_c_off * y_c;
  1630. y_c = 0;
  1631. }
  1632. x_a <<= 16;
  1633. k1 <<= 16;
  1634. if (y_a < 0) {
  1635. x_a -= a_to_b * y_a;
  1636. k1 -= grad_a_off * y_a;
  1637. y_a = 0;
  1638. }
  1639. int k9 = y_c - textureInt2;
  1640. Oa += Va * k9;
  1641. Ob += Vb * k9;
  1642. Oc += Vc * k9;
  1643. if (b_to_c < c_to_a) {
  1644. y_b -= y_a;
  1645. y_a -= y_c;
  1646. y_c = anIntArray1472[y_c];
  1647. while (--y_a >= 0) {
  1648. method379(DrawingArea.pixels, texture, y_c, x_b >> 16, x_c >> 16,
  1649. l1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1650. x_b += b_to_c;
  1651. x_c += c_to_a;
  1652. l1 += grad_b_off;
  1653. i2 += grad_c_off;
  1654. z_c += depth_increment;
  1655. y_c += DrawingArea.width;
  1656. Oa += Va;
  1657. Ob += Vb;
  1658. Oc += Vc;
  1659. }
  1660. while (--y_b >= 0) {
  1661. method379(DrawingArea.pixels, texture, y_c, x_b >> 16, x_a >> 16,
  1662. l1 >> 8, k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1663. x_b += b_to_c;
  1664. x_a += a_to_b;
  1665. l1 += grad_b_off;
  1666. k1 += grad_a_off;
  1667. z_c += depth_increment;
  1668. y_c += DrawingArea.width;
  1669. Oa += Va;
  1670. Ob += Vb;
  1671. Oc += Vc;
  1672. }
  1673. return;
  1674. }
  1675. y_b -= y_a;
  1676. y_a -= y_c;
  1677. y_c = anIntArray1472[y_c];
  1678. while (--y_a >= 0) {
  1679. method379(DrawingArea.pixels, texture, y_c, x_c >> 16, x_b >> 16,
  1680. i2 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1681. x_b += b_to_c;
  1682. x_c += c_to_a;
  1683. l1 += grad_b_off;
  1684. i2 += grad_c_off;
  1685. z_c += depth_increment;
  1686. y_c += DrawingArea.width;
  1687. Oa += Va;
  1688. Ob += Vb;
  1689. Oc += Vc;
  1690. }
  1691. while (--y_b >= 0) {
  1692. method379(DrawingArea.pixels, texture, y_c, x_a >> 16, x_b >> 16,
  1693. k1 >> 8, l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1694. x_b += b_to_c;
  1695. x_a += a_to_b;
  1696. l1 += grad_b_off;
  1697. k1 += grad_a_off;
  1698. z_c += depth_increment;
  1699. y_c += DrawingArea.width;
  1700. Oa += Va;
  1701. Ob += Vb;
  1702. Oc += Vc;
  1703. }
  1704. return;
  1705. }
  1706. x_a = x_c <<= 16;
  1707. k1 = i2 <<= 16;
  1708. if (y_c < 0) {
  1709. x_a -= b_to_c * y_c;
  1710. x_c -= c_to_a * y_c;
  1711. z_c -= depth_increment * y_c;
  1712. k1 -= grad_b_off * y_c;
  1713. i2 -= grad_c_off * y_c;
  1714. y_c = 0;
  1715. }
  1716. x_b <<= 16;
  1717. l1 <<= 16;
  1718. if (y_b < 0) {
  1719. x_b -= a_to_b * y_b;
  1720. l1 -= grad_a_off * y_b;
  1721. y_b = 0;
  1722. }
  1723. int l9 = y_c - textureInt2;
  1724. Oa += Va * l9;
  1725. Ob += Vb * l9;
  1726. Oc += Vc * l9;
  1727. if (b_to_c < c_to_a) {
  1728. y_a -= y_b;
  1729. y_b -= y_c;
  1730. y_c = anIntArray1472[y_c];
  1731. while (--y_b >= 0) {
  1732. method379(DrawingArea.pixels, texture, y_c, x_a >> 16, x_c >> 16,
  1733. k1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1734. x_a += b_to_c;
  1735. x_c += c_to_a;
  1736. k1 += grad_b_off;
  1737. i2 += grad_c_off;
  1738. z_c += depth_increment;
  1739. y_c += DrawingArea.width;
  1740. Oa += Va;
  1741. Ob += Vb;
  1742. Oc += Vc;
  1743. }
  1744. while (--y_a >= 0) {
  1745. method379(DrawingArea.pixels, texture, y_c, x_b >> 16, x_c >> 16,
  1746. l1 >> 8, i2 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1747. x_b += a_to_b;
  1748. x_c += c_to_a;
  1749. l1 += grad_a_off;
  1750. i2 += grad_c_off;
  1751. z_c += depth_increment;
  1752. y_c += DrawingArea.width;
  1753. Oa += Va;
  1754. Ob += Vb;
  1755. Oc += Vc;
  1756. }
  1757. return;
  1758. }
  1759. y_a -= y_b;
  1760. y_b -= y_c;
  1761. y_c = anIntArray1472[y_c];
  1762. while (--y_b >= 0) {
  1763. method379(DrawingArea.pixels, texture, y_c, x_c >> 16, x_a >> 16, i2 >> 8,
  1764. k1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1765. x_a += b_to_c;
  1766. x_c += c_to_a;
  1767. k1 += grad_b_off;
  1768. i2 += grad_c_off;
  1769. z_c += depth_increment;
  1770. y_c += DrawingArea.width;
  1771. Oa += Va;
  1772. Ob += Vb;
  1773. Oc += Vc;
  1774. }
  1775. while (--y_a >= 0) {
  1776. method379(DrawingArea.pixels, texture, y_c, x_c >> 16, x_b >> 16, i2 >> 8,
  1777. l1 >> 8, Oa, Ob, Oc, Ha, Hb, Hc, z_c, depth_slope);
  1778. x_b += a_to_b;
  1779. x_c += c_to_a;
  1780. l1 += grad_a_off;
  1781. i2 += grad_c_off;
  1782. z_c += depth_increment;
  1783. y_c += DrawingArea.width;
  1784. Oa += Va;
  1785. Ob += Vb;
  1786. Oc += Vc;
  1787. }
  1788. }
  1789.  
  1790. private static void method379(int dest[], int texture[], int dest_off, int start_x, int end_x,
  1791. int shadeValue, int gradient, int l1, int i2, int j2, int k2, int l2, int i3, float depth, float depth_slope) {
  1792. int rgb = 0;// was parameter
  1793. int loops = 0;// was parameter
  1794. if (start_x >= end_x)
  1795. return;
  1796. int j3;
  1797. int k3;
  1798. if (aBoolean1462) {
  1799. j3 = (gradient - shadeValue) / (end_x - start_x);
  1800. if (end_x > DrawingArea.centerX)
  1801. end_x = DrawingArea.centerX;
  1802. if (start_x < 0) {
  1803. shadeValue -= start_x * j3;
  1804. start_x = 0;
  1805. }
  1806. if (start_x >= end_x)
  1807. return;
  1808. k3 = end_x - start_x >> 3;
  1809. j3 <<= 12;
  1810. shadeValue <<= 9;
  1811. } else {
  1812. if (end_x - start_x > 7) {
  1813. k3 = end_x - start_x >> 3;
  1814. j3 = (gradient - shadeValue) * anIntArray1468[k3] >> 6;
  1815. } else {
  1816. k3 = 0;
  1817. j3 = 0;
  1818. }
  1819. shadeValue <<= 9;
  1820. }
  1821. dest_off += start_x;
  1822. depth += depth_slope * (float) start_x;
  1823. if (lowMem) {
  1824. int i4 = 0;
  1825. int k4 = 0;
  1826. int k6 = start_x - textureInt1;
  1827. l1 += (k2 >> 3) * k6;
  1828. i2 += (l2 >> 3) * k6;
  1829. j2 += (i3 >> 3) * k6;
  1830. int i5 = j2 >> 12;
  1831. if (i5 != 0) {
  1832. rgb = l1 / i5;
  1833. loops = i2 / i5;
  1834. if (rgb < 0)
  1835. rgb = 0;
  1836. else if (rgb > 4032)
  1837. rgb = 4032;
  1838. }
  1839. l1 += k2;
  1840. i2 += l2;
  1841. j2 += i3;
  1842. i5 = j2 >> 12;
  1843. if (i5 != 0) {
  1844. i4 = l1 / i5;
  1845. k4 = i2 / i5;
  1846. if (i4 < 7)
  1847. i4 = 7;
  1848. else if (i4 > 4032)
  1849. i4 = 4032;
  1850. }
  1851. int i7 = i4 - rgb >> 3;
  1852. int k7 = k4 - loops >> 3;
  1853. rgb += (shadeValue & 0x600000) >> 3;
  1854. int i8 = shadeValue >> 23;
  1855. if (aBoolean1463) {
  1856. while (k3-- > 0) {
  1857. for (int i = 0; i < 8; i++) {
  1858. dest[dest_off] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
  1859. DrawingArea.depthBuffer[dest_off] = depth;
  1860. dest_off++;
  1861. depth += depth_slope;
  1862. rgb += i7;
  1863. loops += k7;
  1864. }
  1865. rgb = i4;
  1866. loops = k4;
  1867. l1 += k2;
  1868. i2 += l2;
  1869. j2 += i3;
  1870. int j5 = j2 >> 12;
  1871. if (j5 != 0) {
  1872. i4 = l1 / j5;
  1873. k4 = i2 / j5;
  1874. if (i4 < 7)
  1875. i4 = 7;
  1876. else if (i4 > 4032)
  1877. i4 = 4032;
  1878. }
  1879. i7 = i4 - rgb >> 3;
  1880. k7 = k4 - loops >> 3;
  1881. shadeValue += j3;
  1882. rgb += (shadeValue & 0x600000) >> 3;
  1883. i8 = shadeValue >> 23;
  1884. }
  1885. for (k3 = end_x - start_x & 7; k3-- > 0;) {
  1886. dest[dest_off] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
  1887. DrawingArea.depthBuffer[dest_off] = depth;
  1888. dest_off++;
  1889. depth += depth_slope;
  1890. rgb += i7;
  1891. loops += k7;
  1892. }
  1893.  
  1894. return;
  1895. }
  1896. while (k3-- > 0) {
  1897. int k8;
  1898. for (int i = 0; i < 8; i++) {
  1899. if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0) {
  1900. dest[dest_off] = k8;
  1901. DrawingArea.depthBuffer[dest_off] = depth;
  1902. }
  1903. dest_off++;
  1904. depth += depth_slope;
  1905. rgb += i7;
  1906. loops += k7;
  1907. }
  1908. rgb = i4;
  1909. loops = k4;
  1910. l1 += k2;
  1911. i2 += l2;
  1912. j2 += i3;
  1913. int k5 = j2 >> 12;
  1914. if (k5 != 0) {
  1915. i4 = l1 / k5;
  1916. k4 = i2 / k5;
  1917. if (i4 < 7)
  1918. i4 = 7;
  1919. else if (i4 > 4032)
  1920. i4 = 4032;
  1921. }
  1922. i7 = i4 - rgb >> 3;
  1923. k7 = k4 - loops >> 3;
  1924. shadeValue += j3;
  1925. rgb += (shadeValue & 0x600000) >> 3;
  1926. i8 = shadeValue >> 23;
  1927. }
  1928. for (k3 = end_x - start_x & 7; k3-- > 0;) {
  1929. int l8;
  1930. if ((l8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0) {
  1931. dest[dest_off] = l8;
  1932. DrawingArea.depthBuffer[dest_off] = depth;
  1933. }
  1934. dest_off++;
  1935. depth += depth_slope;
  1936. rgb += i7;
  1937. loops += k7;
  1938. }
  1939.  
  1940. return;
  1941. }
  1942. int j4 = 0;
  1943. int l4 = 0;
  1944. int l6 = start_x - textureInt1;
  1945. l1 += (k2 >> 3) * l6;
  1946. i2 += (l2 >> 3) * l6;
  1947. j2 += (i3 >> 3) * l6;
  1948. int l5 = j2 >> 14;
  1949. if (l5 != 0) {
  1950. rgb = l1 / l5;
  1951. loops = i2 / l5;
  1952. if (rgb < 0)
  1953. rgb = 0;
  1954. else if (rgb > 16256)
  1955. rgb = 16256;
  1956. }
  1957. l1 += k2;
  1958. i2 += l2;
  1959. j2 += i3;
  1960. l5 = j2 >> 14;
  1961. if (l5 != 0) {
  1962. j4 = l1 / l5;
  1963. l4 = i2 / l5;
  1964. if (j4 < 7)
  1965. j4 = 7;
  1966. else if (j4 > 16256)
  1967. j4 = 16256;
  1968. }
  1969. int j7 = j4 - rgb >> 3;
  1970. int l7 = l4 - loops >> 3;
  1971. rgb += shadeValue & 0x600000;
  1972. int j8 = shadeValue >> 23;
  1973. if (aBoolean1463) {
  1974. while (k3-- > 0) {
  1975. for (int i = 0; i < 8; i++) {
  1976. dest[dest_off] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
  1977. DrawingArea.depthBuffer[dest_off] = depth;
  1978. depth += depth_slope;
  1979. dest_off++;
  1980. rgb += j7;
  1981. loops += l7;
  1982. }
  1983. rgb = j4;
  1984. loops = l4;
  1985. l1 += k2;
  1986. i2 += l2;
  1987. j2 += i3;
  1988. int i6 = j2 >> 14;
  1989. if (i6 != 0) {
  1990. j4 = l1 / i6;
  1991. l4 = i2 / i6;
  1992. if (j4 < 7)
  1993. j4 = 7;
  1994. else if (j4 > 16256)
  1995. j4 = 16256;
  1996. }
  1997. j7 = j4 - rgb >> 3;
  1998. l7 = l4 - loops >> 3;
  1999. shadeValue += j3;
  2000. rgb += shadeValue & 0x600000;
  2001. j8 = shadeValue >> 23;
  2002. }
  2003. for (k3 = end_x - start_x & 7; k3-- > 0;) {
  2004. dest[dest_off] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
  2005. DrawingArea.depthBuffer[dest_off] = depth;
  2006. dest_off++;
  2007. depth += depth_slope;
  2008. rgb += j7;
  2009. loops += l7;
  2010. }
  2011.  
  2012. return;
  2013. }
  2014. while (k3-- > 0) {
  2015. int i9;
  2016. for (int i = 0; i < 8; i++) {
  2017. if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0) {
  2018. dest[dest_off] = i9;
  2019. DrawingArea.depthBuffer[dest_off] = depth;
  2020. }
  2021. dest_off++;
  2022. depth += depth_slope;
  2023. rgb += j7;
  2024. loops += l7;
  2025. }
  2026. rgb = j4;
  2027. loops = l4;
  2028. l1 += k2;
  2029. i2 += l2;
  2030. j2 += i3;
  2031. int j6 = j2 >> 14;
  2032. if (j6 != 0) {
  2033. j4 = l1 / j6;
  2034. l4 = i2 / j6;
  2035. if (j4 < 7)
  2036. j4 = 7;
  2037. else if (j4 > 16256)
  2038. j4 = 16256;
  2039. }
  2040. j7 = j4 - rgb >> 3;
  2041. l7 = l4 - loops >> 3;
  2042. shadeValue += j3;
  2043. rgb += shadeValue & 0x600000;
  2044. j8 = shadeValue >> 23;
  2045. }
  2046. for (int l3 = end_x - start_x & 7; l3-- > 0;) {
  2047. int j9;
  2048. if ((j9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0) {
  2049. dest[dest_off] = j9;
  2050. DrawingArea.depthBuffer[dest_off] = depth;
  2051. }
  2052. depth += depth_slope;
  2053. dest_off++;
  2054. rgb += j7;
  2055. loops += l7;
  2056. }
  2057. }
  2058.  
  2059. public static void drawDepthTriangle(int x_a, int x_b, int x_c, int y_a, int y_b, int y_c, float z_a, float z_b, float z_c) {
  2060. int a_to_b = 0;
  2061. if (y_b != y_a) {
  2062. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  2063. }
  2064. int b_to_c = 0;
  2065. if (y_c != y_b) {
  2066. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  2067. }
  2068. int c_to_a = 0;
  2069. if (y_c != y_a) {
  2070. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  2071. }
  2072.  
  2073. float b_aX = x_b - x_a;
  2074. float b_aY = y_b - y_a;
  2075. float c_aX = x_c - x_a;
  2076. float c_aY = y_c - y_a;
  2077. float b_aZ = z_b - z_a;
  2078. float c_aZ = z_c - z_a;
  2079.  
  2080. float div = b_aX * c_aY - c_aX * b_aY;
  2081. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  2082. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  2083. if (y_a <= y_b && y_a <= y_c) {
  2084. if (y_a < DrawingArea.bottomY) {
  2085. if (y_b > DrawingArea.bottomY)
  2086. y_b = DrawingArea.bottomY;
  2087. if (y_c > DrawingArea.bottomY)
  2088. y_c = DrawingArea.bottomY;
  2089. z_a = z_a - depth_slope * x_a + depth_slope;
  2090. if (y_b < y_c) {
  2091. x_c = x_a <<= 16;
  2092. if (y_a < 0) {
  2093. x_c -= c_to_a * y_a;
  2094. x_a -= a_to_b * y_a;
  2095. z_a -= depth_increment * y_a;
  2096. y_a = 0;
  2097. }
  2098. x_b <<= 16;
  2099. if (y_b < 0) {
  2100. x_b -= b_to_c * y_b;
  2101. y_b = 0;
  2102. }
  2103. if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  2104. y_c -= y_b;
  2105. y_b -= y_a;
  2106. y_a = anIntArray1472[y_a];
  2107. while (--y_b >= 0) {
  2108. drawDepthTriangleScanline(y_a, x_c >> 16, x_a >> 16, z_a, depth_slope);
  2109. x_c += c_to_a;
  2110. x_a += a_to_b;
  2111. z_a += depth_increment;
  2112. y_a += DrawingArea.width;
  2113. }
  2114. while (--y_c >= 0) {
  2115. drawDepthTriangleScanline(y_a, x_c >> 16, x_b >> 16, z_a, depth_slope);
  2116. x_c += c_to_a;
  2117. x_b += b_to_c;
  2118. z_a += depth_increment;
  2119. y_a += DrawingArea.width;
  2120. }
  2121. } else {
  2122. y_c -= y_b;
  2123. y_b -= y_a;
  2124. y_a = anIntArray1472[y_a];
  2125. while (--y_b >= 0) {
  2126. drawDepthTriangleScanline(y_a, x_a >> 16, x_c >> 16, z_a, depth_slope);
  2127. x_c += c_to_a;
  2128. x_a += a_to_b;
  2129. z_a += depth_increment;
  2130. y_a += DrawingArea.width;
  2131. }
  2132. while (--y_c >= 0) {
  2133. drawDepthTriangleScanline(y_a, x_b >> 16, x_c >> 16, z_a, depth_slope);
  2134. x_c += c_to_a;
  2135. x_b += b_to_c;
  2136. z_a += depth_increment;
  2137. y_a += DrawingArea.width;
  2138. }
  2139. }
  2140. } else {
  2141. x_b = x_a <<= 16;
  2142. if (y_a < 0) {
  2143. x_b -= c_to_a * y_a;
  2144. x_a -= a_to_b * y_a;
  2145. z_a -= depth_increment * y_a;
  2146. y_a = 0;
  2147. }
  2148. x_c <<= 16;
  2149. if (y_c < 0) {
  2150. x_c -= b_to_c * y_c;
  2151. y_c = 0;
  2152. }
  2153. if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  2154. y_b -= y_c;
  2155. y_c -= y_a;
  2156. y_a = anIntArray1472[y_a];
  2157. while (--y_c >= 0) {
  2158. drawDepthTriangleScanline(y_a, x_b >> 16, x_a >> 16, z_a, depth_slope);
  2159. x_b += c_to_a;
  2160. x_a += a_to_b;
  2161. z_a += depth_increment;
  2162. y_a += DrawingArea.width;
  2163. }
  2164. while (--y_b >= 0) {
  2165. drawDepthTriangleScanline(y_a, x_c >> 16, x_a >> 16, z_a, depth_slope);
  2166. x_c += b_to_c;
  2167. x_a += a_to_b;
  2168. z_a += depth_increment;
  2169. y_a += DrawingArea.width;
  2170. }
  2171. } else {
  2172. y_b -= y_c;
  2173. y_c -= y_a;
  2174. y_a = anIntArray1472[y_a];
  2175. while (--y_c >= 0) {
  2176. drawDepthTriangleScanline(y_a, x_a >> 16, x_b >> 16, z_a, depth_slope);
  2177. x_b += c_to_a;
  2178. x_a += a_to_b;
  2179. z_a += depth_increment;
  2180. y_a += DrawingArea.width;
  2181. }
  2182. while (--y_b >= 0) {
  2183. drawDepthTriangleScanline(y_a, x_a >> 16, x_c >> 16, z_a, depth_slope);
  2184. x_c += b_to_c;
  2185. x_a += a_to_b;
  2186. z_a += depth_increment;
  2187. y_a += DrawingArea.width;
  2188. }
  2189. }
  2190. }
  2191. }
  2192. } else if (y_b <= y_c) {
  2193. if (y_b < DrawingArea.bottomY) {
  2194. if (y_c > DrawingArea.bottomY)
  2195. y_c = DrawingArea.bottomY;
  2196. if (y_a > DrawingArea.bottomY)
  2197. y_a = DrawingArea.bottomY;
  2198. z_b = z_b - depth_slope * x_b + depth_slope;
  2199. if (y_c < y_a) {
  2200. x_a = x_b <<= 16;
  2201. if (y_b < 0) {
  2202. x_a -= a_to_b * y_b;
  2203. x_b -= b_to_c * y_b;
  2204. z_b -= depth_increment * y_b;
  2205. y_b = 0;
  2206. }
  2207. x_c <<= 16;
  2208. if (y_c < 0) {
  2209. x_c -= c_to_a * y_c;
  2210. y_c = 0;
  2211. }
  2212. if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  2213. y_a -= y_c;
  2214. y_c -= y_b;
  2215. y_b = anIntArray1472[y_b];
  2216. while (--y_c >= 0) {
  2217. drawDepthTriangleScanline(y_b, x_a >> 16, x_b >> 16, z_b, depth_slope);
  2218. x_a += a_to_b;
  2219. x_b += b_to_c;
  2220. z_b += depth_increment;
  2221. y_b += DrawingArea.width;
  2222. }
  2223. while (--y_a >= 0) {
  2224. drawDepthTriangleScanline(y_b, x_a >> 16, x_c >> 16, z_b, depth_slope);
  2225. x_a += a_to_b;
  2226. x_c += c_to_a;
  2227. z_b += depth_increment;
  2228. y_b += DrawingArea.width;
  2229. }
  2230. } else {
  2231. y_a -= y_c;
  2232. y_c -= y_b;
  2233. y_b = anIntArray1472[y_b];
  2234. while (--y_c >= 0) {
  2235. drawDepthTriangleScanline(y_b, x_b >> 16, x_a >> 16, z_b, depth_slope);
  2236. x_a += a_to_b;
  2237. x_b += b_to_c;
  2238. z_b += depth_increment;
  2239. y_b += DrawingArea.width;
  2240. }
  2241. while (--y_a >= 0) {
  2242. drawDepthTriangleScanline(y_b, x_c >> 16, x_a >> 16, z_b, depth_slope);
  2243. x_a += a_to_b;
  2244. x_c += c_to_a;
  2245. z_b += depth_increment;
  2246. y_b += DrawingArea.width;
  2247. }
  2248. }
  2249. } else {
  2250. x_c = x_b <<= 16;
  2251. if (y_b < 0) {
  2252. x_c -= a_to_b * y_b;
  2253. x_b -= b_to_c * y_b;
  2254. z_b -= depth_increment * y_b;
  2255. y_b = 0;
  2256. }
  2257. x_a <<= 16;
  2258. if (y_a < 0) {
  2259. x_a -= c_to_a * y_a;
  2260. y_a = 0;
  2261. }
  2262. if (a_to_b < b_to_c) {
  2263. y_c -= y_a;
  2264. y_a -= y_b;
  2265. y_b = anIntArray1472[y_b];
  2266. while (--y_a >= 0) {
  2267. drawDepthTriangleScanline(y_b, x_c >> 16, x_b >> 16, z_b, depth_slope);
  2268. x_c += a_to_b;
  2269. x_b += b_to_c;
  2270. z_b += depth_increment;
  2271. y_b += DrawingArea.width;
  2272. }
  2273. while (--y_c >= 0) {
  2274. drawDepthTriangleScanline(y_b, x_a >> 16, x_b >> 16, z_b, depth_slope);
  2275. x_a += c_to_a;
  2276. x_b += b_to_c;
  2277. z_b += depth_increment;
  2278. y_b += DrawingArea.width;
  2279. }
  2280. } else {
  2281. y_c -= y_a;
  2282. y_a -= y_b;
  2283. y_b = anIntArray1472[y_b];
  2284. while (--y_a >= 0) {
  2285. drawDepthTriangleScanline(y_b, x_b >> 16, x_c >> 16, z_b, depth_slope);
  2286. x_c += a_to_b;
  2287. x_b += b_to_c;
  2288. z_b += depth_increment;
  2289. y_b += DrawingArea.width;
  2290. }
  2291. while (--y_c >= 0) {
  2292. drawDepthTriangleScanline(y_b, x_b >> 16, x_a >> 16, z_b, depth_slope);
  2293. x_a += c_to_a;
  2294. x_b += b_to_c;
  2295. z_b += depth_increment;
  2296. y_b += DrawingArea.width;
  2297. }
  2298. }
  2299. }
  2300. }
  2301. } else if (y_c < DrawingArea.bottomY) {
  2302. if (y_a > DrawingArea.bottomY)
  2303. y_a = DrawingArea.bottomY;
  2304. if (y_b > DrawingArea.bottomY)
  2305. y_b = DrawingArea.bottomY;
  2306. z_c = z_c - depth_slope * x_c + depth_slope;
  2307. if (y_a < y_b) {
  2308. x_b = x_c <<= 16;
  2309. if (y_c < 0) {
  2310. x_b -= b_to_c * y_c;
  2311. x_c -= c_to_a * y_c;
  2312. z_c -= depth_increment * y_c;
  2313. y_c = 0;
  2314. }
  2315. x_a <<= 16;
  2316. if (y_a < 0) {
  2317. x_a -= a_to_b * y_a;
  2318. y_a = 0;
  2319. }
  2320. if (b_to_c < c_to_a) {
  2321. y_b -= y_a;
  2322. y_a -= y_c;
  2323. y_c = anIntArray1472[y_c];
  2324. while (--y_a >= 0) {
  2325. drawDepthTriangleScanline(y_c, x_b >> 16, x_c >> 16, z_c, depth_slope);
  2326. x_b += b_to_c;
  2327. x_c += c_to_a;
  2328. z_c += depth_increment;
  2329. y_c += DrawingArea.width;
  2330. }
  2331. while (--y_b >= 0) {
  2332. drawDepthTriangleScanline(y_c, x_b >> 16, x_a >> 16, z_c, depth_slope);
  2333. x_b += b_to_c;
  2334. x_a += a_to_b;
  2335. z_c += depth_increment;
  2336. y_c += DrawingArea.width;
  2337. }
  2338. } else {
  2339. y_b -= y_a;
  2340. y_a -= y_c;
  2341. y_c = anIntArray1472[y_c];
  2342. while (--y_a >= 0) {
  2343. drawDepthTriangleScanline(y_c, x_c >> 16, x_b >> 16, z_c, depth_slope);
  2344. x_b += b_to_c;
  2345. x_c += c_to_a;
  2346. z_c += depth_increment;
  2347. y_c += DrawingArea.width;
  2348. }
  2349. while (--y_b >= 0) {
  2350. drawDepthTriangleScanline(y_c, x_a >> 16, x_b >> 16, z_c, depth_slope);
  2351. x_b += b_to_c;
  2352. x_a += a_to_b;
  2353. z_c += depth_increment;
  2354. y_c += DrawingArea.width;
  2355. }
  2356. }
  2357. } else {
  2358. x_a = x_c <<= 16;
  2359. if (y_c < 0) {
  2360. x_a -= b_to_c * y_c;
  2361. x_c -= c_to_a * y_c;
  2362. z_c -= depth_increment * y_c;
  2363. y_c = 0;
  2364. }
  2365. x_b <<= 16;
  2366. if (y_b < 0) {
  2367. x_b -= a_to_b * y_b;
  2368. y_b = 0;
  2369. }
  2370. if (b_to_c < c_to_a) {
  2371. y_a -= y_b;
  2372. y_b -= y_c;
  2373. y_c = anIntArray1472[y_c];
  2374. while (--y_b >= 0) {
  2375. drawDepthTriangleScanline(y_c, x_a >> 16, x_c >> 16, z_c, depth_slope);
  2376. x_a += b_to_c;
  2377. x_c += c_to_a;
  2378. z_c += depth_increment;
  2379. y_c += DrawingArea.width;
  2380. }
  2381. while (--y_a >= 0) {
  2382. drawDepthTriangleScanline(y_c, x_b >> 16, x_c >> 16, z_c, depth_slope);
  2383. x_b += a_to_b;
  2384. x_c += c_to_a;
  2385. z_c += depth_increment;
  2386. y_c += DrawingArea.width;
  2387. }
  2388. } else {
  2389. y_a -= y_b;
  2390. y_b -= y_c;
  2391. y_c = anIntArray1472[y_c];
  2392. while (--y_b >= 0) {
  2393. drawDepthTriangleScanline(y_c, x_c >> 16, x_a >> 16, z_c, depth_slope);
  2394. x_a += b_to_c;
  2395. x_c += c_to_a;
  2396. z_c += depth_increment;
  2397. y_c += DrawingArea.width;
  2398. }
  2399. while (--y_a >= 0) {
  2400. drawDepthTriangleScanline(y_c, x_c >> 16, x_b >> 16, z_c, depth_slope);
  2401. x_b += a_to_b;
  2402. x_c += c_to_a;
  2403. z_c += depth_increment;
  2404. y_c += DrawingArea.width;
  2405. }
  2406. }
  2407. }
  2408. }
  2409. }
  2410.  
  2411. private static void drawDepthTriangleScanline(int dest_off, int start_x, int end_x, float depth, float depth_slope) {
  2412. int dbl = DrawingArea.depthBuffer.length;
  2413. if (aBoolean1462) {
  2414. if (end_x > DrawingArea.width) {
  2415. end_x = DrawingArea.width;
  2416. }
  2417. if (start_x < 0) {
  2418. start_x = 0;
  2419. }
  2420. }
  2421. if (start_x >= end_x) {
  2422. return;
  2423. }
  2424. dest_off += start_x - 1;
  2425. int loops = end_x - start_x >> 2;
  2426. depth += depth_slope * (float) start_x;
  2427. if (anInt1465 == 0) {
  2428. while (--loops >= 0) {
  2429. dest_off++;
  2430. if (dest_off >= 0 && dest_off < dbl && true) {
  2431. DrawingArea.depthBuffer[dest_off] = depth;
  2432. }
  2433. depth += depth_slope;
  2434. dest_off++;
  2435. if (dest_off >= 0 && dest_off < dbl && true) {
  2436. DrawingArea.depthBuffer[dest_off] = depth;
  2437. }
  2438. depth += depth_slope;
  2439. dest_off++;
  2440. if (dest_off >= 0 && dest_off < dbl && true) {
  2441. DrawingArea.depthBuffer[dest_off] = depth;
  2442. }
  2443. depth += depth_slope;
  2444. dest_off++;
  2445. if (dest_off >= 0 && dest_off < dbl && true) {
  2446. DrawingArea.depthBuffer[dest_off] = depth;
  2447. }
  2448. depth += depth_slope;
  2449. }
  2450. for (loops = end_x - start_x & 3; --loops >= 0;) {
  2451. dest_off++;
  2452. if (dest_off >= 0 && dest_off < dbl && true) {
  2453. DrawingArea.depthBuffer[dest_off] = depth;
  2454. }
  2455. depth += depth_slope;
  2456. }
  2457. return;
  2458. }
  2459. while (--loops >= 0) {
  2460. dest_off++;
  2461. if (dest_off >= 0 && dest_off < dbl && true) {
  2462. DrawingArea.depthBuffer[dest_off] = depth;
  2463. }
  2464. depth += depth_slope;
  2465. dest_off++;
  2466. if (dest_off >= 0 && dest_off < dbl && true) {
  2467. DrawingArea.depthBuffer[dest_off] = depth;
  2468. }
  2469. depth += depth_slope;
  2470. dest_off++;
  2471. if (dest_off >= 0 && dest_off < dbl && true) {
  2472. DrawingArea.depthBuffer[dest_off] = depth;
  2473. }
  2474. depth += depth_slope;
  2475. dest_off++;
  2476. if (dest_off >= 0 && dest_off < dbl && true) {
  2477. DrawingArea.depthBuffer[dest_off] = depth;
  2478. }
  2479. depth += depth_slope;
  2480. }
  2481. for (loops = end_x - start_x & 3; --loops >= 0;) {
  2482. dest_off++;
  2483. if (dest_off >= 0 && dest_off < dbl && true) {
  2484. DrawingArea.depthBuffer[dest_off] = depth;
  2485. }
  2486. depth += depth_slope;
  2487. }
  2488. }
  2489.  
  2490. public static final int anInt1459 = -477;
  2491. public static boolean lowMem = true;
  2492. static boolean aBoolean1462;
  2493. private static boolean aBoolean1463;
  2494. public static boolean aBoolean1464 = true;
  2495. public static int anInt1465;
  2496. public static int textureInt1;
  2497. public static int textureInt2;
  2498. private static int[] anIntArray1468;
  2499. public static final int[] anIntArray1469;
  2500. public static int anIntArray1470[];
  2501. public static int anIntArray1471[];
  2502. public static int anIntArray1472[];
  2503. private static int anInt1473;
  2504. public static Background aBackgroundArray1474s[] = new Background[52];
  2505. private static boolean[] aBooleanArray1475 = new boolean[52];
  2506. private static int[] anIntArray1476 = new int[52];
  2507. private static int anInt1477;
  2508. private static int[][] anIntArrayArray1478;
  2509. private static int[][] anIntArrayArray1479 = new int[52][];
  2510. public static int anIntArray1480[] = new int[52];
  2511. public static int anInt1481;
  2512. public static int anIntArray1482[] = new int[0x10000];
  2513. private static int[][] anIntArrayArray1483 = new int[52][];
  2514.  
  2515. static {
  2516. anIntArray1468 = new int[512];
  2517. anIntArray1469 = new int[2048];
  2518. anIntArray1470 = new int[2048];
  2519. anIntArray1471 = new int[2048];
  2520. for (int i = 1; i < 512; i++)
  2521. anIntArray1468[i] = 32768 / i;
  2522.  
  2523. for (int j = 1; j < 2048; j++)
  2524. anIntArray1469[j] = 0x10000 / j;
  2525.  
  2526. for (int k = 0; k < 2048; k++) {
  2527. anIntArray1470[k] = (int) (65536D * Math
  2528. .sin(k * 0.0030679614999999999D));
  2529. anIntArray1471[k] = (int) (65536D * Math
  2530. .cos(k * 0.0030679614999999999D));
  2531. }
  2532.  
  2533. }
  2534. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement