Alchemy
Loading...
Searching...
No Matches

map_panel.h

Go to the documentation of this file.
1#include "types.h"
2#include "ram_buffer.h"
3#include "map.h"
4#include "io_reg.h"
5
6// Crossbone Isle's pillar rooms and Kolima's forest bend: drawing a stretch of
7// the map, in one of the states kept elsewhere in it (such as the water
8// raised or not), straight into the background's tile map.
9
10/// Draws the width by height cells at cell (x, y) of the map into screen block
11/// 5 from cell (destX, destY), wrapped to 16 by 16 cells, in band plane (16
12/// cell rows each): each cell is its block's tiles from Ram_MapBlocks.
13static void Map_DrawCellPanel(s32 x, s32 y, s32 width, s32 height, s32 plane,
14 s32 destX, s32 destY) {
15 u32 *cell = (u32 *)Ram_MapCellBuffer + (y * 128 + x);
16 s32 row;
17 s32 col;
18 s32 end;
19
20 for (row = destY; row < destY + height; row++) {
21 col = destX;
22 if (col < destX + width)
23 do {
24 u16 tile = 0xfff & *cell++;
25 u16 offset = tile * 8;
26 s32 index = (plane * 16 + (row & 15)) * 32 + (col & 15);
27 u32 *src;
28 u32 *dst;
29
30 dst = (u32 *)BG_SCREEN_BLOCK(5) + index;
31 src = (u32 *)(Ram_MapBlocks + offset);
32 *dst = *src;
33 src = (u32 *)(Ram_MapBlocks + 4 + offset);
34 dst = (u32 *)(BG_SCREEN_BLOCK(5) + 64) + index;
35 *dst = *src;
36
37 /* FAKEMATCH(temporary): end takes the bound where the loop tests it,
38 * apart from the guard's destX + width; as ++col < destX + width, 12
39 * of 80 instructions differ in tbs-en. */
40 } while (end = destX + width, ++col < end);
41 cell += 128 - width;
42 }
43}
The hardware's I/O registers and their bits, as pret names them.
#define BG_SCREEN_BLOCK(n)
Definition io_reg.h:167
Maps: their cells, layers, animations and blend scripts, and the map state.
static void Map_DrawCellPanel(s32 x, s32 y, s32 width, s32 height, s32 plane, s32 destX, s32 destY)
Draws the width by height cells at cell (x, y) of the map into screen block 5 from cell (destX,...
Definition map_panel.h:13
The work pointers in the gWorkSlot table, by name.
#define Ram_MapBlocks
Definition ram_buffer.h:12
#define Ram_MapCellBuffer
Definition ram_buffer.h:10
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
unsigned short u16
Definition types.h:13