Browse Source

♻️Deduplicate DRLG_LPass3

pull/1652/head
Anders Jenbo 5 years ago
parent
commit
e9fe8e986d
  1. 55
      Source/drlg_l1.cpp
  2. 1
      Source/drlg_l1.h
  3. 40
      Source/drlg_l2.cpp
  4. 47
      Source/drlg_l3.cpp
  5. 47
      Source/drlg_l4.cpp

55
Source/drlg_l1.cpp

@ -1071,22 +1071,16 @@ static void DRLG_L1Floor()
}
}
static void DRLG_L1Pass3()
void DRLG_LPass3(int lv)
{
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
WORD *MegaTiles;
lv = 22 - 1;
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (j = 0; j < MAXDUNY; j += 2) {
for (i = 0; i < MAXDUNX; i += 2) {
WORD *MegaTiles = (WORD *)&pMegaTiles[lv * 8];
int v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
int v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
int v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
int v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (int j = 0; j < MAXDUNY; j += 2) {
for (int i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i + 1][j] = v2;
dPiece[i][j + 1] = v3;
@ -1094,17 +1088,23 @@ static void DRLG_L1Pass3()
}
}
yy = 16;
for (j = 0; j < DMAXY; j++) {
xx = 16;
for (i = 0; i < DMAXX; i++) {
int yy = 16;
for (int j = 0; j < DMAXY; j++) {
int xx = 16;
for (int i = 0; i < DMAXX; i++) {
lv = dungeon[i][j] - 1;
assert(lv >= 0);
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
if (lv >= 0) {
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
} else {
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
dPiece[xx][yy] = v1;
dPiece[xx + 1][yy] = v2;
dPiece[xx][yy + 1] = v3;
@ -1115,6 +1115,11 @@ static void DRLG_L1Pass3()
}
}
static void DRLG_L1Pass3()
{
DRLG_LPass3(22 - 1);
}
static void DRLG_LoadL1SP()
{
L5setloadflag = false;

1
Source/drlg_l1.h

@ -20,6 +20,7 @@ extern int UberLeverCol;
extern bool IsUberLeverActivated;
extern int UberDiabloMonsterIndex;
void DRLG_LPass3(int lv);
void DRLG_Init_Globals();
void LoadL1Dungeon(const char *sFileName, int vx, int vy);
void LoadPreL1Dungeon(const char *sFileName);

40
Source/drlg_l2.cpp

@ -2844,45 +2844,7 @@ static bool CreateDungeon()
static void DRLG_L2Pass3()
{
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
WORD *MegaTiles;
lv = 12 - 1;
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (j = 0; j < MAXDUNY; j += 2) {
for (i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i + 1][j] = v2;
dPiece[i][j + 1] = v3;
dPiece[i + 1][j + 1] = v4;
}
}
yy = 16;
for (j = 0; j < DMAXY; j++) {
xx = 16;
for (i = 0; i < DMAXX; i++) {
lv = dungeon[i][j] - 1;
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
dPiece[xx][yy] = v1;
dPiece[xx + 1][yy] = v2;
dPiece[xx][yy + 1] = v3;
dPiece[xx + 1][yy + 1] = v4;
xx += 2;
}
yy += 2;
}
DRLG_LPass3(12 - 1);
}
static void DRLG_L2FTVR(int i, int j, int x, int y, int d)

47
Source/drlg_l3.cpp

@ -2575,52 +2575,7 @@ static void DRLG_L3(lvl_entry entry)
static void DRLG_L3Pass3()
{
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
WORD *MegaTiles;
lv = 8 - 1;
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (j = 0; j < MAXDUNY; j += 2) {
for (i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i + 1][j] = v2;
dPiece[i][j + 1] = v3;
dPiece[i + 1][j + 1] = v4;
}
}
yy = 16;
for (j = 0; j < DMAXY; j++) {
xx = 16;
for (i = 0; i < DMAXX; i++) {
lv = dungeon[i][j] - 1;
if (lv >= 0) {
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
} else {
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
dPiece[xx][yy] = v1;
dPiece[xx + 1][yy] = v2;
dPiece[xx][yy + 1] = v3;
dPiece[xx + 1][yy + 1] = v4;
xx += 2;
}
yy += 2;
}
DRLG_LPass3(8 - 1);
}
void CreateL3Dungeon(DWORD rseed, lvl_entry entry)

47
Source/drlg_l4.cpp

@ -1749,52 +1749,7 @@ static void DRLG_L4(lvl_entry entry)
static void DRLG_L4Pass3()
{
int i, j, xx, yy;
long v1, v2, v3, v4, lv;
WORD *MegaTiles;
lv = 30 - 1;
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (j = 0; j < MAXDUNY; j += 2) {
for (i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i + 1][j] = v2;
dPiece[i][j + 1] = v3;
dPiece[i + 1][j + 1] = v4;
}
}
yy = 16;
for (j = 0; j < DMAXY; j++) {
xx = 16;
for (i = 0; i < DMAXX; i++) {
lv = dungeon[i][j] - 1;
if (lv >= 0) {
MegaTiles = (WORD *)&pMegaTiles[lv * 8];
v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
} else {
v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
}
dPiece[xx][yy] = v1;
dPiece[xx + 1][yy] = v2;
dPiece[xx][yy + 1] = v3;
dPiece[xx + 1][yy + 1] = v4;
xx += 2;
}
yy += 2;
}
DRLG_LPass3(30 - 1);
}
void CreateL4Dungeon(DWORD rseed, lvl_entry entry)

Loading…
Cancel
Save