X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fdos%2Fvbe.c;fp=src%2Fdos%2Fvbe.c;h=05a5883b25c4e5a8b2d6739db9667c2151cd6c08;hp=3ada182faa32171e2dd97f2e0225c043b2aba781;hb=93f68e445b0a4f10f2b15383aafed8a216a4a228;hpb=1329933c9afad7e3d0a7ce1f9839910706672f00 diff --git a/src/dos/vbe.c b/src/dos/vbe.c index 3ada182..05a5883 100644 --- a/src/dos/vbe.c +++ b/src/dos/vbe.c @@ -29,10 +29,10 @@ static int cur_pitch; int vbe_info(struct vbe_info *info) { - int i, num; void *lowbuf; uint16_t seg, sel; uint16_t *modeptr; + uint32_t offs; struct dpmi_regs regs = {0}; assert(sizeof *info == 512); @@ -63,7 +63,23 @@ int vbe_info(struct vbe_info *info) FIXPTR(info->product); FIXPTR(info->revstr); FIXPTR(info->modes); - FIXPTR(info->accel_modes); + /* implementations without the accel capability, will use the space taken + * by the accel_modes pointer for other data (probably video modes). We + * need to check for the capability before "fixing" this pointer, otherwise + * we'll shuffle random data. + */ + if(info->caps & VBE_ACCEL) { + FIXPTR(info->accel_modes); + } + + /* info->modes should be pointing somewhere at the end of the original + * low memory buffer. make it point at the same offset in the info + * buffer where we copied everything instead. + */ + offs = (char*)info->modes - (char*)lowbuf; + if(offs < sizeof *info) { /* this should always be true */ + info->modes = (uint16_t*)((char*)info + offs); + } modeptr = info->modes; while(*modeptr != 0xffff) { @@ -96,7 +112,6 @@ int vbe_num_modes(struct vbe_info *info) int vbe_mode_info(int mode, struct vbe_mode_info *minf) { - int i, num; void *lowbuf; uint16_t seg, sel; struct dpmi_regs regs = {0}; @@ -191,6 +206,8 @@ void vbe_print_mode_info(FILE *fp, struct vbe_mode_info *minf) if(minf->attr & VBE_ATTR_LFB) { fprintf(fp, " lfb@%lx", (unsigned long)minf->fb_addr); + } else { + fprintf(fp, " %xkb/bank", (unsigned int)minf->bank_size); } fprintf(fp, " [");