Include the video mode list location in the debug messages.
[v86d.git] / testvbe.c
blob544838026707af835621dcf016c2ce1585495f7e
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <errno.h>
6 #include <time.h>
7 #include <fcntl.h>
9 #include "v86.h"
10 #include "testvbe.h"
12 #define reg16(reg) (reg & 0xffff)
13 #define failed(tsk) (reg16(tsk.regs.eax) != 0x004f)
15 int main(int argc, char *argv[])
17 struct uvesafb_task tsk;
18 struct vbe_ib ib;
19 u16 *s;
20 u8 *t;
22 if (v86_init())
23 return -1;
24 tsk.regs.eax = 0x4f00;
25 tsk.flags = TF_VBEIB;
26 tsk.buf_len = sizeof(ib);
27 strncpy((char*)&ib.vbe_signature, "VBE2", 4);
29 v86_task(&tsk, (u8*)&ib);
30 if (failed(tsk)) {
31 fprintf(stderr, "Getting VBE Info Block failed with eax = %.4x\n",
32 reg16(tsk.regs.eax));
33 return -1;
36 t = (u8*)&ib;
38 printf("VBE Version: %x.%.2x\n", ((ib.vbe_version & 0xf00) >> 8), (ib.vbe_version & 0xff));
39 printf("OEM String: %s\n", ib.oem_string_ptr + t);
40 printf("OEM Vendor Name: %s\n", ib.oem_vendor_name_ptr + t);
41 printf("OEM Prod. Name: %s\n", ib.oem_product_name_ptr + t);
42 printf("OEM Prod. Rev: %s\n", ib.oem_product_rev_ptr + t);
44 printf("\n%-6s %-6s mode\n", "ID", "attr");
45 printf("---------------------------\n");
47 for (s = t + ib.mode_list_ptr; *s != 0xffff; s++) {
48 struct vbe_mode_ib mib;
50 tsk.regs.eax = 0x4f01;
51 tsk.regs.ecx = *s;
52 tsk.flags = TF_BUF_RET | TF_BUF_ESDI;
53 tsk.buf_len = sizeof(mib);
55 v86_task(&tsk, (u8*)&mib);
56 if (failed(tsk)) {
57 fprintf(stderr, "Getting Mode Info Block for mode %.4x "
58 "failed with eax = %.4x\n", *s, reg16(tsk.regs.eax));
59 return -1;
62 printf("%-6.4x %-6.4x %dx%d-%d\n", *s, mib.mode_attr,
63 mib.x_res, mib.y_res, mib.bits_per_pixel);
66 v86_cleanup();
68 return 0;