summaryrefslogtreecommitdiff
path: root/src/fieldmap.c
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-10-09 12:12:18 -0400
committerGriffinR <griffin.g.richards@gmail.com>2021-10-09 13:19:27 -0400
commit862febe03a354218d3c8bd14d9c7d1a49e8981b8 (patch)
tree583c9759092167966229324c1cf72868cdd5f0e7 /src/fieldmap.c
parent28de627913f04e059f995169299e41ce4c2544f0 (diff)
Add MAP_OFFSET
Diffstat (limited to 'src/fieldmap.c')
-rw-r--r--src/fieldmap.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/fieldmap.c b/src/fieldmap.c
index e437ea7fc..aff72c4c6 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -105,9 +105,9 @@ static void InitMapLayoutData(struct MapHeader *mapHeader)
mapLayout = mapHeader->mapLayout;
CpuFastFill16(METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
gBackupMapLayout.map = gBackupMapData;
- width = mapLayout->width + 15;
+ width = mapLayout->width + MAP_OFFSET_W;
gBackupMapLayout.width = width;
- height = mapLayout->height + 14;
+ height = mapLayout->height + MAP_OFFSET_H;
gBackupMapLayout.height = height;
if (width * height <= MAX_MAP_DATA_SIZE)
{
@@ -121,11 +121,11 @@ static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height)
u16 *dest;
int y;
dest = gBackupMapLayout.map;
- dest += gBackupMapLayout.width * 7 + 7;
+ dest += gBackupMapLayout.width * 7 + MAP_OFFSET;
for (y = 0; y < height; y++)
{
CpuCopy16(map, dest, width * 2);
- dest += width + 15;
+ dest += width + MAP_OFFSET_W;
map += width;
}
}
@@ -197,8 +197,8 @@ static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
if (connectedMapHeader)
{
cWidth = connectedMapHeader->mapLayout->width;
- x = offset + 7;
- y = mapHeader->mapLayout->height + 7;
+ x = offset + MAP_OFFSET;
+ y = mapHeader->mapLayout->height + MAP_OFFSET;
if (x < 0)
{
x2 = -x;
@@ -222,7 +222,7 @@ static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
x, y,
connectedMapHeader,
x2, /*y2*/ 0,
- width, /*height*/ 7);
+ width, /*height*/ MAP_OFFSET);
}
}
@@ -237,8 +237,8 @@ static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
{
cWidth = connectedMapHeader->mapLayout->width;
cHeight = connectedMapHeader->mapLayout->height;
- x = offset + 7;
- y2 = cHeight - 7;
+ x = offset + MAP_OFFSET;
+ y2 = cHeight - MAP_OFFSET;
if (x < 0)
{
x2 = -x;
@@ -262,7 +262,7 @@ static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
x, /*y*/ 0,
connectedMapHeader,
x2, y2,
- width, /*height*/ 7);
+ width, /*height*/ MAP_OFFSET);
}
}
@@ -277,8 +277,8 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
{
cWidth = connectedMapHeader->mapLayout->width;
cHeight = connectedMapHeader->mapLayout->height;
- y = offset + 7;
- x2 = cWidth - 7;
+ y = offset + MAP_OFFSET;
+ x2 = cWidth - MAP_OFFSET;
if (y < 0)
{
y2 = -y;
@@ -301,7 +301,7 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
/*x*/ 0, y,
connectedMapHeader,
x2, y2,
- /*width*/ 7, height);
+ /*width*/ MAP_OFFSET, height);
}
}
@@ -314,8 +314,8 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
if (connectedMapHeader)
{
cHeight = connectedMapHeader->mapLayout->height;
- x = mapHeader->mapLayout->width + 7;
- y = offset + 7;
+ x = mapHeader->mapLayout->width + MAP_OFFSET;
+ y = offset + MAP_OFFSET;
if (y < 0)
{
y2 = -y;
@@ -338,7 +338,7 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
x, y,
connectedMapHeader,
/*x2*/ 0, y2,
- /*width*/ 8, height);
+ /*width*/ MAP_OFFSET + 1, height);
}
}
@@ -433,9 +433,9 @@ void SaveMapView(void)
width = gBackupMapLayout.width;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
- for (i = y; i < y + 14; i++)
+ for (i = y; i < y + MAP_OFFSET_H; i++)
{
- for (j = x; j < x + 15; j++)
+ for (j = x; j < x + MAP_OFFSET_W; j++)
*mapView++ = gBackupMapData[width * i + j];
}
}
@@ -480,28 +480,28 @@ static void LoadSavedMapView(void)
width = gBackupMapLayout.width;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
- for (i = y; i < y + 14; i++)
+ for (i = y; i < y + MAP_OFFSET_H; i++)
{
if (i == y && i != 0)
yMode = 0;
- else if (i == y + 13 && i != gMapHeader.mapLayout->height - 1)
+ else if (i == y + MAP_OFFSET_H - 1 && i != gMapHeader.mapLayout->height - 1)
yMode = 1;
else
yMode = 0xFF;
- for (j = x; j < x + 15; j++)
+ for (j = x; j < x + MAP_OFFSET_W; j++)
{
if (!SkipCopyingMetatileFromSavedMap(&gBackupMapData[j + width * i], width, yMode))
gBackupMapData[j + width * i] = *mapView;
mapView++;
}
}
- for (j = x; j < x + 15; j++)
+ for (j = x; j < x + MAP_OFFSET_W; j++)
{
if (y != 0)
FixLongGrassMetatilesWindowTop(j, y - 1);
if (i < gMapHeader.mapLayout->height - 1)
- FixLongGrassMetatilesWindowBottom(j, y + 13);
+ FixLongGrassMetatilesWindowBottom(j, y + MAP_OFFSET_H - 1);
}
ClearSavedMapView();
}
@@ -524,25 +524,25 @@ static void MoveMapViewToBackup(u8 direction)
r8 = 0;
x0 = gSaveBlock1Ptr->pos.x;
y0 = gSaveBlock1Ptr->pos.y;
- x2 = 15;
- y2 = 14;
+ x2 = MAP_OFFSET_W;
+ y2 = MAP_OFFSET_H;
switch (direction)
{
case CONNECTION_NORTH:
y0 += 1;
- y2 = 13;
+ y2 = MAP_OFFSET_H - 1;
break;
case CONNECTION_SOUTH:
r8 = 1;
- y2 = 13;
+ y2 = MAP_OFFSET_H - 1;
break;
case CONNECTION_WEST:
x0 += 1;
- x2 = 14;
+ x2 = MAP_OFFSET_W - 1;
break;
case CONNECTION_EAST:
r9 = 1;
- x2 = 14;
+ x2 = MAP_OFFSET_W - 1;
break;
}
for (y = 0; y < y2; y++)
@@ -552,7 +552,7 @@ static void MoveMapViewToBackup(u8 direction)
for (x = 0; x < x2; x++)
{
desti = width * (y + y0);
- srci = (y + r8) * 15 + r9;
+ srci = (y + r8) * MAP_OFFSET_W + r9;
src = &mapView[srci + i];
dest = &gBackupMapData[x0 + desti + j];
*dest = *src;
@@ -568,28 +568,28 @@ int GetMapBorderIdAt(int x, int y)
if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED)
return CONNECTION_INVALID;
- if (x >= (gBackupMapLayout.width - 8))
+ if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1)))
{
if (!gMapConnectionFlags.east)
return CONNECTION_INVALID;
return CONNECTION_EAST;
}
- else if (x < 7)
+ else if (x < MAP_OFFSET)
{
if (!gMapConnectionFlags.west)
return CONNECTION_INVALID;
return CONNECTION_WEST;
}
- else if (y >= (gBackupMapLayout.height - 7))
+ else if (y >= (gBackupMapLayout.height - MAP_OFFSET))
{
if (!gMapConnectionFlags.south)
return CONNECTION_INVALID;
return CONNECTION_SOUTH;
}
- else if (y < 7)
+ else if (y < MAP_OFFSET)
{
if (!gMapConnectionFlags.north)
return CONNECTION_INVALID;
@@ -604,14 +604,14 @@ int GetMapBorderIdAt(int x, int y)
int GetPostCameraMoveMapBorderId(int x, int y)
{
- return GetMapBorderIdAt(gSaveBlock1Ptr->pos.x + 7 + x, gSaveBlock1Ptr->pos.y + 7 + y);
+ return GetMapBorderIdAt(gSaveBlock1Ptr->pos.x + MAP_OFFSET + x, gSaveBlock1Ptr->pos.y + MAP_OFFSET + y);
}
bool32 CanCameraMoveInDirection(int direction)
{
int x, y;
- x = gSaveBlock1Ptr->pos.x + 7 + gDirectionToVectors[direction].x;
- y = gSaveBlock1Ptr->pos.y + 7 + gDirectionToVectors[direction].y;
+ x = gSaveBlock1Ptr->pos.x + MAP_OFFSET + gDirectionToVectors[direction].x;
+ y = gSaveBlock1Ptr->pos.y + MAP_OFFSET + gDirectionToVectors[direction].y;
if (GetMapBorderIdAt(x, y) == CONNECTION_INVALID)
return FALSE;
@@ -771,14 +771,14 @@ struct MapConnection *GetConnectionAtCoords(s16 x, s16 y)
{
direction = connection->direction;
if ((direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE)
- || (direction == CONNECTION_NORTH && y > 6)
- || (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + 7)
- || (direction == CONNECTION_WEST && x > 6)
- || (direction == CONNECTION_EAST && x < gMapHeader.mapLayout->width + 7))
+ || (direction == CONNECTION_NORTH && y > MAP_OFFSET - 1)
+ || (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + MAP_OFFSET)
+ || (direction == CONNECTION_WEST && x > MAP_OFFSET - 1)
+ || (direction == CONNECTION_EAST && x < gMapHeader.mapLayout->width + MAP_OFFSET))
{
continue;
}
- if (IsPosInConnectingMap(connection, x - 7, y - 7) == TRUE)
+ if (IsPosInConnectingMap(connection, x - MAP_OFFSET, y - MAP_OFFSET) == TRUE)
{
return connection;
}
@@ -789,14 +789,14 @@ struct MapConnection *GetConnectionAtCoords(s16 x, s16 y)
void SetCameraFocusCoords(u16 x, u16 y)
{
- gSaveBlock1Ptr->pos.x = x - 7;
- gSaveBlock1Ptr->pos.y = y - 7;
+ gSaveBlock1Ptr->pos.x = x - MAP_OFFSET;
+ gSaveBlock1Ptr->pos.y = y - MAP_OFFSET;
}
void GetCameraFocusCoords(u16 *x, u16 *y)
{
- *x = gSaveBlock1Ptr->pos.x + 7;
- *y = gSaveBlock1Ptr->pos.y + 7;
+ *x = gSaveBlock1Ptr->pos.x + MAP_OFFSET;
+ *y = gSaveBlock1Ptr->pos.y + MAP_OFFSET;
}
// Unused