Revision 159
working
proj/DR.mk | ||
---|---|---|
2 | 2 |
|
3 | 3 |
SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c |
4 | 4 |
|
5 |
CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_ -D DIOGO
|
|
5 |
CPPFLAGS += -pedantic -D DIOGO # -D __LCOM_OPTIMIZED_
|
|
6 | 6 |
|
7 | 7 |
DPADD += ${LIBLCF} |
8 | 8 |
LDADD += -llcf |
proj/proj.c | ||
---|---|---|
12 | 12 |
#include "proj_macros.h" |
13 | 13 |
#include "errors.h" |
14 | 14 |
|
15 |
#include "sprite.h" |
|
15 | 16 |
#include "kbc.h" |
16 | 17 |
#include "graphics.h" |
17 | 18 |
#include "timer.h" |
... | ... | |
58 | 59 |
return 1; |
59 | 60 |
}; |
60 | 61 |
|
62 |
#ifdef DIOGO |
|
63 |
sprite_t *sp = sprite_ctor((xpm_map_t)plus_xpm); |
|
64 |
sprite_draw(sp); |
|
65 |
#endif |
|
61 | 66 |
|
62 | 67 |
/// loop stuff |
63 | 68 |
int ipc_status, r; |
proj/proj_macros.h | ||
---|---|---|
19 | 19 |
#define REFRESH_RATE 60 /** @brief Screen refresh rate */ |
20 | 20 |
|
21 | 21 |
//Graphics mode |
22 |
#define GRAPH_MODE DIRECT_1280_1024_888 /** @brief Graphic mode used */
|
|
22 |
#define GRAPH_MODE DIRECT_800_600 /** @brief Graphic mode used */
|
|
23 | 23 |
|
24 | 24 |
#endif /* end of include guard: PROJ_MACROS_H_INCLUDED */ |
proj/sprite.c | ||
---|---|---|
13 | 13 |
sprite_t* sprite_ctor(const xpm_map_t xpm){ |
14 | 14 |
sprite_t *ret = (sprite_t*)malloc(sizeof(sprite_t)); |
15 | 15 |
if(ret == NULL) return NULL; |
16 |
enum xpm_image_type type = XPM_INDEXED;
|
|
16 |
enum xpm_image_type type = XPM_8_8_8;
|
|
17 | 17 |
xpm_image_t img; |
18 | 18 |
ret->map = xpm_load(xpm, type, &img); |
19 | 19 |
if(ret->map == NULL){ |
20 | 20 |
free(ret); |
21 | 21 |
return NULL; |
22 | 22 |
} |
23 |
ret->x = 0; |
|
24 |
ret->y = 0; |
|
23 | 25 |
ret->w = img.width; |
24 | 26 |
ret->h = img.height; |
25 | 27 |
return ret; |
... | ... | |
42 | 44 |
int sprite_get_h(const sprite_t *p){ return p->h; } |
43 | 45 |
|
44 | 46 |
void sprite_draw(const sprite_t *p){ |
47 |
uint8_t *m = p->map; |
|
45 | 48 |
for (int i = 0; i < p->w; i++) { |
46 |
for (int j = 0; j < p->h; j++) { |
|
47 |
if (p->x + i < get_XRes() && p->y + j < get_YRes()) { |
|
48 |
set_pixel(p->x + i, p->y + j, p->map[i + j * p->w]); |
|
49 |
for (int j = 0; j < p->h; j++, m += 3) { |
|
50 |
if (p->x + i < get_XRes() && p->y + j < get_YRes()){ |
|
51 |
uint32_t color = SET_COLOR(*m,*(m+1),*(m+2)); |
|
52 |
set_pixel(p->x + i, p->y + j, color); |
|
49 | 53 |
} |
50 | 54 |
} |
51 | 55 |
} |
Also available in: Unified diff