pokeemerald/include/gba/defines.h

98 lines
2.5 KiB
C
Raw Normal View History

2021-04-02 18:54:40 +02:00
#ifndef GUARD_GBA_DEFINES_H
#define GUARD_GBA_DEFINES_H
2016-10-31 09:14:22 +01:00
#include <stddef.h>
#define TRUE 1
#define FALSE 0
#define IWRAM_DATA __attribute__((section("iwram_data")))
#define EWRAM_DATA __attribute__((section("ewram_data")))
2020-02-16 19:49:36 +01:00
#define UNUSED __attribute__((unused))
2016-10-31 09:14:22 +01:00
#if MODERN
#define NOINLINE __attribute__((noinline))
#else
#define NOINLINE
#endif
2016-10-31 09:14:22 +01:00
#define ALIGNED(n) __attribute__((aligned(n)))
#define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0)
#define INTR_CHECK (*(u16 *)0x3007FF8)
#define INTR_VECTOR (*(void **)0x3007FFC)
#define ROM_START 0x8000000
#define ROM_END 0xA000000
2017-09-10 02:46:19 +02:00
#define EWRAM_START 0x02000000
#define EWRAM_END (EWRAM_START + 0x40000)
#define IWRAM_START 0x03000000
#define IWRAM_END (IWRAM_START + 0x8000)
2023-05-23 19:16:18 +02:00
#define PLTT 0x5000000
#define BG_PLTT PLTT
#define BG_PLTT_SIZE 0x200
#define OBJ_PLTT (PLTT + BG_PLTT_SIZE)
2016-10-31 09:14:22 +01:00
#define OBJ_PLTT_SIZE 0x200
2023-05-23 19:16:18 +02:00
#define PLTT_SIZE (BG_PLTT_SIZE + OBJ_PLTT_SIZE)
2016-10-31 09:14:22 +01:00
#define VRAM 0x6000000
#define VRAM_SIZE 0x18000
#define BG_VRAM VRAM
#define BG_VRAM_SIZE 0x10000
2017-09-10 03:52:33 +02:00
#define BG_CHAR_SIZE 0x4000
#define BG_SCREEN_SIZE 0x800
#define BG_CHAR_ADDR(n) (BG_VRAM + (BG_CHAR_SIZE * (n)))
#define BG_SCREEN_ADDR(n) (BG_VRAM + (BG_SCREEN_SIZE * (n)))
2016-10-31 09:14:22 +01:00
2018-01-27 06:41:52 +01:00
#define BG_TILE_H_FLIP(n) (0x400 + (n))
#define BG_TILE_V_FLIP(n) (0x800 + (n))
2018-01-25 22:25:35 +01:00
2021-02-18 16:00:07 +01:00
#define NUM_BACKGROUNDS 4
2016-10-31 09:14:22 +01:00
// text-mode BG
#define OBJ_VRAM0 (VRAM + 0x10000)
#define OBJ_VRAM0_SIZE 0x8000
// bitmap-mode BG
#define OBJ_VRAM1 (VRAM + 0x14000)
#define OBJ_VRAM1_SIZE 0x4000
#define OAM 0x7000000
#define OAM_SIZE 0x400
2017-09-25 23:26:45 +02:00
#define ROM_HEADER_SIZE 0xC0
2023-05-10 04:04:26 +02:00
// Dimensions of a tile in pixels
#define TILE_WIDTH 8
#define TILE_HEIGHT 8
// Dimensions of the GBA screen in pixels
2016-10-31 09:14:22 +01:00
#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 160
2023-05-10 04:04:26 +02:00
// Dimensions of the GBA screen in tiles
#define DISPLAY_TILE_WIDTH (DISPLAY_WIDTH / TILE_WIDTH)
#define DISPLAY_TILE_HEIGHT (DISPLAY_HEIGHT / TILE_HEIGHT)
2022-08-19 16:29:35 +02:00
2023-05-10 04:04:26 +02:00
// Size of different tile formats in bytes
#define TILE_SIZE(bpp)((bpp) * TILE_WIDTH * TILE_HEIGHT / 8)
#define TILE_SIZE_1BPP TILE_SIZE(1) // 8
#define TILE_SIZE_4BPP TILE_SIZE(4) // 32
#define TILE_SIZE_8BPP TILE_SIZE(8) // 64
2016-10-31 09:14:22 +01:00
#define TILE_OFFSET_4BPP(n) ((n) * TILE_SIZE_4BPP)
#define TILE_OFFSET_8BPP(n) ((n) * TILE_SIZE_8BPP)
2016-10-31 09:14:22 +01:00
#define TOTAL_OBJ_TILE_COUNT 1024
#define PLTT_SIZEOF(n) ((n) * sizeof(u16))
#define PLTT_SIZE_4BPP PLTT_SIZEOF(16)
#define PLTT_SIZE_8BPP PLTT_SIZEOF(256)
#define PLTT_OFFSET_4BPP(n) ((n) * PLTT_SIZE_4BPP)
2021-04-02 18:54:40 +02:00
#endif // GUARD_GBA_DEFINES_H