X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fdos%2Fvbe.c;h=72f4b516a4d607a4f62e05c5c6d84134511686b6;hp=622508401e973d78505dd87e6535b1a735ae43eb;hb=282021dce00ae9430184cb033c1e49ba5aa132a1;hpb=05672cb8988cd30a798ea3fbce124695fc76f09c diff --git a/src/dos/vbe.c b/src/dos/vbe.c index 6225084..72f4b51 100644 --- a/src/dos/vbe.c +++ b/src/dos/vbe.c @@ -198,7 +198,7 @@ void vbe_print_mode_info(FILE *fp, struct vbe_mode_info *minf) if(minf->attr & VBE_ATTR_NOTVGA) fprintf(fp, " non-vga"); if(minf->attr & VBE_ATTR_BANKED) fprintf(fp, " banked"); if(minf->attr & VBE_ATTR_LFB) fprintf(fp, " lfb"); - if(minf->attr & VBE_ATTR_2XSCAN) fprintf(fp, " dblscan"); + if(minf->attr & VBE_ATTR_DBLSCAN) fprintf(fp, " dblscan"); if(minf->attr & VBE_ATTR_ILACE) fprintf(fp, " ilace"); if(minf->attr & VBE_ATTR_TRIPLEBUF) fprintf(fp, " trplbuf"); if(minf->attr & VBE_ATTR_STEREO) fprintf(fp, " stereo"); @@ -206,3 +206,45 @@ void vbe_print_mode_info(FILE *fp, struct vbe_mode_info *minf) fprintf(fp, " ]\n"); fflush(fp); } + +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; +}