Corrected formatting in Map.cpp

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
Gabriel Ravier 2019-05-08 09:28:44 +02:00
parent 71015da19b
commit 1d0129e681

View file

@ -29,16 +29,16 @@ BOOL LoadMapData2(const char *path_map)
{ {
unsigned char dum; unsigned char dum;
//Get path // Get path
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, path_map); sprintf(path, "%s/%s", gDataPath, path_map);
//Open file // Open file
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp == NULL) if (fp == NULL)
return FALSE; return FALSE;
//Make sure file begins with "PXM" // Make sure file begins with "PXM"
char check[3]; char check[3];
fread(check, 1, 3, fp); fread(check, 1, 3, fp);
@ -50,10 +50,9 @@ BOOL LoadMapData2(const char *path_map)
else else
{ {
fread(&dum, 1, 1, fp); fread(&dum, 1, 1, fp);
//Get width and height // Get width and height
#ifdef NONPORTABLE #ifdef NONPORTABLE
// This fails on big-endian hardware, and platforms // This fails on big-endian hardware, and platforms where short is not two bytes long.
// where short is not two bytes long.
fread(&gMap.width, 2, 1, fp); fread(&gMap.width, 2, 1, fp);
fread(&gMap.length, 2, 1, fp); fread(&gMap.length, 2, 1, fp);
#else #else
@ -68,7 +67,7 @@ BOOL LoadMapData2(const char *path_map)
} }
else else
{ {
//Read tiledata // Read tiledata
fread(gMap.data, 1, gMap.length * gMap.width, fp); fread(gMap.data, 1, gMap.length * gMap.width, fp);
fclose(fp); fclose(fp);
return TRUE; return TRUE;
@ -80,7 +79,7 @@ BOOL LoadMapData2(const char *path_map)
BOOL LoadAttributeData(const char *path_atrb) BOOL LoadAttributeData(const char *path_atrb)
{ {
//Open file // Open file
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, path_atrb); sprintf(path, "%s/%s", gDataPath, path_atrb);
@ -88,7 +87,7 @@ BOOL LoadAttributeData(const char *path_atrb)
if (fp == NULL) if (fp == NULL)
return FALSE; return FALSE;
//Read data // Read data
fread(gMap.atrb, 1, 0x100, fp); fread(gMap.atrb, 1, 0x100, fp);
fclose(fp); fclose(fp);
return TRUE; return TRUE;
@ -158,7 +157,7 @@ void PutStage_Back(int fx, int fy)
RECT rect; RECT rect;
int num_x; int num_x;
//Get range to draw // Get range to draw
num_x = ((WINDOW_WIDTH + 0xF) / 0x10) + 1; num_x = ((WINDOW_WIDTH + 0xF) / 0x10) + 1;
num_y = ((WINDOW_HEIGHT + 0xF) / 0x10) + 1; num_y = ((WINDOW_HEIGHT + 0xF) / 0x10) + 1;
put_x = (fx / 0x200 + 8) / 0x10; put_x = (fx / 0x200 + 8) / 0x10;
@ -168,14 +167,14 @@ void PutStage_Back(int fx, int fy)
{ {
for (i = put_x; i < put_x + num_x; i++) for (i = put_x; i < put_x + num_x; i++)
{ {
//Get attribute // Get attribute
offset = i + j * gMap.width; offset = i + j * gMap.width;
atrb = GetAttribute(i, j); atrb = GetAttribute(i, j);
if (atrb >= 0x20) if (atrb >= 0x20)
continue; continue;
//Draw tile // Draw tile
rect.left = 16 * (gMap.data[offset] % 0x10); rect.left = 16 * (gMap.data[offset] % 0x10);
rect.top = 16 * (gMap.data[offset] / 0x10); rect.top = 16 * (gMap.data[offset] / 0x10);
rect.right = rect.left + 16; rect.right = rect.left + 16;
@ -199,7 +198,7 @@ void PutStage_Front(int fx, int fy)
RECT rect; RECT rect;
int num_x; int num_x;
//Get range to draw // Get range to draw
num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1; num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1; num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
put_x = (fx / 0x200 + 8) / 16; put_x = (fx / 0x200 + 8) / 16;
@ -209,14 +208,14 @@ void PutStage_Front(int fx, int fy)
{ {
for (i = put_x; i < put_x + num_x; i++) for (i = put_x; i < put_x + num_x; i++)
{ {
//Get attribute // Get attribute
offset = i + j * gMap.width; offset = i + j * gMap.width;
atrb = GetAttribute(i, j); atrb = GetAttribute(i, j);
if (atrb < 0x40 || atrb >= 0x80) if (atrb < 0x40 || atrb >= 0x80)
continue; continue;
//Draw tile // Draw tile
rect.left = 16 * (gMap.data[offset] % 0x10); rect.left = 16 * (gMap.data[offset] % 0x10);
rect.top = 16 * (gMap.data[offset] / 0x10); rect.top = 16 * (gMap.data[offset] / 0x10);
rect.right = rect.left + 16; rect.right = rect.left + 16;
@ -242,11 +241,11 @@ void PutMapDataVector(int fx, int fy)
RECT rect; RECT rect;
int num_x; int num_x;
//Animate the wind // Animate the wind
static unsigned char count = 0; static unsigned char count = 0;
count += 2; count += 2;
//Get range to draw // Get range to draw
num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1; num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1; num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
put_x = (fx / 0x200 + 8) / 16; put_x = (fx / 0x200 + 8) / 16;
@ -256,7 +255,7 @@ void PutMapDataVector(int fx, int fy)
{ {
for (i = put_x; i < put_x + num_x; i++) for (i = put_x; i < put_x + num_x; i++)
{ {
//Get attribute // Get attribute
offset = i + j * gMap.width; offset = i + j * gMap.width;
atrb = GetAttribute(i, j); atrb = GetAttribute(i, j);