19 const BYTE
L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 };
20 const BYTE
L3UP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 51, 50, 0, 48, 49, 0, 0, 0, 0 };
21 const BYTE
L3DOWN[20] = { 3, 3, 8, 9, 7, 8, 9, 7, 0, 0, 0, 0, 47, 0, 0, 46, 0, 0, 0, 0 };
22 const BYTE
L3HOLDWARP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 125, 125, 0, 125, 125, 0, 0, 0, 0 };
23 const BYTE
L3TITE1[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 57, 58, 0, 0, 56, 55, 0, 0, 0, 0, 0 };
24 const BYTE
L3TITE2[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 61, 62, 0, 0, 60, 59, 0, 0, 0, 0, 0 };
25 const BYTE
L3TITE3[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 65, 66, 0, 0, 64, 63, 0, 0, 0, 0, 0 };
26 const BYTE
L3TITE6[42] = { 5, 4, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 77, 78, 0, 0, 0, 76, 74, 75, 0, 0, 0, 0, 0, 0 };
27 const BYTE
L3TITE7[42] = { 4, 5, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 83, 0, 0, 0, 82, 80, 0, 0, 81, 79, 0, 0, 0, 0, 0 };
28 const BYTE
L3TITE8[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 52, 0, 0, 0, 0 };
29 const BYTE
L3TITE9[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 53, 0, 0, 0, 0 };
30 const BYTE
L3TITE10[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 54, 0, 0, 0, 0 };
31 const BYTE
L3TITE11[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 67, 0, 0, 0, 0 };
32 const BYTE
L3TITE12[6] = { 2, 1, 9, 7, 68, 0 };
33 const BYTE
L3TITE13[6] = { 1, 2, 10, 7, 69, 0 };
34 const BYTE
L3CREV1[6] = { 2, 1, 8, 7, 84, 85 };
35 const BYTE
L3CREV2[6] = { 2, 1, 8, 11, 86, 87 };
36 const BYTE
L3CREV3[6] = { 1, 2, 8, 10, 89, 88 };
37 const BYTE
L3CREV4[6] = { 2, 1, 8, 7, 90, 91 };
38 const BYTE
L3CREV5[6] = { 1, 2, 8, 11, 92, 93 };
39 const BYTE
L3CREV6[6] = { 1, 2, 8, 10, 95, 94 };
40 const BYTE
L3CREV7[6] = { 2, 1, 8, 7, 96, 101 };
41 const BYTE
L3CREV8[6] = { 1, 2, 2, 8, 102, 97 };
42 const BYTE
L3CREV9[6] = { 2, 1, 3, 8, 103, 98 };
43 const BYTE
L3CREV10[6] = { 2, 1, 4, 8, 104, 99 };
44 const BYTE
L3CREV11[6] = { 1, 2, 6, 8, 105, 100 };
45 const BYTE
L3ISLE1[14] = { 2, 3, 5, 14, 4, 9, 13, 12, 7, 7, 7, 7, 7, 7 };
46 const BYTE
L3ISLE2[14] = { 3, 2, 5, 2, 14, 13, 10, 12, 7, 7, 7, 7, 7, 7 };
47 const BYTE
L3ISLE3[14] = { 2, 3, 5, 14, 4, 9, 13, 12, 29, 30, 25, 28, 31, 32 };
48 const BYTE
L3ISLE4[14] = { 3, 2, 5, 2, 14, 13, 10, 12, 29, 26, 30, 31, 27, 32 };
49 const BYTE
L3ISLE5[10] = { 2, 2, 5, 14, 13, 12, 7, 7, 7, 7 };
54 const BYTE
L3XTRA5[4] = { 1, 1, 10, 110 };
56 11, 11, 7, 7, 7, 7, 7, 7, 7, 7,
57 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
58 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
59 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
60 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
61 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
62 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
63 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
64 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
65 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
66 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
67 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
68 7, 7, 7, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 29, 26, 26, 26,
70 26, 26, 30, 0, 0, 0, 29, 34, 33, 33,
71 37, 36, 33, 35, 30, 0, 0, 25, 33, 37,
72 27, 32, 31, 36, 33, 28, 0, 0, 25, 37,
73 32, 7, 7, 7, 31, 27, 32, 0, 0, 25,
74 28, 7, 7, 7, 7, 2, 2, 2, 0, 0,
75 25, 35, 30, 7, 7, 7, 29, 26, 30, 0,
76 0, 25, 33, 35, 26, 30, 29, 34, 33, 28,
77 0, 0, 31, 36, 33, 33, 35, 34, 33, 37,
78 32, 0, 0, 0, 31, 27, 27, 27, 27, 27,
79 32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
89 for (j = 0; j <
DMAXY; j++) {
90 for (i = 0; i <
DMAXX; i++) {
101 if (x1 <= 1 || x2 >= 34 || y1 <= 1 || y2 >= 38) {
106 for (j = y1; j <= y2; j++) {
107 for (i = x1; i <= x2; i++) {
116 for (j = y1 + 1; j < y2; j++) {
117 for (i = x1 + 1; i < x2; i++) {
121 for (j = y1; j <= y2; j++) {
129 for (i = x1; i <= x2; i++) {
143 int blksizex, blksizey, x1, y1, x2, y2;
152 if (blksizex < obs) {
155 if (blksizex == obs) {
158 if (blksizex > obs) {
166 if (blksizey < obs) {
169 if (blksizey == obs) {
172 if (blksizey > obs) {
180 if (blksizex < obs) {
183 if (blksizex == obs) {
186 if (blksizex > obs) {
194 if (blksizey < obs) {
197 if (blksizey == obs) {
200 if (blksizey > obs) {
208 if (contflag && dir != 2) {
211 if (contflag && dir != 3) {
214 if (contflag && dir != 0) {
217 if (contflag && dir != 1) {
227 for (j = y1; j <= y2; j++) {
228 for (i = x1; i <= x2; i++) {
238 for (j = 0; j <
DMAXY - 1; j++) {
239 for (i = 0; i <
DMAXX - 1; i++) {
263 for (j = 1; j <
DMAXY - 1; j++) {
264 for (i = 1; i <
DMAXX - 1; i++) {
277 int i, j, xc, xs, yc, ys, k, rv;
279 for (j = 0; j <
DMAXY - 1; j++) {
281 for (i = 0; i < 37; i++) {
288 if (xs > 3 &&
random_(0, 2) != 0) {
289 for (k = xc; k < i; k++) {
298 for (j = 0; j <
DMAXY - 1; j++) {
300 for (i = 0; i < 37; i++) {
307 if (xs > 3 &&
random_(0, 2) != 0) {
308 for (k = xc; k < i; k++) {
317 for (i = 0; i <
DMAXX - 1; i++) {
319 for (j = 0; j < 37; j++) {
326 if (ys > 3 &&
random_(0, 2) != 0) {
327 for (k = yc; k < j; k++) {
336 for (i = 0; i <
DMAXX - 1; i++) {
338 for (j = 0; j < 37; j++) {
345 if (ys > 3 &&
random_(0, 2) != 0) {
346 for (k = yc; k < j; k++) {
361 for (j = 0; j <
DMAXY; j++) {
364 for (i = 0; i <
DMAXX; i++) {
375 for (j = 0; j <
DMAXY; j++) {
376 for (i = 0; i <
DMAXX; i++) {
388 for (j = 0; j <
DMAXY - 1; j++) {
389 for (i = 0; i <
DMAXX - 1; i++) {
411 for (i = 0; i <
DMAXX; i++) {
418 int rx, ry, px, py, dir, pdir, nodir, nodir2, dircheck;
420 int rivercnt, riveramt;
421 int i, trys, found, bridge, lpcnt;
430 while (trys < 200 && rivercnt < 4) {
432 while (!bail && trys < 200) {
484 while (dircheck < 4 && riveramt < 100) {
493 while (dir == nodir || dir == nodir2) {
497 if (dir == 0 && ry > 0) {
500 if (dir == 1 && ry <
DMAXY) {
503 if (dir == 2 && rx <
DMAXX) {
506 if (dir == 3 && rx > 0) {
512 river[2][riveramt] = (BYTE)
random_(0, 2) + 17;
515 river[2][riveramt] = (BYTE)
random_(0, 2) + 15;
517 river[0][riveramt] = rx;
518 river[1][riveramt] = ry;
520 if (dir == 0 && pdir == 2 || dir == 3 && pdir == 1) {
522 river[2][riveramt - 2] = 22;
530 if (dir == 0 && pdir == 3 || dir == 2 && pdir == 1) {
532 river[2][riveramt - 2] = 21;
540 if (dir == 1 && pdir == 2 || dir == 3 && pdir == 0) {
542 river[2][riveramt - 2] = 20;
550 if (dir == 1 && pdir == 3 || dir == 2 && pdir == 0) {
552 river[2][riveramt - 2] = 19;
567 if (dir == 0 && ry >= 2 &&
dungeon[rx][ry - 1] == 10 &&
dungeon[rx][ry - 2] == 8) {
568 river[0][riveramt] = rx;
569 river[1][riveramt] = ry - 1;
570 river[2][riveramt] = 24;
572 river[2][riveramt - 1] = 22;
575 river[2][riveramt - 1] = 21;
581 river[0][riveramt] = rx;
582 river[1][riveramt] = ry + 1;
583 river[2][riveramt] = 42;
585 river[2][riveramt - 1] = 20;
588 river[2][riveramt - 1] = 19;
594 river[0][riveramt] = rx + 1;
595 river[1][riveramt] = ry;
596 river[2][riveramt] = 43;
598 river[2][riveramt - 1] = 19;
601 river[2][riveramt - 1] = 21;
606 if (dir == 3 && rx >= 2 &&
dungeon[rx - 1][ry] == 9 &&
dungeon[rx - 2][ry] == 8) {
607 river[0][riveramt] = rx - 1;
608 river[1][riveramt] = ry;
609 river[2][riveramt] = 23;
611 river[2][riveramt - 1] = 20;
614 river[2][riveramt - 1] = 22;
619 if (bail == TRUE && riveramt < 7) {
625 while (found == 0 && lpcnt < 30) {
628 if ((river[2][bridge] == 15 || river[2][bridge] == 16)
629 &&
dungeon[river[0][bridge]][river[1][bridge] - 1] == 7
630 &&
dungeon[river[0][bridge]][river[1][bridge] + 1] == 7) {
633 if ((river[2][bridge] == 17 || river[2][bridge] == 18)
634 &&
dungeon[river[0][bridge] - 1][river[1][bridge]] == 7
635 &&
dungeon[river[0][bridge] + 1][river[1][bridge]] == 7) {
638 for (i = 0; i < riveramt && found != 0; i++) {
640 && (river[1][bridge] - 1 == river[1][i] || river[1][bridge] + 1 == river[1][i])
641 && river[0][bridge] == river[0][i]) {
645 && (river[0][bridge] - 1 == river[0][i] || river[0][bridge] + 1 == river[0][i])
646 && river[1][bridge] == river[1][i]) {
653 river[2][bridge] = 44;
655 river[2][bridge] = 45;
658 for (bridge = 0; bridge <= riveramt; bridge++) {
659 dungeon[river[0][bridge]][river[1][bridge]] = river[2][bridge];
673 static BYTE spawntable[15] = { 0, 0x0A, 0x43, 0x05, 0x2C, 0x06, 0x09, 0, 0, 0x1C, 0x83, 0x06, 0x09, 0x0A, 0x05 };
678 if (x < 0 || y < 0 || x >=
DMAXX || y >=
DMAXY) {
704 if (spawntable[i] & 0x80 &&
DRLG_L3Spawn(x, y - 1, totarea) == TRUE) {
707 if (spawntable[i] & 0x40 &&
DRLG_L3Spawn(x, y + 1, totarea) == TRUE) {
710 if (spawntable[i] & 0x20 &&
DRLG_L3Spawn(x + 1, y, totarea) == TRUE) {
713 if (spawntable[i] & 0x10 &&
DRLG_L3Spawn(x - 1, y, totarea) == TRUE) {
723 static BYTE spawntable[15] = { 0, 0x0A, 0x03, 0x05, 0x0C, 0x06, 0x09, 0, 0, 0x012, 0x03, 0x06, 0x09, 0x0A, 0x05 };
728 if (x < 0 || y < 0 || x >=
DMAXX || y >=
DMAXY) {
780 int i, j, dunx, duny, totarea, poolchance;
783 static BYTE poolsub[15] = { 0, 35, 26, 36, 25, 29, 34, 7, 33, 28, 27, 37, 32, 31, 30 };
785 for (duny = 0; duny <
DMAXY; duny++) {
786 for (dunx = 0; dunx <
DMAXY; dunx++) {
787 if (
dungeon[dunx][duny] != 8) {
792 if (dunx + 1 <
DMAXX) {
797 if (dunx - 1 > 0 && !found) {
802 if (duny + 1 <
DMAXY && !found) {
807 if (duny - 1 > 0 && !found) {
813 for (j = std::max(duny - totarea, 0); j < std::min(duny + totarea,
DMAXY); j++) {
814 for (i = std::max(dunx - totarea, 0); i < std::min(dunx + totarea,
DMAXX); i++) {
819 if (totarea > 4 && poolchance < 25 && !found) {
821 if (k != 0 && k <= 37) {
837 for (duny = 1; duny <
DMAXY - 1; duny++) {
838 for (dunx = 1; dunx <
DMAXX - 1; dunx++) {
839 if (
dungeon[dunx][duny] == 8) {
840 if (
dungeon[dunx - 1][duny - 1] >= 25 &&
dungeon[dunx - 1][duny - 1] <= 41
842 &&
dungeon[dunx - 1][duny + 1] >= 25 &&
dungeon[dunx - 1][duny + 1] <= 41
845 &&
dungeon[dunx + 1][duny - 1] >= 25 &&
dungeon[dunx + 1][duny - 1] <= 41
847 &&
dungeon[dunx + 1][duny + 1] >= 25 &&
dungeon[dunx + 1][duny + 1] <= 41) {
855 static BOOL
DRLG_L3PlaceMiniSet(
const BYTE *miniset,
int tmin,
int tmax,
int cx,
int cy, BOOL setview,
int ldir)
857 int sx, sy, sw, sh, xx, yy, i, ii, numt, trys;
863 if (tmax - tmin == 0) {
866 numt =
random_(0, tmax - tmin) + tmin;
869 for (i = 0; i < numt; i++) {
874 while (!found && trys < 200) {
877 if (cx != -1 && sx >= cx - sw && sx <= cx + 12) {
882 if (cy != -1 && sy >= cy - sh && sy <= cy + 12) {
888 for (yy = 0; yy < sh && found == TRUE; yy++) {
889 for (xx = 0; xx < sw && found == TRUE; xx++) {
890 if (miniset[ii] != 0 &&
dungeon[xx + sx][yy + sy] != miniset[ii]) {
893 if (
dflags[xx + sx][yy + sy] != 0) {
901 if (sx ==
DMAXX - sw) {
904 if (sy ==
DMAXY - sh) {
914 for (yy = 0; yy < sh; yy++) {
915 for (xx = 0; xx < sw; xx++) {
916 if (miniset[ii] != 0) {
917 dungeon[xx + sx][yy + sy] = miniset[ii];
924 if (setview == TRUE) {
938 int sx, sy, sw, sh, xx, yy, ii, kk;
944 for (sy = 0; sy <
DMAXX - sh; sy++) {
945 for (sx = 0; sx <
DMAXY - sw; sx++) {
948 for (yy = 0; yy < sh && found == TRUE; yy++) {
949 for (xx = 0; xx < sw && found == TRUE; xx++) {
950 if (miniset[ii] != 0 &&
dungeon[xx + sx][yy + sy] != miniset[ii]) {
953 if (
dflags[xx + sx][yy + sy] != 0) {
960 if (miniset[kk] >= 84 && miniset[kk] <= 100 && found == TRUE) {
963 if (sx - 1 >= 0 &&
dungeon[sx - 1][sy] >= 84 &&
dungeon[sx - 1][sy] <= 100) {
966 if (sx + 1 < 40 && sx - 1 >= 0 &&
dungeon[sx + 1][sy] >= 84 &&
dungeon[sx - 1][sy] <= 100) {
969 if (sy + 1 < 40 && sx - 1 >= 0 &&
dungeon[sx][sy + 1] >= 84 &&
dungeon[sx - 1][sy] <= 100) {
972 if (sy - 1 >= 0 && sx - 1 >= 0 &&
dungeon[sx][sy - 1] >= 84 &&
dungeon[sx - 1][sy] <= 100) {
976 if (found == TRUE &&
random_(0, 100) < rndper) {
977 for (yy = 0; yy < sh; yy++) {
978 for (xx = 0; xx < sw; xx++) {
979 if (miniset[kk] != 0) {
980 dungeon[xx + sx][yy + sy] = miniset[kk];
1090 for (j = 0; j <
DMAXY; j++) {
1091 for (i = 0; i <
DMAXX; i++) {
1114 for (j = 0; j <
DMAXY; j++) {
1115 for (i = 0; i <
DMAXX; i++) {
1160 int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2;
1163 for (j = 1; j <
DMAXY - 1; j++) {
1164 for (i = 1; i <
DMAXX - 1; i++) {
1173 for (xx = i + 1; xx < x; xx++) {
1191 for (yy = j + 1; yy < y; yy++) {
1208 for (xx = i + 1; xx < x; xx++) {
1221 for (yy = j + 1; yy < y; yy++) {
1233 for (j = 1; j <
DMAXY; j++) {
1234 for (i = 1; i <
DMAXX; i++) {
1257 if (y2 - y1 > 1 && skip) {
1258 rp =
random_(0, y2 - y1 - 1) + y1 + 1;
1259 for (y = y1; y <= y2; y++) {
1311 if (x2 - x1 > 1 && skip) {
1312 rp =
random_(0, x2 - x1 - 1) + x1 + 1;
1313 for (x = x1; x <= x2; x++) {
1355 int sx, sy, sw, sh, xx, yy, ii, trys;
1365 while (!found && trys < 200) {
1369 for (yy = 0; yy < sh && found == TRUE; yy++) {
1370 for (xx = 0; xx < sw && found == TRUE; xx++) {
1374 if (
dflags[xx + sx][yy + sy] != 0) {
1382 if (sx ==
DMAXX - sw) {
1385 if (sy ==
DMAXY - sh) {
1396 for (yy = 0; yy < sh; yy++) {
1397 for (xx = 0; xx < sw; xx++) {
1418 for (j = 0; j <
DMAXY; j++) {
1419 for (i = 0; i <
DMAXX; i++) {
1438 for (j = 0; j <
DMAXY; j++) {
1439 for (i = 0; i <
DMAXX; i++) {
1445 for (j = 0; j <
DMAXY; j++) {
1446 for (i = 0; i <
DMAXX; i++) {
1477 int i, j, t, fx, fy;
1480 for (j = 0; j <
DMAXY; j++) {
1481 for (i = 0; i <
DMAXX; i++) {
1501 int x1, y1, x2, y2, i, j;
1546 }
else if (entry == 1) {
1568 }
while (genok == TRUE);
1623 for (j = 0; j <
DMAXY; j++) {
1624 for (i = 0; i <
DMAXX; i++) {
1635 long v1, v2, v3, v4, lv;
1641 v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
1642 v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
1643 v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
1644 v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
1646 for (j = 0; j <
MAXDUNY; j += 2)
1648 for (i = 0; i <
MAXDUNX; i += 2) {
1652 dPiece[i + 1][j + 1] = v4;
1657 for (j = 0; j <
DMAXY; j++) {
1659 for (i = 0; i <
DMAXX; i++) {
1663 v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
1664 v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
1665 v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
1666 v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
1676 dPiece[xx + 1][yy + 1] = v4;
1697 for (j = 0; j <
MAXDUNY; j++) {
1698 for (i = 0; i <
MAXDUNX; i++) {
1701 }
else if (
dPiece[i][j] >= 154 &&
dPiece[i][j] <= 161) {
1703 }
else if (
dPiece[i][j] == 150) {
1705 }
else if (
dPiece[i][j] == 152) {
1717 BYTE *pLevelMap, *lm;
1733 for (j = 0; j < rh; j++) {
1734 for (i = 0; i < rw; i++) {
1743 for (j = 0; j <
DMAXY; j++) {
1744 for (i = 0; i <
DMAXX; i++) {
1759 for (j = 0; j <
MAXDUNY; j++) {
1760 for (i = 0; i <
MAXDUNX; i++) {
1763 }
else if (
dPiece[i][j] >= 154 &&
dPiece[i][j] <= 161) {
1765 }
else if (
dPiece[i][j] == 150) {
1767 }
else if (
dPiece[i][j] == 152) {
1779 BYTE *pLevelMap, *lm;
1791 for (j = 0; j < rh; j++) {
1792 for (i = 0; i < rw; i++) {
1801 for (j = 0; j <
DMAXY; j++) {
1802 for (i = 0; i <
DMAXX; i++) {