11#ifndef GBA_DRIVERS_DISPLAY_OBJ_H
22#define GBA_DRIVERS_DISPLAY_OBJ_H
33
4+ #include < libgba-cpp/arch/display/tilemap.h>
45#include < libgba-cpp/arch/display/video.h>
6+ #include < libgba-cpp/utils/bitset.h>
57
68namespace gba ::display {
79
@@ -20,12 +22,10 @@ enum class ObjectMapping {
2022 MAP_TILE_MATRIX,
2123};
2224
23-
2425/* *
2526 * Object Color Palette array.
2627 */
27- RawPalette<256 >& obj_palette ();
28-
28+ auto obj_palette () -> RawPalette<256>&;
2929
3030/* *
3131 * Changes object mapping mode.
@@ -34,6 +34,108 @@ inline void object_mapping(ObjectMapping map) {
3434 gba::arch::registers::display::lcd_control[6 ] = utils::value_of (map);
3535}
3636
37+ enum class ObjectMode {
38+ NORMAL,
39+ SEMI_TRANSPARENT,
40+ OBJECT_WINDOW,
41+ };
42+
43+ enum class ObjectColorMode {
44+ COLORS_16,
45+ COLORS_256,
46+ };
47+
48+ enum class ObjectShape {
49+ SQUARE,
50+ HORIZONTAL,
51+ VERTICAL,
52+ };
53+
54+ enum class ObjectSize {
55+ TINY,
56+ SMALL,
57+ MEDIUM,
58+ BIG,
59+ };
60+
61+ enum class ObjectPriority {
62+ HIGHEST,
63+ HIGH,
64+ LOW,
65+ LOWEST,
66+ };
67+
68+ struct OAMEntry {
69+ gba::utils::bitset<uint16_t > attr0;
70+ gba::utils::bitset<uint16_t > attr1;
71+ gba::utils::bitset<uint16_t > attr2;
72+ uint16_t _unused;
73+
74+ auto set_x (int y) -> void {
75+ attr1 = (attr1.to_ulong () & ~0b11111111 ) | (y & 0b11111111 );
76+ }
77+
78+ auto set_y (int y) -> void {
79+ attr0 = (attr0.to_ulong () & ~0b11111111 ) | (y & 0b11111111 );
80+ }
81+
82+ auto rotation_scaling (bool enabled) -> void {
83+ attr0[8 ] = enabled;
84+ }
85+
86+ auto visible (bool visible) -> void {
87+ attr0[9 ] = not visible;
88+ }
89+
90+ auto mode (ObjectMode mode) -> void {
91+ attr0 = (attr0.to_ulong () & ~0b110000000000 ) |
92+ (utils::value_of (mode) << 10 );
93+ }
94+
95+ auto mosaic (bool enabled) -> void {
96+ attr0[12 ] = enabled;
97+ }
98+
99+ auto color_mode (ObjectColorMode mode) -> void {
100+ attr0[13 ] = utils::value_of (mode);
101+ }
102+
103+ auto shape (ObjectShape shape) -> void {
104+ attr0 = (attr0.to_ulong () & 0b0011111111111111 ) |
105+ (utils::value_of (shape) << 14 );
106+ }
107+
108+ auto size (ObjectSize size) -> void {
109+ attr1 = (attr1.to_ulong () & 0b0011111111111111 ) |
110+ (utils::value_of (size) << 14 );
111+ }
112+
113+ auto flip_horizontally (bool flip) -> void {
114+ attr1[12 ] = flip;
115+ }
116+
117+ auto flip_vertically (bool flip) -> void {
118+ attr1[13 ] = flip;
119+ }
120+
121+ auto tile (int index) -> void {
122+ attr2 = (attr2.to_ulong () & ~0b111111111 ) | (index & 0b111111111 );
123+ }
124+
125+ auto priority (ObjectPriority priority) -> void {
126+ attr2 = (attr2.to_ulong () & ~0b11000000000 ) |
127+ (utils::value_of (priority) << 10 );
128+ }
129+
130+ auto palette (int index) -> void {
131+ attr2 = (attr2.to_ulong () & ~(0xff << 12 )) | ((index & 0xff ) << 12 );
132+ }
133+ };
134+
135+ auto oam_entry (int index) -> OAMEntry&;
136+
137+ auto sprite_tile (int index) -> gba::display::map::Tile&;
138+
37139}
38140
39141#endif
0 commit comments