Alchemy
Loading...
Searching...
No Matches

map_scroll.h

Go to the documentation of this file.
1#ifndef ALCHEMY_MAP_SCROLL_H
2#define ALCHEMY_MAP_SCROLL_H
3
4/// @file
5/// The map layers' scroll work and the background scroll values.
6
7#include "types.h"
8#include "global_cells.h"
9#include "static_assert.h"
10#include "map.h"
11
12/// One background layer of the field map: its scroll position, origin,
13/// parallax against the view, drift and wrap, and its first map cell.
15 s32 x, y; ///< 16.16 fixed-point pixels
16 s32 offsetX, offsetY; ///< 16.16 fixed-point pixels
17 s32 scaleX, scaleY; ///< 16.16 fixed point, 0x10000 moves with the view
18 s32 speedX, speedY; ///< 16.16 fixed-point pixels per frame
19 s32 phaseX, phaseY; ///< 16.16 fixed-point pixels
20 u16 maskX, maskY; ///< a drifting layer's wrap mask, in 8-pixel tiles
21 struct MapCell *cells; ///< the layer's first cell in the map cell buffer
22};
23
24/// The field map's work: the followed position, screen shake, tile
25/// animations, blend script, view and its bounds, and three scrolling layers.
26/// Heap slot 8.
28 /// The followed point, read as x, height and z in 16.16 fixed-point pixels;
29 /// Camera_FollowActor points it at the camera's position.
31 /// Screen shake amplitudes in 16.16 fixed-point pixels, and the 16.16
32 /// factor that scales them each frame.
34 u8 *script; ///< set from the layered scene's header; not read by name
35 u16 flags; ///< REG_DISPCNT bits: objects and the BG1 to BG3 shown
36 u8 wideTiles; ///< nonzero: tile animations copy 64-byte tiles
37 u8 footprints; ///< nonzero: the leader leaves footprints
38 struct MapAnimation anim[16];
40 s32 viewX, viewY; ///< the view's top left, 16.16 fixed-point pixels
41 s32 minX, minY, maxX, maxY; ///< 16.16 fixed-point pixels
42 /// Set while a BG1 animation runs; the tile animations are then neither
43 /// suspended nor resumed.
45 u8 unk0fd[3]; ///< not named by TBS code
46 /// Each layer's BG priority, written into its BGCNT; zero hides the layer.
48 u8 unk103; ///< MapState's blendControl, the last BLDCNT the blend script set
49 struct MapLayerScroll layers[3]; ///< BG3, BG2 and BG1, in that order
50};
51
52#include "perspective.h"
53
54STATIC_ASSERT(sizeof(struct MapLayerScroll) == 0x30);
56STATIC_ASSERT(sizeof(struct MapScrollWork) == 0x194);
57STATIC_ASSERT(offsetof(struct MapScrollWork, anim) == 0x18);
58STATIC_ASSERT(offsetof(struct MapScrollWork, blend) == 0xd8);
59STATIC_ASSERT(offsetof(struct MapScrollWork, viewX) == 0xe4);
60STATIC_ASSERT(offsetof(struct MapScrollWork, animationActive) == 0xfc);
61STATIC_ASSERT(offsetof(struct MapScrollWork, layers) == 0x104);
62
63/// A background's hardware scroll offsets.
64struct BgScroll {
65 u16 x, y; ///< pixels
66};
67
68extern struct BgScroll gBgScroll[];
69
70#endif
The work slots of gWorkSlot, read through their own names.
Maps: their cells, layers, animations and blend scripts, and the map state.
struct BgScroll gBgScroll[]
The world map's perspective view work.
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A background's hardware scroll offsets.
Definition map_scroll.h:64
u16 y
pixels
Definition map_scroll.h:65
The map's running blend script, which sets the blend registers over time.
Definition map.h:31
One of the 16 tile animation channels, which copy tiles into VRAM by script.
Definition map.h:40
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
Definition map.h:13
One background layer of the field map: its scroll position, origin, parallax against the view,...
Definition map_scroll.h:14
s32 scaleY
16.16 fixed point, 0x10000 moves with the view
Definition map_scroll.h:17
s32 speedY
16.16 fixed-point pixels per frame
Definition map_scroll.h:18
u16 maskY
a drifting layer's wrap mask, in 8-pixel tiles
Definition map_scroll.h:20
s32 y
16.16 fixed-point pixels
Definition map_scroll.h:15
s32 phaseY
16.16 fixed-point pixels
Definition map_scroll.h:19
struct MapCell * cells
the layer's first cell in the map cell buffer
Definition map_scroll.h:21
s32 offsetY
16.16 fixed-point pixels
Definition map_scroll.h:16
The field map's work: the followed position, screen shake, tile animations, blend script,...
Definition map_scroll.h:27
s32 viewY
the view's top left, 16.16 fixed-point pixels
Definition map_scroll.h:40
u8 unk0fd[3]
not named by TBS code
Definition map_scroll.h:45
struct MapLayerScroll layers[3]
BG3, BG2 and BG1, in that order.
Definition map_scroll.h:49
u8 unk103
MapState's blendControl, the last BLDCNT the blend script set.
Definition map_scroll.h:48
s32 shakeX
Screen shake amplitudes in 16.16 fixed-point pixels, and the 16.16 factor that scales them each frame...
Definition map_scroll.h:33
u16 flags
REG_DISPCNT bits: objects and the BG1 to BG3 shown.
Definition map_scroll.h:35
s8 animationActive
Set while a BG1 animation runs; the tile animations are then neither suspended nor resumed.
Definition map_scroll.h:44
u8 footprints
nonzero: the leader leaves footprints
Definition map_scroll.h:37
u8 * script
set from the layered scene's header; not read by name
Definition map_scroll.h:34
struct BlendScriptState blend
Definition map_scroll.h:39
struct MapAnimation anim[16]
Definition map_scroll.h:38
s32 * origin
The followed point, read as x, height and z in 16.16 fixed-point pixels; Camera_FollowActor points it...
Definition map_scroll.h:30
s32 maxY
16.16 fixed-point pixels
Definition map_scroll.h:41
u8 enabled[3]
Each layer's BG priority, written into its BGCNT; zero hides the layer.
Definition map_scroll.h:47
u8 wideTiles
nonzero: tile animations copy 64-byte tiles
Definition map_scroll.h:36
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
signed char s8
Definition types.h:10
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11