Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.graardor.client.world;
- import java.util.HashMap;
- import com.graardor.client.Client;
- import com.graardor.client.cache.Archive;
- import com.graardor.client.graphics.Background;
- import com.graardor.client.graphics.Raster;
- public final class Rasterizer extends Raster {
- public static int TEXTURE_COUNT = 51;
- public static Background aBackgroundArray1474s[] = new Background[TEXTURE_COUNT];
- public static boolean restrict_edges;
- private static boolean aBoolean1463;
- private static boolean[] aBooleanArray1475 = new boolean[TEXTURE_COUNT];
- public static int alpha;
- private static int anInt1473;
- private static int textureRequestBufferPointer;
- public static int anInt1481;
- private static int[] anIntArray1468;
- public static final int[] anIntArray1469;
- private static int[] averageTextureColours = new int[TEXTURE_COUNT];
- public static int anIntArray1480[] = new int[TEXTURE_COUNT];
- public static int hsl2rgb[] = new int[0x10000];
- private static int[][] textureRequestPixelBuffer;
- private static int[][] texturesPixelBuffer = new int[TEXTURE_COUNT][];
- private static int[][] currentPalette = new int[TEXTURE_COUNT][];
- public static int centerX;
- public static int centerY;
- public static int COSINE[];
- public static int lineOffsets[];
- public static boolean lowDetail = true;
- public static boolean notTextured = true;
- private static int[] OFFSETS_512_334 = null;
- private static int[] OFFSETS_765_503 = null;
- public static int SINE[];
- public static boolean ignoreInterfaceModel = false;
- public static boolean textureOnInterface = false;
- static {
- anIntArray1468 = new int[512];
- anIntArray1469 = new int[2048];
- SINE = new int[2048];
- COSINE = new int[2048];
- for (int i = 1; i < 512; i++) {
- anIntArray1468[i] = 32768 / i;
- }
- for (int j = 1; j < 2048; j++) {
- anIntArray1469[j] = 0x10000 / j;
- }
- for (int k = 0; k < 2048; k++) {
- SINE[k] = (int) (65536D * Math.sin(k * 0.0030679614999999999D));
- COSINE[k] = (int) (65536D * Math.cos(k * 0.0030679614999999999D));
- }
- }
- public static int[] getOffsets(int j, int k) {
- if (j == 512 && k == 334 && OFFSETS_512_334 != null) {
- return OFFSETS_512_334;
- }
- if (j == 765 + 1 && k == 503 && OFFSETS_765_503 != null) {
- return OFFSETS_765_503;
- }
- int[] t = new int[k];
- for (int l = 0; l < k; l++) {
- t[l] = j * l;
- }
- if (j == 512 && k == 334) {
- OFFSETS_512_334 = t;
- }
- if (j == 765 + 1 && k == 503) {
- OFFSETS_765_503 = t;
- }
- return t;
- }
- public static void useViewport() {
- lineOffsets = new int[Raster.height];
- for (int j = 0; j < Raster.height; j++) {
- lineOffsets[j] = Raster.rasterWidth * j;
- }
- centerX = Raster.rasterWidth / 2;
- centerY = Raster.height / 2;
- }
- public static void method366() {
- textureRequestPixelBuffer = null;
- for (int j = 0; j < TEXTURE_COUNT; j++) {
- texturesPixelBuffer[j] = null;
- }
- }
- public static void method367() {
- if (textureRequestPixelBuffer == null) {
- textureRequestBufferPointer = 20;// was parameter
- if (lowDetail) {
- textureRequestPixelBuffer = new int[textureRequestBufferPointer][16384];
- } else {
- textureRequestPixelBuffer = new int[textureRequestBufferPointer][0x10000];
- }
- for (int k = 0; k < TEXTURE_COUNT; k++) {
- texturesPixelBuffer[k] = null;
- }
- }
- }
- public static void method368(Archive streamLoader) {
- anInt1473 = 0;
- for (int i = 0; i < 51; i++) {
- try {
- aBackgroundArray1474s[i] = new Background(streamLoader, String.valueOf(i), 0);
- if (lowDetail && aBackgroundArray1474s[i].resizeWidth == 128) {
- aBackgroundArray1474s[i].method356();
- } else {
- aBackgroundArray1474s[i].method357();
- }
- anInt1473++;
- } catch (Exception _ex) {
- _ex.printStackTrace();
- }
- }
- for (int i = 51; i < TEXTURE_COUNT; i++) {
- try {
- try {
- aBackgroundArray1474s[i] = new Background(streamLoader, String.valueOf(i), 0);
- } catch(Exception e) {
- e.printStackTrace();
- continue;
- }
- if (lowDetail && aBackgroundArray1474s[i].resizeWidth == 128) {
- aBackgroundArray1474s[i].method356();
- } else {
- aBackgroundArray1474s[i].method357();
- }
- anInt1473++;
- } catch (Exception _ex) {
- _ex.printStackTrace();
- }
- }
- }
- public static int getTexture(int i) {
- if (averageTextureColours[i] != 0) {
- return averageTextureColours[i];
- }
- int totalRed = 0;
- int totalGreen = 0;
- int totalBlue = 0;
- int j1 = currentPalette[i].length;
- for (int k1 = 0; k1 < j1; k1++) {
- totalRed += currentPalette[i][k1] >> 16 & 0xff;
- totalGreen += currentPalette[i][k1] >> 8 & 0xff;
- totalBlue += currentPalette[i][k1] & 0xff;
- }
- int l1 = (totalRed / j1 << 16) + (totalGreen / j1 << 8) + totalBlue / j1;
- l1 = adjustBrightness(l1, 1.3999999999999999D);
- if (l1 == 0) {
- l1 = 1;
- }
- averageTextureColours[i] = l1;
- return l1;
- }
- public static void requestTextureUpdate(int i) {
- if (texturesPixelBuffer[i] == null) {
- return;
- }
- textureRequestPixelBuffer[textureRequestBufferPointer++] = texturesPixelBuffer[i];
- texturesPixelBuffer[i] = null;
- }
- private static int[] method371(int i) {
- anIntArray1480[i] = anInt1481++;
- if (texturesPixelBuffer[i] != null) {
- return texturesPixelBuffer[i];
- }
- int ai[];
- if (textureRequestBufferPointer > 0) {
- ai = textureRequestPixelBuffer[--textureRequestBufferPointer];
- textureRequestPixelBuffer[textureRequestBufferPointer] = null;
- } else {
- int j = 0;
- int k = -1;
- for (int l = 0; l < anInt1473; l++) {
- if (texturesPixelBuffer[l] != null && (anIntArray1480[l] < j || k == -1)) {
- j = anIntArray1480[l];
- k = l;
- }
- }
- ai = texturesPixelBuffer[k];
- texturesPixelBuffer[k] = null;
- }
- texturesPixelBuffer[i] = ai;
- Background background = aBackgroundArray1474s[i];
- int ai1[] = currentPalette[i];
- if (lowDetail) {
- aBooleanArray1475[i] = false;
- for (int i1 = 0; i1 < 4096; i1++) {
- int i2 = ai[i1] = ai1[background.palettePixels[i1]] & 0xf8f8ff;
- if (i2 == 0) {
- aBooleanArray1475[i] = true;
- }
- ai[4096 + i1] = i2 - (i2 >>> 3) & 0xf8f8ff;
- ai[8192 + i1] = i2 - (i2 >>> 2) & 0xf8f8ff;
- ai[12288 + i1] = i2 - (i2 >>> 2) - (i2 >>> 3) & 0xf8f8ff;
- }
- } else {
- if (background.width == 64) {
- for (int j1 = 0; j1 < 128; j1++) {
- for (int j2 = 0; j2 < 128; j2++) {
- ai[j2 + (j1 << 7)] = ai1[background.palettePixels[(j2 >> 1) + (j1 >> 1 << 6)]];
- }
- }
- } else {
- for (int k1 = 0; k1 < 16384; k1++) {
- ai[k1] = ai1[background.palettePixels[k1]];
- }
- }
- aBooleanArray1475[i] = false;
- for (int l1 = 0; l1 < 16384; l1++) {
- ai[l1] &= 0xf8f8ff;
- int k2 = ai[l1];
- if (k2 == 0) {
- aBooleanArray1475[i] = true;
- }
- ai[16384 + l1] = k2 - (k2 >>> 3) & 0xf8f8ff;
- ai[32768 + l1] = k2 - (k2 >>> 2) & 0xf8f8ff;
- ai[49152 + l1] = k2 - (k2 >>> 2) - (k2 >>> 3) & 0xf8f8ff;
- }
- }
- return ai;
- }
- public static void setBrightness(double d) {
- int j = 0;
- for (int k = 0; k < 512; k++) {
- double d1 = k / 8 / 64D + 0.0078125D;
- double d2 = (k & 7) / 8D + 0.0625D;
- for (int k1 = 0; k1 < 128; k1++) {
- double d3 = k1 / 128D;
- double d4 = d3;
- double d5 = d3;
- double d6 = d3;
- if (d2 != 0.0D) {
- double d7;
- if (d3 < 0.5D) {
- d7 = d3 * (1.0D + d2);
- } else {
- d7 = d3 + d2 - d3 * d2;
- }
- double d8 = 2D * d3 - d7;
- double d9 = d1 + 0.33333333333333331D;
- if (d9 > 1.0D) {
- d9--;
- }
- double d10 = d1;
- double d11 = d1 - 0.33333333333333331D;
- if (d11 < 0.0D) {
- d11++;
- }
- if (6D * d9 < 1.0D) {
- d4 = d8 + (d7 - d8) * 6D * d9;
- } else if (2D * d9 < 1.0D) {
- d4 = d7;
- } else if (3D * d9 < 2D) {
- d4 = d8 + (d7 - d8) * (0.66666666666666663D - d9) * 6D;
- } else {
- d4 = d8;
- }
- if (6D * d10 < 1.0D) {
- d5 = d8 + (d7 - d8) * 6D * d10;
- } else if (2D * d10 < 1.0D) {
- d5 = d7;
- } else if (3D * d10 < 2D) {
- d5 = d8 + (d7 - d8) * (0.66666666666666663D - d10) * 6D;
- } else {
- d5 = d8;
- }
- if (6D * d11 < 1.0D) {
- d6 = d8 + (d7 - d8) * 6D * d11;
- } else if (2D * d11 < 1.0D) {
- d6 = d7;
- } else if (3D * d11 < 2D) {
- d6 = d8 + (d7 - d8) * (0.66666666666666663D - d11) * 6D;
- } else {
- d6 = d8;
- }
- }
- int l1 = (int) (d4 * 256D);
- int i2 = (int) (d5 * 256D);
- int j2 = (int) (d6 * 256D);
- int k2 = (l1 << 16) + (i2 << 8) + j2;
- k2 = adjustBrightness(k2, d);
- if (k2 == 0) {
- k2 = 1;
- }
- hsl2rgb[j++] = k2;
- }
- }
- for (int l = 0; l < TEXTURE_COUNT; l++) {
- if (aBackgroundArray1474s[l] != null) {
- int ai[] = aBackgroundArray1474s[l].palette;
- if(ai == null) continue;
- currentPalette[l] = new int[ai.length];
- for (int j1 = 0; j1 < ai.length; j1++) {
- currentPalette[l][j1] = adjustBrightness(ai[j1], d);
- if ((currentPalette[l][j1] & 0xf8f8ff) == 0 && j1 != 0) {
- currentPalette[l][j1] = 1;
- }
- }
- }
- }
- for (int i1 = 0; i1 < TEXTURE_COUNT; i1++) {
- requestTextureUpdate(i1);
- }
- }
- private static int adjustBrightness(int i, double d) {
- double d1 = (i >> 16) / 256D;
- double d2 = (i >> 8 & 0xff) / 256D;
- double d3 = (i & 0xff) / 256D;
- d1 = Math.pow(d1, d);
- d2 = Math.pow(d2, d);
- d3 = Math.pow(d3, d);
- int j = (int) (d1 * 256D);
- int k = (int) (d2 * 256D);
- int l = (int) (d3 * 256D);
- return (j << 16) + (k << 8) + l;
- }
- 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) {
- if (z_a < 0 || z_b < 0 || z_c < 0)
- return;
- int rgb1 = hsl2rgb[hsl1];
- int rgb2 = hsl2rgb[hsl2];
- int rgb3 = hsl2rgb[hsl3];
- int r1 = rgb1 >> 16 & 0xff;
- int g1 = rgb1 >> 8 & 0xff;
- int b1 = rgb1 & 0xff;
- int r2 = rgb2 >> 16 & 0xff;
- int g2 = rgb2 >> 8 & 0xff;
- int b2 = rgb2 & 0xff;
- int r3 = rgb3 >> 16 & 0xff;
- int g3 = rgb3 >> 8 & 0xff;
- int b3 = rgb3 & 0xff;
- int a_to_b = 0;
- int dr1 = 0;
- int dg1 = 0;
- int db1 = 0;
- if (y_b != y_a) {
- a_to_b = (x_b - x_a << 16) / (y_b - y_a);
- dr1 = (r2 - r1 << 16) / (y_b - y_a);
- dg1 = (g2 - g1 << 16) / (y_b - y_a);
- db1 = (b2 - b1 << 16) / (y_b - y_a);
- }
- int b_to_c = 0;
- int dr2 = 0;
- int dg2 = 0;
- int db2 = 0;
- if (y_c != y_b) {
- b_to_c = (x_c - x_b << 16) / (y_c - y_b);
- dr2 = (r3 - r2 << 16) / (y_c - y_b);
- dg2 = (g3 - g2 << 16) / (y_c - y_b);
- db2 = (b3 - b2 << 16) / (y_c - y_b);
- }
- int c_to_a = 0;
- int dr3 = 0;
- int dg3 = 0;
- int db3 = 0;
- if (y_c != y_a) {
- c_to_a = (x_a - x_c << 16) / (y_a - y_c);
- dr3 = (r1 - r3 << 16) / (y_a - y_c);
- dg3 = (g1 - g3 << 16) / (y_a - y_c);
- db3 = (b1 - b3 << 16) / (y_a - y_c);
- }
- float b_aX = x_b - x_a;
- float b_aY = y_b - y_a;
- float c_aX = x_c - x_a;
- float c_aY = y_c - y_a;
- float b_aZ = z_b - z_a;
- float c_aZ = z_c - z_a;
- float div = b_aX * c_aY - c_aX * b_aY;
- float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
- float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
- if(y_a <= y_b && y_a <= y_c) {
- if(y_a >= Raster.bottomY) {
- return;
- }
- if(y_b > Raster.bottomY) {
- y_b = Raster.bottomY;
- }
- if(y_c > Raster.bottomY) {
- y_c = Raster.bottomY;
- }
- z_a = z_a - depth_slope * x_a + depth_slope;
- if(y_b < y_c) {
- x_c = x_a <<= 16;
- r3 = r1 <<= 16;
- g3 = g1 <<= 16;
- b3 = b1 <<= 16;
- if(y_a < 0) {
- x_c -= c_to_a * y_a;
- x_a -= a_to_b * y_a;
- r3 -= dr3 * y_a;
- g3 -= dg3 * y_a;
- b3 -= db3 * y_a;
- r1 -= dr1 * y_a;
- g1 -= dg1 * y_a;
- b1 -= db1 * y_a;
- z_a -= depth_increment * y_a;
- y_a = 0;
- }
- x_b <<= 16;
- r2 <<= 16;
- g2 <<= 16;
- b2 <<= 16;
- if(y_b < 0) {
- x_b -= b_to_c * y_b;
- r2 -= dr2 * y_b;
- g2 -= dg2 * y_b;
- b2 -= db2 * y_b;
- y_b = 0;
- }
- if(y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
- y_c -= y_b;
- y_b -= y_a;
- for(y_a = lineOffsets[y_a]; --y_b >= 0; y_a += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_a, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_a, depth_slope);
- x_c += c_to_a;
- x_a += a_to_b;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- z_a += depth_increment;
- }
- while(--y_c >= 0) {
- drawShadedScanline(Raster.pixels, y_a, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_a, depth_slope);
- x_c += c_to_a;
- x_b += b_to_c;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- y_a += Raster.rasterWidth;
- z_a += depth_increment;
- }
- return;
- }
- y_c -= y_b;
- y_b -= y_a;
- for(y_a = lineOffsets[y_a]; --y_b >= 0; y_a += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_a, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_a, depth_slope);
- x_c += c_to_a;
- x_a += a_to_b;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- z_a += depth_increment;
- }
- while(--y_c >= 0) {
- drawShadedScanline(Raster.pixels, y_a, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_a, depth_slope);
- x_c += c_to_a;
- x_b += b_to_c;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- y_a += Raster.rasterWidth;
- z_a += depth_increment;
- }
- return;
- }
- x_b = x_a <<= 16;
- r2 = r1 <<= 16;
- g2 = g1 <<= 16;
- b2 = b1 <<= 16;
- if(y_a < 0) {
- x_b -= c_to_a * y_a;
- x_a -= a_to_b * y_a;
- r2 -= dr3 * y_a;
- g2 -= dg3 * y_a;
- b2 -= db3 * y_a;
- r1 -= dr1 * y_a;
- g1 -= dg1 * y_a;
- b1 -= db1 * y_a;
- z_a -= depth_increment * y_a;
- y_a = 0;
- }
- x_c <<= 16;
- r3 <<= 16;
- g3 <<= 16;
- b3 <<= 16;
- if(y_c < 0) {
- x_c -= b_to_c * y_c;
- r3 -= dr2 * y_c;
- g3 -= dg2 * y_c;
- b3 -= db2 * y_c;
- y_c = 0;
- }
- if(y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
- y_b -= y_c;
- y_c -= y_a;
- for(y_a = lineOffsets[y_a]; --y_c >= 0; y_a += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_a, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_a, depth_slope);
- x_b += c_to_a;
- x_a += a_to_b;
- r2 += dr3;
- g2 += dg3;
- b2 += db3;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- z_a += depth_increment;
- }
- while(--y_b >= 0) {
- drawShadedScanline(Raster.pixels, y_a, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_a, depth_slope);
- x_c += b_to_c;
- x_a += a_to_b;
- r3 += dr2;
- g3 += dg2;
- b3 += db2;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- y_a += Raster.rasterWidth;
- z_a += depth_increment;
- }
- return;
- }
- y_b -= y_c;
- y_c -= y_a;
- for(y_a = lineOffsets[y_a]; --y_c >= 0; y_a += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_a, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_a, depth_slope);
- x_b += c_to_a;
- x_a += a_to_b;
- r2 += dr3;
- g2 += dg3;
- b2 += db3;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- z_a += depth_increment;
- }
- while(--y_b >= 0) {
- drawShadedScanline(Raster.pixels, y_a, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_a, depth_slope);
- x_c += b_to_c;
- x_a += a_to_b;
- r3 += dr2;
- g3 += dg2;
- b3 += db2;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- y_a += Raster.rasterWidth;
- z_a += depth_increment;
- }
- return;
- }
- if(y_b <= y_c) {
- if(y_b >= Raster.bottomY) {
- return;
- }
- if(y_c > Raster.bottomY) {
- y_c = Raster.bottomY;
- }
- if(y_a > Raster.bottomY) {
- y_a = Raster.bottomY;
- }
- z_b = z_b - depth_slope * x_b + depth_slope;
- if(y_c < y_a) {
- x_a = x_b <<= 16;
- r1 = r2 <<= 16;
- g1 = g2 <<= 16;
- b1 = b2 <<= 16;
- if(y_b < 0) {
- x_a -= a_to_b * y_b;
- x_b -= b_to_c * y_b;
- r1 -= dr1 * y_b;
- g1 -= dg1 * y_b;
- b1 -= db1 * y_b;
- r2 -= dr2 * y_b;
- g2 -= dg2 * y_b;
- b2 -= db2 * y_b;
- z_b -= depth_increment * y_b;
- y_b = 0;
- }
- x_c <<= 16;
- r3 <<= 16;
- g3 <<= 16;
- b3 <<= 16;
- if(y_c < 0) {
- x_c -= c_to_a * y_c;
- r3 -= dr3 * y_c;
- g3 -= dg3 * y_c;
- b3 -= db3 * y_c;
- y_c = 0;
- }
- if(y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
- y_a -= y_c;
- y_c -= y_b;
- for(y_b = lineOffsets[y_b]; --y_c >= 0; y_b += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_b, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_b, depth_slope);
- x_a += a_to_b;
- x_b += b_to_c;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- z_b += depth_increment;
- }
- while(--y_a >= 0) {
- drawShadedScanline(Raster.pixels, y_b, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_b, depth_slope);
- x_a += a_to_b;
- x_c += c_to_a;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- y_b += Raster.rasterWidth;
- z_b += depth_increment;
- }
- return;
- }
- y_a -= y_c;
- y_c -= y_b;
- for(y_b = lineOffsets[y_b]; --y_c >= 0; y_b += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_b, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_b, depth_slope);
- x_a += a_to_b;
- x_b += b_to_c;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- z_b += depth_increment;
- }
- while(--y_a >= 0) {
- drawShadedScanline(Raster.pixels, y_b, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_b, depth_slope);
- x_a += a_to_b;
- x_c += c_to_a;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- y_b += Raster.rasterWidth;
- z_b += depth_increment;
- }
- return;
- }
- x_c = x_b <<= 16;
- r3 = r2 <<= 16;
- g3 = g2 <<= 16;
- b3 = b2 <<= 16;
- if(y_b < 0) {
- x_c -= a_to_b * y_b;
- x_b -= b_to_c * y_b;
- r3 -= dr1 * y_b;
- g3 -= dg1 * y_b;
- b3 -= db1 * y_b;
- r2 -= dr2 * y_b;
- g2 -= dg2 * y_b;
- b2 -= db2 * y_b;
- z_b -= depth_increment * y_b;
- y_b = 0;
- }
- x_a <<= 16;
- r1 <<= 16;
- g1 <<= 16;
- b1 <<= 16;
- if(y_a < 0) {
- x_a -= c_to_a * y_a;
- r1 -= dr3 * y_a;
- g1 -= dg3 * y_a;
- b1 -= db3 * y_a;
- y_a = 0;
- }
- if(a_to_b < b_to_c) {
- y_c -= y_a;
- y_a -= y_b;
- for(y_b = lineOffsets[y_b]; --y_a >= 0; y_b += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_b, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_b, depth_slope);
- x_c += a_to_b;
- x_b += b_to_c;
- r3 += dr1;
- g3 += dg1;
- b3 += db1;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- z_b += depth_increment;
- }
- while(--y_c >= 0) {
- drawShadedScanline(Raster.pixels, y_b, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_b, depth_slope);
- x_a += c_to_a;
- x_b += b_to_c;
- r1 += dr3;
- g1 += dg3;
- b1 += db3;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- y_b += Raster.rasterWidth;
- z_b += depth_increment;
- }
- return;
- }
- y_c -= y_a;
- y_a -= y_b;
- for(y_b = lineOffsets[y_b]; --y_a >= 0; y_b += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_b, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_b, depth_slope);
- x_c += a_to_b;
- x_b += b_to_c;
- r3 += dr1;
- g3 += dg1;
- b3 += db1;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- z_b += depth_increment;
- }
- while(--y_c >= 0) {
- drawShadedScanline(Raster.pixels, y_b, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_b, depth_slope);
- x_a += c_to_a;
- x_b += b_to_c;
- r1 += dr3;
- g1 += dg3;
- b1 += db3;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- y_b += Raster.rasterWidth;
- z_b += depth_increment;
- }
- return;
- }
- if(y_c >= Raster.bottomY) {
- return;
- }
- if(y_a > Raster.bottomY) {
- y_a = Raster.bottomY;
- }
- if(y_b > Raster.bottomY) {
- y_b = Raster.bottomY;
- }
- z_c = z_c - depth_slope * x_c + depth_slope;
- if(y_a < y_b) {
- x_b = x_c <<= 16;
- r2 = r3 <<= 16;
- g2 = g3 <<= 16;
- b2 = b3 <<= 16;
- if(y_c < 0) {
- x_b -= b_to_c * y_c;
- x_c -= c_to_a * y_c;
- r2 -= dr2 * y_c;
- g2 -= dg2 * y_c;
- b2 -= db2 * y_c;
- r3 -= dr3 * y_c;
- g3 -= dg3 * y_c;
- b3 -= db3 * y_c;
- z_c -= depth_increment * y_c;
- y_c = 0;
- }
- x_a <<= 16;
- r1 <<= 16;
- g1 <<= 16;
- b1 <<= 16;
- if(y_a < 0) {
- x_a -= a_to_b * y_a;
- r1 -= dr1 * y_a;
- g1 -= dg1 * y_a;
- b1 -= db1 * y_a;
- y_a = 0;
- }
- if(b_to_c < c_to_a) {
- y_b -= y_a;
- y_a -= y_c;
- for(y_c = lineOffsets[y_c]; --y_a >= 0; y_c += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_c, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_c, depth_slope);
- x_b += b_to_c;
- x_c += c_to_a;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- z_c += depth_increment;
- }
- while(--y_b >= 0) {
- drawShadedScanline(Raster.pixels, y_c, x_b >> 16, x_a >> 16, r2, g2, b2, r1, g1, b1, z_c, depth_slope);
- x_b += b_to_c;
- x_a += a_to_b;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- y_c += Raster.rasterWidth;
- z_c += depth_increment;
- }
- return;
- }
- y_b -= y_a;
- y_a -= y_c;
- for(y_c = lineOffsets[y_c]; --y_a >= 0; y_c += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_c, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_c, depth_slope);
- x_b += b_to_c;
- x_c += c_to_a;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- z_c += depth_increment;
- }
- while(--y_b >= 0) {
- drawShadedScanline(Raster.pixels, y_c, x_a >> 16, x_b >> 16, r1, g1, b1, r2, g2, b2, z_c, depth_slope);
- x_b += b_to_c;
- x_a += a_to_b;
- r2 += dr2;
- g2 += dg2;
- b2 += db2;
- r1 += dr1;
- g1 += dg1;
- b1 += db1;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- return;
- }
- x_a = x_c <<= 16;
- r1 = r3 <<= 16;
- g1 = g3 <<= 16;
- b1 = b3 <<= 16;
- if(y_c < 0) {
- x_a -= b_to_c * y_c;
- x_c -= c_to_a * y_c;
- r1 -= dr2 * y_c;
- g1 -= dg2 * y_c;
- b1 -= db2 * y_c;
- r3 -= dr3 * y_c;
- g3 -= dg3 * y_c;
- b3 -= db3 * y_c;
- z_c -= depth_increment * y_c;
- y_c = 0;
- }
- x_b <<= 16;
- r2 <<= 16;
- g2 <<= 16;
- b2 <<= 16;
- if(y_b < 0) {
- x_b -= a_to_b * y_b;
- r2 -= dr1 * y_b;
- g2 -= dg1 * y_b;
- b2 -= db1 * y_b;
- y_b = 0;
- }
- if(b_to_c < c_to_a) {
- y_a -= y_b;
- y_b -= y_c;
- for(y_c = lineOffsets[y_c]; --y_b >= 0; y_c += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_c, x_a >> 16, x_c >> 16, r1, g1, b1, r3, g3, b3, z_c, depth_slope);
- x_a += b_to_c;
- x_c += c_to_a;
- r1 += dr2;
- g1 += dg2;
- b1 += db2;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- z_c += depth_increment;
- }
- while(--y_a >= 0) {
- drawShadedScanline(Raster.pixels, y_c, x_b >> 16, x_c >> 16, r2, g2, b2, r3, g3, b3, z_c, depth_slope);
- x_b += a_to_b;
- x_c += c_to_a;
- r2 += dr1;
- g2 += dg1;
- b2 += db1;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- return;
- }
- y_a -= y_b;
- y_b -= y_c;
- for(y_c = lineOffsets[y_c]; --y_b >= 0; y_c += Raster.rasterWidth) {
- drawShadedScanline(Raster.pixels, y_c, x_c >> 16, x_a >> 16, r3, g3, b3, r1, g1, b1, z_c, depth_slope);
- x_a += b_to_c;
- x_c += c_to_a;
- r1 += dr2;
- g1 += dg2;
- b1 += db2;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- z_c += depth_increment;
- }
- while(--y_a >= 0) {
- drawShadedScanline(Raster.pixels, y_c, x_c >> 16, x_b >> 16, r3, g3, b3, r2, g2, b2, z_c, depth_slope);
- x_b += a_to_b;
- x_c += c_to_a;
- r2 += dr1;
- g2 += dg1;
- b2 += db1;
- r3 += dr3;
- g3 += dg3;
- b3 += db3;
- y_c += Raster.rasterWidth;
- z_c += depth_increment;
- }
- }
- public static void drawShadedScanline(int[] dest, int offset, int x1, int x2, int r1, int g1, int b1, int r2,
- int g2, int b2, float depth, float depth_slope) {
- int n = x2 - x1;
- if (n <= 0) {
- return;
- }
- r2 = (r2 - r1) / n;
- g2 = (g2 - g1) / n;
- b2 = (b2 - b1) / n;
- if (restrict_edges) {
- if (x2 > Raster.viewportRx) {
- n -= x2 - Raster.viewportRx;
- x2 = Raster.viewportRx;
- }
- if (x1 < 0) {
- n = x2;
- r1 -= x1 * r2;
- g1 -= x1 * g2;
- b1 -= x1 * b2;
- x1 = 0;
- }
- }
- if (x1 < x2) {
- offset += x1;
- depth += depth_slope * (float) x1;
- if (alpha == 0) {
- while (--n >= 0) {
- if (Raster.depthBuffer != null && depth <= Raster.depthBuffer[offset]) {
- dest[offset] = (r1 & 0xff0000) | (g1 >> 8 & 0xff00) | (b1 >> 16 & 0xff);
- Raster.depthBuffer[offset] = depth;
- }
- depth += depth_slope;
- r1 += r2;
- g1 += g2;
- b1 += b2;
- offset++;
- }
- } else {
- final int a1 = alpha;
- final int a2 = 256 - alpha;
- int rgb;
- int dst;
- while (--n >= 0) {
- rgb = (r1 & 0xff0000) | (g1 >> 8 & 0xff00) | (b1 >> 16 & 0xff);
- rgb = ((rgb & 0xff00ff) * a2 >> 8 & 0xff00ff) + ((rgb & 0xff00) * a2 >> 8 & 0xff00);
- if (Raster.depthBuffer != null && depth <= Raster.depthBuffer[offset] && rgb != 0) {
- dst = dest[offset];
- dest[offset] = rgb + ((dst & 0xff00ff) * a1 >> 8 & 0xff00ff)
- + ((dst & 0xff00) * a1 >> 8 & 0xff00);
- Raster.depthBuffer[offset] = depth;
- }
- depth += depth_slope;
- r1 += r2;
- g1 += g2;
- b1 += b2;
- offset++;
- }
- }
- }
- }
- 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,
- float z_b, float z_c) {
- int a_to_b = 0, b_to_c = 0, c_to_a = 0;
- if (y_b != y_a) {
- a_to_b = (x_b - x_a << 16) / (y_b - y_a);
- }
- if (y_c != y_b) {
- b_to_c = (x_c - x_b << 16) / (y_c - y_b);
- }
- if (y_c != y_a) {
- c_to_a = (x_a - x_c << 16) / (y_a - y_c);
- }
- float b_aX = x_b - x_a;
- float b_aY = y_b - y_a;
- float c_aX = x_c - x_a;
- float c_aY = y_c - y_a;
- float b_aZ = z_b - z_a;
- float c_aZ = z_c - z_a;
- float div = b_aX * c_aY - c_aX * b_aY;
- float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
- float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
- // B /|
- // / |
- // / |
- // / |
- // A ----- C
- if (y_a <= y_b && y_a <= y_c) {
- if (y_a < Raster.bottomY) {
- if (y_b > Raster.bottomY)
- y_b = Raster.bottomY;
- if (y_c > Raster.bottomY)
- y_c = Raster.bottomY;
- z_a = z_a - depth_slope * x_a + depth_slope;
- if (y_b < y_c) {
- x_c = x_a <<= 16;
- if (y_a < 0) {
- x_c -= c_to_a * y_a;
- x_a -= a_to_b * y_a;
- z_a -= depth_increment * y_a;
- y_a = 0;
- }
- x_b <<= 16;
- if (y_b < 0) {
- x_b -= b_to_c * y_b;
- y_b = 0;
- }
- if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
- y_c -= y_b;
- y_b -= y_a;
- y_a = Rasterizer.lineOffsets[y_a];
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_c >> 16, x_a >> 16, z_a, depth_slope, rgb);
- x_c += c_to_a;
- x_a += a_to_b;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_c >> 16, x_b >> 16, z_a, depth_slope, rgb);
- x_c += c_to_a;
- x_b += b_to_c;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- } else {
- y_c -= y_b;
- y_b -= y_a;
- y_a = Rasterizer.lineOffsets[y_a];
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_a >> 16, x_c >> 16, z_a, depth_slope, rgb);
- x_c += c_to_a;
- x_a += a_to_b;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_b >> 16, x_c >> 16, z_a, depth_slope, rgb);
- x_c += c_to_a;
- x_b += b_to_c;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- }
- } else {
- x_b = x_a <<= 16;
- if (y_a < 0) {
- x_b -= c_to_a * y_a;
- x_a -= a_to_b * y_a;
- z_a -= depth_increment * y_a;
- y_a = 0;
- }
- x_c <<= 16;
- if (y_c < 0) {
- x_c -= b_to_c * y_c;
- y_c = 0;
- }
- if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
- y_b -= y_c;
- y_c -= y_a;
- y_a = Rasterizer.lineOffsets[y_a];
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_b >> 16, x_a >> 16, z_a, depth_slope, rgb);
- x_b += c_to_a;
- x_a += a_to_b;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_c >> 16, x_a >> 16, z_a, depth_slope, rgb);
- x_c += b_to_c;
- x_a += a_to_b;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- } else {
- y_b -= y_c;
- y_c -= y_a;
- y_a = Rasterizer.lineOffsets[y_a];
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_a >> 16, x_b >> 16, z_a, depth_slope, rgb);
- x_b += c_to_a;
- x_a += a_to_b;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_a, x_a >> 16, x_c >> 16, z_a, depth_slope, rgb);
- x_c += b_to_c;
- x_a += a_to_b;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- }
- }
- }
- }
- } else if (y_b <= y_c) {
- // A |\
- // | \
- // | \
- // | \
- // C ----- B
- if (y_b < Raster.bottomY) {
- if (y_c > Raster.bottomY)
- y_c = Raster.bottomY;
- if (y_a > Raster.bottomY)
- y_a = Raster.bottomY;
- z_b = z_b - depth_slope * x_b + depth_slope;
- if (y_c < y_a) {
- x_a = x_b <<= 16;
- if (y_b < 0) {
- x_a -= a_to_b * y_b;
- x_b -= b_to_c * y_b;
- z_b -= depth_increment * y_b;
- y_b = 0;
- }
- x_c <<= 16;
- if (y_c < 0) {
- x_c -= c_to_a * y_c;
- y_c = 0;
- }
- if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
- y_a -= y_c;
- y_c -= y_b;
- y_b = Rasterizer.lineOffsets[y_b];
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_a >> 16, x_b >> 16, z_b, depth_slope, rgb);
- x_a += a_to_b;
- x_b += b_to_c;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_a >> 16, x_c >> 16, z_b, depth_slope, rgb);
- x_a += a_to_b;
- x_c += c_to_a;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- } else {
- y_a -= y_c;
- y_c -= y_b;
- y_b = Rasterizer.lineOffsets[y_b];
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_b >> 16, x_a >> 16, z_b, depth_slope, rgb);
- x_a += a_to_b;
- x_b += b_to_c;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_c >> 16, x_a >> 16, z_b, depth_slope, rgb);
- x_a += a_to_b;
- x_c += c_to_a;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- }
- } else {
- x_c = x_b <<= 16;
- if (y_b < 0) {
- x_c -= a_to_b * y_b;
- x_b -= b_to_c * y_b;
- z_b -= depth_increment * y_b;
- y_b = 0;
- }
- x_a <<= 16;
- if (y_a < 0) {
- x_a -= c_to_a * y_a;
- y_a = 0;
- }
- if (a_to_b < b_to_c) {
- y_c -= y_a;
- y_a -= y_b;
- y_b = Rasterizer.lineOffsets[y_b];
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_c >> 16, x_b >> 16, z_b, depth_slope, rgb);
- x_c += a_to_b;
- x_b += b_to_c;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_a >> 16, x_b >> 16, z_b, depth_slope, rgb);
- x_a += c_to_a;
- x_b += b_to_c;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- } else {
- y_c -= y_a;
- y_a -= y_b;
- y_b = Rasterizer.lineOffsets[y_b];
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_b >> 16, x_c >> 16, z_b, depth_slope, rgb);
- x_c += a_to_b;
- x_b += b_to_c;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- while (--y_c >= 0) {
- drawFlatScanLine(Raster.pixels, y_b, x_b >> 16, x_a >> 16, z_b, depth_slope, rgb);
- x_a += c_to_a;
- x_b += b_to_c;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- }
- }
- }
- }
- } else if (y_c < Raster.bottomY) {
- if (y_a > Raster.bottomY)
- y_a = Raster.bottomY;
- if (y_b > Raster.bottomY)
- y_b = Raster.bottomY;
- z_c = z_c - depth_slope * x_c + depth_slope;
- if (y_a < y_b) {
- x_b = x_c <<= 16;
- if (y_c < 0) {
- x_b -= b_to_c * y_c;
- x_c -= c_to_a * y_c;
- z_c -= depth_increment * y_c;
- y_c = 0;
- }
- x_a <<= 16;
- if (y_a < 0) {
- x_a -= a_to_b * y_a;
- y_a = 0;
- }
- if (b_to_c < c_to_a) {
- y_b -= y_a;
- y_a -= y_c;
- y_c = Rasterizer.lineOffsets[y_c];
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_b >> 16, x_c >> 16, z_c, depth_slope, rgb);
- x_b += b_to_c;
- x_c += c_to_a;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_b >> 16, x_a >> 16, z_c, depth_slope, rgb);
- x_b += b_to_c;
- x_a += a_to_b;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- } else {
- y_b -= y_a;
- y_a -= y_c;
- y_c = Rasterizer.lineOffsets[y_c];
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_c >> 16, x_b >> 16, z_c, depth_slope, rgb);
- x_b += b_to_c;
- x_c += c_to_a;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_a >> 16, x_b >> 16, z_c, depth_slope, rgb);
- x_b += b_to_c;
- x_a += a_to_b;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- }
- } else {
- x_a = x_c <<= 16;
- if (y_c < 0) {
- x_a -= b_to_c * y_c;
- x_c -= c_to_a * y_c;
- z_c -= depth_increment * y_c;
- y_c = 0;
- }
- x_b <<= 16;
- if (y_b < 0) {
- x_b -= a_to_b * y_b;
- y_b = 0;
- }
- if (b_to_c < c_to_a) {
- y_a -= y_b;
- y_b -= y_c;
- y_c = Rasterizer.lineOffsets[y_c];
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_a >> 16, x_c >> 16, z_c, depth_slope, rgb);
- x_a += b_to_c;
- x_c += c_to_a;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_b >> 16, x_c >> 16, z_c, depth_slope, rgb);
- x_b += a_to_b;
- x_c += c_to_a;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- } else {
- y_a -= y_b;
- y_b -= y_c;
- y_c = Rasterizer.lineOffsets[y_c];
- while (--y_b >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_c >> 16, x_a >> 16, z_c, depth_slope, rgb);
- x_a += b_to_c;
- x_c += c_to_a;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- while (--y_a >= 0) {
- drawFlatScanLine(Raster.pixels, y_c, x_c >> 16, x_b >> 16, z_c, depth_slope, rgb);
- x_b += a_to_b;
- x_c += c_to_a;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- }
- }
- }
- }
- }
- private static void drawFlatScanLine(int[] dest, int dest_off, int start_x, int end_x, float depth,
- float depth_slope, int rgb) {
- if (Rasterizer.restrict_edges) {
- if (end_x > Raster.viewportRx)
- end_x = Raster.viewportRx;
- if (start_x < 0)
- start_x = 0;
- }
- if (start_x >= end_x)
- return;
- dest_off += start_x - 1;
- int loops = end_x - start_x >> 2;
- depth += depth_slope * (float) start_x;
- if (Rasterizer.alpha == 0) {
- while (--loops >= 0) {
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb;
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb;
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb;
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb;
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- }
- for (loops = end_x - start_x & 3; --loops >= 0;) {
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb;
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- }
- return;
- }
- int src_alpha = Rasterizer.alpha;
- int dest_alpha = 256 - Rasterizer.alpha;
- rgb = ((rgb & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((rgb & 0xff00) * dest_alpha >> 8 & 0xff00);
- while (--loops >= 0) {
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
- + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
- + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
- + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
- + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- }
- for (loops = end_x - start_x & 3; --loops >= 0;) {
- dest_off++;
- if (depth < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = rgb + ((dest[dest_off] & 0xff00ff) * src_alpha >> 8 & 0xff00ff)
- + ((dest[dest_off] & 0xff00) * src_alpha >> 8 & 0xff00);
- Raster.depthBuffer[dest_off] = depth;
- }
- depth += depth_slope;
- }
- }
- private static int anInt2229;
- private static int anInt2230;
- private static int anInt2232;
- private static int anInt2243;
- public static void drawTexturedTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int k1, int l1,
- int i2, int Px, int Mx, int Nx, int Pz, int Mz, int Nz, int Py, int My, int Ny, int k4, float z_a,
- float z_b, float z_c) {
- if (z_a < 0 || z_b < 0 || z_c < 0)
- return;
- int texture[] = method371(k4);
- aBoolean1463 = !aBooleanArray1475[k4];
- Mx = Px - Mx;
- Mz = Pz - Mz;
- My = Py - My;
- Nx -= Px;
- Nz -= Pz;
- Ny -= Py;
- int Oa = Nx * Pz - Nz * Px << (Client.log_view_dist == 9 ? 14 : 15);
- int Ha = Nz * Py - Ny * Pz << 8;
- int Va = Ny * Px - Nx * Py << 5;
- int Ob = Mx * Pz - Mz * Px << (Client.log_view_dist == 9 ? 14 : 15);
- int Hb = Mz * Py - My * Pz << 8;
- int Vb = My * Px - Mx * Py << 5;
- int Oc = Mz * Nx - Mx * Nz << (Client.log_view_dist == 9 ? 14 : 15);
- int Hc = My * Nz - Mz * Ny << 8;
- int Vc = Mx * Ny - My * Nx << 5;
- int a_to_b = 0;
- int grad_a_off = 0;
- if (y_b != y_a) {
- a_to_b = (x_b - x_a << 16) / (y_b - y_a);
- grad_a_off = (l1 - k1 << 16) / (y_b - y_a);
- }
- int b_to_c = 0;
- int grad_b_off = 0;
- if (y_c != y_b) {
- b_to_c = (x_c - x_b << 16) / (y_c - y_b);
- grad_b_off = (i2 - l1 << 16) / (y_c - y_b);
- }
- int c_to_a = 0;
- int grad_c_off = 0;
- if (y_c != y_a) {
- c_to_a = (x_a - x_c << 16) / (y_a - y_c);
- grad_c_off = (k1 - i2 << 16) / (y_a - y_c);
- }
- float b_aX = x_b - x_a;
- float b_aY = y_b - y_a;
- float c_aX = x_c - x_a;
- float c_aY = y_c - y_a;
- float b_aZ = z_b - z_a;
- float c_aZ = z_c - z_a;
- float div = b_aX * c_aY - c_aX * b_aY;
- float depth_slope = (b_aZ * c_aY - c_aZ * b_aY) / div;
- float depth_increment = (c_aZ * b_aX - b_aZ * c_aX) / div;
- if (y_a <= y_b && y_a <= y_c) {
- if (y_a >= Raster.bottomY)
- return;
- if (y_b > Raster.bottomY)
- y_b = Raster.bottomY;
- if (y_c > Raster.bottomY)
- y_c = Raster.bottomY;
- z_a = z_a - depth_slope * x_a + depth_slope;
- if (y_b < y_c) {
- x_c = x_a <<= 16;
- i2 = k1 <<= 16;
- if (y_a < 0) {
- x_c -= c_to_a * y_a;
- x_a -= a_to_b * y_a;
- z_a -= depth_increment * y_a;
- i2 -= grad_c_off * y_a;
- k1 -= grad_a_off * y_a;
- y_a = 0;
- }
- x_b <<= 16;
- l1 <<= 16;
- if (y_b < 0) {
- x_b -= b_to_c * y_b;
- l1 -= grad_b_off * y_b;
- y_b = 0;
- }
- int k8 = y_a - centerY;
- Oa += Va * k8;
- Ob += Vb * k8;
- Oc += Vc * k8;
- if (y_a != y_b && c_to_a < a_to_b || y_a == y_b && c_to_a > b_to_c) {
- y_c -= y_b;
- y_b -= y_a;
- y_a = lineOffsets[y_a];
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa,
- Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
- x_c += c_to_a;
- x_a += a_to_b;
- z_a += depth_increment;
- i2 += grad_c_off;
- k1 += grad_a_off;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa,
- Ob, Oc, Ha, Hb, Hc, z_a, depth_slope);
- x_c += c_to_a;
- x_b += b_to_c;
- z_a += depth_increment;
- i2 += grad_c_off;
- l1 += grad_b_off;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- y_c -= y_b;
- y_b -= y_a;
- y_a = lineOffsets[y_a];
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_a, depth_slope);
- x_c += c_to_a;
- x_a += a_to_b;
- z_a += depth_increment;
- i2 += grad_c_off;
- k1 += grad_a_off;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_a, depth_slope);
- x_c += c_to_a;
- x_b += b_to_c;
- z_a += depth_increment;
- i2 += grad_c_off;
- l1 += grad_b_off;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- x_b = x_a <<= 16;
- l1 = k1 <<= 16;
- if (y_a < 0) {
- x_b -= c_to_a * y_a;
- x_a -= a_to_b * y_a;
- z_a -= depth_increment * y_a;
- l1 -= grad_c_off * y_a;
- k1 -= grad_a_off * y_a;
- y_a = 0;
- }
- x_c <<= 16;
- i2 <<= 16;
- if (y_c < 0) {
- x_c -= b_to_c * y_c;
- i2 -= grad_b_off * y_c;
- y_c = 0;
- }
- int l8 = y_a - centerY;
- Oa += Va * l8;
- Ob += Vb * l8;
- Oc += Vc * l8;
- if (y_a != y_c && c_to_a < a_to_b || y_a == y_c && b_to_c > a_to_b) {
- y_b -= y_c;
- y_c -= y_a;
- y_a = lineOffsets[y_a];
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_a, depth_slope);
- x_b += c_to_a;
- x_a += a_to_b;
- l1 += grad_c_off;
- k1 += grad_a_off;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_a, depth_slope);
- x_c += b_to_c;
- x_a += a_to_b;
- i2 += grad_b_off;
- k1 += grad_a_off;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- y_b -= y_c;
- y_c -= y_a;
- y_a = lineOffsets[y_a];
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_a, depth_slope);
- x_b += c_to_a;
- x_a += a_to_b;
- l1 += grad_c_off;
- k1 += grad_a_off;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_a, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_a, depth_slope);
- x_c += b_to_c;
- x_a += a_to_b;
- i2 += grad_b_off;
- k1 += grad_a_off;
- z_a += depth_increment;
- y_a += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- if (y_b <= y_c) {
- if (y_b >= Raster.bottomY)
- return;
- if (y_c > Raster.bottomY)
- y_c = Raster.bottomY;
- if (y_a > Raster.bottomY)
- y_a = Raster.bottomY;
- z_b = z_b - depth_slope * x_b + depth_slope;
- if (y_c < y_a) {
- x_a = x_b <<= 16;
- k1 = l1 <<= 16;
- if (y_b < 0) {
- x_a -= a_to_b * y_b;
- x_b -= b_to_c * y_b;
- z_b -= depth_increment * y_b;
- k1 -= grad_a_off * y_b;
- l1 -= grad_b_off * y_b;
- y_b = 0;
- }
- x_c <<= 16;
- i2 <<= 16;
- if (y_c < 0) {
- x_c -= c_to_a * y_c;
- i2 -= grad_c_off * y_c;
- y_c = 0;
- }
- int i9 = y_b - centerY;
- Oa += Va * i9;
- Ob += Vb * i9;
- Oc += Vc * i9;
- if (y_b != y_c && a_to_b < b_to_c || y_b == y_c && a_to_b > c_to_a) {
- y_a -= y_c;
- y_c -= y_b;
- y_b = lineOffsets[y_b];
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa,
- Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
- x_a += a_to_b;
- x_b += b_to_c;
- k1 += grad_a_off;
- l1 += grad_b_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa,
- Ob, Oc, Ha, Hb, Hc, z_b, depth_slope);
- x_a += a_to_b;
- x_c += c_to_a;
- k1 += grad_a_off;
- i2 += grad_c_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- y_a -= y_c;
- y_c -= y_b;
- y_b = lineOffsets[y_b];
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_b, depth_slope);
- x_a += a_to_b;
- x_b += b_to_c;
- k1 += grad_a_off;
- l1 += grad_b_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_b, depth_slope);
- x_a += a_to_b;
- x_c += c_to_a;
- k1 += grad_a_off;
- i2 += grad_c_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- x_c = x_b <<= 16;
- i2 = l1 <<= 16;
- if (y_b < 0) {
- x_c -= a_to_b * y_b;
- x_b -= b_to_c * y_b;
- z_b -= depth_increment * y_b;
- i2 -= grad_a_off * y_b;
- l1 -= grad_b_off * y_b;
- y_b = 0;
- }
- x_a <<= 16;
- k1 <<= 16;
- if (y_a < 0) {
- x_a -= c_to_a * y_a;
- k1 -= grad_c_off * y_a;
- y_a = 0;
- }
- int j9 = y_b - centerY;
- Oa += Va * j9;
- Ob += Vb * j9;
- Oc += Vc * j9;
- if (a_to_b < b_to_c) {
- y_c -= y_a;
- y_a -= y_b;
- y_b = lineOffsets[y_b];
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_b, depth_slope);
- x_c += a_to_b;
- x_b += b_to_c;
- i2 += grad_a_off;
- l1 += grad_b_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_b, depth_slope);
- x_a += c_to_a;
- x_b += b_to_c;
- k1 += grad_c_off;
- l1 += grad_b_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- y_c -= y_a;
- y_a -= y_b;
- y_b = lineOffsets[y_b];
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_b, depth_slope);
- x_c += a_to_b;
- x_b += b_to_c;
- i2 += grad_a_off;
- l1 += grad_b_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_c >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_b, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_b, depth_slope);
- x_a += c_to_a;
- x_b += b_to_c;
- k1 += grad_c_off;
- l1 += grad_b_off;
- z_b += depth_increment;
- y_b += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- if (y_c >= Raster.bottomY)
- return;
- if (y_a > Raster.bottomY)
- y_a = Raster.bottomY;
- if (y_b > Raster.bottomY)
- y_b = Raster.bottomY;
- z_c = z_c - depth_slope * x_c + depth_slope;
- if (y_a < y_b) {
- x_b = x_c <<= 16;
- l1 = i2 <<= 16;
- if (y_c < 0) {
- x_b -= b_to_c * y_c;
- x_c -= c_to_a * y_c;
- z_c -= depth_increment * y_c;
- l1 -= grad_b_off * y_c;
- i2 -= grad_c_off * y_c;
- y_c = 0;
- }
- x_a <<= 16;
- k1 <<= 16;
- if (y_a < 0) {
- x_a -= a_to_b * y_a;
- k1 -= grad_a_off * y_a;
- y_a = 0;
- }
- int k9 = y_c - centerY;
- Oa += Va * k9;
- Ob += Vb * k9;
- Oc += Vc * k9;
- if (b_to_c < c_to_a) {
- y_b -= y_a;
- y_a -= y_c;
- y_c = lineOffsets[y_c];
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_c, depth_slope);
- x_b += b_to_c;
- x_c += c_to_a;
- l1 += grad_b_off;
- i2 += grad_c_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_b >> 16, x_a >> 16, l1 >> 8, k1 >> 8, Oa, Ob,
- Oc, Ha, Hb, Hc, z_c, depth_slope);
- x_b += b_to_c;
- x_a += a_to_b;
- l1 += grad_b_off;
- k1 += grad_a_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- y_b -= y_a;
- y_a -= y_c;
- y_c = lineOffsets[y_c];
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_c, depth_slope);
- x_b += b_to_c;
- x_c += c_to_a;
- l1 += grad_b_off;
- i2 += grad_c_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_a >> 16, x_b >> 16, k1 >> 8, l1 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_c, depth_slope);
- x_b += b_to_c;
- x_a += a_to_b;
- l1 += grad_b_off;
- k1 += grad_a_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- x_a = x_c <<= 16;
- k1 = i2 <<= 16;
- if (y_c < 0) {
- x_a -= b_to_c * y_c;
- x_c -= c_to_a * y_c;
- z_c -= depth_increment * y_c;
- k1 -= grad_b_off * y_c;
- i2 -= grad_c_off * y_c;
- y_c = 0;
- }
- x_b <<= 16;
- l1 <<= 16;
- if (y_b < 0) {
- x_b -= a_to_b * y_b;
- l1 -= grad_a_off * y_b;
- y_b = 0;
- }
- int l9 = y_c - centerY;
- Oa += Va * l9;
- Ob += Vb * l9;
- Oc += Vc * l9;
- if (b_to_c < c_to_a) {
- y_a -= y_b;
- y_b -= y_c;
- y_c = lineOffsets[y_c];
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_a >> 16, x_c >> 16, k1 >> 8, i2 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_c, depth_slope);
- x_a += b_to_c;
- x_c += c_to_a;
- k1 += grad_b_off;
- i2 += grad_c_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_b >> 16, x_c >> 16, l1 >> 8, i2 >> 8, Oa, Ob, Oc,
- Ha, Hb, Hc, z_c, depth_slope);
- x_b += a_to_b;
- x_c += c_to_a;
- l1 += grad_a_off;
- i2 += grad_c_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- return;
- }
- y_a -= y_b;
- y_b -= y_c;
- y_c = lineOffsets[y_c];
- while (--y_b >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_c >> 16, x_a >> 16, i2 >> 8, k1 >> 8, Oa, Ob, Oc, Ha,
- Hb, Hc, z_c, depth_slope);
- x_a += b_to_c;
- x_c += c_to_a;
- k1 += grad_b_off;
- i2 += grad_c_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- while (--y_a >= 0) {
- drawTexturedScanline(Raster.pixels, texture, y_c, x_c >> 16, x_b >> 16, i2 >> 8, l1 >> 8, Oa, Ob, Oc, Ha,
- Hb, Hc, z_c, depth_slope);
- x_b += a_to_b;
- x_c += c_to_a;
- l1 += grad_a_off;
- i2 += grad_c_off;
- z_c += depth_increment;
- y_c += Raster.rasterWidth;
- Oa += Va;
- Ob += Vb;
- Oc += Vc;
- }
- }
- public static void drawTexturedScanline(int dest[], int texture[], int dest_off, int x1, int x2, int shadeValue,
- int gradient, int l1, int i2, int j2, int k2, int l2, int i3, float z1, float z2) {
- int rgb = 0;
- int loops = 0;
- if (x1 >= x2)
- return;
- int j3;
- int k3;
- if (restrict_edges) {
- j3 = (gradient - shadeValue) / (x2 - x1);
- if (x2 > Raster.viewportRx)
- x2 = Raster.viewportRx;
- if (x1 < 0) {
- shadeValue -= x1 * j3;
- x1 = 0;
- }
- if (x1 >= x2)
- return;
- k3 = x2 - x1 >> 3;
- j3 <<= 12;
- shadeValue <<= 9;
- } else {
- if (x2 - x1 > 7) {
- k3 = x2 - x1 >> 3;
- j3 = (gradient - shadeValue) * anIntArray1468[k3] >> 6;
- } else {
- k3 = 0;
- j3 = 0;
- }
- shadeValue <<= 9;
- }
- dest_off += x1;
- z1 += z2 * (float) x1;
- if (lowDetail) {
- int i4 = 0;
- int k4 = 0;
- int k6 = x1 - centerX;
- l1 += (k2 >> 3) * k6;
- i2 += (l2 >> 3) * k6;
- j2 += (i3 >> 3) * k6;
- int i5 = j2 >> 12;
- if (i5 != 0) {
- rgb = l1 / i5;
- loops = i2 / i5;
- if (rgb < 0)
- rgb = 0;
- else if (rgb > 4032)
- rgb = 4032;
- }
- l1 += k2;
- i2 += l2;
- j2 += i3;
- i5 = j2 >> 12;
- if (i5 != 0) {
- i4 = l1 / i5;
- k4 = i2 / i5;
- if (i4 < 7)
- i4 = 7;
- else if (i4 > 4032)
- i4 = 4032;
- }
- int i7 = i4 - rgb >> 3;
- int k7 = k4 - loops >> 3;
- rgb += (shadeValue & 0x600000) >> 3;
- int i8 = shadeValue >> 23;
- if (aBoolean1463) {
- while (k3-- > 0) {
- for (int i = 0; i < 8; i++) {
- if (z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
- Raster.depthBuffer[dest_off] = z1;
- }
- dest_off++;
- z1 += z2;
- rgb += i7;
- loops += k7;
- }
- rgb = i4;
- loops = k4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int j5 = j2 >> 12;
- if (j5 != 0) {
- i4 = l1 / j5;
- k4 = i2 / j5;
- if (i4 < 7)
- i4 = 7;
- else if (i4 > 4032)
- i4 = 4032;
- }
- i7 = i4 - rgb >> 3;
- k7 = k4 - loops >> 3;
- shadeValue += j3;
- rgb += (shadeValue & 0x600000) >> 3;
- i8 = shadeValue >> 23;
- }
- for (k3 = x2 - x1 & 7; k3-- > 0;) {
- if (z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
- Raster.depthBuffer[dest_off] = z1;
- }
- dest_off++;
- z1 += z2;
- rgb += i7;
- loops += k7;
- }
- return;
- }
- while (k3-- > 0) {
- int k8;
- for (int i = 0; i < 8; i++) {
- if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = k8;
- Raster.depthBuffer[dest_off] = z1;
- }
- dest_off++;
- z1 += z2;
- rgb += i7;
- loops += k7;
- }
- rgb = i4;
- loops = k4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int k5 = j2 >> 12;
- if (k5 != 0) {
- i4 = l1 / k5;
- k4 = i2 / k5;
- if (i4 < 7)
- i4 = 7;
- else if (i4 > 4032)
- i4 = 4032;
- }
- i7 = i4 - rgb >> 3;
- k7 = k4 - loops >> 3;
- shadeValue += j3;
- rgb += (shadeValue & 0x600000) >> 3;
- i8 = shadeValue >> 23;
- }
- for (k3 = x2 - x1 & 7; k3-- > 0;) {
- int l8;
- if ((l8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = l8;
- Raster.depthBuffer[dest_off] = z1;
- }
- dest_off++;
- z1 += z2;
- rgb += i7;
- loops += k7;
- }
- return;
- }
- int j4 = 0;
- int l4 = 0;
- int l6 = x1 - centerX;
- l1 += (k2 >> 3) * l6;
- i2 += (l2 >> 3) * l6;
- j2 += (i3 >> 3) * l6;
- int l5 = j2 >> 14;
- if (l5 != 0) {
- rgb = l1 / l5;
- loops = i2 / l5;
- if (rgb < 0)
- rgb = 0;
- else if (rgb > 16256)
- rgb = 16256;
- }
- l1 += k2;
- i2 += l2;
- j2 += i3;
- l5 = j2 >> 14;
- if (l5 != 0) {
- j4 = l1 / l5;
- l4 = i2 / l5;
- if (j4 < 7)
- j4 = 7;
- else if (j4 > 16256)
- j4 = 16256;
- }
- int j7 = j4 - rgb >> 3;
- int l7 = l4 - loops >> 3;
- rgb += shadeValue & 0x600000;
- int j8 = shadeValue >> 23;
- if (aBoolean1463) {
- while (k3-- > 0) {
- for (int i = 0; i < 8; i++) {
- if (z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
- Raster.depthBuffer[dest_off] = z1;
- }
- z1 += z2;
- dest_off++;
- rgb += j7;
- loops += l7;
- }
- rgb = j4;
- loops = l4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int i6 = j2 >> 14;
- if (i6 != 0) {
- j4 = l1 / i6;
- l4 = i2 / i6;
- if (j4 < 7)
- j4 = 7;
- else if (j4 > 16256)
- j4 = 16256;
- }
- j7 = j4 - rgb >> 3;
- l7 = l4 - loops >> 3;
- shadeValue += j3;
- rgb += shadeValue & 0x600000;
- j8 = shadeValue >> 23;
- }
- for (k3 = x2 - x1 & 7; k3-- > 0;) {
- if (z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
- Raster.depthBuffer[dest_off] = z1;
- }
- dest_off++;
- z1 += z2;
- rgb += j7;
- loops += l7;
- }
- return;
- }
- while (k3-- > 0) {
- int i9;
- for (int i = 0; i < 8; i++) {
- if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = i9;
- Raster.depthBuffer[dest_off] = z1;
- }
- dest_off++;
- z1 += z2;
- rgb += j7;
- loops += l7;
- }
- rgb = j4;
- loops = l4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int j6 = j2 >> 14;
- if (j6 != 0) {
- j4 = l1 / j6;
- l4 = i2 / j6;
- if (j4 < 7)
- j4 = 7;
- else if (j4 > 16256)
- j4 = 16256;
- }
- j7 = j4 - rgb >> 3;
- l7 = l4 - loops >> 3;
- shadeValue += j3;
- rgb += shadeValue & 0x600000;
- j8 = shadeValue >> 23;
- }
- for (int l3 = x2 - x1 & 7; l3-- > 0;) {
- int j9;
- if ((j9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0 && z1 < Raster.depthBuffer[dest_off]) {
- dest[dest_off] = j9;
- Raster.depthBuffer[dest_off] = z1;
- }
- z1 += z2;
- dest_off++;
- rgb += j7;
- loops += l7;
- }
- }
- public static void method374(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
- int j2 = 0;
- int k2 = 0;
- if (j != i) {
- j2 = (i1 - l << 16) / (j - i);
- k2 = (l1 - k1 << 15) / (j - i);
- }
- int l2 = 0;
- int i3 = 0;
- if (k != j) {
- l2 = (j1 - i1 << 16) / (k - j);
- i3 = (i2 - l1 << 15) / (k - j);
- }
- int j3 = 0;
- int k3 = 0;
- if (k != i) {
- j3 = (l - j1 << 16) / (i - k);
- k3 = (k1 - i2 << 15) / (i - k);
- }
- if (i <= j && i <= k) {
- if (i >= Raster.bottomY)
- return;
- if (j > Raster.bottomY)
- j = Raster.bottomY;
- if (k > Raster.bottomY)
- k = Raster.bottomY;
- if (j < k) {
- j1 = l <<= 16;
- i2 = k1 <<= 15;
- if (i < 0) {
- j1 -= j3 * i;
- l -= j2 * i;
- i2 -= k3 * i;
- k1 -= k2 * i;
- i = 0;
- }
- i1 <<= 16;
- l1 <<= 15;
- if (j < 0) {
- i1 -= l2 * j;
- l1 -= i3 * j;
- j = 0;
- }
- if (i != j && j3 < j2 || i == j && j3 > l2) {
- k -= j;
- j -= i;
- for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
- method375(Raster.pixels, i, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
- j1 += j3;
- l += j2;
- i2 += k3;
- k1 += k2;
- }
- while (--k >= 0) {
- method375(Raster.pixels, i, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
- j1 += j3;
- i1 += l2;
- i2 += k3;
- l1 += i3;
- i += Raster.rasterWidth;
- }
- return;
- }
- k -= j;
- j -= i;
- for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
- method375(Raster.pixels, i, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
- j1 += j3;
- l += j2;
- i2 += k3;
- k1 += k2;
- }
- while (--k >= 0) {
- method375(Raster.pixels, i, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
- j1 += j3;
- i1 += l2;
- i2 += k3;
- l1 += i3;
- i += Raster.rasterWidth;
- }
- return;
- }
- i1 = l <<= 16;
- l1 = k1 <<= 15;
- if (i < 0) {
- i1 -= j3 * i;
- l -= j2 * i;
- l1 -= k3 * i;
- k1 -= k2 * i;
- i = 0;
- }
- j1 <<= 16;
- i2 <<= 15;
- if (k < 0) {
- j1 -= l2 * k;
- i2 -= i3 * k;
- k = 0;
- }
- if (i != k && j3 < j2 || i == k && l2 > j2) {
- j -= k;
- k -= i;
- for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
- method375(Raster.pixels, i, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
- i1 += j3;
- l += j2;
- l1 += k3;
- k1 += k2;
- }
- while (--j >= 0) {
- method375(Raster.pixels, i, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
- j1 += l2;
- l += j2;
- i2 += i3;
- k1 += k2;
- i += Raster.rasterWidth;
- }
- return;
- }
- j -= k;
- k -= i;
- for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
- method375(Raster.pixels, i, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
- i1 += j3;
- l += j2;
- l1 += k3;
- k1 += k2;
- }
- while (--j >= 0) {
- method375(Raster.pixels, i, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
- j1 += l2;
- l += j2;
- i2 += i3;
- k1 += k2;
- i += Raster.rasterWidth;
- }
- return;
- }
- if (j <= k) {
- if (j >= Raster.bottomY)
- return;
- if (k > Raster.bottomY)
- k = Raster.bottomY;
- if (i > Raster.bottomY)
- i = Raster.bottomY;
- if (k < i) {
- l = i1 <<= 16;
- k1 = l1 <<= 15;
- if (j < 0) {
- l -= j2 * j;
- i1 -= l2 * j;
- k1 -= k2 * j;
- l1 -= i3 * j;
- j = 0;
- }
- j1 <<= 16;
- i2 <<= 15;
- if (k < 0) {
- j1 -= j3 * k;
- i2 -= k3 * k;
- k = 0;
- }
- if (j != k && j2 < l2 || j == k && j2 > j3) {
- i -= k;
- k -= j;
- for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
- method375(Raster.pixels, j, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
- l += j2;
- i1 += l2;
- k1 += k2;
- l1 += i3;
- }
- while (--i >= 0) {
- method375(Raster.pixels, j, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
- l += j2;
- j1 += j3;
- k1 += k2;
- i2 += k3;
- j += Raster.rasterWidth;
- }
- return;
- }
- i -= k;
- k -= j;
- for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
- method375(Raster.pixels, j, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
- l += j2;
- i1 += l2;
- k1 += k2;
- l1 += i3;
- }
- while (--i >= 0) {
- method375(Raster.pixels, j, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
- l += j2;
- j1 += j3;
- k1 += k2;
- i2 += k3;
- j += Raster.rasterWidth;
- }
- return;
- }
- j1 = i1 <<= 16;
- i2 = l1 <<= 15;
- if (j < 0) {
- j1 -= j2 * j;
- i1 -= l2 * j;
- i2 -= k2 * j;
- l1 -= i3 * j;
- j = 0;
- }
- l <<= 16;
- k1 <<= 15;
- if (i < 0) {
- l -= j3 * i;
- k1 -= k3 * i;
- i = 0;
- }
- if (j2 < l2) {
- k -= i;
- i -= j;
- for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
- method375(Raster.pixels, j, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
- j1 += j2;
- i1 += l2;
- i2 += k2;
- l1 += i3;
- }
- while (--k >= 0) {
- method375(Raster.pixels, j, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
- l += j3;
- i1 += l2;
- k1 += k3;
- l1 += i3;
- j += Raster.rasterWidth;
- }
- return;
- }
- k -= i;
- i -= j;
- for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
- method375(Raster.pixels, j, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
- j1 += j2;
- i1 += l2;
- i2 += k2;
- l1 += i3;
- }
- while (--k >= 0) {
- method375(Raster.pixels, j, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
- l += j3;
- i1 += l2;
- k1 += k3;
- l1 += i3;
- j += Raster.rasterWidth;
- }
- return;
- }
- if (k >= Raster.bottomY)
- return;
- if (i > Raster.bottomY)
- i = Raster.bottomY;
- if (j > Raster.bottomY)
- j = Raster.bottomY;
- if (i < j) {
- i1 = j1 <<= 16;
- l1 = i2 <<= 15;
- if (k < 0) {
- i1 -= l2 * k;
- j1 -= j3 * k;
- l1 -= i3 * k;
- i2 -= k3 * k;
- k = 0;
- }
- l <<= 16;
- k1 <<= 15;
- if (i < 0) {
- l -= j2 * i;
- k1 -= k2 * i;
- i = 0;
- }
- if (l2 < j3) {
- j -= i;
- i -= k;
- for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
- method375(Raster.pixels, k, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
- i1 += l2;
- j1 += j3;
- l1 += i3;
- i2 += k3;
- }
- while (--j >= 0) {
- method375(Raster.pixels, k, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
- i1 += l2;
- l += j2;
- l1 += i3;
- k1 += k2;
- k += Raster.rasterWidth;
- }
- return;
- }
- j -= i;
- i -= k;
- for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
- method375(Raster.pixels, k, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
- i1 += l2;
- j1 += j3;
- l1 += i3;
- i2 += k3;
- }
- while (--j >= 0) {
- method375(Raster.pixels, k, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
- i1 += l2;
- l += j2;
- l1 += i3;
- k1 += k2;
- k += Raster.rasterWidth;
- }
- return;
- }
- l = j1 <<= 16;
- k1 = i2 <<= 15;
- if (k < 0) {
- l -= l2 * k;
- j1 -= j3 * k;
- k1 -= i3 * k;
- i2 -= k3 * k;
- k = 0;
- }
- i1 <<= 16;
- l1 <<= 15;
- if (j < 0) {
- i1 -= j2 * j;
- l1 -= k2 * j;
- j = 0;
- }
- if (l2 < j3) {
- i -= j;
- j -= k;
- for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
- method375(Raster.pixels, k, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
- l += l2;
- j1 += j3;
- k1 += i3;
- i2 += k3;
- }
- while (--i >= 0) {
- method375(Raster.pixels, k, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
- i1 += j2;
- j1 += j3;
- l1 += k2;
- i2 += k3;
- k += Raster.rasterWidth;
- }
- return;
- }
- i -= j;
- j -= k;
- for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
- method375(Raster.pixels, k, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
- l += l2;
- j1 += j3;
- k1 += i3;
- i2 += k3;
- }
- while (--i >= 0) {
- method375(Raster.pixels, k, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
- i1 += j2;
- j1 += j3;
- l1 += k2;
- i2 += k3;
- k += Raster.rasterWidth;
- }
- }
- public static void method375(int[] ai, int i, int l, int i1, int j1, int k1) {
- int j;
- int k;
- int l1 = 0;
- if (restrict_edges) {
- if (i1 > Raster.viewportRx)
- i1 = Raster.viewportRx;
- if (l < 0) {
- j1 -= l * l1;
- l = 0;
- }
- }
- if (l < i1) {
- i += l;
- j1 += l1 * l;
- if (notTextured) {
- k = i1 - l >> 2;
- if (k > 0)
- l1 = (k1 - j1) * anIntArray1468[k] >> 15;
- else
- l1 = 0;
- if (alpha == 0) {
- if (k > 0) {
- do {
- j = hsl2rgb[j1 >> 8];
- j1 += l1;
- ai[i++] = j;
- ai[i++] = j;
- ai[i++] = j;
- ai[i++] = j;
- } while (--k > 0);
- }
- k = i1 - l & 0x3;
- if (k > 0) {
- j = hsl2rgb[j1 >> 8];
- do
- ai[i++] = j;
- while (--k > 0);
- }
- } else {
- int j2 = alpha;
- int l2 = 256 - alpha;
- if (k > 0) {
- do {
- j = hsl2rgb[j1 >> 8];
- j1 += l1;
- j = (((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00));
- int h = ai[i];
- ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
- h = ai[i];
- ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
- h = ai[i];
- ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
- h = ai[i];
- ai[i++] = (j + ((h & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((h & 0xff00) * j2 >> 8 & 0xff00));
- } while (--k > 0);
- }
- k = i1 - l & 0x3;
- if (k > 0) {
- j = hsl2rgb[j1 >> 8];
- j = (((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00));
- do {
- int i_61_ = ai[i];
- ai[i++] = (j + ((i_61_ & 0xff00ff) * j2 >> 8 & 0xff00ff)
- + ((i_61_ & 0xff00) * j2 >> 8 & 0xff00));
- } while (--k > 0);
- }
- }
- } else {
- int i2 = (k1 - j1) / (i1 - l);
- k = i1 - l;
- if (alpha == 0) {
- do {
- ai[i++] = hsl2rgb[j1 >> 8];
- j1 += i2;
- } while (--k > 0);
- } else {
- int i_62_ = alpha;
- int i_63_ = 256 - alpha;
- do {
- j = hsl2rgb[j1 >> 8];
- j1 += i2;
- j = (((j & 0xff00ff) * i_63_ >> 8 & 0xff00ff) + ((j & 0xff00) * i_63_ >> 8 & 0xff00));
- int i_64_ = ai[i];
- ai[i++] = (j + ((i_64_ & 0xff00ff) * i_62_ >> 8 & 0xff00ff)
- + ((i_64_ & 0xff00) * i_62_ >> 8 & 0xff00));
- } while (--k > 0);
- }
- }
- }
- }
- public static void method376(int i, int j, int k, int l, int i1, int j1, int k1) {
- int l1 = 0;
- if (j != i)
- l1 = (i1 - l << 16) / (j - i);
- int i2 = 0;
- if (k != j)
- i2 = (j1 - i1 << 16) / (k - j);
- int j2 = 0;
- if (k != i)
- j2 = (l - j1 << 16) / (i - k);
- if (i <= j && i <= k) {
- if (i >= Raster.bottomY)
- return;
- if (j > Raster.bottomY)
- j = Raster.bottomY;
- if (k > Raster.bottomY)
- k = Raster.bottomY;
- if (j < k) {
- j1 = l <<= 16;
- if (i < 0) {
- j1 -= j2 * i;
- l -= l1 * i;
- i = 0;
- }
- i1 <<= 16;
- if (j < 0) {
- i1 -= i2 * j;
- j = 0;
- }
- if (i != j && j2 < l1 || i == j && j2 > i2) {
- k -= j;
- j -= i;
- for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
- method377(Raster.pixels, i, k1, j1 >> 16, l >> 16);
- j1 += j2;
- l += l1;
- }
- while (--k >= 0) {
- method377(Raster.pixels, i, k1, j1 >> 16, i1 >> 16);
- j1 += j2;
- i1 += i2;
- i += Raster.rasterWidth;
- }
- return;
- }
- k -= j;
- j -= i;
- for (i = lineOffsets[i]; --j >= 0; i += Raster.rasterWidth) {
- method377(Raster.pixels, i, k1, l >> 16, j1 >> 16);
- j1 += j2;
- l += l1;
- }
- while (--k >= 0) {
- method377(Raster.pixels, i, k1, i1 >> 16, j1 >> 16);
- j1 += j2;
- i1 += i2;
- i += Raster.rasterWidth;
- }
- return;
- }
- i1 = l <<= 16;
- if (i < 0) {
- i1 -= j2 * i;
- l -= l1 * i;
- i = 0;
- }
- j1 <<= 16;
- if (k < 0) {
- j1 -= i2 * k;
- k = 0;
- }
- if (i != k && j2 < l1 || i == k && i2 > l1) {
- j -= k;
- k -= i;
- for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
- method377(Raster.pixels, i, k1, i1 >> 16, l >> 16);
- i1 += j2;
- l += l1;
- }
- while (--j >= 0) {
- method377(Raster.pixels, i, k1, j1 >> 16, l >> 16);
- j1 += i2;
- l += l1;
- i += Raster.rasterWidth;
- }
- return;
- }
- j -= k;
- k -= i;
- for (i = lineOffsets[i]; --k >= 0; i += Raster.rasterWidth) {
- method377(Raster.pixels, i, k1, l >> 16, i1 >> 16);
- i1 += j2;
- l += l1;
- }
- while (--j >= 0) {
- method377(Raster.pixels, i, k1, l >> 16, j1 >> 16);
- j1 += i2;
- l += l1;
- i += Raster.rasterWidth;
- }
- return;
- }
- if (j <= k) {
- if (j >= Raster.bottomY)
- return;
- if (k > Raster.bottomY)
- k = Raster.bottomY;
- if (i > Raster.bottomY)
- i = Raster.bottomY;
- if (k < i) {
- l = i1 <<= 16;
- if (j < 0) {
- l -= l1 * j;
- i1 -= i2 * j;
- j = 0;
- }
- j1 <<= 16;
- if (k < 0) {
- j1 -= j2 * k;
- k = 0;
- }
- if (j != k && l1 < i2 || j == k && l1 > j2) {
- i -= k;
- k -= j;
- for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
- method377(Raster.pixels, j, k1, l >> 16, i1 >> 16);
- l += l1;
- i1 += i2;
- }
- while (--i >= 0) {
- method377(Raster.pixels, j, k1, l >> 16, j1 >> 16);
- l += l1;
- j1 += j2;
- j += Raster.rasterWidth;
- }
- return;
- }
- i -= k;
- k -= j;
- for (j = lineOffsets[j]; --k >= 0; j += Raster.rasterWidth) {
- method377(Raster.pixels, j, k1, i1 >> 16, l >> 16);
- l += l1;
- i1 += i2;
- }
- while (--i >= 0) {
- method377(Raster.pixels, j, k1, j1 >> 16, l >> 16);
- l += l1;
- j1 += j2;
- j += Raster.rasterWidth;
- }
- return;
- }
- j1 = i1 <<= 16;
- if (j < 0) {
- j1 -= l1 * j;
- i1 -= i2 * j;
- j = 0;
- }
- l <<= 16;
- if (i < 0) {
- l -= j2 * i;
- i = 0;
- }
- if (l1 < i2) {
- k -= i;
- i -= j;
- for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
- method377(Raster.pixels, j, k1, j1 >> 16, i1 >> 16);
- j1 += l1;
- i1 += i2;
- }
- while (--k >= 0) {
- method377(Raster.pixels, j, k1, l >> 16, i1 >> 16);
- l += j2;
- i1 += i2;
- j += Raster.rasterWidth;
- }
- return;
- }
- k -= i;
- i -= j;
- for (j = lineOffsets[j]; --i >= 0; j += Raster.rasterWidth) {
- method377(Raster.pixels, j, k1, i1 >> 16, j1 >> 16);
- j1 += l1;
- i1 += i2;
- }
- while (--k >= 0) {
- method377(Raster.pixels, j, k1, i1 >> 16, l >> 16);
- l += j2;
- i1 += i2;
- j += Raster.rasterWidth;
- }
- return;
- }
- if (k >= Raster.bottomY)
- return;
- if (i > Raster.bottomY)
- i = Raster.bottomY;
- if (j > Raster.bottomY)
- j = Raster.bottomY;
- if (i < j) {
- i1 = j1 <<= 16;
- if (k < 0) {
- i1 -= i2 * k;
- j1 -= j2 * k;
- k = 0;
- }
- l <<= 16;
- if (i < 0) {
- l -= l1 * i;
- i = 0;
- }
- if (i2 < j2) {
- j -= i;
- i -= k;
- for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
- method377(Raster.pixels, k, k1, i1 >> 16, j1 >> 16);
- i1 += i2;
- j1 += j2;
- }
- while (--j >= 0) {
- method377(Raster.pixels, k, k1, i1 >> 16, l >> 16);
- i1 += i2;
- l += l1;
- k += Raster.rasterWidth;
- }
- return;
- }
- j -= i;
- i -= k;
- for (k = lineOffsets[k]; --i >= 0; k += Raster.rasterWidth) {
- method377(Raster.pixels, k, k1, j1 >> 16, i1 >> 16);
- i1 += i2;
- j1 += j2;
- }
- while (--j >= 0) {
- method377(Raster.pixels, k, k1, l >> 16, i1 >> 16);
- i1 += i2;
- l += l1;
- k += Raster.rasterWidth;
- }
- return;
- }
- l = j1 <<= 16;
- if (k < 0) {
- l -= i2 * k;
- j1 -= j2 * k;
- k = 0;
- }
- i1 <<= 16;
- if (j < 0) {
- i1 -= l1 * j;
- j = 0;
- }
- if (i2 < j2) {
- i -= j;
- j -= k;
- for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
- method377(Raster.pixels, k, k1, l >> 16, j1 >> 16);
- l += i2;
- j1 += j2;
- }
- while (--i >= 0) {
- method377(Raster.pixels, k, k1, i1 >> 16, j1 >> 16);
- i1 += l1;
- j1 += j2;
- k += Raster.rasterWidth;
- }
- return;
- }
- i -= j;
- j -= k;
- for (k = lineOffsets[k]; --j >= 0; k += Raster.rasterWidth) {
- method377(Raster.pixels, k, k1, j1 >> 16, l >> 16);
- l += i2;
- j1 += j2;
- }
- while (--i >= 0) {
- method377(Raster.pixels, k, k1, j1 >> 16, i1 >> 16);
- i1 += l1;
- j1 += j2;
- k += Raster.rasterWidth;
- }
- }
- private static void method377(int ai[], int i, int j, int l, int i1) {
- int k;// was parameter
- if (restrict_edges) {
- if (i1 > Raster.viewportRx)
- i1 = Raster.viewportRx;
- if (l < 0)
- l = 0;
- }
- if (l >= i1)
- return;
- i += l;
- k = i1 - l >> 2;
- if (alpha == 0) {
- while (--k >= 0) {
- ai[i++] = j;
- ai[i++] = j;
- ai[i++] = j;
- ai[i++] = j;
- }
- for (k = i1 - l & 3; --k >= 0;)
- ai[i++] = j;
- return;
- }
- int j1 = alpha;
- int k1 = 256 - alpha;
- j = ((j & 0xff00ff) * k1 >> 8 & 0xff00ff) + ((j & 0xff00) * k1 >> 8 & 0xff00);
- while (--k >= 0) {
- ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
- ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
- ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
- ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
- }
- for (k = i1 - l & 3; --k >= 0;)
- ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
- }
- 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,
- int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4) {
- int ai[] = method371(k4);
- aBoolean1463 = !aBooleanArray1475[k4];
- k2 = j2 - k2;
- j3 = i3 - j3;
- i4 = l3 - i4;
- l2 -= j2;
- k3 -= i3;
- j4 -= l3;
- int l4 = l2 * i3 - k3 * j2 << (Client.log_view_dist == 9 ? 14 : 15);
- int i5 = k3 * l3 - j4 * i3 << 8;
- int j5 = j4 * j2 - l2 * l3 << 5;
- int k5 = k2 * i3 - j3 * j2 << (Client.log_view_dist == 9 ? 14 : 15);
- int l5 = j3 * l3 - i4 * i3 << 8;
- int i6 = i4 * j2 - k2 * l3 << 5;
- int j6 = j3 * l2 - k2 * k3 << (Client.log_view_dist == 9 ? 14 : 15);
- int k6 = i4 * k3 - j3 * j4 << 8;
- int l6 = k2 * j4 - i4 * l2 << 5;
- int i7 = 0;
- int j7 = 0;
- if (j != i) {
- i7 = (i1 - l << 16) / (j - i);
- j7 = (l1 - k1 << 16) / (j - i);
- }
- int k7 = 0;
- int l7 = 0;
- if (k != j) {
- k7 = (j1 - i1 << 16) / (k - j);
- l7 = (i2 - l1 << 16) / (k - j);
- }
- int i8 = 0;
- int j8 = 0;
- if (k != i) {
- i8 = (l - j1 << 16) / (i - k);
- j8 = (k1 - i2 << 16) / (i - k);
- }
- if (i <= j && i <= k) {
- if (i >= Raster.bottomY)
- return;
- if (j > Raster.bottomY)
- j = Raster.bottomY;
- if (k > Raster.bottomY)
- k = Raster.bottomY;
- if (j < k) {
- j1 = l <<= 16;
- i2 = k1 <<= 16;
- if (i < 0) {
- j1 -= i8 * i;
- l -= i7 * i;
- i2 -= j8 * i;
- k1 -= j7 * i;
- i = 0;
- }
- i1 <<= 16;
- l1 <<= 16;
- if (j < 0) {
- i1 -= k7 * j;
- l1 -= l7 * j;
- j = 0;
- }
- int k8 = i - centerY;
- l4 += j5 * k8;
- k5 += i6 * k8;
- j6 += l6 * k8;
- if (i != j && i8 < i7 || i == j && i8 > k7) {
- k -= j;
- j -= i;
- i = lineOffsets[i];
- while (--j >= 0) {
- method379(Raster.pixels, ai, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += i8;
- l += i7;
- i2 += j8;
- k1 += j7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--k >= 0) {
- method379(Raster.pixels, ai, i, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += i8;
- i1 += k7;
- i2 += j8;
- l1 += l7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- k -= j;
- j -= i;
- i = lineOffsets[i];
- while (--j >= 0) {
- method379(Raster.pixels, ai, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += i8;
- l += i7;
- i2 += j8;
- k1 += j7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--k >= 0) {
- method379(Raster.pixels, ai, i, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += i8;
- i1 += k7;
- i2 += j8;
- l1 += l7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- i1 = l <<= 16;
- l1 = k1 <<= 16;
- if (i < 0) {
- i1 -= i8 * i;
- l -= i7 * i;
- l1 -= j8 * i;
- k1 -= j7 * i;
- i = 0;
- }
- j1 <<= 16;
- i2 <<= 16;
- if (k < 0) {
- j1 -= k7 * k;
- i2 -= l7 * k;
- k = 0;
- }
- int l8 = i - centerY;
- l4 += j5 * l8;
- k5 += i6 * l8;
- j6 += l6 * l8;
- if (i != k && i8 < i7 || i == k && k7 > i7) {
- j -= k;
- k -= i;
- i = lineOffsets[i];
- while (--k >= 0) {
- method379(Raster.pixels, ai, i, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += i8;
- l += i7;
- l1 += j8;
- k1 += j7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--j >= 0) {
- method379(Raster.pixels, ai, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += k7;
- l += i7;
- i2 += l7;
- k1 += j7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- j -= k;
- k -= i;
- i = lineOffsets[i];
- while (--k >= 0) {
- method379(Raster.pixels, ai, i, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += i8;
- l += i7;
- l1 += j8;
- k1 += j7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--j >= 0) {
- method379(Raster.pixels, ai, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += k7;
- l += i7;
- i2 += l7;
- k1 += j7;
- i += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- if (j <= k) {
- if (j >= Raster.bottomY)
- return;
- if (k > Raster.bottomY)
- k = Raster.bottomY;
- if (i > Raster.bottomY)
- i = Raster.bottomY;
- if (k < i) {
- l = i1 <<= 16;
- k1 = l1 <<= 16;
- if (j < 0) {
- l -= i7 * j;
- i1 -= k7 * j;
- k1 -= j7 * j;
- l1 -= l7 * j;
- j = 0;
- }
- j1 <<= 16;
- i2 <<= 16;
- if (k < 0) {
- j1 -= i8 * k;
- i2 -= j8 * k;
- k = 0;
- }
- int i9 = j - centerY;
- l4 += j5 * i9;
- k5 += i6 * i9;
- j6 += l6 * i9;
- if (j != k && i7 < k7 || j == k && i7 > i8) {
- i -= k;
- k -= j;
- j = lineOffsets[j];
- while (--k >= 0) {
- method379(Raster.pixels, ai, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- l += i7;
- i1 += k7;
- k1 += j7;
- l1 += l7;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--i >= 0) {
- method379(Raster.pixels, ai, j, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- l += i7;
- j1 += i8;
- k1 += j7;
- i2 += j8;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- i -= k;
- k -= j;
- j = lineOffsets[j];
- while (--k >= 0) {
- method379(Raster.pixels, ai, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- l += i7;
- i1 += k7;
- k1 += j7;
- l1 += l7;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--i >= 0) {
- method379(Raster.pixels, ai, j, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- l += i7;
- j1 += i8;
- k1 += j7;
- i2 += j8;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- j1 = i1 <<= 16;
- i2 = l1 <<= 16;
- if (j < 0) {
- j1 -= i7 * j;
- i1 -= k7 * j;
- i2 -= j7 * j;
- l1 -= l7 * j;
- j = 0;
- }
- l <<= 16;
- k1 <<= 16;
- if (i < 0) {
- l -= i8 * i;
- k1 -= j8 * i;
- i = 0;
- }
- int j9 = j - centerY;
- l4 += j5 * j9;
- k5 += i6 * j9;
- j6 += l6 * j9;
- if (i7 < k7) {
- k -= i;
- i -= j;
- j = lineOffsets[j];
- while (--i >= 0) {
- method379(Raster.pixels, ai, j, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += i7;
- i1 += k7;
- i2 += j7;
- l1 += l7;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--k >= 0) {
- method379(Raster.pixels, ai, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- l += i8;
- i1 += k7;
- k1 += j8;
- l1 += l7;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- k -= i;
- i -= j;
- j = lineOffsets[j];
- while (--i >= 0) {
- method379(Raster.pixels, ai, j, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- j1 += i7;
- i1 += k7;
- i2 += j7;
- l1 += l7;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--k >= 0) {
- method379(Raster.pixels, ai, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- l += i8;
- i1 += k7;
- k1 += j8;
- l1 += l7;
- j += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- if (k >= Raster.bottomY)
- return;
- if (i > Raster.bottomY)
- i = Raster.bottomY;
- if (j > Raster.bottomY)
- j = Raster.bottomY;
- if (i < j) {
- i1 = j1 <<= 16;
- l1 = i2 <<= 16;
- if (k < 0) {
- i1 -= k7 * k;
- j1 -= i8 * k;
- l1 -= l7 * k;
- i2 -= j8 * k;
- k = 0;
- }
- l <<= 16;
- k1 <<= 16;
- if (i < 0) {
- l -= i7 * i;
- k1 -= j7 * i;
- i = 0;
- }
- int k9 = k - centerY;
- l4 += j5 * k9;
- k5 += i6 * k9;
- j6 += l6 * k9;
- if (k7 < i8) {
- j -= i;
- i -= k;
- k = lineOffsets[k];
- while (--i >= 0) {
- method379(Raster.pixels, ai, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += k7;
- j1 += i8;
- l1 += l7;
- i2 += j8;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--j >= 0) {
- method379(Raster.pixels, ai, k, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += k7;
- l += i7;
- l1 += l7;
- k1 += j7;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- j -= i;
- i -= k;
- k = lineOffsets[k];
- while (--i >= 0) {
- method379(Raster.pixels, ai, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += k7;
- j1 += i8;
- l1 += l7;
- i2 += j8;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--j >= 0) {
- method379(Raster.pixels, ai, k, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += k7;
- l += i7;
- l1 += l7;
- k1 += j7;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- l = j1 <<= 16;
- k1 = i2 <<= 16;
- if (k < 0) {
- l -= k7 * k;
- j1 -= i8 * k;
- k1 -= l7 * k;
- i2 -= j8 * k;
- k = 0;
- }
- i1 <<= 16;
- l1 <<= 16;
- if (j < 0) {
- i1 -= i7 * j;
- l1 -= j7 * j;
- j = 0;
- }
- int l9 = k - centerY;
- l4 += j5 * l9;
- k5 += i6 * l9;
- j6 += l6 * l9;
- if (k7 < i8) {
- i -= j;
- j -= k;
- k = lineOffsets[k];
- while (--j >= 0) {
- method379(Raster.pixels, ai, k, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- l += k7;
- j1 += i8;
- k1 += l7;
- i2 += j8;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--i >= 0) {
- method379(Raster.pixels, ai, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += i7;
- j1 += i8;
- l1 += j7;
- i2 += j8;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- return;
- }
- i -= j;
- j -= k;
- k = lineOffsets[k];
- while (--j >= 0) {
- method379(Raster.pixels, ai, k, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6, i5, l5, k6);
- l += k7;
- j1 += i8;
- k1 += l7;
- i2 += j8;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- while (--i >= 0) {
- method379(Raster.pixels, ai, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6, i5, l5, k6);
- i1 += i7;
- j1 += i8;
- l1 += j7;
- i2 += j8;
- k += Raster.rasterWidth;
- l4 += j5;
- k5 += i6;
- j6 += l6;
- }
- }
- private static void method379(int ai[], int ai1[], int k, int l, int i1, int j1, int k1, int l1, int i2, int j2,
- int k2, int l2, int i3) {
- int i = 0;// was parameter
- int j = 0;// was parameter
- if (l >= i1)
- return;
- int j3;
- int k3;
- if (restrict_edges) {
- j3 = (k1 - j1) / (i1 - l);
- if (i1 > Raster.viewportRx)
- i1 = Raster.viewportRx;
- if (l < 0) {
- j1 -= l * j3;
- l = 0;
- }
- if (l >= i1)
- return;
- k3 = i1 - l >> 3;
- j3 <<= 12;
- j1 <<= 9;
- } else {
- if (i1 - l > 7) {
- k3 = i1 - l >> 3;
- j3 = (k1 - j1) * anIntArray1468[k3] >> 6;
- } else {
- k3 = 0;
- j3 = 0;
- }
- j1 <<= 9;
- }
- k += l;
- if (lowDetail) {
- int i4 = 0;
- int k4 = 0;
- int k6 = l - centerX;
- l1 += (k2 >> 3) * k6;
- i2 += (l2 >> 3) * k6;
- j2 += (i3 >> 3) * k6;
- int i5 = j2 >> 12;
- if (i5 != 0) {
- i = l1 / i5;
- j = i2 / i5;
- if (i < 0)
- i = 0;
- else if (i > 4032)
- i = 4032;
- }
- l1 += k2;
- i2 += l2;
- j2 += i3;
- i5 = j2 >> 12;
- if (i5 != 0) {
- i4 = l1 / i5;
- k4 = i2 / i5;
- if (i4 < 7)
- i4 = 7;
- else if (i4 > 4032)
- i4 = 4032;
- }
- int i7 = i4 - i >> 3;
- int k7 = k4 - j >> 3;
- i += (j1 & 0x600000) >> 3;
- int i8 = j1 >> 23;
- if (aBoolean1463) {
- while (k3-- > 0) {
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i = i4;
- j = k4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int j5 = j2 >> 12;
- if (j5 != 0) {
- i4 = l1 / j5;
- k4 = i2 / j5;
- if (i4 < 7)
- i4 = 7;
- else if (i4 > 4032)
- i4 = 4032;
- }
- i7 = i4 - i >> 3;
- k7 = k4 - j >> 3;
- j1 += j3;
- i += (j1 & 0x600000) >> 3;
- i8 = j1 >> 23;
- }
- for (k3 = i1 - l & 7; k3-- > 0;) {
- ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
- i += i7;
- j += k7;
- }
- return;
- }
- while (k3-- > 0) {
- int k8;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i += i7;
- j += k7;
- if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = k8;
- k++;
- i = i4;
- j = k4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int k5 = j2 >> 12;
- if (k5 != 0) {
- i4 = l1 / k5;
- k4 = i2 / k5;
- if (i4 < 7)
- i4 = 7;
- else if (i4 > 4032)
- i4 = 4032;
- }
- i7 = i4 - i >> 3;
- k7 = k4 - j >> 3;
- j1 += j3;
- i += (j1 & 0x600000) >> 3;
- i8 = j1 >> 23;
- }
- for (k3 = i1 - l & 7; k3-- > 0;) {
- int l8;
- if ((l8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
- ai[k] = l8;
- k++;
- i += i7;
- j += k7;
- }
- return;
- }
- int j4 = 0;
- int l4 = 0;
- int l6 = l - centerX;
- l1 += (k2 >> 3) * l6;
- i2 += (l2 >> 3) * l6;
- j2 += (i3 >> 3) * l6;
- int l5 = j2 >> 14;
- if (l5 != 0) {
- i = l1 / l5;
- j = i2 / l5;
- if (i < 0)
- i = 0;
- else if (i > 16256)
- i = 16256;
- }
- l1 += k2;
- i2 += l2;
- j2 += i3;
- l5 = j2 >> 14;
- if (l5 != 0) {
- j4 = l1 / l5;
- l4 = i2 / l5;
- if (j4 < 7)
- j4 = 7;
- else if (j4 > 16256)
- j4 = 16256;
- }
- int j7 = j4 - i >> 3;
- int l7 = l4 - j >> 3;
- i += j1 & 0x600000;
- int j8 = j1 >> 23;
- if (aBoolean1463) {
- while (k3-- > 0) {
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i = j4;
- j = l4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int i6 = j2 >> 14;
- if (i6 != 0) {
- j4 = l1 / i6;
- l4 = i2 / i6;
- if (j4 < 7)
- j4 = 7;
- else if (j4 > 16256)
- j4 = 16256;
- }
- j7 = j4 - i >> 3;
- l7 = l4 - j >> 3;
- j1 += j3;
- i += j1 & 0x600000;
- j8 = j1 >> 23;
- }
- for (k3 = i1 - l & 7; k3-- > 0;) {
- ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
- i += j7;
- j += l7;
- }
- return;
- }
- while (k3-- > 0) {
- int i9;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i += j7;
- j += l7;
- if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = i9;
- k++;
- i = j4;
- j = l4;
- l1 += k2;
- i2 += l2;
- j2 += i3;
- int j6 = j2 >> 14;
- if (j6 != 0) {
- j4 = l1 / j6;
- l4 = i2 / j6;
- if (j4 < 7)
- j4 = 7;
- else if (j4 > 16256)
- j4 = 16256;
- }
- j7 = j4 - i >> 3;
- l7 = l4 - j >> 3;
- j1 += j3;
- i += j1 & 0x600000;
- j8 = j1 >> 23;
- }
- for (int l3 = i1 - l & 7; l3-- > 0;) {
- int j9;
- if ((j9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
- ai[k] = j9;
- k++;
- i += j7;
- j += l7;
- }
- }
- public static void nullify() {
- anIntArray1468 = null;
- anIntArray1468 = null;
- SINE = null;
- COSINE = null;
- lineOffsets = null;
- aBackgroundArray1474s = null;
- aBooleanArray1475 = null;
- averageTextureColours = null;
- textureRequestPixelBuffer = null;
- texturesPixelBuffer = null;
- anIntArray1480 = null;
- hsl2rgb = null;
- currentPalette = null;
- }
- public static void setBounds(int offSetX, int offSetY) {
- lineOffsets = new int[offSetY];
- for (int l = 0; l < offSetY; l++) {
- lineOffsets[l] = offSetX * l;
- }
- centerX = offSetX / 2;
- centerY = offSetY / 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement