Merge remote-tracking branch 'pret/master' into 'rhh/master'

This commit is contained in:
Martin Griffin 2023-07-25 19:40:34 +01:00
commit 0e5c78aeb6
37 changed files with 213 additions and 64 deletions

View File

@ -125,19 +125,53 @@ Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or conti
Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert.
1. Open msys2 at C:\devkitPro\msys2\mingw64.exe or run `C:\devkitPro\msys2\msys2_shell.bat -mingw64`. 1. Open msys2 at C:\devkitPro\msys2\msys2_shell.bat.
2. Certain packages are required to build pokeemerald. Install these by running the following command: 2. Certain packages are required to build pokeemerald. Install these by running the following two commands:
```bash ```bash
pacman -S make zlib-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-libpng pacman -Sy msys2-keyring
pacman -S make gcc zlib-devel git
``` ```
<details> <details>
<summary><i>Note...</i></summary> <summary><i>Note...</i></summary>
> This command will ask for confirmation, just enter the yes action when prompted. > The commands will ask for confirmation, just enter the yes action when prompted.
</details> </details>
3. Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download).
4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\&#8288;_\<user>_**, where *\<user>* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\<user>_\Downloads** (the Downloads location for most users), enter this command:
```bash
cd Downloads
```
<details>
<summary><i>Notes...</i></summary>
> Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator.
> Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`.
> Note 3: Windows path names are case-insensitive so adhering to capitalization isnt needed.
> Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there.
</details>
5. Run the following commands to uncompress and install libpng.
```bash
tar xf libpng-1.6.37.tar.xz
cd libpng-1.6.37
./configure --prefix=/usr
make check
make install
```
6. Then finally, run the following command to change back to the user profile folder.
```bash
cd
```
### Choosing where to store pokeemerald (msys2) ### Choosing where to store pokeemerald (msys2)
At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder. At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder.

View File

@ -3,7 +3,7 @@
#include "sprite.h" #include "sprite.h"
extern u8 gDecompressionBuffer[0x4000]; extern u8 ALIGNED(4) gDecompressionBuffer[0x4000];
void LZDecompressWram(const u32 *src, void *dest); void LZDecompressWram(const u32 *src, void *dest);
void LZDecompressVram(const u32 *src, void *dest); void LZDecompressVram(const u32 *src, void *dest);

View File

@ -213,7 +213,7 @@ struct SoundInfo
ExtVolPitFunc ExtVolPit; ExtVolPitFunc ExtVolPit;
u8 gap2[16]; u8 gap2[16];
struct SoundChannel chans[MAX_DIRECTSOUND_CHANNELS]; struct SoundChannel chans[MAX_DIRECTSOUND_CHANNELS];
s8 pcmBuffer[PCM_DMA_BUF_SIZE * 2]; s8 ALIGNED(4) pcmBuffer[PCM_DMA_BUF_SIZE * 2];
}; };
struct SongHeader struct SongHeader

View File

@ -1,7 +1,7 @@
#ifndef GUARD_GBA_MACRO_H #ifndef GUARD_GBA_MACRO_H
#define GUARD_GBA_MACRO_H #define GUARD_GBA_MACRO_H
#define CPU_FILL(value, dest, size, bit) \ #define CPU_FILL_UNCHECKED(value, dest, size, bit) \
{ \ { \
vu##bit tmp = (vu##bit)(value); \ vu##bit tmp = (vu##bit)(value); \
CpuSet((void *)&tmp, \ CpuSet((void *)&tmp, \
@ -9,10 +9,33 @@
CPU_SET_##bit##BIT | CPU_SET_SRC_FIXED | ((size)/(bit/8) & 0x1FFFFF)); \ CPU_SET_##bit##BIT | CPU_SET_SRC_FIXED | ((size)/(bit/8) & 0x1FFFFF)); \
} }
#if MODERN
#define CPU_FILL(value, dest, size, bit) \
do \
{ \
_Static_assert(_Alignof(dest) >= (bit / 8), "destination potentially unaligned"); \
CPU_FILL_UNCHECKED(value, dest, size, bit); \
} while (0)
#else
#define CPU_FILL(value, dest, size, bit) CPU_FILL_UNCHECKED(value, dest, size, bit)
#endif
#define CpuFill16(value, dest, size) CPU_FILL(value, dest, size, 16) #define CpuFill16(value, dest, size) CPU_FILL(value, dest, size, 16)
#define CpuFill32(value, dest, size) CPU_FILL(value, dest, size, 32) #define CpuFill32(value, dest, size) CPU_FILL(value, dest, size, 32)
#define CPU_COPY(src, dest, size, bit) CpuSet(src, dest, CPU_SET_##bit##BIT | ((size)/(bit/8) & 0x1FFFFF)) #define CPU_COPY_UNCHECKED(src, dest, size, bit) CpuSet(src, dest, CPU_SET_##bit##BIT | ((size)/(bit/8) & 0x1FFFFF))
#if MODERN
#define CPU_COPY(src, dest, size, bit) \
do \
{ \
_Static_assert(_Alignof(src) >= (bit / 8), "source potentially unaligned"); \
_Static_assert(_Alignof(dest) >= (bit / 8), "destination potentially unaligned"); \
CPU_COPY_UNCHECKED(src, dest, size, bit); \
} while (0)
#else
#define CPU_COPY(src, dest, size, bit) CPU_COPY_UNCHECKED(src, dest, size, bit)
#endif
#define CpuCopy16(src, dest, size) CPU_COPY(src, dest, size, 16) #define CpuCopy16(src, dest, size) CPU_COPY(src, dest, size, 16)
#define CpuCopy32(src, dest, size) CPU_COPY(src, dest, size, 32) #define CpuCopy32(src, dest, size) CPU_COPY(src, dest, size, 32)
@ -31,7 +54,7 @@
#define CpuFastCopy(src, dest, size) CpuFastSet(src, dest, ((size)/(32/8) & 0x1FFFFF)) #define CpuFastCopy(src, dest, size) CpuFastSet(src, dest, ((size)/(32/8) & 0x1FFFFF))
#define DmaSet(dmaNum, src, dest, control) \ #define DmaSetUnchecked(dmaNum, src, dest, control) \
{ \ { \
vu32 *dmaRegs = (vu32 *)REG_ADDR_DMA##dmaNum; \ vu32 *dmaRegs = (vu32 *)REG_ADDR_DMA##dmaNum; \
dmaRegs[0] = (vu32)(src); \ dmaRegs[0] = (vu32)(src); \
@ -40,7 +63,21 @@
dmaRegs[2]; \ dmaRegs[2]; \
} }
#define DMA_FILL(dmaNum, value, dest, size, bit) \ #if MODERN
// NOTE: Assumes 16-bit DMAs.
#define DmaSet(dmaNum, src, dest, control) \
do \
{ \
_Static_assert(_Alignof(src) >= __builtin_choose_expr(__builtin_constant_p(control), ((control) & (DMA_32BIT << 16)) ? 4 : 2, 2), "source potentially unaligned"); \
_Static_assert(_Alignof(dest) >= __builtin_choose_expr(__builtin_constant_p(control), ((control) & (DMA_32BIT << 16)) ? 4 : 2, 2), "destination potentially unaligned"); \
DmaSetUnchecked(dmaNum, src, dest, control); \
} while (0)
#else
#define DmaSet(dmaNum, src, dest, control) \
DmaSetUnchecked(dmaNum, src, dest, control)
#endif
#define DMA_FILL_UNCHECKED(dmaNum, value, dest, size, bit) \
{ \ { \
vu##bit tmp = (vu##bit)(value); \ vu##bit tmp = (vu##bit)(value); \
DmaSet(dmaNum, \ DmaSet(dmaNum, \
@ -50,6 +87,17 @@
| ((size)/(bit/8))); \ | ((size)/(bit/8))); \
} }
#if MODERN
#define DMA_FILL(dmaNum, value, dest, size, bit) \
do \
{ \
_Static_assert(_Alignof(dest) >= (bit / 8), "destination potentially unaligned"); \
DMA_FILL_UNCHECKED(dmaNum, value, dest, size, bit); \
} while (0)
#else
#define DMA_FILL(dmaNum, value, dest, size, bit) DMA_FILL_UNCHECKED(dmaNum, value, dest, size, bit)
#endif
#define DmaFill16(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 16) #define DmaFill16(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 16)
#define DmaFill32(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 32) #define DmaFill32(dmaNum, value, dest, size) DMA_FILL(dmaNum, value, dest, size, 32)
@ -58,23 +106,46 @@
// unit size (2 or 4 bytes) and then combined with the DMA control flags using a // unit size (2 or 4 bytes) and then combined with the DMA control flags using a
// bitwise OR operation. // bitwise OR operation.
#define DMA_CLEAR(dmaNum, dest, size, bit) \ #define DMA_CLEAR_UNCHECKED(dmaNum, dest, size, bit) \
{ \ { \
vu##bit *_dest = (vu##bit *)(dest); \ vu##bit *_dest = (vu##bit *)(dest); \
u32 _size = size; \ u32 _size = size; \
DmaFill##bit(dmaNum, 0, _dest, _size); \ DmaFill##bit(dmaNum, 0, _dest, _size); \
} }
#if MODERN
#define DMA_CLEAR(dmaNum, dest, size, bit) \
do \
{ \
_Static_assert(_Alignof(dest) >= (bit / 8), "destination potentially unaligned"); \
DMA_CLEAR_UNCHECKED(dmaNum, dest, size, bit); \
} while (0)
#else
#define DMA_CLEAR(dmaNum, dest, size, bit) DMA_CLEAR_UNCHECKED(dmaNum, dest, size, bit)
#endif
#define DmaClear16(dmaNum, dest, size) DMA_CLEAR(dmaNum, dest, size, 16) #define DmaClear16(dmaNum, dest, size) DMA_CLEAR(dmaNum, dest, size, 16)
#define DmaClear32(dmaNum, dest, size) DMA_CLEAR(dmaNum, dest, size, 32) #define DmaClear32(dmaNum, dest, size) DMA_CLEAR(dmaNum, dest, size, 32)
#define DMA_COPY(dmaNum, src, dest, size, bit) \ #define DMA_COPY_UNCHECKED(dmaNum, src, dest, size, bit) \
DmaSet(dmaNum, \ DmaSet(dmaNum, \
src, \ src, \
dest, \ dest, \
(DMA_ENABLE | DMA_START_NOW | DMA_##bit##BIT | DMA_SRC_INC | DMA_DEST_INC) << 16 \ (DMA_ENABLE | DMA_START_NOW | DMA_##bit##BIT | DMA_SRC_INC | DMA_DEST_INC) << 16 \
| ((size)/(bit/8))) | ((size)/(bit/8)))
#if MODERN
#define DMA_COPY(dmaNum, src, dest, size, bit) \
do \
{ \
_Static_assert(_Alignof(src) >= (bit / 8), "source potentially unaligned"); \
_Static_assert(_Alignof(dest) >= (bit / 8), "destination potentially unaligned"); \
DMA_COPY_UNCHECKED(dmaNum, src, dest, size, bit); \
} while (0)
#else
#define DMA_COPY(dmaNum, src, dest, size, bit) DMA_COPY_UNCHECKED(dmaNum, src, dest, size, bit)
#endif
#define DmaCopy16(dmaNum, src, dest, size) DMA_COPY(dmaNum, src, dest, size, 16) #define DmaCopy16(dmaNum, src, dest, size) DMA_COPY(dmaNum, src, dest, size, 16)
#define DmaCopy32(dmaNum, src, dest, size) DMA_COPY(dmaNum, src, dest, size, 32) #define DmaCopy32(dmaNum, src, dest, size) DMA_COPY(dmaNum, src, dest, size, 32)

View File

@ -27,10 +27,32 @@ u16 ArcTan2(s16 x, s16 y);
void CpuSet(const void *src, void *dest, u32 control); void CpuSet(const void *src, void *dest, u32 control);
#if MODERN
// NOTE: Assumes 16-bit CpuSets unless control is a constant and has
// CPU_SET_32BIT set.
#define CpuSet(src, dest, control) \
do \
{ \
_Static_assert(_Alignof(src) >= __builtin_choose_expr(__builtin_constant_p(control), ((control) & CPU_SET_32BIT) ? 4 : 2, 2), "source potentially unaligned"); \
_Static_assert(_Alignof(dest) >= __builtin_choose_expr(__builtin_constant_p(control), ((control) & CPU_SET_32BIT) ? 4 : 2, 2), "destination potentially unaligned"); \
CpuSet(src, dest, control); \
} while (0)
#endif
#define CPU_FAST_SET_SRC_FIXED 0x01000000 #define CPU_FAST_SET_SRC_FIXED 0x01000000
void CpuFastSet(const void *src, void *dest, u32 control); void CpuFastSet(const void *src, void *dest, u32 control);
#if MODERN
#define CpuFastSet(src, dest, control) \
do \
{ \
_Static_assert(_Alignof(src) >= 4, "source potentially unaligned"); \
_Static_assert(_Alignof(dest) >= 4, "destination potentially unaligned"); \
CpuFastSet(src, dest, control); \
} while (0)
#endif
void BgAffineSet(struct BgAffineSrcData *src, struct BgAffineDstData *dest, s32 count); void BgAffineSet(struct BgAffineSrcData *src, struct BgAffineDstData *dest, s32 count);
void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset); void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset);

View File

@ -20,7 +20,6 @@
#define BLOCK_CROSS_JUMP asm(""); #define BLOCK_CROSS_JUMP asm("");
// to help in decompiling // to help in decompiling
#define asm_comment(x) asm volatile("@ -- " x " -- ")
#define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided")
#define NAKED __attribute__((naked)) #define NAKED __attribute__((naked))
@ -141,6 +140,8 @@
// Calls m0/m1/.../m8 depending on how many arguments are passed. // Calls m0/m1/.../m8 depending on how many arguments are passed.
#define VARARG_8(m, ...) CAT(m, NARG_8(__VA_ARGS__))(__VA_ARGS__) #define VARARG_8(m, ...) CAT(m, NARG_8(__VA_ARGS__))(__VA_ARGS__)
// This returns the number of arguments passed to it (up to 8).
#define NARG_8(...) NARG_8_(_, ##__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) #define NARG_8(...) NARG_8_(_, ##__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define NARG_8_(_, a, b, c, d, e, f, g, h, N, ...) N #define NARG_8_(_, a, b, c, d, e, f, g, h, N, ...) N
@ -856,7 +857,7 @@ struct WaldaPhrase
struct TrainerNameRecord struct TrainerNameRecord
{ {
u32 trainerId; u32 trainerId;
u8 trainerName[PLAYER_NAME_LENGTH + 1]; u8 ALIGNED(2) trainerName[PLAYER_NAME_LENGTH + 1];
}; };
struct TrainerHillSave struct TrainerHillSave

View File

@ -8923,7 +8923,7 @@ extern const u32 gIntroGroudon_Gfx[];
extern const u32 gIntroGroudon_Tilemap[]; extern const u32 gIntroGroudon_Tilemap[];
extern const u32 gIntroLegendBg_Gfx[]; extern const u32 gIntroLegendBg_Gfx[];
extern const u32 gIntroGroudonBg_Tilemap[]; extern const u32 gIntroGroudonBg_Tilemap[];
extern const u8 gIntro3Bg_Pal[0x200]; extern const u8 ALIGNED(2) gIntro3Bg_Pal[0x200];
extern const u32 gIntroKyogre_Gfx[]; extern const u32 gIntroKyogre_Gfx[];
extern const u32 gIntroKyogre_Tilemap[]; extern const u32 gIntroKyogre_Tilemap[];
extern const u32 gIntroKyogreBg_Tilemap[]; extern const u32 gIntroKyogreBg_Tilemap[];
@ -10432,8 +10432,8 @@ extern const u32 gPokenavOptions_Gfx[];
extern const u16 gPokenavOptions_Pal[]; extern const u16 gPokenavOptions_Pal[];
// Battle Factory Screen // Battle Factory Screen
extern const u8 gFrontierFactorySelectMenu_Gfx[]; extern const u16 gFrontierFactorySelectMenu_Gfx[];
extern const u8 gFrontierFactorySelectMenu_Tilemap[]; extern const u16 gFrontierFactorySelectMenu_Tilemap[];
extern const u16 gFrontierFactorySelectMenu_Pal[]; extern const u16 gFrontierFactorySelectMenu_Pal[];
// Object event pals // Object event pals

View File

@ -78,7 +78,7 @@ struct BagMenu
u8 numShownItems[POCKETS_COUNT]; u8 numShownItems[POCKETS_COUNT];
s16 graphicsLoadState; s16 graphicsLoadState;
u8 unused2[14]; u8 unused2[14];
u8 pocketNameBuffer[32][32]; u8 ALIGNED(4) pocketNameBuffer[32][32];
u8 unused3[4]; u8 unused3[4];
}; };

View File

@ -329,7 +329,7 @@ struct RfuIntrStruct
{ {
union RfuPacket rxPacketAlloc; union RfuPacket rxPacketAlloc;
union RfuPacket txPacketAlloc; union RfuPacket txPacketAlloc;
u8 block1[0x960]; // size of librfu_intr.s binary u8 ALIGNED(2) block1[0x960]; // size of librfu_intr.s binary
struct STWIStatus block2; struct STWIStatus block2;
}; };

View File

@ -238,7 +238,7 @@ struct BlockRequest
}; };
extern struct Link gLink; extern struct Link gLink;
extern u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH]; extern u16 ALIGNED(4) gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH];
extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE]; extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE];
extern u16 gLinkType; extern u16 gLinkType;
extern u32 gLinkStatus; extern u32 gLinkStatus;

View File

@ -18,7 +18,7 @@ struct MonMarkingsMenu
struct Sprite *textSprite; struct Sprite *textSprite;
const u8 *frameTiles; const u8 *frameTiles;
const u16 *framePalette; const u16 *framePalette;
u8 windowSpriteTiles[0x1000]; u8 ALIGNED(2) windowSpriteTiles[0x1000];
u8 unused[0x80]; u8 unused[0x80];
u8 tileLoadState; u8 tileLoadState;
}; };

View File

@ -54,9 +54,9 @@ struct PaletteFadeControl
extern struct PaletteFadeControl gPaletteFade; extern struct PaletteFadeControl gPaletteFade;
extern u32 gPlttBufferTransferPending; extern u32 gPlttBufferTransferPending;
extern u8 gPaletteDecompressionBuffer[]; extern u8 ALIGNED(4) gPaletteDecompressionBuffer[];
extern u16 gPlttBufferUnfaded[PLTT_BUFFER_SIZE]; extern u16 ALIGNED(4) gPlttBufferUnfaded[PLTT_BUFFER_SIZE];
extern u16 gPlttBufferFaded[PLTT_BUFFER_SIZE]; extern u16 ALIGNED(4) gPlttBufferFaded[PLTT_BUFFER_SIZE];
void LoadCompressedPalette(const u32 *src, u16 offset, u16 size); void LoadCompressedPalette(const u32 *src, u16 offset, u16 size);
void LoadPalette(const void *src, u16 offset, u16 size); void LoadPalette(const void *src, u16 offset, u16 size);

View File

@ -49,7 +49,7 @@ extern const struct SpriteTemplate gBallSpriteTemplates[];
#define POKEBALL_OPPONENT_SENDOUT 0xFE #define POKEBALL_OPPONENT_SENDOUT 0xFE
u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow); u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow);
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 delay, u32 fadePalettes, u16 species); void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriority, u8 delay, u32 fadePalettes, u16 species);
u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes); u8 CreateTradePokeballSprite(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 delay, u32 fadePalettes);
void StartHealthboxSlideIn(u8 battler); void StartHealthboxSlideIn(u8 battler);
void DoHitAnimHealthboxEffect(u8 battler); void DoHitAnimHealthboxEffect(u8 battler);

View File

@ -462,12 +462,17 @@ void SetMultiuseSpriteTemplateToPokemon(u16 speciesTag, u8 battlerPosition);
void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerSpriteId, u8 battlerPosition); void SetMultiuseSpriteTemplateToTrainerBack(u16 trainerSpriteId, u8 battlerPosition);
void SetMultiuseSpriteTemplateToTrainerFront(u16 trainerPicId, u8 battlerPosition); void SetMultiuseSpriteTemplateToTrainerFront(u16 trainerPicId, u8 battlerPosition);
// These are full type signatures for GetMonData() and GetBoxMonData(), /* GameFreak called Get(Box)MonData with either 2 or 3 arguments, for
// but they are not used since some code erroneously omits the third arg. * type safety we have a Get(Box)MonData macro which dispatches to
// u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data); * either Get(Box)MonData2 or Get(Box)MonData3 based on the number of
// u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data); * arguments. The two functions are aliases of each other, but they
u32 GetMonData(); * differ for matching purposes in the caller's codegen. */
u32 GetBoxMonData(); #define GetMonData(...) CAT(GetMonData, NARG_8(__VA_ARGS__))(__VA_ARGS__)
#define GetBoxMonData(...) CAT(GetBoxMonData, NARG_8(__VA_ARGS__))(__VA_ARGS__)
u32 GetMonData3(struct Pokemon *mon, s32 field, u8 *data);
u32 GetMonData2(struct Pokemon *mon, s32 field);
u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data);
u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field);
void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg); void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg);
void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg); void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg);

View File

@ -37,7 +37,7 @@ struct ScanlineEffect
extern struct ScanlineEffect gScanlineEffect; extern struct ScanlineEffect gScanlineEffect;
extern u16 gScanlineEffectRegBuffers[2][0x3C0]; extern u16 ALIGNED(4) gScanlineEffectRegBuffers[2][0x3C0];
void ScanlineEffect_Stop(void); void ScanlineEffect_Stop(void);
void ScanlineEffect_Clear(void); void ScanlineEffect_Clear(void);

View File

@ -268,7 +268,7 @@ static const u8 sActionHighlightMiddle_Gfx[] = INCBIN_U8( "graphics/battle_front
static const u8 sActionHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_right.4bpp"); static const u8 sActionHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_right.4bpp");
static const u8 sMonPicBgAnim_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg_anim.4bpp"); static const u8 sMonPicBgAnim_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg_anim.4bpp");
static const u8 sMonPicBg_Tilemap[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.bin"); static const u8 sMonPicBg_Tilemap[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.bin");
static const u8 sMonPicBg_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.4bpp"); static const u16 sMonPicBg_Gfx[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.4bpp");
static const u16 sMonPicBg_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal"); static const u16 sMonPicBg_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal");
static const struct SpriteSheet sSelect_SpriteSheets[] = static const struct SpriteSheet sSelect_SpriteSheets[] =

View File

@ -117,7 +117,7 @@ static const struct WindowTemplate sBerryFixWindowTemplates[] = {
DUMMY_WIN_TEMPLATE DUMMY_WIN_TEMPLATE
}; };
static const u16 sBerryFixPalColors[] = { static const u16 ALIGNED(4) sBerryFixPalColors[] = {
RGB_WHITE, RGB_WHITE, RGB(12, 12, 12), RGB(26, 26, 25), RGB_WHITE, RGB_WHITE, RGB(12, 12, 12), RGB(26, 26, 25),
RGB(28, 1, 1), RGB(31, 23, 14), RGB(4, 19, 1), RGB(18, 30, 18), RGB(28, 1, 1), RGB(31, 23, 14), RGB(4, 19, 1), RGB(18, 30, 18),
RGB(6, 10, 25), RGB(20, 24, 30), RGB_WHITE, RGB(12, 12, 12), RGB(6, 10, 25), RGB(20, 24, 30), RGB_WHITE, RGB(12, 12, 12),

View File

@ -1301,8 +1301,8 @@ static void Task_ReadyStartLinkContest(u8 taskId)
static bool8 SetupContestGraphics(u8 *stateVar) static bool8 SetupContestGraphics(u8 *stateVar)
{ {
u16 tempPalette1[16]; u16 ALIGNED(4) tempPalette1[16];
u16 tempPalette2[16]; u16 ALIGNED(4) tempPalette2[16];
switch (*stateVar) switch (*stateVar)
{ {

View File

@ -412,7 +412,7 @@ static void Debug_AddDaycareSteps(u16 numSteps)
u8 GetNumLevelsGainedFromDaycare(void) u8 GetNumLevelsGainedFromDaycare(void)
{ {
if (GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[gSpecialVar_0x8004], MON_DATA_SPECIES) != 0) if (GetBoxMonData(&gSaveBlock1Ptr->daycare.mons[gSpecialVar_0x8004].mon, MON_DATA_SPECIES) != 0)
return GetNumLevelsGainedForDaycareMon(&gSaveBlock1Ptr->daycare.mons[gSpecialVar_0x8004]); return GetNumLevelsGainedForDaycareMon(&gSaveBlock1Ptr->daycare.mons[gSpecialVar_0x8004]);
return 0; return 0;

View File

@ -1916,7 +1916,7 @@ static void CopyPalette(u16 *dest, u16 pal)
static void CopyTile(u8 *dest, u16 tile) static void CopyTile(u8 *dest, u16 tile)
{ {
u8 buffer[TILE_SIZE_4BPP]; u8 ALIGNED(4) buffer[TILE_SIZE_4BPP];
u16 mode; u16 mode;
u16 i; u16 i;

View File

@ -61,7 +61,7 @@ static void None_Main(void);
static u8 None_Finish(void); static u8 None_Finish(void);
EWRAM_DATA struct Weather gWeather = {0}; EWRAM_DATA struct Weather gWeather = {0};
EWRAM_DATA static u8 sFieldEffectPaletteColorMapTypes[32] = {0}; EWRAM_DATA static u8 ALIGNED(2) sFieldEffectPaletteColorMapTypes[32] = {0};
static const u8 *sPaletteColorMapTypes; static const u8 *sPaletteColorMapTypes;
@ -111,7 +111,7 @@ void (*const gWeatherPalStateFuncs[])(void) =
// This table specifies which of the color maps should be // This table specifies which of the color maps should be
// applied to each of the background and sprite palettes. // applied to each of the background and sprite palettes.
static const u8 sBasePaletteColorMapTypes[32] = static const u8 ALIGNED(2) sBasePaletteColorMapTypes[32] =
{ {
// background palettes // background palettes
COLOR_MAP_DARK_CONTRAST, COLOR_MAP_DARK_CONTRAST,
@ -149,7 +149,7 @@ static const u8 sBasePaletteColorMapTypes[32] =
COLOR_MAP_DARK_CONTRAST, COLOR_MAP_DARK_CONTRAST,
}; };
const u16 gFogPalette[] = INCBIN_U16("graphics/weather/fog.gbapal"); const u16 ALIGNED(4) gFogPalette[] = INCBIN_U16("graphics/weather/fog.gbapal");
void StartWeather(void) void StartWeather(void)
{ {

View File

@ -25,7 +25,7 @@ struct ConnectionFlags
u8 east:1; u8 east:1;
}; };
EWRAM_DATA static u16 sBackupMapData[MAX_MAP_DATA_SIZE] = {0}; EWRAM_DATA static u16 ALIGNED(4) sBackupMapData[MAX_MAP_DATA_SIZE] = {0};
EWRAM_DATA struct MapHeader gMapHeader = {0}; EWRAM_DATA struct MapHeader gMapHeader = {0};
EWRAM_DATA struct Camera gCamera = {0}; EWRAM_DATA struct Camera gCamera = {0};
EWRAM_DATA static struct ConnectionFlags sMapConnectionFlags = {0}; EWRAM_DATA static struct ConnectionFlags sMapConnectionFlags = {0};

View File

@ -1709,8 +1709,8 @@ const u32 gRouletteMultiplier_Gfx[] = INCBIN_U32("graphics/roulette/multiplier.4
const u16 gFrontierFactorySelectMenu_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_menu1.gbapal"); const u16 gFrontierFactorySelectMenu_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_menu1.gbapal");
const u16 gFrontierFactorySelectMenu_Pal2[] = INCBIN_U16("graphics/battle_frontier/factory_menu2.gbapal"); const u16 gFrontierFactorySelectMenu_Pal2[] = INCBIN_U16("graphics/battle_frontier/factory_menu2.gbapal");
const u8 gFrontierFactorySelectMenu_Gfx[] = INCBIN_U8("graphics/battle_frontier/factory_menu1.4bpp"); const u16 gFrontierFactorySelectMenu_Gfx[] = INCBIN_U16("graphics/battle_frontier/factory_menu1.4bpp");
const u8 gFrontierFactorySelectMenu_Gfx2[] = INCBIN_U8("graphics/battle_frontier/factory_menu2.4bpp"); const u16 gFrontierFactorySelectMenu_Gfx2[] = INCBIN_U16("graphics/battle_frontier/factory_menu2.4bpp");
const u16 gFrontierFactorySelectMenu_Tilemap[] = INCBIN_U16("graphics/battle_frontier/factory_menu.bin"); const u16 gFrontierFactorySelectMenu_Tilemap[] = INCBIN_U16("graphics/battle_frontier/factory_menu.bin");

View File

@ -2436,16 +2436,16 @@ static void PrintPocketNames(const u8 *pocketName1, const u8 *pocketName2)
static void CopyPocketNameToWindow(u32 a) static void CopyPocketNameToWindow(u32 a)
{ {
u8 (* tileDataBuffer)[32][32]; u8 (*tileDataBuffer)[32][32];
u8 *windowTileData; u8 *windowTileData;
int b; int b;
if (a > 8) if (a > 8)
a = 8; a = 8;
tileDataBuffer = &gBagMenu->pocketNameBuffer; tileDataBuffer = &gBagMenu->pocketNameBuffer;
windowTileData = (u8 *)GetWindowAttribute(2, WINDOW_TILE_DATA); windowTileData = (u8 *)GetWindowAttribute(2, WINDOW_TILE_DATA);
CpuCopy32(tileDataBuffer[0][a], windowTileData, 0x100); // Top half of pocket name CpuCopy32(&tileDataBuffer[0][a], windowTileData, 0x100); // Top half of pocket name
b = a + 16; b = a + 16;
CpuCopy32(tileDataBuffer[0][b], windowTileData + 0x100, 0x100); // Bottom half of pocket name CpuCopy32(&tileDataBuffer[0][b], windowTileData + 0x100, 0x100); // Bottom half of pocket name
CopyWindowToVram(WIN_POCKET_NAME, COPYWIN_GFX); CopyWindowToVram(WIN_POCKET_NAME, COPYWIN_GFX);
} }

View File

@ -78,7 +78,7 @@ bool8 gRemoteLinkPlayersNotReceived[MAX_LINK_PLAYERS];
u8 gBlockReceivedStatus[MAX_LINK_PLAYERS]; u8 gBlockReceivedStatus[MAX_LINK_PLAYERS];
u32 gLinkFiller2; u32 gLinkFiller2;
u16 gLinkHeldKeys; u16 gLinkHeldKeys;
u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH]; u16 ALIGNED(4) gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH];
u32 gLinkStatus; u32 gLinkStatus;
bool8 gLinkDummy1; // Never read bool8 gLinkDummy1; // Never read
bool8 gLinkDummy2; // Never read bool8 gLinkDummy2; // Never read

View File

@ -75,7 +75,7 @@ static void Task_FossilFallAndSink(u8);
static void SpriteCB_FallingFossil(struct Sprite *); static void SpriteCB_FallingFossil(struct Sprite *);
static void UpdateDisintegrationEffect(u8 *, u16, u8, u8, u8); static void UpdateDisintegrationEffect(u8 *, u16, u8, u8, u8);
static const u8 sBlankTile_Gfx[32] = {0}; static const u8 ALIGNED(2) sBlankTile_Gfx[32] = {0};
static const u8 sMirageTower_Gfx[] = INCBIN_U8("graphics/misc/mirage_tower.4bpp"); static const u8 sMirageTower_Gfx[] = INCBIN_U8("graphics/misc/mirage_tower.4bpp");
static const u16 sMirageTowerTilemap[] = INCBIN_U16("graphics/misc/mirage_tower.bin"); static const u16 sMirageTowerTilemap[] = INCBIN_U16("graphics/misc/mirage_tower.bin");
static const u16 sFossil_Pal[] = INCBIN_U16("graphics/object_events/pics/misc/fossil.gbapal"); // Unused static const u16 sFossil_Pal[] = INCBIN_U16("graphics/object_events/pics/misc/fossil.gbapal"); // Unused

View File

@ -64,7 +64,7 @@ static EWRAM_DATA struct PaletteStruct sPaletteStructs[NUM_PALETTE_STRUCTS] = {0
EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0}; EWRAM_DATA struct PaletteFadeControl gPaletteFade = {0};
static EWRAM_DATA u32 sFiller = 0; static EWRAM_DATA u32 sFiller = 0;
static EWRAM_DATA u32 sPlttBufferTransferPending = 0; static EWRAM_DATA u32 sPlttBufferTransferPending = 0;
EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_SIZE] = {0}; EWRAM_DATA u8 ALIGNED(2) gPaletteDecompressionBuffer[PLTT_SIZE] = {0};
static const struct PaletteStructTemplate sDummyPaletteStructTemplate = { static const struct PaletteStructTemplate sDummyPaletteStructTemplate = {
.id = 0xFFFF, .id = 0xFFFF,

View File

@ -1218,13 +1218,13 @@ static u8 LaunchBallFadeMonTaskForPokeball(bool8 unFadeLater, u8 spritePalNum, u
#define sTrigIdx data[7] #define sTrigIdx data[7]
// Pokeball in Birch intro, and when receiving via trade // Pokeball in Birch intro, and when receiving via trade
void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 delay, u32 fadePalettes, u16 species) void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 monPalNum, u8 x, u8 y, u8 oamPriority, u8 subpriority, u8 delay, u32 fadePalettes, u16 species)
{ {
u8 spriteId; u8 spriteId;
LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[BALL_POKE]); LoadCompressedSpriteSheetUsingHeap(&gBallSpriteSheets[BALL_POKE]);
LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[BALL_POKE]); LoadCompressedSpritePaletteUsingHeap(&gBallSpritePalettes[BALL_POKE]);
spriteId = CreateSprite(&gBallSpriteTemplates[BALL_POKE], x, y, subpriortiy); spriteId = CreateSprite(&gBallSpriteTemplates[BALL_POKE], x, y, subpriority);
gSprites[spriteId].sMonSpriteId = monSpriteId; gSprites[spriteId].sMonSpriteId = monSpriteId;
gSprites[spriteId].sFinalMonX = gSprites[monSpriteId].x; gSprites[spriteId].sFinalMonX = gSprites[monSpriteId].x;

View File

@ -4537,7 +4537,7 @@ static void PrintDecimalNum(u8 windowId, u16 num, u8 left, u8 top)
static void DrawFootprint(u8 windowId, u16 dexNum) static void DrawFootprint(u8 windowId, u16 dexNum)
{ {
u8 footprint4bpp[TILE_SIZE_4BPP * NUM_FOOTPRINT_TILES]; u8 ALIGNED(4) footprint4bpp[TILE_SIZE_4BPP * NUM_FOOTPRINT_TILES];
const u8 *footprintGfx = gMonFootprintTable[NationalPokedexNumToSpecies(dexNum)]; const u8 *footprintGfx = gMonFootprintTable[NationalPokedexNumToSpecies(dexNum)];
u32 i, j, tileIdx = 0; u32 i, j, tileIdx = 0;

View File

@ -8,7 +8,7 @@
static EWRAM_DATA u8 *sPokedexAreaMapBgNum = NULL; static EWRAM_DATA u8 *sPokedexAreaMapBgNum = NULL;
static const u16 sPokedexAreaMap_Pal[] = INCBIN_U16("graphics/pokedex/region_map.gbapal"); static const u16 ALIGNED(4) sPokedexAreaMap_Pal[] = INCBIN_U16("graphics/pokedex/region_map.gbapal");
static const u32 sPokedexAreaMap_Gfx[] = INCBIN_U32("graphics/pokedex/region_map.8bpp.lz"); static const u32 sPokedexAreaMap_Gfx[] = INCBIN_U32("graphics/pokedex/region_map.8bpp.lz");
static const u32 sPokedexAreaMap_Tilemap[] = INCBIN_U32("graphics/pokedex/region_map.bin.lz"); static const u32 sPokedexAreaMap_Tilemap[] = INCBIN_U32("graphics/pokedex/region_map.bin.lz");
static const u32 sPokedexAreaMapAffine_Gfx[] = INCBIN_U32("graphics/pokedex/region_map_affine.8bpp.lz"); static const u32 sPokedexAreaMapAffine_Gfx[] = INCBIN_U32("graphics/pokedex/region_map_affine.8bpp.lz");

View File

@ -4627,7 +4627,11 @@ static union PokemonSubstruct *GetSubstruct(struct BoxPokemon *boxMon, u32 perso
return substruct; return substruct;
} }
u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data) /* GameFreak called GetMonData with either 2 or 3 arguments, for type
* safety we have a GetMonData macro (in include/pokemon.h) which
* dispatches to either GetMonData2 or GetMonData3 based on the number
* of arguments. */
u32 GetMonData3(struct Pokemon *mon, s32 field, u8 *data)
{ {
u32 ret; u32 ret;
@ -4685,7 +4689,13 @@ u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data)
return ret; return ret;
} }
u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) u32 GetMonData2(struct Pokemon *mon, s32 field) __attribute__((alias("GetMonData3")));
/* GameFreak called GetBoxMonData with either 2 or 3 arguments, for type
* safety we have a GetBoxMonData macro (in include/pokemon.h) which
* dispatches to either GetBoxMonData2 or GetBoxMonData3 based on the
* number of arguments. */
u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
{ {
s32 i; s32 i;
u32 retVal = 0; u32 retVal = 0;
@ -5041,6 +5051,8 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
return retVal; return retVal;
} }
u32 GetBoxMonData2(struct BoxPokemon *boxMon, s32 field) __attribute__((alias("GetBoxMonData3")));
#define SET8(lhs) (lhs) = *data #define SET8(lhs) (lhs) = *data
#define SET16(lhs) (lhs) = data[0] + (data[1] << 8) #define SET16(lhs) (lhs) = data[0] + (data[1] << 8)
#define SET32(lhs) (lhs) = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24) #define SET32(lhs) (lhs) = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24)

View File

@ -552,8 +552,8 @@ struct PokemonStorageSystemData
u16 *displayMonTilePtr; u16 *displayMonTilePtr;
struct Sprite *displayMonSprite; struct Sprite *displayMonSprite;
u16 displayMonPalBuffer[0x40]; u16 displayMonPalBuffer[0x40];
u8 tileBuffer[MON_PIC_SIZE * MAX_MON_PIC_FRAMES]; u8 ALIGNED(4) tileBuffer[MON_PIC_SIZE * MAX_MON_PIC_FRAMES];
u8 itemIconBuffer[0x800]; u8 ALIGNED(4) itemIconBuffer[0x800];
u8 wallpaperBgTilemapBuffer[0x1000]; u8 wallpaperBgTilemapBuffer[0x1000];
u8 displayMenuTilemapBuffer[0x800]; u8 displayMenuTilemapBuffer[0x800];
}; };
@ -10150,7 +10150,7 @@ void UpdateSpeciesSpritePSS(struct BoxPokemon *boxMon)
{ {
DestroyBoxMonIcon(sStorage->boxMonsSprites[sCursorPosition]); DestroyBoxMonIcon(sStorage->boxMonsSprites[sCursorPosition]);
CreateBoxMonIconAtPos(sCursorPosition); CreateBoxMonIconAtPos(sCursorPosition);
SetBoxMonIconObjMode(sCursorPosition, GetMonData(boxMon, MON_DATA_HELD_ITEM) == ITEM_NONE); SetBoxMonIconObjMode(sCursorPosition, GetBoxMonData(boxMon, MON_DATA_HELD_ITEM) == ITEM_NONE);
} }
} }
sJustOpenedBag = FALSE; sJustOpenedBag = FALSE;

View File

@ -116,10 +116,12 @@ static const LoopedTask sLoopedTaskFuncs[] =
[CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow [CONDITION_FUNC_CLOSE_MARKINGS] = LoopedTask_CloseMonMarkingsWindow
}; };
typedef u8 ALIGNED(4) TilemapBuffer[BG_SCREEN_SIZE];
struct Pokenav_ConditionMenuGfx struct Pokenav_ConditionMenuGfx
{ {
u32 loopedTaskId; u32 loopedTaskId;
u8 tilemapBuffers[3][BG_SCREEN_SIZE]; TilemapBuffer tilemapBuffers[3];
u8 filler[2]; u8 filler[2];
u8 partyPokeballSpriteIds[PARTY_SIZE + 1]; u8 partyPokeballSpriteIds[PARTY_SIZE + 1];
u32 (*callback)(void); u32 (*callback)(void);

View File

@ -35,7 +35,7 @@ struct Pokenav_RegionMapGfx
u32 loopTaskId; u32 loopTaskId;
u16 infoWindowId; u16 infoWindowId;
struct Sprite *cityZoomTextSprites[3]; struct Sprite *cityZoomTextSprites[3];
u8 tilemapBuffer[BG_SCREEN_SIZE]; u8 ALIGNED(2) tilemapBuffer[BG_SCREEN_SIZE];
u8 cityZoomPics[NUM_CITY_MAPS][200]; u8 cityZoomPics[NUM_CITY_MAPS][200];
}; };

View File

@ -60,10 +60,12 @@ enum
#define MAX_SMOKE 10 #define MAX_SMOKE 10
typedef u8 ALIGNED(4) TilemapBuffer[BG_SCREEN_SIZE];
struct RayquazaScene struct RayquazaScene
{ {
MainCallback exitCallback; MainCallback exitCallback;
u8 tilemapBuffers[4][BG_SCREEN_SIZE]; TilemapBuffer tilemapBuffers[4];
u16 unk; // never read u16 unk; // never read
u8 animId; u8 animId;
bool8 endEarly; bool8 endEarly;

View File

@ -13,7 +13,7 @@ static void CopyValue32Bit(void);
// Per-scanline register values. // Per-scanline register values.
// This is double buffered so that it can be safely written to at any time // This is double buffered so that it can be safely written to at any time
// without overwriting the buffer that the DMA is currently reading // without overwriting the buffer that the DMA is currently reading
EWRAM_DATA u16 gScanlineEffectRegBuffers[2][0x3C0] = {0}; EWRAM_DATA u16 ALIGNED(4) gScanlineEffectRegBuffers[2][0x3C0] = {0};
EWRAM_DATA struct ScanlineEffect gScanlineEffect = {0}; EWRAM_DATA struct ScanlineEffect gScanlineEffect = {0};
EWRAM_DATA static bool8 sShouldStopWaveTask = FALSE; EWRAM_DATA static bool8 sShouldStopWaveTask = FALSE;

View File

@ -158,7 +158,7 @@ void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output)
{ {
u8 x, y; u8 x, y;
s8 i, j; s8 i, j;
u8 xflip[32]; u8 ALIGNED(4) xflip[32];
u8 h = sSpriteDimensions[shape][size][1]; u8 h = sSpriteDimensions[shape][size][1];
u8 w = sSpriteDimensions[shape][size][0]; u8 w = sSpriteDimensions[shape][size][0];