Revision 333
more changes, added docs
proj/include/proj_func.h | ||
---|---|---|
2 | 2 |
#define PROJ_FUNC_H_INCLUDED |
3 | 3 |
|
4 | 4 |
#include "ent.h" |
5 |
#include "font.h"
|
|
5 |
#include "text.h"
|
|
6 | 6 |
#include "proj_structures.h" |
7 | 7 |
|
8 | 8 |
#include <stdint.h> |
proj/libs/graph/include/basic_sprite.h | ||
---|---|---|
10 | 10 |
* |
11 | 11 |
* @{ |
12 | 12 |
*/ |
13 |
struct basic_sprite; |
|
14 | 13 |
typedef struct basic_sprite basic_sprite_t; |
15 | 14 |
|
15 |
/** |
|
16 |
* @brief Construct basic sprite. |
|
17 |
* @param xpm XPM array to build the basic sprite from |
|
18 |
* @param u0 X-center of the XPM. |
|
19 |
* @param v0 Y-center of the XPM. |
|
20 |
* @return Pointer to created basic_sprite_t, or NULL if fails |
|
21 |
*/ |
|
16 | 22 |
basic_sprite_t* (basic_sprite_ctor)(const char *const *xpm, int16_t u0, int16_t v0); |
23 |
/** |
|
24 |
* @brief Destruct basic sprite. |
|
25 |
* @param p Pointer to basic sprite to destruct. |
|
26 |
*/ |
|
17 | 27 |
void (basic_sprite_dtor)(basic_sprite_t *p); |
28 |
/** |
|
29 |
* @brief Get basic sprite map (pixels). |
|
30 |
* @param p Pointer to basic sprite |
|
31 |
* @return Pixel map |
|
32 |
*/ |
|
18 | 33 |
const uint8_t* (basic_sprite_get_map)(const basic_sprite_t *p); |
34 |
/** |
|
35 |
* @brief Get width. |
|
36 |
* @param p Pointer to basic sprite |
|
37 |
* @return Width |
|
38 |
*/ |
|
19 | 39 |
uint16_t (basic_sprite_get_w) (const basic_sprite_t *p); |
40 |
/** |
|
41 |
* @brief Get height. |
|
42 |
* @param p Pointer to basic sprite |
|
43 |
* @return Height |
|
44 |
*/ |
|
20 | 45 |
uint16_t (basic_sprite_get_h) (const basic_sprite_t *p); |
46 |
/** |
|
47 |
* @brief Get X-center of the basic sprite. |
|
48 |
* @param p Pointer to basic sprite |
|
49 |
* @return X-center |
|
50 |
*/ |
|
21 | 51 |
int16_t (basic_sprite_get_u0) (const basic_sprite_t *p); |
52 |
/** |
|
53 |
* @brief Get Y-center of the basic sprite. |
|
54 |
* @param p Pointer to basic sprite |
|
55 |
* @return Y-center |
|
56 |
*/ |
|
22 | 57 |
int16_t (basic_sprite_get_v0) (const basic_sprite_t *p); |
23 | 58 |
|
24 | 59 |
/** |
proj/libs/graph/include/font.h | ||
---|---|---|
1 | 1 |
#ifndef FONT_H_INCLUDED |
2 | 2 |
#define FONT_H_INCLUDED |
3 | 3 |
|
4 |
struct font; |
|
5 | 4 |
/** |
6 |
* @brief Font. Represents a set of glyphs that can be drawn for showing text. |
|
5 |
* @defgroup font_t font_t |
|
6 |
* @ingroup graph |
|
7 |
* @brief Font module. |
|
8 |
* |
|
9 |
* Represents a set of glyphs that can be drawn for showing text. |
|
10 |
* |
|
11 |
* @{ |
|
7 | 12 |
*/ |
13 |
|
|
14 |
/** |
|
15 |
* @brief Font. |
|
16 |
*/ |
|
8 | 17 |
typedef struct font font_t; |
9 | 18 |
/** |
10 | 19 |
* @brief Construct font. |
... | ... | |
48 | 57 |
void (font_free)(void); |
49 | 58 |
|
50 | 59 |
/** |
51 |
* @brief Enumeration of vertical alignment schemes.
|
|
60 |
* @}
|
|
52 | 61 |
*/ |
53 |
typedef enum{ |
|
54 |
text_valign_top = -1, |
|
55 |
text_valign_center = 0, |
|
56 |
text_valign_bottom = 1 |
|
57 |
} text_valign; |
|
58 |
/** |
|
59 |
* @brief Enumeration of horizontal alignment schemes. |
|
60 |
*/ |
|
61 |
typedef enum{ |
|
62 |
text_halign_left = -1, |
|
63 |
text_halign_center = 0, |
|
64 |
text_halign_right = 1 |
|
65 |
} text_halign; |
|
66 | 62 |
|
67 |
struct text; |
|
68 |
/** |
|
69 |
* @brief Drawable text. |
|
70 |
*/ |
|
71 |
typedef struct text text_t; |
|
72 |
/** |
|
73 |
* @brief Construct text. |
|
74 |
* @param fnt Font to draw the text |
|
75 |
* @param txt String to be drawn |
|
76 |
* @return Pointer to constructed text |
|
77 |
*/ |
|
78 |
text_t* (text_ctor)(const font_t *fnt, const char *txt); |
|
79 |
/** |
|
80 |
* @brief Destruct text. |
|
81 |
* @param p Pointer to text to be destroyed |
|
82 |
*/ |
|
83 |
void (text_dtor)(text_t *p); |
|
84 |
/** |
|
85 |
* @brief Set text string. |
|
86 |
* @param p Pointer to text |
|
87 |
* @param txt String to be set |
|
88 |
*/ |
|
89 |
void (text_set_string)(text_t *p, const char *txt); |
|
90 |
/** |
|
91 |
* @brief Set text position. |
|
92 |
* @param p Pointer to text |
|
93 |
* @param x X-position of the text |
|
94 |
* @param y Y-position of the text |
|
95 |
*/ |
|
96 |
void (text_set_pos) (text_t *p, int16_t x, int16_t y); |
|
97 |
/** |
|
98 |
* @brief Set text size (letter size, in pixels). |
|
99 |
* @param p Pointer to text |
|
100 |
* @param size Letter size of the text |
|
101 |
*/ |
|
102 |
void (text_set_size) (text_t *p, uint16_t size); |
|
103 |
/** |
|
104 |
* @brief Set text color. |
|
105 |
* @param p Pointer to text |
|
106 |
* @param color Text color |
|
107 |
*/ |
|
108 |
void (text_set_color) (text_t *p, uint32_t color); |
|
109 |
/** |
|
110 |
* @brief Set text vertical alignment. |
|
111 |
* @param p Pointer to text |
|
112 |
* @param valign Vertical alignment of the text |
|
113 |
*/ |
|
114 |
void (text_set_valign)(text_t *p, text_valign valign); |
|
115 |
/** |
|
116 |
* @brief Set text horizontal alignment. |
|
117 |
* @param p Pointer to text |
|
118 |
* @param halign Horizontal alignment of the text |
|
119 |
*/ |
|
120 |
void (text_set_halign)(text_t *p, text_halign halign); |
|
121 |
/** |
|
122 |
* @brief Get string of the text. |
|
123 |
* @param p Pointer to text |
|
124 |
* @return Pointer to string |
|
125 |
*/ |
|
126 |
const char* (text_get_string)(const text_t *p); |
|
127 |
/** |
|
128 |
* @brief Get text x-position. |
|
129 |
* @param p Pointer to text |
|
130 |
* @return X-position of text |
|
131 |
*/ |
|
132 |
int16_t (text_get_x) (const text_t *p); |
|
133 |
/** |
|
134 |
* @brief Get text y-position. |
|
135 |
* @param p Pointer to text |
|
136 |
* @return Y-position of text |
|
137 |
*/ |
|
138 |
int16_t (text_get_y) (const text_t *p); |
|
139 |
/** |
|
140 |
* @brief Draw text on the screen buffer. |
|
141 |
* @param p Pointer to text |
|
142 |
* @return SUCCESS if operation was successful, false otherwise |
|
143 |
*/ |
|
144 |
int (text_draw) (const text_t *p); |
|
145 |
|
|
146 | 63 |
#endif //FONT_H_INCLUDED |
proj/libs/graph/include/graph.h | ||
---|---|---|
17 | 17 |
#define DIRECT_1024_768_888 0x118 |
18 | 18 |
#define DIRECT_1280_1024_565 0x11A |
19 | 19 |
#define DIRECT_1280_1024_888 0x11B |
20 |
#define LINEAR_FRAME_BUFFER_MD BIT(14) |
|
21 | 20 |
|
22 | 21 |
// Colors in RBG (8 bit) |
23 | 22 |
#define GRAPH_BLACK 0x000000 |
... | ... | |
28 | 27 |
// Alpha |
29 | 28 |
#define ALPHA_THRESHOLD 0x7F |
30 | 29 |
|
31 |
// MACROS |
|
32 |
#define GET_ALP(n) (0xFF & ((n) >> 24)) |
|
33 |
#define GET_RED(n) (0xFF & ((n) >> 16)) |
|
34 |
#define GET_GRE(n) (0xFF & ((n) >> 8)) |
|
35 |
#define GET_BLU(n) (0xFF & (n )) |
|
36 |
#define GET_COLOR(n) (0xFFFFFF & (n)) |
|
37 |
#define SET_ALP(n) (((n)&0xFF) << 24) |
|
38 |
#define SET_RED(n) (((n)&0xFF) << 16) |
|
39 |
#define SET_GRE(n) (((n)&0xFF) << 8) |
|
40 |
#define SET_BLU(n) (((n)&0xFF) ) |
|
41 |
#define SET_RGB(r,g,b) (SET_RED(r) | SET_GRE(g) | SET_BLU(b)) |
|
42 |
|
|
43 | 30 |
/** |
44 | 31 |
* @brief Initialize graphics. |
45 | 32 |
* @param mode Graphics mode to use |
... | ... | |
88 | 75 |
*/ |
89 | 76 |
void (graph_set_pixel_pos) (unsigned pos , uint32_t color); |
90 | 77 |
|
91 |
// SCREEN |
|
78 |
/** |
|
79 |
* @brief Clear screen, painting it black. |
|
80 |
* @return SUCCESS if operation was successful, other value otherwise |
|
81 |
*/ |
|
92 | 82 |
int (graph_clear_screen)(void); |
93 | 83 |
|
94 |
// DRAW |
|
84 |
/** |
|
85 |
* @brief Draw everything on the buffer to the screen. |
|
86 |
* @return SUCCESS if operation was successful, other value otherwise |
|
87 |
*/ |
|
95 | 88 |
int (graph_draw)(void); |
96 | 89 |
|
97 | 90 |
/** |
proj/libs/graph/include/menu.h | ||
---|---|---|
1 | 1 |
#ifndef MENU_H_INCLUDED |
2 | 2 |
#define MENU_H_INCLUDED |
3 | 3 |
|
4 |
/** |
|
5 |
* @defgroup menu_t menu_t |
|
6 |
* @ingroup graph |
|
7 |
* @brief Menu module |
|
8 |
* |
|
9 |
* Allows to create flexible and responsive menus. |
|
10 |
* |
|
11 |
* @{ |
|
12 |
*/ |
|
13 |
|
|
4 | 14 |
#include "font.h" |
5 | 15 |
|
6 | 16 |
typedef struct menu menu_t; |
... | ... | |
15 | 25 |
|
16 | 26 |
void (menu_dtor)(menu_t *p); |
17 | 27 |
|
28 |
/** |
|
29 |
* @} |
|
30 |
*/ |
|
31 |
|
|
18 | 32 |
#endif //MENU_H_INCLUDED |
proj/libs/graph/include/rectangle.h | ||
---|---|---|
1 | 1 |
#ifndef RECTANGLE_H_INCLUDED |
2 | 2 |
#define RECTANGLE_H_INCLUDED |
3 | 3 |
|
4 |
struct rectangle; |
|
4 |
/** |
|
5 |
* @defgroup rectangle_t rectangle_t |
|
6 |
* @ingroup graph |
|
7 |
* @brief Rectangle module. |
|
8 |
* |
|
9 |
* @{ |
|
10 |
*/ |
|
11 |
|
|
5 | 12 |
typedef struct rectangle rectangle_t; |
6 | 13 |
|
7 | 14 |
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h); |
... | ... | |
22 | 29 |
|
23 | 30 |
void (rectangle_draw)(const rectangle_t *p); |
24 | 31 |
|
32 |
/** |
|
33 |
* @} |
|
34 |
*/ |
|
35 |
|
|
25 | 36 |
#endif //RECTANGLE_H_INCLUDED |
proj/libs/graph/include/sprite.h | ||
---|---|---|
13 | 13 |
|
14 | 14 |
#include "basic_sprite.h" |
15 | 15 |
|
16 |
struct sprite; |
|
17 | 16 |
typedef struct sprite sprite_t; |
18 | 17 |
|
18 |
/** |
|
19 |
* @brief Construct sprite. |
|
20 |
* @param bsp Basic sprite from which to build the sprite |
|
21 |
* @return Pointer to constructed sprite, or NULL if failed |
|
22 |
*/ |
|
19 | 23 |
sprite_t* (sprite_ctor)(const basic_sprite_t *bsp); |
20 |
/* |
|
21 |
* /!\ WARNING: Entity destructor does not destruct the basic_sprite passed as |
|
22 |
* constructor arguments, since it is assumed the same basic_sprite may be used to |
|
23 |
* draw several sprites. It is thus YOUR responsibility to delete basic_sprite's. |
|
24 |
/** |
|
25 |
* @brief Destruct sprite. |
|
26 |
* |
|
27 |
* |
|
28 |
* @attention Destructor does not destruct the basic sprite passed as |
|
29 |
* constructor argument, since it is assumed the same basic sprite may be used to |
|
30 |
* draw several sprites. It is thus YOUR responsibility to delete basic sprites. |
|
24 | 31 |
* @param p Pointer to sprite_t to be destructed |
25 | 32 |
*/ |
26 | 33 |
void (sprite_dtor)(sprite_t *p); |
27 |
|
|
34 |
/** |
|
35 |
* @brief Set sprite position. |
|
36 |
* @param p Pointer to sprite |
|
37 |
* @param x X-position in map |
|
38 |
* @param y Y-position in map |
|
39 |
*/ |
|
28 | 40 |
void (sprite_set_pos) (sprite_t *p, int16_t x, int16_t y); |
29 |
void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0); |
|
41 |
/** |
|
42 |
* @brief Set sprite angle. |
|
43 |
* |
|
44 |
* If not provided, will be drawn with angle 0, corresponding to the same |
|
45 |
* orientation as the original image. |
|
46 |
* @param p Pointer to sprite |
|
47 |
* @param angle Angle in radians, counterclockwise positive and 0 on positive x-axis |
|
48 |
*/ |
|
30 | 49 |
void (sprite_set_angle) (sprite_t *p, double angle); |
50 |
/** |
|
51 |
* @brief Set sprite scale. |
|
52 |
* |
|
53 |
* Default scale is 1, corresponding to original image scale. |
|
54 |
* @param p Pointer to sprite |
|
55 |
* @param scale Scale, greater than 0 |
|
56 |
*/ |
|
31 | 57 |
void (sprite_set_scale) (sprite_t *p, double scale); |
32 |
|
|
33 |
int16_t (sprite_get_x)(const sprite_t *p); |
|
34 |
int16_t (sprite_get_y)(const sprite_t *p); |
|
58 |
/** |
|
59 |
* @brief Get sprite angle. |
|
60 |
* @param p Pointer to sprite |
|
61 |
* @return Sprite angle |
|
62 |
*/ |
|
35 | 63 |
double (sprite_get_angle)(const sprite_t *p); |
64 |
/** |
|
65 |
* @brief Get sprite width (same as the underlying basic sprite). |
|
66 |
* @param p Pointer to sprite |
|
67 |
* @return Sprite width |
|
68 |
*/ |
|
36 | 69 |
uint16_t (sprite_get_w)(const sprite_t *p); |
70 |
/** |
|
71 |
* @brief Get sprite height (same as the underlying basic sprite). |
|
72 |
* @param p Pointer to sprite |
|
73 |
* @return Sprite height |
|
74 |
*/ |
|
37 | 75 |
uint16_t (sprite_get_h)(const sprite_t *p); |
38 |
|
|
76 |
/** |
|
77 |
* @brief Draw sprite in buffer. |
|
78 |
* @param p Pointer to sprite |
|
79 |
*/ |
|
39 | 80 |
void (sprite_draw)(const sprite_t *p); |
40 | 81 |
|
41 | 82 |
/** |
proj/libs/graph/src/font.c | ||
---|---|---|
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
/// TEXT |
136 |
#include "text.h" |
|
137 |
|
|
136 | 138 |
struct text{ |
137 | 139 |
const font_t *fnt; |
138 | 140 |
char *txt; |
proj/libs/graph/src/graph.c | ||
---|---|---|
11 | 11 |
#define MBYTE_BASE 0x0 /** @brief Base address (zero address) */ |
12 | 12 |
#define MBYTE_SIZE 0xFFFFF /** @brief Size of a mebibyte */ |
13 | 13 |
|
14 |
#define LINEAR_FRAME_BUFFER_MD BIT(14) |
|
15 |
|
|
14 | 16 |
// Graphics Functions |
15 | 17 |
#define VBE_CTRL_INFO 0x00 /** @brief Get VBE Controller Information */ |
16 | 18 |
#define VBE_MD_INFO 0x01 /** @brief Get VBE Mode Information */ |
... | ... | |
350 | 352 |
} |
351 | 353 |
} |
352 | 354 |
} |
353 |
int16_t (sprite_get_x)(const sprite_t *p){ return p->x; } |
|
354 |
int16_t (sprite_get_y)(const sprite_t *p){ return p->y; } |
|
355 | 355 |
double (sprite_get_angle)(const sprite_t *p){ return p->theta; } |
356 | 356 |
uint16_t (sprite_get_w)(const sprite_t *p){ return basic_sprite_get_w(p->bsp); } |
357 | 357 |
uint16_t (sprite_get_h)(const sprite_t *p){ return basic_sprite_get_h(p->bsp); } |
proj/src/ent.c | ||
---|---|---|
6 | 6 |
#include "sprite.h" |
7 | 7 |
#include "utils.h" |
8 | 8 |
#include "rectangle.h" |
9 |
#include "font.h"
|
|
9 |
#include "text.h"
|
|
10 | 10 |
#include "errors.h" |
11 | 11 |
#include "queue.h" |
12 | 12 |
#include <math.h> |
proj/Doxyfile | ||
---|---|---|
2265 | 2265 |
# The default value is: YES. |
2266 | 2266 |
# This tag requires that the tag HAVE_DOT is set to YES. |
2267 | 2267 |
|
2268 |
COLLABORATION_GRAPH = NO
|
|
2268 |
COLLABORATION_GRAPH = YES
|
|
2269 | 2269 |
|
2270 | 2270 |
# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for |
2271 | 2271 |
# groups, showing the direct groups dependencies. |
... | ... | |
2331 | 2331 |
# The default value is: NO. |
2332 | 2332 |
# This tag requires that the tag HAVE_DOT is set to YES. |
2333 | 2333 |
|
2334 |
CALL_GRAPH = NO
|
|
2334 |
CALL_GRAPH = YES
|
|
2335 | 2335 |
|
2336 | 2336 |
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller |
2337 | 2337 |
# dependency graph for every global function or class method. |
... | ... | |
2343 | 2343 |
# The default value is: NO. |
2344 | 2344 |
# This tag requires that the tag HAVE_DOT is set to YES. |
2345 | 2345 |
|
2346 |
CALLER_GRAPH = NO
|
|
2346 |
CALLER_GRAPH = YES
|
|
2347 | 2347 |
|
2348 | 2348 |
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical |
2349 | 2349 |
# hierarchy of all classes instead of a textual one. |
... | ... | |
4759 | 4759 |
# The default value is: YES. |
4760 | 4760 |
# This tag requires that the tag HAVE_DOT is set to YES. |
4761 | 4761 |
|
4762 |
COLLABORATION_GRAPH = NO
|
|
4762 |
COLLABORATION_GRAPH = YES
|
|
4763 | 4763 |
|
4764 | 4764 |
# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for |
4765 | 4765 |
# groups, showing the direct groups dependencies. |
... | ... | |
4825 | 4825 |
# The default value is: NO. |
4826 | 4826 |
# This tag requires that the tag HAVE_DOT is set to YES. |
4827 | 4827 |
|
4828 |
CALL_GRAPH = NO
|
|
4828 |
CALL_GRAPH = YES
|
|
4829 | 4829 |
|
4830 | 4830 |
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller |
4831 | 4831 |
# dependency graph for every global function or class method. |
... | ... | |
4837 | 4837 |
# The default value is: NO. |
4838 | 4838 |
# This tag requires that the tag HAVE_DOT is set to YES. |
4839 | 4839 |
|
4840 |
CALLER_GRAPH = NO
|
|
4840 |
CALLER_GRAPH = YES
|
|
4841 | 4841 |
|
4842 | 4842 |
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical |
4843 | 4843 |
# hierarchy of all classes instead of a textual one. |
Also available in: Unified diff