diff options
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/common.h b/src/common.h index 35b4619..6047e5f 100644 --- a/src/common.h +++ b/src/common.h | |||
@@ -76,6 +76,20 @@ | |||
76 | #define BG_V_SCROLL_2 *((vu16*)(0x04000012 + 0x0004 * 2)) | 76 | #define BG_V_SCROLL_2 *((vu16*)(0x04000012 + 0x0004 * 2)) |
77 | #define BG_V_SCROLL_3 *((vu16*)(0x04000012 + 0x0004 * 3)) | 77 | #define BG_V_SCROLL_3 *((vu16*)(0x04000012 + 0x0004 * 3)) |
78 | 78 | ||
79 | // Screenblocks for BGs. | ||
80 | typedef u16 ScreenBlock[1024]; | ||
81 | #define SCREENBLOCK_MEM ((ScreenBlock*)MEM_VRAM) | ||
82 | |||
83 | // Screenblock entry bits. | ||
84 | #define SCREENBLOCK_ENTRY_H_FLIP (1 << 0xA) | ||
85 | #define SCREENBLOCK_ENTRY_V_FLIP (1 << 0xB) | ||
86 | #define SCREENBLOCK_ENTRY_PAL(N) ((N) << 0xC) | ||
87 | |||
88 | size_t se_index(size_t tile_x, size_t tile_y, size_t map_width) { | ||
89 | size_t sbb = ((tile_x >> 5) + (tile_y >> 5) * (map_width >> 5)); | ||
90 | return sbb * 1024 + ((tile_x & 31) + (tile_y & 31) * 32); | ||
91 | } | ||
92 | |||
79 | // Screen settings. | 93 | // Screen settings. |
80 | #define SCREEN_WIDTH 240 | 94 | #define SCREEN_WIDTH 240 |
81 | #define SCREEN_HEIGHT 160 | 95 | #define SCREEN_HEIGHT 160 |
@@ -84,6 +98,9 @@ | |||
84 | // (RGB) have a 0--31 range. For example, pure red would be rgb15(31, 0, 0). | 98 | // (RGB) have a 0--31 range. For example, pure red would be rgb15(31, 0, 0). |
85 | typedef u16 Color; | 99 | typedef u16 Color; |
86 | 100 | ||
101 | // A palette is composed of 16 colors, with color at index 0 being transparent. | ||
102 | typedef Color Palette[16]; | ||
103 | |||
87 | // | 104 | // |
88 | // Tile memory access. | 105 | // Tile memory access. |
89 | // | 106 | // |
@@ -96,9 +113,6 @@ typedef struct Tile { | |||
96 | typedef Tile TileBlock[512]; | 113 | typedef Tile TileBlock[512]; |
97 | #define TILE_MEM ((TileBlock*) MEM_VRAM) | 114 | #define TILE_MEM ((TileBlock*) MEM_VRAM) |
98 | 115 | ||
99 | typedef u16 ScreenBlock[1024]; | ||
100 | #define SCREENBLOCK_MEM ((ScreenBlock*)MEM_VRAM) | ||
101 | |||
102 | // We can treat the screen as a HxW matrix. With the following macro we can | 116 | // We can treat the screen as a HxW matrix. With the following macro we can |
103 | // write a pixel to the screen at the (x, y) position using: | 117 | // write a pixel to the screen at the (x, y) position using: |
104 | // | 118 | // |
@@ -109,6 +123,8 @@ typedef Color Scanline[SCREEN_WIDTH]; | |||
109 | #define SCREEN_BUFFER ((u16*) MEM_VRAM) | 123 | #define SCREEN_BUFFER ((u16*) MEM_VRAM) |
110 | #define PAL_BUFFER_BG ((u16*) MEM_PAL) | 124 | #define PAL_BUFFER_BG ((u16*) MEM_PAL) |
111 | #define PAL_BUFFER_SPRITES ((u16*) 0x05000200) | 125 | #define PAL_BUFFER_SPRITES ((u16*) 0x05000200) |
126 | #define PAL_BANK_BG ((Palette*) MEM_PAL) | ||
127 | #define PAL_BANK_SPRITES ((Palette*) 0x05000200) | ||
112 | 128 | ||
113 | // | 129 | // |
114 | // Colors. | 130 | // Colors. |
@@ -277,5 +293,4 @@ key_hold(u32 key) { | |||
277 | // Check if the given key/button is currently pressed. | 293 | // Check if the given key/button is currently pressed. |
278 | #define KEY_PRESSED(key) (~(KEY_INPUTS) & key) | 294 | #define KEY_PRESSED(key) (~(KEY_INPUTS) & key) |
279 | 295 | ||
280 | |||
281 | #endif // GBAEXP_COMMON_H | 296 | #endif // GBAEXP_COMMON_H |