mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Name overworld tilemaps for their bg, add layer type constants
This commit is contained in:
parent
69759b2d12
commit
f127e64a3c
@ -1,6 +1,6 @@
|
|||||||
gBGTilemapBuffers1
|
gOverworldTilemapBuffer_Bg2
|
||||||
gBGTilemapBuffers2
|
gOverworldTilemapBuffer_Bg1
|
||||||
gBGTilemapBuffers3
|
gOverworldTilemapBuffer_Bg3
|
||||||
gHeldKeyCodeToSend
|
gHeldKeyCodeToSend
|
||||||
gFieldCallback
|
gFieldCallback
|
||||||
gFieldCallback2
|
gFieldCallback2
|
||||||
|
@ -9,6 +9,12 @@
|
|||||||
#define METATILE_COLLISION_SHIFT 10
|
#define METATILE_COLLISION_SHIFT 10
|
||||||
#define METATILE_ELEVATION_MASK 0xF000
|
#define METATILE_ELEVATION_MASK 0xF000
|
||||||
|
|
||||||
|
enum {
|
||||||
|
METATILE_LAYER_TYPE_NORMAL, // Metatile uses middle and top bg layers
|
||||||
|
METATILE_LAYER_TYPE_COVERED, // Metatile uses bottom and middle bg layers
|
||||||
|
METATILE_LAYER_TYPE_SPLIT, // Metatile uses bottom and top bg layers
|
||||||
|
};
|
||||||
|
|
||||||
#define METATILE_ID(tileset, name) (METATILE_##tileset##_##name)
|
#define METATILE_ID(tileset, name) (METATILE_##tileset##_##name)
|
||||||
|
|
||||||
// Rows of metatiles do not actually have a strict width.
|
// Rows of metatiles do not actually have a strict width.
|
||||||
|
@ -40,20 +40,18 @@ struct LinkPlayerObjectEvent
|
|||||||
u8 movementMode;
|
u8 movementMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Exported RAM declarations
|
|
||||||
extern struct WarpData gLastUsedWarp;
|
extern struct WarpData gLastUsedWarp;
|
||||||
extern struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4];
|
extern struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4];
|
||||||
|
|
||||||
extern u16 *gBGTilemapBuffers1;
|
extern u16 *gOverworldTilemapBuffer_Bg2;
|
||||||
extern u16 *gBGTilemapBuffers2;
|
extern u16 *gOverworldTilemapBuffer_Bg1;
|
||||||
extern u16 *gBGTilemapBuffers3;
|
extern u16 *gOverworldTilemapBuffer_Bg3;
|
||||||
extern u16 gHeldKeyCodeToSend;
|
extern u16 gHeldKeyCodeToSend;
|
||||||
extern void (*gFieldCallback)(void);
|
extern void (*gFieldCallback)(void);
|
||||||
extern bool8 (*gFieldCallback2)(void);
|
extern bool8 (*gFieldCallback2)(void);
|
||||||
extern u8 gLocalLinkPlayerId;
|
extern u8 gLocalLinkPlayerId;
|
||||||
extern u8 gFieldLinkPlayerCount;
|
extern u8 gFieldLinkPlayerCount;
|
||||||
|
|
||||||
// Exported ROM declarations
|
|
||||||
extern const struct UCoords32 gDirectionToVectors[];
|
extern const struct UCoords32 gDirectionToVectors[];
|
||||||
|
|
||||||
void DoWhiteOut(void);
|
void DoWhiteOut(void);
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE;
|
EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE;
|
||||||
|
|
||||||
// Static type declarations
|
|
||||||
struct FieldCameraOffset
|
struct FieldCameraOffset
|
||||||
{
|
{
|
||||||
u8 xPixelOffset;
|
u8 xPixelOffset;
|
||||||
@ -24,18 +23,16 @@ struct FieldCameraOffset
|
|||||||
bool8 copyBGToVRAM;
|
bool8 copyBGToVRAM;
|
||||||
};
|
};
|
||||||
|
|
||||||
// static functions
|
static void RedrawMapSliceNorth(struct FieldCameraOffset *, const struct MapLayout *);
|
||||||
static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
static void RedrawMapSliceSouth(struct FieldCameraOffset *, const struct MapLayout *);
|
||||||
static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
static void RedrawMapSliceEast(struct FieldCameraOffset *, const struct MapLayout *);
|
||||||
static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
static void RedrawMapSliceWest(struct FieldCameraOffset *, const struct MapLayout *);
|
||||||
static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
|
static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *, s32, s32);
|
||||||
static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *a, s32 x, s32 y);
|
static void DrawWholeMapViewInternal(int, int, const struct MapLayout *);
|
||||||
static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout);
|
static void DrawMetatileAt(const struct MapLayout *, u16, int, int);
|
||||||
static void DrawMetatileAt(const struct MapLayout *mapLayout, u16, int, int);
|
static void DrawMetatile(s32, u16 *, u16);
|
||||||
static void DrawMetatile(s32 a, u16 *b, u16 c);
|
|
||||||
static void CameraPanningCB_PanAhead(void);
|
static void CameraPanningCB_PanAhead(void);
|
||||||
|
|
||||||
// IWRAM bss vars
|
|
||||||
static struct FieldCameraOffset sFieldCameraOffset;
|
static struct FieldCameraOffset sFieldCameraOffset;
|
||||||
static s16 sHorizontalCameraPan;
|
static s16 sHorizontalCameraPan;
|
||||||
static s16 sVerticalCameraPan;
|
static s16 sVerticalCameraPan;
|
||||||
@ -46,7 +43,6 @@ struct CameraObject gFieldCamera;
|
|||||||
u16 gTotalCameraPixelOffsetY;
|
u16 gTotalCameraPixelOffsetY;
|
||||||
u16 gTotalCameraPixelOffsetX;
|
u16 gTotalCameraPixelOffsetX;
|
||||||
|
|
||||||
// text
|
|
||||||
static void ResetCameraOffset(struct FieldCameraOffset *cameraOffset)
|
static void ResetCameraOffset(struct FieldCameraOffset *cameraOffset)
|
||||||
{
|
{
|
||||||
cameraOffset->xTileOffset = 0;
|
cameraOffset->xTileOffset = 0;
|
||||||
@ -222,7 +218,7 @@ void DrawDoorMetatileAt(int x, int y, u16 *arr)
|
|||||||
|
|
||||||
if (offset >= 0)
|
if (offset >= 0)
|
||||||
{
|
{
|
||||||
DrawMetatile(1, arr, offset);
|
DrawMetatile(METATILE_LAYER_TYPE_COVERED, arr, offset);
|
||||||
sFieldCameraOffset.copyBGToVRAM = TRUE;
|
sFieldCameraOffset.copyBGToVRAM = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,66 +240,66 @@ static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 offset, int x,
|
|||||||
DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset);
|
DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawMetatile(s32 metatileLayerType, u16 *metatiles, u16 offset)
|
static void DrawMetatile(s32 metatileLayerType, u16 *tiles, u16 offset)
|
||||||
{
|
{
|
||||||
switch (metatileLayerType)
|
switch (metatileLayerType)
|
||||||
{
|
{
|
||||||
case 2: // LAYER_TYPE_
|
case METATILE_LAYER_TYPE_SPLIT:
|
||||||
// Draw metatile's bottom layer to the bottom background layer.
|
// Draw metatile's bottom layer to the bottom background layer.
|
||||||
gBGTilemapBuffers3[offset] = metatiles[0];
|
gOverworldTilemapBuffer_Bg3[offset] = tiles[0];
|
||||||
gBGTilemapBuffers3[offset + 1] = metatiles[1];
|
gOverworldTilemapBuffer_Bg3[offset + 1] = tiles[1];
|
||||||
gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
|
gOverworldTilemapBuffer_Bg3[offset + 0x20] = tiles[2];
|
||||||
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
|
gOverworldTilemapBuffer_Bg3[offset + 0x21] = tiles[3];
|
||||||
|
|
||||||
// Draw transparent tiles to the middle background layer.
|
// Draw transparent tiles to the middle background layer.
|
||||||
gBGTilemapBuffers1[offset] = 0;
|
gOverworldTilemapBuffer_Bg2[offset] = 0;
|
||||||
gBGTilemapBuffers1[offset + 1] = 0;
|
gOverworldTilemapBuffer_Bg2[offset + 1] = 0;
|
||||||
gBGTilemapBuffers1[offset + 0x20] = 0;
|
gOverworldTilemapBuffer_Bg2[offset + 0x20] = 0;
|
||||||
gBGTilemapBuffers1[offset + 0x21] = 0;
|
gOverworldTilemapBuffer_Bg2[offset + 0x21] = 0;
|
||||||
|
|
||||||
// Draw metatile's top layer to the top background layer.
|
// Draw metatile's top layer to the top background layer.
|
||||||
gBGTilemapBuffers2[offset] = metatiles[4];
|
gOverworldTilemapBuffer_Bg1[offset] = tiles[4];
|
||||||
gBGTilemapBuffers2[offset + 1] = metatiles[5];
|
gOverworldTilemapBuffer_Bg1[offset + 1] = tiles[5];
|
||||||
gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
|
gOverworldTilemapBuffer_Bg1[offset + 0x20] = tiles[6];
|
||||||
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
|
gOverworldTilemapBuffer_Bg1[offset + 0x21] = tiles[7];
|
||||||
break;
|
break;
|
||||||
case 1: // LAYER_TYPE_COVERED_BY_OBJECTS
|
case METATILE_LAYER_TYPE_COVERED:
|
||||||
// Draw metatile's bottom layer to the bottom background layer.
|
// Draw metatile's bottom layer to the bottom background layer.
|
||||||
gBGTilemapBuffers3[offset] = metatiles[0];
|
gOverworldTilemapBuffer_Bg3[offset] = tiles[0];
|
||||||
gBGTilemapBuffers3[offset + 1] = metatiles[1];
|
gOverworldTilemapBuffer_Bg3[offset + 1] = tiles[1];
|
||||||
gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
|
gOverworldTilemapBuffer_Bg3[offset + 0x20] = tiles[2];
|
||||||
gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
|
gOverworldTilemapBuffer_Bg3[offset + 0x21] = tiles[3];
|
||||||
|
|
||||||
// Draw metatile's top layer to the middle background layer.
|
// Draw metatile's top layer to the middle background layer.
|
||||||
gBGTilemapBuffers1[offset] = metatiles[4];
|
gOverworldTilemapBuffer_Bg2[offset] = tiles[4];
|
||||||
gBGTilemapBuffers1[offset + 1] = metatiles[5];
|
gOverworldTilemapBuffer_Bg2[offset + 1] = tiles[5];
|
||||||
gBGTilemapBuffers1[offset + 0x20] = metatiles[6];
|
gOverworldTilemapBuffer_Bg2[offset + 0x20] = tiles[6];
|
||||||
gBGTilemapBuffers1[offset + 0x21] = metatiles[7];
|
gOverworldTilemapBuffer_Bg2[offset + 0x21] = tiles[7];
|
||||||
|
|
||||||
// Draw transparent tiles to the top background layer.
|
// Draw transparent tiles to the top background layer.
|
||||||
gBGTilemapBuffers2[offset] = 0;
|
gOverworldTilemapBuffer_Bg1[offset] = 0;
|
||||||
gBGTilemapBuffers2[offset + 1] = 0;
|
gOverworldTilemapBuffer_Bg1[offset + 1] = 0;
|
||||||
gBGTilemapBuffers2[offset + 0x20] = 0;
|
gOverworldTilemapBuffer_Bg1[offset + 0x20] = 0;
|
||||||
gBGTilemapBuffers2[offset + 0x21] = 0;
|
gOverworldTilemapBuffer_Bg1[offset + 0x21] = 0;
|
||||||
break;
|
break;
|
||||||
case 0: // LAYER_TYPE_NORMAL
|
case METATILE_LAYER_TYPE_NORMAL:
|
||||||
// Draw garbage to the bottom background layer.
|
// Draw garbage to the bottom background layer.
|
||||||
gBGTilemapBuffers3[offset] = 0x3014;
|
gOverworldTilemapBuffer_Bg3[offset] = 0x3014;
|
||||||
gBGTilemapBuffers3[offset + 1] = 0x3014;
|
gOverworldTilemapBuffer_Bg3[offset + 1] = 0x3014;
|
||||||
gBGTilemapBuffers3[offset + 0x20] = 0x3014;
|
gOverworldTilemapBuffer_Bg3[offset + 0x20] = 0x3014;
|
||||||
gBGTilemapBuffers3[offset + 0x21] = 0x3014;
|
gOverworldTilemapBuffer_Bg3[offset + 0x21] = 0x3014;
|
||||||
|
|
||||||
// Draw metatile's bottom layer to the middle background layer.
|
// Draw metatile's bottom layer to the middle background layer.
|
||||||
gBGTilemapBuffers1[offset] = metatiles[0];
|
gOverworldTilemapBuffer_Bg2[offset] = tiles[0];
|
||||||
gBGTilemapBuffers1[offset + 1] = metatiles[1];
|
gOverworldTilemapBuffer_Bg2[offset + 1] = tiles[1];
|
||||||
gBGTilemapBuffers1[offset + 0x20] = metatiles[2];
|
gOverworldTilemapBuffer_Bg2[offset + 0x20] = tiles[2];
|
||||||
gBGTilemapBuffers1[offset + 0x21] = metatiles[3];
|
gOverworldTilemapBuffer_Bg2[offset + 0x21] = tiles[3];
|
||||||
|
|
||||||
// Draw metatile's top layer to the top background layer, which covers object event sprites.
|
// Draw metatile's top layer to the top background layer, which covers object event sprites.
|
||||||
gBGTilemapBuffers2[offset] = metatiles[4];
|
gOverworldTilemapBuffer_Bg1[offset] = tiles[4];
|
||||||
gBGTilemapBuffers2[offset + 1] = metatiles[5];
|
gOverworldTilemapBuffer_Bg1[offset + 1] = tiles[5];
|
||||||
gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
|
gOverworldTilemapBuffer_Bg1[offset + 0x20] = tiles[6];
|
||||||
gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
|
gOverworldTilemapBuffer_Bg1[offset + 0x21] = tiles[7];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ScheduleBgCopyTilemapToVram(1);
|
ScheduleBgCopyTilemapToVram(1);
|
||||||
|
@ -183,9 +183,9 @@ static u16 (*sPlayerKeyInterceptCallback)(u32);
|
|||||||
static bool8 sReceivingFromLink;
|
static bool8 sReceivingFromLink;
|
||||||
static u8 sRfuKeepAliveTimer;
|
static u8 sRfuKeepAliveTimer;
|
||||||
|
|
||||||
u16 *gBGTilemapBuffers1;
|
u16 *gOverworldTilemapBuffer_Bg2;
|
||||||
u16 *gBGTilemapBuffers2;
|
u16 *gOverworldTilemapBuffer_Bg1;
|
||||||
u16 *gBGTilemapBuffers3;
|
u16 *gOverworldTilemapBuffer_Bg3;
|
||||||
u16 gHeldKeyCodeToSend;
|
u16 gHeldKeyCodeToSend;
|
||||||
void (*gFieldCallback)(void);
|
void (*gFieldCallback)(void);
|
||||||
bool8 (*gFieldCallback2)(void);
|
bool8 (*gFieldCallback2)(void);
|
||||||
@ -1394,12 +1394,12 @@ static void InitOverworldBgs(void)
|
|||||||
SetBgAttribute(1, BG_ATTR_MOSAIC, 1);
|
SetBgAttribute(1, BG_ATTR_MOSAIC, 1);
|
||||||
SetBgAttribute(2, BG_ATTR_MOSAIC, 1);
|
SetBgAttribute(2, BG_ATTR_MOSAIC, 1);
|
||||||
SetBgAttribute(3, BG_ATTR_MOSAIC, 1);
|
SetBgAttribute(3, BG_ATTR_MOSAIC, 1);
|
||||||
gBGTilemapBuffers2 = AllocZeroed(BG_SCREEN_SIZE);
|
gOverworldTilemapBuffer_Bg1 = AllocZeroed(BG_SCREEN_SIZE);
|
||||||
gBGTilemapBuffers1 = AllocZeroed(BG_SCREEN_SIZE);
|
gOverworldTilemapBuffer_Bg2 = AllocZeroed(BG_SCREEN_SIZE);
|
||||||
gBGTilemapBuffers3 = AllocZeroed(BG_SCREEN_SIZE);
|
gOverworldTilemapBuffer_Bg3 = AllocZeroed(BG_SCREEN_SIZE);
|
||||||
SetBgTilemapBuffer(1, gBGTilemapBuffers2);
|
SetBgTilemapBuffer(1, gOverworldTilemapBuffer_Bg1);
|
||||||
SetBgTilemapBuffer(2, gBGTilemapBuffers1);
|
SetBgTilemapBuffer(2, gOverworldTilemapBuffer_Bg2);
|
||||||
SetBgTilemapBuffer(3, gBGTilemapBuffers3);
|
SetBgTilemapBuffer(3, gOverworldTilemapBuffer_Bg3);
|
||||||
InitStandardTextBoxWindows();
|
InitStandardTextBoxWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1407,12 +1407,9 @@ void CleanupOverworldWindowsAndTilemaps(void)
|
|||||||
{
|
{
|
||||||
ClearMirageTowerPulseBlendEffect();
|
ClearMirageTowerPulseBlendEffect();
|
||||||
FreeAllOverworldWindowBuffers();
|
FreeAllOverworldWindowBuffers();
|
||||||
if (gBGTilemapBuffers3)
|
TRY_FREE_AND_SET_NULL(gOverworldTilemapBuffer_Bg3);
|
||||||
FREE_AND_SET_NULL(gBGTilemapBuffers3);
|
TRY_FREE_AND_SET_NULL(gOverworldTilemapBuffer_Bg2);
|
||||||
if (gBGTilemapBuffers1)
|
TRY_FREE_AND_SET_NULL(gOverworldTilemapBuffer_Bg1);
|
||||||
FREE_AND_SET_NULL(gBGTilemapBuffers1);
|
|
||||||
if (gBGTilemapBuffers2)
|
|
||||||
FREE_AND_SET_NULL(gBGTilemapBuffers2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResetSafariZoneFlag_(void)
|
static void ResetSafariZoneFlag_(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user