2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2006,2007 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #include <grub/machine/vbeutil.h>
20 #include <grub/types.h>
21 #include <grub/video.h>
24 get_data_ptr (struct grub_video_i386_vbeblit_info
*source
,
25 unsigned int x
, unsigned int y
)
27 grub_uint8_t
*ptr
= 0;
29 switch (source
->mode_info
->bpp
)
32 ptr
= (grub_uint8_t
*)source
->data
33 + y
* source
->mode_info
->pitch
38 ptr
= (grub_uint8_t
*)source
->data
39 + y
* source
->mode_info
->pitch
45 ptr
= (grub_uint8_t
*)source
->data
46 + y
* source
->mode_info
->pitch
51 ptr
= (grub_uint8_t
*)source
->data
52 + y
* source
->mode_info
->pitch
61 get_pixel (struct grub_video_i386_vbeblit_info
*source
,
62 unsigned int x
, unsigned int y
)
64 grub_video_color_t color
= 0;
66 switch (source
->mode_info
->bpp
)
69 color
= *(grub_uint32_t
*)get_data_ptr (source
, x
, y
);
75 ptr
= get_data_ptr (source
, x
, y
);
76 color
= ptr
[0] | (ptr
[1] << 8) | (ptr
[2] << 16);
82 color
= *(grub_uint16_t
*)get_data_ptr (source
, x
, y
);
86 color
= *(grub_uint8_t
*)get_data_ptr (source
, x
, y
);
97 set_pixel (struct grub_video_i386_vbeblit_info
*source
,
98 unsigned int x
, unsigned int y
, grub_video_color_t color
)
100 switch (source
->mode_info
->bpp
)
106 ptr
= (grub_uint32_t
*)get_data_ptr (source
, x
, y
);
115 grub_uint8_t
*colorptr
= (grub_uint8_t
*)&color
;
117 ptr
= get_data_ptr (source
, x
, y
);
119 ptr
[0] = colorptr
[0];
120 ptr
[1] = colorptr
[1];
121 ptr
[2] = colorptr
[2];
130 ptr
= (grub_uint16_t
*)get_data_ptr (source
, x
, y
);
132 *ptr
= (grub_uint16_t
) (color
& 0xFFFF);
140 ptr
= (grub_uint8_t
*)get_data_ptr (source
, x
, y
);
142 *ptr
= (grub_uint8_t
) (color
& 0xFF);