alpha
Login
or
Join now
sickday.tngl.sh
/
hla-client
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
A RuneTek3 client (377) that is deobfuscated, converted to Kotlin, and includes QoL improvements.
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Resterizer3d now 100% refactored
author
Henning Berge
date
6 years ago
(Feb 21, 2020, 1:35 PM +0100)
commit
bf84ca22
bf84ca222f6f6ecd1f1a08962cc696d7945403e8
parent
faac07ff
faac07ff3c17d15b52d7c984898f35e5c6d9a934
+2319
-2073
9 changed files
Expand all
Collapse all
Unified
Split
src
main
java
com
jagex
runescape
Game.java
cache
def
ItemDefinition.java
media
ImageRGB.java
IndexedImage.java
media
Rasterizer.java
Rasterizer3D.java
renderable
Model.java
scene
Region.java
Scene.java
+35
-35
src/main/java/com/jagex/runescape/Game.java
Reviewed
···
5224
5224
}
5225
5225
5226
5226
drawLoadingText(83, "Unpacking textures");
5227
5227
-
Rasterizer3D.loadIndexedImages(textureArchive);
5228
5228
-
Rasterizer3D.method501(0.80000000000000004D);
5229
5229
-
Rasterizer3D.method496(20);
5227
5227
+
Rasterizer3D.unpackTextures(textureArchive);
5228
5228
+
Rasterizer3D.calculatePalette(0.80000000000000004D);
5229
5229
+
Rasterizer3D.resetTextures(20);
5230
5230
drawLoadingText(86, "Unpacking config");
5231
5231
AnimationSequence.load(configArchive);
5232
5232
GameObjectDefinition.load(configArchive);
···
5265
5265
int maxWidth = 0;
5266
5266
5267
5267
for (int x = 0; x < 34; x++) {
5268
5268
-
if (minimapBackgroundImage.pixels[x + y * minimapBackgroundImage.width] == 0) {
5268
5268
+
if (minimapBackgroundImage.imgPixels[x + y * minimapBackgroundImage.imgWidth] == 0) {
5269
5269
if (minWidth == 999)
5270
5270
minWidth = x;
5271
5271
···
5288
5288
int maxWidth = 0;
5289
5289
5290
5290
for (int x = 25; x < 172; x++) {
5291
5291
-
if (minimapBackgroundImage.pixels[x + y * minimapBackgroundImage.width] == 0
5291
5291
+
if (minimapBackgroundImage.imgPixels[x + y * minimapBackgroundImage.imgWidth] == 0
5292
5292
&& (x > 34 || y > 34)) {
5293
5293
if (minWidth == 999)
5294
5294
minWidth = x;
···
5307
5307
anIntArray920[y - 5] = maxWidth - minWidth;
5308
5308
}
5309
5309
5310
5310
-
Rasterizer3D.method494(765, 503);
5310
5310
+
Rasterizer3D.setBounds(765, 503);
5311
5311
fullScreenTextureArray = Rasterizer3D.lineOffsets;
5312
5312
5313
5313
-
Rasterizer3D.method494(479, 96);
5313
5313
+
Rasterizer3D.setBounds(479, 96);
5314
5314
chatboxLineOffsets = Rasterizer3D.lineOffsets;
5315
5315
5316
5316
-
Rasterizer3D.method494(190, 261);
5316
5316
+
Rasterizer3D.setBounds(190, 261);
5317
5317
sidebarOffsets = Rasterizer3D.lineOffsets;
5318
5318
5319
5319
-
Rasterizer3D.method494(512, 334);
5319
5319
+
Rasterizer3D.setBounds(512, 334);
5320
5320
viewportOffsets = Rasterizer3D.lineOffsets;
5321
5321
5322
5322
int[] ai = new int[9];
···
5350
5350
if (!lowMemory) {
5351
5351
for (int k = 0; k < anIntArray1290.length; k++) {
5352
5352
int l = anIntArray1290[k];
5353
5353
-
if (Rasterizer3D.anIntArray1546[l] >= i) {
5354
5354
-
IndexedImage class50_sub1_sub1_sub3 = Rasterizer3D.aClass50_Sub1_Sub1_Sub3Array1540[l];
5355
5355
-
int i1 = class50_sub1_sub1_sub3.width * class50_sub1_sub1_sub3.height - 1;
5356
5356
-
int j1 = class50_sub1_sub1_sub3.width * tickDelta * 2;
5357
5357
-
byte[] abyte0 = class50_sub1_sub1_sub3.pixels;
5353
5353
+
if (Rasterizer3D.textureLastUsed[l] >= i) {
5354
5354
+
IndexedImage class50_sub1_sub1_sub3 = Rasterizer3D.textureImages[l];
5355
5355
+
int i1 = class50_sub1_sub1_sub3.imgWidth * class50_sub1_sub1_sub3.height - 1;
5356
5356
+
int j1 = class50_sub1_sub1_sub3.imgWidth * tickDelta * 2;
5357
5357
+
byte[] abyte0 = class50_sub1_sub1_sub3.imgPixels;
5358
5358
byte[] abyte1 = aByteArray1245;
5359
5359
for (int k1 = 0; k1 <= i1; k1++)
5360
5360
abyte1[k1] = abyte0[k1 - j1 & i1];
5361
5361
5362
5362
-
class50_sub1_sub1_sub3.pixels = abyte1;
5362
5362
+
class50_sub1_sub1_sub3.imgPixels = abyte1;
5363
5363
aByteArray1245 = abyte0;
5364
5364
-
Rasterizer3D.method499(l, 9);
5364
5364
+
Rasterizer3D.resetTexture(l);
5365
5365
}
5366
5366
}
5367
5367
···
6912
6912
if (class50_sub1_sub1_sub3 != null) {
6913
6913
int l1 = 0;
6914
6914
for (int j2 = 0; j2 < class50_sub1_sub1_sub3.height; j2++) {
6915
6915
-
for (int l2 = 0; l2 < class50_sub1_sub1_sub3.width; l2++)
6916
6916
-
if (class50_sub1_sub1_sub3.pixels[l1++] != 0) {
6915
6915
+
for (int l2 = 0; l2 < class50_sub1_sub1_sub3.imgWidth; l2++)
6916
6916
+
if (class50_sub1_sub1_sub3.imgPixels[l1++] != 0) {
6917
6917
int i3 = l2 + 16 + class50_sub1_sub1_sub3.xDrawOffset;
6918
6918
int j3 = j2 + 16 + class50_sub1_sub1_sub3.yDrawOffset;
6919
6919
int k3 = i3 + (j3 << 7);
···
7237
7237
aClass18_1157.createRasterizer();
7238
7238
7239
7239
if (minimapState == 2) {
7240
7240
-
byte[] mmBackgroundPixels = minimapBackgroundImage.pixels;
7240
7240
+
byte[] mmBackgroundPixels = minimapBackgroundImage.imgPixels;
7241
7241
int[] rasterPixels = Rasterizer.pixels;
7242
7242
int pixelCount = mmBackgroundPixels.length;
7243
7243
···
7699
7699
7700
7700
}
7701
7701
System.gc();
7702
7702
-
Rasterizer3D.method496(20);
7702
7702
+
Rasterizer3D.resetTextures(20);
7703
7703
onDemandRequester.immediateRequestCount();
7704
7704
int l = (chunkX - 6) / 8 - 1;
7705
7705
int k1 = (chunkX + 6) / 8 + 1;
···
8232
8232
int config = widgetSettings[j];
8233
8233
if (action == 1) {
8234
8234
if (config == 1)
8235
8235
-
Rasterizer3D.method501(0.90000000000000002D);
8235
8235
+
Rasterizer3D.calculatePalette(0.90000000000000002D);
8236
8236
if (config == 2)
8237
8237
-
Rasterizer3D.method501(0.80000000000000004D);
8237
8237
+
Rasterizer3D.calculatePalette(0.80000000000000004D);
8238
8238
if (config == 3)
8239
8239
-
Rasterizer3D.method501(0.69999999999999996D);
8239
8239
+
Rasterizer3D.calculatePalette(0.69999999999999996D);
8240
8240
if (config == 4)
8241
8241
-
Rasterizer3D.method501(0.59999999999999998D);
8241
8241
+
Rasterizer3D.calculatePalette(0.59999999999999998D);
8242
8242
ItemDefinition.rgbImageCache.removeAll();
8243
8243
welcomeScreenRaised = true;
8244
8244
}
···
10811
10811
y = z * pitchSine + y * pitchCosine >> 16;
10812
10812
z = i;
10813
10813
if (y >= 50) {
10814
10814
-
drawX = Rasterizer3D.centerX + (x << 9) / y;
10815
10815
-
drawY = Rasterizer3D.centerY + (z << 9) / y;
10814
10814
+
drawX = Rasterizer3D.center_x + (x << 9) / y;
10815
10815
+
drawY = Rasterizer3D.center_y + (z << 9) / y;
10816
10816
} else {
10817
10817
drawX = -1;
10818
10818
drawY = -1;
···
11225
11225
if (imageRGB != null)
11226
11226
imageRGB.drawImage(k2, l2);
11227
11227
} else if (child.type == 6) {
11228
11228
-
int k3 = Rasterizer3D.centerX;
11229
11229
-
int k4 = Rasterizer3D.centerY;
11230
11230
-
Rasterizer3D.centerX = k2 + child.width / 2;
11231
11231
-
Rasterizer3D.centerY = l2 + child.height / 2;
11228
11228
+
int k3 = Rasterizer3D.center_x;
11229
11229
+
int k4 = Rasterizer3D.center_y;
11230
11230
+
Rasterizer3D.center_x = k2 + child.width / 2;
11231
11231
+
Rasterizer3D.center_y = l2 + child.height / 2;
11232
11232
int k5 = Rasterizer3D.SINE[child.rotationX] * child.zoom >> 16;
11233
11233
int j6 = Rasterizer3D.COSINE[child.rotationX] * child.zoom >> 16;
11234
11234
boolean flag2 = componentEnabled(child);
···
11247
11247
}
11248
11248
if (model != null)
11249
11249
model.render(0, child.rotationY, 0, child.rotationX, 0, k5, j6);
11250
11250
-
Rasterizer3D.centerX = k3;
11251
11251
-
Rasterizer3D.centerY = k4;
11250
11250
+
Rasterizer3D.center_x = k3;
11251
11251
+
Rasterizer3D.center_y = k4;
11252
11252
} else {
11253
11253
if (child.type == 7) {
11254
11254
TypeFace typeFace = child.typeFaces;
···
11599
11599
if (gameObjectDefinition.anInt795 != -1) {
11600
11600
IndexedImage indexedImage = mapIcons[gameObjectDefinition.anInt795];
11601
11601
if (indexedImage != null) {
11602
11602
-
int i6 = (gameObjectDefinition.sizeX * 4 - indexedImage.width) / 2;
11602
11602
+
int i6 = (gameObjectDefinition.sizeX * 4 - indexedImage.imgWidth) / 2;
11603
11603
int j6 = (gameObjectDefinition.sizeY * 4 - indexedImage.height) / 2;
11604
11604
indexedImage.drawImage(48 + k * 4 + i6, 48 + (104 - i - gameObjectDefinition.sizeY) * 4 + j6
11605
11605
);
···
11670
11670
if (gameObjectDefinition.anInt795 != -1) {
11671
11671
IndexedImage indexedImage = mapIcons[gameObjectDefinition.anInt795];
11672
11672
if (indexedImage != null) {
11673
11673
-
int j5 = (gameObjectDefinition.sizeX * 4 - indexedImage.width) / 2;
11673
11673
+
int j5 = (gameObjectDefinition.sizeX * 4 - indexedImage.imgWidth) / 2;
11674
11674
int k5 = (gameObjectDefinition.sizeY * 4 - indexedImage.height) / 2;
11675
11675
indexedImage.drawImage(48 + k * 4 + j5, 48 + (104 - i - gameObjectDefinition.sizeY) * 4 + k5
11676
11676
);
···
11701
11701
if (class47.anInt795 != -1) {
11702
11702
IndexedImage indexedImage = mapIcons[class47.anInt795];
11703
11703
if (indexedImage != null) {
11704
11704
-
int i4 = (class47.sizeX * 4 - indexedImage.width) / 2;
11704
11704
+
int i4 = (class47.sizeX * 4 - indexedImage.imgWidth) / 2;
11705
11705
int j4 = (class47.sizeY * 4 - indexedImage.height) / 2;
11706
11706
indexedImage.drawImage(48 + k * 4 + i4, 48 + (104 - i - class47.sizeY) * 4 + j4);
11707
11707
}
+7
-7
src/main/java/com/jagex/runescape/cache/def/ItemDefinition.java
Reviewed
···
456
456
return null;
457
457
}
458
458
ImageRGB rendered = new ImageRGB(32, 32);
459
459
-
int centreX = Rasterizer3D.centerX;
460
460
-
int centerY = Rasterizer3D.centerY;
459
459
+
int centreX = Rasterizer3D.center_x;
460
460
+
int centerY = Rasterizer3D.center_y;
461
461
int lineOffsets[] = Rasterizer3D.lineOffsets;
462
462
int pixels[] = Rasterizer.pixels;
463
463
int width = Rasterizer.width;
···
466
466
int bottomX = Rasterizer.bottomX;
467
467
int topY = Rasterizer.topY;
468
468
int bottomY = Rasterizer.bottomY;
469
469
-
Rasterizer3D.approximateAlphaBlending = false;
469
469
+
Rasterizer3D.notTextured = false;
470
470
Rasterizer.createRasterizer(rendered.pixels, 32, 32);
471
471
Rasterizer.drawFilledRectangle(0, 0, 32, 32, 0);
472
472
-
Rasterizer3D.setDefaultBoundaries();
472
472
+
Rasterizer3D.setDefaultBounds();
473
473
int scale = definition.modelScale;
474
474
if (backColour == -1)
475
475
scale = (int) (scale * 1.5D);
···
532
532
rgbImageCache.put(rendered, id);
533
533
Rasterizer.createRasterizer(pixels, width, height);
534
534
Rasterizer.setCoordinates(topY, topX, bottomY, bottomX);
535
535
-
Rasterizer3D.centerX = centreX;
536
536
-
Rasterizer3D.centerY = centerY;
535
535
+
Rasterizer3D.center_x = centreX;
536
536
+
Rasterizer3D.center_y = centerY;
537
537
Rasterizer3D.lineOffsets = lineOffsets;
538
538
-
Rasterizer3D.approximateAlphaBlending = true;
538
538
+
Rasterizer3D.notTextured = true;
539
539
if (definition.stackable)
540
540
rendered.maxWidth = 33;
541
541
else
+1
-1
src/main/java/com/jagex/runescape/cache/media/ImageRGB.java
Reviewed
···
441
441
return;
442
442
} else {
443
443
method468(l, l1, pixels, k1, Rasterizer.pixels,
444
444
-
indexedImage.pixels, 40303, j1, i1, 0, i2);
444
444
+
indexedImage.imgPixels, 40303, j1, i1, 0, i2);
445
445
return;
446
446
}
447
447
}
+30
-30
src/main/java/com/jagex/runescape/cache/media/IndexedImage.java
Reviewed
···
6
6
7
7
public class IndexedImage extends Rasterizer {
8
8
9
9
-
public byte[] pixels;
9
9
+
public byte[] imgPixels;
10
10
public int[] palette;
11
11
-
public int width;
11
11
+
public int imgWidth;
12
12
public int height;
13
13
public int xDrawOffset;
14
14
public int yDrawOffset;
···
34
34
35
35
xDrawOffset = indexBuffer.getUnsignedByte();
36
36
yDrawOffset = indexBuffer.getUnsignedByte();
37
37
-
width = indexBuffer.getUnsignedShortBE();
37
37
+
imgWidth = indexBuffer.getUnsignedShortBE();
38
38
height = indexBuffer.getUnsignedShortBE();
39
39
int type = indexBuffer.getUnsignedByte();
40
40
-
int pixelLength = width * height;
41
41
-
pixels = new byte[pixelLength];
40
40
+
int pixelLength = imgWidth * height;
41
41
+
imgPixels = new byte[pixelLength];
42
42
if (type == 0) {
43
43
for (int pixel = 0; pixel < pixelLength; pixel++)
44
44
-
pixels[pixel] = dataBuffer.getByte();
44
44
+
imgPixels[pixel] = dataBuffer.getByte();
45
45
46
46
return;
47
47
}
48
48
if (type == 1) {
49
49
-
for (int x = 0; x < width; x++) {
49
49
+
for (int x = 0; x < imgWidth; x++) {
50
50
for (int y = 0; y < height; y++)
51
51
-
pixels[x + y * width] = dataBuffer.getByte();
51
51
+
imgPixels[x + y * imgWidth] = dataBuffer.getByte();
52
52
53
53
}
54
54
55
55
}
56
56
}
57
57
58
58
-
public void resizeToHalfMax() {
58
58
+
public void resizeToHalfLibSize() {
59
59
maxWidth /= 2;
60
60
maxHeight /= 2;
61
61
byte[] resizedPixels = new byte[maxWidth * maxHeight];
62
62
int pixelCount = 0;
63
63
for (int y = 0; y < height; y++) {
64
64
-
for (int x = 0; x < width; x++)
65
65
-
resizedPixels[(x + xDrawOffset >> 1) + (y + yDrawOffset >> 1) * maxWidth] = pixels[pixelCount++];
64
64
+
for (int x = 0; x < imgWidth; x++)
65
65
+
resizedPixels[(x + xDrawOffset >> 1) + (y + yDrawOffset >> 1) * maxWidth] = imgPixels[pixelCount++];
66
66
67
67
}
68
68
69
69
-
pixels = resizedPixels;
70
70
-
width = maxWidth;
69
69
+
imgPixels = resizedPixels;
70
70
+
imgWidth = maxWidth;
71
71
height = maxHeight;
72
72
xDrawOffset = 0;
73
73
yDrawOffset = 0;
74
74
}
75
75
76
76
-
public void resizeToMax() {
77
77
-
if (width != maxWidth || height != maxHeight) {
76
76
+
public void resizeToLibSize() {
77
77
+
if (imgWidth != maxWidth || height != maxHeight) {
78
78
byte[] resizedPixels = new byte[maxWidth * maxHeight];
79
79
int pixelCount = 0;
80
80
for (int y = 0; y < height; y++) {
81
81
-
for (int x = 0; x < width; x++)
82
82
-
resizedPixels[x + xDrawOffset + (y + yDrawOffset) * maxWidth] = pixels[pixelCount++];
81
81
+
for (int x = 0; x < imgWidth; x++)
82
82
+
resizedPixels[x + xDrawOffset + (y + yDrawOffset) * maxWidth] = imgPixels[pixelCount++];
83
83
84
84
}
85
85
86
86
-
pixels = resizedPixels;
87
87
-
width = maxWidth;
86
86
+
imgPixels = resizedPixels;
87
87
+
imgWidth = maxWidth;
88
88
height = maxHeight;
89
89
xDrawOffset = 0;
90
90
yDrawOffset = 0;
···
93
93
}
94
94
95
95
public void flipHorizontal() {
96
96
-
byte[] flipedPixels = new byte[width * height];
96
96
+
byte[] flipedPixels = new byte[imgWidth * height];
97
97
int pixelCount = 0;
98
98
for (int y = 0; y < height; y++) {
99
99
-
for (int x = width - 1; x >= 0; x--)
100
100
-
flipedPixels[pixelCount++] = pixels[x + y * width];
99
99
+
for (int x = imgWidth - 1; x >= 0; x--)
100
100
+
flipedPixels[pixelCount++] = imgPixels[x + y * imgWidth];
101
101
102
102
}
103
103
104
104
-
pixels = flipedPixels;
105
105
-
xDrawOffset = maxWidth - width - xDrawOffset;
104
104
+
imgPixels = flipedPixels;
105
105
+
xDrawOffset = maxWidth - imgWidth - xDrawOffset;
106
106
107
107
}
108
108
109
109
public void flipVertical() {
110
110
-
byte[] flipedPixels = new byte[width * height];
110
110
+
byte[] flipedPixels = new byte[imgWidth * height];
111
111
int pixelCount = 0;
112
112
for (int y = height - 1; y >= 0; y--) {
113
113
-
for (int x = 0; x < width; x++)
114
114
-
flipedPixels[pixelCount++] = pixels[x + y * width];
113
113
+
for (int x = 0; x < imgWidth; x++)
114
114
+
flipedPixels[pixelCount++] = imgPixels[x + y * imgWidth];
115
115
116
116
}
117
117
-
pixels = flipedPixels;
117
117
+
imgPixels = flipedPixels;
118
118
yDrawOffset = maxHeight - height - yDrawOffset;
119
119
}
120
120
···
148
148
int offset = x + y * Rasterizer.width;
149
149
int originalOffset = 0;
150
150
int imageHeight = height;
151
151
-
int imageWidth = width;
151
151
+
int imageWidth = imgWidth;
152
152
int deviation = Rasterizer.width - imageWidth;
153
153
int originalDeviation = 0;
154
154
if (y < Rasterizer.topY) {
···
176
176
deviation += xOffset;
177
177
}
178
178
if (imageWidth > 0 && imageHeight > 0) {
179
179
-
copyPixels(pixels, Rasterizer.pixels, imageWidth, imageHeight, offset, originalOffset, deviation, originalDeviation, palette);
179
179
+
copyPixels(imgPixels, Rasterizer.pixels, imageWidth, imageHeight, offset, originalOffset, deviation, originalDeviation, palette);
180
180
}
181
181
}
182
182
+3
-3
src/main/java/com/jagex/runescape/media/Rasterizer.java
Reviewed
···
11
11
public static int bottomY;
12
12
public static int topX;
13
13
public static int bottomX;
14
14
-
public static int virtualBottomX;
14
14
+
public static int viewportRx;
15
15
public static int centerX;
16
16
public static int centerY;
17
17
···
28
28
topY = 0;
29
29
bottomX = width;
30
30
bottomY = height;
31
31
-
virtualBottomX = bottomX - 1;
31
31
+
viewportRx = bottomX - 1;
32
32
centerX = bottomX / 2;
33
33
}
34
34
···
61
61
topY = y;
62
62
bottomX = width;
63
63
bottomY = height;
64
64
-
virtualBottomX = bottomX - 1;
64
64
+
viewportRx = bottomX - 1;
65
65
centerX = bottomX / 2;
66
66
centerY = bottomY / 2;
67
67
+2166
-1922
src/main/java/com/jagex/runescape/media/Rasterizer3D.java
Reviewed
···
5
5
6
6
public class Rasterizer3D extends Rasterizer {
7
7
8
8
-
public static int anInt1524 = -20714;
9
9
-
public static int anInt1525;
10
10
-
public static boolean aBoolean1526;
11
11
-
public static boolean lowMemory = true;
12
12
-
public static boolean restrictEdges;
13
13
-
public static boolean aBoolean1529;
14
14
-
public static boolean approximateAlphaBlending = true;
15
15
-
public static int alpha;
16
16
-
public static int centerX;
17
17
-
public static int centerY;
18
18
-
public static int[] anIntArray1534 = new int[512];
19
19
-
public static int[] anIntArray1535 = new int[2048];
20
20
-
public static int[] SINE = new int[2048];
21
21
-
public static int[] COSINE = new int[2048];
22
22
-
public static int[] lineOffsets;
23
23
-
public static int anInt1539;
24
24
-
public static IndexedImage aClass50_Sub1_Sub1_Sub3Array1540[] = new IndexedImage[50];
25
25
-
public static boolean aBooleanArray1541[] = new boolean[50];
26
26
-
public static int anIntArray1542[] = new int[50];
27
27
-
public static int anInt1543;
28
28
-
public static int texelArrayPool[][];
29
29
-
public static int texelCache[][] = new int[50][];
30
30
-
public static int anIntArray1546[] = new int[50];
31
31
-
public static int textureGetCount;
32
32
-
public static int getRgbLookupTableId[] = new int[0x10000];
33
33
-
public static int anIntArrayArray1549[][] = new int[50][];
8
8
+
public static boolean lowMemory = true;
9
9
+
public static boolean restrict_edges;
10
10
+
public static boolean opaque;
11
11
+
public static boolean notTextured = true;
12
12
+
public static int alpha;
13
13
+
public static int center_x;
14
14
+
public static int center_y;
15
15
+
public static int[] shadowDecay = new int[512];
16
16
+
public static int[] anIntArray1469 = new int[2048];
17
17
+
public static int[] SINE = new int[2048];
18
18
+
public static int[] COSINE = new int[2048];
19
19
+
public static int[] lineOffsets;
20
20
+
public static int loadedTextureCount;
21
21
+
public static IndexedImage textureImages[] = new IndexedImage[50];
22
22
+
public static boolean textureIsTransparent[] = new boolean[50];
23
23
+
public static int averageTextureColour[] = new int[50];
24
24
+
public static int textureTexelPoolPointer;
25
25
+
public static int texelArrayPool[][];
26
26
+
public static int texelCache[][] = new int[50][];
27
27
+
public static int textureLastUsed[] = new int[50];
28
28
+
public static int textureGetCount;
29
29
+
public static int hsl2rgb[] = new int[0x10000];
30
30
+
public static int texturePalettes[][] = new int[50][];
31
31
+
private static boolean useLatestShadeLine = true;
34
32
35
33
36
36
-
public static void reset() {
37
37
-
anIntArray1534 = null;
38
38
-
anIntArray1534 = null;
39
39
-
SINE = null;
40
40
-
COSINE = null;
41
41
-
lineOffsets = null;
42
42
-
aClass50_Sub1_Sub1_Sub3Array1540 = null;
43
43
-
aBooleanArray1541 = null;
44
44
-
anIntArray1542 = null;
45
45
-
texelArrayPool = null;
46
46
-
texelCache = null;
47
47
-
anIntArray1546 = null;
48
48
-
getRgbLookupTableId = null;
49
49
-
anIntArrayArray1549 = null;
50
50
-
}
34
34
+
public static void reset() {
35
35
+
shadowDecay = null;
36
36
+
SINE = null;
37
37
+
COSINE = null;
38
38
+
lineOffsets = null;
39
39
+
textureImages = null;
40
40
+
textureIsTransparent = null;
41
41
+
averageTextureColour = null;
42
42
+
texelArrayPool = null;
43
43
+
texelCache = null;
44
44
+
textureLastUsed = null;
45
45
+
hsl2rgb = null;
46
46
+
texturePalettes = null;
47
47
+
}
51
48
52
52
-
public static void setDefaultBoundaries() {
53
53
-
Rasterizer3D.lineOffsets = new int[height];
54
54
-
for (int lineOffset = 0; lineOffset < height; lineOffset++)
55
55
-
Rasterizer3D.lineOffsets[lineOffset] = width * lineOffset;
49
49
+
public static void setDefaultBounds() {
50
50
+
lineOffsets = new int[Rasterizer.height];
51
51
+
for (int i = 0; i < height; i++) {
52
52
+
lineOffsets[i] = width * i;
53
53
+
}
54
54
+
center_x = width / 2;
55
55
+
center_y = height / 2;
56
56
+
}
56
57
57
57
-
Rasterizer3D.centerX = width / 2;
58
58
-
Rasterizer3D.centerY = height / 2;
59
59
-
}
58
58
+
public static void setBounds(int width, int height) {
59
59
+
lineOffsets = new int[height];
60
60
+
for (int i = 0; i < height; i++) {
61
61
+
lineOffsets[i] = width * i;
62
62
+
}
63
63
+
center_x = width / 2;
64
64
+
center_y = height / 2;
65
65
+
}
60
66
61
61
-
public static void method494(int width, int height) {
62
62
-
Rasterizer3D.lineOffsets = new int[height];
63
63
-
for (int lineOffset = 0; lineOffset < height; lineOffset++)
64
64
-
Rasterizer3D.lineOffsets[lineOffset] = width * lineOffset;
67
67
+
public static void clearTextureCache() {
68
68
+
texelArrayPool = null;
69
69
+
for (int i = 0; i < 50; i++) {
70
70
+
texelCache[i] = null;
71
71
+
}
72
72
+
}
65
73
66
66
-
Rasterizer3D.centerX = width / 2;
67
67
-
Rasterizer3D.centerY = height / 2;
68
68
-
}
74
74
+
public static void resetTextures(int texturePoolSize) {
75
75
+
if (texelArrayPool == null) {
76
76
+
textureTexelPoolPointer = texturePoolSize;//was parameter
77
77
+
if (lowMemory) {
78
78
+
texelArrayPool = new int[textureTexelPoolPointer][16384];
79
79
+
} else {
80
80
+
texelArrayPool = new int[textureTexelPoolPointer][0x10000];
81
81
+
}
82
82
+
for (int k = 0; k < 50; k++) {
83
83
+
texelCache[k] = null;
84
84
+
}
69
85
70
70
-
public static void clearTextureCache() {
71
71
-
texelArrayPool = null;
72
72
-
for (int i = 0; i < 50; i++)
73
73
-
texelCache[i] = null;
86
86
+
}
87
87
+
}
74
88
75
75
-
}
89
89
+
public static void unpackTextures(Archive jagexArchive) {
90
90
+
loadedTextureCount = 0;
91
91
+
for (int i = 0; i < 50; i++) {
92
92
+
try {
93
93
+
textureImages[i] = new IndexedImage(jagexArchive, String.valueOf(i), 0);
94
94
+
if (lowMemory && textureImages[i].maxWidth == 128) {
95
95
+
textureImages[i].resizeToHalfLibSize();
96
96
+
} else {
97
97
+
textureImages[i].resizeToLibSize();
98
98
+
}
99
99
+
loadedTextureCount++;
100
100
+
} catch (Exception exception) {
101
101
+
}
102
102
+
}/*
103
103
+
for (int k = 0;k < textureImagesHD.length;k++)
104
104
+
try{
105
105
+
textureImagesHD[k] = new RgbImage("./hddata/texture/"+k+".png");
106
106
+
} catch (Exception ignored){
107
107
+
textureImagesHD[k] = textureImagesHD[k - 1];
108
108
+
}
109
109
+
*/
110
110
+
}
76
111
77
77
-
public static void method496(int i) {
78
78
-
if (texelArrayPool == null) {
79
79
-
anInt1543 = i;
80
80
-
if (lowMemory)
81
81
-
texelArrayPool = new int[anInt1543][16384];
82
82
-
else
83
83
-
texelArrayPool = new int[anInt1543][0x10000];
84
84
-
for (int k = 0; k < 50; k++)
85
85
-
texelCache[k] = null;
112
112
+
public static int getAverageRgbColorForTexture(int textureId) {
113
113
+
if (averageTextureColour[textureId] != 0) {
114
114
+
return averageTextureColour[textureId];
115
115
+
}
116
116
+
int red = 0;
117
117
+
int green = 0;
118
118
+
int blue = 0;
119
119
+
int colourCount = texturePalettes[textureId].length;
120
120
+
for (int ptr = 0; ptr < colourCount; ptr++) {
121
121
+
red += texturePalettes[textureId][ptr] >> 16 & 0xff;
122
122
+
green += texturePalettes[textureId][ptr] >> 8 & 0xff;
123
123
+
blue += texturePalettes[textureId][ptr] & 0xff;
124
124
+
}
86
125
87
87
-
}
88
88
-
}
126
126
+
int rgb = (red / colourCount << 16) + (green / colourCount << 8) + blue / colourCount;
127
127
+
rgb = adjustBrightness(rgb, 1.3999999999999999D);
128
128
+
if (rgb == 0) {
129
129
+
rgb = 1;
130
130
+
}
131
131
+
averageTextureColour[textureId] = rgb;
132
132
+
return rgb;
133
133
+
}
89
134
90
90
-
public static void loadIndexedImages(Archive class2) {
91
91
-
anInt1539 = 0;
92
92
-
for (int k = 0; k < 50; k++)
93
93
-
try {
94
94
-
aClass50_Sub1_Sub1_Sub3Array1540[k] = new IndexedImage(class2, String.valueOf(k), 0);
95
95
-
if (lowMemory && aClass50_Sub1_Sub1_Sub3Array1540[k].maxWidth == 128)
96
96
-
aClass50_Sub1_Sub1_Sub3Array1540[k].resizeToHalfMax();
97
97
-
else
98
98
-
aClass50_Sub1_Sub1_Sub3Array1540[k].resizeToMax();
99
99
-
anInt1539++;
100
100
-
} catch (Exception _ex) {
101
101
-
}
135
135
+
public static void resetTexture(int textureId) {
136
136
+
if (texelCache[textureId] == null) {
137
137
+
return;
138
138
+
}
139
139
+
texelArrayPool[textureTexelPoolPointer++] = texelCache[textureId];
140
140
+
texelCache[textureId] = null;
141
141
+
}
102
142
103
103
-
}
143
143
+
public static int[] getTexturePixels(int textureId) {
144
144
+
textureLastUsed[textureId] = textureGetCount++;
145
145
+
if (texelCache[textureId] != null) {
146
146
+
return texelCache[textureId];
147
147
+
}
148
148
+
int texels[];
149
149
+
//Start of mem management code
150
150
+
if (textureTexelPoolPointer > 0) { //Freed texture data arrays available
151
151
+
texels = texelArrayPool[--textureTexelPoolPointer];
152
152
+
texelArrayPool[textureTexelPoolPointer] = null;
153
153
+
} else { //No freed texture data arrays available, recycle least used texture's array
154
154
+
int lastUsed = 0;
155
155
+
int target = -1;
156
156
+
for (int i = 0; i < loadedTextureCount; i++) {
157
157
+
if (texelCache[i] != null && (textureLastUsed[i] < lastUsed || target == -1)) {
158
158
+
lastUsed = textureLastUsed[i];
159
159
+
target = i;
160
160
+
}
161
161
+
}
104
162
105
105
-
public static int getAverageRgbColorForTexture(int i, int j) {
106
106
-
if (anIntArray1542[i] != 0)
107
107
-
return anIntArray1542[i];
108
108
-
int k = 0;
109
109
-
int l = 0;
110
110
-
int i1 = 0;
111
111
-
int j1 = anIntArrayArray1549[i].length;
112
112
-
for (int k1 = 0; k1 < j1; k1++) {
113
113
-
k += anIntArrayArray1549[i][k1] >> 16 & 0xff;
114
114
-
l += anIntArrayArray1549[i][k1] >> 8 & 0xff;
115
115
-
i1 += anIntArrayArray1549[i][k1] & 0xff;
116
116
-
}
163
163
+
texels = texelCache[target];
164
164
+
texelCache[target] = null;
165
165
+
}
166
166
+
texelCache[textureId] = texels;
167
167
+
//End of mem management code
168
168
+
IndexedImage indexedImage = textureImages[textureId];
169
169
+
int texturePalette[] = texturePalettes[textureId];
170
170
+
if (lowMemory) {
171
171
+
textureIsTransparent[textureId] = false;
172
172
+
for (int texelPtr = 0; texelPtr < 4096; texelPtr++) {
173
173
+
int texel = texels[texelPtr] = texturePalette[indexedImage.imgPixels[texelPtr]] & 0xf8f8ff;
174
174
+
if (texel == 0) {
175
175
+
textureIsTransparent[textureId] = true;
176
176
+
}
177
177
+
texels[4096 + texelPtr] = texel - (texel >>> 3) & 0xf8f8ff;
178
178
+
texels[8192 + texelPtr] = texel - (texel >>> 2) & 0xf8f8ff;
179
179
+
texels[12288 + texelPtr] = texel - (texel >>> 2) - (texel >>> 3) & 0xf8f8ff;
180
180
+
}
117
181
118
118
-
if (j != 0)
119
119
-
return anInt1525;
120
120
-
int l1 = (k / j1 << 16) + (l / j1 << 8) + i1 / j1;
121
121
-
l1 = method502(l1, 1.3999999999999999D);
122
122
-
if (l1 == 0)
123
123
-
l1 = 1;
124
124
-
anIntArray1542[i] = l1;
125
125
-
return l1;
126
126
-
}
182
182
+
} else {
183
183
+
if (indexedImage.imgWidth == 64) {
184
184
+
for (int y = 0; y < 128; y++) {
185
185
+
for (int x = 0; x < 128; x++) {
186
186
+
texels[x + (y << 7)] = texturePalette[indexedImage.imgPixels[(x >> 1) + ((y >> 1) << 6)]];
187
187
+
}
127
188
128
128
-
public static void method499(int i, int j) {
129
129
-
if (j != 9)
130
130
-
anInt1524 = -48;
131
131
-
if (texelCache[i] == null) {
132
132
-
return;
133
133
-
} else {
134
134
-
texelArrayPool[anInt1543++] = texelCache[i];
135
135
-
texelCache[i] = null;
136
136
-
return;
137
137
-
}
138
138
-
}
189
189
+
}
139
190
140
140
-
public static int[] method500(int i) {
141
141
-
anIntArray1546[i] = textureGetCount++;
142
142
-
if (texelCache[i] != null)
143
143
-
return texelCache[i];
144
144
-
int ai[];
145
145
-
if (anInt1543 > 0) {
146
146
-
ai = texelArrayPool[--anInt1543];
147
147
-
texelArrayPool[anInt1543] = null;
148
148
-
} else {
149
149
-
int j = 0;
150
150
-
int k = -1;
151
151
-
for (int l = 0; l < anInt1539; l++)
152
152
-
if (texelCache[l] != null && (anIntArray1546[l] < j || k == -1)) {
153
153
-
j = anIntArray1546[l];
154
154
-
k = l;
155
155
-
}
191
191
+
} else {
192
192
+
for (int texelPtr = 0; texelPtr < 16384; texelPtr++) {
193
193
+
texels[texelPtr] = texturePalette[indexedImage.imgPixels[texelPtr]];
194
194
+
}
156
195
157
157
-
ai = texelCache[k];
158
158
-
texelCache[k] = null;
159
159
-
}
160
160
-
texelCache[i] = ai;
161
161
-
IndexedImage class50_sub1_sub1_sub3 = aClass50_Sub1_Sub1_Sub3Array1540[i];
162
162
-
int ai1[] = anIntArrayArray1549[i];
163
163
-
if (lowMemory) {
164
164
-
aBooleanArray1541[i] = false;
165
165
-
for (int i1 = 0; i1 < 4096; i1++) {
166
166
-
int i2 = ai[i1] = ai1[class50_sub1_sub1_sub3.pixels[i1]] & 0xf8f8ff;
167
167
-
if (i2 == 0)
168
168
-
aBooleanArray1541[i] = true;
169
169
-
ai[4096 + i1] = i2 - (i2 >>> 3) & 0xf8f8ff;
170
170
-
ai[8192 + i1] = i2 - (i2 >>> 2) & 0xf8f8ff;
171
171
-
ai[12288 + i1] = i2 - (i2 >>> 2) - (i2 >>> 3) & 0xf8f8ff;
172
172
-
}
196
196
+
}
197
197
+
textureIsTransparent[textureId] = false;
198
198
+
for (int texelPtr = 0; texelPtr < 16384; texelPtr++) {
199
199
+
texels[texelPtr] &= 0xf8f8ff;
200
200
+
int texel = texels[texelPtr];
201
201
+
if (texel == 0) {
202
202
+
textureIsTransparent[textureId] = true;
203
203
+
}
204
204
+
texels[16384 + texelPtr] = texel - (texel >>> 3) & 0xf8f8ff;
205
205
+
texels[32768 + texelPtr] = texel - (texel >>> 2) & 0xf8f8ff;
206
206
+
texels[49152 + texelPtr] = texel - (texel >>> 2) - (texel >>> 3) & 0xf8f8ff;
207
207
+
}
173
208
174
174
-
} else {
175
175
-
if (class50_sub1_sub1_sub3.width == 64) {
176
176
-
for (int j1 = 0; j1 < 128; j1++) {
177
177
-
for (int j2 = 0; j2 < 128; j2++)
178
178
-
ai[j2 + (j1 << 7)] = ai1[class50_sub1_sub1_sub3.pixels[(j2 >> 1) + ((j1 >> 1) << 6)]];
209
209
+
}
210
210
+
return texels;
211
211
+
}
179
212
180
180
-
}
213
213
+
public static void calculatePalette(double brightness) {
214
214
+
brightness += Math.random() * 0.029999999999999999D - 0.014999999999999999D;
215
215
+
int hsl = 0;
216
216
+
for (int k = 0; k < 512; k++) {
217
217
+
double d1 = (double) (k / 8) / 64D + 0.0078125D;
218
218
+
double d2 = (double) (k & 7) / 8D + 0.0625D;
219
219
+
for (int k1 = 0; k1 < 128; k1++) {
220
220
+
double d3 = (double) k1 / 128D;
221
221
+
double r = d3;
222
222
+
double g = d3;
223
223
+
double b = d3;
224
224
+
if (d2 != 0.0D) {
225
225
+
double d7;
226
226
+
if (d3 < 0.5D) {
227
227
+
d7 = d3 * (1.0D + d2);
228
228
+
} else {
229
229
+
d7 = (d3 + d2) - d3 * d2;
230
230
+
}
231
231
+
double d8 = 2D * d3 - d7;
232
232
+
double d9 = d1 + 0.33333333333333331D;
233
233
+
if (d9 > 1.0D) {
234
234
+
d9--;
235
235
+
}
236
236
+
double d10 = d1;
237
237
+
double d11 = d1 - 0.33333333333333331D;
238
238
+
if (d11 < 0.0D) {
239
239
+
d11++;
240
240
+
}
241
241
+
if (6D * d9 < 1.0D) {
242
242
+
r = d8 + (d7 - d8) * 6D * d9;
243
243
+
} else if (2D * d9 < 1.0D) {
244
244
+
r = d7;
245
245
+
} else if (3D * d9 < 2D) {
246
246
+
r = d8 + (d7 - d8) * (0.66666666666666663D - d9) * 6D;
247
247
+
} else {
248
248
+
r = d8;
249
249
+
}
250
250
+
if (6D * d10 < 1.0D) {
251
251
+
g = d8 + (d7 - d8) * 6D * d10;
252
252
+
} else if (2D * d10 < 1.0D) {
253
253
+
g = d7;
254
254
+
} else if (3D * d10 < 2D) {
255
255
+
g = d8 + (d7 - d8) * (0.66666666666666663D - d10) * 6D;
256
256
+
} else {
257
257
+
g = d8;
258
258
+
}
259
259
+
if (6D * d11 < 1.0D) {
260
260
+
b = d8 + (d7 - d8) * 6D * d11;
261
261
+
} else if (2D * d11 < 1.0D) {
262
262
+
b = d7;
263
263
+
} else if (3D * d11 < 2D) {
264
264
+
b = d8 + (d7 - d8) * (0.66666666666666663D - d11) * 6D;
265
265
+
} else {
266
266
+
b = d8;
267
267
+
}
268
268
+
}
269
269
+
int byteR = (int) (r * 256D);
270
270
+
int byteG = (int) (g * 256D);
271
271
+
int byteB = (int) (b * 256D);
272
272
+
int rgb = (byteR << 16) + (byteG << 8) + byteB;
273
273
+
rgb = adjustBrightness(rgb, brightness);
274
274
+
if (rgb == 0) {
275
275
+
rgb = 1;
276
276
+
}
277
277
+
hsl2rgb[hsl++] = rgb;
278
278
+
}
181
279
182
182
-
} else {
183
183
-
for (int k1 = 0; k1 < 16384; k1++)
184
184
-
ai[k1] = ai1[class50_sub1_sub1_sub3.pixels[k1]];
280
280
+
}
185
281
186
186
-
}
187
187
-
aBooleanArray1541[i] = false;
188
188
-
for (int l1 = 0; l1 < 16384; l1++) {
189
189
-
ai[l1] &= 0xf8f8ff;
190
190
-
int k2 = ai[l1];
191
191
-
if (k2 == 0)
192
192
-
aBooleanArray1541[i] = true;
193
193
-
ai[16384 + l1] = k2 - (k2 >>> 3) & 0xf8f8ff;
194
194
-
ai[32768 + l1] = k2 - (k2 >>> 2) & 0xf8f8ff;
195
195
-
ai[49152 + l1] = k2 - (k2 >>> 2) - (k2 >>> 3) & 0xf8f8ff;
196
196
-
}
282
282
+
for (int textureId = 0; textureId < 50; textureId++) {
283
283
+
if (textureImages[textureId] != null) {
284
284
+
int palette[] = textureImages[textureId].palette;
285
285
+
texturePalettes[textureId] = new int[palette.length];
286
286
+
for (int colourIdx = 0; colourIdx < palette.length; colourIdx++) {
287
287
+
texturePalettes[textureId][colourIdx] = adjustBrightness(palette[colourIdx], brightness);
288
288
+
if ((texturePalettes[textureId][colourIdx] & 0xf8f8ff) == 0 && colourIdx != 0) {
289
289
+
texturePalettes[textureId][colourIdx] = 1;
290
290
+
}
291
291
+
}
197
292
198
198
-
}
199
199
-
return ai;
200
200
-
}
293
293
+
}
294
294
+
}
201
295
202
202
-
public static void method501(double d) {
203
203
-
d += Math.random() * 0.029999999999999999D - 0.014999999999999999D;
204
204
-
int i = 0;
205
205
-
for (int j = 0; j < 512; j++) {
206
206
-
double d1 = (j / 8) / 64D + 0.0078125D;
207
207
-
double d2 = (j & 7) / 8D + 0.0625D;
208
208
-
for (int j1 = 0; j1 < 128; j1++) {
209
209
-
double d3 = j1 / 128D;
210
210
-
double d4 = d3;
211
211
-
double d5 = d3;
212
212
-
double d6 = d3;
213
213
-
if (d2 != 0.0D) {
214
214
-
double d7;
215
215
-
if (d3 < 0.5D)
216
216
-
d7 = d3 * (1.0D + d2);
217
217
-
else
218
218
-
d7 = (d3 + d2) - d3 * d2;
219
219
-
double d8 = 2D * d3 - d7;
220
220
-
double d9 = d1 + 0.33333333333333331D;
221
221
-
if (d9 > 1.0D)
222
222
-
d9--;
223
223
-
double d10 = d1;
224
224
-
double d11 = d1 - 0.33333333333333331D;
225
225
-
if (d11 < 0.0D)
226
226
-
d11++;
227
227
-
if (6D * d9 < 1.0D)
228
228
-
d4 = d8 + (d7 - d8) * 6D * d9;
229
229
-
else if (2D * d9 < 1.0D)
230
230
-
d4 = d7;
231
231
-
else if (3D * d9 < 2D)
232
232
-
d4 = d8 + (d7 - d8) * (0.66666666666666663D - d9) * 6D;
233
233
-
else
234
234
-
d4 = d8;
235
235
-
if (6D * d10 < 1.0D)
236
236
-
d5 = d8 + (d7 - d8) * 6D * d10;
237
237
-
else if (2D * d10 < 1.0D)
238
238
-
d5 = d7;
239
239
-
else if (3D * d10 < 2D)
240
240
-
d5 = d8 + (d7 - d8) * (0.66666666666666663D - d10) * 6D;
241
241
-
else
242
242
-
d5 = d8;
243
243
-
if (6D * d11 < 1.0D)
244
244
-
d6 = d8 + (d7 - d8) * 6D * d11;
245
245
-
else if (2D * d11 < 1.0D)
246
246
-
d6 = d7;
247
247
-
else if (3D * d11 < 2D)
248
248
-
d6 = d8 + (d7 - d8) * (0.66666666666666663D - d11) * 6D;
249
249
-
else
250
250
-
d6 = d8;
251
251
-
}
252
252
-
int k1 = (int) (d4 * 256D);
253
253
-
int l1 = (int) (d5 * 256D);
254
254
-
int i2 = (int) (d6 * 256D);
255
255
-
int j2 = (k1 << 16) + (l1 << 8) + i2;
256
256
-
j2 = method502(j2, d);
257
257
-
if (j2 == 0)
258
258
-
j2 = 1;
259
259
-
getRgbLookupTableId[i++] = j2;
260
260
-
}
296
296
+
for (int textureId = 0; textureId < 50; textureId++) {
297
297
+
resetTexture(textureId);
298
298
+
}
261
299
262
262
-
}
300
300
+
}
263
301
264
264
-
for (int k = 0; k < 50; k++)
265
265
-
if (aClass50_Sub1_Sub1_Sub3Array1540[k] != null) {
266
266
-
int ai[] = aClass50_Sub1_Sub1_Sub3Array1540[k].palette;
267
267
-
anIntArrayArray1549[k] = new int[ai.length];
268
268
-
for (int i1 = 0; i1 < ai.length; i1++) {
269
269
-
anIntArrayArray1549[k][i1] = method502(ai[i1], d);
270
270
-
if ((anIntArrayArray1549[k][i1] & 0xf8f8ff) == 0 && i1 != 0)
271
271
-
anIntArrayArray1549[k][i1] = 1;
272
272
-
}
302
302
+
private static int adjustBrightness(int rgb, double intensity) {
303
303
+
double r = (double) (rgb >> 16) / 256D;
304
304
+
double g = (double) (rgb >> 8 & 0xff) / 256D;
305
305
+
double b = (double) (rgb & 0xff) / 256D;
306
306
+
r = Math.pow(r, intensity);
307
307
+
g = Math.pow(g, intensity);
308
308
+
b = Math.pow(b, intensity);
309
309
+
int r_byte = (int) (r * 256D);
310
310
+
int g_byte = (int) (g * 256D);
311
311
+
int b_byte = (int) (b * 256D);
312
312
+
return (r_byte << 16) + (g_byte << 8) + b_byte;
313
313
+
}
273
314
274
274
-
}
315
315
+
public static void drawShadedTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int z_a, int z_b, int z_c) {
316
316
+
int x_a_off = 0;
317
317
+
int z_a_off = 0;
318
318
+
if (y_b != y_a) {
319
319
+
x_a_off = (x_b - x_a << 16) / (y_b - y_a);
320
320
+
z_a_off = (z_b - z_a << 15) / (y_b - y_a);
321
321
+
}
322
322
+
int x_b_off = 0;
323
323
+
int z_b_off = 0;
324
324
+
if (y_c != y_b) {
325
325
+
x_b_off = (x_c - x_b << 16) / (y_c - y_b);
326
326
+
z_b_off = (z_c - z_b << 15) / (y_c - y_b);
327
327
+
}
328
328
+
int x_c_off = 0;
329
329
+
int z_c_off = 0;
330
330
+
if (y_c != y_a) {
331
331
+
x_c_off = (x_a - x_c << 16) / (y_a - y_c);
332
332
+
z_c_off = (z_a - z_c << 15) / (y_a - y_c);
333
333
+
}
334
334
+
if (y_a <= y_b && y_a <= y_c) {
335
335
+
if (y_a >= bottomY) {
336
336
+
return;
337
337
+
}
338
338
+
if (y_b > bottomY) {
339
339
+
y_b = bottomY;
340
340
+
}
341
341
+
if (y_c > bottomY) {
342
342
+
y_c = bottomY;
343
343
+
}
344
344
+
if (y_b < y_c) {
345
345
+
x_c = x_a <<= 16;
346
346
+
z_c = z_a <<= 15;
347
347
+
if (y_a < 0) {
348
348
+
x_c -= x_c_off * y_a;
349
349
+
x_a -= x_a_off * y_a;
350
350
+
z_c -= z_c_off * y_a;
351
351
+
z_a -= z_a_off * y_a;
352
352
+
y_a = 0;
353
353
+
}
354
354
+
x_b <<= 16;
355
355
+
z_b <<= 15;
356
356
+
if (y_b < 0) {
357
357
+
x_b -= x_b_off * y_b;
358
358
+
z_b -= z_b_off * y_b;
359
359
+
y_b = 0;
360
360
+
}
361
361
+
if (y_a != y_b && x_c_off < x_a_off || y_a == y_b && x_c_off > x_b_off) {
362
362
+
y_c -= y_b;
363
363
+
y_b -= y_a;
364
364
+
for (y_a = lineOffsets[y_a]; --y_b >= 0; y_a += width) {
365
365
+
drawShadedLine(pixels, y_a, x_c >> 16, x_a >> 16, z_c >> 7, z_a >> 7);
366
366
+
x_c += x_c_off;
367
367
+
x_a += x_a_off;
368
368
+
z_c += z_c_off;
369
369
+
z_a += z_a_off;
370
370
+
}
275
371
276
276
-
for (int l = 0; l < 50; l++)
277
277
-
method499(l, 9);
372
372
+
while (--y_c >= 0) {
373
373
+
drawShadedLine(pixels, y_a, x_c >> 16, x_b >> 16, z_c >> 7, z_b >> 7);
374
374
+
x_c += x_c_off;
375
375
+
x_b += x_b_off;
376
376
+
z_c += z_c_off;
377
377
+
z_b += z_b_off;
378
378
+
y_a += width;
379
379
+
}
380
380
+
return;
381
381
+
}
382
382
+
y_c -= y_b;
383
383
+
y_b -= y_a;
384
384
+
for (y_a = lineOffsets[y_a]; --y_b >= 0; y_a += width) {
385
385
+
drawShadedLine(pixels, y_a, x_a >> 16, x_c >> 16, z_a >> 7, z_c >> 7);
386
386
+
x_c += x_c_off;
387
387
+
x_a += x_a_off;
388
388
+
z_c += z_c_off;
389
389
+
z_a += z_a_off;
390
390
+
}
278
391
279
279
-
}
392
392
+
while (--y_c >= 0) {
393
393
+
drawShadedLine(pixels, y_a, x_b >> 16, x_c >> 16, z_b >> 7, z_c >> 7);
394
394
+
x_c += x_c_off;
395
395
+
x_b += x_b_off;
396
396
+
z_c += z_c_off;
397
397
+
z_b += z_b_off;
398
398
+
y_a += width;
399
399
+
}
400
400
+
return;
401
401
+
}
402
402
+
x_b = x_a <<= 16;
403
403
+
z_b = z_a <<= 15;
404
404
+
if (y_a < 0) {
405
405
+
x_b -= x_c_off * y_a;
406
406
+
x_a -= x_a_off * y_a;
407
407
+
z_b -= z_c_off * y_a;
408
408
+
z_a -= z_a_off * y_a;
409
409
+
y_a = 0;
410
410
+
}
411
411
+
x_c <<= 16;
412
412
+
z_c <<= 15;
413
413
+
if (y_c < 0) {
414
414
+
x_c -= x_b_off * y_c;
415
415
+
z_c -= z_b_off * y_c;
416
416
+
y_c = 0;
417
417
+
}
418
418
+
if (y_a != y_c && x_c_off < x_a_off || y_a == y_c && x_b_off > x_a_off) {
419
419
+
y_b -= y_c;
420
420
+
y_c -= y_a;
421
421
+
for (y_a = lineOffsets[y_a]; --y_c >= 0; y_a += width) {
422
422
+
drawShadedLine(pixels, y_a, x_b >> 16, x_a >> 16, z_b >> 7, z_a >> 7);
423
423
+
x_b += x_c_off;
424
424
+
x_a += x_a_off;
425
425
+
z_b += z_c_off;
426
426
+
z_a += z_a_off;
427
427
+
}
280
428
281
281
-
public static int method502(int i, double d) {
282
282
-
double d1 = (i >> 16) / 256D;
283
283
-
double d2 = (i >> 8 & 0xff) / 256D;
284
284
-
double d3 = (i & 0xff) / 256D;
285
285
-
d1 = Math.pow(d1, d);
286
286
-
d2 = Math.pow(d2, d);
287
287
-
d3 = Math.pow(d3, d);
288
288
-
int j = (int) (d1 * 256D);
289
289
-
int k = (int) (d2 * 256D);
290
290
-
int l = (int) (d3 * 256D);
291
291
-
return (j << 16) + (k << 8) + l;
292
292
-
}
429
429
+
while (--y_b >= 0) {
430
430
+
drawShadedLine(pixels, y_a, x_c >> 16, x_a >> 16, z_c >> 7, z_a >> 7);
431
431
+
x_c += x_b_off;
432
432
+
x_a += x_a_off;
433
433
+
z_c += z_b_off;
434
434
+
z_a += z_a_off;
435
435
+
y_a += width;
436
436
+
}
437
437
+
return;
438
438
+
}
439
439
+
y_b -= y_c;
440
440
+
y_c -= y_a;
441
441
+
for (y_a = lineOffsets[y_a]; --y_c >= 0; y_a += width) {
442
442
+
drawShadedLine(pixels, y_a, x_a >> 16, x_b >> 16, z_a >> 7, z_b >> 7);
443
443
+
x_b += x_c_off;
444
444
+
x_a += x_a_off;
445
445
+
z_b += z_c_off;
446
446
+
z_a += z_a_off;
447
447
+
}
293
448
294
294
-
public static void drawShadedTriangle(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
295
295
-
int j2 = 0;
296
296
-
int k2 = 0;
297
297
-
if (j != i) {
298
298
-
j2 = (i1 - l << 16) / (j - i);
299
299
-
k2 = (l1 - k1 << 15) / (j - i);
300
300
-
}
301
301
-
int l2 = 0;
302
302
-
int i3 = 0;
303
303
-
if (k != j) {
304
304
-
l2 = (j1 - i1 << 16) / (k - j);
305
305
-
i3 = (i2 - l1 << 15) / (k - j);
306
306
-
}
307
307
-
int j3 = 0;
308
308
-
int k3 = 0;
309
309
-
if (k != i) {
310
310
-
j3 = (l - j1 << 16) / (i - k);
311
311
-
k3 = (k1 - i2 << 15) / (i - k);
312
312
-
}
313
313
-
if (i <= j && i <= k) {
314
314
-
if (i >= Rasterizer.bottomY)
315
315
-
return;
316
316
-
if (j > Rasterizer.bottomY)
317
317
-
j = Rasterizer.bottomY;
318
318
-
if (k > Rasterizer.bottomY)
319
319
-
k = Rasterizer.bottomY;
320
320
-
if (j < k) {
321
321
-
j1 = l <<= 16;
322
322
-
i2 = k1 <<= 15;
323
323
-
if (i < 0) {
324
324
-
j1 -= j3 * i;
325
325
-
l -= j2 * i;
326
326
-
i2 -= k3 * i;
327
327
-
k1 -= k2 * i;
328
328
-
i = 0;
329
329
-
}
330
330
-
i1 <<= 16;
331
331
-
l1 <<= 15;
332
332
-
if (j < 0) {
333
333
-
i1 -= l2 * j;
334
334
-
l1 -= i3 * j;
335
335
-
j = 0;
336
336
-
}
337
337
-
if (i != j && j3 < j2 || i == j && j3 > l2) {
338
338
-
k -= j;
339
339
-
j -= i;
340
340
-
for (i = lineOffsets[i]; --j >= 0; i += Rasterizer.width) {
341
341
-
method504(Rasterizer.pixels, i, 0, 0, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
342
342
-
j1 += j3;
343
343
-
l += j2;
344
344
-
i2 += k3;
345
345
-
k1 += k2;
346
346
-
}
449
449
+
while (--y_b >= 0) {
450
450
+
drawShadedLine(pixels, y_a, x_a >> 16, x_c >> 16, z_a >> 7, z_c >> 7);
451
451
+
x_c += x_b_off;
452
452
+
x_a += x_a_off;
453
453
+
z_c += z_b_off;
454
454
+
z_a += z_a_off;
455
455
+
y_a += width;
456
456
+
}
457
457
+
return;
458
458
+
}
459
459
+
if (y_b <= y_c) {
460
460
+
if (y_b >= bottomY) {
461
461
+
return;
462
462
+
}
463
463
+
if (y_c > bottomY) {
464
464
+
y_c = bottomY;
465
465
+
}
466
466
+
if (y_a > bottomY) {
467
467
+
y_a = bottomY;
468
468
+
}
469
469
+
if (y_c < y_a) {
470
470
+
x_a = x_b <<= 16;
471
471
+
z_a = z_b <<= 15;
472
472
+
if (y_b < 0) {
473
473
+
x_a -= x_a_off * y_b;
474
474
+
x_b -= x_b_off * y_b;
475
475
+
z_a -= z_a_off * y_b;
476
476
+
z_b -= z_b_off * y_b;
477
477
+
y_b = 0;
478
478
+
}
479
479
+
x_c <<= 16;
480
480
+
z_c <<= 15;
481
481
+
if (y_c < 0) {
482
482
+
x_c -= x_c_off * y_c;
483
483
+
z_c -= z_c_off * y_c;
484
484
+
y_c = 0;
485
485
+
}
486
486
+
if (y_b != y_c && x_a_off < x_b_off || y_b == y_c && x_a_off > x_c_off) {
487
487
+
y_a -= y_c;
488
488
+
y_c -= y_b;
489
489
+
for (y_b = lineOffsets[y_b]; --y_c >= 0; y_b += width) {
490
490
+
drawShadedLine(pixels, y_b, x_a >> 16, x_b >> 16, z_a >> 7, z_b >> 7);
491
491
+
x_a += x_a_off;
492
492
+
x_b += x_b_off;
493
493
+
z_a += z_a_off;
494
494
+
z_b += z_b_off;
495
495
+
}
347
496
348
348
-
while (--k >= 0) {
349
349
-
method504(Rasterizer.pixels, i, 0, 0, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
350
350
-
j1 += j3;
351
351
-
i1 += l2;
352
352
-
i2 += k3;
353
353
-
l1 += i3;
354
354
-
i += Rasterizer.width;
355
355
-
}
356
356
-
return;
357
357
-
}
358
358
-
k -= j;
359
359
-
j -= i;
360
360
-
for (i = lineOffsets[i]; --j >= 0; i += Rasterizer.width) {
361
361
-
method504(Rasterizer.pixels, i, 0, 0, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
362
362
-
j1 += j3;
363
363
-
l += j2;
364
364
-
i2 += k3;
365
365
-
k1 += k2;
366
366
-
}
497
497
+
while (--y_a >= 0) {
498
498
+
drawShadedLine(pixels, y_b, x_a >> 16, x_c >> 16, z_a >> 7, z_c >> 7);
499
499
+
x_a += x_a_off;
500
500
+
x_c += x_c_off;
501
501
+
z_a += z_a_off;
502
502
+
z_c += z_c_off;
503
503
+
y_b += width;
504
504
+
}
505
505
+
return;
506
506
+
}
507
507
+
y_a -= y_c;
508
508
+
y_c -= y_b;
509
509
+
for (y_b = lineOffsets[y_b]; --y_c >= 0; y_b += width) {
510
510
+
drawShadedLine(pixels, y_b, x_b >> 16, x_a >> 16, z_b >> 7, z_a >> 7);
511
511
+
x_a += x_a_off;
512
512
+
x_b += x_b_off;
513
513
+
z_a += z_a_off;
514
514
+
z_b += z_b_off;
515
515
+
}
367
516
368
368
-
while (--k >= 0) {
369
369
-
method504(Rasterizer.pixels, i, 0, 0, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
370
370
-
j1 += j3;
371
371
-
i1 += l2;
372
372
-
i2 += k3;
373
373
-
l1 += i3;
374
374
-
i += Rasterizer.width;
375
375
-
}
376
376
-
return;
377
377
-
}
378
378
-
i1 = l <<= 16;
379
379
-
l1 = k1 <<= 15;
380
380
-
if (i < 0) {
381
381
-
i1 -= j3 * i;
382
382
-
l -= j2 * i;
383
383
-
l1 -= k3 * i;
384
384
-
k1 -= k2 * i;
385
385
-
i = 0;
386
386
-
}
387
387
-
j1 <<= 16;
388
388
-
i2 <<= 15;
389
389
-
if (k < 0) {
390
390
-
j1 -= l2 * k;
391
391
-
i2 -= i3 * k;
392
392
-
k = 0;
393
393
-
}
394
394
-
if (i != k && j3 < j2 || i == k && l2 > j2) {
395
395
-
j -= k;
396
396
-
k -= i;
397
397
-
for (i = lineOffsets[i]; --k >= 0; i += Rasterizer.width) {
398
398
-
method504(Rasterizer.pixels, i, 0, 0, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
399
399
-
i1 += j3;
400
400
-
l += j2;
401
401
-
l1 += k3;
402
402
-
k1 += k2;
403
403
-
}
517
517
+
while (--y_a >= 0) {
518
518
+
drawShadedLine(pixels, y_b, x_c >> 16, x_a >> 16, z_c >> 7, z_a >> 7);
519
519
+
x_a += x_a_off;
520
520
+
x_c += x_c_off;
521
521
+
z_a += z_a_off;
522
522
+
z_c += z_c_off;
523
523
+
y_b += width;
524
524
+
}
525
525
+
return;
526
526
+
}
527
527
+
x_c = x_b <<= 16;
528
528
+
z_c = z_b <<= 15;
529
529
+
if (y_b < 0) {
530
530
+
x_c -= x_a_off * y_b;
531
531
+
x_b -= x_b_off * y_b;
532
532
+
z_c -= z_a_off * y_b;
533
533
+
z_b -= z_b_off * y_b;
534
534
+
y_b = 0;
535
535
+
}
536
536
+
x_a <<= 16;
537
537
+
z_a <<= 15;
538
538
+
if (y_a < 0) {
539
539
+
x_a -= x_c_off * y_a;
540
540
+
z_a -= z_c_off * y_a;
541
541
+
y_a = 0;
542
542
+
}
543
543
+
if (x_a_off < x_b_off) {
544
544
+
y_c -= y_a;
545
545
+
y_a -= y_b;
546
546
+
for (y_b = lineOffsets[y_b]; --y_a >= 0; y_b += width) {
547
547
+
drawShadedLine(pixels, y_b, x_c >> 16, x_b >> 16, z_c >> 7, z_b >> 7);
548
548
+
x_c += x_a_off;
549
549
+
x_b += x_b_off;
550
550
+
z_c += z_a_off;
551
551
+
z_b += z_b_off;
552
552
+
}
404
553
405
405
-
while (--j >= 0) {
406
406
-
method504(Rasterizer.pixels, i, 0, 0, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
407
407
-
j1 += l2;
408
408
-
l += j2;
409
409
-
i2 += i3;
410
410
-
k1 += k2;
411
411
-
i += Rasterizer.width;
412
412
-
}
413
413
-
return;
414
414
-
}
415
415
-
j -= k;
416
416
-
k -= i;
417
417
-
for (i = lineOffsets[i]; --k >= 0; i += Rasterizer.width) {
418
418
-
method504(Rasterizer.pixels, i, 0, 0, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
419
419
-
i1 += j3;
420
420
-
l += j2;
421
421
-
l1 += k3;
422
422
-
k1 += k2;
423
423
-
}
554
554
+
while (--y_c >= 0) {
555
555
+
drawShadedLine(pixels, y_b, x_a >> 16, x_b >> 16, z_a >> 7, z_b >> 7);
556
556
+
x_a += x_c_off;
557
557
+
x_b += x_b_off;
558
558
+
z_a += z_c_off;
559
559
+
z_b += z_b_off;
560
560
+
y_b += width;
561
561
+
}
562
562
+
return;
563
563
+
}
564
564
+
y_c -= y_a;
565
565
+
y_a -= y_b;
566
566
+
for (y_b = lineOffsets[y_b]; --y_a >= 0; y_b += width) {
567
567
+
drawShadedLine(pixels, y_b, x_b >> 16, x_c >> 16, z_b >> 7, z_c >> 7);
568
568
+
x_c += x_a_off;
569
569
+
x_b += x_b_off;
570
570
+
z_c += z_a_off;
571
571
+
z_b += z_b_off;
572
572
+
}
424
573
425
425
-
while (--j >= 0) {
426
426
-
method504(Rasterizer.pixels, i, 0, 0, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
427
427
-
j1 += l2;
428
428
-
l += j2;
429
429
-
i2 += i3;
430
430
-
k1 += k2;
431
431
-
i += Rasterizer.width;
432
432
-
}
433
433
-
return;
434
434
-
}
435
435
-
if (j <= k) {
436
436
-
if (j >= Rasterizer.bottomY)
437
437
-
return;
438
438
-
if (k > Rasterizer.bottomY)
439
439
-
k = Rasterizer.bottomY;
440
440
-
if (i > Rasterizer.bottomY)
441
441
-
i = Rasterizer.bottomY;
442
442
-
if (k < i) {
443
443
-
l = i1 <<= 16;
444
444
-
k1 = l1 <<= 15;
445
445
-
if (j < 0) {
446
446
-
l -= j2 * j;
447
447
-
i1 -= l2 * j;
448
448
-
k1 -= k2 * j;
449
449
-
l1 -= i3 * j;
450
450
-
j = 0;
451
451
-
}
452
452
-
j1 <<= 16;
453
453
-
i2 <<= 15;
454
454
-
if (k < 0) {
455
455
-
j1 -= j3 * k;
456
456
-
i2 -= k3 * k;
457
457
-
k = 0;
458
458
-
}
459
459
-
if (j != k && j2 < l2 || j == k && j2 > j3) {
460
460
-
i -= k;
461
461
-
k -= j;
462
462
-
for (j = lineOffsets[j]; --k >= 0; j += Rasterizer.width) {
463
463
-
method504(Rasterizer.pixels, j, 0, 0, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
464
464
-
l += j2;
465
465
-
i1 += l2;
466
466
-
k1 += k2;
467
467
-
l1 += i3;
468
468
-
}
574
574
+
while (--y_c >= 0) {
575
575
+
drawShadedLine(pixels, y_b, x_b >> 16, x_a >> 16, z_b >> 7, z_a >> 7);
576
576
+
x_a += x_c_off;
577
577
+
x_b += x_b_off;
578
578
+
z_a += z_c_off;
579
579
+
z_b += z_b_off;
580
580
+
y_b += width;
581
581
+
}
582
582
+
return;
583
583
+
}
584
584
+
if (y_c >= bottomY) {
585
585
+
return;
586
586
+
}
587
587
+
if (y_a > bottomY) {
588
588
+
y_a = bottomY;
589
589
+
}
590
590
+
if (y_b > bottomY) {
591
591
+
y_b = bottomY;
592
592
+
}
593
593
+
if (y_a < y_b) {
594
594
+
x_b = x_c <<= 16;
595
595
+
z_b = z_c <<= 15;
596
596
+
if (y_c < 0) {
597
597
+
x_b -= x_b_off * y_c;
598
598
+
x_c -= x_c_off * y_c;
599
599
+
z_b -= z_b_off * y_c;
600
600
+
z_c -= z_c_off * y_c;
601
601
+
y_c = 0;
602
602
+
}
603
603
+
x_a <<= 16;
604
604
+
z_a <<= 15;
605
605
+
if (y_a < 0) {
606
606
+
x_a -= x_a_off * y_a;
607
607
+
z_a -= z_a_off * y_a;
608
608
+
y_a = 0;
609
609
+
}
610
610
+
if (x_b_off < x_c_off) {
611
611
+
y_b -= y_a;
612
612
+
y_a -= y_c;
613
613
+
for (y_c = lineOffsets[y_c]; --y_a >= 0; y_c += width) {
614
614
+
drawShadedLine(pixels, y_c, x_b >> 16, x_c >> 16, z_b >> 7, z_c >> 7);
615
615
+
x_b += x_b_off;
616
616
+
x_c += x_c_off;
617
617
+
z_b += z_b_off;
618
618
+
z_c += z_c_off;
619
619
+
}
469
620
470
470
-
while (--i >= 0) {
471
471
-
method504(Rasterizer.pixels, j, 0, 0, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
472
472
-
l += j2;
473
473
-
j1 += j3;
474
474
-
k1 += k2;
475
475
-
i2 += k3;
476
476
-
j += Rasterizer.width;
477
477
-
}
478
478
-
return;
479
479
-
}
480
480
-
i -= k;
481
481
-
k -= j;
482
482
-
for (j = lineOffsets[j]; --k >= 0; j += Rasterizer.width) {
483
483
-
method504(Rasterizer.pixels, j, 0, 0, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
484
484
-
l += j2;
485
485
-
i1 += l2;
486
486
-
k1 += k2;
487
487
-
l1 += i3;
488
488
-
}
621
621
+
while (--y_b >= 0) {
622
622
+
drawShadedLine(pixels, y_c, x_b >> 16, x_a >> 16, z_b >> 7, z_a >> 7);
623
623
+
x_b += x_b_off;
624
624
+
x_a += x_a_off;
625
625
+
z_b += z_b_off;
626
626
+
z_a += z_a_off;
627
627
+
y_c += width;
628
628
+
}
629
629
+
return;
630
630
+
}
631
631
+
y_b -= y_a;
632
632
+
y_a -= y_c;
633
633
+
for (y_c = lineOffsets[y_c]; --y_a >= 0; y_c += width) {
634
634
+
drawShadedLine(pixels, y_c, x_c >> 16, x_b >> 16, z_c >> 7, z_b >> 7);
635
635
+
x_b += x_b_off;
636
636
+
x_c += x_c_off;
637
637
+
z_b += z_b_off;
638
638
+
z_c += z_c_off;
639
639
+
}
489
640
490
490
-
while (--i >= 0) {
491
491
-
method504(Rasterizer.pixels, j, 0, 0, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
492
492
-
l += j2;
493
493
-
j1 += j3;
494
494
-
k1 += k2;
495
495
-
i2 += k3;
496
496
-
j += Rasterizer.width;
497
497
-
}
498
498
-
return;
499
499
-
}
500
500
-
j1 = i1 <<= 16;
501
501
-
i2 = l1 <<= 15;
502
502
-
if (j < 0) {
503
503
-
j1 -= j2 * j;
504
504
-
i1 -= l2 * j;
505
505
-
i2 -= k2 * j;
506
506
-
l1 -= i3 * j;
507
507
-
j = 0;
508
508
-
}
509
509
-
l <<= 16;
510
510
-
k1 <<= 15;
511
511
-
if (i < 0) {
512
512
-
l -= j3 * i;
513
513
-
k1 -= k3 * i;
514
514
-
i = 0;
515
515
-
}
516
516
-
if (j2 < l2) {
517
517
-
k -= i;
518
518
-
i -= j;
519
519
-
for (j = lineOffsets[j]; --i >= 0; j += Rasterizer.width) {
520
520
-
method504(Rasterizer.pixels, j, 0, 0, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
521
521
-
j1 += j2;
522
522
-
i1 += l2;
523
523
-
i2 += k2;
524
524
-
l1 += i3;
525
525
-
}
641
641
+
while (--y_b >= 0) {
642
642
+
drawShadedLine(pixels, y_c, x_a >> 16, x_b >> 16, z_a >> 7, z_b >> 7);
643
643
+
x_b += x_b_off;
644
644
+
x_a += x_a_off;
645
645
+
z_b += z_b_off;
646
646
+
z_a += z_a_off;
647
647
+
y_c += width;
648
648
+
}
649
649
+
return;
650
650
+
}
651
651
+
x_a = x_c <<= 16;
652
652
+
z_a = z_c <<= 15;
653
653
+
if (y_c < 0) {
654
654
+
x_a -= x_b_off * y_c;
655
655
+
x_c -= x_c_off * y_c;
656
656
+
z_a -= z_b_off * y_c;
657
657
+
z_c -= z_c_off * y_c;
658
658
+
y_c = 0;
659
659
+
}
660
660
+
x_b <<= 16;
661
661
+
z_b <<= 15;
662
662
+
if (y_b < 0) {
663
663
+
x_b -= x_a_off * y_b;
664
664
+
z_b -= z_a_off * y_b;
665
665
+
y_b = 0;
666
666
+
}
667
667
+
if (x_b_off < x_c_off) {
668
668
+
y_a -= y_b;
669
669
+
y_b -= y_c;
670
670
+
for (y_c = lineOffsets[y_c]; --y_b >= 0; y_c += width) {
671
671
+
drawShadedLine(pixels, y_c, x_a >> 16, x_c >> 16, z_a >> 7, z_c >> 7);
672
672
+
x_a += x_b_off;
673
673
+
x_c += x_c_off;
674
674
+
z_a += z_b_off;
675
675
+
z_c += z_c_off;
676
676
+
}
526
677
527
527
-
while (--k >= 0) {
528
528
-
method504(Rasterizer.pixels, j, 0, 0, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
529
529
-
l += j3;
530
530
-
i1 += l2;
531
531
-
k1 += k3;
532
532
-
l1 += i3;
533
533
-
j += Rasterizer.width;
534
534
-
}
535
535
-
return;
536
536
-
}
537
537
-
k -= i;
538
538
-
i -= j;
539
539
-
for (j = lineOffsets[j]; --i >= 0; j += Rasterizer.width) {
540
540
-
method504(Rasterizer.pixels, j, 0, 0, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
541
541
-
j1 += j2;
542
542
-
i1 += l2;
543
543
-
i2 += k2;
544
544
-
l1 += i3;
545
545
-
}
678
678
+
while (--y_a >= 0) {
679
679
+
drawShadedLine(pixels, y_c, x_b >> 16, x_c >> 16, z_b >> 7, z_c >> 7);
680
680
+
x_b += x_a_off;
681
681
+
x_c += x_c_off;
682
682
+
z_b += z_a_off;
683
683
+
z_c += z_c_off;
684
684
+
y_c += width;
685
685
+
}
686
686
+
return;
687
687
+
}
688
688
+
y_a -= y_b;
689
689
+
y_b -= y_c;
690
690
+
for (y_c = lineOffsets[y_c]; --y_b >= 0; y_c += width) {
691
691
+
drawShadedLine(pixels, y_c, x_c >> 16, x_a >> 16, z_c >> 7, z_a >> 7);
692
692
+
x_a += x_b_off;
693
693
+
x_c += x_c_off;
694
694
+
z_a += z_b_off;
695
695
+
z_c += z_c_off;
696
696
+
}
546
697
547
547
-
while (--k >= 0) {
548
548
-
method504(Rasterizer.pixels, j, 0, 0, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
549
549
-
l += j3;
550
550
-
i1 += l2;
551
551
-
k1 += k3;
552
552
-
l1 += i3;
553
553
-
j += Rasterizer.width;
554
554
-
}
555
555
-
return;
556
556
-
}
557
557
-
if (k >= Rasterizer.bottomY)
558
558
-
return;
559
559
-
if (i > Rasterizer.bottomY)
560
560
-
i = Rasterizer.bottomY;
561
561
-
if (j > Rasterizer.bottomY)
562
562
-
j = Rasterizer.bottomY;
563
563
-
if (i < j) {
564
564
-
i1 = j1 <<= 16;
565
565
-
l1 = i2 <<= 15;
566
566
-
if (k < 0) {
567
567
-
i1 -= l2 * k;
568
568
-
j1 -= j3 * k;
569
569
-
l1 -= i3 * k;
570
570
-
i2 -= k3 * k;
571
571
-
k = 0;
572
572
-
}
573
573
-
l <<= 16;
574
574
-
k1 <<= 15;
575
575
-
if (i < 0) {
576
576
-
l -= j2 * i;
577
577
-
k1 -= k2 * i;
578
578
-
i = 0;
579
579
-
}
580
580
-
if (l2 < j3) {
581
581
-
j -= i;
582
582
-
i -= k;
583
583
-
for (k = lineOffsets[k]; --i >= 0; k += Rasterizer.width) {
584
584
-
method504(Rasterizer.pixels, k, 0, 0, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
585
585
-
i1 += l2;
586
586
-
j1 += j3;
587
587
-
l1 += i3;
588
588
-
i2 += k3;
589
589
-
}
698
698
+
while (--y_a >= 0) {
699
699
+
drawShadedLine(pixels, y_c, x_c >> 16, x_b >> 16, z_c >> 7, z_b >> 7);
700
700
+
x_b += x_a_off;
701
701
+
x_c += x_c_off;
702
702
+
z_b += z_a_off;
703
703
+
z_c += z_c_off;
704
704
+
y_c += width;
705
705
+
}
706
706
+
}
590
707
591
591
-
while (--j >= 0) {
592
592
-
method504(Rasterizer.pixels, k, 0, 0, i1 >> 16, l >> 16, l1 >> 7, k1 >> 7);
593
593
-
i1 += l2;
594
594
-
l += j2;
595
595
-
l1 += i3;
596
596
-
k1 += k2;
597
597
-
k += Rasterizer.width;
598
598
-
}
599
599
-
return;
600
600
-
}
601
601
-
j -= i;
602
602
-
i -= k;
603
603
-
for (k = lineOffsets[k]; --i >= 0; k += Rasterizer.width) {
604
604
-
method504(Rasterizer.pixels, k, 0, 0, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
605
605
-
i1 += l2;
606
606
-
j1 += j3;
607
607
-
l1 += i3;
608
608
-
i2 += k3;
609
609
-
}
708
708
+
//562 drawshadedline
709
709
+
//has vertex blending :O
710
710
+
public static void drawShadedLine562(int dest[], int dest_off, int startX, int endX, int colorIndex, int grad) {
711
711
+
int off = 0;
712
712
+
int color;
713
713
+
int loops;
714
714
+
if (restrict_edges) {
715
715
+
if (endX > viewportRx)
716
716
+
endX = viewportRx;
717
717
+
if (startX < 0) {
718
718
+
//colorIndex -= startX * off;//not sure if needed
719
719
+
startX = 0;
720
720
+
}
721
721
+
}
722
722
+
if (startX < endX) {
723
723
+
dest_off += startX - 1;
724
724
+
colorIndex += off * startX;
725
725
+
if (notTextured) {
726
726
+
loops = endX - startX >> 2;
727
727
+
if (loops > 0)
728
728
+
off = (grad - colorIndex) * shadowDecay[loops] >> 15;
729
729
+
else
730
730
+
off = 0;
731
731
+
if (alpha == 0) {
732
732
+
if (loops > 0) {
733
733
+
do {
734
734
+
color = hsl2rgb[colorIndex >> 8];
735
735
+
colorIndex += off;
736
736
+
dest[++dest_off] = color;
737
737
+
dest[++dest_off] = color;
738
738
+
dest[++dest_off] = color;
739
739
+
dest[++dest_off] = color;
740
740
+
} while (--loops > 0);
741
741
+
}
742
742
+
loops = endX - startX & 0x3;
743
743
+
if (loops > 0) {
744
744
+
color = hsl2rgb[colorIndex >> 8];
745
745
+
do
746
746
+
dest[++dest_off] = color;
747
747
+
while (--loops > 0);
748
748
+
}
749
749
+
} else {
750
750
+
int src_alpha = alpha;
751
751
+
int dest_alpha = 256 - alpha;
752
752
+
if (loops > 0) {
753
753
+
do {
754
754
+
color = hsl2rgb[colorIndex >> 8];
755
755
+
colorIndex += off;
756
756
+
color = (((color & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((color & 0xff00) * dest_alpha >> 8 & 0xff00));
757
757
+
int i_169_ = dest[++dest_off];
758
758
+
dest[dest_off] = (color + ((i_169_ & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i_169_ & 0xff00) * src_alpha >> 8 & 0xff00));
759
759
+
i_169_ = dest[++dest_off];
760
760
+
dest[dest_off] = (color + ((i_169_ & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i_169_ & 0xff00) * src_alpha >> 8 & 0xff00));
761
761
+
i_169_ = dest[++dest_off];
762
762
+
dest[dest_off] = (color + ((i_169_ & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i_169_ & 0xff00) * src_alpha >> 8 & 0xff00));
763
763
+
i_169_ = dest[++dest_off];
764
764
+
dest[dest_off] = (color + ((i_169_ & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i_169_ & 0xff00) * src_alpha >> 8 & 0xff00));
765
765
+
} while (--loops > 0);
766
766
+
}
767
767
+
loops = endX - startX & 0x3;
768
768
+
if (loops > 0) {
769
769
+
color = hsl2rgb[colorIndex >> 8];
770
770
+
color = (((color & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((color & 0xff00) * dest_alpha >> 8 & 0xff00));
771
771
+
do {
772
772
+
int i_170_ = dest[++dest_off];
773
773
+
dest[dest_off] = (color + ((i_170_ & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i_170_ & 0xff00) * src_alpha >> 8 & 0xff00));
774
774
+
} while (--loops > 0);
775
775
+
}
776
776
+
}
777
777
+
} else {
778
778
+
loops = endX - startX;
779
779
+
if (alpha == 0) {
780
780
+
do {
781
781
+
dest[++dest_off] = hsl2rgb[colorIndex >> 8];
782
782
+
colorIndex += off;
783
783
+
} while (--loops > 0);
784
784
+
} else {
785
785
+
int i = alpha;
786
786
+
int i_171_ = 256 - alpha;
787
787
+
do {
788
788
+
color = hsl2rgb[colorIndex >> 8];
789
789
+
colorIndex += off;
790
790
+
color = (((color & 0xff00ff) * i_171_ >> 8 & 0xff00ff) + ((color & 0xff00) * i_171_ >> 8 & 0xff00));
791
791
+
int i_ = dest[++dest_off];
792
792
+
dest[dest_off] = (color + ((i_ & 0xff00ff) * i >> 8 & 0xff00ff) + ((i_ & 0xff00) * i >> 8 & 0xff00));
793
793
+
} while (--loops > 0);
794
794
+
}
795
795
+
}
796
796
+
}
797
797
+
}
610
798
611
611
-
while (--j >= 0) {
612
612
-
method504(Rasterizer.pixels, k, 0, 0, l >> 16, i1 >> 16, k1 >> 7, l1 >> 7);
613
613
-
i1 += l2;
614
614
-
l += j2;
615
615
-
l1 += i3;
616
616
-
k1 += k2;
617
617
-
k += Rasterizer.width;
618
618
-
}
619
619
-
return;
620
620
-
}
621
621
-
l = j1 <<= 16;
622
622
-
k1 = i2 <<= 15;
623
623
-
if (k < 0) {
624
624
-
l -= l2 * k;
625
625
-
j1 -= j3 * k;
626
626
-
k1 -= i3 * k;
627
627
-
i2 -= k3 * k;
628
628
-
k = 0;
629
629
-
}
630
630
-
i1 <<= 16;
631
631
-
l1 <<= 15;
632
632
-
if (j < 0) {
633
633
-
i1 -= j2 * j;
634
634
-
l1 -= k2 * j;
635
635
-
j = 0;
636
636
-
}
637
637
-
if (l2 < j3) {
638
638
-
i -= j;
639
639
-
j -= k;
640
640
-
for (k = lineOffsets[k]; --j >= 0; k += Rasterizer.width) {
641
641
-
method504(Rasterizer.pixels, k, 0, 0, l >> 16, j1 >> 16, k1 >> 7, i2 >> 7);
642
642
-
l += l2;
643
643
-
j1 += j3;
644
644
-
k1 += i3;
645
645
-
i2 += k3;
646
646
-
}
799
799
+
public static void drawShadedLine(int[] dest, int dest_off, int start_x, int end_x, int color_index, int grad) {
800
800
+
if (useLatestShadeLine) {//divert all calls to the new method as its better
801
801
+
drawShadedLine562(dest, dest_off, start_x, end_x, color_index, grad);
802
802
+
// drawShadedLine656(dest, dest_off, start_x, end_x, color_index, grad);
803
803
+
return;
804
804
+
}
647
805
648
648
-
while (--i >= 0) {
649
649
-
method504(Rasterizer.pixels, k, 0, 0, i1 >> 16, j1 >> 16, l1 >> 7, i2 >> 7);
650
650
-
i1 += j2;
651
651
-
j1 += j3;
652
652
-
l1 += k2;
653
653
-
i2 += k3;
654
654
-
k += Rasterizer.width;
655
655
-
}
656
656
-
return;
657
657
-
}
658
658
-
i -= j;
659
659
-
j -= k;
660
660
-
for (k = lineOffsets[k]; --j >= 0; k += Rasterizer.width) {
661
661
-
method504(Rasterizer.pixels, k, 0, 0, j1 >> 16, l >> 16, i2 >> 7, k1 >> 7);
662
662
-
l += l2;
663
663
-
j1 += j3;
664
664
-
k1 += i3;
665
665
-
i2 += k3;
666
666
-
}
806
806
+
int color;
807
807
+
int loops;
808
808
+
int off = 0;
809
809
+
if (restrict_edges) {
810
810
+
if (end_x > viewportRx) {
811
811
+
end_x = viewportRx;
812
812
+
}
813
813
+
if (start_x < 0) {
814
814
+
color_index -= start_x * off;
815
815
+
start_x = 0;
816
816
+
}
817
817
+
}
818
818
+
if (start_x < end_x) {
819
819
+
dest_off += start_x;
820
820
+
color_index += off * start_x;
821
821
+
//if(1 != 1)//if the below code is dead only textured parts of models appear
822
822
+
if (notTextured) {//ifNontexturedModel?
823
823
+
loops = end_x - start_x >> 2;
824
824
+
if (loops > 0) {
825
825
+
off = (grad - color_index) * shadowDecay[loops] >> 15;
826
826
+
} else {
827
827
+
off = 0;
828
828
+
}
829
829
+
if (alpha == 0) {
830
830
+
if (loops > 0) {
831
831
+
do {
832
832
+
color = hsl2rgb[color_index >> 8];
833
833
+
color_index += off;
834
834
+
dest[dest_off++] = color;
835
835
+
dest[dest_off++] = color;
836
836
+
dest[dest_off++] = color;
837
837
+
dest[dest_off++] = color;
838
838
+
} while (--loops > 0);
839
839
+
}
840
840
+
loops = end_x - start_x & 0x3;
841
841
+
if (loops > 0) {
842
842
+
color = hsl2rgb[color_index >> 8];
843
843
+
do {
844
844
+
dest[dest_off++] = color;
845
845
+
}
846
846
+
while (--loops > 0);
847
847
+
}
848
848
+
} else {
849
849
+
int src_alpha = alpha;
850
850
+
int dest_alpha = 256 - alpha;
851
851
+
if (loops > 0) {
852
852
+
do {
853
853
+
color = hsl2rgb[color_index >> 8];
854
854
+
color_index += off;
855
855
+
color = (((color & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((color & 0xff00) * dest_alpha >> 8 & 0xff00));
856
856
+
int i = dest[dest_off];
857
857
+
dest[dest_off++] = (color + ((i & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i & 0xff00) * src_alpha >> 8 & 0xff00));
858
858
+
i = dest[dest_off];
859
859
+
dest[dest_off++] = (color
860
860
+
+ ((i & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i & 0xff00)
861
861
+
* src_alpha >> 8 & 0xff00));
862
862
+
i = dest[dest_off];
863
863
+
dest[dest_off++] = (color
864
864
+
+ ((i & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i & 0xff00)
865
865
+
* src_alpha >> 8 & 0xff00));
866
866
+
i = dest[dest_off];
867
867
+
dest[dest_off++] = (color
868
868
+
+ ((i & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i & 0xff00)
869
869
+
* src_alpha >> 8 & 0xff00));
870
870
+
} while (--loops > 0);
871
871
+
}
872
872
+
loops = end_x - start_x & 0x3;
873
873
+
if (loops > 0) {
874
874
+
color = hsl2rgb[color_index >> 8];
875
875
+
color = (((color & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((color & 0xff00)
876
876
+
* dest_alpha >> 8 & 0xff00));
877
877
+
do {
878
878
+
int i = dest[dest_off];
879
879
+
dest[dest_off++] = (color
880
880
+
+ ((i & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i & 0xff00)
881
881
+
* src_alpha >> 8 & 0xff00));
882
882
+
} while (--loops > 0);
883
883
+
}
884
884
+
}
885
885
+
} else {
886
886
+
int col_off = (grad - color_index) / (end_x - start_x);
887
887
+
loops = end_x - start_x;
888
888
+
if (alpha == 0) {
889
889
+
do {
890
890
+
dest[dest_off++] = hsl2rgb[color_index >> 8];
891
891
+
color_index += col_off;
892
892
+
} while (--loops > 0);
893
893
+
} else {
894
894
+
int src_alpha = alpha;
895
895
+
int dest_alpha = 256 - alpha;
896
896
+
do {
897
897
+
color = hsl2rgb[color_index >> 8];
898
898
+
color_index += col_off;
899
899
+
color = (((color & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((color & 0xff00)
900
900
+
* dest_alpha >> 8 & 0xff00));
901
901
+
int i = dest[dest_off];
902
902
+
dest[dest_off++] = (color
903
903
+
+ ((i & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((i & 0xff00)
904
904
+
* src_alpha >> 8 & 0xff00));
905
905
+
} while (--loops > 0);
906
906
+
}
907
907
+
}
908
908
+
}
909
909
+
}
667
910
668
668
-
while (--i >= 0) {
669
669
-
method504(Rasterizer.pixels, k, 0, 0, j1 >> 16, i1 >> 16, i2 >> 7, l1 >> 7);
670
670
-
i1 += j2;
671
671
-
j1 += j3;
672
672
-
l1 += k2;
673
673
-
i2 += k3;
674
674
-
k += Rasterizer.width;
675
675
-
}
676
676
-
}
911
911
+
// public static void drawShadedLine(int[] ai, int i, int l, int i1, int j1, int k1, int j, int k) {
912
912
+
// if (notTextured) {
913
913
+
// int l1;
914
914
+
// if (restrict_edges) {
915
915
+
// if (i1 - l > 3)
916
916
+
// l1 = (k1 - j1) / (i1 - l);
917
917
+
// else
918
918
+
// l1 = 0;
919
919
+
// if (i1 > Rasterizer.viewportRx)
920
920
+
// i1 = Rasterizer.viewportRx;
921
921
+
// if (l < 0) {
922
922
+
// j1 -= l * l1;
923
923
+
// l = 0;
924
924
+
// }
925
925
+
// if (l >= i1)
926
926
+
// return;
927
927
+
// i += l;
928
928
+
// k = i1 - l >> 2;
929
929
+
// l1 <<= 2;
930
930
+
// } else {
931
931
+
// if (l >= i1)
932
932
+
// return;
933
933
+
// i += l;
934
934
+
// k = i1 - l >> 2;
935
935
+
// if (k > 0)
936
936
+
// l1 = (k1 - j1) * shadowDecay[k] >> 15;
937
937
+
// else
938
938
+
// l1 = 0;
939
939
+
// }
940
940
+
// if (alpha == 0) {
941
941
+
// while (--k >= 0) {
942
942
+
// j = hsl2rgb[j1 >> 8];
943
943
+
// j1 += l1;
944
944
+
// ai[i++] = j;
945
945
+
// ai[i++] = j;
946
946
+
// ai[i++] = j;
947
947
+
// ai[i++] = j;
948
948
+
// }
949
949
+
// k = i1 - l & 3;
950
950
+
// if (k > 0) {
951
951
+
// j = hsl2rgb[j1 >> 8];
952
952
+
// do
953
953
+
// ai[i++] = j;
954
954
+
// while (--k > 0);
955
955
+
// return;
956
956
+
// }
957
957
+
// } else {
958
958
+
// int j2 = alpha;
959
959
+
// int l2 = 256 - alpha;
960
960
+
// while (--k >= 0) {
961
961
+
// j = hsl2rgb[j1 >> 8];
962
962
+
// j1 += l1;
963
963
+
// j = ((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00);
964
964
+
// ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
965
965
+
// ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
966
966
+
// ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
967
967
+
// ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
968
968
+
// }
969
969
+
// k = i1 - l & 3;
970
970
+
// if (k > 0) {
971
971
+
// j = hsl2rgb[j1 >> 8];
972
972
+
// j = ((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00);
973
973
+
// do
974
974
+
// ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
975
975
+
// while (--k > 0);
976
976
+
// }
977
977
+
// }
978
978
+
// return;
979
979
+
// }
980
980
+
// if (l >= i1)
981
981
+
// return;
982
982
+
// int i2 = (k1 - j1) / (i1 - l);
983
983
+
// if (restrict_edges) {
984
984
+
// if (i1 > Rasterizer.viewportRx)
985
985
+
// i1 = Rasterizer.viewportRx;
986
986
+
// if (l < 0) {
987
987
+
// j1 -= l * i2;
988
988
+
// l = 0;
989
989
+
// }
990
990
+
// if (l >= i1)
991
991
+
// return;
992
992
+
// }
993
993
+
// i += l;
994
994
+
// k = i1 - l;
995
995
+
// if (alpha == 0) {
996
996
+
// do {
997
997
+
// ai[i++] = hsl2rgb[j1 >> 8];
998
998
+
// j1 += i2;
999
999
+
// } while (--k > 0);
1000
1000
+
// return;
1001
1001
+
// }
1002
1002
+
// int k2 = alpha;
1003
1003
+
// int i3 = 256 - alpha;
1004
1004
+
// do {
1005
1005
+
// j = hsl2rgb[j1 >> 8];
1006
1006
+
// j1 += i2;
1007
1007
+
// j = ((j & 0xff00ff) * i3 >> 8 & 0xff00ff) + ((j & 0xff00) * i3 >> 8 & 0xff00);
1008
1008
+
// ai[i++] = j + ((ai[i] & 0xff00ff) * k2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * k2 >> 8 & 0xff00);
1009
1009
+
// } while (--k > 0);
1010
1010
+
// }
677
1011
678
678
-
public static void method504(int ai[], int i, int j, int k, int l, int i1, int j1, int k1) {
679
679
-
if (approximateAlphaBlending) {
680
680
-
int l1;
681
681
-
if (restrictEdges) {
682
682
-
if (i1 - l > 3)
683
683
-
l1 = (k1 - j1) / (i1 - l);
684
684
-
else
685
685
-
l1 = 0;
686
686
-
if (i1 > Rasterizer.virtualBottomX)
687
687
-
i1 = Rasterizer.virtualBottomX;
688
688
-
if (l < 0) {
689
689
-
j1 -= l * l1;
690
690
-
l = 0;
691
691
-
}
692
692
-
if (l >= i1)
693
693
-
return;
694
694
-
i += l;
695
695
-
k = i1 - l >> 2;
696
696
-
l1 <<= 2;
697
697
-
} else {
698
698
-
if (l >= i1)
699
699
-
return;
700
700
-
i += l;
701
701
-
k = i1 - l >> 2;
702
702
-
if (k > 0)
703
703
-
l1 = (k1 - j1) * anIntArray1534[k] >> 15;
704
704
-
else
705
705
-
l1 = 0;
706
706
-
}
707
707
-
if (alpha == 0) {
708
708
-
while (--k >= 0) {
709
709
-
j = getRgbLookupTableId[j1 >> 8];
710
710
-
j1 += l1;
711
711
-
ai[i++] = j;
712
712
-
ai[i++] = j;
713
713
-
ai[i++] = j;
714
714
-
ai[i++] = j;
715
715
-
}
716
716
-
k = i1 - l & 3;
717
717
-
if (k > 0) {
718
718
-
j = getRgbLookupTableId[j1 >> 8];
719
719
-
do
720
720
-
ai[i++] = j;
721
721
-
while (--k > 0);
722
722
-
return;
723
723
-
}
724
724
-
} else {
725
725
-
int j2 = alpha;
726
726
-
int l2 = 256 - alpha;
727
727
-
while (--k >= 0) {
728
728
-
j = getRgbLookupTableId[j1 >> 8];
729
729
-
j1 += l1;
730
730
-
j = ((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00);
731
731
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
732
732
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
733
733
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
734
734
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
735
735
-
}
736
736
-
k = i1 - l & 3;
737
737
-
if (k > 0) {
738
738
-
j = getRgbLookupTableId[j1 >> 8];
739
739
-
j = ((j & 0xff00ff) * l2 >> 8 & 0xff00ff) + ((j & 0xff00) * l2 >> 8 & 0xff00);
740
740
-
do
741
741
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j2 >> 8 & 0xff00);
742
742
-
while (--k > 0);
743
743
-
}
744
744
-
}
745
745
-
return;
746
746
-
}
747
747
-
if (l >= i1)
748
748
-
return;
749
749
-
int i2 = (k1 - j1) / (i1 - l);
750
750
-
if (restrictEdges) {
751
751
-
if (i1 > Rasterizer.virtualBottomX)
752
752
-
i1 = Rasterizer.virtualBottomX;
753
753
-
if (l < 0) {
754
754
-
j1 -= l * i2;
755
755
-
l = 0;
756
756
-
}
757
757
-
if (l >= i1)
758
758
-
return;
759
759
-
}
760
760
-
i += l;
761
761
-
k = i1 - l;
762
762
-
if (alpha == 0) {
763
763
-
do {
764
764
-
ai[i++] = getRgbLookupTableId[j1 >> 8];
765
765
-
j1 += i2;
766
766
-
} while (--k > 0);
767
767
-
return;
768
768
-
}
769
769
-
int k2 = alpha;
770
770
-
int i3 = 256 - alpha;
771
771
-
do {
772
772
-
j = getRgbLookupTableId[j1 >> 8];
773
773
-
j1 += i2;
774
774
-
j = ((j & 0xff00ff) * i3 >> 8 & 0xff00ff) + ((j & 0xff00) * i3 >> 8 & 0xff00);
775
775
-
ai[i++] = j + ((ai[i] & 0xff00ff) * k2 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * k2 >> 8 & 0xff00);
776
776
-
} while (--k > 0);
777
777
-
}
1012
1012
+
public static void drawFlatTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int color) {
1013
1013
+
int x_a_off = 0;
1014
1014
+
if (y_b != y_a) {
1015
1015
+
x_a_off = (x_b - x_a << 16) / (y_b - y_a);
1016
1016
+
}
1017
1017
+
int x_b_off = 0;
1018
1018
+
if (y_c != y_b) {
1019
1019
+
x_b_off = (x_c - x_b << 16) / (y_c - y_b);
1020
1020
+
}
1021
1021
+
int x_c_off = 0;
1022
1022
+
if (y_c != y_a) {
1023
1023
+
x_c_off = (x_a - x_c << 16) / (y_a - y_c);
1024
1024
+
}
1025
1025
+
if (y_a <= y_b && y_a <= y_c) {
1026
1026
+
if (y_a >= bottomY) {
1027
1027
+
return;
1028
1028
+
}
1029
1029
+
if (y_b > bottomY) {
1030
1030
+
y_b = bottomY;
1031
1031
+
}
1032
1032
+
if (y_c > bottomY) {
1033
1033
+
y_c = bottomY;
1034
1034
+
}
1035
1035
+
if (y_b < y_c) {
1036
1036
+
x_c = x_a <<= 16;
1037
1037
+
if (y_a < 0) {
1038
1038
+
x_c -= x_c_off * y_a;
1039
1039
+
x_a -= x_a_off * y_a;
1040
1040
+
y_a = 0;
1041
1041
+
}
1042
1042
+
x_b <<= 16;
1043
1043
+
if (y_b < 0) {
1044
1044
+
x_b -= x_b_off * y_b;
1045
1045
+
y_b = 0;
1046
1046
+
}
1047
1047
+
if (y_a != y_b && x_c_off < x_a_off || y_a == y_b && x_c_off > x_b_off) {
1048
1048
+
y_c -= y_b;
1049
1049
+
y_b -= y_a;
1050
1050
+
for (y_a = lineOffsets[y_a]; --y_b >= 0; y_a += width) {
1051
1051
+
drawScanLine(pixels, y_a, color, x_c >> 16, x_a >> 16);
1052
1052
+
x_c += x_c_off;
1053
1053
+
x_a += x_a_off;
1054
1054
+
}
778
1055
779
779
-
public static void method505(int i, int j, int k, int l, int i1, int j1, int k1) {
780
780
-
int l1 = 0;
781
781
-
if (j != i)
782
782
-
l1 = (i1 - l << 16) / (j - i);
783
783
-
int i2 = 0;
784
784
-
if (k != j)
785
785
-
i2 = (j1 - i1 << 16) / (k - j);
786
786
-
int j2 = 0;
787
787
-
if (k != i)
788
788
-
j2 = (l - j1 << 16) / (i - k);
789
789
-
if (i <= j && i <= k) {
790
790
-
if (i >= Rasterizer.bottomY)
791
791
-
return;
792
792
-
if (j > Rasterizer.bottomY)
793
793
-
j = Rasterizer.bottomY;
794
794
-
if (k > Rasterizer.bottomY)
795
795
-
k = Rasterizer.bottomY;
796
796
-
if (j < k) {
797
797
-
j1 = l <<= 16;
798
798
-
if (i < 0) {
799
799
-
j1 -= j2 * i;
800
800
-
l -= l1 * i;
801
801
-
i = 0;
802
802
-
}
803
803
-
i1 <<= 16;
804
804
-
if (j < 0) {
805
805
-
i1 -= i2 * j;
806
806
-
j = 0;
807
807
-
}
808
808
-
if (i != j && j2 < l1 || i == j && j2 > i2) {
809
809
-
k -= j;
810
810
-
j -= i;
811
811
-
for (i = lineOffsets[i]; --j >= 0; i += Rasterizer.width) {
812
812
-
method506(Rasterizer.pixels, i, k1, 0, j1 >> 16, l >> 16);
813
813
-
j1 += j2;
814
814
-
l += l1;
815
815
-
}
1056
1056
+
while (--y_c >= 0) {
1057
1057
+
drawScanLine(pixels, y_a, color, x_c >> 16, x_b >> 16);
1058
1058
+
x_c += x_c_off;
1059
1059
+
x_b += x_b_off;
1060
1060
+
y_a += width;
1061
1061
+
}
1062
1062
+
return;
1063
1063
+
}
1064
1064
+
y_c -= y_b;
1065
1065
+
y_b -= y_a;
1066
1066
+
for (y_a = lineOffsets[y_a]; --y_b >= 0; y_a += width) {
1067
1067
+
drawScanLine(pixels, y_a, color, x_a >> 16, x_c >> 16);
1068
1068
+
x_c += x_c_off;
1069
1069
+
x_a += x_a_off;
1070
1070
+
}
816
1071
817
817
-
while (--k >= 0) {
818
818
-
method506(Rasterizer.pixels, i, k1, 0, j1 >> 16, i1 >> 16);
819
819
-
j1 += j2;
820
820
-
i1 += i2;
821
821
-
i += Rasterizer.width;
822
822
-
}
823
823
-
return;
824
824
-
}
825
825
-
k -= j;
826
826
-
j -= i;
827
827
-
for (i = lineOffsets[i]; --j >= 0; i += Rasterizer.width) {
828
828
-
method506(Rasterizer.pixels, i, k1, 0, l >> 16, j1 >> 16);
829
829
-
j1 += j2;
830
830
-
l += l1;
831
831
-
}
1072
1072
+
while (--y_c >= 0) {
1073
1073
+
drawScanLine(pixels, y_a, color, x_b >> 16, x_c >> 16);
1074
1074
+
x_c += x_c_off;
1075
1075
+
x_b += x_b_off;
1076
1076
+
y_a += width;
1077
1077
+
}
1078
1078
+
return;
1079
1079
+
}
1080
1080
+
x_b = x_a <<= 16;
1081
1081
+
if (y_a < 0) {
1082
1082
+
x_b -= x_c_off * y_a;
1083
1083
+
x_a -= x_a_off * y_a;
1084
1084
+
y_a = 0;
1085
1085
+
}
1086
1086
+
x_c <<= 16;
1087
1087
+
if (y_c < 0) {
1088
1088
+
x_c -= x_b_off * y_c;
1089
1089
+
y_c = 0;
1090
1090
+
}
1091
1091
+
if (y_a != y_c && x_c_off < x_a_off || y_a == y_c && x_b_off > x_a_off) {
1092
1092
+
y_b -= y_c;
1093
1093
+
y_c -= y_a;
1094
1094
+
for (y_a = lineOffsets[y_a]; --y_c >= 0; y_a += width) {
1095
1095
+
drawScanLine(pixels, y_a, color, x_b >> 16, x_a >> 16);
1096
1096
+
x_b += x_c_off;
1097
1097
+
x_a += x_a_off;
1098
1098
+
}
832
1099
833
833
-
while (--k >= 0) {
834
834
-
method506(Rasterizer.pixels, i, k1, 0, i1 >> 16, j1 >> 16);
835
835
-
j1 += j2;
836
836
-
i1 += i2;
837
837
-
i += Rasterizer.width;
838
838
-
}
839
839
-
return;
840
840
-
}
841
841
-
i1 = l <<= 16;
842
842
-
if (i < 0) {
843
843
-
i1 -= j2 * i;
844
844
-
l -= l1 * i;
845
845
-
i = 0;
846
846
-
}
847
847
-
j1 <<= 16;
848
848
-
if (k < 0) {
849
849
-
j1 -= i2 * k;
850
850
-
k = 0;
851
851
-
}
852
852
-
if (i != k && j2 < l1 || i == k && i2 > l1) {
853
853
-
j -= k;
854
854
-
k -= i;
855
855
-
for (i = lineOffsets[i]; --k >= 0; i += Rasterizer.width) {
856
856
-
method506(Rasterizer.pixels, i, k1, 0, i1 >> 16, l >> 16);
857
857
-
i1 += j2;
858
858
-
l += l1;
859
859
-
}
1100
1100
+
while (--y_b >= 0) {
1101
1101
+
drawScanLine(pixels, y_a, color, x_c >> 16, x_a >> 16);
1102
1102
+
x_c += x_b_off;
1103
1103
+
x_a += x_a_off;
1104
1104
+
y_a += width;
1105
1105
+
}
1106
1106
+
return;
1107
1107
+
}
1108
1108
+
y_b -= y_c;
1109
1109
+
y_c -= y_a;
1110
1110
+
for (y_a = lineOffsets[y_a]; --y_c >= 0; y_a += width) {
1111
1111
+
drawScanLine(pixels, y_a, color, x_a >> 16, x_b >> 16);
1112
1112
+
x_b += x_c_off;
1113
1113
+
x_a += x_a_off;
1114
1114
+
}
860
1115
861
861
-
while (--j >= 0) {
862
862
-
method506(Rasterizer.pixels, i, k1, 0, j1 >> 16, l >> 16);
863
863
-
j1 += i2;
864
864
-
l += l1;
865
865
-
i += Rasterizer.width;
866
866
-
}
867
867
-
return;
868
868
-
}
869
869
-
j -= k;
870
870
-
k -= i;
871
871
-
for (i = lineOffsets[i]; --k >= 0; i += Rasterizer.width) {
872
872
-
method506(Rasterizer.pixels, i, k1, 0, l >> 16, i1 >> 16);
873
873
-
i1 += j2;
874
874
-
l += l1;
875
875
-
}
1116
1116
+
while (--y_b >= 0) {
1117
1117
+
drawScanLine(pixels, y_a, color, x_a >> 16, x_c >> 16);
1118
1118
+
x_c += x_b_off;
1119
1119
+
x_a += x_a_off;
1120
1120
+
y_a += width;
1121
1121
+
}
1122
1122
+
return;
1123
1123
+
}
1124
1124
+
if (y_b <= y_c) {
1125
1125
+
if (y_b >= bottomY) {
1126
1126
+
return;
1127
1127
+
}
1128
1128
+
if (y_c > bottomY) {
1129
1129
+
y_c = bottomY;
1130
1130
+
}
1131
1131
+
if (y_a > bottomY) {
1132
1132
+
y_a = bottomY;
1133
1133
+
}
1134
1134
+
if (y_c < y_a) {
1135
1135
+
x_a = x_b <<= 16;
1136
1136
+
if (y_b < 0) {
1137
1137
+
x_a -= x_a_off * y_b;
1138
1138
+
x_b -= x_b_off * y_b;
1139
1139
+
y_b = 0;
1140
1140
+
}
1141
1141
+
x_c <<= 16;
1142
1142
+
if (y_c < 0) {
1143
1143
+
x_c -= x_c_off * y_c;
1144
1144
+
y_c = 0;
1145
1145
+
}
1146
1146
+
if (y_b != y_c && x_a_off < x_b_off || y_b == y_c && x_a_off > x_c_off) {
1147
1147
+
y_a -= y_c;
1148
1148
+
y_c -= y_b;
1149
1149
+
for (y_b = lineOffsets[y_b]; --y_c >= 0; y_b += width) {
1150
1150
+
drawScanLine(pixels, y_b, color, x_a >> 16, x_b >> 16);
1151
1151
+
x_a += x_a_off;
1152
1152
+
x_b += x_b_off;
1153
1153
+
}
876
1154
877
877
-
while (--j >= 0) {
878
878
-
method506(Rasterizer.pixels, i, k1, 0, l >> 16, j1 >> 16);
879
879
-
j1 += i2;
880
880
-
l += l1;
881
881
-
i += Rasterizer.width;
882
882
-
}
883
883
-
return;
884
884
-
}
885
885
-
if (j <= k) {
886
886
-
if (j >= Rasterizer.bottomY)
887
887
-
return;
888
888
-
if (k > Rasterizer.bottomY)
889
889
-
k = Rasterizer.bottomY;
890
890
-
if (i > Rasterizer.bottomY)
891
891
-
i = Rasterizer.bottomY;
892
892
-
if (k < i) {
893
893
-
l = i1 <<= 16;
894
894
-
if (j < 0) {
895
895
-
l -= l1 * j;
896
896
-
i1 -= i2 * j;
897
897
-
j = 0;
898
898
-
}
899
899
-
j1 <<= 16;
900
900
-
if (k < 0) {
901
901
-
j1 -= j2 * k;
902
902
-
k = 0;
903
903
-
}
904
904
-
if (j != k && l1 < i2 || j == k && l1 > j2) {
905
905
-
i -= k;
906
906
-
k -= j;
907
907
-
for (j = lineOffsets[j]; --k >= 0; j += Rasterizer.width) {
908
908
-
method506(Rasterizer.pixels, j, k1, 0, l >> 16, i1 >> 16);
909
909
-
l += l1;
910
910
-
i1 += i2;
911
911
-
}
1155
1155
+
while (--y_a >= 0) {
1156
1156
+
drawScanLine(pixels, y_b, color, x_a >> 16, x_c >> 16);
1157
1157
+
x_a += x_a_off;
1158
1158
+
x_c += x_c_off;
1159
1159
+
y_b += width;
1160
1160
+
}
1161
1161
+
return;
1162
1162
+
}
1163
1163
+
y_a -= y_c;
1164
1164
+
y_c -= y_b;
1165
1165
+
for (y_b = lineOffsets[y_b]; --y_c >= 0; y_b += width) {
1166
1166
+
drawScanLine(pixels, y_b, color, x_b >> 16, x_a >> 16);
1167
1167
+
x_a += x_a_off;
1168
1168
+
x_b += x_b_off;
1169
1169
+
}
912
1170
913
913
-
while (--i >= 0) {
914
914
-
method506(Rasterizer.pixels, j, k1, 0, l >> 16, j1 >> 16);
915
915
-
l += l1;
916
916
-
j1 += j2;
917
917
-
j += Rasterizer.width;
918
918
-
}
919
919
-
return;
920
920
-
}
921
921
-
i -= k;
922
922
-
k -= j;
923
923
-
for (j = lineOffsets[j]; --k >= 0; j += Rasterizer.width) {
924
924
-
method506(Rasterizer.pixels, j, k1, 0, i1 >> 16, l >> 16);
925
925
-
l += l1;
926
926
-
i1 += i2;
927
927
-
}
1171
1171
+
while (--y_a >= 0) {
1172
1172
+
drawScanLine(pixels, y_b, color, x_c >> 16, x_a >> 16);
1173
1173
+
x_a += x_a_off;
1174
1174
+
x_c += x_c_off;
1175
1175
+
y_b += width;
1176
1176
+
}
1177
1177
+
return;
1178
1178
+
}
1179
1179
+
x_c = x_b <<= 16;
1180
1180
+
if (y_b < 0) {
1181
1181
+
x_c -= x_a_off * y_b;
1182
1182
+
x_b -= x_b_off * y_b;
1183
1183
+
y_b = 0;
1184
1184
+
}
1185
1185
+
x_a <<= 16;
1186
1186
+
if (y_a < 0) {
1187
1187
+
x_a -= x_c_off * y_a;
1188
1188
+
y_a = 0;
1189
1189
+
}
1190
1190
+
if (x_a_off < x_b_off) {
1191
1191
+
y_c -= y_a;
1192
1192
+
y_a -= y_b;
1193
1193
+
for (y_b = lineOffsets[y_b]; --y_a >= 0; y_b += width) {
1194
1194
+
drawScanLine(pixels, y_b, color, x_c >> 16, x_b >> 16);
1195
1195
+
x_c += x_a_off;
1196
1196
+
x_b += x_b_off;
1197
1197
+
}
928
1198
929
929
-
while (--i >= 0) {
930
930
-
method506(Rasterizer.pixels, j, k1, 0, j1 >> 16, l >> 16);
931
931
-
l += l1;
932
932
-
j1 += j2;
933
933
-
j += Rasterizer.width;
934
934
-
}
935
935
-
return;
936
936
-
}
937
937
-
j1 = i1 <<= 16;
938
938
-
if (j < 0) {
939
939
-
j1 -= l1 * j;
940
940
-
i1 -= i2 * j;
941
941
-
j = 0;
942
942
-
}
943
943
-
l <<= 16;
944
944
-
if (i < 0) {
945
945
-
l -= j2 * i;
946
946
-
i = 0;
947
947
-
}
948
948
-
if (l1 < i2) {
949
949
-
k -= i;
950
950
-
i -= j;
951
951
-
for (j = lineOffsets[j]; --i >= 0; j += Rasterizer.width) {
952
952
-
method506(Rasterizer.pixels, j, k1, 0, j1 >> 16, i1 >> 16);
953
953
-
j1 += l1;
954
954
-
i1 += i2;
955
955
-
}
1199
1199
+
while (--y_c >= 0) {
1200
1200
+
drawScanLine(pixels, y_b, color, x_a >> 16, x_b >> 16);
1201
1201
+
x_a += x_c_off;
1202
1202
+
x_b += x_b_off;
1203
1203
+
y_b += width;
1204
1204
+
}
1205
1205
+
return;
1206
1206
+
}
1207
1207
+
y_c -= y_a;
1208
1208
+
y_a -= y_b;
1209
1209
+
for (y_b = lineOffsets[y_b]; --y_a >= 0; y_b += width) {
1210
1210
+
drawScanLine(pixels, y_b, color, x_b >> 16, x_c >> 16);
1211
1211
+
x_c += x_a_off;
1212
1212
+
x_b += x_b_off;
1213
1213
+
}
956
1214
957
957
-
while (--k >= 0) {
958
958
-
method506(Rasterizer.pixels, j, k1, 0, l >> 16, i1 >> 16);
959
959
-
l += j2;
960
960
-
i1 += i2;
961
961
-
j += Rasterizer.width;
962
962
-
}
963
963
-
return;
964
964
-
}
965
965
-
k -= i;
966
966
-
i -= j;
967
967
-
for (j = lineOffsets[j]; --i >= 0; j += Rasterizer.width) {
968
968
-
method506(Rasterizer.pixels, j, k1, 0, i1 >> 16, j1 >> 16);
969
969
-
j1 += l1;
970
970
-
i1 += i2;
971
971
-
}
1215
1215
+
while (--y_c >= 0) {
1216
1216
+
drawScanLine(pixels, y_b, color, x_b >> 16, x_a >> 16);
1217
1217
+
x_a += x_c_off;
1218
1218
+
x_b += x_b_off;
1219
1219
+
y_b += width;
1220
1220
+
}
1221
1221
+
return;
1222
1222
+
}
1223
1223
+
if (y_c >= bottomY) {
1224
1224
+
return;
1225
1225
+
}
1226
1226
+
if (y_a > bottomY) {
1227
1227
+
y_a = bottomY;
1228
1228
+
}
1229
1229
+
if (y_b > bottomY) {
1230
1230
+
y_b = bottomY;
1231
1231
+
}
1232
1232
+
if (y_a < y_b) {
1233
1233
+
x_b = x_c <<= 16;
1234
1234
+
if (y_c < 0) {
1235
1235
+
x_b -= x_b_off * y_c;
1236
1236
+
x_c -= x_c_off * y_c;
1237
1237
+
y_c = 0;
1238
1238
+
}
1239
1239
+
x_a <<= 16;
1240
1240
+
if (y_a < 0) {
1241
1241
+
x_a -= x_a_off * y_a;
1242
1242
+
y_a = 0;
1243
1243
+
}
1244
1244
+
if (x_b_off < x_c_off) {
1245
1245
+
y_b -= y_a;
1246
1246
+
y_a -= y_c;
1247
1247
+
for (y_c = lineOffsets[y_c]; --y_a >= 0; y_c += width) {
1248
1248
+
drawScanLine(pixels, y_c, color, x_b >> 16, x_c >> 16);
1249
1249
+
x_b += x_b_off;
1250
1250
+
x_c += x_c_off;
1251
1251
+
}
972
1252
973
973
-
while (--k >= 0) {
974
974
-
method506(Rasterizer.pixels, j, k1, 0, i1 >> 16, l >> 16);
975
975
-
l += j2;
976
976
-
i1 += i2;
977
977
-
j += Rasterizer.width;
978
978
-
}
979
979
-
return;
980
980
-
}
981
981
-
if (k >= Rasterizer.bottomY)
982
982
-
return;
983
983
-
if (i > Rasterizer.bottomY)
984
984
-
i = Rasterizer.bottomY;
985
985
-
if (j > Rasterizer.bottomY)
986
986
-
j = Rasterizer.bottomY;
987
987
-
if (i < j) {
988
988
-
i1 = j1 <<= 16;
989
989
-
if (k < 0) {
990
990
-
i1 -= i2 * k;
991
991
-
j1 -= j2 * k;
992
992
-
k = 0;
993
993
-
}
994
994
-
l <<= 16;
995
995
-
if (i < 0) {
996
996
-
l -= l1 * i;
997
997
-
i = 0;
998
998
-
}
999
999
-
if (i2 < j2) {
1000
1000
-
j -= i;
1001
1001
-
i -= k;
1002
1002
-
for (k = lineOffsets[k]; --i >= 0; k += Rasterizer.width) {
1003
1003
-
method506(Rasterizer.pixels, k, k1, 0, i1 >> 16, j1 >> 16);
1004
1004
-
i1 += i2;
1005
1005
-
j1 += j2;
1006
1006
-
}
1253
1253
+
while (--y_b >= 0) {
1254
1254
+
drawScanLine(pixels, y_c, color, x_b >> 16, x_a >> 16);
1255
1255
+
x_b += x_b_off;
1256
1256
+
x_a += x_a_off;
1257
1257
+
y_c += width;
1258
1258
+
}
1259
1259
+
return;
1260
1260
+
}
1261
1261
+
y_b -= y_a;
1262
1262
+
y_a -= y_c;
1263
1263
+
for (y_c = lineOffsets[y_c]; --y_a >= 0; y_c += width) {
1264
1264
+
drawScanLine(pixels, y_c, color, x_c >> 16, x_b >> 16);
1265
1265
+
x_b += x_b_off;
1266
1266
+
x_c += x_c_off;
1267
1267
+
}
1007
1268
1008
1008
-
while (--j >= 0) {
1009
1009
-
method506(Rasterizer.pixels, k, k1, 0, i1 >> 16, l >> 16);
1010
1010
-
i1 += i2;
1011
1011
-
l += l1;
1012
1012
-
k += Rasterizer.width;
1013
1013
-
}
1014
1014
-
return;
1015
1015
-
}
1016
1016
-
j -= i;
1017
1017
-
i -= k;
1018
1018
-
for (k = lineOffsets[k]; --i >= 0; k += Rasterizer.width) {
1019
1019
-
method506(Rasterizer.pixels, k, k1, 0, j1 >> 16, i1 >> 16);
1020
1020
-
i1 += i2;
1021
1021
-
j1 += j2;
1022
1022
-
}
1269
1269
+
while (--y_b >= 0) {
1270
1270
+
drawScanLine(pixels, y_c, color, x_a >> 16, x_b >> 16);
1271
1271
+
x_b += x_b_off;
1272
1272
+
x_a += x_a_off;
1273
1273
+
y_c += width;
1274
1274
+
}
1275
1275
+
return;
1276
1276
+
}
1277
1277
+
x_a = x_c <<= 16;
1278
1278
+
if (y_c < 0) {
1279
1279
+
x_a -= x_b_off * y_c;
1280
1280
+
x_c -= x_c_off * y_c;
1281
1281
+
y_c = 0;
1282
1282
+
}
1283
1283
+
x_b <<= 16;
1284
1284
+
if (y_b < 0) {
1285
1285
+
x_b -= x_a_off * y_b;
1286
1286
+
y_b = 0;
1287
1287
+
}
1288
1288
+
if (x_b_off < x_c_off) {
1289
1289
+
y_a -= y_b;
1290
1290
+
y_b -= y_c;
1291
1291
+
for (y_c = lineOffsets[y_c]; --y_b >= 0; y_c += width) {
1292
1292
+
drawScanLine(pixels, y_c, color, x_a >> 16, x_c >> 16);
1293
1293
+
x_a += x_b_off;
1294
1294
+
x_c += x_c_off;
1295
1295
+
}
1023
1296
1024
1024
-
while (--j >= 0) {
1025
1025
-
method506(Rasterizer.pixels, k, k1, 0, l >> 16, i1 >> 16);
1026
1026
-
i1 += i2;
1027
1027
-
l += l1;
1028
1028
-
k += Rasterizer.width;
1029
1029
-
}
1030
1030
-
return;
1031
1031
-
}
1032
1032
-
l = j1 <<= 16;
1033
1033
-
if (k < 0) {
1034
1034
-
l -= i2 * k;
1035
1035
-
j1 -= j2 * k;
1036
1036
-
k = 0;
1037
1037
-
}
1038
1038
-
i1 <<= 16;
1039
1039
-
if (j < 0) {
1040
1040
-
i1 -= l1 * j;
1041
1041
-
j = 0;
1042
1042
-
}
1043
1043
-
if (i2 < j2) {
1044
1044
-
i -= j;
1045
1045
-
j -= k;
1046
1046
-
for (k = lineOffsets[k]; --j >= 0; k += Rasterizer.width) {
1047
1047
-
method506(Rasterizer.pixels, k, k1, 0, l >> 16, j1 >> 16);
1048
1048
-
l += i2;
1049
1049
-
j1 += j2;
1050
1050
-
}
1297
1297
+
while (--y_a >= 0) {
1298
1298
+
drawScanLine(pixels, y_c, color, x_b >> 16, x_c >> 16);
1299
1299
+
x_b += x_a_off;
1300
1300
+
x_c += x_c_off;
1301
1301
+
y_c += width;
1302
1302
+
}
1303
1303
+
return;
1304
1304
+
}
1305
1305
+
y_a -= y_b;
1306
1306
+
y_b -= y_c;
1307
1307
+
for (y_c = lineOffsets[y_c]; --y_b >= 0; y_c += width) {
1308
1308
+
drawScanLine(pixels, y_c, color, x_c >> 16, x_a >> 16);
1309
1309
+
x_a += x_b_off;
1310
1310
+
x_c += x_c_off;
1311
1311
+
}
1051
1312
1052
1052
-
while (--i >= 0) {
1053
1053
-
method506(Rasterizer.pixels, k, k1, 0, i1 >> 16, j1 >> 16);
1054
1054
-
i1 += l1;
1055
1055
-
j1 += j2;
1056
1056
-
k += Rasterizer.width;
1057
1057
-
}
1058
1058
-
return;
1059
1059
-
}
1060
1060
-
i -= j;
1061
1061
-
j -= k;
1062
1062
-
for (k = lineOffsets[k]; --j >= 0; k += Rasterizer.width) {
1063
1063
-
method506(Rasterizer.pixels, k, k1, 0, j1 >> 16, l >> 16);
1064
1064
-
l += i2;
1065
1065
-
j1 += j2;
1066
1066
-
}
1313
1313
+
while (--y_a >= 0) {
1314
1314
+
drawScanLine(pixels, y_c, color, x_c >> 16, x_b >> 16);
1315
1315
+
x_b += x_a_off;
1316
1316
+
x_c += x_c_off;
1317
1317
+
y_c += width;
1318
1318
+
}
1319
1319
+
}
1067
1320
1068
1068
-
while (--i >= 0) {
1069
1069
-
method506(Rasterizer.pixels, k, k1, 0, j1 >> 16, i1 >> 16);
1070
1070
-
i1 += l1;
1071
1071
-
j1 += j2;
1072
1072
-
k += Rasterizer.width;
1073
1073
-
}
1074
1074
-
}
1075
1321
1076
1076
-
public static void method506(int ai[], int i, int j, int k, int l, int i1) {
1077
1077
-
if (restrictEdges) {
1078
1078
-
if (i1 > Rasterizer.virtualBottomX)
1079
1079
-
i1 = Rasterizer.virtualBottomX;
1080
1080
-
if (l < 0)
1081
1081
-
l = 0;
1082
1082
-
}
1083
1083
-
if (l >= i1)
1084
1084
-
return;
1085
1085
-
i += l;
1086
1086
-
k = i1 - l >> 2;
1087
1087
-
if (alpha == 0) {
1088
1088
-
while (--k >= 0) {
1089
1089
-
ai[i++] = j;
1090
1090
-
ai[i++] = j;
1091
1091
-
ai[i++] = j;
1092
1092
-
ai[i++] = j;
1093
1093
-
}
1094
1094
-
for (k = i1 - l & 3; --k >= 0;)
1095
1095
-
ai[i++] = j;
1322
1322
+
public static void drawScanLine(int[] dest, int dest_off, int loops, int start_x, int end_x) {
1323
1323
+
int rgb;//was parameter
1324
1324
+
if (restrict_edges) {
1325
1325
+
if (end_x > viewportRx) {
1326
1326
+
end_x = viewportRx;
1327
1327
+
}
1328
1328
+
if (start_x < 0) {
1329
1329
+
start_x = 0;
1330
1330
+
}
1331
1331
+
}
1332
1332
+
if (start_x >= end_x) {
1333
1333
+
return;
1334
1334
+
}
1335
1335
+
dest_off += start_x;
1336
1336
+
rgb = end_x - start_x >> 2;
1337
1337
+
if (alpha == 0) {
1338
1338
+
while (--rgb >= 0) {
1339
1339
+
dest[dest_off++] = loops;
1340
1340
+
dest[dest_off++] = loops;
1341
1341
+
dest[dest_off++] = loops;
1342
1342
+
dest[dest_off++] = loops;
1343
1343
+
}
1344
1344
+
for (rgb = end_x - start_x & 3; --rgb >= 0; ) {
1345
1345
+
dest[dest_off++] = loops;
1346
1346
+
}
1096
1347
1097
1097
-
return;
1098
1098
-
}
1099
1099
-
int j1 = alpha;
1100
1100
-
int k1 = 256 - alpha;
1101
1101
-
j = ((j & 0xff00ff) * k1 >> 8 & 0xff00ff) + ((j & 0xff00) * k1 >> 8 & 0xff00);
1102
1102
-
while (--k >= 0) {
1103
1103
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
1104
1104
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
1105
1105
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
1106
1106
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
1107
1107
-
}
1108
1108
-
for (k = i1 - l & 3; --k >= 0;)
1109
1109
-
ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
1348
1348
+
return;
1349
1349
+
}
1350
1350
+
int dest_alpha = alpha;
1351
1351
+
int src_alpha = 256 - alpha;
1352
1352
+
loops = ((loops & 0xff00ff) * src_alpha >> 8 & 0xff00ff) + ((loops & 0xff00) * src_alpha >> 8 & 0xff00);
1353
1353
+
while (--rgb >= 0) {//alpha channel fix
1354
1354
+
dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
1355
1355
+
dest_off++;
1356
1356
+
dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
1357
1357
+
dest_off++;
1358
1358
+
dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
1359
1359
+
dest_off++;
1360
1360
+
dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
1361
1361
+
dest_off++;
1362
1362
+
}
1363
1363
+
for (rgb = end_x - start_x & 3; --rgb >= 0; ) {
1364
1364
+
dest[dest_off] = loops + ((dest[dest_off] & 0xff00ff) * dest_alpha >> 8 & 0xff00ff) + ((dest[dest_off] & 0xff00) * dest_alpha >> 8 & 0xff00);
1365
1365
+
dest_off++;
1366
1366
+
}
1110
1367
1111
1111
-
}
1368
1368
+
}
1112
1369
1113
1113
-
public static void drawTexturedTriangle(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2,
1114
1114
-
int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4) {
1115
1115
-
int ai[] = method500(k4);
1116
1116
-
aBoolean1529 = !aBooleanArray1541[k4];
1117
1117
-
k2 = j2 - k2;
1118
1118
-
j3 = i3 - j3;
1119
1119
-
i4 = l3 - i4;
1120
1120
-
l2 -= j2;
1121
1121
-
k3 -= i3;
1122
1122
-
j4 -= l3;
1123
1123
-
int l4 = l2 * i3 - k3 * j2 << 14;
1124
1124
-
int i5 = k3 * l3 - j4 * i3 << 8;
1125
1125
-
int j5 = j4 * j2 - l2 * l3 << 5;
1126
1126
-
int k5 = k2 * i3 - j3 * j2 << 14;
1127
1127
-
int l5 = j3 * l3 - i4 * i3 << 8;
1128
1128
-
int i6 = i4 * j2 - k2 * l3 << 5;
1129
1129
-
int j6 = j3 * l2 - k2 * k3 << 14;
1130
1130
-
int k6 = i4 * k3 - j3 * j4 << 8;
1131
1131
-
int l6 = k2 * j4 - i4 * l2 << 5;
1132
1132
-
int i7 = 0;
1133
1133
-
int j7 = 0;
1134
1134
-
if (j != i) {
1135
1135
-
i7 = (i1 - l << 16) / (j - i);
1136
1136
-
j7 = (l1 - k1 << 16) / (j - i);
1137
1137
-
}
1138
1138
-
int k7 = 0;
1139
1139
-
int l7 = 0;
1140
1140
-
if (k != j) {
1141
1141
-
k7 = (j1 - i1 << 16) / (k - j);
1142
1142
-
l7 = (i2 - l1 << 16) / (k - j);
1143
1143
-
}
1144
1144
-
int i8 = 0;
1145
1145
-
int j8 = 0;
1146
1146
-
if (k != i) {
1147
1147
-
i8 = (l - j1 << 16) / (i - k);
1148
1148
-
j8 = (k1 - i2 << 16) / (i - k);
1149
1149
-
}
1150
1150
-
if (i <= j && i <= k) {
1151
1151
-
if (i >= Rasterizer.bottomY)
1152
1152
-
return;
1153
1153
-
if (j > Rasterizer.bottomY)
1154
1154
-
j = Rasterizer.bottomY;
1155
1155
-
if (k > Rasterizer.bottomY)
1156
1156
-
k = Rasterizer.bottomY;
1157
1157
-
if (j < k) {
1158
1158
-
j1 = l <<= 16;
1159
1159
-
i2 = k1 <<= 16;
1160
1160
-
if (i < 0) {
1161
1161
-
j1 -= i8 * i;
1162
1162
-
l -= i7 * i;
1163
1163
-
i2 -= j8 * i;
1164
1164
-
k1 -= j7 * i;
1165
1165
-
i = 0;
1166
1166
-
}
1167
1167
-
i1 <<= 16;
1168
1168
-
l1 <<= 16;
1169
1169
-
if (j < 0) {
1170
1170
-
i1 -= k7 * j;
1171
1171
-
l1 -= l7 * j;
1172
1172
-
j = 0;
1173
1173
-
}
1174
1174
-
int k8 = i - Rasterizer3D.centerY;
1175
1175
-
l4 += j5 * k8;
1176
1176
-
k5 += i6 * k8;
1177
1177
-
j6 += l6 * k8;
1178
1178
-
if (i != j && i8 < i7 || i == j && i8 > k7) {
1179
1179
-
k -= j;
1180
1180
-
j -= i;
1181
1181
-
i = lineOffsets[i];
1182
1182
-
while (--j >= 0) {
1183
1183
-
method508(Rasterizer.pixels, ai, 0, 0, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8,
1184
1184
-
l4, k5, j6, i5, l5, k6);
1185
1185
-
j1 += i8;
1186
1186
-
l += i7;
1187
1187
-
i2 += j8;
1188
1188
-
k1 += j7;
1189
1189
-
i += Rasterizer.width;
1190
1190
-
l4 += j5;
1191
1191
-
k5 += i6;
1192
1192
-
j6 += l6;
1193
1193
-
}
1194
1194
-
while (--k >= 0) {
1195
1195
-
method508(Rasterizer.pixels, ai, 0, 0, i, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8,
1196
1196
-
l4, k5, j6, i5, l5, k6);
1197
1197
-
j1 += i8;
1198
1198
-
i1 += k7;
1199
1199
-
i2 += j8;
1200
1200
-
l1 += l7;
1201
1201
-
i += Rasterizer.width;
1202
1202
-
l4 += j5;
1203
1203
-
k5 += i6;
1204
1204
-
j6 += l6;
1205
1205
-
}
1206
1206
-
return;
1207
1207
-
}
1208
1208
-
k -= j;
1209
1209
-
j -= i;
1210
1210
-
i = lineOffsets[i];
1211
1211
-
while (--j >= 0) {
1212
1212
-
method508(Rasterizer.pixels, ai, 0, 0, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4,
1213
1213
-
k5, j6, i5, l5, k6);
1214
1214
-
j1 += i8;
1215
1215
-
l += i7;
1216
1216
-
i2 += j8;
1217
1217
-
k1 += j7;
1218
1218
-
i += Rasterizer.width;
1219
1219
-
l4 += j5;
1220
1220
-
k5 += i6;
1221
1221
-
j6 += l6;
1222
1222
-
}
1223
1223
-
while (--k >= 0) {
1224
1224
-
method508(Rasterizer.pixels, ai, 0, 0, i, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4,
1225
1225
-
k5, j6, i5, l5, k6);
1226
1226
-
j1 += i8;
1227
1227
-
i1 += k7;
1228
1228
-
i2 += j8;
1229
1229
-
l1 += l7;
1230
1230
-
i += Rasterizer.width;
1231
1231
-
l4 += j5;
1232
1232
-
k5 += i6;
1233
1233
-
j6 += l6;
1234
1234
-
}
1235
1235
-
return;
1236
1236
-
}
1237
1237
-
i1 = l <<= 16;
1238
1238
-
l1 = k1 <<= 16;
1239
1239
-
if (i < 0) {
1240
1240
-
i1 -= i8 * i;
1241
1241
-
l -= i7 * i;
1242
1242
-
l1 -= j8 * i;
1243
1243
-
k1 -= j7 * i;
1244
1244
-
i = 0;
1245
1245
-
}
1246
1246
-
j1 <<= 16;
1247
1247
-
i2 <<= 16;
1248
1248
-
if (k < 0) {
1249
1249
-
j1 -= k7 * k;
1250
1250
-
i2 -= l7 * k;
1251
1251
-
k = 0;
1252
1252
-
}
1253
1253
-
int l8 = i - Rasterizer3D.centerY;
1254
1254
-
l4 += j5 * l8;
1255
1255
-
k5 += i6 * l8;
1256
1256
-
j6 += l6 * l8;
1257
1257
-
if (i != k && i8 < i7 || i == k && k7 > i7) {
1258
1258
-
j -= k;
1259
1259
-
k -= i;
1260
1260
-
i = lineOffsets[i];
1261
1261
-
while (--k >= 0) {
1262
1262
-
method508(Rasterizer.pixels, ai, 0, 0, i, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4,
1263
1263
-
k5, j6, i5, l5, k6);
1264
1264
-
i1 += i8;
1265
1265
-
l += i7;
1266
1266
-
l1 += j8;
1267
1267
-
k1 += j7;
1268
1268
-
i += Rasterizer.width;
1269
1269
-
l4 += j5;
1270
1270
-
k5 += i6;
1271
1271
-
j6 += l6;
1272
1272
-
}
1273
1273
-
while (--j >= 0) {
1274
1274
-
method508(Rasterizer.pixels, ai, 0, 0, i, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4,
1275
1275
-
k5, j6, i5, l5, k6);
1276
1276
-
j1 += k7;
1277
1277
-
l += i7;
1278
1278
-
i2 += l7;
1279
1279
-
k1 += j7;
1280
1280
-
i += Rasterizer.width;
1281
1281
-
l4 += j5;
1282
1282
-
k5 += i6;
1283
1283
-
j6 += l6;
1284
1284
-
}
1285
1285
-
return;
1286
1286
-
}
1287
1287
-
j -= k;
1288
1288
-
k -= i;
1289
1289
-
i = lineOffsets[i];
1290
1290
-
while (--k >= 0) {
1291
1291
-
method508(Rasterizer.pixels, ai, 0, 0, i, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5,
1292
1292
-
j6, i5, l5, k6);
1293
1293
-
i1 += i8;
1294
1294
-
l += i7;
1295
1295
-
l1 += j8;
1296
1296
-
k1 += j7;
1297
1297
-
i += Rasterizer.width;
1298
1298
-
l4 += j5;
1299
1299
-
k5 += i6;
1300
1300
-
j6 += l6;
1301
1301
-
}
1302
1302
-
while (--j >= 0) {
1303
1303
-
method508(Rasterizer.pixels, ai, 0, 0, i, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5,
1304
1304
-
j6, i5, l5, k6);
1305
1305
-
j1 += k7;
1306
1306
-
l += i7;
1307
1307
-
i2 += l7;
1308
1308
-
k1 += j7;
1309
1309
-
i += Rasterizer.width;
1310
1310
-
l4 += j5;
1311
1311
-
k5 += i6;
1312
1312
-
j6 += l6;
1313
1313
-
}
1314
1314
-
return;
1315
1315
-
}
1316
1316
-
if (j <= k) {
1317
1317
-
if (j >= Rasterizer.bottomY)
1318
1318
-
return;
1319
1319
-
if (k > Rasterizer.bottomY)
1320
1320
-
k = Rasterizer.bottomY;
1321
1321
-
if (i > Rasterizer.bottomY)
1322
1322
-
i = Rasterizer.bottomY;
1323
1323
-
if (k < i) {
1324
1324
-
l = i1 <<= 16;
1325
1325
-
k1 = l1 <<= 16;
1326
1326
-
if (j < 0) {
1327
1327
-
l -= i7 * j;
1328
1328
-
i1 -= k7 * j;
1329
1329
-
k1 -= j7 * j;
1330
1330
-
l1 -= l7 * j;
1331
1331
-
j = 0;
1332
1332
-
}
1333
1333
-
j1 <<= 16;
1334
1334
-
i2 <<= 16;
1335
1335
-
if (k < 0) {
1336
1336
-
j1 -= i8 * k;
1337
1337
-
i2 -= j8 * k;
1338
1338
-
k = 0;
1339
1339
-
}
1340
1340
-
int i9 = j - Rasterizer3D.centerY;
1341
1341
-
l4 += j5 * i9;
1342
1342
-
k5 += i6 * i9;
1343
1343
-
j6 += l6 * i9;
1344
1344
-
if (j != k && i7 < k7 || j == k && i7 > i8) {
1345
1345
-
i -= k;
1346
1346
-
k -= j;
1347
1347
-
j = lineOffsets[j];
1348
1348
-
while (--k >= 0) {
1349
1349
-
method508(Rasterizer.pixels, ai, 0, 0, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8,
1350
1350
-
l4, k5, j6, i5, l5, k6);
1351
1351
-
l += i7;
1352
1352
-
i1 += k7;
1353
1353
-
k1 += j7;
1354
1354
-
l1 += l7;
1355
1355
-
j += Rasterizer.width;
1356
1356
-
l4 += j5;
1357
1357
-
k5 += i6;
1358
1358
-
j6 += l6;
1359
1359
-
}
1360
1360
-
while (--i >= 0) {
1361
1361
-
method508(Rasterizer.pixels, ai, 0, 0, j, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8,
1362
1362
-
l4, k5, j6, i5, l5, k6);
1363
1363
-
l += i7;
1364
1364
-
j1 += i8;
1365
1365
-
k1 += j7;
1366
1366
-
i2 += j8;
1367
1367
-
j += Rasterizer.width;
1368
1368
-
l4 += j5;
1369
1369
-
k5 += i6;
1370
1370
-
j6 += l6;
1371
1371
-
}
1372
1372
-
return;
1373
1373
-
}
1374
1374
-
i -= k;
1375
1375
-
k -= j;
1376
1376
-
j = lineOffsets[j];
1377
1377
-
while (--k >= 0) {
1378
1378
-
method508(Rasterizer.pixels, ai, 0, 0, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4,
1379
1379
-
k5, j6, i5, l5, k6);
1380
1380
-
l += i7;
1381
1381
-
i1 += k7;
1382
1382
-
k1 += j7;
1383
1383
-
l1 += l7;
1384
1384
-
j += Rasterizer.width;
1385
1385
-
l4 += j5;
1386
1386
-
k5 += i6;
1387
1387
-
j6 += l6;
1388
1388
-
}
1389
1389
-
while (--i >= 0) {
1390
1390
-
method508(Rasterizer.pixels, ai, 0, 0, j, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4,
1391
1391
-
k5, j6, i5, l5, k6);
1392
1392
-
l += i7;
1393
1393
-
j1 += i8;
1394
1394
-
k1 += j7;
1395
1395
-
i2 += j8;
1396
1396
-
j += Rasterizer.width;
1397
1397
-
l4 += j5;
1398
1398
-
k5 += i6;
1399
1399
-
j6 += l6;
1400
1400
-
}
1401
1401
-
return;
1402
1402
-
}
1403
1403
-
j1 = i1 <<= 16;
1404
1404
-
i2 = l1 <<= 16;
1405
1405
-
if (j < 0) {
1406
1406
-
j1 -= i7 * j;
1407
1407
-
i1 -= k7 * j;
1408
1408
-
i2 -= j7 * j;
1409
1409
-
l1 -= l7 * j;
1410
1410
-
j = 0;
1411
1411
-
}
1412
1412
-
l <<= 16;
1413
1413
-
k1 <<= 16;
1414
1414
-
if (i < 0) {
1415
1415
-
l -= i8 * i;
1416
1416
-
k1 -= j8 * i;
1417
1417
-
i = 0;
1418
1418
-
}
1419
1419
-
int j9 = j - Rasterizer3D.centerY;
1420
1420
-
l4 += j5 * j9;
1421
1421
-
k5 += i6 * j9;
1422
1422
-
j6 += l6 * j9;
1423
1423
-
if (i7 < k7) {
1424
1424
-
k -= i;
1425
1425
-
i -= j;
1426
1426
-
j = lineOffsets[j];
1427
1427
-
while (--i >= 0) {
1428
1428
-
method508(Rasterizer.pixels, ai, 0, 0, j, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4,
1429
1429
-
k5, j6, i5, l5, k6);
1430
1430
-
j1 += i7;
1431
1431
-
i1 += k7;
1432
1432
-
i2 += j7;
1433
1433
-
l1 += l7;
1434
1434
-
j += Rasterizer.width;
1435
1435
-
l4 += j5;
1436
1436
-
k5 += i6;
1437
1437
-
j6 += l6;
1438
1438
-
}
1439
1439
-
while (--k >= 0) {
1440
1440
-
method508(Rasterizer.pixels, ai, 0, 0, j, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4,
1441
1441
-
k5, j6, i5, l5, k6);
1442
1442
-
l += i8;
1443
1443
-
i1 += k7;
1444
1444
-
k1 += j8;
1445
1445
-
l1 += l7;
1446
1446
-
j += Rasterizer.width;
1447
1447
-
l4 += j5;
1448
1448
-
k5 += i6;
1449
1449
-
j6 += l6;
1450
1450
-
}
1451
1451
-
return;
1452
1452
-
}
1453
1453
-
k -= i;
1454
1454
-
i -= j;
1455
1455
-
j = lineOffsets[j];
1456
1456
-
while (--i >= 0) {
1457
1457
-
method508(Rasterizer.pixels, ai, 0, 0, j, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5,
1458
1458
-
j6, i5, l5, k6);
1459
1459
-
j1 += i7;
1460
1460
-
i1 += k7;
1461
1461
-
i2 += j7;
1462
1462
-
l1 += l7;
1463
1463
-
j += Rasterizer.width;
1464
1464
-
l4 += j5;
1465
1465
-
k5 += i6;
1466
1466
-
j6 += l6;
1467
1467
-
}
1468
1468
-
while (--k >= 0) {
1469
1469
-
method508(Rasterizer.pixels, ai, 0, 0, j, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4, k5,
1470
1470
-
j6, i5, l5, k6);
1471
1471
-
l += i8;
1472
1472
-
i1 += k7;
1473
1473
-
k1 += j8;
1474
1474
-
l1 += l7;
1475
1475
-
j += Rasterizer.width;
1476
1476
-
l4 += j5;
1477
1477
-
k5 += i6;
1478
1478
-
j6 += l6;
1479
1479
-
}
1480
1480
-
return;
1481
1481
-
}
1482
1482
-
if (k >= Rasterizer.bottomY)
1483
1483
-
return;
1484
1484
-
if (i > Rasterizer.bottomY)
1485
1485
-
i = Rasterizer.bottomY;
1486
1486
-
if (j > Rasterizer.bottomY)
1487
1487
-
j = Rasterizer.bottomY;
1488
1488
-
if (i < j) {
1489
1489
-
i1 = j1 <<= 16;
1490
1490
-
l1 = i2 <<= 16;
1491
1491
-
if (k < 0) {
1492
1492
-
i1 -= k7 * k;
1493
1493
-
j1 -= i8 * k;
1494
1494
-
l1 -= l7 * k;
1495
1495
-
i2 -= j8 * k;
1496
1496
-
k = 0;
1497
1497
-
}
1498
1498
-
l <<= 16;
1499
1499
-
k1 <<= 16;
1500
1500
-
if (i < 0) {
1501
1501
-
l -= i7 * i;
1502
1502
-
k1 -= j7 * i;
1503
1503
-
i = 0;
1504
1504
-
}
1505
1505
-
int k9 = k - Rasterizer3D.centerY;
1506
1506
-
l4 += j5 * k9;
1507
1507
-
k5 += i6 * k9;
1508
1508
-
j6 += l6 * k9;
1509
1509
-
if (k7 < i8) {
1510
1510
-
j -= i;
1511
1511
-
i -= k;
1512
1512
-
k = lineOffsets[k];
1513
1513
-
while (--i >= 0) {
1514
1514
-
method508(Rasterizer.pixels, ai, 0, 0, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4,
1515
1515
-
k5, j6, i5, l5, k6);
1516
1516
-
i1 += k7;
1517
1517
-
j1 += i8;
1518
1518
-
l1 += l7;
1519
1519
-
i2 += j8;
1520
1520
-
k += Rasterizer.width;
1521
1521
-
l4 += j5;
1522
1522
-
k5 += i6;
1523
1523
-
j6 += l6;
1524
1524
-
}
1525
1525
-
while (--j >= 0) {
1526
1526
-
method508(Rasterizer.pixels, ai, 0, 0, k, i1 >> 16, l >> 16, l1 >> 8, k1 >> 8, l4,
1527
1527
-
k5, j6, i5, l5, k6);
1528
1528
-
i1 += k7;
1529
1529
-
l += i7;
1530
1530
-
l1 += l7;
1531
1531
-
k1 += j7;
1532
1532
-
k += Rasterizer.width;
1533
1533
-
l4 += j5;
1534
1534
-
k5 += i6;
1535
1535
-
j6 += l6;
1536
1536
-
}
1537
1537
-
return;
1538
1538
-
}
1539
1539
-
j -= i;
1540
1540
-
i -= k;
1541
1541
-
k = lineOffsets[k];
1542
1542
-
while (--i >= 0) {
1543
1543
-
method508(Rasterizer.pixels, ai, 0, 0, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5,
1544
1544
-
j6, i5, l5, k6);
1545
1545
-
i1 += k7;
1546
1546
-
j1 += i8;
1547
1547
-
l1 += l7;
1548
1548
-
i2 += j8;
1549
1549
-
k += Rasterizer.width;
1550
1550
-
l4 += j5;
1551
1551
-
k5 += i6;
1552
1552
-
j6 += l6;
1553
1553
-
}
1554
1554
-
while (--j >= 0) {
1555
1555
-
method508(Rasterizer.pixels, ai, 0, 0, k, l >> 16, i1 >> 16, k1 >> 8, l1 >> 8, l4, k5,
1556
1556
-
j6, i5, l5, k6);
1557
1557
-
i1 += k7;
1558
1558
-
l += i7;
1559
1559
-
l1 += l7;
1560
1560
-
k1 += j7;
1561
1561
-
k += Rasterizer.width;
1562
1562
-
l4 += j5;
1563
1563
-
k5 += i6;
1564
1564
-
j6 += l6;
1565
1565
-
}
1566
1566
-
return;
1567
1567
-
}
1568
1568
-
l = j1 <<= 16;
1569
1569
-
k1 = i2 <<= 16;
1570
1570
-
if (k < 0) {
1571
1571
-
l -= k7 * k;
1572
1572
-
j1 -= i8 * k;
1573
1573
-
k1 -= l7 * k;
1574
1574
-
i2 -= j8 * k;
1575
1575
-
k = 0;
1576
1576
-
}
1577
1577
-
i1 <<= 16;
1578
1578
-
l1 <<= 16;
1579
1579
-
if (j < 0) {
1580
1580
-
i1 -= i7 * j;
1581
1581
-
l1 -= j7 * j;
1582
1582
-
j = 0;
1583
1583
-
}
1584
1584
-
int l9 = k - Rasterizer3D.centerY;
1585
1585
-
l4 += j5 * l9;
1586
1586
-
k5 += i6 * l9;
1587
1587
-
j6 += l6 * l9;
1588
1588
-
if (k7 < i8) {
1589
1589
-
i -= j;
1590
1590
-
j -= k;
1591
1591
-
k = lineOffsets[k];
1592
1592
-
while (--j >= 0) {
1593
1593
-
method508(Rasterizer.pixels, ai, 0, 0, k, l >> 16, j1 >> 16, k1 >> 8, i2 >> 8, l4, k5,
1594
1594
-
j6, i5, l5, k6);
1595
1595
-
l += k7;
1596
1596
-
j1 += i8;
1597
1597
-
k1 += l7;
1598
1598
-
i2 += j8;
1599
1599
-
k += Rasterizer.width;
1600
1600
-
l4 += j5;
1601
1601
-
k5 += i6;
1602
1602
-
j6 += l6;
1603
1603
-
}
1604
1604
-
while (--i >= 0) {
1605
1605
-
method508(Rasterizer.pixels, ai, 0, 0, k, i1 >> 16, j1 >> 16, l1 >> 8, i2 >> 8, l4, k5,
1606
1606
-
j6, i5, l5, k6);
1607
1607
-
i1 += i7;
1608
1608
-
j1 += i8;
1609
1609
-
l1 += j7;
1610
1610
-
i2 += j8;
1611
1611
-
k += Rasterizer.width;
1612
1612
-
l4 += j5;
1613
1613
-
k5 += i6;
1614
1614
-
j6 += l6;
1615
1615
-
}
1616
1616
-
return;
1617
1617
-
}
1618
1618
-
i -= j;
1619
1619
-
j -= k;
1620
1620
-
k = lineOffsets[k];
1621
1621
-
while (--j >= 0) {
1622
1622
-
method508(Rasterizer.pixels, ai, 0, 0, k, j1 >> 16, l >> 16, i2 >> 8, k1 >> 8, l4, k5, j6,
1623
1623
-
i5, l5, k6);
1624
1624
-
l += k7;
1625
1625
-
j1 += i8;
1626
1626
-
k1 += l7;
1627
1627
-
i2 += j8;
1628
1628
-
k += Rasterizer.width;
1629
1629
-
l4 += j5;
1630
1630
-
k5 += i6;
1631
1631
-
j6 += l6;
1632
1632
-
}
1633
1633
-
while (--i >= 0) {
1634
1634
-
method508(Rasterizer.pixels, ai, 0, 0, k, j1 >> 16, i1 >> 16, i2 >> 8, l1 >> 8, l4, k5, j6,
1635
1635
-
i5, l5, k6);
1636
1636
-
i1 += i7;
1637
1637
-
j1 += i8;
1638
1638
-
l1 += j7;
1639
1639
-
i2 += j8;
1640
1640
-
k += Rasterizer.width;
1641
1641
-
l4 += j5;
1642
1642
-
k5 += i6;
1643
1643
-
j6 += l6;
1644
1644
-
}
1645
1645
-
}
1370
1370
+
public static void drawTexturedTriangle(int y_a, int y_b, int y_c, int x_a, int x_b, int x_c, int grad_a, int grad_b, int grad_c, int Px, int Mx,
1371
1371
+
int Nx, int Pz, int Mz, int Nz, int Py, int My, int Ny, int t_id) {
1372
1372
+
int texture[] = getTexturePixels(t_id);
1373
1373
+
opaque = !textureIsTransparent[t_id];
1374
1374
+
Mx = Px - Mx;
1375
1375
+
Mz = Pz - Mz;
1376
1376
+
My = Py - My;
1377
1377
+
Nx -= Px;
1378
1378
+
Nz -= Pz;
1379
1379
+
Ny -= Py;
1380
1380
+
int Oa = Nx * Pz - Nz * Px << 14;
1381
1381
+
int Ha = Nz * Py - Ny * Pz << 8;
1382
1382
+
int Va = Ny * Px - Nx * Py << 5;
1383
1383
+
int Ob = Mx * Pz - Mz * Px << 14;
1384
1384
+
int Hb = Mz * Py - My * Pz << 8;
1385
1385
+
int Vb = My * Px - Mx * Py << 5;
1386
1386
+
int Oc = Mz * Nx - Mx * Nz << 14;
1387
1387
+
int Hc = My * Nz - Mz * Ny << 8;
1388
1388
+
int Vc = Mx * Ny - My * Nx << 5;
1389
1389
+
int x_a_off = 0;
1390
1390
+
int grad_a_off = 0;
1391
1391
+
if (y_b != y_a) {
1392
1392
+
x_a_off = (x_b - x_a << 16) / (y_b - y_a);
1393
1393
+
grad_a_off = (grad_b - grad_a << 16) / (y_b - y_a);
1394
1394
+
}
1395
1395
+
int x_b_off = 0;
1396
1396
+
int grad_b_off = 0;
1397
1397
+
if (y_c != y_b) {
1398
1398
+
x_b_off = (x_c - x_b << 16) / (y_c - y_b);
1399
1399
+
grad_b_off = (grad_c - grad_b << 16) / (y_c - y_b);
1400
1400
+
}
1401
1401
+
int x_c_off = 0;
1402
1402
+
int grad_c_off = 0;
1403
1403
+
if (y_c != y_a) {
1404
1404
+
x_c_off = (x_a - x_c << 16) / (y_a - y_c);
1405
1405
+
grad_c_off = (grad_a - grad_c << 16) / (y_a - y_c);
1406
1406
+
}
1407
1407
+
if (y_a <= y_b && y_a <= y_c) {
1408
1408
+
if (y_a >= bottomY) {
1409
1409
+
return;
1410
1410
+
}
1411
1411
+
if (y_b > bottomY) {
1412
1412
+
y_b = bottomY;
1413
1413
+
}
1414
1414
+
if (y_c > bottomY) {
1415
1415
+
y_c = bottomY;
1416
1416
+
}
1417
1417
+
if (y_b < y_c) {
1418
1418
+
x_c = x_a <<= 16;
1419
1419
+
grad_c = grad_a <<= 16;
1420
1420
+
if (y_a < 0) {
1421
1421
+
x_c -= x_c_off * y_a;
1422
1422
+
x_a -= x_a_off * y_a;
1423
1423
+
grad_c -= grad_c_off * y_a;
1424
1424
+
grad_a -= grad_a_off * y_a;
1425
1425
+
y_a = 0;
1426
1426
+
}
1427
1427
+
x_b <<= 16;
1428
1428
+
grad_b <<= 16;
1429
1429
+
if (y_b < 0) {
1430
1430
+
x_b -= x_b_off * y_b;
1431
1431
+
grad_b -= grad_b_off * y_b;
1432
1432
+
y_b = 0;
1433
1433
+
}
1434
1434
+
int jA = y_a - center_y;
1435
1435
+
Oa += Va * jA;
1436
1436
+
Ob += Vb * jA;
1437
1437
+
Oc += Vc * jA;
1438
1438
+
if (y_a != y_b && x_c_off < x_a_off || y_a == y_b && x_c_off > x_b_off) {
1439
1439
+
y_c -= y_b;
1440
1440
+
y_b -= y_a;
1441
1441
+
y_a = lineOffsets[y_a];
1442
1442
+
while (--y_b >= 0) {
1443
1443
+
drawTexturedLine(pixels, texture, y_a, x_c >> 16, x_a >> 16, grad_c >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1444
1444
+
x_c += x_c_off;
1445
1445
+
x_a += x_a_off;
1446
1446
+
grad_c += grad_c_off;
1447
1447
+
grad_a += grad_a_off;
1448
1448
+
y_a += width;
1449
1449
+
Oa += Va;
1450
1450
+
Ob += Vb;
1451
1451
+
Oc += Vc;
1452
1452
+
}
1453
1453
+
while (--y_c >= 0) {
1454
1454
+
drawTexturedLine(pixels, texture, y_a, x_c >> 16, x_b >> 16, grad_c >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1455
1455
+
x_c += x_c_off;
1456
1456
+
x_b += x_b_off;
1457
1457
+
grad_c += grad_c_off;
1458
1458
+
grad_b += grad_b_off;
1459
1459
+
y_a += width;
1460
1460
+
Oa += Va;
1461
1461
+
Ob += Vb;
1462
1462
+
Oc += Vc;
1463
1463
+
}
1464
1464
+
return;
1465
1465
+
}
1466
1466
+
y_c -= y_b;
1467
1467
+
y_b -= y_a;
1468
1468
+
y_a = lineOffsets[y_a];
1469
1469
+
while (--y_b >= 0) {
1470
1470
+
drawTexturedLine(pixels, texture, y_a, x_a >> 16, x_c >> 16, grad_a >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1471
1471
+
x_c += x_c_off;
1472
1472
+
x_a += x_a_off;
1473
1473
+
grad_c += grad_c_off;
1474
1474
+
grad_a += grad_a_off;
1475
1475
+
y_a += width;
1476
1476
+
Oa += Va;
1477
1477
+
Ob += Vb;
1478
1478
+
Oc += Vc;
1479
1479
+
}
1480
1480
+
while (--y_c >= 0) {
1481
1481
+
drawTexturedLine(pixels, texture, y_a, x_b >> 16, x_c >> 16, grad_b >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1482
1482
+
x_c += x_c_off;
1483
1483
+
x_b += x_b_off;
1484
1484
+
grad_c += grad_c_off;
1485
1485
+
grad_b += grad_b_off;
1486
1486
+
y_a += width;
1487
1487
+
Oa += Va;
1488
1488
+
Ob += Vb;
1489
1489
+
Oc += Vc;
1490
1490
+
}
1491
1491
+
return;
1492
1492
+
}
1493
1493
+
x_b = x_a <<= 16;
1494
1494
+
grad_b = grad_a <<= 16;
1495
1495
+
if (y_a < 0) {
1496
1496
+
x_b -= x_c_off * y_a;
1497
1497
+
x_a -= x_a_off * y_a;
1498
1498
+
grad_b -= grad_c_off * y_a;
1499
1499
+
grad_a -= grad_a_off * y_a;
1500
1500
+
y_a = 0;
1501
1501
+
}
1502
1502
+
x_c <<= 16;
1503
1503
+
grad_c <<= 16;
1504
1504
+
if (y_c < 0) {
1505
1505
+
x_c -= x_b_off * y_c;
1506
1506
+
grad_c -= grad_b_off * y_c;
1507
1507
+
y_c = 0;
1508
1508
+
}
1509
1509
+
int l8 = y_a - center_y;
1510
1510
+
Oa += Va * l8;
1511
1511
+
Ob += Vb * l8;
1512
1512
+
Oc += Vc * l8;
1513
1513
+
if (y_a != y_c && x_c_off < x_a_off || y_a == y_c && x_b_off > x_a_off) {
1514
1514
+
y_b -= y_c;
1515
1515
+
y_c -= y_a;
1516
1516
+
y_a = lineOffsets[y_a];
1517
1517
+
while (--y_c >= 0) {
1518
1518
+
drawTexturedLine(pixels, texture, y_a, x_b >> 16, x_a >> 16, grad_b >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1519
1519
+
x_b += x_c_off;
1520
1520
+
x_a += x_a_off;
1521
1521
+
grad_b += grad_c_off;
1522
1522
+
grad_a += grad_a_off;
1523
1523
+
y_a += width;
1524
1524
+
Oa += Va;
1525
1525
+
Ob += Vb;
1526
1526
+
Oc += Vc;
1527
1527
+
}
1528
1528
+
while (--y_b >= 0) {
1529
1529
+
drawTexturedLine(pixels, texture, y_a, x_c >> 16, x_a >> 16, grad_c >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1530
1530
+
x_c += x_b_off;
1531
1531
+
x_a += x_a_off;
1532
1532
+
grad_c += grad_b_off;
1533
1533
+
grad_a += grad_a_off;
1534
1534
+
y_a += width;
1535
1535
+
Oa += Va;
1536
1536
+
Ob += Vb;
1537
1537
+
Oc += Vc;
1538
1538
+
}
1539
1539
+
return;
1540
1540
+
}
1541
1541
+
y_b -= y_c;
1542
1542
+
y_c -= y_a;
1543
1543
+
y_a = lineOffsets[y_a];
1544
1544
+
while (--y_c >= 0) {
1545
1545
+
drawTexturedLine(pixels, texture, y_a, x_a >> 16, x_b >> 16, grad_a >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1546
1546
+
x_b += x_c_off;
1547
1547
+
x_a += x_a_off;
1548
1548
+
grad_b += grad_c_off;
1549
1549
+
grad_a += grad_a_off;
1550
1550
+
y_a += width;
1551
1551
+
Oa += Va;
1552
1552
+
Ob += Vb;
1553
1553
+
Oc += Vc;
1554
1554
+
}
1555
1555
+
while (--y_b >= 0) {
1556
1556
+
drawTexturedLine(pixels, texture, y_a, x_a >> 16, x_c >> 16, grad_a >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1557
1557
+
x_c += x_b_off;
1558
1558
+
x_a += x_a_off;
1559
1559
+
grad_c += grad_b_off;
1560
1560
+
grad_a += grad_a_off;
1561
1561
+
y_a += width;
1562
1562
+
Oa += Va;
1563
1563
+
Ob += Vb;
1564
1564
+
Oc += Vc;
1565
1565
+
}
1566
1566
+
return;
1567
1567
+
}
1568
1568
+
if (y_b <= y_c) {
1569
1569
+
if (y_b >= bottomY) {
1570
1570
+
return;
1571
1571
+
}
1572
1572
+
if (y_c > bottomY) {
1573
1573
+
y_c = bottomY;
1574
1574
+
}
1575
1575
+
if (y_a > bottomY) {
1576
1576
+
y_a = bottomY;
1577
1577
+
}
1578
1578
+
if (y_c < y_a) {
1579
1579
+
x_a = x_b <<= 16;
1580
1580
+
grad_a = grad_b <<= 16;
1581
1581
+
if (y_b < 0) {
1582
1582
+
x_a -= x_a_off * y_b;
1583
1583
+
x_b -= x_b_off * y_b;
1584
1584
+
grad_a -= grad_a_off * y_b;
1585
1585
+
grad_b -= grad_b_off * y_b;
1586
1586
+
y_b = 0;
1587
1587
+
}
1588
1588
+
x_c <<= 16;
1589
1589
+
grad_c <<= 16;
1590
1590
+
if (y_c < 0) {
1591
1591
+
x_c -= x_c_off * y_c;
1592
1592
+
grad_c -= grad_c_off * y_c;
1593
1593
+
y_c = 0;
1594
1594
+
}
1595
1595
+
int i9 = y_b - center_y;
1596
1596
+
Oa += Va * i9;
1597
1597
+
Ob += Vb * i9;
1598
1598
+
Oc += Vc * i9;
1599
1599
+
if (y_b != y_c && x_a_off < x_b_off || y_b == y_c && x_a_off > x_c_off) {
1600
1600
+
y_a -= y_c;
1601
1601
+
y_c -= y_b;
1602
1602
+
y_b = lineOffsets[y_b];
1603
1603
+
while (--y_c >= 0) {
1604
1604
+
drawTexturedLine(pixels, texture, y_b, x_a >> 16, x_b >> 16, grad_a >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1605
1605
+
x_a += x_a_off;
1606
1606
+
x_b += x_b_off;
1607
1607
+
grad_a += grad_a_off;
1608
1608
+
grad_b += grad_b_off;
1609
1609
+
y_b += width;
1610
1610
+
Oa += Va;
1611
1611
+
Ob += Vb;
1612
1612
+
Oc += Vc;
1613
1613
+
}
1614
1614
+
while (--y_a >= 0) {
1615
1615
+
drawTexturedLine(pixels, texture, y_b, x_a >> 16, x_c >> 16, grad_a >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1616
1616
+
x_a += x_a_off;
1617
1617
+
x_c += x_c_off;
1618
1618
+
grad_a += grad_a_off;
1619
1619
+
grad_c += grad_c_off;
1620
1620
+
y_b += width;
1621
1621
+
Oa += Va;
1622
1622
+
Ob += Vb;
1623
1623
+
Oc += Vc;
1624
1624
+
}
1625
1625
+
return;
1626
1626
+
}
1627
1627
+
y_a -= y_c;
1628
1628
+
y_c -= y_b;
1629
1629
+
y_b = lineOffsets[y_b];
1630
1630
+
while (--y_c >= 0) {
1631
1631
+
drawTexturedLine(pixels, texture, y_b, x_b >> 16, x_a >> 16, grad_b >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1632
1632
+
x_a += x_a_off;
1633
1633
+
x_b += x_b_off;
1634
1634
+
grad_a += grad_a_off;
1635
1635
+
grad_b += grad_b_off;
1636
1636
+
y_b += width;
1637
1637
+
Oa += Va;
1638
1638
+
Ob += Vb;
1639
1639
+
Oc += Vc;
1640
1640
+
}
1641
1641
+
while (--y_a >= 0) {
1642
1642
+
drawTexturedLine(pixels, texture, y_b, x_c >> 16, x_a >> 16, grad_c >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1643
1643
+
x_a += x_a_off;
1644
1644
+
x_c += x_c_off;
1645
1645
+
grad_a += grad_a_off;
1646
1646
+
grad_c += grad_c_off;
1647
1647
+
y_b += width;
1648
1648
+
Oa += Va;
1649
1649
+
Ob += Vb;
1650
1650
+
Oc += Vc;
1651
1651
+
}
1652
1652
+
return;
1653
1653
+
}
1654
1654
+
x_c = x_b <<= 16;
1655
1655
+
grad_c = grad_b <<= 16;
1656
1656
+
if (y_b < 0) {
1657
1657
+
x_c -= x_a_off * y_b;
1658
1658
+
x_b -= x_b_off * y_b;
1659
1659
+
grad_c -= grad_a_off * y_b;
1660
1660
+
grad_b -= grad_b_off * y_b;
1661
1661
+
y_b = 0;
1662
1662
+
}
1663
1663
+
x_a <<= 16;
1664
1664
+
grad_a <<= 16;
1665
1665
+
if (y_a < 0) {
1666
1666
+
x_a -= x_c_off * y_a;
1667
1667
+
grad_a -= grad_c_off * y_a;
1668
1668
+
y_a = 0;
1669
1669
+
}
1670
1670
+
int j9 = y_b - center_y;
1671
1671
+
Oa += Va * j9;
1672
1672
+
Ob += Vb * j9;
1673
1673
+
Oc += Vc * j9;
1674
1674
+
if (x_a_off < x_b_off) {
1675
1675
+
y_c -= y_a;
1676
1676
+
y_a -= y_b;
1677
1677
+
y_b = lineOffsets[y_b];
1678
1678
+
while (--y_a >= 0) {
1679
1679
+
drawTexturedLine(pixels, texture, y_b, x_c >> 16, x_b >> 16, grad_c >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1680
1680
+
x_c += x_a_off;
1681
1681
+
x_b += x_b_off;
1682
1682
+
grad_c += grad_a_off;
1683
1683
+
grad_b += grad_b_off;
1684
1684
+
y_b += width;
1685
1685
+
Oa += Va;
1686
1686
+
Ob += Vb;
1687
1687
+
Oc += Vc;
1688
1688
+
}
1689
1689
+
while (--y_c >= 0) {
1690
1690
+
drawTexturedLine(pixels, texture, y_b, x_a >> 16, x_b >> 16, grad_a >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1691
1691
+
x_a += x_c_off;
1692
1692
+
x_b += x_b_off;
1693
1693
+
grad_a += grad_c_off;
1694
1694
+
grad_b += grad_b_off;
1695
1695
+
y_b += width;
1696
1696
+
Oa += Va;
1697
1697
+
Ob += Vb;
1698
1698
+
Oc += Vc;
1699
1699
+
}
1700
1700
+
return;
1701
1701
+
}
1702
1702
+
y_c -= y_a;
1703
1703
+
y_a -= y_b;
1704
1704
+
y_b = lineOffsets[y_b];
1705
1705
+
while (--y_a >= 0) {
1706
1706
+
drawTexturedLine(pixels, texture, y_b, x_b >> 16, x_c >> 16, grad_b >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1707
1707
+
x_c += x_a_off;
1708
1708
+
x_b += x_b_off;
1709
1709
+
grad_c += grad_a_off;
1710
1710
+
grad_b += grad_b_off;
1711
1711
+
y_b += width;
1712
1712
+
Oa += Va;
1713
1713
+
Ob += Vb;
1714
1714
+
Oc += Vc;
1715
1715
+
}
1716
1716
+
while (--y_c >= 0) {
1717
1717
+
drawTexturedLine(pixels, texture, y_b, x_b >> 16, x_a >> 16, grad_b >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1718
1718
+
x_a += x_c_off;
1719
1719
+
x_b += x_b_off;
1720
1720
+
grad_a += grad_c_off;
1721
1721
+
grad_b += grad_b_off;
1722
1722
+
y_b += width;
1723
1723
+
Oa += Va;
1724
1724
+
Ob += Vb;
1725
1725
+
Oc += Vc;
1726
1726
+
}
1727
1727
+
return;
1728
1728
+
}
1729
1729
+
if (y_c >= bottomY) {
1730
1730
+
return;
1731
1731
+
}
1732
1732
+
if (y_a > bottomY) {
1733
1733
+
y_a = bottomY;
1734
1734
+
}
1735
1735
+
if (y_b > bottomY) {
1736
1736
+
y_b = bottomY;
1737
1737
+
}
1738
1738
+
if (y_a < y_b) {
1739
1739
+
x_b = x_c <<= 16;
1740
1740
+
grad_b = grad_c <<= 16;
1741
1741
+
if (y_c < 0) {
1742
1742
+
x_b -= x_b_off * y_c;
1743
1743
+
x_c -= x_c_off * y_c;
1744
1744
+
grad_b -= grad_b_off * y_c;
1745
1745
+
grad_c -= grad_c_off * y_c;
1746
1746
+
y_c = 0;
1747
1747
+
}
1748
1748
+
x_a <<= 16;
1749
1749
+
grad_a <<= 16;
1750
1750
+
if (y_a < 0) {
1751
1751
+
x_a -= x_a_off * y_a;
1752
1752
+
grad_a -= grad_a_off * y_a;
1753
1753
+
y_a = 0;
1754
1754
+
}
1755
1755
+
int k9 = y_c - center_y;
1756
1756
+
Oa += Va * k9;
1757
1757
+
Ob += Vb * k9;
1758
1758
+
Oc += Vc * k9;
1759
1759
+
if (x_b_off < x_c_off) {
1760
1760
+
y_b -= y_a;
1761
1761
+
y_a -= y_c;
1762
1762
+
y_c = lineOffsets[y_c];
1763
1763
+
while (--y_a >= 0) {
1764
1764
+
drawTexturedLine(pixels, texture, y_c, x_b >> 16, x_c >> 16, grad_b >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1765
1765
+
x_b += x_b_off;
1766
1766
+
x_c += x_c_off;
1767
1767
+
grad_b += grad_b_off;
1768
1768
+
grad_c += grad_c_off;
1769
1769
+
y_c += width;
1770
1770
+
Oa += Va;
1771
1771
+
Ob += Vb;
1772
1772
+
Oc += Vc;
1773
1773
+
}
1774
1774
+
while (--y_b >= 0) {
1775
1775
+
drawTexturedLine(pixels, texture, y_c, x_b >> 16, x_a >> 16, grad_b >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1776
1776
+
x_b += x_b_off;
1777
1777
+
x_a += x_a_off;
1778
1778
+
grad_b += grad_b_off;
1779
1779
+
grad_a += grad_a_off;
1780
1780
+
y_c += width;
1781
1781
+
Oa += Va;
1782
1782
+
Ob += Vb;
1783
1783
+
Oc += Vc;
1784
1784
+
}
1785
1785
+
return;
1786
1786
+
}
1787
1787
+
y_b -= y_a;
1788
1788
+
y_a -= y_c;
1789
1789
+
y_c = lineOffsets[y_c];
1790
1790
+
while (--y_a >= 0) {
1791
1791
+
drawTexturedLine(pixels, texture, y_c, x_c >> 16, x_b >> 16, grad_c >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1792
1792
+
x_b += x_b_off;
1793
1793
+
x_c += x_c_off;
1794
1794
+
grad_b += grad_b_off;
1795
1795
+
grad_c += grad_c_off;
1796
1796
+
y_c += width;
1797
1797
+
Oa += Va;
1798
1798
+
Ob += Vb;
1799
1799
+
Oc += Vc;
1800
1800
+
}
1801
1801
+
while (--y_b >= 0) {
1802
1802
+
drawTexturedLine(pixels, texture, y_c, x_a >> 16, x_b >> 16, grad_a >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1803
1803
+
x_b += x_b_off;
1804
1804
+
x_a += x_a_off;
1805
1805
+
grad_b += grad_b_off;
1806
1806
+
grad_a += grad_a_off;
1807
1807
+
y_c += width;
1808
1808
+
Oa += Va;
1809
1809
+
Ob += Vb;
1810
1810
+
Oc += Vc;
1811
1811
+
}
1812
1812
+
return;
1813
1813
+
}
1814
1814
+
x_a = x_c <<= 16;
1815
1815
+
grad_a = grad_c <<= 16;
1816
1816
+
if (y_c < 0) {
1817
1817
+
x_a -= x_b_off * y_c;
1818
1818
+
x_c -= x_c_off * y_c;
1819
1819
+
grad_a -= grad_b_off * y_c;
1820
1820
+
grad_c -= grad_c_off * y_c;
1821
1821
+
y_c = 0;
1822
1822
+
}
1823
1823
+
x_b <<= 16;
1824
1824
+
grad_b <<= 16;
1825
1825
+
if (y_b < 0) {
1826
1826
+
x_b -= x_a_off * y_b;
1827
1827
+
grad_b -= grad_a_off * y_b;
1828
1828
+
y_b = 0;
1829
1829
+
}
1830
1830
+
int l9 = y_c - center_y;
1831
1831
+
Oa += Va * l9;
1832
1832
+
Ob += Vb * l9;
1833
1833
+
Oc += Vc * l9;
1834
1834
+
if (x_b_off < x_c_off) {
1835
1835
+
y_a -= y_b;
1836
1836
+
y_b -= y_c;
1837
1837
+
y_c = lineOffsets[y_c];
1838
1838
+
while (--y_b >= 0) {
1839
1839
+
drawTexturedLine(pixels, texture, y_c, x_a >> 16, x_c >> 16, grad_a >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1840
1840
+
x_a += x_b_off;
1841
1841
+
x_c += x_c_off;
1842
1842
+
grad_a += grad_b_off;
1843
1843
+
grad_c += grad_c_off;
1844
1844
+
y_c += width;
1845
1845
+
Oa += Va;
1846
1846
+
Ob += Vb;
1847
1847
+
Oc += Vc;
1848
1848
+
}
1849
1849
+
while (--y_a >= 0) {
1850
1850
+
drawTexturedLine(pixels, texture, y_c, x_b >> 16, x_c >> 16, grad_b >> 8, grad_c >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1851
1851
+
x_b += x_a_off;
1852
1852
+
x_c += x_c_off;
1853
1853
+
grad_b += grad_a_off;
1854
1854
+
grad_c += grad_c_off;
1855
1855
+
y_c += width;
1856
1856
+
Oa += Va;
1857
1857
+
Ob += Vb;
1858
1858
+
Oc += Vc;
1859
1859
+
}
1860
1860
+
return;
1861
1861
+
}
1862
1862
+
y_a -= y_b;
1863
1863
+
y_b -= y_c;
1864
1864
+
y_c = lineOffsets[y_c];
1865
1865
+
while (--y_b >= 0) {
1866
1866
+
drawTexturedLine(pixels, texture, y_c, x_c >> 16, x_a >> 16, grad_c >> 8, grad_a >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1867
1867
+
x_a += x_b_off;
1868
1868
+
x_c += x_c_off;
1869
1869
+
grad_a += grad_b_off;
1870
1870
+
grad_c += grad_c_off;
1871
1871
+
y_c += width;
1872
1872
+
Oa += Va;
1873
1873
+
Ob += Vb;
1874
1874
+
Oc += Vc;
1875
1875
+
}
1876
1876
+
while (--y_a >= 0) {
1877
1877
+
drawTexturedLine(pixels, texture, y_c, x_c >> 16, x_b >> 16, grad_c >> 8, grad_b >> 8, Oa, Ob, Oc, Ha, Hb, Hc);
1878
1878
+
x_b += x_a_off;
1879
1879
+
x_c += x_c_off;
1880
1880
+
grad_b += grad_a_off;
1881
1881
+
grad_c += grad_c_off;
1882
1882
+
y_c += width;
1883
1883
+
Oa += Va;
1884
1884
+
Ob += Vb;
1885
1885
+
Oc += Vc;
1886
1886
+
}
1887
1887
+
}
1646
1888
1647
1647
-
public static void method508(int ai[], int ai1[], int i, int j, int k, int l, int i1, int j1, int k1, int l1,
1648
1648
-
int i2, int j2, int k2, int l2, int i3) {
1649
1649
-
if (l >= i1)
1650
1650
-
return;
1651
1651
-
int j3;
1652
1652
-
int k3;
1653
1653
-
if (restrictEdges) {
1654
1654
-
j3 = (k1 - j1) / (i1 - l);
1655
1655
-
if (i1 > Rasterizer.virtualBottomX)
1656
1656
-
i1 = Rasterizer.virtualBottomX;
1657
1657
-
if (l < 0) {
1658
1658
-
j1 -= l * j3;
1659
1659
-
l = 0;
1660
1660
-
}
1661
1661
-
if (l >= i1)
1662
1662
-
return;
1663
1663
-
k3 = i1 - l >> 3;
1664
1664
-
j3 <<= 12;
1665
1665
-
j1 <<= 9;
1666
1666
-
} else {
1667
1667
-
if (i1 - l > 7) {
1668
1668
-
k3 = i1 - l >> 3;
1669
1669
-
j3 = (k1 - j1) * anIntArray1534[k3] >> 6;
1670
1670
-
} else {
1671
1671
-
k3 = 0;
1672
1672
-
j3 = 0;
1673
1673
-
}
1674
1674
-
j1 <<= 9;
1675
1675
-
}
1676
1676
-
k += l;
1677
1677
-
if (lowMemory) {
1678
1678
-
int i4 = 0;
1679
1679
-
int k4 = 0;
1680
1680
-
int k6 = l - Rasterizer3D.centerX;
1681
1681
-
l1 += (k2 >> 3) * k6;
1682
1682
-
i2 += (l2 >> 3) * k6;
1683
1683
-
j2 += (i3 >> 3) * k6;
1684
1684
-
int i5 = j2 >> 12;
1685
1685
-
if (i5 != 0) {
1686
1686
-
i = l1 / i5;
1687
1687
-
j = i2 / i5;
1688
1688
-
if (i < 0)
1689
1689
-
i = 0;
1690
1690
-
else if (i > 4032)
1691
1691
-
i = 4032;
1692
1692
-
}
1693
1693
-
l1 += k2;
1694
1694
-
i2 += l2;
1695
1695
-
j2 += i3;
1696
1696
-
i5 = j2 >> 12;
1697
1697
-
if (i5 != 0) {
1698
1698
-
i4 = l1 / i5;
1699
1699
-
k4 = i2 / i5;
1700
1700
-
if (i4 < 7)
1701
1701
-
i4 = 7;
1702
1702
-
else if (i4 > 4032)
1703
1703
-
i4 = 4032;
1704
1704
-
}
1705
1705
-
int i7 = i4 - i >> 3;
1706
1706
-
int k7 = k4 - j >> 3;
1707
1707
-
i += (j1 & 0x600000) >> 3;
1708
1708
-
int i8 = j1 >> 23;
1709
1709
-
if (aBoolean1529) {
1710
1710
-
while (k3-- > 0) {
1711
1711
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1712
1712
-
i += i7;
1713
1713
-
j += k7;
1714
1714
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1715
1715
-
i += i7;
1716
1716
-
j += k7;
1717
1717
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1718
1718
-
i += i7;
1719
1719
-
j += k7;
1720
1720
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1721
1721
-
i += i7;
1722
1722
-
j += k7;
1723
1723
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1724
1724
-
i += i7;
1725
1725
-
j += k7;
1726
1726
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1727
1727
-
i += i7;
1728
1728
-
j += k7;
1729
1729
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1730
1730
-
i += i7;
1731
1731
-
j += k7;
1732
1732
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1733
1733
-
i = i4;
1734
1734
-
j = k4;
1735
1735
-
l1 += k2;
1736
1736
-
i2 += l2;
1737
1737
-
j2 += i3;
1738
1738
-
int j5 = j2 >> 12;
1739
1739
-
if (j5 != 0) {
1740
1740
-
i4 = l1 / j5;
1741
1741
-
k4 = i2 / j5;
1742
1742
-
if (i4 < 7)
1743
1743
-
i4 = 7;
1744
1744
-
else if (i4 > 4032)
1745
1745
-
i4 = 4032;
1746
1746
-
}
1747
1747
-
i7 = i4 - i >> 3;
1748
1748
-
k7 = k4 - j >> 3;
1749
1749
-
j1 += j3;
1750
1750
-
i += (j1 & 0x600000) >> 3;
1751
1751
-
i8 = j1 >> 23;
1752
1752
-
}
1753
1753
-
for (k3 = i1 - l & 7; k3-- > 0;) {
1754
1754
-
ai[k++] = ai1[(j & 0xfc0) + (i >> 6)] >>> i8;
1755
1755
-
i += i7;
1756
1756
-
j += k7;
1757
1757
-
}
1889
1889
+
public static void drawTexturedLine(int dest[], int texture[], int dest_off, int start_x, int end_x, int shadeValue,
1890
1890
+
int gradient, int arg7, int arg8, int arg9, int arg10, int arg11, int arg12) {
1891
1891
+
int rgb = 0;
1892
1892
+
int loops = 0;
1893
1893
+
if (start_x >= end_x)
1894
1894
+
return;
1895
1895
+
int j3;
1896
1896
+
int k3;
1897
1897
+
if (restrict_edges) {
1898
1898
+
j3 = (gradient - shadeValue) / (end_x - start_x);
1899
1899
+
if (end_x > Rasterizer.viewportRx)
1900
1900
+
end_x = Rasterizer.viewportRx;
1901
1901
+
if (start_x < 0) {
1902
1902
+
shadeValue -= start_x * j3;
1903
1903
+
start_x = 0;
1904
1904
+
}
1905
1905
+
if (start_x >= end_x)
1906
1906
+
return;
1907
1907
+
k3 = end_x - start_x >> 3;
1908
1908
+
j3 <<= 12;
1909
1909
+
shadeValue <<= 9;
1910
1910
+
} else {
1911
1911
+
if (end_x - start_x > 7) {
1912
1912
+
k3 = end_x - start_x >> 3;
1913
1913
+
j3 = (gradient - shadeValue) * shadowDecay[k3] >> 6;
1914
1914
+
} else {
1915
1915
+
k3 = 0;
1916
1916
+
j3 = 0;
1917
1917
+
}
1918
1918
+
shadeValue <<= 9;
1919
1919
+
}
1920
1920
+
dest_off += start_x;
1921
1921
+
if (lowMemory) {
1922
1922
+
int i4 = 0;
1923
1923
+
int k4 = 0;
1924
1924
+
int k6 = start_x - Rasterizer3D.center_x;
1925
1925
+
arg7 += (arg10 >> 3) * k6;
1926
1926
+
arg8 += (arg11 >> 3) * k6;
1927
1927
+
arg9 += (arg12 >> 3) * k6;
1928
1928
+
int i5 = arg9 >> 12;
1929
1929
+
if (i5 != 0) {
1930
1930
+
rgb = arg7 / i5;
1931
1931
+
loops = arg8 / i5;
1932
1932
+
if (rgb < 0)
1933
1933
+
rgb = 0;
1934
1934
+
else if (rgb > 4032)
1935
1935
+
rgb = 4032;
1936
1936
+
}
1937
1937
+
arg7 += arg10;
1938
1938
+
arg8 += arg11;
1939
1939
+
arg9 += arg12;
1940
1940
+
i5 = arg9 >> 12;
1941
1941
+
if (i5 != 0) {
1942
1942
+
i4 = arg7 / i5;
1943
1943
+
k4 = arg8 / i5;
1944
1944
+
if (i4 < 7)
1945
1945
+
i4 = 7;
1946
1946
+
else if (i4 > 4032)
1947
1947
+
i4 = 4032;
1948
1948
+
}
1949
1949
+
int i7 = i4 - rgb >> 3;
1950
1950
+
int k7 = k4 - loops >> 3;
1951
1951
+
rgb += (shadeValue & 0x600000) >> 3;
1952
1952
+
int i8 = shadeValue >> 23;
1953
1953
+
if (opaque) {
1954
1954
+
while (k3-- > 0) {
1955
1955
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1956
1956
+
rgb += i7;
1957
1957
+
loops += k7;
1958
1958
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1959
1959
+
rgb += i7;
1960
1960
+
loops += k7;
1961
1961
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1962
1962
+
rgb += i7;
1963
1963
+
loops += k7;
1964
1964
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1965
1965
+
rgb += i7;
1966
1966
+
loops += k7;
1967
1967
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1968
1968
+
rgb += i7;
1969
1969
+
loops += k7;
1970
1970
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1971
1971
+
rgb += i7;
1972
1972
+
loops += k7;
1973
1973
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1974
1974
+
rgb += i7;
1975
1975
+
loops += k7;
1976
1976
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1977
1977
+
rgb = i4;
1978
1978
+
loops = k4;
1979
1979
+
arg7 += arg10;
1980
1980
+
arg8 += arg11;
1981
1981
+
arg9 += arg12;
1982
1982
+
int j5 = arg9 >> 12;
1983
1983
+
if (j5 != 0) {
1984
1984
+
i4 = arg7 / j5;
1985
1985
+
k4 = arg8 / j5;
1986
1986
+
if (i4 < 7)
1987
1987
+
i4 = 7;
1988
1988
+
else if (i4 > 4032)
1989
1989
+
i4 = 4032;
1990
1990
+
}
1991
1991
+
i7 = i4 - rgb >> 3;
1992
1992
+
k7 = k4 - loops >> 3;
1993
1993
+
shadeValue += j3;
1994
1994
+
rgb += (shadeValue & 0x600000) >> 3;
1995
1995
+
i8 = shadeValue >> 23;
1996
1996
+
}
1997
1997
+
for (k3 = end_x - start_x & 7; k3-- > 0; ) {
1998
1998
+
dest[dest_off++] = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8;
1999
1999
+
rgb += i7;
2000
2000
+
loops += k7;
2001
2001
+
}
1758
2002
1759
1759
-
return;
1760
1760
-
}
1761
1761
-
while (k3-- > 0) {
1762
1762
-
int k8;
1763
1763
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1764
1764
-
ai[k] = k8;
1765
1765
-
k++;
1766
1766
-
i += i7;
1767
1767
-
j += k7;
1768
1768
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1769
1769
-
ai[k] = k8;
1770
1770
-
k++;
1771
1771
-
i += i7;
1772
1772
-
j += k7;
1773
1773
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1774
1774
-
ai[k] = k8;
1775
1775
-
k++;
1776
1776
-
i += i7;
1777
1777
-
j += k7;
1778
1778
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1779
1779
-
ai[k] = k8;
1780
1780
-
k++;
1781
1781
-
i += i7;
1782
1782
-
j += k7;
1783
1783
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1784
1784
-
ai[k] = k8;
1785
1785
-
k++;
1786
1786
-
i += i7;
1787
1787
-
j += k7;
1788
1788
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1789
1789
-
ai[k] = k8;
1790
1790
-
k++;
1791
1791
-
i += i7;
1792
1792
-
j += k7;
1793
1793
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1794
1794
-
ai[k] = k8;
1795
1795
-
k++;
1796
1796
-
i += i7;
1797
1797
-
j += k7;
1798
1798
-
if ((k8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1799
1799
-
ai[k] = k8;
1800
1800
-
k++;
1801
1801
-
i = i4;
1802
1802
-
j = k4;
1803
1803
-
l1 += k2;
1804
1804
-
i2 += l2;
1805
1805
-
j2 += i3;
1806
1806
-
int k5 = j2 >> 12;
1807
1807
-
if (k5 != 0) {
1808
1808
-
i4 = l1 / k5;
1809
1809
-
k4 = i2 / k5;
1810
1810
-
if (i4 < 7)
1811
1811
-
i4 = 7;
1812
1812
-
else if (i4 > 4032)
1813
1813
-
i4 = 4032;
1814
1814
-
}
1815
1815
-
i7 = i4 - i >> 3;
1816
1816
-
k7 = k4 - j >> 3;
1817
1817
-
j1 += j3;
1818
1818
-
i += (j1 & 0x600000) >> 3;
1819
1819
-
i8 = j1 >> 23;
1820
1820
-
}
1821
1821
-
for (k3 = i1 - l & 7; k3-- > 0;) {
1822
1822
-
int l8;
1823
1823
-
if ((l8 = ai1[(j & 0xfc0) + (i >> 6)] >>> i8) != 0)
1824
1824
-
ai[k] = l8;
1825
1825
-
k++;
1826
1826
-
i += i7;
1827
1827
-
j += k7;
1828
1828
-
}
2003
2003
+
return;
2004
2004
+
}
2005
2005
+
while (k3-- > 0) {
2006
2006
+
int k8;
2007
2007
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2008
2008
+
dest[dest_off] = k8;
2009
2009
+
dest_off++;
2010
2010
+
rgb += i7;
2011
2011
+
loops += k7;
2012
2012
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2013
2013
+
dest[dest_off] = k8;
2014
2014
+
dest_off++;
2015
2015
+
rgb += i7;
2016
2016
+
loops += k7;
2017
2017
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2018
2018
+
dest[dest_off] = k8;
2019
2019
+
dest_off++;
2020
2020
+
rgb += i7;
2021
2021
+
loops += k7;
2022
2022
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2023
2023
+
dest[dest_off] = k8;
2024
2024
+
dest_off++;
2025
2025
+
rgb += i7;
2026
2026
+
loops += k7;
2027
2027
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2028
2028
+
dest[dest_off] = k8;
2029
2029
+
dest_off++;
2030
2030
+
rgb += i7;
2031
2031
+
loops += k7;
2032
2032
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2033
2033
+
dest[dest_off] = k8;
2034
2034
+
dest_off++;
2035
2035
+
rgb += i7;
2036
2036
+
loops += k7;
2037
2037
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2038
2038
+
dest[dest_off] = k8;
2039
2039
+
dest_off++;
2040
2040
+
rgb += i7;
2041
2041
+
loops += k7;
2042
2042
+
if ((k8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2043
2043
+
dest[dest_off] = k8;
2044
2044
+
dest_off++;
2045
2045
+
rgb = i4;
2046
2046
+
loops = k4;
2047
2047
+
arg7 += arg10;
2048
2048
+
arg8 += arg11;
2049
2049
+
arg9 += arg12;
2050
2050
+
int k5 = arg9 >> 12;
2051
2051
+
if (k5 != 0) {
2052
2052
+
i4 = arg7 / k5;
2053
2053
+
k4 = arg8 / k5;
2054
2054
+
if (i4 < 7)
2055
2055
+
i4 = 7;
2056
2056
+
else if (i4 > 4032)
2057
2057
+
i4 = 4032;
2058
2058
+
}
2059
2059
+
i7 = i4 - rgb >> 3;
2060
2060
+
k7 = k4 - loops >> 3;
2061
2061
+
shadeValue += j3;
2062
2062
+
rgb += (shadeValue & 0x600000) >> 3;
2063
2063
+
i8 = shadeValue >> 23;
2064
2064
+
}
2065
2065
+
for (k3 = end_x - start_x & 7; k3-- > 0; ) {
2066
2066
+
int l8;
2067
2067
+
if ((l8 = texture[(loops & 0xfc0) + (rgb >> 6)] >>> i8) != 0)
2068
2068
+
dest[dest_off] = l8;
2069
2069
+
dest_off++;
2070
2070
+
rgb += i7;
2071
2071
+
loops += k7;
2072
2072
+
}
1829
2073
1830
1830
-
return;
1831
1831
-
}
1832
1832
-
int j4 = 0;
1833
1833
-
int l4 = 0;
1834
1834
-
int l6 = l - Rasterizer3D.centerX;
1835
1835
-
l1 += (k2 >> 3) * l6;
1836
1836
-
i2 += (l2 >> 3) * l6;
1837
1837
-
j2 += (i3 >> 3) * l6;
1838
1838
-
int l5 = j2 >> 14;
1839
1839
-
if (l5 != 0) {
1840
1840
-
i = l1 / l5;
1841
1841
-
j = i2 / l5;
1842
1842
-
if (i < 0)
1843
1843
-
i = 0;
1844
1844
-
else if (i > 16256)
1845
1845
-
i = 16256;
1846
1846
-
}
1847
1847
-
l1 += k2;
1848
1848
-
i2 += l2;
1849
1849
-
j2 += i3;
1850
1850
-
l5 = j2 >> 14;
1851
1851
-
if (l5 != 0) {
1852
1852
-
j4 = l1 / l5;
1853
1853
-
l4 = i2 / l5;
1854
1854
-
if (j4 < 7)
1855
1855
-
j4 = 7;
1856
1856
-
else if (j4 > 16256)
1857
1857
-
j4 = 16256;
1858
1858
-
}
1859
1859
-
int j7 = j4 - i >> 3;
1860
1860
-
int l7 = l4 - j >> 3;
1861
1861
-
i += j1 & 0x600000;
1862
1862
-
int j8 = j1 >> 23;
1863
1863
-
if (aBoolean1529) {
1864
1864
-
while (k3-- > 0) {
1865
1865
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1866
1866
-
i += j7;
1867
1867
-
j += l7;
1868
1868
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1869
1869
-
i += j7;
1870
1870
-
j += l7;
1871
1871
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1872
1872
-
i += j7;
1873
1873
-
j += l7;
1874
1874
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1875
1875
-
i += j7;
1876
1876
-
j += l7;
1877
1877
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1878
1878
-
i += j7;
1879
1879
-
j += l7;
1880
1880
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1881
1881
-
i += j7;
1882
1882
-
j += l7;
1883
1883
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1884
1884
-
i += j7;
1885
1885
-
j += l7;
1886
1886
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1887
1887
-
i = j4;
1888
1888
-
j = l4;
1889
1889
-
l1 += k2;
1890
1890
-
i2 += l2;
1891
1891
-
j2 += i3;
1892
1892
-
int i6 = j2 >> 14;
1893
1893
-
if (i6 != 0) {
1894
1894
-
j4 = l1 / i6;
1895
1895
-
l4 = i2 / i6;
1896
1896
-
if (j4 < 7)
1897
1897
-
j4 = 7;
1898
1898
-
else if (j4 > 16256)
1899
1899
-
j4 = 16256;
1900
1900
-
}
1901
1901
-
j7 = j4 - i >> 3;
1902
1902
-
l7 = l4 - j >> 3;
1903
1903
-
j1 += j3;
1904
1904
-
i += j1 & 0x600000;
1905
1905
-
j8 = j1 >> 23;
1906
1906
-
}
1907
1907
-
for (k3 = i1 - l & 7; k3-- > 0;) {
1908
1908
-
ai[k++] = ai1[(j & 0x3f80) + (i >> 7)] >>> j8;
1909
1909
-
i += j7;
1910
1910
-
j += l7;
1911
1911
-
}
2074
2074
+
return;
2075
2075
+
}
2076
2076
+
int j4 = 0;
2077
2077
+
int l4 = 0;
2078
2078
+
int l6 = start_x - Rasterizer3D.center_x;
2079
2079
+
arg7 += (arg10 >> 3) * l6;
2080
2080
+
arg8 += (arg11 >> 3) * l6;
2081
2081
+
arg9 += (arg12 >> 3) * l6;
2082
2082
+
int l5 = arg9 >> 14;
2083
2083
+
if (l5 != 0) {
2084
2084
+
rgb = arg7 / l5;
2085
2085
+
loops = arg8 / l5;
2086
2086
+
if (rgb < 0)
2087
2087
+
rgb = 0;
2088
2088
+
else if (rgb > 16256)
2089
2089
+
rgb = 16256;
2090
2090
+
}
2091
2091
+
arg7 += arg10;
2092
2092
+
arg8 += arg11;
2093
2093
+
arg9 += arg12;
2094
2094
+
l5 = arg9 >> 14;
2095
2095
+
if (l5 != 0) {
2096
2096
+
j4 = arg7 / l5;
2097
2097
+
l4 = arg8 / l5;
2098
2098
+
if (j4 < 7)
2099
2099
+
j4 = 7;
2100
2100
+
else if (j4 > 16256)
2101
2101
+
j4 = 16256;
2102
2102
+
}
2103
2103
+
int j7 = j4 - rgb >> 3;
2104
2104
+
int l7 = l4 - loops >> 3;
2105
2105
+
rgb += shadeValue & 0x600000;
2106
2106
+
int j8 = shadeValue >> 23;
2107
2107
+
if (opaque) {
2108
2108
+
while (k3-- > 0) {
2109
2109
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2110
2110
+
rgb += j7;
2111
2111
+
loops += l7;
2112
2112
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2113
2113
+
rgb += j7;
2114
2114
+
loops += l7;
2115
2115
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2116
2116
+
rgb += j7;
2117
2117
+
loops += l7;
2118
2118
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2119
2119
+
rgb += j7;
2120
2120
+
loops += l7;
2121
2121
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2122
2122
+
rgb += j7;
2123
2123
+
loops += l7;
2124
2124
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2125
2125
+
rgb += j7;
2126
2126
+
loops += l7;
2127
2127
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2128
2128
+
rgb += j7;
2129
2129
+
loops += l7;
2130
2130
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2131
2131
+
rgb = j4;
2132
2132
+
loops = l4;
2133
2133
+
arg7 += arg10;
2134
2134
+
arg8 += arg11;
2135
2135
+
arg9 += arg12;
2136
2136
+
int i6 = arg9 >> 14;
2137
2137
+
if (i6 != 0) {
2138
2138
+
j4 = arg7 / i6;
2139
2139
+
l4 = arg8 / i6;
2140
2140
+
if (j4 < 7)
2141
2141
+
j4 = 7;
2142
2142
+
else if (j4 > 16256)
2143
2143
+
j4 = 16256;
2144
2144
+
}
2145
2145
+
j7 = j4 - rgb >> 3;
2146
2146
+
l7 = l4 - loops >> 3;
2147
2147
+
shadeValue += j3;
2148
2148
+
rgb += shadeValue & 0x600000;
2149
2149
+
j8 = shadeValue >> 23;
2150
2150
+
}
2151
2151
+
for (k3 = end_x - start_x & 7; k3-- > 0; ) {
2152
2152
+
dest[dest_off++] = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8;
2153
2153
+
rgb += j7;
2154
2154
+
loops += l7;
2155
2155
+
}
1912
2156
1913
1913
-
return;
1914
1914
-
}
1915
1915
-
while (k3-- > 0) {
1916
1916
-
int i9;
1917
1917
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1918
1918
-
ai[k] = i9;
1919
1919
-
k++;
1920
1920
-
i += j7;
1921
1921
-
j += l7;
1922
1922
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1923
1923
-
ai[k] = i9;
1924
1924
-
k++;
1925
1925
-
i += j7;
1926
1926
-
j += l7;
1927
1927
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1928
1928
-
ai[k] = i9;
1929
1929
-
k++;
1930
1930
-
i += j7;
1931
1931
-
j += l7;
1932
1932
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1933
1933
-
ai[k] = i9;
1934
1934
-
k++;
1935
1935
-
i += j7;
1936
1936
-
j += l7;
1937
1937
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1938
1938
-
ai[k] = i9;
1939
1939
-
k++;
1940
1940
-
i += j7;
1941
1941
-
j += l7;
1942
1942
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1943
1943
-
ai[k] = i9;
1944
1944
-
k++;
1945
1945
-
i += j7;
1946
1946
-
j += l7;
1947
1947
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1948
1948
-
ai[k] = i9;
1949
1949
-
k++;
1950
1950
-
i += j7;
1951
1951
-
j += l7;
1952
1952
-
if ((i9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1953
1953
-
ai[k] = i9;
1954
1954
-
k++;
1955
1955
-
i = j4;
1956
1956
-
j = l4;
1957
1957
-
l1 += k2;
1958
1958
-
i2 += l2;
1959
1959
-
j2 += i3;
1960
1960
-
int j6 = j2 >> 14;
1961
1961
-
if (j6 != 0) {
1962
1962
-
j4 = l1 / j6;
1963
1963
-
l4 = i2 / j6;
1964
1964
-
if (j4 < 7)
1965
1965
-
j4 = 7;
1966
1966
-
else if (j4 > 16256)
1967
1967
-
j4 = 16256;
1968
1968
-
}
1969
1969
-
j7 = j4 - i >> 3;
1970
1970
-
l7 = l4 - j >> 3;
1971
1971
-
j1 += j3;
1972
1972
-
i += j1 & 0x600000;
1973
1973
-
j8 = j1 >> 23;
1974
1974
-
}
1975
1975
-
for (int l3 = i1 - l & 7; l3-- > 0;) {
1976
1976
-
int j9;
1977
1977
-
if ((j9 = ai1[(j & 0x3f80) + (i >> 7)] >>> j8) != 0)
1978
1978
-
ai[k] = j9;
1979
1979
-
k++;
1980
1980
-
i += j7;
1981
1981
-
j += l7;
1982
1982
-
}
2157
2157
+
return;
2158
2158
+
}
2159
2159
+
while (k3-- > 0) {
2160
2160
+
int i9;
2161
2161
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2162
2162
+
dest[dest_off] = i9;
2163
2163
+
dest_off++;
2164
2164
+
rgb += j7;
2165
2165
+
loops += l7;
2166
2166
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2167
2167
+
dest[dest_off] = i9;
2168
2168
+
dest_off++;
2169
2169
+
rgb += j7;
2170
2170
+
loops += l7;
2171
2171
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2172
2172
+
dest[dest_off] = i9;
2173
2173
+
dest_off++;
2174
2174
+
rgb += j7;
2175
2175
+
loops += l7;
2176
2176
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2177
2177
+
dest[dest_off] = i9;
2178
2178
+
dest_off++;
2179
2179
+
rgb += j7;
2180
2180
+
loops += l7;
2181
2181
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2182
2182
+
dest[dest_off] = i9;
2183
2183
+
dest_off++;
2184
2184
+
rgb += j7;
2185
2185
+
loops += l7;
2186
2186
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2187
2187
+
dest[dest_off] = i9;
2188
2188
+
dest_off++;
2189
2189
+
rgb += j7;
2190
2190
+
loops += l7;
2191
2191
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2192
2192
+
dest[dest_off] = i9;
2193
2193
+
dest_off++;
2194
2194
+
rgb += j7;
2195
2195
+
loops += l7;
2196
2196
+
if ((i9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2197
2197
+
dest[dest_off] = i9;
2198
2198
+
dest_off++;
2199
2199
+
rgb = j4;
2200
2200
+
loops = l4;
2201
2201
+
arg7 += arg10;
2202
2202
+
arg8 += arg11;
2203
2203
+
arg9 += arg12;
2204
2204
+
int j6 = arg9 >> 14;
2205
2205
+
if (j6 != 0) {
2206
2206
+
j4 = arg7 / j6;
2207
2207
+
l4 = arg8 / j6;
2208
2208
+
if (j4 < 7)
2209
2209
+
j4 = 7;
2210
2210
+
else if (j4 > 16256)
2211
2211
+
j4 = 16256;
2212
2212
+
}
2213
2213
+
j7 = j4 - rgb >> 3;
2214
2214
+
l7 = l4 - loops >> 3;
2215
2215
+
shadeValue += j3;
2216
2216
+
rgb += shadeValue & 0x600000;
2217
2217
+
j8 = shadeValue >> 23;
2218
2218
+
}
2219
2219
+
for (int l3 = end_x - start_x & 7; l3-- > 0; ) {
2220
2220
+
int j9;
2221
2221
+
if ((j9 = texture[(loops & 0x3f80) + (rgb >> 7)] >>> j8) != 0)
2222
2222
+
dest[dest_off] = j9;
2223
2223
+
dest_off++;
2224
2224
+
rgb += j7;
2225
2225
+
loops += l7;
2226
2226
+
}
1983
2227
1984
1984
-
}
2228
2228
+
}
1985
2229
1986
1986
-
static {
1987
1987
-
for (int i = 1; i < 512; i++)
1988
1988
-
anIntArray1534[i] = 32768 / i;
2230
2230
+
static {
2231
2231
+
for (int i = 1; i < 512; i++)
2232
2232
+
shadowDecay[i] = 32768 / i;
1989
2233
1990
1990
-
for (int j = 1; j < 2048; j++)
1991
1991
-
anIntArray1535[j] = 0x10000 / j;
2234
2234
+
for (int j = 1; j < 2048; j++)
2235
2235
+
anIntArray1469[j] = 0x10000 / j;
1992
2236
1993
1993
-
for (int k = 0; k < 2048; k++) {
1994
1994
-
SINE[k] = (int) (65536D * Math.sin(k * 0.0030679614999999999D));
1995
1995
-
COSINE[k] = (int) (65536D * Math.cos(k * 0.0030679614999999999D));
1996
1996
-
}
2237
2237
+
for (int k = 0; k < 2048; k++) {
2238
2238
+
SINE[k] = (int) (65536D * Math.sin(k * 0.0030679614999999999D));
2239
2239
+
COSINE[k] = (int) (65536D * Math.cos(k * 0.0030679614999999999D));
2240
2240
+
}
1997
2241
1998
1998
-
}
2242
2242
+
}
1999
2243
}
+25
-25
src/main/java/com/jagex/runescape/media/renderable/Model.java
Reviewed
···
1377
1377
}
1378
1378
1379
1379
public void render(int i, int j, int k, int l, int i1, int j1, int k1) {
1380
1380
-
int l1 = Rasterizer3D.centerX;
1381
1381
-
int i2 = Rasterizer3D.centerY;
1380
1380
+
int l1 = Rasterizer3D.center_x;
1381
1381
+
int i2 = Rasterizer3D.center_y;
1382
1382
int j2 = SINE[i];
1383
1383
int k2 = COSINE[i];
1384
1384
int l2 = SINE[j];
···
1483
1483
k4 /= i3;
1484
1484
i5 /= k5;
1485
1485
}
1486
1486
-
int i6 = cursorX - Rasterizer3D.centerX;
1487
1487
-
int k6 = cursorY - Rasterizer3D.centerY;
1486
1486
+
int i6 = cursorX - Rasterizer3D.center_x;
1487
1487
+
int k6 = cursorY - Rasterizer3D.center_y;
1488
1488
if (i6 > k3 && i6 < l3 && k6 > i5 && k6 < k4) {
1489
1489
if (singleTile) {
1490
1490
hoveredHash[resourceCount++] = i2;
···
1493
1493
}
1494
1494
}
1495
1495
}
1496
1496
-
int l5 = Rasterizer3D.centerX;
1497
1497
-
int j6 = Rasterizer3D.centerY;
1496
1496
+
int l5 = Rasterizer3D.center_x;
1497
1497
+
int j6 = Rasterizer3D.center_y;
1498
1498
int l6 = 0;
1499
1499
int i7 = 0;
1500
1500
if (i != 0) {
···
1567
1567
if ((i3 - l3) * (vertexScreenY[j2] - vertexScreenY[k1])
1568
1568
- (vertexScreenY[l] - vertexScreenY[k1]) * (k4 - l3) > 0) {
1569
1569
aBooleanArray1685[k] = false;
1570
1570
-
if (i3 < 0 || l3 < 0 || k4 < 0 || i3 > Rasterizer.virtualBottomX
1571
1571
-
|| l3 > Rasterizer.virtualBottomX || k4 > Rasterizer.virtualBottomX) {
1570
1570
+
if (i3 < 0 || l3 < 0 || k4 < 0 || i3 > Rasterizer.viewportRx
1571
1571
+
|| l3 > Rasterizer.viewportRx || k4 > Rasterizer.viewportRx) {
1572
1572
restrictEdges[k] = true;
1573
1573
} else {
1574
1574
restrictEdges[k] = false;
···
1723
1723
int j = trianglePointsX[i];
1724
1724
int k = trianglePointsY[i];
1725
1725
int l = trianglePointsZ[i];
1726
1726
-
Rasterizer3D.restrictEdges = restrictEdges[i];
1726
1726
+
Rasterizer3D.restrict_edges = restrictEdges[i];
1727
1727
if (triangleAlphaValues == null) {
1728
1728
Rasterizer3D.alpha = 0;
1729
1729
} else {
···
1742
1742
return;
1743
1743
}
1744
1744
if (i1 == 1) {
1745
1745
-
Rasterizer3D.method505(vertexScreenY[j], vertexScreenY[k], vertexScreenY[l],
1745
1745
+
Rasterizer3D.drawFlatTriangle(vertexScreenY[j], vertexScreenY[k], vertexScreenY[l],
1746
1746
vertexScreenX[j], vertexScreenX[k], vertexScreenX[l], HSLtoRGB[triangleHSLA[i]]);
1747
1747
return;
1748
1748
}
···
1770
1770
}
1771
1771
1772
1772
private void method601(int i) {
1773
1773
-
int j = Rasterizer3D.centerX;
1774
1774
-
int k = Rasterizer3D.centerY;
1773
1773
+
int j = Rasterizer3D.center_x;
1774
1774
+
int k = Rasterizer3D.center_y;
1775
1775
int l = 0;
1776
1776
int i1 = trianglePointsX[i];
1777
1777
int j1 = trianglePointsY[i];
···
1849
1849
int j7 = anIntArray1700[1];
1850
1850
int k7 = anIntArray1700[2];
1851
1851
if ((j3 - j4) * (k7 - j7) - (i7 - j7) * (j5 - j4) > 0) {
1852
1852
-
Rasterizer3D.restrictEdges = false;
1852
1852
+
Rasterizer3D.restrict_edges = false;
1853
1853
if (l == 3) {
1854
1854
-
if (j3 < 0 || j4 < 0 || j5 < 0 || j3 > Rasterizer.virtualBottomX || j4 > Rasterizer.virtualBottomX
1855
1855
-
|| j5 > Rasterizer.virtualBottomX) {
1856
1856
-
Rasterizer3D.restrictEdges = true;
1854
1854
+
if (j3 < 0 || j4 < 0 || j5 < 0 || j3 > Rasterizer.viewportRx || j4 > Rasterizer.viewportRx
1855
1855
+
|| j5 > Rasterizer.viewportRx) {
1856
1856
+
Rasterizer3D.restrict_edges = true;
1857
1857
}
1858
1858
int l7;
1859
1859
if (triangleDrawType == null) {
···
1865
1865
Rasterizer3D.drawShadedTriangle(i7, j7, k7, j3, j4, j5, anIntArray1701[0], anIntArray1701[1],
1866
1866
anIntArray1701[2]);
1867
1867
} else if (l7 == 1) {
1868
1868
-
Rasterizer3D.method505(i7, j7, k7, j3, j4, j5, HSLtoRGB[triangleHSLA[i]]);
1868
1868
+
Rasterizer3D.drawFlatTriangle(i7, j7, k7, j3, j4, j5, HSLtoRGB[triangleHSLA[i]]);
1869
1869
} else if (l7 == 2) {
1870
1870
int j8 = triangleDrawType[i] >> 2;
1871
1871
int k9 = texturedTrianglePointsX[j8];
···
1887
1887
}
1888
1888
}
1889
1889
if (l == 4) {
1890
1890
-
if (j3 < 0 || j4 < 0 || j5 < 0 || j3 > Rasterizer.virtualBottomX || j4 > Rasterizer.virtualBottomX
1891
1891
-
|| j5 > Rasterizer.virtualBottomX || anIntArray1699[3] < 0
1892
1892
-
|| anIntArray1699[3] > Rasterizer.virtualBottomX) {
1893
1893
-
Rasterizer3D.restrictEdges = true;
1890
1890
+
if (j3 < 0 || j4 < 0 || j5 < 0 || j3 > Rasterizer.viewportRx || j4 > Rasterizer.viewportRx
1891
1891
+
|| j5 > Rasterizer.viewportRx || anIntArray1699[3] < 0
1892
1892
+
|| anIntArray1699[3] > Rasterizer.viewportRx) {
1893
1893
+
Rasterizer3D.restrict_edges = true;
1894
1894
}
1895
1895
int i8;
1896
1896
if (triangleDrawType == null) {
···
1907
1907
}
1908
1908
if (i8 == 1) {
1909
1909
int l8 = HSLtoRGB[triangleHSLA[i]];
1910
1910
-
Rasterizer3D.method505(i7, j7, k7, j3, j4, j5, l8);
1911
1911
-
Rasterizer3D.method505(i7, k7, anIntArray1700[3], j3, j5, anIntArray1699[3], l8);
1910
1910
+
Rasterizer3D.drawFlatTriangle(i7, j7, k7, j3, j4, j5, l8);
1911
1911
+
Rasterizer3D.drawFlatTriangle(i7, k7, anIntArray1700[3], j3, j5, anIntArray1699[3], l8);
1912
1912
return;
1913
1913
}
1914
1914
if (i8 == 2) {
···
1961
1961
static {
1962
1962
SINE = Rasterizer3D.SINE;
1963
1963
COSINE = Rasterizer3D.COSINE;
1964
1964
-
HSLtoRGB = Rasterizer3D.getRgbLookupTableId;
1965
1965
-
anIntArray1713 = Rasterizer3D.anIntArray1535;
1964
1964
+
HSLtoRGB = Rasterizer3D.hsl2rgb;
1965
1965
+
anIntArray1713 = Rasterizer3D.anIntArray1469;
1966
1966
}
1967
1967
}
1968
1968
+6
-6
src/main/java/com/jagex/runescape/scene/Region.java
Reviewed
···
459
459
}
460
460
int rgbBitsetRandomized = 0;
461
461
if (hslBitsetUnmodified != -1)
462
462
-
rgbBitsetRandomized = (Rasterizer3D.getRgbLookupTableId[trimHSLLightness(hslBitsetRandomized, 96)]);
462
462
+
rgbBitsetRandomized = (Rasterizer3D.hsl2rgb[trimHSLLightness(hslBitsetRandomized, 96)]);
463
463
if (overlayFloorId == 0)
464
464
-
scene.renderTile(plane, x, y, 0, 0, -1, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest,
464
464
+
scene.addTile(plane, x, y, 0, 0, -1, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest,
465
465
trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthEast),
466
466
trimHSLLightness(hslBitsetUnmodified, lightNorthWest), 0, 0, 0, 0, rgbBitsetRandomized, 0);
467
467
else {
···
472
472
int hslBitset;
473
473
int rgbBitset;
474
474
if (textureid >= 0) {
475
475
-
rgbBitset = Rasterizer3D.getAverageRgbColorForTexture(textureid, 0);
475
475
+
rgbBitset = Rasterizer3D.getAverageRgbColorForTexture(textureid);
476
476
hslBitset = -1;
477
477
} else if (floor.rgbColor == 16711935) {
478
478
hslBitset = -2;
479
479
textureid = -1;
480
480
-
rgbBitset = (Rasterizer3D.getRgbLookupTableId[mixLightnessSigned(floor.hslColor2, 96)]);
480
480
+
rgbBitset = (Rasterizer3D.hsl2rgb[mixLightnessSigned(floor.hslColor2, 96)]);
481
481
} else {
482
482
hslBitset = getHSLBitset(floor.hue2, floor.saturation, floor.lightness);
483
483
-
rgbBitset = (Rasterizer3D.getRgbLookupTableId[mixLightnessSigned(floor.hslColor2, 96)]);
483
483
+
rgbBitset = (Rasterizer3D.hsl2rgb[mixLightnessSigned(floor.hslColor2, 96)]);
484
484
}
485
485
-
scene.renderTile(plane, x, y, clippingPath, clippingPathRotation, textureid, vertexSouthWest, vertexSouthEast, vertexNorthEast,
485
485
+
scene.addTile(plane, x, y, clippingPath, clippingPathRotation, textureid, vertexSouthWest, vertexSouthEast, vertexNorthEast,
486
486
vertexNorthWest, trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified,
487
487
lightNorthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthWest), mixLightnessSigned(hslBitset, lightSouthWest),
488
488
mixLightnessSigned(hslBitset, lightSouthEast), mixLightnessSigned(hslBitset, lightNorthEast),
+46
-44
src/main/java/com/jagex/runescape/scene/Scene.java
Reviewed
···
201
201
}
202
202
}
203
203
204
204
-
void renderTile(int plane, int x, int y, int clippingPath, int clippingPathRotation, int textureId, int vertexHeightSW, int vertexHeightSE, int vertexHeightNE, int vertexHeightNW, int cA, int cB,
205
205
-
int cD, int cC, int colourA, int colourB, int colourD, int colourC, int underlayRGB, int overlayRGB) {
206
206
-
if (clippingPath == 0) {
204
204
+
void addTile(int plane, int x, int y, int shape, int clippingPathRotation, int textureId, int vertexHeightSW, int vertexHeightSE, int vertexHeightNE, int vertexHeightNW, int cA, int cB,
205
205
+
int cD, int cC, int colourA, int colourB, int colourD, int colourC, int underlayRGB, int overlayRGB) {
206
206
+
if (shape == 0) {
207
207
GenericTile tile = new GenericTile(cA, cB, cC, cD, -1, underlayRGB, false);
208
208
for (int _z = plane; _z >= 0; _z--) {
209
209
if (groundArray.isTileEmpty(_z, x, y)) {
···
212
212
}
213
213
214
214
groundArray.getTile(plane, x, y).plainTile = tile;
215
215
-
return;
216
216
-
}
217
217
-
if (clippingPath == 1) {
215
215
+
} else if (shape == 1) {
218
216
GenericTile tile = new GenericTile(colourA, colourB, colourC, colourD, textureId, overlayRGB, vertexHeightSW == vertexHeightSE && vertexHeightSW == vertexHeightNE && vertexHeightSW == vertexHeightNW);
219
217
for (int _z = plane; _z >= 0; _z--) {
220
218
if (groundArray.isTileEmpty(_z, x, y)) {
221
219
groundArray.setTile(_z, x, y, new SceneTile(x, y, _z));
222
220
}
223
221
}
222
222
+
if ((overlayRGB & 0xFF0000) >> 16 >= 160) {
223
223
+
System.out.println("FOUND RED INIT!!!" + overlayRGB);
224
224
+
}
224
225
225
226
groundArray.getTile(plane, x, y).plainTile = tile;
226
226
-
return;
227
227
-
}
228
228
-
ComplexTile tile = new ComplexTile(x, vertexHeightSW, vertexHeightSE, vertexHeightNW, vertexHeightNE, y, clippingPathRotation, textureId, clippingPath, cA, colourA, cB, colourB, cC, colourC, cD, colourD, overlayRGB, underlayRGB);
229
229
-
for (int _z = plane; _z >= 0; _z--) {
230
230
-
if (groundArray.isTileEmpty(_z, x, y)) {
231
231
-
groundArray.setTile(_z, x, y, new SceneTile(x, y, _z));
227
227
+
} else {
228
228
+
ComplexTile tile = new ComplexTile(x, vertexHeightSW, vertexHeightSE, vertexHeightNW, vertexHeightNE, y, clippingPathRotation, textureId, shape, cA, colourA, cB, colourB, cC, colourC, cD, colourD, overlayRGB, underlayRGB);
229
229
+
for (int _z = plane; _z >= 0; _z--) {
230
230
+
if (groundArray.isTileEmpty(_z, x, y)) {
231
231
+
groundArray.setTile(_z, x, y, new SceneTile(x, y, _z));
232
232
+
}
232
233
}
233
233
-
}
234
234
235
235
236
236
-
groundArray.getTile(plane, x, y).shapedTile = tile;
236
236
+
groundArray.getTile(plane, x, y).shapedTile = tile;
237
237
+
}
237
238
}
238
239
239
240
void addGroundDecoration(int x, int y, int z, int drawHeight, int uid, Renderable renderable, byte config) {
···
873
874
if (tileRGB == 0) {
874
875
return;
875
876
}
876
876
-
if((tileRGB & 0xFF0000) >> 16 >= 160){
877
877
+
if ((tileRGB & 0xFF0000) >> 16 >= 160) {
877
878
System.out.println("FOUND RED!!!");
879
879
+
System.out.println(genericTile.flat);
878
880
}
879
881
for (int k1 = 0; k1 < 4; k1++) {
880
882
pixels[pixelPointer] = tileRGB;
···
1405
1407
}
1406
1408
}
1407
1409
if (x > cameraPositionTileX && (k4 & 1) != 0) {
1408
1408
-
SceneTile tile = groundArray.getTile(z, x-1, y);
1410
1410
+
SceneTile tile = groundArray.getTile(z, x - 1, y);
1409
1411
if (tile != null && tile.visible) {
1410
1412
tileList.pushBack(tile);
1411
1413
}
1412
1414
}
1413
1415
if (y > cameraPositionTileY && (k4 & 8) != 0) {
1414
1414
-
SceneTile tile = groundArray.getTile(z, x, y-1);
1416
1416
+
SceneTile tile = groundArray.getTile(z, x, y - 1);
1415
1417
if (tile != null && tile.visible) {
1416
1418
tileList.pushBack(tile);
1417
1419
}
···
1553
1555
continue;
1554
1556
}
1555
1557
if (x <= cameraPositionTileX && x > currentPositionX) {
1556
1556
-
SceneTile tile = groundArray.getTile(z, x-1, y);
1558
1558
+
SceneTile tile = groundArray.getTile(z, x - 1, y);
1557
1559
if (tile != null && tile.visible) {
1558
1560
continue;
1559
1561
}
1560
1562
}
1561
1563
if (x >= cameraPositionTileX && x < mapBoundsX - 1) {
1562
1562
-
SceneTile tile = groundArray.getTile(z, x+1, y);
1564
1564
+
SceneTile tile = groundArray.getTile(z, x + 1, y);
1563
1565
if (tile != null && tile.visible) {
1564
1566
continue;
1565
1567
}
1566
1568
}
1567
1569
if (y <= cameraPositionTileY && y > currentPositionY) {
1568
1568
-
SceneTile tile = groundArray.getTile(z, x, y-1);
1570
1570
+
SceneTile tile = groundArray.getTile(z, x, y - 1);
1569
1571
if (tile != null && tile.visible) {
1570
1572
continue;
1571
1573
}
1572
1574
}
1573
1575
if (y >= cameraPositionTileY && y < mapBoundsY - 1) {
1574
1574
-
SceneTile tile = groundArray.getTile(z, x, y+1);
1576
1576
+
SceneTile tile = groundArray.getTile(z, x, y + 1);
1575
1577
if (tile != null && tile.visible) {
1576
1578
continue;
1577
1579
}
···
1649
1651
}
1650
1652
}
1651
1653
if (z < mapSizeZ - 1) {
1652
1652
-
SceneTile tile = groundArray.getTile(z+1, x, y);
1654
1654
+
SceneTile tile = groundArray.getTile(z + 1, x, y);
1653
1655
if (tile != null && tile.visible) {
1654
1656
tileList.pushBack(tile);
1655
1657
}
1656
1658
}
1657
1659
if (x < cameraPositionTileX) {
1658
1658
-
SceneTile tile = groundArray.getTile(z, x+1, y);
1660
1660
+
SceneTile tile = groundArray.getTile(z, x + 1, y);
1659
1661
if (tile != null && tile.visible) {
1660
1662
tileList.pushBack(tile);
1661
1663
}
1662
1664
}
1663
1665
if (y < cameraPositionTileY) {
1664
1664
-
SceneTile tile = groundArray.getTile(z, x, y+1);
1666
1666
+
SceneTile tile = groundArray.getTile(z, x, y + 1);
1665
1667
if (tile != null && tile.visible) {
1666
1668
tileList.pushBack(tile);
1667
1669
}
1668
1670
}
1669
1671
if (x > cameraPositionTileX) {
1670
1670
-
SceneTile tile = groundArray.getTile(z, x-1, y);
1672
1672
+
SceneTile tile = groundArray.getTile(z, x - 1, y);
1671
1673
if (tile != null && tile.visible) {
1672
1674
tileList.pushBack(tile);
1673
1675
}
1674
1676
}
1675
1677
if (y > cameraPositionTileY) {
1676
1676
-
SceneTile tile = groundArray.getTile(z, x, y-1);
1678
1678
+
SceneTile tile = groundArray.getTile(z, x, y - 1);
1677
1679
if (tile != null && tile.visible) {
1678
1680
tileList.pushBack(tile);
1679
1681
}
···
1730
1732
if (yC < 50) {
1731
1733
return;
1732
1734
}
1733
1733
-
int screenXA = Rasterizer3D.centerX + (xA << 9) / yA;
1734
1734
-
int screenYA = Rasterizer3D.centerY + (zA << 9) / yA;
1735
1735
-
int screenXB = Rasterizer3D.centerX + (xB << 9) / yB;
1736
1736
-
int screenYB = Rasterizer3D.centerY + (zB << 9) / yB;
1737
1737
-
int screenXD = Rasterizer3D.centerX + (xD << 9) / yD;
1738
1738
-
int screenYD = Rasterizer3D.centerY + (zC << 9) / yD;
1739
1739
-
int screenXC = Rasterizer3D.centerX + (xC << 9) / yC;
1740
1740
-
int screenYC = Rasterizer3D.centerY + (zD << 9) / yC;
1735
1735
+
int screenXA = Rasterizer3D.center_x + (xA << 9) / yA;
1736
1736
+
int screenYA = Rasterizer3D.center_y + (zA << 9) / yA;
1737
1737
+
int screenXB = Rasterizer3D.center_x + (xB << 9) / yB;
1738
1738
+
int screenYB = Rasterizer3D.center_y + (zB << 9) / yB;
1739
1739
+
int screenXD = Rasterizer3D.center_x + (xD << 9) / yD;
1740
1740
+
int screenYD = Rasterizer3D.center_y + (zC << 9) / yD;
1741
1741
+
int screenXC = Rasterizer3D.center_x + (xC << 9) / yC;
1742
1742
+
int screenYC = Rasterizer3D.center_y + (zD << 9) / yC;
1741
1743
Rasterizer3D.alpha = 0;
1742
1744
if ((screenXD - screenXC) * (screenYB - screenYC) - (screenYD - screenYC) * (screenXB - screenXC) > 0) {
1743
1743
-
Rasterizer3D.restrictEdges = screenXD < 0 || screenXC < 0 || screenXB < 0 ||
1744
1744
-
screenXD > Rasterizer.virtualBottomX ||
1745
1745
-
screenXC > Rasterizer.virtualBottomX ||
1746
1746
-
screenXB > Rasterizer.virtualBottomX;
1745
1745
+
Rasterizer3D.restrict_edges = screenXD < 0 || screenXC < 0 || screenXB < 0 ||
1746
1746
+
screenXD > Rasterizer.viewportRx ||
1747
1747
+
screenXC > Rasterizer.viewportRx ||
1748
1748
+
screenXB > Rasterizer.viewportRx;
1747
1749
if (clicked && isMouseWithinTriangle(clickX, clickY, screenYD, screenYC, screenYB, screenXD, screenXC, screenXB)) {
1748
1750
clickedTileX = tileX;
1749
1751
clickedTileY = tileY;
···
1768
1770
}
1769
1771
}
1770
1772
if ((screenXA - screenXB) * (screenYC - screenYB) - (screenYA - screenYB) * (screenXC - screenXB) > 0) {
1771
1771
-
Rasterizer3D.restrictEdges = screenXA < 0 || screenXB < 0 || screenXC < 0 || screenXA > Rasterizer.virtualBottomX || screenXB > Rasterizer.virtualBottomX
1772
1772
-
|| screenXC > Rasterizer.virtualBottomX;
1773
1773
+
Rasterizer3D.restrict_edges = screenXA < 0 || screenXB < 0 || screenXC < 0 || screenXA > Rasterizer.viewportRx || screenXB > Rasterizer.viewportRx
1774
1774
+
|| screenXC > Rasterizer.viewportRx;
1773
1775
if (clicked && isMouseWithinTriangle(clickX, clickY, screenYA, screenYB, screenYC, screenXA, screenXB, screenXC)) {
1774
1776
clickedTileX = tileX;
1775
1777
clickedTileY = tileY;
···
1812
1814
ComplexTile.viewspaceY[triangle] = viewspaceY;
1813
1815
ComplexTile.viewspaceZ[triangle] = viewspaceZ;
1814
1816
}
1815
1815
-
ComplexTile.screenX[triangle] = Rasterizer3D.centerX + (viewspaceX << 9) / viewspaceZ;
1816
1816
-
ComplexTile.screenY[triangle] = Rasterizer3D.centerY + (viewspaceY << 9) / viewspaceZ;
1817
1817
+
ComplexTile.screenX[triangle] = Rasterizer3D.center_x + (viewspaceX << 9) / viewspaceZ;
1818
1818
+
ComplexTile.screenY[triangle] = Rasterizer3D.center_y + (viewspaceY << 9) / viewspaceZ;
1817
1819
}
1818
1820
1819
1821
Rasterizer3D.alpha = 0;
···
1829
1831
int screenYB = ComplexTile.screenY[b];
1830
1832
int screenYC = ComplexTile.screenY[c];
1831
1833
if ((screenXA - screenXB) * (screenYC - screenYB) - (screenYA - screenYB) * (screenXC - screenXB) > 0) {
1832
1832
-
Rasterizer3D.restrictEdges = screenXA < 0 || screenXB < 0 || screenXC < 0 || screenXA > Rasterizer.virtualBottomX || screenXB > Rasterizer.virtualBottomX
1833
1833
-
|| screenXC > Rasterizer.virtualBottomX;
1834
1834
+
Rasterizer3D.restrict_edges = screenXA < 0 || screenXB < 0 || screenXC < 0 || screenXA > Rasterizer.viewportRx || screenXB > Rasterizer.viewportRx
1835
1835
+
|| screenXC > Rasterizer.viewportRx;
1834
1836
if (clicked && isMouseWithinTriangle(clickX, clickY, screenYA, screenYB, screenYC, screenXA, screenXB, screenXC)) {
1835
1837
clickedTileX = tileX;
1836
1838
clickedTileY = tileY;