Guest User

Texture.java

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