VBE fix: wrong bpp reported (24) with 32bpp modes
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 18 May 2021 23:44:30 +0000 (02:44 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 18 May 2021 23:44:30 +0000 (02:44 +0300)
src/dos/gfx.c
src/dos/main.c

index c8444aa..c686e35 100644 (file)
@@ -13,7 +13,7 @@
 
 void (*blit_frame)(void*, int);
 
-int resizefb(int x, int y, int bpp);
+int resizefb(int x, int y, int bpp, int pitch);
 
 static void blit_frame_lfb(void *pixels, int vsync);
 static void blit_frame_banked(void *pixels, int vsync);
@@ -86,7 +86,7 @@ int init_video(void)
                        vmptr->rmask = calc_mask(minf.rsize, minf.rpos);
                        vmptr->gmask = calc_mask(minf.gsize, minf.gpos);
                        vmptr->bmask = calc_mask(minf.bsize, minf.bpos);
-                       vmptr->bpp = vmptr->rbits + vmptr->gbits + vmptr->bbits;
+                       /*vmptr->bpp = vmptr->rbits + vmptr->gbits + vmptr->bbits;*/
                }
                if(minf.attr & VBE_ATTR_LFB) {
                        vmptr->fb_addr = minf.fb_addr;
@@ -230,7 +230,7 @@ void *set_video_mode(int idx, int nbuf)
        }
 
        /* allocate main memory framebuffer */
-       if(resizefb(vm->xsz, vm->ysz, vm->bpp) == -1) {
+       if(resizefb(vm->xsz, vm->ysz, vm->bpp, vm->pitch) == -1) {
                fprintf(stderr, "failed to allocate %dx%d (%d bpp) framebuffer\n", vm->xsz,
                                vm->ysz, vm->bpp);
                set_text_mode();
index 761dd56..f048366 100644 (file)
@@ -74,14 +74,16 @@ end:
        return 0;
 }
 
-int resizefb(int x, int y, int bpp)
+int resizefb(int x, int y, int bpp, int pitch)
 {
+       printf("resizefb %dx%d %dbpp (pitch: %d)\n", x, y, bpp, pitch);
+
        free(framebuf);
 
        fb_width = x;
        fb_height = y;
        fb_bpp = bpp;
-       fb_pitch = x * bpp / 8;
+       fb_pitch = pitch;
 
        if(!(framebuf = malloc(fb_pitch * fb_height))) {
                fprintf(stderr, "failed to allocate %dx%d (%dbpp) framebuffer\n",