Revision 124
implemented sprites
lab5/Makefile | ||
---|---|---|
2 | 2 |
PROG=lab5 |
3 | 3 |
|
4 | 4 |
# source code files to be compiled |
5 |
SRCS = lab5.c graphics.c keyboard.c kbc.c utils.c |
|
5 |
SRCS = lab5.c graphics.c keyboard.c kbc.c utils.c sprite.c
|
|
6 | 6 |
|
7 | 7 |
# additional compilation flags |
8 | 8 |
# "-Wall -Wextra -Werror -I . -std=c11 -Wno-unused-parameter" are already set |
9 |
CFLAGS += -pedantic |
|
9 |
CFLAGS += -pedantic -c
|
|
10 | 10 |
|
11 | 11 |
# list of library dependencies (for Lab 2, only LCF library) |
12 | 12 |
DPADD += ${LIBLCF} |
lab5/lab5.c | ||
---|---|---|
5 | 5 |
#include <stdint.h> |
6 | 6 |
#include <stdio.h> |
7 | 7 |
|
8 |
#include "sprite.h" |
|
8 | 9 |
#include "graphics.h" |
9 | 10 |
#include "graphics_macros.h" |
10 | 11 |
#include "keyboard.h" |
... | ... | |
38 | 39 |
} |
39 | 40 |
|
40 | 41 |
int(video_test_init)(uint16_t mode, uint8_t delay) { |
41 |
//int r; |
|
42 |
//if ((r = get_permissions_first_mbyte())) |
|
43 |
// panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
44 | 42 |
|
45 | 43 |
if (vbe_get_mode_information(mode)) { |
46 | 44 |
printf("%s: failed to get information for mode %x.\n", __func__, mode); |
... | ... | |
79 | 77 |
// lcom_run lab5 "rectangle 115 100 100 100 100 FF0000" |
80 | 78 |
int(video_test_rectangle)(uint16_t mode, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color) { |
81 | 79 |
int r; |
82 |
//if ((r = get_permissions_first_mbyte())) |
|
83 |
// panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
84 | 80 |
|
85 | 81 |
if (vbe_get_mode_information(mode)) { |
86 | 82 |
printf("%s: failed to get information for mode %x.\n", __func__, mode); |
... | ... | |
167 | 163 |
|
168 | 164 |
int(video_test_pattern)(uint16_t mode, uint8_t no_rectangles, uint32_t first, uint8_t step) { |
169 | 165 |
int r; |
170 |
//if ((r = get_permissions_first_mbyte())) |
|
171 |
// panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
172 | 166 |
|
173 | 167 |
if (vbe_get_mode_information(mode)) { |
174 | 168 |
printf("%s: failed to get information for mode %x.\n", __func__, mode); |
... | ... | |
270 | 264 |
|
271 | 265 |
int(video_test_xpm)(xpm_map_t xpm, uint16_t x, uint16_t y) { |
272 | 266 |
int r; |
273 |
//if ((r = get_permissions_first_mbyte())) |
|
274 |
// panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
275 | 267 |
|
276 | 268 |
if (vbe_get_mode_information(INDEXED_1024_768)) { |
277 | 269 |
printf("%s: failed to get information for mode %x.\n", __func__, INDEXED_1024_768); |
... | ... | |
288 | 280 |
return 1; |
289 | 281 |
}; |
290 | 282 |
|
291 |
enum xpm_image_type type = XPM_INDEXED; |
|
292 |
xpm_image_t img; |
|
283 |
sprite_t *sp = sprite_ctor(xpm); |
|
284 |
sprite_set_pos(sp, x, y); |
|
285 |
sprite_draw(sp); |
|
293 | 286 |
|
294 |
uint8_t *map = xpm_load(xpm, type, &img); |
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
for (int i = 0; i < img.width; i++) { |
|
299 |
for (int j = 0; j < img.height; j++) { |
|
300 |
set_pixel(x + i, y + j, map[i + j * img.width]); |
|
301 |
} |
|
302 |
} |
|
303 |
|
|
304 | 287 |
/// loop stuff |
305 | 288 |
int ipc_status; |
306 | 289 |
message msg; |
Also available in: Unified diff