|
@@ -1,7 +1,41 @@
|
|
1
|
+/****************************************************************************
|
|
2
|
+ * Copyright (C) 2015-2016 by the SotS Team *
|
|
3
|
+ * *
|
|
4
|
+ * This file is part of Sovereign of the Skies. *
|
|
5
|
+ * *
|
|
6
|
+ * Sovereign of the Skies is free software: you can redistribute it *
|
|
7
|
+ * and/or modify it *
|
|
8
|
+ * under the terms of the GNU Lesser General Public License as published *
|
|
9
|
+ * by the Free Software Foundation, either version 3 of the License, or *
|
|
10
|
+ * (at your option) any later version provided you include a copy of the *
|
|
11
|
+ * licence and this header. *
|
|
12
|
+ * *
|
|
13
|
+ * Sovereign of the Skies is distributed in the hope that it will be *
|
|
14
|
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
15
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
16
|
+ * GNU Lesser General Public License for more details. *
|
|
17
|
+ * *
|
|
18
|
+ * You should have received a copy of the GNU Lesser General Public *
|
|
19
|
+ * License along with Sovereign of the Skies. *
|
|
20
|
+ * If not, see <http://www.gnu.org/licenses/>. *
|
|
21
|
+ ****************************************************************************/
|
|
22
|
+
|
|
23
|
+/**
|
|
24
|
+ * @file lcd.h
|
|
25
|
+ * @author Sturmvogel
|
|
26
|
+ * @date 15 dec 2016
|
|
27
|
+ * @brief Operations on the GBA Screen
|
|
28
|
+ *
|
|
29
|
+ * This header contains methods to manipulate and update the lcd screen,
|
|
30
|
+ * for interacting with the object entity engine
|
|
31
|
+ * @see objects.h
|
|
32
|
+ */
|
|
33
|
+
|
|
34
|
+
|
1
|
35
|
#ifndef LCD_H_
|
2
|
36
|
#define LCD_H_
|
3
|
37
|
|
4
|
|
-#include "objects.h"
|
|
38
|
+/* === STRUCTURES === */
|
5
|
39
|
|
6
|
40
|
struct bg_config {
|
7
|
41
|
u32 id : 2;
|
|
@@ -30,6 +64,8 @@ struct color {
|
30
|
64
|
u16 b : 5;
|
31
|
65
|
};
|
32
|
66
|
|
|
67
|
+/* === STATIC STRUCTURES === */
|
|
68
|
+
|
33
|
69
|
static struct bg_config standard_bg[4] = {
|
34
|
70
|
{0, 0, 0x19, 0, 0, 0},
|
35
|
71
|
{1, 1, 0x1A, 0, 0, 1},
|
|
@@ -37,26 +73,118 @@ static struct bg_config standard_bg[4] = {
|
37
|
73
|
{3, 3, 0x1C, 0, 0, 3}
|
38
|
74
|
};
|
39
|
75
|
|
40
|
|
-u8 gpu_copy_to_vram_by_bgid(u8 bg_id, void* source, u16 byte_size, u16 start_tile, u8 mode);
|
41
|
|
-void gpu_init_bgs();
|
42
|
|
-void gpu_tile_bg_drop_all_sets(u8 bg);
|
43
|
|
-void bg_vram_setup(u8 mirror, struct bg_config* configs, u8 count);
|
44
|
|
-void bg_set_tilemap(u8 bg_id, void* tilemap);
|
45
|
|
-void bg_nullify_tilemap(u8 bg_id);
|
46
|
|
-void* bg_get_tilemap(u8 bg_id);
|
47
|
|
-void bg_send_tilemap(u8 bg_id);
|
48
|
|
-void wram_decompress(void* src, void* dst);
|
49
|
|
-void vram_decompress(void* src, void* dst);
|
|
76
|
+/* === EXTERN METHODS === */
|
|
77
|
+
|
|
78
|
+/**
|
|
79
|
+ * @brief copy tileset or tilemap to bg
|
|
80
|
+ * @param bg_id bg id to copy tileset to
|
|
81
|
+ * @param source tileset source
|
|
82
|
+ * @param byte_size tileset size
|
|
83
|
+ * @param start_tile start tile to copy to
|
|
84
|
+ * @param mode 1 = copy tileset 2 = copy tilemap
|
|
85
|
+ * @return
|
|
86
|
+ */
|
|
87
|
+extern u8 gpu_copy_to_vram_by_bgid(u8 bg_id, void* source, u16 byte_size, u16 start_tile, u8 mode);
|
|
88
|
+
|
|
89
|
+/**
|
|
90
|
+ * @brief reset bg configs and init bgs
|
|
91
|
+ */
|
|
92
|
+extern void gpu_init_bgs();
|
|
93
|
+
|
|
94
|
+/**
|
|
95
|
+ * @brief drop all tilesets from bg ( ? )
|
|
96
|
+ * @param bg background to drop tilesets from
|
|
97
|
+ */
|
|
98
|
+extern void gpu_tile_bg_drop_all_sets(u8 bg);
|
|
99
|
+
|
|
100
|
+/**
|
|
101
|
+ * @setup bg vram
|
|
102
|
+ * @param mirror not so sure about that
|
|
103
|
+ * @param configs pointer to config array (4 entries)
|
|
104
|
+ * @param count number of entries
|
|
105
|
+ */
|
|
106
|
+extern void gpu_bg_vram_setup(u8 mirror, struct bg_config* configs, u8 count);
|
|
107
|
+
|
|
108
|
+/**
|
|
109
|
+ * @brief set tilemap of bg in the bg structure
|
|
110
|
+ * @param bg_id bg to set tilemap for
|
|
111
|
+ * @param tilemap pointer to tilemap
|
|
112
|
+ */
|
|
113
|
+extern void virtual_bg_set_tilemap(u8 bg_id, void* tilemap);
|
|
114
|
+
|
|
115
|
+/**
|
|
116
|
+ * @brief set tilemap of bg to NULL in bg structure
|
|
117
|
+ * @param bg_id bg to set tilemap for
|
|
118
|
+ */
|
|
119
|
+extern void virtual_bg_nullify_tilemap(u8 bg_id);
|
|
120
|
+
|
|
121
|
+/**
|
|
122
|
+ * @brief get tilemap of bg in bg structure
|
|
123
|
+ * @param bg_id bg to get tilemap for
|
|
124
|
+ * @return pointer to tilemap, might be null
|
|
125
|
+ */
|
|
126
|
+extern void* virtual_bg_get_tilemap(u8 bg_id);
|
|
127
|
+
|
|
128
|
+/**
|
|
129
|
+ * @brief sends virtual tilemap to vram
|
|
130
|
+ * @param bg_id bg id to send tilemap for
|
|
131
|
+ */
|
|
132
|
+extern void virtual_bg_send_tilemap(u8 bg_id);
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+/**
|
|
136
|
+ * @brief decompress palette and copy to f/u buffers
|
|
137
|
+ * @param src palette source (lz compressed)
|
|
138
|
+ * @param start palette start (in bytes)
|
|
139
|
+ * @param end palette count (in entries, I think)
|
|
140
|
+ */
|
50
|
141
|
void pal_decompress_slice_to_faded_and_unfaded(void* src, u16 start, u16 end);
|
|
142
|
+
|
|
143
|
+/**
|
|
144
|
+ * @brief show bg
|
|
145
|
+ * @param id bg id
|
|
146
|
+ */
|
51
|
147
|
void gpu_bg_show(u8 id);
|
|
148
|
+
|
|
149
|
+/**
|
|
150
|
+ * @brief hide bg
|
|
151
|
+ * @param id bg id
|
|
152
|
+ */
|
52
|
153
|
void gpu_bg_hide(u8 id);
|
|
154
|
+
|
|
155
|
+/**
|
|
156
|
+ * @brief sync bg visibility and mode, execute during vblank to avoid artifacts
|
|
157
|
+ */
|
53
|
158
|
void gpu_sync_bg_visibility_and_mode();
|
|
159
|
+
|
|
160
|
+/**
|
|
161
|
+ * @brief set I/O
|
|
162
|
+ * @param id device ID
|
|
163
|
+ * @param value value to set I/O device to
|
|
164
|
+ */
|
54
|
165
|
void lcd_io_set_func(u8 id, u16 value);
|
|
166
|
+
|
|
167
|
+/**
|
|
168
|
+ * @brief upload palettes from buffer to palette memory
|
|
169
|
+ */
|
55
|
170
|
void gpu_pal_upload();
|
|
171
|
+
|
|
172
|
+/**
|
|
173
|
+ * @brief free pal tag
|
|
174
|
+ * @param tag tag to free
|
|
175
|
+ */
|
56
|
176
|
void gpu_pal_free_by_tag(u16 tag);
|
57
|
177
|
|
|
178
|
+/**
|
|
179
|
+ * @brief get from I/O
|
|
180
|
+ * @param id device ID
|
|
181
|
+ * @return I/O value
|
|
182
|
+ */
|
58
|
183
|
u16 lcd_io_get(u8 id);
|
59
|
184
|
|
|
185
|
+/* === MACROS AND DEFINES === */
|
|
186
|
+
|
|
187
|
+/* TODO: Implement without macros */
|
60
|
188
|
#define palette_faded_buffer ((struct color*) 0x020375F8)
|
61
|
189
|
#define palette_unfaded_buffer ((struct color*) 0x020371F8)
|
62
|
190
|
|