+
+int vbe_setmode(uint16_t mode)
+{
+ struct dpmi_regs regs = {0};
+
+ regs.eax = 0x4f02;
+ regs.ebx = mode;
+ dpmi_int(0x10, ®s);
+
+ if((regs.eax & 0xffff) != 0x4f) {
+ return -1;
+ }
+ return 0;
+}
+
+int vbe_setmode_crtc(uint16_t mode, struct vbe_crtc_info *crtc)
+{
+ void *lowbuf;
+ uint16_t seg, sel;
+ struct dpmi_regs regs = {0};
+
+ assert(sizeof *crtc == 59);
+
+ if(!(seg = dpmi_alloc((sizeof *crtc + 15) / 16, &sel))) {
+ return -1;
+ }
+ lowbuf = (void*)((uint32_t)seg << 4);
+
+ memcpy(lowbuf, crtc, sizeof *crtc);
+
+ regs.eax = 0x4f02;
+ regs.ebx = mode;
+ regs.es = seg;
+ dpmi_int(0x10, ®s);
+
+ dpmi_free(sel);
+
+ if((regs.eax & 0xffff) != 0x4f) {
+ return -1;
+ }
+ return 0;
+}