Revision 105
set pixel function
lab5/errors.h | ||
---|---|---|
13 | 13 |
INVALID_COMMAND, /* @brief Invalid Command issued */ |
14 | 14 |
INVALID_STATE, /* @brief State machine reached an invalid state */ |
15 | 15 |
BIOS_CALL_ERROR, /* @brief Error upon BIOS call */ |
16 |
OUT_OF_RANGE, |
|
16 | 17 |
OTHER_ERROR /* @brief Unspecified error */ |
17 | 18 |
}; |
18 | 19 |
|
lab5/graphics.c | ||
---|---|---|
69 | 69 |
return vbe_mem_info.BitsPerPixel; |
70 | 70 |
} |
71 | 71 |
|
72 |
uint16_t get_bytes_pixel(void) { |
|
73 |
return (vbe_mem_info.BitsPerPixel + 7) >> 3; |
|
74 |
} |
|
75 |
|
|
72 | 76 |
int (map_vram)(void) { |
73 | 77 |
int r; |
74 | 78 |
unsigned int vram_base = get_phys_addr(); |
... | ... | |
88 | 92 |
return !lm_free(&mem_map); |
89 | 93 |
} |
90 | 94 |
|
95 |
int (set_pixel)(uint16_t row, uint16_t col, uint32_t color) { |
|
96 |
if (row >= vbe_mem_info.XResolution || col >= vbe_mem_info.YResolution) { |
|
97 |
printf("%s: invalid pixel.\n", __func__); |
|
98 |
return OUT_OF_RANGE; |
|
99 |
} |
|
100 |
unsigned int pos = (row + col * vbe_mem_info.XResolution) * get_bytes_pixel(); |
|
101 |
memcpy((void*)(video_mem + pos), &color, get_bytes_pixel()); |
|
102 |
return SUCCESS; |
|
103 |
} |
|
104 |
|
|
91 | 105 |
int (set_graphics_mode)(uint16_t mode) { |
92 | 106 |
struct reg86 reg_86; |
93 | 107 |
|
lab5/graphics.h | ||
---|---|---|
20 | 20 |
|
21 | 21 |
uint16_t get_bits_pixel(void); |
22 | 22 |
|
23 |
uint16_t get_bytes_pixel(void); |
|
24 |
|
|
23 | 25 |
int (map_vram)(void); |
24 | 26 |
|
25 | 27 |
int (free_memory)(void); |
26 | 28 |
|
29 |
int (set_pixel)(uint16_t row, uint16_t col, uint32_t color); |
|
30 |
|
|
27 | 31 |
/** |
28 | 32 |
* @brief |
29 | 33 |
* @param mode |
Also available in: Unified diff