Revision 212
now working
proj/src/sprite.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
3 |
#include "sprite.h" |
|
4 |
|
|
5 |
#include "graph.h" |
|
6 |
|
|
7 |
/// sprite_draw is implemented in graph.c |
|
8 | 0 |
proj/include/graph_macros.h | ||
---|---|---|
20 | 20 |
|
21 | 21 |
// Graphics modes |
22 | 22 |
#define INDEXED_1024_768 0x105 |
23 |
#define DIRECT_640_480 0x110 |
|
24 |
#define DIRECT_800_600 0x115 |
|
23 |
#define DIRECT_640_480_888 0x110 |
|
24 |
#define DIRECT_800_600_888 0x115 |
|
25 |
#define DIRECT_1024_768_888 0x118 |
|
25 | 26 |
#define DIRECT_1280_1024_565 0x11A |
26 | 27 |
#define DIRECT_1280_1024_888 0x11B |
27 | 28 |
#define LINEAR_FRAME_BUFFER_MD BIT(14) |
proj/include/proj_macros.h | ||
---|---|---|
34 | 34 |
#define REFRESH_RATE 60 /** @brief Screen refresh rate */ |
35 | 35 |
|
36 | 36 |
//Graphics mode |
37 |
#define GRAPH_MODE DIRECT_1280_1024_888 /** @brief Graphic mode used */
|
|
38 |
#define MIN_SCALE 0.3 /** @brief Minimum zoom */
|
|
39 |
#define DEFAULT_SCALE 1.0 /** @brief Default zoom */
|
|
40 |
#define MAX_SCALE 10.0 /** @brief Maximum zoom */
|
|
37 |
#define GRAPH_MODE DIRECT_1024_768_888 /** @brief Graphic mode used */
|
|
38 |
#define MIN_SCALE 0.2 /** @brief Minimum zoom */
|
|
39 |
#define DEFAULT_SCALE 0.5 /** @brief Default zoom */
|
|
40 |
#define MAX_SCALE 2.0 /** @brief Maximum zoom */
|
|
41 | 41 |
|
42 | 42 |
#endif /* end of include guard: PROJ_MACROS_H_INCLUDED */ |
proj/src/graph.c | ||
---|---|---|
260 | 260 |
int (graph_draw)(void){ memcpy(video_mem, video_buf, graph_get_vram_size()); return SUCCESS; } |
261 | 261 |
|
262 | 262 |
///SPRITE |
263 |
#include "sprite.h" |
|
264 |
|
|
263 | 265 |
#include "utils.h" |
264 | 266 |
#include "fast_math.h" |
265 | 267 |
#include <math.h> |
... | ... | |
363 | 365 |
const uint8_t *map = basic_sprite_get_map(p->bsp); |
364 | 366 |
const uint16_t bytes_pixel = graph_get_bytes_pixel(); |
365 | 367 |
for(int16_t u, v, y = ymin; y < ymax; ++y){ |
366 |
unsigned pos = (xmin + y*graph_get_XRes())*bytes_pixel;
|
|
367 |
for(int16_t x = xmin; x < xmax; ++x, pos += bytes_pixel){
|
|
368 |
uint8_t *place = video_buf + (xmin + y*graph_get_XRes())*bytes_pixel;
|
|
369 |
for(int16_t x = xmin; x < xmax; ++x, place += bytes_pixel){
|
|
368 | 370 |
sprite_src2pic(p, x, y, &u, &v); |
369 | 371 |
if(0 <= u && u < w && 0 <= v && v < h){ |
370 |
uint32_t c = *(uint32_t*)(map + (v*w + u)*4);
|
|
371 |
if(GET_ALP(c) < 0x7F)
|
|
372 |
graph_set_pixel_pos(pos, c);
|
|
372 |
const uint8_t *c_p = map+(v*w+u)*4;
|
|
373 |
if(*(c_p+3) < 0x7F) //alpha
|
|
374 |
memcpy(place, c_p, bytes_pixel);
|
|
373 | 375 |
} |
374 | 376 |
} |
375 | 377 |
} |
proj/src/proj.c | ||
---|---|---|
109 | 109 |
#endif |
110 | 110 |
|
111 | 111 |
#ifdef TELMO |
112 |
ent_set_scale(2.0);
|
|
112 |
ent_set_scale(1.0);
|
|
113 | 113 |
|
114 | 114 |
gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n"); |
115 | 115 |
gunner_set_pos(shooter1, 0, 0); |
proj/DR.mk | ||
---|---|---|
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 | 4 |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c
|
|
5 |
SRCS= proj.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c |
|
6 | 6 |
|
7 | 7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D DIOGO -D __LCOM_OPTIMIZED_ |
8 | 8 |
|
proj/Makefile | ||
---|---|---|
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 | 4 |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c
|
|
5 |
SRCS= proj.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c |
|
6 | 6 |
|
7 | 7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D __LCOM_OPTIMIZED_ |
8 | 8 |
|
proj/TB.mk | ||
---|---|---|
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 | 4 |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c
|
|
5 |
SRCS= proj.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c |
|
6 | 6 |
|
7 | 7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D TELMO #-D __LCOM_OPTIMIZED_ |
8 | 8 |
|
Also available in: Unified diff