Clean-up Back.cpp

This commit is contained in:
Clownacy 2019-11-17 16:31:34 +00:00
parent 4e82665819
commit 5914ce01ef
2 changed files with 22 additions and 20 deletions

View file

@ -20,7 +20,7 @@ static unsigned long color_black;
// TODO - Another function that has an incorrect stack frame // TODO - Another function that has an incorrect stack frame
BOOL InitBack(const char *fName, int type) BOOL InitBack(const char *fName, int type)
{ {
// Unused, hilariously // Unused
color_black = GetCortBoxColor(RGB(0, 0, 0x10)); color_black = GetCortBoxColor(RGB(0, 0, 0x10));
// Get width and height // Get width and height
@ -55,20 +55,21 @@ BOOL InitBack(const char *fName, int type)
gBack.partsH = bmp_header_buffer2[2]; gBack.partsH = bmp_header_buffer2[2];
// Set background stuff and load texture // Set background stuff and load texture
gBack.flag = 1; gBack.flag = TRUE;
if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND)) if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND))
return FALSE; return FALSE;
gBack.type = type; gBack.type = type;
gWaterY = 0x1E0000; gWaterY = 240 * 0x10 * 0x200;
return TRUE; return TRUE;
} }
void ActBack() void ActBack(void)
{ {
switch (gBack.type) switch (gBack.type)
{ {
case 5: case 5:
gBack.fx += 0xC00; gBack.fx += 6 * 0x200;
break; break;
case 6: case 6:
@ -95,22 +96,22 @@ void PutBack(int fx, int fy)
break; break;
case 1: case 1:
for (y = -(fy / 2 / 0x200 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH) for (y = -((fy / 2 / 0x200) % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
for (x = -(fx / 2 / 0x200 % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW) for (x = -((fx / 2 / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break; break;
case 2: case 2:
for (y = -(fy / 0x200 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH) for (y = -((fy / 0x200) % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
for (x = -(fx / 0x200 % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW) for (x = -((fx / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break; break;
case 5: case 5:
for (y = -gBack.partsH; y < WINDOW_HEIGHT; y += gBack.partsH) for (y = -gBack.partsH; y < WINDOW_HEIGHT; y += gBack.partsH)
for (x = -(gBack.fx / 0x200 % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW) for (x = -((gBack.fx / 0x200) % gBack.partsW); x < WINDOW_WIDTH; x += gBack.partsW)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break; break;
@ -130,7 +131,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, 0, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
PutBitmap4(&grcGame, 320 - gBack.fx / 2 % 320, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 320 - ((gBack.fx / 2) % 320), 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.top = 123; rect.top = 123;
rect.bottom = 146; rect.bottom = 146;
@ -139,7 +140,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, 0, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
PutBitmap4(&grcGame, 320 - gBack.fx % 320, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 320 - (gBack.fx % 320), 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.top = 146; rect.top = 146;
rect.bottom = 176; rect.bottom = 176;
@ -148,7 +149,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, 0, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
PutBitmap4(&grcGame, 320 - 2 * gBack.fx % 320, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 320 - ((gBack.fx * 2) % 320), 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.top = 176; rect.top = 176;
rect.bottom = 240; rect.bottom = 240;
@ -157,7 +158,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, 0, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
PutBitmap4(&grcGame, 320 - 4 * gBack.fx % 320, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 320 - ((gBack.fx * 4) % 320), 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
break; break;
} }
@ -184,9 +185,9 @@ void PutFront(int fx, int fy)
y_1 = 0; y_1 = 0;
y_2 = y_1 + 32; y_2 = y_1 + 32;
for (y = y_1; y < y_2; y++) for (y = y_1; y < y_2; ++y)
{ {
ypos = (y * 32 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200; ypos = ((y * 32 * 0x200) / 0x200) - (fy / 0x200) + (gWaterY / 0x200);
if (ypos < -32) if (ypos < -32)
continue; continue;
@ -194,14 +195,15 @@ void PutFront(int fx, int fy)
if (ypos > WINDOW_HEIGHT) if (ypos > WINDOW_HEIGHT)
break; break;
for (x = x_1; x < x_2; x++) for (x = x_1; x < x_2; ++x)
{ {
xpos = (x * 32 * 0x200) / 0x200 - fx / 0x200; xpos = ((x * 32 * 0x200) / 0x200) - (fx / 0x200);
PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND); PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND);
if (y == 0) if (y == 0)
PutBitmap3(&grcGame, xpos, ypos, &rcWater[0], SURFACE_ID_LEVEL_BACKGROUND); PutBitmap3(&grcGame, xpos, ypos, &rcWater[0], SURFACE_ID_LEVEL_BACKGROUND);
} }
} }
break;
} }
} }

View file

@ -4,7 +4,7 @@
struct BACK struct BACK
{ {
int flag; BOOL flag; // Basically unused
int partsW; int partsW;
int partsH; int partsH;
int numX; int numX;
@ -17,6 +17,6 @@ extern BACK gBack;
extern int gWaterY; extern int gWaterY;
BOOL InitBack(const char *fName, int type); BOOL InitBack(const char *fName, int type);
void ActBack(); void ActBack(void);
void PutBack(int fx, int fy); void PutBack(int fx, int fy);
void PutFront(int fx, int fy); void PutFront(int fx, int fy);