Revision 102
changed indent
lab5/graphics.c | ||
---|---|---|
85 | 85 |
|
86 | 86 |
return SUCCESS; |
87 | 87 |
} |
88 |
|
|
89 |
int (vg_draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color){ |
|
90 |
/* |
|
91 |
uint8_t color8 = color; |
|
92 |
for(uint16_t l = 0; l < len; ++l){ |
|
93 |
*(video_mem+y*1024+x+len) = color8; |
|
94 |
}*/ |
|
95 |
return 0; |
|
96 |
} |
lab5/lab5.c | ||
---|---|---|
11 | 11 |
// Any header files included below this line should have been created by you |
12 | 12 |
|
13 | 13 |
int main(int argc, char *argv[]) { |
14 |
// sets the language of LCF messages (can be either EN-US or PT-PT) |
|
15 |
lcf_set_language("EN-US"); |
|
14 |
// sets the language of LCF messages (can be either EN-US or PT-PT)
|
|
15 |
lcf_set_language("EN-US");
|
|
16 | 16 |
|
17 |
// enables to log function invocations that are being "wrapped" by LCF |
|
18 |
// [comment this out if you don't want/need it] |
|
19 |
lcf_trace_calls("/home/lcom/labs/lab5/trace.txt"); |
|
17 |
// enables to log function invocations that are being "wrapped" by LCF
|
|
18 |
// [comment this out if you don't want/need it]
|
|
19 |
lcf_trace_calls("/home/lcom/labs/lab5/trace.txt");
|
|
20 | 20 |
|
21 |
// enables to save the output of printf function calls on a file |
|
22 |
// [comment this out if you don't want/need it] |
|
23 |
lcf_log_output("/home/lcom/labs/lab5/output.txt"); |
|
21 |
// enables to save the output of printf function calls on a file
|
|
22 |
// [comment this out if you don't want/need it]
|
|
23 |
lcf_log_output("/home/lcom/labs/lab5/output.txt");
|
|
24 | 24 |
|
25 |
// handles control over to LCF |
|
26 |
// [LCF handles command line arguments and invokes the right function] |
|
27 |
if (lcf_start(argc, argv)) |
|
25 |
// handles control over to LCF
|
|
26 |
// [LCF handles command line arguments and invokes the right function]
|
|
27 |
if (lcf_start(argc, argv))
|
|
28 | 28 |
return 1; |
29 | 29 |
|
30 |
// LCF clean up tasks |
|
31 |
// [must be the last statement before return] |
|
32 |
lcf_cleanup(); |
|
30 |
// LCF clean up tasks
|
|
31 |
// [must be the last statement before return]
|
|
32 |
lcf_cleanup();
|
|
33 | 33 |
|
34 |
return 0; |
|
34 |
return 0;
|
|
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
int(video_test_init)(uint16_t mode, uint8_t delay) { |
38 | 38 |
int r; |
39 | 39 |
if ((r = get_permissions_first_mbyte())) |
40 |
panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
|
|
40 |
panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
41 | 41 |
|
42 | 42 |
if (set_graphics_mode(mode)) { |
43 | 43 |
printf("%s: failed to set graphic mode %x.\n", __func__, mode); |
44 | 44 |
if (vg_exit()) |
45 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__);
|
|
45 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
46 | 46 |
return 1; |
47 | 47 |
}; |
48 |
/** |
|
48 |
|
|
49 | 49 |
vbe_mode_info_t vbe_mem_info; |
50 | 50 |
|
51 | 51 |
if (vbe_get_mode_information(mode, &vbe_mem_info)) { |
52 | 52 |
printf("%s: failed to get information for mode %x.\n", __func__, mode); |
53 | 53 |
if (vg_exit()) |
54 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__);
|
|
54 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
55 | 55 |
return 1; |
56 | 56 |
} |
57 | 57 |
|
... | ... | |
59 | 59 |
unsigned int vram_size = vbe_mem_info.XResolution * vbe_mem_info.YResolution * ((vbe_mem_info.BitsPerPixel + 7) >> 3); |
60 | 60 |
|
61 | 61 |
map_vram(vram_base, vram_size); // if function fails it aborts program |
62 |
*/ |
|
62 |
|
|
63 | 63 |
tickdelay(micros_to_ticks(delay*1e6)); |
64 | 64 |
|
65 | 65 |
if (vg_exit()) { |
66 | 66 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
67 |
/*if (free_memory())
|
|
68 |
printf("%s: lm_free failed\n", __func__);*/
|
|
67 |
if (free_memory()) |
|
68 |
printf("%s: lm_free failed\n", __func__);
|
|
69 | 69 |
return 1; |
70 | 70 |
} |
71 |
/* |
|
71 |
|
|
72 | 72 |
if (free_memory()) { |
73 | 73 |
printf("%s: lm_free failed\n", __func__); |
74 | 74 |
return 1; |
75 |
}*/
|
|
75 |
} |
|
76 | 76 |
return 0; |
77 | 77 |
} |
78 | 78 |
|
79 |
int(video_test_rectangle)(uint16_t mode, uint16_t x, uint16_t y, |
|
80 |
uint16_t width, uint16_t height, uint32_t color) { |
|
81 |
/* To be completed */ |
|
82 |
printf("%s(0x%03X, %u, %u, %u, %u, 0x%08x): under construction\n", |
|
83 |
__func__, mode, x, y, width, height, color); |
|
79 |
int(video_test_rectangle)(uint16_t mode, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color) { |
|
80 |
int r; |
|
81 |
if ((r = get_permissions_first_mbyte())) |
|
82 |
panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r); |
|
84 | 83 |
|
85 |
return 1; |
|
84 |
if (set_graphics_mode(mode)) { |
|
85 |
printf("%s: failed to set graphic mode %x.\n", __func__, mode); |
|
86 |
if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
87 |
return 1; |
|
88 |
}; |
|
89 |
|
|
90 |
vg_draw_hline(x, y, width, color); |
|
91 |
tickdelay(micros_to_ticks(1000000)); |
|
92 |
if (vg_exit()) { |
|
93 |
printf("%s: vg_exit failed to exit to text mode.\n", __func__); |
|
94 |
if (free_memory()) printf("%s: lm_free failed\n", __func__); |
|
95 |
return 1; |
|
96 |
} |
|
97 |
return 0; |
|
86 | 98 |
} |
87 | 99 |
|
88 | 100 |
int(video_test_pattern)(uint16_t mode, uint8_t no_rectangles, uint32_t first, uint8_t step) { |
... | ... | |
90 | 102 |
} |
91 | 103 |
|
92 | 104 |
int(video_test_xpm)(xpm_map_t xpm, uint16_t x, uint16_t y) { |
93 |
/* To be completed */ |
|
94 |
printf("%s(%8p, %u, %u): under construction\n", __func__, xpm, x, y); |
|
105 |
/* To be completed */
|
|
106 |
printf("%s(%8p, %u, %u): under construction\n", __func__, xpm, x, y);
|
|
95 | 107 |
|
96 |
return 1; |
|
108 |
return 1;
|
|
97 | 109 |
} |
98 | 110 |
|
99 |
int(video_test_move)(xpm_map_t xpm, uint16_t xi, uint16_t yi, uint16_t xf, uint16_t yf, |
|
100 |
int16_t speed, uint8_t fr_rate) { |
|
101 |
/* To be completed */ |
|
102 |
printf("%s(%8p, %u, %u, %u, %u, %d, %u): under construction\n", |
|
103 |
__func__, xpm, xi, yi, xf, yf, speed, fr_rate); |
|
111 |
int(video_test_move)(xpm_map_t xpm, uint16_t xi, uint16_t yi, uint16_t xf, uint16_t yf, int16_t speed, uint8_t fr_rate) { |
|
112 |
/* To be completed */ |
|
113 |
printf("%s(%8p, %u, %u, %u, %u, %d, %u): under construction\n", |
|
114 |
__func__, xpm, xi, yi, xf, yf, speed, fr_rate); |
|
104 | 115 |
|
105 |
return 1; |
|
116 |
return 1;
|
|
106 | 117 |
} |
107 | 118 |
|
108 | 119 |
int(video_test_controller)() { |
109 |
/* To be completed */ |
|
110 |
printf("%s(): under construction\n", __func__); |
|
120 |
/* To be completed */
|
|
121 |
printf("%s(): under construction\n", __func__);
|
|
111 | 122 |
|
112 |
return 1; |
|
123 |
return 1;
|
|
113 | 124 |
} |
Also available in: Unified diff