summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Custom-Border-Dimensions.md80
1 files changed, 2 insertions, 78 deletions
diff --git a/Custom-Border-Dimensions.md b/Custom-Border-Dimensions.md
index 3e68ae7..ff8484d 100644
--- a/Custom-Border-Dimensions.md
+++ b/Custom-Border-Dimensions.md
@@ -21,9 +21,9 @@ struct MapLayout
```
## 2. Use dimensions fields to read border data
-The following changes will all be in [src/fieldmap.c](https://github.com/pret/pokeemerald/blob/master/src/fieldmap.c).
+Next we need to use these new fields when we're trying to access border data.
-We'll be simplifying some existing functions with a few new macros. First, insert the following above `MapGridGetZCoordAt`.
+In [src/fieldmap.c](https://github.com/pret/pokeemerald/blob/master/src/fieldmap.c), find the definition of the macro `MapGridGetBorderTileAt` and replace it with the version below:
```c
#define MapGridGetBorderTileAt(x, y) ({ \
u16 block; \
@@ -42,82 +42,6 @@ We'll be simplifying some existing functions with a few new macros. First, inser
\
block = mapLayout->border[xprime + yprime * mapLayout->borderWidth] | METATILE_COLLISION_MASK; \
})
-
-#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
-
-#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : MapGridGetBorderTileAt(x, y))
-```
-
-Now we'll use these new macros. Replace the `MapGridGetZCoordAt`, `MapGridIsImpassableAt`, and `MapGridGetMetatileIdAt` functions with the versions below.
-```c
-u8 MapGridGetZCoordAt(int x, int y)
-{
- u16 block = MapGridGetTileAt(x, y);
-
- if (block == METATILE_ID_UNDEFINED)
- return 0;
-
- return block >> METATILE_ELEVATION_SHIFT;
-}
-
-u8 MapGridIsImpassableAt(int x, int y)
-{
- u16 block = MapGridGetTileAt(x, y);
-
- if (block == METATILE_ID_UNDEFINED)
- return 1;
-
- return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT;
-}
-
-u32 MapGridGetMetatileIdAt(int x, int y)
-{
- u16 block = MapGridGetTileAt(x, y);
-
- if (block == METATILE_ID_UNDEFINED)
- return MapGridGetBorderTileAt(x, y) & METATILE_ID_MASK;
-
- return block & METATILE_ID_MASK;
-}
-```
-Then in `GetMapBorderIdAt`, make the following change.
-```diff
- int GetMapBorderIdAt(int x, int y)
- {
-- struct MapLayout const *mapLayout;
-- u16 block, block2;
-- int i, j;
-- if (x >= 0 && x < gBackupMapLayout.width
-- && y >= 0 && y < gBackupMapLayout.height)
-- {
-- i = gBackupMapLayout.width;
-- i *= y;
-- block = gBackupMapLayout.map[x + i];
-- if (block == METATILE_ID_UNDEFINED)
-- {
-- goto fail;
-- }
-- }
-- else
-- {
-- mapLayout = gMapHeader.mapLayout;
-- j = (x + 1) & 1;
-- j += ((y + 1) & 1) * 2;
-- block2 = METATILE_COLLISION_MASK | mapLayout->border[j];
-- if (block2 == METATILE_ID_UNDEFINED)
-- {
-- goto fail;
-- }
-- }
-- goto success;
--fail:
-- return -1;
--success:
-+ if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED)
-+ return -1;
-
- if (x >= (gBackupMapLayout.width - 8))
- {
```
## 3. Add border dimension data