|
17 | 17 | @OriginalClass("mapview!mapview")
|
18 | 18 | public final class mapview extends GameShell {
|
19 | 19 |
|
20 |
| - // 2005 mapview applet features |
21 | 20 | private static final boolean shouldDrawBorders = false;
|
22 | 21 | private static final boolean shouldDrawLabels = true;
|
23 | 22 |
|
| 23 | + private static final boolean showMultiZones = false; |
| 24 | + private static final boolean showFreeZones = false; |
| 25 | + |
| 26 | + private boolean[][] objTiles; |
| 27 | + private boolean[][] npcTiles; |
| 28 | + private boolean[][] multiTiles; |
| 29 | + private boolean[][] freeTiles; |
| 30 | + |
24 | 31 | // overworld
|
25 | 32 | private final short startX = 3200;
|
26 | 33 | private final short startZ = 3200;
|
@@ -72,10 +79,6 @@ public final class mapview extends GameShell {
|
72 | 79 | @OriginalMember(owner = "mapview!mapview", name = "U", descriptor = "[[B")
|
73 | 80 | private byte[][] locMapscenes;
|
74 | 81 |
|
75 |
| - private boolean[][] objTiles; |
76 |
| - |
77 |
| - private boolean[][] npcTiles; |
78 |
| - |
79 | 82 | @OriginalMember(owner = "mapview!mapview", name = "X", descriptor = "Lmapview!j;")
|
80 | 83 | private PixFont b12;
|
81 | 84 |
|
@@ -312,6 +315,20 @@ protected void load() {
|
312 | 315 | this.npcTiles = new boolean[this.sizeX][this.sizeZ];
|
313 | 316 | this.readNpcData(npcData, this.npcTiles);
|
314 | 317 |
|
| 318 | + try { |
| 319 | + byte[] multiData = worldmap.read("multi.dat", null); |
| 320 | + this.multiTiles = new boolean[this.sizeX][this.sizeZ]; |
| 321 | + this.readMultiData(multiData, this.multiTiles); |
| 322 | + } catch (Exception ex) { |
| 323 | + } |
| 324 | + |
| 325 | + try { |
| 326 | + byte[] freeData = worldmap.read("free.dat", null); |
| 327 | + this.freeTiles = new boolean[this.sizeX][this.sizeZ]; |
| 328 | + this.readFreeData(freeData, this.freeTiles); |
| 329 | + } catch (Exception ex) { |
| 330 | + } |
| 331 | + |
315 | 332 | try {
|
316 | 333 | for (int i = 0; i < 50; i++) {
|
317 | 334 | this.imageMapscene[i] = new Pix8(worldmap, "mapscene", i);
|
@@ -445,6 +462,48 @@ private void readNpcData(byte[] data, boolean[][] npcs) {
|
445 | 462 | }
|
446 | 463 | }
|
447 | 464 |
|
| 465 | + private void readMultiData(byte[] data, boolean[][] multimap) { |
| 466 | + int pos = 0; |
| 467 | + while (pos < data.length) { |
| 468 | + int mx = (data[pos++] & 0xFF) * 64 - this.originX; |
| 469 | + int mz = (data[pos++] & 0xFF) * 64 - this.originZ; |
| 470 | + |
| 471 | + if (mx > 0 && mz > 0 && mx + 64 < this.sizeX && mz + 64 < this.sizeZ) { |
| 472 | + for (int x = 0; x < 64; x++) { |
| 473 | + boolean[] map = multimap[x + mx]; |
| 474 | + int zIndex = this.sizeZ - mz - 1; |
| 475 | + |
| 476 | + for (int z = -64; z < 0; z++) { |
| 477 | + map[zIndex--] = data[pos++] == 1; |
| 478 | + } |
| 479 | + } |
| 480 | + } else { |
| 481 | + pos += 4096; |
| 482 | + } |
| 483 | + } |
| 484 | + } |
| 485 | + |
| 486 | + private void readFreeData(byte[] data, boolean[][] freemap) { |
| 487 | + int pos = 0; |
| 488 | + while (pos < data.length) { |
| 489 | + int mx = (data[pos++] & 0xFF) * 64 - this.originX; |
| 490 | + int mz = (data[pos++] & 0xFF) * 64 - this.originZ; |
| 491 | + |
| 492 | + if (mx > 0 && mz > 0 && mx + 64 < this.sizeX && mz + 64 < this.sizeZ) { |
| 493 | + for (int x = 0; x < 64; x++) { |
| 494 | + boolean[] map = freemap[x + mx]; |
| 495 | + int zIndex = this.sizeZ - mz - 1; |
| 496 | + |
| 497 | + for (int z = -64; z < 0; z++) { |
| 498 | + map[zIndex--] = data[pos++] == 1; |
| 499 | + } |
| 500 | + } |
| 501 | + } else { |
| 502 | + pos += 4096; |
| 503 | + } |
| 504 | + } |
| 505 | + } |
| 506 | + |
448 | 507 | @OriginalMember(owner = "mapview!mapview", name = "a", descriptor = "([B[[B)V")
|
449 | 508 | private void readUnderlayData(@OriginalArg(0) byte[] data, @OriginalArg(1) byte[][] underlays) {
|
450 | 509 | @Pc(3) int pos = 0;
|
@@ -614,6 +673,8 @@ protected void unload() {
|
614 | 673 | this.locMapscenes = null;
|
615 | 674 | this.objTiles = null;
|
616 | 675 | this.npcTiles = null;
|
| 676 | + this.multiTiles = null; |
| 677 | + this.freeTiles = null; |
617 | 678 | this.imageMapscene = null;
|
618 | 679 | this.imageMapfunction = null;
|
619 | 680 | this.imageMapdot0 = null;
|
@@ -1187,6 +1248,68 @@ private void drawMap(@OriginalArg(0) int left, @OriginalArg(1) int top, @Origina
|
1187 | 1248 | }
|
1188 | 1249 | }
|
1189 | 1250 |
|
| 1251 | + if (showMultiZones) { |
| 1252 | + for (int x = 0; x < visibleX; x++) { |
| 1253 | + int startX = widthRatio * x >> 16; |
| 1254 | + int endX = widthRatio * (x + 1) >> 16; |
| 1255 | + int lengthX = endX - startX; |
| 1256 | + if (lengthX <= 0) { |
| 1257 | + continue; |
| 1258 | + } |
| 1259 | + |
| 1260 | + startX += widthOffset; |
| 1261 | + endX += widthOffset; |
| 1262 | + |
| 1263 | + boolean[] multi = this.multiTiles[x + left]; |
| 1264 | + for (int y = 0; y < visibleY; y++) { |
| 1265 | + int startY = heightRatio * y >> 16; |
| 1266 | + int endY = heightRatio * (y + 1) >> 16; |
| 1267 | + int lengthY = endY - startY; |
| 1268 | + if (lengthY <= 0) { |
| 1269 | + continue; |
| 1270 | + } |
| 1271 | + |
| 1272 | + startY += heightOffset; |
| 1273 | + endY += heightOffset; |
| 1274 | + |
| 1275 | + if (multi[y + top]) { |
| 1276 | + Pix2D.fillRectTrans(startX, startY, lengthX, lengthY, 0xff0000, 96); |
| 1277 | + } |
| 1278 | + } |
| 1279 | + } |
| 1280 | + } |
| 1281 | + |
| 1282 | + if (showFreeZones) { |
| 1283 | + for (int x = 0; x < visibleX; x++) { |
| 1284 | + int startX = widthRatio * x >> 16; |
| 1285 | + int endX = widthRatio * (x + 1) >> 16; |
| 1286 | + int lengthX = endX - startX; |
| 1287 | + if (lengthX <= 0) { |
| 1288 | + continue; |
| 1289 | + } |
| 1290 | + |
| 1291 | + startX += widthOffset; |
| 1292 | + endX += widthOffset; |
| 1293 | + |
| 1294 | + boolean[] free = this.freeTiles[x + left]; |
| 1295 | + for (int y = 0; y < visibleY; y++) { |
| 1296 | + int startY = heightRatio * y >> 16; |
| 1297 | + int endY = heightRatio * (y + 1) >> 16; |
| 1298 | + int lengthY = endY - startY; |
| 1299 | + if (lengthY <= 0) { |
| 1300 | + continue; |
| 1301 | + } |
| 1302 | + |
| 1303 | + startY += heightOffset; |
| 1304 | + endY += heightOffset; |
| 1305 | + |
| 1306 | + if (free[y + top]) { |
| 1307 | + Pix2D.fillRectTrans(startX, startY, lengthX, lengthY, 0x00ff00, 96); |
| 1308 | + } |
| 1309 | + } |
| 1310 | + } |
| 1311 | + } |
| 1312 | + |
1190 | 1313 | for (int i = 0; i < visibleMapFunctionCount; i++) {
|
1191 | 1314 | this.imageMapfunction[this.visibleMapFunctions[i]].draw(this.visibleMapFunctionsX[i] - 7, this.visibleMapFunctionsY[i] - 7);
|
1192 | 1315 | }
|
|
0 commit comments