Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 96.31 KB | None | 0 0
  1. package com.graardor.client.world;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import com.graardor.client.Client;
  6. import com.graardor.client.cache.Archive;
  7. import com.graardor.client.graphics.Background;
  8. import com.graardor.client.graphics.Raster;
  9.  
  10. public final class Rasterizer extends Raster {
  11.  
  12. public static int TEXTURE_COUNT = 51;
  13. public static Background aBackgroundArray1474s[] = new Background[TEXTURE_COUNT];
  14. public static boolean restrict_edges;
  15. private static boolean aBoolean1463;
  16. private static boolean[] aBooleanArray1475 = new boolean[TEXTURE_COUNT];
  17. public static int alpha;
  18. private static int anInt1473;
  19. private static int textureRequestBufferPointer;
  20. public static int anInt1481;
  21. private static int[] anIntArray1468;
  22. public static final int[] anIntArray1469;
  23. private static int[] averageTextureColours = new int[TEXTURE_COUNT];
  24. public static int anIntArray1480[] = new int[TEXTURE_COUNT];
  25. public static int hsl2rgb[] = new int[0x10000];
  26. private static int[][] textureRequestPixelBuffer;
  27. private static int[][] texturesPixelBuffer = new int[TEXTURE_COUNT][];
  28. private static int[][] currentPalette = new int[TEXTURE_COUNT][];
  29. public static int centerX;
  30. public static int centerY;
  31. public static int COSINE[];
  32. public static int lineOffsets[];
  33. public static boolean lowDetail = true;
  34. public static boolean notTextured = true;
  35. private static int[] OFFSETS_512_334 = null;
  36. private static int[] OFFSETS_765_503 = null;
  37. public static int SINE[];
  38. public static boolean ignoreInterfaceModel = false;
  39. public static boolean textureOnInterface = false;
  40.  
  41.  
  42. static {
  43. anIntArray1468 = new int[512];
  44. anIntArray1469 = new int[2048];
  45. SINE = new int[2048];
  46. COSINE = new int[2048];
  47.  
  48. for (int i = 1; i < 512; i++) {
  49. anIntArray1468[i] = 32768 / i;
  50. }
  51.  
  52. for (int j = 1; j < 2048; j++) {
  53. anIntArray1469[j] = 0x10000 / j;
  54. }
  55.  
  56. for (int k = 0; k < 2048; k++) {
  57. SINE[k] = (int) (65536D * Math.sin(k * 0.0030679614999999999D));
  58. COSINE[k] = (int) (65536D * Math.cos(k * 0.0030679614999999999D));
  59. }
  60.  
  61. }
  62.  
  63. public static int[] getOffsets(int j, int k) {
  64. if (j == 512 && k == 334 && OFFSETS_512_334 != null) {
  65. return OFFSETS_512_334;
  66. }
  67.  
  68. if (j == 765 + 1 && k == 503 && OFFSETS_765_503 != null) {
  69. return OFFSETS_765_503;
  70. }
  71.  
  72. int[] t = new int[k];
  73. for (int l = 0; l < k; l++) {
  74. t[l] = j * l;
  75. }
  76.  
  77. if (j == 512 && k == 334) {
  78. OFFSETS_512_334 = t;
  79. }
  80.  
  81. if (j == 765 + 1 && k == 503) {
  82. OFFSETS_765_503 = t;
  83. }
  84.  
  85. return t;
  86. }
  87.  
  88. public static void useViewport() {
  89. lineOffsets = new int[Raster.height];
  90. for (int j = 0; j < Raster.height; j++) {
  91. lineOffsets[j] = Raster.rasterWidth * j;
  92. }
  93.  
  94. centerX = Raster.rasterWidth / 2;
  95. centerY = Raster.height / 2;
  96. }
  97.  
  98. public static void method366() {
  99. textureRequestPixelBuffer = null;
  100. for (int j = 0; j < TEXTURE_COUNT; j++) {
  101. texturesPixelBuffer[j] = null;
  102. }
  103.  
  104. }
  105.  
  106. public static void method367() {
  107. if (textureRequestPixelBuffer == null) {
  108. textureRequestBufferPointer = 20;// was parameter
  109. if (lowDetail) {
  110. textureRequestPixelBuffer = new int[textureRequestBufferPointer][16384];
  111. } else {
  112. textureRequestPixelBuffer = new int[textureRequestBufferPointer][0x10000];
  113. }
  114. for (int k = 0; k < TEXTURE_COUNT; k++) {
  115. texturesPixelBuffer[k] = null;
  116. }
  117.  
  118. }
  119. }
  120.  
  121. public static void method368(Archive streamLoader) {
  122. anInt1473 = 0;
  123.  
  124. for (int i = 0; i < 51; i++) {
  125. try {
  126. aBackgroundArray1474s[i] = new Background(streamLoader, String.valueOf(i), 0);
  127.  
  128. if (lowDetail && aBackgroundArray1474s[i].resizeWidth == 128) {
  129. aBackgroundArray1474s[i].method356();
  130. } else {
  131. aBackgroundArray1474s[i].method357();
  132. }
  133.  
  134. anInt1473++;
  135. } catch (Exception _ex) {
  136. _ex.printStackTrace();
  137. }
  138. }
  139.  
  140. for (int i = 51; i < TEXTURE_COUNT; i++) {
  141. try {
  142. try {
  143. aBackgroundArray1474s[i] = new Background(streamLoader, String.valueOf(i), 0);
  144. } catch(Exception e) {
  145. e.printStackTrace();
  146. continue;
  147. }
  148.  
  149. if (lowDetail && aBackgroundArray1474s[i].resizeWidth == 128) {
  150. aBackgroundArray1474s[i].method356();
  151. } else {
  152. aBackgroundArray1474s[i].method357();
  153. }
  154.  
  155.  
  156. anInt1473++;
  157. } catch (Exception _ex) {
  158. _ex.printStackTrace();
  159. }
  160. }
  161. }
  162.  
  163. public static int getTexture(int i) {
  164. if (averageTextureColours[i] != 0) {
  165. return averageTextureColours[i];
  166. }
  167.  
  168. int totalRed = 0;
  169. int totalGreen = 0;
  170. int totalBlue = 0;
  171. int j1 = currentPalette[i].length;
  172.  
  173. for (int k1 = 0; k1 < j1; k1++) {
  174. totalRed += currentPalette[i][k1] >> 16 & 0xff;
  175. totalGreen += currentPalette[i][k1] >> 8 & 0xff;
  176. totalBlue += currentPalette[i][k1] & 0xff;
  177. }
  178.  
  179. int l1 = (totalRed / j1 << 16) + (totalGreen / j1 << 8) + totalBlue / j1;
  180. l1 = adjustBrightness(l1, 1.3999999999999999D);
  181.  
  182. if (l1 == 0) {
  183. l1 = 1;
  184. }
  185.  
  186. averageTextureColours[i] = l1;
  187. return l1;
  188. }
  189.  
  190. public static void requestTextureUpdate(int i) {
  191. if (texturesPixelBuffer[i] == null) {
  192. return;
  193. }
  194.  
  195. textureRequestPixelBuffer[textureRequestBufferPointer++] = texturesPixelBuffer[i];
  196. texturesPixelBuffer[i] = null;
  197. }
  198.  
  199. private static int[] method371(int i) {
  200. anIntArray1480[i] = anInt1481++;
  201.  
  202. if (texturesPixelBuffer[i] != null) {
  203. return texturesPixelBuffer[i];
  204. }
  205.  
  206. int ai[];
  207.  
  208. if (textureRequestBufferPointer > 0) {
  209. ai = textureRequestPixelBuffer[--textureRequestBufferPointer];
  210. textureRequestPixelBuffer[textureRequestBufferPointer] = null;
  211. } else {
  212. int j = 0;
  213. int k = -1;
  214.  
  215. for (int l = 0; l < anInt1473; l++) {
  216. if (texturesPixelBuffer[l] != null && (anIntArray1480[l] < j || k == -1)) {
  217. j = anIntArray1480[l];
  218. k = l;
  219. }
  220. }
  221.  
  222. ai = texturesPixelBuffer[k];
  223. texturesPixelBuffer[k] = null;
  224. }
  225.  
  226. texturesPixelBuffer[i] = ai;
  227. Background background = aBackgroundArray1474s[i];
  228. int ai1[] = currentPalette[i];
  229.  
  230. if (lowDetail) {
  231. aBooleanArray1475[i] = false;
  232.  
  233. for (int i1 = 0; i1 < 4096; i1++) {
  234. int i2 = ai[i1] = ai1[background.palettePixels[i1]] & 0xf8f8ff;
  235.  
  236. if (i2 == 0) {
  237. aBooleanArray1475[i] = true;
  238. }
  239.  
  240. ai[4096 + i1] = i2 - (i2 >>> 3) & 0xf8f8ff;
  241. ai[8192 + i1] = i2 - (i2 >>> 2) & 0xf8f8ff;
  242. ai[12288 + i1] = i2 - (i2 >>> 2) - (i2 >>> 3) & 0xf8f8ff;
  243. }
  244. } else {
  245. if (background.width == 64) {
  246. for (int j1 = 0; j1 < 128; j1++) {
  247. for (int j2 = 0; j2 < 128; j2++) {
  248. ai[j2 + (j1 << 7)] = ai1[background.palettePixels[(j2 >> 1) + (j1 >> 1 << 6)]];
  249. }
  250. }
  251. } else {
  252. for (int k1 = 0; k1 < 16384; k1++) {
  253. ai[k1] = ai1[background.palettePixels[k1]];
  254. }
  255. }
  256.  
  257. aBooleanArray1475[i] = false;
  258.  
  259. for (int l1 = 0; l1 < 16384; l1++) {
  260. ai[l1] &= 0xf8f8ff;
  261. int k2 = ai[l1];
  262.  
  263. if (k2 == 0) {
  264. aBooleanArray1475[i] = true;
  265. }
  266.  
  267. ai[16384 + l1] = k2 - (k2 >>> 3) & 0xf8f8ff;
  268. ai[32768 + l1] = k2 - (k2 >>> 2) & 0xf8f8ff;
  269. ai[49152 + l1] = k2 - (k2 >>> 2) - (k2 >>> 3) & 0xf8f8ff;
  270. }
  271. }
  272.  
  273. return ai;
  274. }
  275.  
  276. public static void setBrightness(double d) {
  277. int j = 0;
  278.  
  279. for (int k = 0; k < 512; k++) {
  280. double d1 = k / 8 / 64D + 0.0078125D;
  281. double d2 = (k & 7) / 8D + 0.0625D;
  282.  
  283. for (int k1 = 0; k1 < 128; k1++) {
  284. double d3 = k1 / 128D;
  285. double d4 = d3;
  286. double d5 = d3;
  287. double d6 = d3;
  288.  
  289. if (d2 != 0.0D) {
  290. double d7;
  291.  
  292. if (d3 < 0.5D) {
  293. d7 = d3 * (1.0D + d2);
  294. } else {
  295. d7 = d3 + d2 - d3 * d2;
  296. }
  297.  
  298. double d8 = 2D * d3 - d7;
  299. double d9 = d1 + 0.33333333333333331D;
  300.  
  301. if (d9 > 1.0D) {
  302. d9--;
  303. }
  304.  
  305. double d10 = d1;
  306. double d11 = d1 - 0.33333333333333331D;
  307.  
  308. if (d11 < 0.0D) {
  309. d11++;
  310. }
  311.  
  312. if (6D * d9 < 1.0D) {
  313. d4 = d8 + (d7 - d8) * 6D * d9;
  314. } else if (2D * d9 < 1.0D) {
  315. d4 = d7;
  316. } else if (3D * d9 < 2D) {
  317. d4 = d8 + (d7 - d8) * (0.66666666666666663D - d9) * 6D;
  318. } else {
  319. d4 = d8;
  320. }
  321.  
  322. if (6D * d10 < 1.0D) {
  323. d5 = d8 + (d7 - d8) * 6D * d10;
  324. } else if (2D * d10 < 1.0D) {
  325. d5 = d7;
  326. } else if (3D * d10 < 2D) {
  327. d5 = d8 + (d7 - d8) * (0.66666666666666663D - d10) * 6D;
  328. } else {
  329. d5 = d8;
  330. }
  331.  
  332. if (6D * d11 < 1.0D) {
  333. d6 = d8 + (d7 - d8) * 6D * d11;
  334. } else if (2D * d11 < 1.0D) {
  335. d6 = d7;
  336. } else if (3D * d11 < 2D) {
  337. d6 = d8 + (d7 - d8) * (0.66666666666666663D - d11) * 6D;
  338. } else {
  339. d6 = d8;
  340. }
  341. }
  342.  
  343. int l1 = (int) (d4 * 256D);
  344. int i2 = (int) (d5 * 256D);
  345. int j2 = (int) (d6 * 256D);
  346. int k2 = (l1 << 16) + (i2 << 8) + j2;
  347. k2 = adjustBrightness(k2, d);
  348.  
  349. if (k2 == 0) {
  350. k2 = 1;
  351. }
  352.  
  353. hsl2rgb[j++] = k2;
  354. }
  355. }
  356.  
  357. for (int l = 0; l < TEXTURE_COUNT; l++) {
  358. if (aBackgroundArray1474s[l] != null) {
  359. int ai[] = aBackgroundArray1474s[l].palette;
  360. if(ai == null) continue;
  361. currentPalette[l] = new int[ai.length];
  362.  
  363. for (int j1 = 0; j1 < ai.length; j1++) {
  364. currentPalette[l][j1] = adjustBrightness(ai[j1], d);
  365.  
  366. if ((currentPalette[l][j1] & 0xf8f8ff) == 0 && j1 != 0) {
  367. currentPalette[l][j1] = 1;
  368. }
  369. }
  370. }
  371. }
  372.  
  373. for (int i1 = 0; i1 < TEXTURE_COUNT; i1++) {
  374. requestTextureUpdate(i1);
  375. }
  376. }
  377.  
  378. private static int adjustBrightness(int i, double d) {
  379. double d1 = (i >> 16) / 256D;
  380. double d2 = (i >> 8 & 0xff) / 256D;
  381. double d3 = (i & 0xff) / 256D;
  382. d1 = Math.pow(d1, d);
  383. d2 = Math.pow(d2, d);
  384. d3 = Math.pow(d3, d);
  385. int j = (int) (d1 * 256D);
  386. int k = (int) (d2 * 256D);
  387. int l = (int) (d3 * 256D);
  388. return (j << 16) + (k << 8) + l;
  389. }
  390.  
  391.  
  392. 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) {
  393. if (z_a < 0 || z_b < 0 || z_c < 0)
  394. return;
  395. int rgb1 = hsl2rgb[hsl1];
  396. int rgb2 = hsl2rgb[hsl2];
  397. int rgb3 = hsl2rgb[hsl3];
  398. int r1 = rgb1 >> 16 & 0xff;
  399. int g1 = rgb1 >> 8 & 0xff;
  400. int b1 = rgb1 & 0xff;
  401. int r2 = rgb2 >> 16 & 0xff;
  402. int g2 = rgb2 >> 8 & 0xff;
  403. int b2 = rgb2 & 0xff;
  404. int r3 = rgb3 >> 16 & 0xff;
  405. int g3 = rgb3 >> 8 & 0xff;
  406. int b3 = rgb3 & 0xff;
  407. int a_to_b = 0;
  408. int dr1 = 0;
  409. int dg1 = 0;
  410. int db1 = 0;
  411. if (y_b != y_a) {
  412. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  413. dr1 = (r2 - r1 << 16) / (y_b - y_a);
  414. dg1 = (g2 - g1 << 16) / (y_b - y_a);
  415. db1 = (b2 - b1 << 16) / (y_b - y_a);
  416. }
  417. int b_to_c = 0;
  418. int dr2 = 0;
  419. int dg2 = 0;
  420. int db2 = 0;
  421. if (y_c != y_b) {
  422. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  423. dr2 = (r3 - r2 << 16) / (y_c - y_b);
  424. dg2 = (g3 - g2 << 16) / (y_c - y_b);
  425. db2 = (b3 - b2 << 16) / (y_c - y_b);
  426. }
  427. int c_to_a = 0;
  428. int dr3 = 0;
  429. int dg3 = 0;
  430. int db3 = 0;
  431. if (y_c != y_a) {
  432. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  433. dr3 = (r1 - r3 << 16) / (y_a - y_c);
  434. dg3 = (g1 - g3 << 16) / (y_a - y_c);
  435. db3 = (b1 - b3 << 16) / (y_a - y_c);
  436. }
  437. float b_aX = x_b - x_a;
  438. float b_aY = y_b - y_a;
  439. float c_aX = x_c - x_a;
  440. float c_aY = y_c - y_a;
  441. float b_aZ = z_b - z_a;
  442. float c_aZ = z_c - z_a;
  443.  
  444. float div = b_aX * c_aY - c_aX * b_aY;
  445. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  446. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  447. if(y_a <= y_b && y_a <= y_c) {
  448. if(y_a >= Raster.bottomY) {
  449. return;
  450. }
  451. if(y_b > Raster.bottomY) {
  452. y_b = Raster.bottomY;
  453. }
  454. if(y_c > Raster.bottomY) {
  455. y_c = Raster.bottomY;
  456. }
  457. z_a = z_a - depth_slope * x_a + depth_slope;
  458. if(y_b < y_c) {
  459. x_c = x_a <<= 16;
  460. r3 = r1 <<= 16;
  461. g3 = g1 <<= 16;
  462. b3 = b1 <<= 16;
  463. if(y_a < 0) {
  464. x_c -= c_to_a * y_a;
  465. x_a -= a_to_b * y_a;
  466. r3 -= dr3 * y_a;
  467. g3 -= dg3 * y_a;
  468. b3 -= db3 * y_a;
  469. r1 -= dr1 * y_a;
  470. g1 -= dg1 * y_a;
  471. b1 -= db1 * y_a;
  472. z_a -= depth_increment * y_a;
  473. y_a = 0;
  474. }
  475. x_b <<= 16;
  476. r2 <<= 16;
  477. g2 <<= 16;
  478. b2 <<= 16;
  479. if(y_b < 0) {
  480. x_b -= b_to_c * y_b;
  481. r2 -= dr2 * y_b;
  482. g2 -= dg2 * y_b;
  483. b2 -= db2 * y_b;
  484. y_b = 0;
  485. }
  486. if(y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  487. y_c -= y_b;
  488. y_b -= y_a;
  489. for(y_a = lineOffsets[y_a]; --y_b >= 0; y_a += Raster.rasterWidth) {
  490. drawShadedScanline(Raster.pixels, y_a, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_a, depth_slope);
  491. x_c += c_to_a;
  492. x_a += a_to_b;
  493. r3 += dr3;
  494. g3 += dg3;
  495. b3 += db3;
  496. r1 += dr1;
  497. g1 += dg1;
  498. b1 += db1;
  499. z_a += depth_increment;
  500. }
  501. while(--y_c >= 0) {
  502. drawShadedScanline(Raster.pixels, y_a, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_a, depth_slope);
  503. x_c += c_to_a;
  504. x_b += b_to_c;
  505. r3 += dr3;
  506. g3 += dg3;
  507. b3 += db3;
  508. r2 += dr2;
  509. g2 += dg2;
  510. b2 += db2;
  511. y_a += Raster.rasterWidth;
  512. z_a += depth_increment;
  513. }
  514. return;
  515. }
  516. y_c -= y_b;
  517. y_b -= y_a;
  518. for(y_a = lineOffsets[y_a]; --y_b >= 0; y_a += Raster.rasterWidth) {
  519. drawShadedScanline(Raster.pixels, y_a, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_a, depth_slope);
  520. x_c += c_to_a;
  521. x_a += a_to_b;
  522. r3 += dr3;
  523. g3 += dg3;
  524. b3 += db3;
  525. r1 += dr1;
  526. g1 += dg1;
  527. b1 += db1;
  528. z_a += depth_increment;
  529. }
  530. while(--y_c >= 0) {
  531. drawShadedScanline(Raster.pixels, y_a, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_a, depth_slope);
  532. x_c += c_to_a;
  533. x_b += b_to_c;
  534. r3 += dr3;
  535. g3 += dg3;
  536. b3 += db3;
  537. r2 += dr2;
  538. g2 += dg2;
  539. b2 += db2;
  540. y_a += Raster.rasterWidth;
  541. z_a += depth_increment;
  542. }
  543. return;
  544. }
  545. x_b = x_a <<= 16;
  546. r2 = r1 <<= 16;
  547. g2 = g1 <<= 16;
  548. b2 = b1 <<= 16;
  549. if(y_a < 0) {
  550. x_b -= c_to_a * y_a;
  551. x_a -= a_to_b * y_a;
  552. r2 -= dr3 * y_a;
  553. g2 -= dg3 * y_a;
  554. b2 -= db3 * y_a;
  555. r1 -= dr1 * y_a;
  556. g1 -= dg1 * y_a;
  557. b1 -= db1 * y_a;
  558. z_a -= depth_increment * y_a;
  559. y_a = 0;
  560. }
  561. x_c <<= 16;
  562. r3 <<= 16;
  563. g3 <<= 16;
  564. b3 <<= 16;
  565. if(y_c < 0) {
  566. x_c -= b_to_c * y_c;
  567. r3 -= dr2 * y_c;
  568. g3 -= dg2 * y_c;
  569. b3 -= db2 * y_c;
  570. y_c = 0;
  571. }
  572. if(y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  573. y_b -= y_c;
  574. y_c -= y_a;
  575. for(y_a = lineOffsets[y_a]; --y_c >= 0; y_a += Raster.rasterWidth) {
  576. drawShadedScanline(Raster.pixels, y_a, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_a, depth_slope);
  577. x_b += c_to_a;
  578. x_a += a_to_b;
  579. r2 += dr3;
  580. g2 += dg3;
  581. b2 += db3;
  582. r1 += dr1;
  583. g1 += dg1;
  584. b1 += db1;
  585. z_a += depth_increment;
  586. }
  587. while(--y_b >= 0) {
  588. drawShadedScanline(Raster.pixels, y_a, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_a, depth_slope);
  589. x_c += b_to_c;
  590. x_a += a_to_b;
  591. r3 += dr2;
  592. g3 += dg2;
  593. b3 += db2;
  594. r1 += dr1;
  595. g1 += dg1;
  596. b1 += db1;
  597. y_a += Raster.rasterWidth;
  598. z_a += depth_increment;
  599. }
  600. return;
  601. }
  602. y_b -= y_c;
  603. y_c -= y_a;
  604. for(y_a = lineOffsets[y_a]; --y_c >= 0; y_a += Raster.rasterWidth) {
  605. drawShadedScanline(Raster.pixels, y_a, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_a, depth_slope);
  606. x_b += c_to_a;
  607. x_a += a_to_b;
  608. r2 += dr3;
  609. g2 += dg3;
  610. b2 += db3;
  611. r1 += dr1;
  612. g1 += dg1;
  613. b1 += db1;
  614. z_a += depth_increment;
  615. }
  616. while(--y_b >= 0) {
  617. drawShadedScanline(Raster.pixels, y_a, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_a, depth_slope);
  618. x_c += b_to_c;
  619. x_a += a_to_b;
  620. r3 += dr2;
  621. g3 += dg2;
  622. b3 += db2;
  623. r1 += dr1;
  624. g1 += dg1;
  625. b1 += db1;
  626. y_a += Raster.rasterWidth;
  627. z_a += depth_increment;
  628. }
  629. return;
  630. }
  631. if(y_b <= y_c) {
  632. if(y_b >= Raster.bottomY) {
  633. return;
  634. }
  635. if(y_c > Raster.bottomY) {
  636. y_c = Raster.bottomY;
  637. }
  638. if(y_a > Raster.bottomY) {
  639. y_a = Raster.bottomY;
  640. }
  641. z_b = z_b - depth_slope * x_b + depth_slope;
  642. if(y_c < y_a) {
  643. x_a = x_b <<= 16;
  644. r1 = r2 <<= 16;
  645. g1 = g2 <<= 16;
  646. b1 = b2 <<= 16;
  647. if(y_b < 0) {
  648. x_a -= a_to_b * y_b;
  649. x_b -= b_to_c * y_b;
  650. r1 -= dr1 * y_b;
  651. g1 -= dg1 * y_b;
  652. b1 -= db1 * y_b;
  653. r2 -= dr2 * y_b;
  654. g2 -= dg2 * y_b;
  655. b2 -= db2 * y_b;
  656. z_b -= depth_increment * y_b;
  657. y_b = 0;
  658. }
  659. x_c <<= 16;
  660. r3 <<= 16;
  661. g3 <<= 16;
  662. b3 <<= 16;
  663. if(y_c < 0) {
  664. x_c -= c_to_a * y_c;
  665. r3 -= dr3 * y_c;
  666. g3 -= dg3 * y_c;
  667. b3 -= db3 * y_c;
  668. y_c = 0;
  669. }
  670. if(y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  671. y_a -= y_c;
  672. y_c -= y_b;
  673. for(y_b = lineOffsets[y_b]; --y_c >= 0; y_b += Raster.rasterWidth) {
  674. drawShadedScanline(Raster.pixels, y_b, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_b, depth_slope);
  675. x_a += a_to_b;
  676. x_b += b_to_c;
  677. r1 += dr1;
  678. g1 += dg1;
  679. b1 += db1;
  680. r2 += dr2;
  681. g2 += dg2;
  682. b2 += db2;
  683. z_b += depth_increment;
  684. }
  685. while(--y_a >= 0) {
  686. drawShadedScanline(Raster.pixels, y_b, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_b, depth_slope);
  687. x_a += a_to_b;
  688. x_c += c_to_a;
  689. r1 += dr1;
  690. g1 += dg1;
  691. b1 += db1;
  692. r3 += dr3;
  693. g3 += dg3;
  694. b3 += db3;
  695. y_b += Raster.rasterWidth;
  696. z_b += depth_increment;
  697. }
  698. return;
  699. }
  700. y_a -= y_c;
  701. y_c -= y_b;
  702. for(y_b = lineOffsets[y_b]; --y_c >= 0; y_b += Raster.rasterWidth) {
  703. drawShadedScanline(Raster.pixels, y_b, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_b, depth_slope);
  704. x_a += a_to_b;
  705. x_b += b_to_c;
  706. r1 += dr1;
  707. g1 += dg1;
  708. b1 += db1;
  709. r2 += dr2;
  710. g2 += dg2;
  711. b2 += db2;
  712. z_b += depth_increment;
  713. }
  714. while(--y_a >= 0) {
  715. drawShadedScanline(Raster.pixels, y_b, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_b, depth_slope);
  716. x_a += a_to_b;
  717. x_c += c_to_a;
  718. r1 += dr1;
  719. g1 += dg1;
  720. b1 += db1;
  721. r3 += dr3;
  722. g3 += dg3;
  723. b3 += db3;
  724. y_b += Raster.rasterWidth;
  725. z_b += depth_increment;
  726. }
  727. return;
  728. }
  729. x_c = x_b <<= 16;
  730. r3 = r2 <<= 16;
  731. g3 = g2 <<= 16;
  732. b3 = b2 <<= 16;
  733. if(y_b < 0) {
  734. x_c -= a_to_b * y_b;
  735. x_b -= b_to_c * y_b;
  736. r3 -= dr1 * y_b;
  737. g3 -= dg1 * y_b;
  738. b3 -= db1 * y_b;
  739. r2 -= dr2 * y_b;
  740. g2 -= dg2 * y_b;
  741. b2 -= db2 * y_b;
  742. z_b -= depth_increment * y_b;
  743. y_b = 0;
  744. }
  745. x_a <<= 16;
  746. r1 <<= 16;
  747. g1 <<= 16;
  748. b1 <<= 16;
  749. if(y_a < 0) {
  750. x_a -= c_to_a * y_a;
  751. r1 -= dr3 * y_a;
  752. g1 -= dg3 * y_a;
  753. b1 -= db3 * y_a;
  754. y_a = 0;
  755. }
  756. if(a_to_b < b_to_c) {
  757. y_c -= y_a;
  758. y_a -= y_b;
  759. for(y_b = lineOffsets[y_b]; --y_a >= 0; y_b += Raster.rasterWidth) {
  760. drawShadedScanline(Raster.pixels, y_b, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_b, depth_slope);
  761. x_c += a_to_b;
  762. x_b += b_to_c;
  763. r3 += dr1;
  764. g3 += dg1;
  765. b3 += db1;
  766. r2 += dr2;
  767. g2 += dg2;
  768. b2 += db2;
  769. z_b += depth_increment;
  770. }
  771. while(--y_c >= 0) {
  772. drawShadedScanline(Raster.pixels, y_b, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_b, depth_slope);
  773. x_a += c_to_a;
  774. x_b += b_to_c;
  775. r1 += dr3;
  776. g1 += dg3;
  777. b1 += db3;
  778. r2 += dr2;
  779. g2 += dg2;
  780. b2 += db2;
  781. y_b += Raster.rasterWidth;
  782. z_b += depth_increment;
  783. }
  784. return;
  785. }
  786. y_c -= y_a;
  787. y_a -= y_b;
  788. for(y_b = lineOffsets[y_b]; --y_a >= 0; y_b += Raster.rasterWidth) {
  789. drawShadedScanline(Raster.pixels, y_b, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_b, depth_slope);
  790. x_c += a_to_b;
  791. x_b += b_to_c;
  792. r3 += dr1;
  793. g3 += dg1;
  794. b3 += db1;
  795. r2 += dr2;
  796. g2 += dg2;
  797. b2 += db2;
  798. z_b += depth_increment;
  799. }
  800. while(--y_c >= 0) {
  801. drawShadedScanline(Raster.pixels, y_b, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_b, depth_slope);
  802. x_a += c_to_a;
  803. x_b += b_to_c;
  804. r1 += dr3;
  805. g1 += dg3;
  806. b1 += db3;
  807. r2 += dr2;
  808. g2 += dg2;
  809. b2 += db2;
  810. y_b += Raster.rasterWidth;
  811. z_b += depth_increment;
  812. }
  813. return;
  814. }
  815. if(y_c >= Raster.bottomY) {
  816. return;
  817. }
  818. if(y_a > Raster.bottomY) {
  819. y_a = Raster.bottomY;
  820. }
  821. if(y_b > Raster.bottomY) {
  822. y_b = Raster.bottomY;
  823. }
  824. z_c = z_c - depth_slope * x_c + depth_slope;
  825. if(y_a < y_b) {
  826. x_b = x_c <<= 16;
  827. r2 = r3 <<= 16;
  828. g2 = g3 <<= 16;
  829. b2 = b3 <<= 16;
  830. if(y_c < 0) {
  831. x_b -= b_to_c * y_c;
  832. x_c -= c_to_a * y_c;
  833. r2 -= dr2 * y_c;
  834. g2 -= dg2 * y_c;
  835. b2 -= db2 * y_c;
  836. r3 -= dr3 * y_c;
  837. g3 -= dg3 * y_c;
  838. b3 -= db3 * y_c;
  839. z_c -= depth_increment * y_c;
  840. y_c = 0;
  841. }
  842. x_a <<= 16;
  843. r1 <<= 16;
  844. g1 <<= 16;
  845. b1 <<= 16;
  846. if(y_a < 0) {
  847. x_a -= a_to_b * y_a;
  848. r1 -= dr1 * y_a;
  849. g1 -= dg1 * y_a;
  850. b1 -= db1 * y_a;
  851. y_a = 0;
  852. }
  853. if(b_to_c < c_to_a) {
  854. y_b -= y_a;
  855. y_a -= y_c;
  856. for(y_c = lineOffsets[y_c]; --y_a >= 0; y_c += Raster.rasterWidth) {
  857. drawShadedScanline(Raster.pixels, y_c, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_c, depth_slope);
  858. x_b += b_to_c;
  859. x_c += c_to_a;
  860. r2 += dr2;
  861. g2 += dg2;
  862. b2 += db2;
  863. r3 += dr3;
  864. g3 += dg3;
  865. b3 += db3;
  866. z_c += depth_increment;
  867. }
  868. while(--y_b >= 0) {
  869. drawShadedScanline(Raster.pixels, y_c, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_c, depth_slope);
  870. x_b += b_to_c;
  871. x_a += a_to_b;
  872. r2 += dr2;
  873. g2 += dg2;
  874. b2 += db2;
  875. r1 += dr1;
  876. g1 += dg1;
  877. b1 += db1;
  878. y_c += Raster.rasterWidth;
  879. z_c += depth_increment;
  880. }
  881. return;
  882. }
  883. y_b -= y_a;
  884. y_a -= y_c;
  885. for(y_c = lineOffsets[y_c]; --y_a >= 0; y_c += Raster.rasterWidth) {
  886. drawShadedScanline(Raster.pixels, y_c, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_c, depth_slope);
  887. x_b += b_to_c;
  888. x_c += c_to_a;
  889. r2 += dr2;
  890. g2 += dg2;
  891. b2 += db2;
  892. r3 += dr3;
  893. g3 += dg3;
  894. b3 += db3;
  895. z_c += depth_increment;
  896. }
  897. while(--y_b >= 0) {
  898. drawShadedScanline(Raster.pixels, y_c, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_c, depth_slope);
  899. x_b += b_to_c;
  900. x_a += a_to_b;
  901. r2 += dr2;
  902. g2 += dg2;
  903. b2 += db2;
  904. r1 += dr1;
  905. g1 += dg1;
  906. b1 += db1;
  907. z_c += depth_increment;
  908. y_c += Raster.rasterWidth;
  909. }
  910. return;
  911. }
  912. x_a = x_c <<= 16;
  913. r1 = r3 <<= 16;
  914. g1 = g3 <<= 16;
  915. b1 = b3 <<= 16;
  916. if(y_c < 0) {
  917. x_a -= b_to_c * y_c;
  918. x_c -= c_to_a * y_c;
  919. r1 -= dr2 * y_c;
  920. g1 -= dg2 * y_c;
  921. b1 -= db2 * y_c;
  922. r3 -= dr3 * y_c;
  923. g3 -= dg3 * y_c;
  924. b3 -= db3 * y_c;
  925. z_c -= depth_increment * y_c;
  926. y_c = 0;
  927. }
  928. x_b <<= 16;
  929. r2 <<= 16;
  930. g2 <<= 16;
  931. b2 <<= 16;
  932. if(y_b < 0) {
  933. x_b -= a_to_b * y_b;
  934. r2 -= dr1 * y_b;
  935. g2 -= dg1 * y_b;
  936. b2 -= db1 * y_b;
  937. y_b = 0;
  938. }
  939. if(b_to_c < c_to_a) {
  940. y_a -= y_b;
  941. y_b -= y_c;
  942. for(y_c = lineOffsets[y_c]; --y_b >= 0; y_c += Raster.rasterWidth) {
  943. drawShadedScanline(Raster.pixels, y_c, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_c, depth_slope);
  944. x_a += b_to_c;
  945. x_c += c_to_a;
  946. r1 += dr2;
  947. g1 += dg2;
  948. b1 += db2;
  949. r3 += dr3;
  950. g3 += dg3;
  951. b3 += db3;
  952. z_c += depth_increment;
  953. }
  954. while(--y_a >= 0) {
  955. drawShadedScanline(Raster.pixels, y_c, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_c, depth_slope);
  956. x_b += a_to_b;
  957. x_c += c_to_a;
  958. r2 += dr1;
  959. g2 += dg1;
  960. b2 += db1;
  961. r3 += dr3;
  962. g3 += dg3;
  963. b3 += db3;
  964. z_c += depth_increment;
  965. y_c += Raster.rasterWidth;
  966. }
  967. return;
  968. }
  969. y_a -= y_b;
  970. y_b -= y_c;
  971. for(y_c = lineOffsets[y_c]; --y_b >= 0; y_c += Raster.rasterWidth) {
  972. drawShadedScanline(Raster.pixels, y_c, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_c, depth_slope);
  973. x_a += b_to_c;
  974. x_c += c_to_a;
  975. r1 += dr2;
  976. g1 += dg2;
  977. b1 += db2;
  978. r3 += dr3;
  979. g3 += dg3;
  980. b3 += db3;
  981. z_c += depth_increment;
  982. }
  983. while(--y_a >= 0) {
  984. drawShadedScanline(Raster.pixels, y_c, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_c, depth_slope);
  985. x_b += a_to_b;
  986. x_c += c_to_a;
  987. r2 += dr1;
  988. g2 += dg1;
  989. b2 += db1;
  990. r3 += dr3;
  991. g3 += dg3;
  992. b3 += db3;
  993. y_c += Raster.rasterWidth;
  994. z_c += depth_increment;
  995. }
  996. }
  997.  
  998. public static void drawShadedScanline(int[] dest, int offset, int x1, int x2, int r1, int g1, int b1, int r2,
  999. int g2, int b2, float depth, float depth_slope) {
  1000. int n = x2 - x1;
  1001. if (n <= 0) {
  1002. return;
  1003. }
  1004.  
  1005. r2 = (r2 - r1) / n;
  1006. g2 = (g2 - g1) / n;
  1007. b2 = (b2 - b1) / n;
  1008. if (restrict_edges) {
  1009. if (x2 > Raster.viewportRx) {
  1010. n -= x2 - Raster.viewportRx;
  1011. x2 = Raster.viewportRx;
  1012. }
  1013. if (x1 < 0) {
  1014. n = x2;
  1015. r1 -= x1 * r2;
  1016. g1 -= x1 * g2;
  1017. b1 -= x1 * b2;
  1018. x1 = 0;
  1019. }
  1020. }
  1021. if (x1 < x2) {
  1022. offset += x1;
  1023. depth += depth_slope * (float) x1;
  1024. if (alpha == 0) {
  1025. while (--n >= 0) {
  1026. if (Raster.depthBuffer != null && depth <= Raster.depthBuffer[offset]) {
  1027. dest[offset] = (r1 & 0xff0000) | (g1 >> 8 & 0xff00) | (b1 >> 16 & 0xff);
  1028. Raster.depthBuffer[offset] = depth;
  1029. }
  1030. depth += depth_slope;
  1031. r1 += r2;
  1032. g1 += g2;
  1033. b1 += b2;
  1034. offset++;
  1035. }
  1036. } else {
  1037. final int a1 = alpha;
  1038. final int a2 = 256 - alpha;
  1039. int rgb;
  1040. int dst;
  1041. while (--n >= 0) {
  1042. rgb = (r1 & 0xff0000) | (g1 >> 8 & 0xff00) | (b1 >> 16 & 0xff);
  1043. rgb = ((rgb & 0xff00ff) * a2 >> 8 & 0xff00ff) + ((rgb & 0xff00) * a2 >> 8 & 0xff00);
  1044. if (Raster.depthBuffer != null && depth <= Raster.depthBuffer[offset] && rgb != 0) {
  1045. dst = dest[offset];
  1046. dest[offset] = rgb + ((dst & 0xff00ff) * a1 >> 8 & 0xff00ff)
  1047. + ((dst & 0xff00) * a1 >> 8 & 0xff00);
  1048. Raster.depthBuffer[offset] = depth;
  1049. }
  1050. depth += depth_slope;
  1051. r1 += r2;
  1052. g1 += g2;
  1053. b1 += b2;
  1054. offset++;
  1055. }
  1056. }
  1057. }
  1058. }
  1059.  
  1060. public static void drawFlatTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int rgb, float z_a,
  1061. float z_b, float z_c) {
  1062.  
  1063. int a_to_b = 0, b_to_c = 0, c_to_a = 0;
  1064.  
  1065. if (y_b != y_a) {
  1066. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  1067. }
  1068. if (y_c != y_b) {
  1069. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  1070. }
  1071. if (y_c != y_a) {
  1072. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  1073. }
  1074.  
  1075. float b_aX = x_b - x_a;
  1076. float b_aY = y_b - y_a;
  1077. float c_aX = x_c - x_a;
  1078. float c_aY = y_c - y_a;
  1079. float b_aZ = z_b - z_a;
  1080. float c_aZ = z_c - z_a;
  1081.  
  1082. float div = b_aX * c_aY - c_aX * b_aY;
  1083. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  1084. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  1085.  
  1086. // B /|
  1087. // / |
  1088. // / |
  1089. // / |
  1090. // A ----- C
  1091. if (y_a <= y_b && y_a <= y_c) {
  1092. if (y_a < Raster.bottomY) {
  1093. if (y_b > Raster.bottomY)
  1094. y_b = Raster.bottomY;
  1095. if (y_c > Raster.bottomY)
  1096. y_c = Raster.bottomY;
  1097. z_a = z_a - depth_slope * x_a + depth_slope;
  1098. if (y_b < y_c) {
  1099. x_c = x_a <<= 16;
  1100. if (y_a < 0) {
  1101. x_c -= c_to_a * y_a;
  1102. x_a -= a_to_b * y_a;
  1103. z_a -= depth_increment * y_a;
  1104. y_a = 0;
  1105. }
  1106. x_b <<= 16;
  1107. if (y_b < 0) {
  1108. x_b -= b_to_c * y_b;
  1109. y_b = 0;
  1110. }
  1111. if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  1112. y_c -= y_b;
  1113. y_b -= y_a;
  1114. y_a = Rasterizer.lineOffsets[y_a];
  1115. while (--y_b >= 0) {
  1116. drawFlatScanLine(Raster.pixels, y_a, x_c >> 16, x_a >> 16, z_a, depth_slope, rgb);
  1117. x_c += c_to_a;
  1118. x_a += a_to_b;
  1119. z_a += depth_increment;
  1120. y_a += Raster.rasterWidth;
  1121. }
  1122. while (--y_c >= 0) {
  1123. drawFlatScanLine(Raster.pixels, y_a, x_c >> 16, x_b >> 16, z_a, depth_slope, rgb);
  1124. x_c += c_to_a;
  1125. x_b += b_to_c;
  1126. z_a += depth_increment;
  1127. y_a += Raster.rasterWidth;
  1128. }
  1129. } else {
  1130. y_c -= y_b;
  1131. y_b -= y_a;
  1132. y_a = Rasterizer.lineOffsets[y_a];
  1133. while (--y_b >= 0) {
  1134. drawFlatScanLine(Raster.pixels, y_a, x_a >> 16, x_c >> 16, z_a, depth_slope, rgb);
  1135. x_c += c_to_a;
  1136. x_a += a_to_b;
  1137. z_a += depth_increment;
  1138. y_a += Raster.rasterWidth;
  1139. }
  1140. while (--y_c >= 0) {
  1141. drawFlatScanLine(Raster.pixels, y_a, x_b >> 16, x_c >> 16, z_a, depth_slope, rgb);
  1142. x_c += c_to_a;
  1143. x_b += b_to_c;
  1144. z_a += depth_increment;
  1145. y_a += Raster.rasterWidth;
  1146. }
  1147. }
  1148. } else {
  1149. x_b = x_a <<= 16;
  1150. if (y_a < 0) {
  1151. x_b -= c_to_a * y_a;
  1152. x_a -= a_to_b * y_a;
  1153. z_a -= depth_increment * y_a;
  1154. y_a = 0;
  1155. }
  1156. x_c <<= 16;
  1157. if (y_c < 0) {
  1158. x_c -= b_to_c * y_c;
  1159. y_c = 0;
  1160. }
  1161. if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  1162. y_b -= y_c;
  1163. y_c -= y_a;
  1164. y_a = Rasterizer.lineOffsets[y_a];
  1165. while (--y_c >= 0) {
  1166. drawFlatScanLine(Raster.pixels, y_a, x_b >> 16, x_a >> 16, z_a, depth_slope, rgb);
  1167. x_b += c_to_a;
  1168. x_a += a_to_b;
  1169. z_a += depth_increment;
  1170. y_a += Raster.rasterWidth;
  1171. }
  1172. while (--y_b >= 0) {
  1173. drawFlatScanLine(Raster.pixels, y_a, x_c >> 16, x_a >> 16, z_a, depth_slope, rgb);
  1174. x_c += b_to_c;
  1175. x_a += a_to_b;
  1176. z_a += depth_increment;
  1177. y_a += Raster.rasterWidth;
  1178. }
  1179. } else {
  1180. y_b -= y_c;
  1181. y_c -= y_a;
  1182. y_a = Rasterizer.lineOffsets[y_a];
  1183. while (--y_c >= 0) {
  1184. drawFlatScanLine(Raster.pixels, y_a, x_a >> 16, x_b >> 16, z_a, depth_slope, rgb);
  1185. x_b += c_to_a;
  1186. x_a += a_to_b;
  1187. z_a += depth_increment;
  1188. y_a += Raster.rasterWidth;
  1189. }
  1190. while (--y_b >= 0) {
  1191. drawFlatScanLine(Raster.pixels, y_a, x_a >> 16, x_c >> 16, z_a, depth_slope, rgb);
  1192. x_c += b_to_c;
  1193. x_a += a_to_b;
  1194. z_a += depth_increment;
  1195. y_a += Raster.rasterWidth;
  1196. }
  1197. }
  1198. }
  1199. }
  1200. } else if (y_b <= y_c) {
  1201. // A |\
  1202. // | \
  1203. // | \
  1204. // | \
  1205. // C ----- B
  1206. if (y_b < Raster.bottomY) {
  1207. if (y_c > Raster.bottomY)
  1208. y_c = Raster.bottomY;
  1209. if (y_a > Raster.bottomY)
  1210. y_a = Raster.bottomY;
  1211. z_b = z_b - depth_slope * x_b + depth_slope;
  1212. if (y_c < y_a) {
  1213. x_a = x_b <<= 16;
  1214. if (y_b < 0) {
  1215. x_a -= a_to_b * y_b;
  1216. x_b -= b_to_c * y_b;
  1217. z_b -= depth_increment * y_b;
  1218. y_b = 0;
  1219. }
  1220. x_c <<= 16;
  1221. if (y_c < 0) {
  1222. x_c -= c_to_a * y_c;
  1223. y_c = 0;
  1224. }
  1225. if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  1226. y_a -= y_c;
  1227. y_c -= y_b;
  1228. y_b = Rasterizer.lineOffsets[y_b];
  1229. while (--y_c >= 0) {
  1230. drawFlatScanLine(Raster.pixels, y_b, x_a >> 16, x_b >> 16, z_b, depth_slope, rgb);
  1231. x_a += a_to_b;
  1232. x_b += b_to_c;
  1233. z_b += depth_increment;
  1234. y_b += Raster.rasterWidth;
  1235. }
  1236. while (--y_a >= 0) {
  1237. drawFlatScanLine(Raster.pixels, y_b, x_a >> 16, x_c >> 16, z_b, depth_slope, rgb);
  1238. x_a += a_to_b;
  1239. x_c += c_to_a;
  1240. z_b += depth_increment;
  1241. y_b += Raster.rasterWidth;
  1242. }
  1243. } else {
  1244. y_a -= y_c;
  1245. y_c -= y_b;
  1246. y_b = Rasterizer.lineOffsets[y_b];
  1247. while (--y_c >= 0) {
  1248. drawFlatScanLine(Raster.pixels, y_b, x_b >> 16, x_a >> 16, z_b, depth_slope, rgb);
  1249. x_a += a_to_b;
  1250. x_b += b_to_c;
  1251. z_b += depth_increment;
  1252. y_b += Raster.rasterWidth;
  1253. }
  1254. while (--y_a >= 0) {
  1255. drawFlatScanLine(Raster.pixels, y_b, x_c >> 16, x_a >> 16, z_b, depth_slope, rgb);
  1256. x_a += a_to_b;
  1257. x_c += c_to_a;
  1258. z_b += depth_increment;
  1259. y_b += Raster.rasterWidth;
  1260. }
  1261. }
  1262. } else {
  1263. x_c = x_b <<= 16;
  1264. if (y_b < 0) {
  1265. x_c -= a_to_b * y_b;
  1266. x_b -= b_to_c * y_b;
  1267. z_b -= depth_increment * y_b;
  1268. y_b = 0;
  1269. }
  1270. x_a <<= 16;
  1271. if (y_a < 0) {
  1272. x_a -= c_to_a * y_a;
  1273. y_a = 0;
  1274. }
  1275. if (a_to_b < b_to_c) {
  1276. y_c -= y_a;
  1277. y_a -= y_b;
  1278. y_b = Rasterizer.lineOffsets[y_b];
  1279. while (--y_a >= 0) {
  1280. drawFlatScanLine(Raster.pixels, y_b, x_c >> 16, x_b >> 16, z_b, depth_slope, rgb);
  1281. x_c += a_to_b;
  1282. x_b += b_to_c;
  1283. z_b += depth_increment;
  1284. y_b += Raster.rasterWidth;
  1285. }
  1286. while (--y_c >= 0) {
  1287. drawFlatScanLine(Raster.pixels, y_b, x_a >> 16, x_b >> 16, z_b, depth_slope, rgb);
  1288. x_a += c_to_a;
  1289. x_b += b_to_c;
  1290. z_b += depth_increment;
  1291. y_b += Raster.rasterWidth;
  1292. }
  1293. } else {
  1294. y_c -= y_a;
  1295. y_a -= y_b;
  1296. y_b = Rasterizer.lineOffsets[y_b];
  1297. while (--y_a >= 0) {
  1298. drawFlatScanLine(Raster.pixels, y_b, x_b >> 16, x_c >> 16, z_b, depth_slope, rgb);
  1299. x_c += a_to_b;
  1300. x_b += b_to_c;
  1301. z_b += depth_increment;
  1302. y_b += Raster.rasterWidth;
  1303. }
  1304. while (--y_c >= 0) {
  1305. drawFlatScanLine(Raster.pixels, y_b, x_b >> 16, x_a >> 16, z_b, depth_slope, rgb);
  1306. x_a += c_to_a;
  1307. x_b += b_to_c;
  1308. z_b += depth_increment;
  1309. y_b += Raster.rasterWidth;
  1310. }
  1311. }
  1312. }
  1313. }
  1314. } else if (y_c < Raster.bottomY) {
  1315. if (y_a > Raster.bottomY)
  1316. y_a = Raster.bottomY;
  1317. if (y_b > Raster.bottomY)
  1318. y_b = Raster.bottomY;
  1319. z_c = z_c - depth_slope * x_c + depth_slope;
  1320. if (y_a < y_b) {
  1321. x_b = x_c <<= 16;
  1322. if (y_c < 0) {
  1323. x_b -= b_to_c * y_c;
  1324. x_c -= c_to_a * y_c;
  1325. z_c -= depth_increment * y_c;
  1326. y_c = 0;
  1327. }
  1328. x_a <<= 16;
  1329. if (y_a < 0) {
  1330. x_a -= a_to_b * y_a;
  1331. y_a = 0;
  1332. }
  1333. if (b_to_c < c_to_a) {
  1334. y_b -= y_a;
  1335. y_a -= y_c;
  1336. y_c = Rasterizer.lineOffsets[y_c];
  1337. while (--y_a >= 0) {
  1338. drawFlatScanLine(Raster.pixels, y_c, x_b >> 16, x_c >> 16, z_c, depth_slope, rgb);
  1339. x_b += b_to_c;
  1340. x_c += c_to_a;
  1341. z_c += depth_increment;
  1342. y_c += Raster.rasterWidth;
  1343. }
  1344. while (--y_b >= 0) {
  1345. drawFlatScanLine(Raster.pixels, y_c, x_b >> 16, x_a >> 16, z_c, depth_slope, rgb);
  1346. x_b += b_to_c;
  1347. x_a += a_to_b;
  1348. z_c += depth_increment;
  1349. y_c += Raster.rasterWidth;
  1350. }
  1351. } else {
  1352. y_b -= y_a;
  1353. y_a -= y_c;
  1354. y_c = Rasterizer.lineOffsets[y_c];
  1355. while (--y_a >= 0) {
  1356. drawFlatScanLine(Raster.pixels, y_c, x_c >> 16, x_b >> 16, z_c, depth_slope, rgb);
  1357. x_b += b_to_c;
  1358. x_c += c_to_a;
  1359. z_c += depth_increment;
  1360. y_c += Raster.rasterWidth;
  1361. }
  1362. while (--y_b >= 0) {
  1363. drawFlatScanLine(Raster.pixels, y_c, x_a >> 16, x_b >> 16, z_c, depth_slope, rgb);
  1364. x_b += b_to_c;
  1365. x_a += a_to_b;
  1366. z_c += depth_increment;
  1367. y_c += Raster.rasterWidth;
  1368. }
  1369. }
  1370. } else {
  1371. x_a = x_c <<= 16;
  1372. if (y_c < 0) {
  1373. x_a -= b_to_c * y_c;
  1374. x_c -= c_to_a * y_c;
  1375. z_c -= depth_increment * y_c;
  1376. y_c = 0;
  1377. }
  1378. x_b <<= 16;
  1379. if (y_b < 0) {
  1380. x_b -= a_to_b * y_b;
  1381. y_b = 0;
  1382. }
  1383. if (b_to_c < c_to_a) {
  1384. y_a -= y_b;
  1385. y_b -= y_c;
  1386. y_c = Rasterizer.lineOffsets[y_c];
  1387. while (--y_b >= 0) {
  1388. drawFlatScanLine(Raster.pixels, y_c, x_a >> 16, x_c >> 16, z_c, depth_slope, rgb);
  1389. x_a += b_to_c;
  1390. x_c += c_to_a;
  1391. z_c += depth_increment;
  1392. y_c += Raster.rasterWidth;
  1393. }
  1394. while (--y_a >= 0) {
  1395. drawFlatScanLine(Raster.pixels, y_c, x_b >> 16, x_c >> 16, z_c, depth_slope, rgb);
  1396. x_b += a_to_b;
  1397. x_c += c_to_a;
  1398. z_c += depth_increment;
  1399. y_c += Raster.rasterWidth;
  1400. }
  1401. } else {
  1402. y_a -= y_b;
  1403. y_b -= y_c;
  1404. y_c = Rasterizer.lineOffsets[y_c];
  1405. while (--y_b >= 0) {
  1406. drawFlatScanLine(Raster.pixels, y_c, x_c >> 16, x_a >> 16, z_c, depth_slope, rgb);
  1407. x_a += b_to_c;
  1408. x_c += c_to_a;
  1409. z_c += depth_increment;
  1410. y_c += Raster.rasterWidth;
  1411. }
  1412. while (--y_a >= 0) {
  1413. drawFlatScanLine(Raster.pixels, y_c, x_c >> 16, x_b >> 16, z_c, depth_slope, rgb);
  1414. x_b += a_to_b;
  1415. x_c += c_to_a;
  1416. z_c += depth_increment;
  1417. y_c += Raster.rasterWidth;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. }
  1423.  
  1424. private static void drawFlatScanLine(int[] dest, int dest_off, int start_x, int end_x, float depth,
  1425. float depth_slope, int rgb) {
  1426. if (Rasterizer.restrict_edges) {
  1427. if (end_x > Raster.viewportRx)
  1428. end_x = Raster.viewportRx;
  1429. if (start_x < 0)
  1430. start_x = 0;
  1431. }
  1432.  
  1433. if (start_x >= end_x)
  1434. return;
  1435. dest_off += start_x - 1;
  1436. int loops = end_x - start_x >> 2;
  1437. depth += depth_slope * (float) start_x;
  1438.  
  1439. if (Rasterizer.alpha == 0) {
  1440. while (--loops >= 0) {
  1441.  
  1442. dest_off++;
  1443. if (depth < Raster.depthBuffer[dest_off]) {
  1444. dest[dest_off] = rgb;
  1445. Raster.depthBuffer[dest_off] = depth;
  1446. }
  1447.  
  1448. depth += depth_slope;
  1449. dest_off++;
  1450. if (depth < Raster.depthBuffer[dest_off]) {
  1451. dest[dest_off] = rgb;
  1452. Raster.depthBuffer[dest_off] = depth;
  1453. }
  1454. depth += depth_slope;
  1455. dest_off++;
  1456. if (depth < Raster.depthBuffer[dest_off]) {
  1457. dest[dest_off] = rgb;
  1458. Raster.depthBuffer[dest_off] = depth;
  1459. }
  1460. depth += depth_slope;
  1461. dest_off++;
  1462. if (depth < Raster.depthBuffer[dest_off]) {
  1463. dest[dest_off] = rgb;
  1464. Raster.depthBuffer[dest_off] = depth;
  1465. }
  1466. depth += depth_slope;
  1467.  
  1468. }
  1469. for (loops = end_x - start_x & 3; --loops >= 0;) {
  1470. dest_off++;
  1471. if (depth < Raster.depthBuffer[dest_off]) {
  1472. dest[dest_off] = rgb;
  1473. Raster.depthBuffer[dest_off] = depth;
  1474. }
  1475. depth += depth_slope;
  1476. }
  1477. return;
  1478. }
  1479. int src_alpha = Rasterizer.alpha;
  1480. int dest_alpha = 256 - Rasterizer.alpha;
  1481. rgb = ((rgb & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((rgb & 0xff00) * dest_alpha >> 8 & 0xff00);
  1482. while (--loops >= 0) {
  1483.  
  1484. dest_off++;
  1485. if (depth < Raster.depthBuffer[dest_off]) {
  1486. dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
  1487. + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
  1488. Raster.depthBuffer[dest_off] = depth;
  1489. }
  1490.  
  1491. depth += depth_slope;
  1492. dest_off++;
  1493. if (depth < Raster.depthBuffer[dest_off]) {
  1494. dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
  1495. + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
  1496. Raster.depthBuffer[dest_off] = depth;
  1497. }
  1498. depth += depth_slope;
  1499. dest_off++;
  1500. if (depth < Raster.depthBuffer[dest_off]) {
  1501. dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
  1502. + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
  1503. Raster.depthBuffer[dest_off] = depth;
  1504. }
  1505. depth += depth_slope;
  1506. dest_off++;
  1507. if (depth < Raster.depthBuffer[dest_off]) {
  1508. dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
  1509. + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
  1510. Raster.depthBuffer[dest_off] = depth;
  1511. }
  1512. depth += depth_slope;
  1513.  
  1514. }
  1515. for (loops = end_x - start_x & 3; --loops >= 0;) {
  1516. dest_off++;
  1517. if (depth < Raster.depthBuffer[dest_off]) {
  1518. dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
  1519. + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
  1520. Raster.depthBuffer[dest_off] = depth;
  1521. }
  1522. depth += depth_slope;
  1523. }
  1524. }
  1525.  
  1526. private static int anInt2229;
  1527. private static int anInt2230;
  1528. private static int anInt2232;
  1529. private static int anInt2243;
  1530.  
  1531. 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,
  1532. 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,
  1533. float z_b, float z_c) {
  1534. if (z_a < 0 || z_b < 0 || z_c < 0)
  1535. return;
  1536. int texture[] = method371(k4);
  1537. aBoolean1463 = !aBooleanArray1475[k4];
  1538. Mx = Px - Mx;
  1539. Mz = Pz - Mz;
  1540. My = Py - My;
  1541. Nx -= Px;
  1542. Nz -= Pz;
  1543. Ny -= Py;
  1544. int Oa = Nx * Pz - Nz * Px << (Client.log_view_dist == 9 ? 14 : 15);
  1545. int Ha = Nz * Py - Ny * Pz << 8;
  1546. int Va = Ny * Px - Nx * Py << 5;
  1547. int Ob = Mx * Pz - Mz * Px << (Client.log_view_dist == 9 ? 14 : 15);
  1548. int Hb = Mz * Py - My * Pz << 8;
  1549. int Vb = My * Px - Mx * Py << 5;
  1550. int Oc = Mz * Nx - Mx * Nz << (Client.log_view_dist == 9 ? 14 : 15);
  1551. int Hc = My * Nz - Mz * Ny << 8;
  1552. int Vc = Mx * Ny - My * Nx << 5;
  1553. int a_to_b = 0;
  1554. int grad_a_off = 0;
  1555. if (y_b != y_a) {
  1556. a_to_b = (x_b - x_a << 16) / (y_b - y_a);
  1557. grad_a_off = (l1 - k1 << 16) / (y_b - y_a);
  1558. }
  1559. int b_to_c = 0;
  1560. int grad_b_off = 0;
  1561. if (y_c != y_b) {
  1562. b_to_c = (x_c - x_b << 16) / (y_c - y_b);
  1563. grad_b_off = (i2 - l1 << 16) / (y_c - y_b);
  1564. }
  1565. int c_to_a = 0;
  1566. int grad_c_off = 0;
  1567. if (y_c != y_a) {
  1568. c_to_a = (x_a - x_c << 16) / (y_a - y_c);
  1569. grad_c_off = (k1 - i2 << 16) / (y_a - y_c);
  1570. }
  1571. float b_aX = x_b - x_a;
  1572. float b_aY = y_b - y_a;
  1573. float c_aX = x_c - x_a;
  1574. float c_aY = y_c - y_a;
  1575. float b_aZ = z_b - z_a;
  1576. float c_aZ = z_c - z_a;
  1577.  
  1578. float div = b_aX * c_aY - c_aX * b_aY;
  1579. float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
  1580. float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
  1581. if (y_a <= y_b && y_a <= y_c) {
  1582. if (y_a >= Raster.bottomY)
  1583. return;
  1584. if (y_b > Raster.bottomY)
  1585. y_b = Raster.bottomY;
  1586. if (y_c > Raster.bottomY)
  1587. y_c = Raster.bottomY;
  1588. z_a = z_a - depth_slope * x_a + depth_slope;
  1589. if (y_b < y_c) {
  1590. x_c = x_a <<= 16;
  1591. i2 = k1 <<= 16;
  1592. if (y_a < 0) {
  1593. x_c -= c_to_a * y_a;
  1594. x_a -= a_to_b * y_a;
  1595. z_a -= depth_increment * y_a;
  1596. i2 -= grad_c_off * y_a;
  1597. k1 -= grad_a_off * y_a;
  1598. y_a = 0;
  1599. }
  1600. x_b <<= 16;
  1601. l1 <<= 16;
  1602. if (y_b < 0) {
  1603. x_b -= b_to_c * y_b;
  1604. l1 -= grad_b_off * y_b;
  1605. y_b = 0;
  1606. }
  1607. int k8 = y_a - centerY;
  1608. Oa += Va * k8;
  1609. Ob += Vb * k8;
  1610. Oc += Vc * k8;
  1611. if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
  1612. y_c -= y_b;
  1613. y_b -= y_a;
  1614. y_a = lineOffsets[y_a];
  1615. while (--y_b >= 0) {
  1616. drawTexturedScanline(Raster.pixels, texture, y_a, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa,
  1617. Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1618. x_c += c_to_a;
  1619. x_a += a_to_b;
  1620. z_a += depth_increment;
  1621. i2 += grad_c_off;
  1622. k1 += grad_a_off;
  1623. y_a += Raster.rasterWidth;
  1624. Oa += Va;
  1625. Ob += Vb;
  1626. Oc += Vc;
  1627. }
  1628. while (--y_c >= 0) {
  1629. drawTexturedScanline(Raster.pixels, texture, y_a, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa,
  1630. Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
  1631. x_c += c_to_a;
  1632. x_b += b_to_c;
  1633. z_a += depth_increment;
  1634. i2 += grad_c_off;
  1635. l1 += grad_b_off;
  1636. y_a += Raster.rasterWidth;
  1637. Oa += Va;
  1638. Ob += Vb;
  1639. Oc += Vc;
  1640. }
  1641. return;
  1642. }
  1643. y_c -= y_b;
  1644. y_b -= y_a;
  1645. y_a = lineOffsets[y_a];
  1646. while (--y_b >= 0) {
  1647. drawTexturedScanline(Raster.pixels, texture, y_a, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa, Ob,
  1648. Oc, Ha, Hb, Hc, z_a, depth_slope);
  1649. x_c += c_to_a;
  1650. x_a += a_to_b;
  1651. z_a += depth_increment;
  1652. i2 += grad_c_off;
  1653. k1 += grad_a_off;
  1654. y_a += Raster.rasterWidth;
  1655. Oa += Va;
  1656. Ob += Vb;
  1657. Oc += Vc;
  1658. }
  1659. while (--y_c >= 0) {
  1660. drawTexturedScanline(Raster.pixels, texture, y_a, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob,
  1661. Oc, Ha, Hb, Hc, z_a, depth_slope);
  1662. x_c += c_to_a;
  1663. x_b += b_to_c;
  1664. z_a += depth_increment;
  1665. i2 += grad_c_off;
  1666. l1 += grad_b_off;
  1667. y_a += Raster.rasterWidth;
  1668. Oa += Va;
  1669. Ob += Vb;
  1670. Oc += Vc;
  1671. }
  1672. return;
  1673. }
  1674. x_b = x_a <<= 16;
  1675. l1 = k1 <<= 16;
  1676. if (y_a < 0) {
  1677. x_b -= c_to_a * y_a;
  1678. x_a -= a_to_b * y_a;
  1679. z_a -= depth_increment * y_a;
  1680. l1 -= grad_c_off * y_a;
  1681. k1 -= grad_a_off * y_a;
  1682. y_a = 0;
  1683. }
  1684. x_c <<= 16;
  1685. i2 <<= 16;
  1686. if (y_c < 0) {
  1687. x_c -= b_to_c * y_c;
  1688. i2 -= grad_b_off * y_c;
  1689. y_c = 0;
  1690. }
  1691. int l8 = y_a - centerY;
  1692. Oa += Va * l8;
  1693. Ob += Vb * l8;
  1694. Oc += Vc * l8;
  1695. if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
  1696. y_b -= y_c;
  1697. y_c -= y_a;
  1698. y_a = lineOffsets[y_a];
  1699. while (--y_c >= 0) {
  1700. drawTexturedScanline(Raster.pixels, texture, y_a, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob,
  1701. Oc, Ha, Hb, Hc, z_a, depth_slope);
  1702. x_b += c_to_a;
  1703. x_a += a_to_b;
  1704. l1 += grad_c_off;
  1705. k1 += grad_a_off;
  1706. z_a += depth_increment;
  1707. y_a += Raster.rasterWidth;
  1708. Oa += Va;
  1709. Ob += Vb;
  1710. Oc += Vc;
  1711. }
  1712. while (--y_b >= 0) {
  1713. drawTexturedScanline(Raster.pixels, texture, y_a, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob,
  1714. Oc, Ha, Hb, Hc, z_a, depth_slope);
  1715. x_c += b_to_c;
  1716. x_a += a_to_b;
  1717. i2 += grad_b_off;
  1718. k1 += grad_a_off;
  1719. z_a += depth_increment;
  1720. y_a += Raster.rasterWidth;
  1721. Oa += Va;
  1722. Ob += Vb;
  1723. Oc += Vc;
  1724. }
  1725. return;
  1726. }
  1727. y_b -= y_c;
  1728. y_c -= y_a;
  1729. y_a = lineOffsets[y_a];
  1730. while (--y_c >= 0) {
  1731. drawTexturedScanline(Raster.pixels, texture, y_a, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa, Ob, Oc,
  1732. Ha, Hb, Hc, z_a, depth_slope);
  1733. x_b += c_to_a;
  1734. x_a += a_to_b;
  1735. l1 += grad_c_off;
  1736. k1 += grad_a_off;
  1737. z_a += depth_increment;
  1738. y_a += Raster.rasterWidth;
  1739. Oa += Va;
  1740. Ob += Vb;
  1741. Oc += Vc;
  1742. }
  1743. while (--y_b >= 0) {
  1744. drawTexturedScanline(Raster.pixels, texture, y_a, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa, Ob, Oc,
  1745. Ha, Hb, Hc, z_a, depth_slope);
  1746. x_c += b_to_c;
  1747. x_a += a_to_b;
  1748. i2 += grad_b_off;
  1749. k1 += grad_a_off;
  1750. z_a += depth_increment;
  1751. y_a += Raster.rasterWidth;
  1752. Oa += Va;
  1753. Ob += Vb;
  1754. Oc += Vc;
  1755. }
  1756. return;
  1757. }
  1758. if (y_b <= y_c) {
  1759. if (y_b >= Raster.bottomY)
  1760. return;
  1761. if (y_c > Raster.bottomY)
  1762. y_c = Raster.bottomY;
  1763. if (y_a > Raster.bottomY)
  1764. y_a = Raster.bottomY;
  1765. z_b = z_b - depth_slope * x_b + depth_slope;
  1766. if (y_c < y_a) {
  1767. x_a = x_b <<= 16;
  1768. k1 = l1 <<= 16;
  1769. if (y_b < 0) {
  1770. x_a -= a_to_b * y_b;
  1771. x_b -= b_to_c * y_b;
  1772. z_b -= depth_increment * y_b;
  1773. k1 -= grad_a_off * y_b;
  1774. l1 -= grad_b_off * y_b;
  1775. y_b = 0;
  1776. }
  1777. x_c <<= 16;
  1778. i2 <<= 16;
  1779. if (y_c < 0) {
  1780. x_c -= c_to_a * y_c;
  1781. i2 -= grad_c_off * y_c;
  1782. y_c = 0;
  1783. }
  1784. int i9 = y_b - centerY;
  1785. Oa += Va * i9;
  1786. Ob += Vb * i9;
  1787. Oc += Vc * i9;
  1788. if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
  1789. y_a -= y_c;
  1790. y_c -= y_b;
  1791. y_b = lineOffsets[y_b];
  1792. while (--y_c >= 0) {
  1793. drawTexturedScanline(Raster.pixels, texture, y_b, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa,
  1794. Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1795. x_a += a_to_b;
  1796. x_b += b_to_c;
  1797. k1 += grad_a_off;
  1798. l1 += grad_b_off;
  1799. z_b += depth_increment;
  1800. y_b += Raster.rasterWidth;
  1801. Oa += Va;
  1802. Ob += Vb;
  1803. Oc += Vc;
  1804. }
  1805. while (--y_a >= 0) {
  1806. drawTexturedScanline(Raster.pixels, texture, y_b, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa,
  1807. Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
  1808. x_a += a_to_b;
  1809. x_c += c_to_a;
  1810. k1 += grad_a_off;
  1811. i2 += grad_c_off;
  1812. z_b += depth_increment;
  1813. y_b += Raster.rasterWidth;
  1814. Oa += Va;
  1815. Ob += Vb;
  1816. Oc += Vc;
  1817. }
  1818. return;
  1819. }
  1820. y_a -= y_c;
  1821. y_c -= y_b;
  1822. y_b = lineOffsets[y_b];
  1823. while (--y_c >= 0) {
  1824. drawTexturedScanline(Raster.pixels, texture, y_b, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob,
  1825. Oc, Ha, Hb, Hc, z_b, depth_slope);
  1826. x_a += a_to_b;
  1827. x_b += b_to_c;
  1828. k1 += grad_a_off;
  1829. l1 += grad_b_off;
  1830. z_b += depth_increment;
  1831. y_b += Raster.rasterWidth;
  1832. Oa += Va;
  1833. Ob += Vb;
  1834. Oc += Vc;
  1835. }
  1836. while (--y_a >= 0) {
  1837. drawTexturedScanline(Raster.pixels, texture, y_b, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob,
  1838. Oc, Ha, Hb, Hc, z_b, depth_slope);
  1839. x_a += a_to_b;
  1840. x_c += c_to_a;
  1841. k1 += grad_a_off;
  1842. i2 += grad_c_off;
  1843. z_b += depth_increment;
  1844. y_b += Raster.rasterWidth;
  1845. Oa += Va;
  1846. Ob += Vb;
  1847. Oc += Vc;
  1848. }
  1849. return;
  1850. }
  1851. x_c = x_b <<= 16;
  1852. i2 = l1 <<= 16;
  1853. if (y_b < 0) {
  1854. x_c -= a_to_b * y_b;
  1855. x_b -= b_to_c * y_b;
  1856. z_b -= depth_increment * y_b;
  1857. i2 -= grad_a_off * y_b;
  1858. l1 -= grad_b_off * y_b;
  1859. y_b = 0;
  1860. }
  1861. x_a <<= 16;
  1862. k1 <<= 16;
  1863. if (y_a < 0) {
  1864. x_a -= c_to_a * y_a;
  1865. k1 -= grad_c_off * y_a;
  1866. y_a = 0;
  1867. }
  1868. int j9 = y_b - centerY;
  1869. Oa += Va * j9;
  1870. Ob += Vb * j9;
  1871. Oc += Vc * j9;
  1872. if (a_to_b < b_to_c) {
  1873. y_c -= y_a;
  1874. y_a -= y_b;
  1875. y_b = lineOffsets[y_b];
  1876. while (--y_a >= 0) {
  1877. drawTexturedScanline(Raster.pixels, texture, y_b, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob,
  1878. Oc, Ha, Hb, Hc, z_b, depth_slope);
  1879. x_c += a_to_b;
  1880. x_b += b_to_c;
  1881. i2 += grad_a_off;
  1882. l1 += grad_b_off;
  1883. z_b += depth_increment;
  1884. y_b += Raster.rasterWidth;
  1885. Oa += Va;
  1886. Ob += Vb;
  1887. Oc += Vc;
  1888. }
  1889. while (--y_c >= 0) {
  1890. drawTexturedScanline(Raster.pixels, texture, y_b, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa, Ob,
  1891. Oc, Ha, Hb, Hc, z_b, depth_slope);
  1892. x_a += c_to_a;
  1893. x_b += b_to_c;
  1894. k1 += grad_c_off;
  1895. l1 += grad_b_off;
  1896. z_b += depth_increment;
  1897. y_b += Raster.rasterWidth;
  1898. Oa += Va;
  1899. Ob += Vb;
  1900. Oc += Vc;
  1901. }
  1902. return;
  1903. }
  1904. y_c -= y_a;
  1905. y_a -= y_b;
  1906. y_b = lineOffsets[y_b];
  1907. while (--y_a >= 0) {
  1908. drawTexturedScanline(Raster.pixels, texture, y_b, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob, Oc,
  1909. Ha, Hb, Hc, z_b, depth_slope);
  1910. x_c += a_to_b;
  1911. x_b += b_to_c;
  1912. i2 += grad_a_off;
  1913. l1 += grad_b_off;
  1914. z_b += depth_increment;
  1915. y_b += Raster.rasterWidth;
  1916. Oa += Va;
  1917. Ob += Vb;
  1918. Oc += Vc;
  1919. }
  1920. while (--y_c >= 0) {
  1921. drawTexturedScanline(Raster.pixels, texture, y_b, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob, Oc,
  1922. Ha, Hb, Hc, z_b, depth_slope);
  1923. x_a += c_to_a;
  1924. x_b += b_to_c;
  1925. k1 += grad_c_off;
  1926. l1 += grad_b_off;
  1927. z_b += depth_increment;
  1928. y_b += Raster.rasterWidth;
  1929. Oa += Va;
  1930. Ob += Vb;
  1931. Oc += Vc;
  1932. }
  1933. return;
  1934. }
  1935. if (y_c >= Raster.bottomY)
  1936. return;
  1937. if (y_a > Raster.bottomY)
  1938. y_a = Raster.bottomY;
  1939. if (y_b > Raster.bottomY)
  1940. y_b = Raster.bottomY;
  1941. z_c = z_c - depth_slope * x_c + depth_slope;
  1942. if (y_a < y_b) {
  1943. x_b = x_c <<= 16;
  1944. l1 = i2 <<= 16;
  1945. if (y_c < 0) {
  1946. x_b -= b_to_c * y_c;
  1947. x_c -= c_to_a * y_c;
  1948. z_c -= depth_increment * y_c;
  1949. l1 -= grad_b_off * y_c;
  1950. i2 -= grad_c_off * y_c;
  1951. y_c = 0;
  1952. }
  1953. x_a <<= 16;
  1954. k1 <<= 16;
  1955. if (y_a < 0) {
  1956. x_a -= a_to_b * y_a;
  1957. k1 -= grad_a_off * y_a;
  1958. y_a = 0;
  1959. }
  1960. int k9 = y_c - centerY;
  1961. Oa += Va * k9;
  1962. Ob += Vb * k9;
  1963. Oc += Vc * k9;
  1964. if (b_to_c < c_to_a) {
  1965. y_b -= y_a;
  1966. y_a -= y_c;
  1967. y_c = lineOffsets[y_c];
  1968. while (--y_a >= 0) {
  1969. drawTexturedScanline(Raster.pixels, texture, y_c, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob,
  1970. Oc, Ha, Hb, Hc, z_c, depth_slope);
  1971. x_b += b_to_c;
  1972. x_c += c_to_a;
  1973. l1 += grad_b_off;
  1974. i2 += grad_c_off;
  1975. z_c += depth_increment;
  1976. y_c += Raster.rasterWidth;
  1977. Oa += Va;
  1978. Ob += Vb;
  1979. Oc += Vc;
  1980. }
  1981. while (--y_b >= 0) {
  1982. drawTexturedScanline(Raster.pixels, texture, y_c, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob,
  1983. Oc, Ha, Hb, Hc, z_c, depth_slope);
  1984. x_b += b_to_c;
  1985. x_a += a_to_b;
  1986. l1 += grad_b_off;
  1987. k1 += grad_a_off;
  1988. z_c += depth_increment;
  1989. y_c += Raster.rasterWidth;
  1990. Oa += Va;
  1991. Ob += Vb;
  1992. Oc += Vc;
  1993. }
  1994. return;
  1995. }
  1996. y_b -= y_a;
  1997. y_a -= y_c;
  1998. y_c = lineOffsets[y_c];
  1999. while (--y_a >= 0) {
  2000. drawTexturedScanline(Raster.pixels, texture, y_c, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob, Oc,
  2001. Ha, Hb, Hc, z_c, depth_slope);
  2002. x_b += b_to_c;
  2003. x_c += c_to_a;
  2004. l1 += grad_b_off;
  2005. i2 += grad_c_off;
  2006. z_c += depth_increment;
  2007. y_c += Raster.rasterWidth;
  2008. Oa += Va;
  2009. Ob += Vb;
  2010. Oc += Vc;
  2011. }
  2012. while (--y_b >= 0) {
  2013. drawTexturedScanline(Raster.pixels, texture, y_c, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa, Ob, Oc,
  2014. Ha, Hb, Hc, z_c, depth_slope);
  2015. x_b += b_to_c;
  2016. x_a += a_to_b;
  2017. l1 += grad_b_off;
  2018. k1 += grad_a_off;
  2019. z_c += depth_increment;
  2020. y_c += Raster.rasterWidth;
  2021. Oa += Va;
  2022. Ob += Vb;
  2023. Oc += Vc;
  2024. }
  2025. return;
  2026. }
  2027. x_a = x_c <<= 16;
  2028. k1 = i2 <<= 16;
  2029. if (y_c < 0) {
  2030. x_a -= b_to_c * y_c;
  2031. x_c -= c_to_a * y_c;
  2032. z_c -= depth_increment * y_c;
  2033. k1 -= grad_b_off * y_c;
  2034. i2 -= grad_c_off * y_c;
  2035. y_c = 0;
  2036. }
  2037. x_b <<= 16;
  2038. l1 <<= 16;
  2039. if (y_b < 0) {
  2040. x_b -= a_to_b * y_b;
  2041. l1 -= grad_a_off * y_b;
  2042. y_b = 0;
  2043. }
  2044. int l9 = y_c - centerY;
  2045. Oa += Va * l9;
  2046. Ob += Vb * l9;
  2047. Oc += Vc * l9;
  2048. if (b_to_c < c_to_a) {
  2049. y_a -= y_b;
  2050. y_b -= y_c;
  2051. y_c = lineOffsets[y_c];
  2052. while (--y_b >= 0) {
  2053. drawTexturedScanline(Raster.pixels, texture, y_c, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa, Ob, Oc,
  2054. Ha, Hb, Hc, z_c, depth_slope);
  2055. x_a += b_to_c;
  2056. x_c += c_to_a;
  2057. k1 += grad_b_off;
  2058. i2 += grad_c_off;
  2059. z_c += depth_increment;
  2060. y_c += Raster.rasterWidth;
  2061. Oa += Va;
  2062. Ob += Vb;
  2063. Oc += Vc;
  2064. }
  2065. while (--y_a >= 0) {
  2066. drawTexturedScanline(Raster.pixels, texture, y_c, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob, Oc,
  2067. Ha, Hb, Hc, z_c, depth_slope);
  2068. x_b += a_to_b;
  2069. x_c += c_to_a;
  2070. l1 += grad_a_off;
  2071. i2 += grad_c_off;
  2072. z_c += depth_increment;
  2073. y_c += Raster.rasterWidth;
  2074. Oa += Va;
  2075. Ob += Vb;
  2076. Oc += Vc;
  2077. }
  2078. return;
  2079. }
  2080. y_a -= y_b;
  2081. y_b -= y_c;
  2082. y_c = lineOffsets[y_c];
  2083. while (--y_b >= 0) {
  2084. drawTexturedScanline(Raster.pixels, texture, y_c, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob, Oc, Ha,
  2085. Hb, Hc, z_c, depth_slope);
  2086. x_a += b_to_c;
  2087. x_c += c_to_a;
  2088. k1 += grad_b_off;
  2089. i2 += grad_c_off;
  2090. z_c += depth_increment;
  2091. y_c += Raster.rasterWidth;
  2092. Oa += Va;
  2093. Ob += Vb;
  2094. Oc += Vc;
  2095. }
  2096. while (--y_a >= 0) {
  2097. drawTexturedScanline(Raster.pixels, texture, y_c, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob, Oc, Ha,
  2098. Hb, Hc, z_c, depth_slope);
  2099. x_b += a_to_b;
  2100. x_c += c_to_a;
  2101. l1 += grad_a_off;
  2102. i2 += grad_c_off;
  2103. z_c += depth_increment;
  2104. y_c += Raster.rasterWidth;
  2105. Oa += Va;
  2106. Ob += Vb;
  2107. Oc += Vc;
  2108. }
  2109. }
  2110.  
  2111. public static void drawTexturedScanline(int dest[], int texture[], int dest_off, int x1, int x2, int shadeValue,
  2112. int gradient, int l1, int i2, int j2, int k2, int l2, int i3, float z1, float z2) {
  2113. int rgb = 0;
  2114. int loops = 0;
  2115. if (x1 >= x2)
  2116. return;
  2117. int j3;
  2118. int k3;
  2119. if (restrict_edges) {
  2120. j3 = (gradient - shadeValue) / (x2 - x1);
  2121. if (x2 > Raster.viewportRx)
  2122. x2 = Raster.viewportRx;
  2123. if (x1 < 0) {
  2124. shadeValue -= x1 * j3;
  2125. x1 = 0;
  2126. }
  2127. if (x1 >= x2)
  2128. return;
  2129. k3 = x2 - x1 >> 3;
  2130. j3 <<= 12;
  2131. shadeValue <<= 9;
  2132. } else {
  2133. if (x2 - x1 > 7) {
  2134. k3 = x2 - x1 >> 3;
  2135. j3 = (gradient - shadeValue) * anIntArray1468[k3] >> 6;
  2136. } else {
  2137. k3 = 0;
  2138. j3 = 0;
  2139. }
  2140. shadeValue <<= 9;
  2141. }
  2142. dest_off += x1;
  2143. z1 += z2 * (float) x1;
  2144. if (lowDetail) {
  2145. int i4 = 0;
  2146. int k4 = 0;
  2147. int k6 = x1 - centerX;
  2148. l1 += (k2 >> 3) * k6;
  2149. i2 += (l2 >> 3) * k6;
  2150. j2 += (i3 >> 3) * k6;
  2151. int i5 = j2 >> 12;
  2152. if (i5 != 0) {
  2153. rgb = l1 / i5;
  2154. loops = i2 / i5;
  2155. if (rgb < 0)
  2156. rgb = 0;
  2157. else if (rgb > 4032)
  2158. rgb = 4032;
  2159. }
  2160. l1 += k2;
  2161. i2 += l2;
  2162. j2 += i3;
  2163. i5 = j2 >> 12;
  2164. if (i5 != 0) {
  2165. i4 = l1 / i5;
  2166. k4 = i2 / i5;
  2167. if (i4 < 7)
  2168. i4 = 7;
  2169. else if (i4 > 4032)
  2170. i4 = 4032;
  2171. }
  2172. int i7 = i4 - rgb >> 3;
  2173. int k7 = k4 - loops >> 3;
  2174. rgb += (shadeValue & 0x600000) >> 3;
  2175. int i8 = shadeValue >> 23;
  2176. if (aBoolean1463) {
  2177. while (k3-- > 0) {
  2178. for (int i = 0; i < 8; i++) {
  2179. if (z1 < Raster.depthBuffer[dest_off]) {
  2180. dest[dest_off] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
  2181. Raster.depthBuffer[dest_off] = z1;
  2182. }
  2183. dest_off++;
  2184. z1 += z2;
  2185. rgb += i7;
  2186. loops += k7;
  2187. }
  2188. rgb = i4;
  2189. loops = k4;
  2190. l1 += k2;
  2191. i2 += l2;
  2192. j2 += i3;
  2193. int j5 = j2 >> 12;
  2194. if (j5 != 0) {
  2195. i4 = l1 / j5;
  2196. k4 = i2 / j5;
  2197. if (i4 < 7)
  2198. i4 = 7;
  2199. else if (i4 > 4032)
  2200. i4 = 4032;
  2201. }
  2202. i7 = i4 - rgb >> 3;
  2203. k7 = k4 - loops >> 3;
  2204. shadeValue += j3;
  2205. rgb += (shadeValue & 0x600000) >> 3;
  2206. i8 = shadeValue >> 23;
  2207. }
  2208. for (k3 = x2 - x1 & 7; k3-- > 0;) {
  2209. if (z1 < Raster.depthBuffer[dest_off]) {
  2210. dest[dest_off] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
  2211. Raster.depthBuffer[dest_off] = z1;
  2212. }
  2213. dest_off++;
  2214. z1 += z2;
  2215. rgb += i7;
  2216. loops += k7;
  2217. }
  2218.  
  2219. return;
  2220. }
  2221. while (k3-- > 0) {
  2222. int k8;
  2223. for (int i = 0; i < 8; i++) {
  2224. if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
  2225. dest[dest_off] = k8;
  2226. Raster.depthBuffer[dest_off] = z1;
  2227. }
  2228. dest_off++;
  2229. z1 += z2;
  2230. rgb += i7;
  2231. loops += k7;
  2232. }
  2233.  
  2234. rgb = i4;
  2235. loops = k4;
  2236. l1 += k2;
  2237. i2 += l2;
  2238. j2 += i3;
  2239. int k5 = j2 >> 12;
  2240. if (k5 != 0) {
  2241. i4 = l1 / k5;
  2242. k4 = i2 / k5;
  2243. if (i4 < 7)
  2244. i4 = 7;
  2245. else if (i4 > 4032)
  2246. i4 = 4032;
  2247. }
  2248. i7 = i4 - rgb >> 3;
  2249. k7 = k4 - loops >> 3;
  2250. shadeValue += j3;
  2251. rgb += (shadeValue & 0x600000) >> 3;
  2252. i8 = shadeValue >> 23;
  2253. }
  2254. for (k3 = x2 - x1 & 7; k3-- > 0;) {
  2255. int l8;
  2256. if ((l8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
  2257. dest[dest_off] = l8;
  2258. Raster.depthBuffer[dest_off] = z1;
  2259. }
  2260. dest_off++;
  2261. z1 += z2;
  2262. rgb += i7;
  2263. loops += k7;
  2264. }
  2265.  
  2266. return;
  2267. }
  2268. int j4 = 0;
  2269. int l4 = 0;
  2270. int l6 = x1 - centerX;
  2271. l1 += (k2 >> 3) * l6;
  2272. i2 += (l2 >> 3) * l6;
  2273. j2 += (i3 >> 3) * l6;
  2274. int l5 = j2 >> 14;
  2275. if (l5 != 0) {
  2276. rgb = l1 / l5;
  2277. loops = i2 / l5;
  2278. if (rgb < 0)
  2279. rgb = 0;
  2280. else if (rgb > 16256)
  2281. rgb = 16256;
  2282. }
  2283. l1 += k2;
  2284. i2 += l2;
  2285. j2 += i3;
  2286. l5 = j2 >> 14;
  2287. if (l5 != 0) {
  2288. j4 = l1 / l5;
  2289. l4 = i2 / l5;
  2290. if (j4 < 7)
  2291. j4 = 7;
  2292. else if (j4 > 16256)
  2293. j4 = 16256;
  2294. }
  2295. int j7 = j4 - rgb >> 3;
  2296. int l7 = l4 - loops >> 3;
  2297. rgb += shadeValue & 0x600000;
  2298. int j8 = shadeValue >> 23;
  2299. if (aBoolean1463) {
  2300. while (k3-- > 0) {
  2301. for (int i = 0; i < 8; i++) {
  2302. if (z1 < Raster.depthBuffer[dest_off]) {
  2303. dest[dest_off] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
  2304. Raster.depthBuffer[dest_off] = z1;
  2305. }
  2306. z1 += z2;
  2307. dest_off++;
  2308. rgb += j7;
  2309. loops += l7;
  2310. }
  2311. rgb = j4;
  2312. loops = l4;
  2313. l1 += k2;
  2314. i2 += l2;
  2315. j2 += i3;
  2316. int i6 = j2 >> 14;
  2317. if (i6 != 0) {
  2318. j4 = l1 / i6;
  2319. l4 = i2 / i6;
  2320. if (j4 < 7)
  2321. j4 = 7;
  2322. else if (j4 > 16256)
  2323. j4 = 16256;
  2324. }
  2325. j7 = j4 - rgb >> 3;
  2326. l7 = l4 - loops >> 3;
  2327. shadeValue += j3;
  2328. rgb += shadeValue & 0x600000;
  2329. j8 = shadeValue >> 23;
  2330. }
  2331. for (k3 = x2 - x1 & 7; k3-- > 0;) {
  2332. if (z1 < Raster.depthBuffer[dest_off]) {
  2333. dest[dest_off] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
  2334. Raster.depthBuffer[dest_off] = z1;
  2335. }
  2336. dest_off++;
  2337. z1 += z2;
  2338. rgb += j7;
  2339. loops += l7;
  2340. }
  2341.  
  2342. return;
  2343. }
  2344. while (k3-- > 0) {
  2345. int i9;
  2346. for (int i = 0; i < 8; i++) {
  2347. if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
  2348. dest[dest_off] = i9;
  2349. Raster.depthBuffer[dest_off] = z1;
  2350. }
  2351. dest_off++;
  2352. z1 += z2;
  2353. rgb += j7;
  2354. loops += l7;
  2355. }
  2356. rgb = j4;
  2357. loops = l4;
  2358. l1 += k2;
  2359. i2 += l2;
  2360. j2 += i3;
  2361. int j6 = j2 >> 14;
  2362. if (j6 != 0) {
  2363. j4 = l1 / j6;
  2364. l4 = i2 / j6;
  2365. if (j4 < 7)
  2366. j4 = 7;
  2367. else if (j4 > 16256)
  2368. j4 = 16256;
  2369. }
  2370. j7 = j4 - rgb >> 3;
  2371. l7 = l4 - loops >> 3;
  2372. shadeValue += j3;
  2373. rgb += shadeValue & 0x600000;
  2374. j8 = shadeValue >> 23;
  2375. }
  2376. for (int l3 = x2 - x1 & 7; l3-- > 0;) {
  2377. int j9;
  2378. if ((j9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
  2379. dest[dest_off] = j9;
  2380. Raster.depthBuffer[dest_off] = z1;
  2381. }
  2382. z1 += z2;
  2383. dest_off++;
  2384. rgb += j7;
  2385. loops += l7;
  2386. }
  2387. }
  2388.  
  2389. public static void method374(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
  2390. int j2 = 0;
  2391. int k2 = 0;
  2392.  
  2393. if (j != i) {
  2394. j2 = (i1 - l << 16) / (j - i);
  2395. k2 = (l1 - k1 << 15) / (j - i);
  2396. }
  2397. int l2 = 0;
  2398. int i3 = 0;
  2399. if (k != j) {
  2400. l2 = (j1 - i1 << 16) / (k - j);
  2401. i3 = (i2 - l1 << 15) / (k - j);
  2402. }
  2403. int j3 = 0;
  2404. int k3 = 0;
  2405. if (k != i) {
  2406. j3 = (l - j1 << 16) / (i - k);
  2407. k3 = (k1 - i2 << 15) / (i - k);
  2408. }
  2409. if (i <= j && i <= k) {
  2410. if (i >= Raster.bottomY)
  2411. return;
  2412. if (j > Raster.bottomY)
  2413. j = Raster.bottomY;
  2414. if (k > Raster.bottomY)
  2415. k = Raster.bottomY;
  2416. if (j < k) {
  2417. j1 = l <<= 16;
  2418. i2 = k1 <<= 15;
  2419. if (i < 0) {
  2420. j1 -= j3 * i;
  2421. l -= j2 * i;
  2422. i2 -= k3 * i;
  2423. k1 -= k2 * i;
  2424. i = 0;
  2425. }
  2426. i1 <<= 16;
  2427. l1 <<= 15;
  2428. if (j < 0) {
  2429. i1 -= l2 * j;
  2430. l1 -= i3 * j;
  2431. j = 0;
  2432. }
  2433. if (i != j && j3 < j2 || i == j && j3 > l2) {
  2434. k -= j;
  2435. j -= i;
  2436. for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
  2437. method375(Raster.pixels, i, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
  2438. j1 += j3;
  2439. l += j2;
  2440. i2 += k3;
  2441. k1 += k2;
  2442. }
  2443.  
  2444. while (--k >= 0) {
  2445. method375(Raster.pixels, i, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
  2446. j1 += j3;
  2447. i1 += l2;
  2448. i2 += k3;
  2449. l1 += i3;
  2450. i += Raster.rasterWidth;
  2451. }
  2452. return;
  2453. }
  2454. k -= j;
  2455. j -= i;
  2456. for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
  2457. method375(Raster.pixels, i, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
  2458. j1 += j3;
  2459. l += j2;
  2460. i2 += k3;
  2461. k1 += k2;
  2462. }
  2463.  
  2464. while (--k >= 0) {
  2465. method375(Raster.pixels, i, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
  2466. j1 += j3;
  2467. i1 += l2;
  2468. i2 += k3;
  2469. l1 += i3;
  2470. i += Raster.rasterWidth;
  2471. }
  2472. return;
  2473. }
  2474. i1 = l <<= 16;
  2475. l1 = k1 <<= 15;
  2476. if (i < 0) {
  2477. i1 -= j3 * i;
  2478. l -= j2 * i;
  2479. l1 -= k3 * i;
  2480. k1 -= k2 * i;
  2481. i = 0;
  2482. }
  2483. j1 <<= 16;
  2484. i2 <<= 15;
  2485. if (k < 0) {
  2486. j1 -= l2 * k;
  2487. i2 -= i3 * k;
  2488. k = 0;
  2489. }
  2490. if (i != k && j3 < j2 || i == k && l2 > j2) {
  2491. j -= k;
  2492. k -= i;
  2493. for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
  2494. method375(Raster.pixels, i, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
  2495. i1 += j3;
  2496. l += j2;
  2497. l1 += k3;
  2498. k1 += k2;
  2499. }
  2500.  
  2501. while (--j >= 0) {
  2502. method375(Raster.pixels, i, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
  2503. j1 += l2;
  2504. l += j2;
  2505. i2 += i3;
  2506. k1 += k2;
  2507. i += Raster.rasterWidth;
  2508. }
  2509. return;
  2510. }
  2511. j -= k;
  2512. k -= i;
  2513. for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
  2514. method375(Raster.pixels, i, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
  2515. i1 += j3;
  2516. l += j2;
  2517. l1 += k3;
  2518. k1 += k2;
  2519. }
  2520.  
  2521. while (--j >= 0) {
  2522. method375(Raster.pixels, i, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
  2523. j1 += l2;
  2524. l += j2;
  2525. i2 += i3;
  2526. k1 += k2;
  2527. i += Raster.rasterWidth;
  2528. }
  2529. return;
  2530. }
  2531. if (j <= k) {
  2532. if (j >= Raster.bottomY)
  2533. return;
  2534. if (k > Raster.bottomY)
  2535. k = Raster.bottomY;
  2536. if (i > Raster.bottomY)
  2537. i = Raster.bottomY;
  2538. if (k < i) {
  2539. l = i1 <<= 16;
  2540. k1 = l1 <<= 15;
  2541. if (j < 0) {
  2542. l -= j2 * j;
  2543. i1 -= l2 * j;
  2544. k1 -= k2 * j;
  2545. l1 -= i3 * j;
  2546. j = 0;
  2547. }
  2548. j1 <<= 16;
  2549. i2 <<= 15;
  2550. if (k < 0) {
  2551. j1 -= j3 * k;
  2552. i2 -= k3 * k;
  2553. k = 0;
  2554. }
  2555. if (j != k && j2 < l2 || j == k && j2 > j3) {
  2556. i -= k;
  2557. k -= j;
  2558. for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
  2559. method375(Raster.pixels, j, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
  2560. l += j2;
  2561. i1 += l2;
  2562. k1 += k2;
  2563. l1 += i3;
  2564. }
  2565.  
  2566. while (--i >= 0) {
  2567. method375(Raster.pixels, j, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
  2568. l += j2;
  2569. j1 += j3;
  2570. k1 += k2;
  2571. i2 += k3;
  2572. j += Raster.rasterWidth;
  2573. }
  2574. return;
  2575. }
  2576. i -= k;
  2577. k -= j;
  2578. for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
  2579. method375(Raster.pixels, j, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
  2580. l += j2;
  2581. i1 += l2;
  2582. k1 += k2;
  2583. l1 += i3;
  2584. }
  2585.  
  2586. while (--i >= 0) {
  2587. method375(Raster.pixels, j, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
  2588. l += j2;
  2589. j1 += j3;
  2590. k1 += k2;
  2591. i2 += k3;
  2592. j += Raster.rasterWidth;
  2593. }
  2594. return;
  2595. }
  2596. j1 = i1 <<= 16;
  2597. i2 = l1 <<= 15;
  2598. if (j < 0) {
  2599. j1 -= j2 * j;
  2600. i1 -= l2 * j;
  2601. i2 -= k2 * j;
  2602. l1 -= i3 * j;
  2603. j = 0;
  2604. }
  2605. l <<= 16;
  2606. k1 <<= 15;
  2607. if (i < 0) {
  2608. l -= j3 * i;
  2609. k1 -= k3 * i;
  2610. i = 0;
  2611. }
  2612. if (j2 < l2) {
  2613. k -= i;
  2614. i -= j;
  2615. for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
  2616. method375(Raster.pixels, j, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
  2617. j1 += j2;
  2618. i1 += l2;
  2619. i2 += k2;
  2620. l1 += i3;
  2621. }
  2622.  
  2623. while (--k >= 0) {
  2624. method375(Raster.pixels, j, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
  2625. l += j3;
  2626. i1 += l2;
  2627. k1 += k3;
  2628. l1 += i3;
  2629. j += Raster.rasterWidth;
  2630. }
  2631. return;
  2632. }
  2633. k -= i;
  2634. i -= j;
  2635. for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
  2636. method375(Raster.pixels, j, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
  2637. j1 += j2;
  2638. i1 += l2;
  2639. i2 += k2;
  2640. l1 += i3;
  2641. }
  2642.  
  2643. while (--k >= 0) {
  2644. method375(Raster.pixels, j, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
  2645. l += j3;
  2646. i1 += l2;
  2647. k1 += k3;
  2648. l1 += i3;
  2649. j += Raster.rasterWidth;
  2650. }
  2651. return;
  2652. }
  2653. if (k >= Raster.bottomY)
  2654. return;
  2655. if (i > Raster.bottomY)
  2656. i = Raster.bottomY;
  2657. if (j > Raster.bottomY)
  2658. j = Raster.bottomY;
  2659. if (i < j) {
  2660. i1 = j1 <<= 16;
  2661. l1 = i2 <<= 15;
  2662. if (k < 0) {
  2663. i1 -= l2 * k;
  2664. j1 -= j3 * k;
  2665. l1 -= i3 * k;
  2666. i2 -= k3 * k;
  2667. k = 0;
  2668. }
  2669. l <<= 16;
  2670. k1 <<= 15;
  2671. if (i < 0) {
  2672. l -= j2 * i;
  2673. k1 -= k2 * i;
  2674. i = 0;
  2675. }
  2676. if (l2 < j3) {
  2677. j -= i;
  2678. i -= k;
  2679. for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
  2680. method375(Raster.pixels, k, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
  2681. i1 += l2;
  2682. j1 += j3;
  2683. l1 += i3;
  2684. i2 += k3;
  2685. }
  2686.  
  2687. while (--j >= 0) {
  2688. method375(Raster.pixels, k, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
  2689. i1 += l2;
  2690. l += j2;
  2691. l1 += i3;
  2692. k1 += k2;
  2693. k += Raster.rasterWidth;
  2694. }
  2695. return;
  2696. }
  2697. j -= i;
  2698. i -= k;
  2699. for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
  2700. method375(Raster.pixels, k, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
  2701. i1 += l2;
  2702. j1 += j3;
  2703. l1 += i3;
  2704. i2 += k3;
  2705. }
  2706.  
  2707. while (--j >= 0) {
  2708. method375(Raster.pixels, k, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
  2709. i1 += l2;
  2710. l += j2;
  2711. l1 += i3;
  2712. k1 += k2;
  2713. k += Raster.rasterWidth;
  2714. }
  2715. return;
  2716. }
  2717. l = j1 <<= 16;
  2718. k1 = i2 <<= 15;
  2719. if (k < 0) {
  2720. l -= l2 * k;
  2721. j1 -= j3 * k;
  2722. k1 -= i3 * k;
  2723. i2 -= k3 * k;
  2724. k = 0;
  2725. }
  2726. i1 <<= 16;
  2727. l1 <<= 15;
  2728. if (j < 0) {
  2729. i1 -= j2 * j;
  2730. l1 -= k2 * j;
  2731. j = 0;
  2732. }
  2733. if (l2 < j3) {
  2734. i -= j;
  2735. j -= k;
  2736. for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
  2737. method375(Raster.pixels, k, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
  2738. l += l2;
  2739. j1 += j3;
  2740. k1 += i3;
  2741. i2 += k3;
  2742. }
  2743.  
  2744. while (--i >= 0) {
  2745. method375(Raster.pixels, k, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
  2746. i1 += j2;
  2747. j1 += j3;
  2748. l1 += k2;
  2749. i2 += k3;
  2750. k += Raster.rasterWidth;
  2751. }
  2752. return;
  2753. }
  2754. i -= j;
  2755. j -= k;
  2756. for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
  2757. method375(Raster.pixels, k, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
  2758. l += l2;
  2759. j1 += j3;
  2760. k1 += i3;
  2761. i2 += k3;
  2762. }
  2763.  
  2764. while (--i >= 0) {
  2765. method375(Raster.pixels, k, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
  2766. i1 += j2;
  2767. j1 += j3;
  2768. l1 += k2;
  2769. i2 += k3;
  2770. k += Raster.rasterWidth;
  2771. }
  2772. }
  2773.  
  2774. public static void method375(int[] ai, int i, int l, int i1, int j1, int k1) {
  2775. int j;
  2776. int k;
  2777. int l1 = 0;
  2778.  
  2779. if (restrict_edges) {
  2780. if (i1 > Raster.viewportRx)
  2781. i1 = Raster.viewportRx;
  2782. if (l < 0) {
  2783. j1 -= l * l1;
  2784. l = 0;
  2785. }
  2786. }
  2787. if (l < i1) {
  2788. i += l;
  2789. j1 += l1 * l;
  2790. if (notTextured) {
  2791. k = i1 - l >> 2;
  2792. if (k > 0)
  2793. l1 = (k1 - j1) * anIntArray1468[k] >> 15;
  2794. else
  2795. l1 = 0;
  2796. if (alpha == 0) {
  2797. if (k > 0) {
  2798. do {
  2799. j = hsl2rgb[j1 >> 8];
  2800. j1 += l1;
  2801. ai[i++] = j;
  2802. ai[i++] = j;
  2803. ai[i++] = j;
  2804. ai[i++] = j;
  2805. } while (--k > 0);
  2806. }
  2807. k = i1 - l & 0x3;
  2808. if (k > 0) {
  2809. j = hsl2rgb[j1 >> 8];
  2810. do
  2811. ai[i++] = j;
  2812. while (--k > 0);
  2813. }
  2814. } else {
  2815. int j2 = alpha;
  2816. int l2 = 256 - alpha;
  2817. if (k > 0) {
  2818. do {
  2819. j = hsl2rgb[j1 >> 8];
  2820. j1 += l1;
  2821. j = (((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00));
  2822. int h = ai[i];
  2823. ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
  2824. h = ai[i];
  2825. ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
  2826. h = ai[i];
  2827. ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
  2828. h = ai[i];
  2829. ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
  2830. } while (--k > 0);
  2831. }
  2832. k = i1 - l & 0x3;
  2833. if (k > 0) {
  2834. j = hsl2rgb[j1 >> 8];
  2835. j = (((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00));
  2836. do {
  2837. int i_61_ = ai[i];
  2838. ai[i++] = (j + ((i_61_ & 0xff00ff) * j2 >> 8 & 0xff00ff)
  2839. + ((i_61_ & 0xff00) * j2 >> 8 & 0xff00));
  2840. } while (--k > 0);
  2841. }
  2842. }
  2843. } else {
  2844. int i2 = (k1 - j1) / (i1 - l);
  2845. k = i1 - l;
  2846. if (alpha == 0) {
  2847. do {
  2848. ai[i++] = hsl2rgb[j1 >> 8];
  2849. j1 += i2;
  2850. } while (--k > 0);
  2851. } else {
  2852. int i_62_ = alpha;
  2853. int i_63_ = 256 - alpha;
  2854. do {
  2855. j = hsl2rgb[j1 >> 8];
  2856. j1 += i2;
  2857. j = (((j & 0xff00ff) * i_63_ >> 8 & 0xff00ff) + ((j & 0xff00) * i_63_ >> 8 & 0xff00));
  2858. int i_64_ = ai[i];
  2859. ai[i++] = (j + ((i_64_ & 0xff00ff) * i_62_ >> 8 & 0xff00ff)
  2860. + ((i_64_ & 0xff00) * i_62_ >> 8 & 0xff00));
  2861. } while (--k > 0);
  2862. }
  2863. }
  2864. }
  2865. }
  2866.  
  2867. public static void method376(int i, int j, int k, int l, int i1, int j1, int k1) {
  2868. int l1 = 0;
  2869. if (j != i)
  2870. l1 = (i1 - l << 16) / (j - i);
  2871. int i2 = 0;
  2872. if (k != j)
  2873. i2 = (j1 - i1 << 16) / (k - j);
  2874. int j2 = 0;
  2875. if (k != i)
  2876. j2 = (l - j1 << 16) / (i - k);
  2877. if (i <= j && i <= k) {
  2878. if (i >= Raster.bottomY)
  2879. return;
  2880. if (j > Raster.bottomY)
  2881. j = Raster.bottomY;
  2882. if (k > Raster.bottomY)
  2883. k = Raster.bottomY;
  2884. if (j < k) {
  2885. j1 = l <<= 16;
  2886. if (i < 0) {
  2887. j1 -= j2 * i;
  2888. l -= l1 * i;
  2889. i = 0;
  2890. }
  2891. i1 <<= 16;
  2892. if (j < 0) {
  2893. i1 -= i2 * j;
  2894. j = 0;
  2895. }
  2896. if (i != j && j2 < l1 || i == j && j2 > i2) {
  2897. k -= j;
  2898. j -= i;
  2899. for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
  2900. method377(Raster.pixels, i, k1, j1 >> 16, l >> 16);
  2901. j1 += j2;
  2902. l += l1;
  2903. }
  2904.  
  2905. while (--k >= 0) {
  2906. method377(Raster.pixels, i, k1, j1 >> 16, i1 >> 16);
  2907. j1 += j2;
  2908. i1 += i2;
  2909. i += Raster.rasterWidth;
  2910. }
  2911. return;
  2912. }
  2913. k -= j;
  2914. j -= i;
  2915. for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
  2916. method377(Raster.pixels, i, k1, l >> 16, j1 >> 16);
  2917. j1 += j2;
  2918. l += l1;
  2919. }
  2920.  
  2921. while (--k >= 0) {
  2922. method377(Raster.pixels, i, k1, i1 >> 16, j1 >> 16);
  2923. j1 += j2;
  2924. i1 += i2;
  2925. i += Raster.rasterWidth;
  2926. }
  2927. return;
  2928. }
  2929. i1 = l <<= 16;
  2930. if (i < 0) {
  2931. i1 -= j2 * i;
  2932. l -= l1 * i;
  2933. i = 0;
  2934. }
  2935. j1 <<= 16;
  2936. if (k < 0) {
  2937. j1 -= i2 * k;
  2938. k = 0;
  2939. }
  2940. if (i != k && j2 < l1 || i == k && i2 > l1) {
  2941. j -= k;
  2942. k -= i;
  2943. for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
  2944. method377(Raster.pixels, i, k1, i1 >> 16, l >> 16);
  2945. i1 += j2;
  2946. l += l1;
  2947. }
  2948.  
  2949. while (--j >= 0) {
  2950. method377(Raster.pixels, i, k1, j1 >> 16, l >> 16);
  2951. j1 += i2;
  2952. l += l1;
  2953. i += Raster.rasterWidth;
  2954. }
  2955. return;
  2956. }
  2957. j -= k;
  2958. k -= i;
  2959. for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
  2960. method377(Raster.pixels, i, k1, l >> 16, i1 >> 16);
  2961. i1 += j2;
  2962. l += l1;
  2963. }
  2964.  
  2965. while (--j >= 0) {
  2966. method377(Raster.pixels, i, k1, l >> 16, j1 >> 16);
  2967. j1 += i2;
  2968. l += l1;
  2969. i += Raster.rasterWidth;
  2970. }
  2971. return;
  2972. }
  2973. if (j <= k) {
  2974. if (j >= Raster.bottomY)
  2975. return;
  2976. if (k > Raster.bottomY)
  2977. k = Raster.bottomY;
  2978. if (i > Raster.bottomY)
  2979. i = Raster.bottomY;
  2980. if (k < i) {
  2981. l = i1 <<= 16;
  2982. if (j < 0) {
  2983. l -= l1 * j;
  2984. i1 -= i2 * j;
  2985. j = 0;
  2986. }
  2987. j1 <<= 16;
  2988. if (k < 0) {
  2989. j1 -= j2 * k;
  2990. k = 0;
  2991. }
  2992. if (j != k && l1 < i2 || j == k && l1 > j2) {
  2993. i -= k;
  2994. k -= j;
  2995. for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
  2996. method377(Raster.pixels, j, k1, l >> 16, i1 >> 16);
  2997. l += l1;
  2998. i1 += i2;
  2999. }
  3000.  
  3001. while (--i >= 0) {
  3002. method377(Raster.pixels, j, k1, l >> 16, j1 >> 16);
  3003. l += l1;
  3004. j1 += j2;
  3005. j += Raster.rasterWidth;
  3006. }
  3007. return;
  3008. }
  3009. i -= k;
  3010. k -= j;
  3011. for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
  3012. method377(Raster.pixels, j, k1, i1 >> 16, l >> 16);
  3013. l += l1;
  3014. i1 += i2;
  3015. }
  3016.  
  3017. while (--i >= 0) {
  3018. method377(Raster.pixels, j, k1, j1 >> 16, l >> 16);
  3019. l += l1;
  3020. j1 += j2;
  3021. j += Raster.rasterWidth;
  3022. }
  3023. return;
  3024. }
  3025. j1 = i1 <<= 16;
  3026. if (j < 0) {
  3027. j1 -= l1 * j;
  3028. i1 -= i2 * j;
  3029. j = 0;
  3030. }
  3031. l <<= 16;
  3032. if (i < 0) {
  3033. l -= j2 * i;
  3034. i = 0;
  3035. }
  3036. if (l1 < i2) {
  3037. k -= i;
  3038. i -= j;
  3039. for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
  3040. method377(Raster.pixels, j, k1, j1 >> 16, i1 >> 16);
  3041. j1 += l1;
  3042. i1 += i2;
  3043. }
  3044.  
  3045. while (--k >= 0) {
  3046. method377(Raster.pixels, j, k1, l >> 16, i1 >> 16);
  3047. l += j2;
  3048. i1 += i2;
  3049. j += Raster.rasterWidth;
  3050. }
  3051. return;
  3052. }
  3053. k -= i;
  3054. i -= j;
  3055. for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
  3056. method377(Raster.pixels, j, k1, i1 >> 16, j1 >> 16);
  3057. j1 += l1;
  3058. i1 += i2;
  3059. }
  3060.  
  3061. while (--k >= 0) {
  3062. method377(Raster.pixels, j, k1, i1 >> 16, l >> 16);
  3063. l += j2;
  3064. i1 += i2;
  3065. j += Raster.rasterWidth;
  3066. }
  3067. return;
  3068. }
  3069. if (k >= Raster.bottomY)
  3070. return;
  3071. if (i > Raster.bottomY)
  3072. i = Raster.bottomY;
  3073. if (j > Raster.bottomY)
  3074. j = Raster.bottomY;
  3075. if (i < j) {
  3076. i1 = j1 <<= 16;
  3077. if (k < 0) {
  3078. i1 -= i2 * k;
  3079. j1 -= j2 * k;
  3080. k = 0;
  3081. }
  3082. l <<= 16;
  3083. if (i < 0) {
  3084. l -= l1 * i;
  3085. i = 0;
  3086. }
  3087. if (i2 < j2) {
  3088. j -= i;
  3089. i -= k;
  3090. for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
  3091. method377(Raster.pixels, k, k1, i1 >> 16, j1 >> 16);
  3092. i1 += i2;
  3093. j1 += j2;
  3094. }
  3095.  
  3096. while (--j >= 0) {
  3097. method377(Raster.pixels, k, k1, i1 >> 16, l >> 16);
  3098. i1 += i2;
  3099. l += l1;
  3100. k += Raster.rasterWidth;
  3101. }
  3102. return;
  3103. }
  3104. j -= i;
  3105. i -= k;
  3106. for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
  3107. method377(Raster.pixels, k, k1, j1 >> 16, i1 >> 16);
  3108. i1 += i2;
  3109. j1 += j2;
  3110. }
  3111.  
  3112. while (--j >= 0) {
  3113. method377(Raster.pixels, k, k1, l >> 16, i1 >> 16);
  3114. i1 += i2;
  3115. l += l1;
  3116. k += Raster.rasterWidth;
  3117. }
  3118. return;
  3119. }
  3120. l = j1 <<= 16;
  3121. if (k < 0) {
  3122. l -= i2 * k;
  3123. j1 -= j2 * k;
  3124. k = 0;
  3125. }
  3126. i1 <<= 16;
  3127. if (j < 0) {
  3128. i1 -= l1 * j;
  3129. j = 0;
  3130. }
  3131. if (i2 < j2) {
  3132. i -= j;
  3133. j -= k;
  3134. for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
  3135. method377(Raster.pixels, k, k1, l >> 16, j1 >> 16);
  3136. l += i2;
  3137. j1 += j2;
  3138. }
  3139.  
  3140. while (--i >= 0) {
  3141. method377(Raster.pixels, k, k1, i1 >> 16, j1 >> 16);
  3142. i1 += l1;
  3143. j1 += j2;
  3144. k += Raster.rasterWidth;
  3145. }
  3146. return;
  3147. }
  3148. i -= j;
  3149. j -= k;
  3150. for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
  3151. method377(Raster.pixels, k, k1, j1 >> 16, l >> 16);
  3152. l += i2;
  3153. j1 += j2;
  3154. }
  3155.  
  3156. while (--i >= 0) {
  3157. method377(Raster.pixels, k, k1, j1 >> 16, i1 >> 16);
  3158. i1 += l1;
  3159. j1 += j2;
  3160. k += Raster.rasterWidth;
  3161. }
  3162. }
  3163.  
  3164. private static void method377(int ai[], int i, int j, int l, int i1) {
  3165. int k;// was parameter
  3166. if (restrict_edges) {
  3167. if (i1 > Raster.viewportRx)
  3168. i1 = Raster.viewportRx;
  3169. if (l < 0)
  3170. l = 0;
  3171. }
  3172. if (l >= i1)
  3173. return;
  3174. i += l;
  3175. k = i1 - l >> 2;
  3176. if (alpha == 0) {
  3177. while (--k >= 0) {
  3178. ai[i++] = j;
  3179. ai[i++] = j;
  3180. ai[i++] = j;
  3181. ai[i++] = j;
  3182. }
  3183. for (k = i1 - l & 3; --k >= 0;)
  3184. ai[i++] = j;
  3185.  
  3186. return;
  3187. }
  3188. int j1 = alpha;
  3189. int k1 = 256 - alpha;
  3190. j = ((j & 0xff00ff) * k1 >> 8 & 0xff00ff) + ((j & 0xff00) * k1 >> 8 & 0xff00);
  3191. while (--k >= 0) {
  3192. ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
  3193. ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
  3194. ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
  3195. ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
  3196. }
  3197. for (k = i1 - l & 3; --k >= 0;)
  3198. ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
  3199.  
  3200. }
  3201.  
  3202. public static void method378(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2,
  3203. int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4) {
  3204. int ai[] = method371(k4);
  3205. aBoolean1463 = !aBooleanArray1475[k4];
  3206. k2 = j2 - k2;
  3207. j3 = i3 - j3;
  3208. i4 = l3 - i4;
  3209. l2 -= j2;
  3210. k3 -= i3;
  3211. j4 -= l3;
  3212. int l4 = l2 * i3 - k3 * j2 << (Client.log_view_dist == 9 ? 14 : 15);
  3213. int i5 = k3 * l3 - j4 * i3 << 8;
  3214. int j5 = j4 * j2 - l2 * l3 << 5;
  3215. int k5 = k2 * i3 - j3 * j2 << (Client.log_view_dist == 9 ? 14 : 15);
  3216. int l5 = j3 * l3 - i4 * i3 << 8;
  3217. int i6 = i4 * j2 - k2 * l3 << 5;
  3218. int j6 = j3 * l2 - k2 * k3 << (Client.log_view_dist == 9 ? 14 : 15);
  3219. int k6 = i4 * k3 - j3 * j4 << 8;
  3220. int l6 = k2 * j4 - i4 * l2 << 5;
  3221. int i7 = 0;
  3222. int j7 = 0;
  3223. if (j != i) {
  3224. i7 = (i1 - l << 16) / (j - i);
  3225. j7 = (l1 - k1 << 16) / (j - i);
  3226. }
  3227. int k7 = 0;
  3228. int l7 = 0;
  3229. if (k != j) {
  3230. k7 = (j1 - i1 << 16) / (k - j);
  3231. l7 = (i2 - l1 << 16) / (k - j);
  3232. }
  3233. int i8 = 0;
  3234. int j8 = 0;
  3235. if (k != i) {
  3236. i8 = (l - j1 << 16) / (i - k);
  3237. j8 = (k1 - i2 << 16) / (i - k);
  3238. }
  3239. if (i <= j && i <= k) {
  3240. if (i >= Raster.bottomY)
  3241. return;
  3242. if (j > Raster.bottomY)
  3243. j = Raster.bottomY;
  3244. if (k > Raster.bottomY)
  3245. k = Raster.bottomY;
  3246. if (j < k) {
  3247. j1 = l <<= 16;
  3248. i2 = k1 <<= 16;
  3249. if (i < 0) {
  3250. j1 -= i8 * i;
  3251. l -= i7 * i;
  3252. i2 -= j8 * i;
  3253. k1 -= j7 * i;
  3254. i = 0;
  3255. }
  3256. i1 <<= 16;
  3257. l1 <<= 16;
  3258. if (j < 0) {
  3259. i1 -= k7 * j;
  3260. l1 -= l7 * j;
  3261. j = 0;
  3262. }
  3263. int k8 = i - centerY;
  3264. l4 += j5 * k8;
  3265. k5 += i6 * k8;
  3266. j6 += l6 * k8;
  3267. if (i != j && i8 < i7 || i == j && i8 > k7) {
  3268. k -= j;
  3269. j -= i;
  3270. i = lineOffsets[i];
  3271. while (--j >= 0) {
  3272. method379(Raster.pixels, ai, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3273. j1 += i8;
  3274. l += i7;
  3275. i2 += j8;
  3276. k1 += j7;
  3277. i += Raster.rasterWidth;
  3278. l4 += j5;
  3279. k5 += i6;
  3280. j6 += l6;
  3281. }
  3282. while (--k >= 0) {
  3283. method379(Raster.pixels, ai, i, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3284. j1 += i8;
  3285. i1 += k7;
  3286. i2 += j8;
  3287. l1 += l7;
  3288. i += Raster.rasterWidth;
  3289. l4 += j5;
  3290. k5 += i6;
  3291. j6 += l6;
  3292. }
  3293. return;
  3294. }
  3295. k -= j;
  3296. j -= i;
  3297. i = lineOffsets[i];
  3298. while (--j >= 0) {
  3299. method379(Raster.pixels, ai, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3300. j1 += i8;
  3301. l += i7;
  3302. i2 += j8;
  3303. k1 += j7;
  3304. i += Raster.rasterWidth;
  3305. l4 += j5;
  3306. k5 += i6;
  3307. j6 += l6;
  3308. }
  3309. while (--k >= 0) {
  3310. method379(Raster.pixels, ai, i, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3311. j1 += i8;
  3312. i1 += k7;
  3313. i2 += j8;
  3314. l1 += l7;
  3315. i += Raster.rasterWidth;
  3316. l4 += j5;
  3317. k5 += i6;
  3318. j6 += l6;
  3319. }
  3320. return;
  3321. }
  3322. i1 = l <<= 16;
  3323. l1 = k1 <<= 16;
  3324. if (i < 0) {
  3325. i1 -= i8 * i;
  3326. l -= i7 * i;
  3327. l1 -= j8 * i;
  3328. k1 -= j7 * i;
  3329. i = 0;
  3330. }
  3331. j1 <<= 16;
  3332. i2 <<= 16;
  3333. if (k < 0) {
  3334. j1 -= k7 * k;
  3335. i2 -= l7 * k;
  3336. k = 0;
  3337. }
  3338. int l8 = i - centerY;
  3339. l4 += j5 * l8;
  3340. k5 += i6 * l8;
  3341. j6 += l6 * l8;
  3342. if (i != k && i8 < i7 || i == k && k7 > i7) {
  3343. j -= k;
  3344. k -= i;
  3345. i = lineOffsets[i];
  3346. while (--k >= 0) {
  3347. method379(Raster.pixels, ai, i, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3348. i1 += i8;
  3349. l += i7;
  3350. l1 += j8;
  3351. k1 += j7;
  3352. i += Raster.rasterWidth;
  3353. l4 += j5;
  3354. k5 += i6;
  3355. j6 += l6;
  3356. }
  3357. while (--j >= 0) {
  3358. method379(Raster.pixels, ai, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3359. j1 += k7;
  3360. l += i7;
  3361. i2 += l7;
  3362. k1 += j7;
  3363. i += Raster.rasterWidth;
  3364. l4 += j5;
  3365. k5 += i6;
  3366. j6 += l6;
  3367. }
  3368. return;
  3369. }
  3370. j -= k;
  3371. k -= i;
  3372. i = lineOffsets[i];
  3373. while (--k >= 0) {
  3374. method379(Raster.pixels, ai, i, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3375. i1 += i8;
  3376. l += i7;
  3377. l1 += j8;
  3378. k1 += j7;
  3379. i += Raster.rasterWidth;
  3380. l4 += j5;
  3381. k5 += i6;
  3382. j6 += l6;
  3383. }
  3384. while (--j >= 0) {
  3385. method379(Raster.pixels, ai, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3386. j1 += k7;
  3387. l += i7;
  3388. i2 += l7;
  3389. k1 += j7;
  3390. i += Raster.rasterWidth;
  3391. l4 += j5;
  3392. k5 += i6;
  3393. j6 += l6;
  3394. }
  3395. return;
  3396. }
  3397. if (j <= k) {
  3398. if (j >= Raster.bottomY)
  3399. return;
  3400. if (k > Raster.bottomY)
  3401. k = Raster.bottomY;
  3402. if (i > Raster.bottomY)
  3403. i = Raster.bottomY;
  3404. if (k < i) {
  3405. l = i1 <<= 16;
  3406. k1 = l1 <<= 16;
  3407. if (j < 0) {
  3408. l -= i7 * j;
  3409. i1 -= k7 * j;
  3410. k1 -= j7 * j;
  3411. l1 -= l7 * j;
  3412. j = 0;
  3413. }
  3414. j1 <<= 16;
  3415. i2 <<= 16;
  3416. if (k < 0) {
  3417. j1 -= i8 * k;
  3418. i2 -= j8 * k;
  3419. k = 0;
  3420. }
  3421. int i9 = j - centerY;
  3422. l4 += j5 * i9;
  3423. k5 += i6 * i9;
  3424. j6 += l6 * i9;
  3425. if (j != k && i7 < k7 || j == k && i7 > i8) {
  3426. i -= k;
  3427. k -= j;
  3428. j = lineOffsets[j];
  3429. while (--k >= 0) {
  3430. method379(Raster.pixels, ai, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3431. l += i7;
  3432. i1 += k7;
  3433. k1 += j7;
  3434. l1 += l7;
  3435. j += Raster.rasterWidth;
  3436. l4 += j5;
  3437. k5 += i6;
  3438. j6 += l6;
  3439. }
  3440. while (--i >= 0) {
  3441. method379(Raster.pixels, ai, j, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3442. l += i7;
  3443. j1 += i8;
  3444. k1 += j7;
  3445. i2 += j8;
  3446. j += Raster.rasterWidth;
  3447. l4 += j5;
  3448. k5 += i6;
  3449. j6 += l6;
  3450. }
  3451. return;
  3452. }
  3453. i -= k;
  3454. k -= j;
  3455. j = lineOffsets[j];
  3456. while (--k >= 0) {
  3457. method379(Raster.pixels, ai, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3458. l += i7;
  3459. i1 += k7;
  3460. k1 += j7;
  3461. l1 += l7;
  3462. j += Raster.rasterWidth;
  3463. l4 += j5;
  3464. k5 += i6;
  3465. j6 += l6;
  3466. }
  3467. while (--i >= 0) {
  3468. method379(Raster.pixels, ai, j, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3469. l += i7;
  3470. j1 += i8;
  3471. k1 += j7;
  3472. i2 += j8;
  3473. j += Raster.rasterWidth;
  3474. l4 += j5;
  3475. k5 += i6;
  3476. j6 += l6;
  3477. }
  3478. return;
  3479. }
  3480. j1 = i1 <<= 16;
  3481. i2 = l1 <<= 16;
  3482. if (j < 0) {
  3483. j1 -= i7 * j;
  3484. i1 -= k7 * j;
  3485. i2 -= j7 * j;
  3486. l1 -= l7 * j;
  3487. j = 0;
  3488. }
  3489. l <<= 16;
  3490. k1 <<= 16;
  3491. if (i < 0) {
  3492. l -= i8 * i;
  3493. k1 -= j8 * i;
  3494. i = 0;
  3495. }
  3496. int j9 = j - centerY;
  3497. l4 += j5 * j9;
  3498. k5 += i6 * j9;
  3499. j6 += l6 * j9;
  3500. if (i7 < k7) {
  3501. k -= i;
  3502. i -= j;
  3503. j = lineOffsets[j];
  3504. while (--i >= 0) {
  3505. method379(Raster.pixels, ai, j, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3506. j1 += i7;
  3507. i1 += k7;
  3508. i2 += j7;
  3509. l1 += l7;
  3510. j += Raster.rasterWidth;
  3511. l4 += j5;
  3512. k5 += i6;
  3513. j6 += l6;
  3514. }
  3515. while (--k >= 0) {
  3516. method379(Raster.pixels, ai, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3517. l += i8;
  3518. i1 += k7;
  3519. k1 += j8;
  3520. l1 += l7;
  3521. j += Raster.rasterWidth;
  3522. l4 += j5;
  3523. k5 += i6;
  3524. j6 += l6;
  3525. }
  3526. return;
  3527. }
  3528. k -= i;
  3529. i -= j;
  3530. j = lineOffsets[j];
  3531. while (--i >= 0) {
  3532. method379(Raster.pixels, ai, j, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3533. j1 += i7;
  3534. i1 += k7;
  3535. i2 += j7;
  3536. l1 += l7;
  3537. j += Raster.rasterWidth;
  3538. l4 += j5;
  3539. k5 += i6;
  3540. j6 += l6;
  3541. }
  3542. while (--k >= 0) {
  3543. method379(Raster.pixels, ai, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3544. l += i8;
  3545. i1 += k7;
  3546. k1 += j8;
  3547. l1 += l7;
  3548. j += Raster.rasterWidth;
  3549. l4 += j5;
  3550. k5 += i6;
  3551. j6 += l6;
  3552. }
  3553. return;
  3554. }
  3555. if (k >= Raster.bottomY)
  3556. return;
  3557. if (i > Raster.bottomY)
  3558. i = Raster.bottomY;
  3559. if (j > Raster.bottomY)
  3560. j = Raster.bottomY;
  3561. if (i < j) {
  3562. i1 = j1 <<= 16;
  3563. l1 = i2 <<= 16;
  3564. if (k < 0) {
  3565. i1 -= k7 * k;
  3566. j1 -= i8 * k;
  3567. l1 -= l7 * k;
  3568. i2 -= j8 * k;
  3569. k = 0;
  3570. }
  3571. l <<= 16;
  3572. k1 <<= 16;
  3573. if (i < 0) {
  3574. l -= i7 * i;
  3575. k1 -= j7 * i;
  3576. i = 0;
  3577. }
  3578. int k9 = k - centerY;
  3579. l4 += j5 * k9;
  3580. k5 += i6 * k9;
  3581. j6 += l6 * k9;
  3582. if (k7 < i8) {
  3583. j -= i;
  3584. i -= k;
  3585. k = lineOffsets[k];
  3586. while (--i >= 0) {
  3587. method379(Raster.pixels, ai, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3588. i1 += k7;
  3589. j1 += i8;
  3590. l1 += l7;
  3591. i2 += j8;
  3592. k += Raster.rasterWidth;
  3593. l4 += j5;
  3594. k5 += i6;
  3595. j6 += l6;
  3596. }
  3597. while (--j >= 0) {
  3598. method379(Raster.pixels, ai, k, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3599. i1 += k7;
  3600. l += i7;
  3601. l1 += l7;
  3602. k1 += j7;
  3603. k += Raster.rasterWidth;
  3604. l4 += j5;
  3605. k5 += i6;
  3606. j6 += l6;
  3607. }
  3608. return;
  3609. }
  3610. j -= i;
  3611. i -= k;
  3612. k = lineOffsets[k];
  3613. while (--i >= 0) {
  3614. method379(Raster.pixels, ai, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3615. i1 += k7;
  3616. j1 += i8;
  3617. l1 += l7;
  3618. i2 += j8;
  3619. k += Raster.rasterWidth;
  3620. l4 += j5;
  3621. k5 += i6;
  3622. j6 += l6;
  3623. }
  3624. while (--j >= 0) {
  3625. method379(Raster.pixels, ai, k, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3626. i1 += k7;
  3627. l += i7;
  3628. l1 += l7;
  3629. k1 += j7;
  3630. k += Raster.rasterWidth;
  3631. l4 += j5;
  3632. k5 += i6;
  3633. j6 += l6;
  3634. }
  3635. return;
  3636. }
  3637. l = j1 <<= 16;
  3638. k1 = i2 <<= 16;
  3639. if (k < 0) {
  3640. l -= k7 * k;
  3641. j1 -= i8 * k;
  3642. k1 -= l7 * k;
  3643. i2 -= j8 * k;
  3644. k = 0;
  3645. }
  3646. i1 <<= 16;
  3647. l1 <<= 16;
  3648. if (j < 0) {
  3649. i1 -= i7 * j;
  3650. l1 -= j7 * j;
  3651. j = 0;
  3652. }
  3653. int l9 = k - centerY;
  3654. l4 += j5 * l9;
  3655. k5 += i6 * l9;
  3656. j6 += l6 * l9;
  3657. if (k7 < i8) {
  3658. i -= j;
  3659. j -= k;
  3660. k = lineOffsets[k];
  3661. while (--j >= 0) {
  3662. method379(Raster.pixels, ai, k, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3663. l += k7;
  3664. j1 += i8;
  3665. k1 += l7;
  3666. i2 += j8;
  3667. k += Raster.rasterWidth;
  3668. l4 += j5;
  3669. k5 += i6;
  3670. j6 += l6;
  3671. }
  3672. while (--i >= 0) {
  3673. method379(Raster.pixels, ai, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
  3674. i1 += i7;
  3675. j1 += i8;
  3676. l1 += j7;
  3677. i2 += j8;
  3678. k += Raster.rasterWidth;
  3679. l4 += j5;
  3680. k5 += i6;
  3681. j6 += l6;
  3682. }
  3683. return;
  3684. }
  3685. i -= j;
  3686. j -= k;
  3687. k = lineOffsets[k];
  3688. while (--j >= 0) {
  3689. method379(Raster.pixels, ai, k, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
  3690. l += k7;
  3691. j1 += i8;
  3692. k1 += l7;
  3693. i2 += j8;
  3694. k += Raster.rasterWidth;
  3695. l4 += j5;
  3696. k5 += i6;
  3697. j6 += l6;
  3698. }
  3699. while (--i >= 0) {
  3700. method379(Raster.pixels, ai, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
  3701. i1 += i7;
  3702. j1 += i8;
  3703. l1 += j7;
  3704. i2 += j8;
  3705. k += Raster.rasterWidth;
  3706. l4 += j5;
  3707. k5 += i6;
  3708. j6 += l6;
  3709. }
  3710. }
  3711.  
  3712. private static void method379(int ai[], int ai1[], int k, int l, int i1, int j1, int k1, int l1, int i2, int j2,
  3713. int k2, int l2, int i3) {
  3714. int i = 0;// was parameter
  3715. int j = 0;// was parameter
  3716. if (l >= i1)
  3717. return;
  3718. int j3;
  3719. int k3;
  3720. if (restrict_edges) {
  3721. j3 = (k1 - j1) / (i1 - l);
  3722. if (i1 > Raster.viewportRx)
  3723. i1 = Raster.viewportRx;
  3724. if (l < 0) {
  3725. j1 -= l * j3;
  3726. l = 0;
  3727. }
  3728. if (l >= i1)
  3729. return;
  3730. k3 = i1 - l >> 3;
  3731. j3 <<= 12;
  3732. j1 <<= 9;
  3733. } else {
  3734. if (i1 - l > 7) {
  3735. k3 = i1 - l >> 3;
  3736. j3 = (k1 - j1) * anIntArray1468[k3] >> 6;
  3737. } else {
  3738. k3 = 0;
  3739. j3 = 0;
  3740. }
  3741. j1 <<= 9;
  3742. }
  3743. k += l;
  3744. if (lowDetail) {
  3745. int i4 = 0;
  3746. int k4 = 0;
  3747. int k6 = l - centerX;
  3748. l1 += (k2 >> 3) * k6;
  3749. i2 += (l2 >> 3) * k6;
  3750. j2 += (i3 >> 3) * k6;
  3751. int i5 = j2 >> 12;
  3752. if (i5 != 0) {
  3753. i = l1 / i5;
  3754. j = i2 / i5;
  3755. if (i < 0)
  3756. i = 0;
  3757. else if (i > 4032)
  3758. i = 4032;
  3759. }
  3760. l1 += k2;
  3761. i2 += l2;
  3762. j2 += i3;
  3763. i5 = j2 >> 12;
  3764. if (i5 != 0) {
  3765. i4 = l1 / i5;
  3766. k4 = i2 / i5;
  3767. if (i4 < 7)
  3768. i4 = 7;
  3769. else if (i4 > 4032)
  3770. i4 = 4032;
  3771. }
  3772. int i7 = i4 - i >> 3;
  3773. int k7 = k4 - j >> 3;
  3774. i += (j1 & 0x600000) >> 3;
  3775. int i8 = j1 >> 23;
  3776. if (aBoolean1463) {
  3777. while (k3-- > 0) {
  3778. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3779. i += i7;
  3780. j += k7;
  3781. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3782. i += i7;
  3783. j += k7;
  3784. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3785. i += i7;
  3786. j += k7;
  3787. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3788. i += i7;
  3789. j += k7;
  3790. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3791. i += i7;
  3792. j += k7;
  3793. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3794. i += i7;
  3795. j += k7;
  3796. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3797. i += i7;
  3798. j += k7;
  3799. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3800. i = i4;
  3801. j = k4;
  3802. l1 += k2;
  3803. i2 += l2;
  3804. j2 += i3;
  3805. int j5 = j2 >> 12;
  3806. if (j5 != 0) {
  3807. i4 = l1 / j5;
  3808. k4 = i2 / j5;
  3809. if (i4 < 7)
  3810. i4 = 7;
  3811. else if (i4 > 4032)
  3812. i4 = 4032;
  3813. }
  3814. i7 = i4 - i >> 3;
  3815. k7 = k4 - j >> 3;
  3816. j1 += j3;
  3817. i += (j1 & 0x600000) >> 3;
  3818. i8 = j1 >> 23;
  3819. }
  3820. for (k3 = i1 - l & 7; k3-- > 0;) {
  3821. ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
  3822. i += i7;
  3823. j += k7;
  3824. }
  3825.  
  3826. return;
  3827. }
  3828. while (k3-- > 0) {
  3829. int k8;
  3830. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3831. ai[k] = k8;
  3832. k++;
  3833. i += i7;
  3834. j += k7;
  3835. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3836. ai[k] = k8;
  3837. k++;
  3838. i += i7;
  3839. j += k7;
  3840. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3841. ai[k] = k8;
  3842. k++;
  3843. i += i7;
  3844. j += k7;
  3845. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3846. ai[k] = k8;
  3847. k++;
  3848. i += i7;
  3849. j += k7;
  3850. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3851. ai[k] = k8;
  3852. k++;
  3853. i += i7;
  3854. j += k7;
  3855. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3856. ai[k] = k8;
  3857. k++;
  3858. i += i7;
  3859. j += k7;
  3860. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3861. ai[k] = k8;
  3862. k++;
  3863. i += i7;
  3864. j += k7;
  3865. if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3866. ai[k] = k8;
  3867. k++;
  3868. i = i4;
  3869. j = k4;
  3870. l1 += k2;
  3871. i2 += l2;
  3872. j2 += i3;
  3873. int k5 = j2 >> 12;
  3874. if (k5 != 0) {
  3875. i4 = l1 / k5;
  3876. k4 = i2 / k5;
  3877. if (i4 < 7)
  3878. i4 = 7;
  3879. else if (i4 > 4032)
  3880. i4 = 4032;
  3881. }
  3882. i7 = i4 - i >> 3;
  3883. k7 = k4 - j >> 3;
  3884. j1 += j3;
  3885. i += (j1 & 0x600000) >> 3;
  3886. i8 = j1 >> 23;
  3887. }
  3888. for (k3 = i1 - l & 7; k3-- > 0;) {
  3889. int l8;
  3890. if ((l8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
  3891. ai[k] = l8;
  3892. k++;
  3893. i += i7;
  3894. j += k7;
  3895. }
  3896.  
  3897. return;
  3898. }
  3899. int j4 = 0;
  3900. int l4 = 0;
  3901. int l6 = l - centerX;
  3902. l1 += (k2 >> 3) * l6;
  3903. i2 += (l2 >> 3) * l6;
  3904. j2 += (i3 >> 3) * l6;
  3905. int l5 = j2 >> 14;
  3906. if (l5 != 0) {
  3907. i = l1 / l5;
  3908. j = i2 / l5;
  3909. if (i < 0)
  3910. i = 0;
  3911. else if (i > 16256)
  3912. i = 16256;
  3913. }
  3914. l1 += k2;
  3915. i2 += l2;
  3916. j2 += i3;
  3917. l5 = j2 >> 14;
  3918. if (l5 != 0) {
  3919. j4 = l1 / l5;
  3920. l4 = i2 / l5;
  3921. if (j4 < 7)
  3922. j4 = 7;
  3923. else if (j4 > 16256)
  3924. j4 = 16256;
  3925. }
  3926. int j7 = j4 - i >> 3;
  3927. int l7 = l4 - j >> 3;
  3928. i += j1 & 0x600000;
  3929. int j8 = j1 >> 23;
  3930. if (aBoolean1463) {
  3931. while (k3-- > 0) {
  3932. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3933. i += j7;
  3934. j += l7;
  3935. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3936. i += j7;
  3937. j += l7;
  3938. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3939. i += j7;
  3940. j += l7;
  3941. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3942. i += j7;
  3943. j += l7;
  3944. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3945. i += j7;
  3946. j += l7;
  3947. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3948. i += j7;
  3949. j += l7;
  3950. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3951. i += j7;
  3952. j += l7;
  3953. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3954. i = j4;
  3955. j = l4;
  3956. l1 += k2;
  3957. i2 += l2;
  3958. j2 += i3;
  3959. int i6 = j2 >> 14;
  3960. if (i6 != 0) {
  3961. j4 = l1 / i6;
  3962. l4 = i2 / i6;
  3963. if (j4 < 7)
  3964. j4 = 7;
  3965. else if (j4 > 16256)
  3966. j4 = 16256;
  3967. }
  3968. j7 = j4 - i >> 3;
  3969. l7 = l4 - j >> 3;
  3970. j1 += j3;
  3971. i += j1 & 0x600000;
  3972. j8 = j1 >> 23;
  3973. }
  3974. for (k3 = i1 - l & 7; k3-- > 0;) {
  3975. ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
  3976. i += j7;
  3977. j += l7;
  3978. }
  3979.  
  3980. return;
  3981. }
  3982. while (k3-- > 0) {
  3983. int i9;
  3984. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  3985. ai[k] = i9;
  3986. k++;
  3987. i += j7;
  3988. j += l7;
  3989. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  3990. ai[k] = i9;
  3991. k++;
  3992. i += j7;
  3993. j += l7;
  3994. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  3995. ai[k] = i9;
  3996. k++;
  3997. i += j7;
  3998. j += l7;
  3999. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  4000. ai[k] = i9;
  4001. k++;
  4002. i += j7;
  4003. j += l7;
  4004. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  4005. ai[k] = i9;
  4006. k++;
  4007. i += j7;
  4008. j += l7;
  4009. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  4010. ai[k] = i9;
  4011. k++;
  4012. i += j7;
  4013. j += l7;
  4014. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  4015. ai[k] = i9;
  4016. k++;
  4017. i += j7;
  4018. j += l7;
  4019. if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  4020. ai[k] = i9;
  4021. k++;
  4022. i = j4;
  4023. j = l4;
  4024. l1 += k2;
  4025. i2 += l2;
  4026. j2 += i3;
  4027. int j6 = j2 >> 14;
  4028. if (j6 != 0) {
  4029. j4 = l1 / j6;
  4030. l4 = i2 / j6;
  4031. if (j4 < 7)
  4032. j4 = 7;
  4033. else if (j4 > 16256)
  4034. j4 = 16256;
  4035. }
  4036. j7 = j4 - i >> 3;
  4037. l7 = l4 - j >> 3;
  4038. j1 += j3;
  4039. i += j1 & 0x600000;
  4040. j8 = j1 >> 23;
  4041. }
  4042. for (int l3 = i1 - l & 7; l3-- > 0;) {
  4043. int j9;
  4044. if ((j9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
  4045. ai[k] = j9;
  4046. k++;
  4047. i += j7;
  4048. j += l7;
  4049. }
  4050.  
  4051. }
  4052.  
  4053. public static void nullify() {
  4054. anIntArray1468 = null;
  4055. anIntArray1468 = null;
  4056. SINE = null;
  4057. COSINE = null;
  4058. lineOffsets = null;
  4059. aBackgroundArray1474s = null;
  4060. aBooleanArray1475 = null;
  4061. averageTextureColours = null;
  4062. textureRequestPixelBuffer = null;
  4063. texturesPixelBuffer = null;
  4064. anIntArray1480 = null;
  4065. hsl2rgb = null;
  4066. currentPalette = null;
  4067. }
  4068.  
  4069. public static void setBounds(int offSetX, int offSetY) {
  4070. lineOffsets = new int[offSetY];
  4071.  
  4072. for (int l = 0; l < offSetY; l++) {
  4073. lineOffsets[l] = offSetX * l;
  4074. }
  4075.  
  4076. centerX = offSetX / 2;
  4077. centerY = offSetY / 2;
  4078. }
  4079.  
  4080. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement