Merge pull request #19 from GabrielRavier/improveBackCpp

Improve Back
This commit is contained in:
Clownacy 2019-05-07 14:26:56 +00:00 committed by GitHub
commit ef1164cd38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ BOOL InitBack(const char *fName, int type)
// Unused, hilariously
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
//Get width and height
// Get width and height
char path[PATH_LENGTH];
sprintf(path, "%s/%s.pbm", gDataPath, fName);
@ -72,7 +72,7 @@ BOOL InitBack(const char *fName, int type)
fclose(fp);
#endif
//Set background stuff and load texture
// Set background stuff and load texture
gBack.flag = 1;
if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND))
return FALSE;
@ -138,7 +138,7 @@ void PutBack(int fx, int fy)
case 6:
case 7:
//Sky
// Sky
static unsigned int fillNext;
fillNext = 0;
for (int y = 0; y < WINDOW_HEIGHT - 240 + 88; y += 88)
@ -156,7 +156,7 @@ void PutBack(int fx, int fy)
rect.right = 320;
PutBitmap4(&grcGame, (WINDOW_WIDTH - 320) / 2, WINDOW_HEIGHT - 240, &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 1
// Cloud layer 1
rect.top = 88;
rect.bottom = 123;
rect.left = gBack.fx / 2;
@ -167,7 +167,7 @@ void PutBack(int fx, int fy)
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx / 2 % 320, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 2
// Cloud layer 2
rect.top = 123;
rect.bottom = 146;
rect.left = gBack.fx % 320;
@ -178,7 +178,7 @@ void PutBack(int fx, int fy)
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx % 320, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 3
// Cloud layer 3
rect.top = 146;
rect.bottom = 176;
rect.left = 2 * gBack.fx % 320;
@ -189,7 +189,7 @@ void PutBack(int fx, int fy)
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - 2 * gBack.fx % 320, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 4
// Cloud layer 4
rect.top = 176;
rect.bottom = 240;
rect.left = 4 * gBack.fx % 320;
@ -248,49 +248,49 @@ void PutFront(int fx, int fy)
}
//Draw black bars
if (!(g_GameFlags & 8)) //Detect if credits are running
// Draw black bars
if (!(g_GameFlags & 8)) // Detect if credits are running
{
const bool fromFocus = (gStageNo == 31); //Get if we should only draw around a 320x240 area of the focus point
const bool fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point
//Get focus rect
// Get focus rect
int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8);
int focusY = gFrame.y + (WINDOW_HEIGHT << 8) - (240 << 8);
int focusR = focusX + (320 << 9);
int focusB = focusY + (240 << 9);
//Get borders
// Get borders
const int barLeft = fromFocus ? focusX : -0x1000;
const int barTop = fromFocus ? focusY : -0x1000;
const int barRight = fromFocus ? focusR : (gMap.width << 13) - 0x1000;
const int barBottom = fromFocus ? focusB : (gMap.length << 13) - 0x1000;
//Draw bars
// Draw bars
RECT barRect;
//Left
// Left
barRect.left = 0;
barRect.top = 0;
barRect.right = (barLeft - gFrame.x) >> 9;
barRect.bottom = WINDOW_HEIGHT;
CortBox(&barRect, 0x000000);
//Top
// Top
barRect.left = 0;
barRect.top = 0;
barRect.right = WINDOW_WIDTH;
barRect.bottom = (barTop - gFrame.y) >> 9;
CortBox(&barRect, 0x000000);
//Right
// Right
barRect.left = (barRight - gFrame.x) >> 9;
barRect.top = 0;
barRect.right = WINDOW_WIDTH;
barRect.bottom = WINDOW_HEIGHT;
CortBox(&barRect, 0x000000);
//Bottom
// Bottom
barRect.left = 0;
barRect.top = (barBottom - gFrame.y) >> 9;
barRect.right = WINDOW_WIDTH;