vbe mode query
[bootcensus] / src / test / vbetest.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "video.h"
4 #include "asmops.h"
5 #include "keyb.h"
6
7 static uint16_t *framebuf;
8
9 int vbetest(void)
10 {
11         int i, nmodes;
12         struct video_mode vi;
13
14         nmodes = video_mode_count();
15         printf("%d video modes found:\n", nmodes);
16         for(i=0; i<nmodes; i++) {
17                 if(video_mode_info(i, &vi) == -1) {
18                         continue;
19                 }
20                 printf(" %04x: %dx%d %d bpp (%d%d%d)\n", vi.mode, vi.width, vi.height, vi.bpp,
21                                 vi.rbits, vi.gbits, vi.bbits);
22         }
23
24         if(!(framebuf = set_video_mode(find_video_mode(640, 480, 16)))) {
25                 return -1;
26         }
27
28         memset(framebuf, 0xff, 640 * 240 * 2);
29
30         while(kb_getkey() == -1) {
31                 halt_cpu();
32         }
33
34         set_vga_mode(3);
35         return 0;
36 }