fixed blitfb32 for banked video modes with scanline padding (cirrus logic vlb)
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 1 Jul 2023 08:35:32 +0000 (11:35 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 1 Jul 2023 08:35:32 +0000 (11:35 +0300)
src/dos/drv_vbe.c
src/dos/vidsys.c

index 9989bb1..817d9cc 100644 (file)
@@ -20,6 +20,7 @@ static const char *memsize_str(long sz);
 static int get_mode_info(int mode, struct vbe_mode_info *mi);
 static int conv_vbeinfo(int mode, struct vid_modeinfo *mi, struct vbe_mode_info *vbemi);
 static unsigned int calc_mask(int nbits, int pos);
+static void print_mode_info(int mode, struct vid_modeinfo *mi);
 
 static void pack(uint32_t *pix, int r, int g, int b);
 static void unpack(uint32_t pix, int *r, int *g, int *b);
@@ -170,6 +171,8 @@ retry:
        } else {
                minf->ops.blitfb = blitfb_banked;
        }
+
+       print_mode_info(mode, minf);
        return 0;
 }
 
@@ -321,6 +324,28 @@ static unsigned int calc_mask(int nbits, int pos)
        return mask << pos;
 }
 
+static void print_mode_info(int mode, struct vid_modeinfo *mi)
+{
+       infomsg("VBE mode %04x\n", mode);
+       infomsg("  %dx%d %d bpp (%d colors)\n", mi->width, mi->height,
+                  mi->bpp, mi->ncolors);
+       infomsg("  pitch: %d bytes, %d vmem pages\n", mi->pitch, mi->pages);
+
+       if(mi->bpp > 8) {
+               infomsg("  RGB mask %06x %06x %06x (pos: %d %d %d)\n", (unsigned int)mi->rmask,
+                               (unsigned int)mi->gmask, (unsigned int)mi->bmask, mi->rshift,
+                               mi->gshift, mi->bshift);
+       }
+
+       if(mode & VBE_MODE_LFB) {
+               infomsg("  LFB address %xh, size: %d\n", (unsigned int)mi->vmem_addr,
+                               (int)mi->vmem_size);
+       } else {
+               infomsg("  banked window %d kb, granularity: %d kb, step: %d\n", mi->win_size,
+                               mi->win_gran, mi->win_step);
+       }
+}
+
 
 static void pack(uint32_t *pix, int r, int g, int b)
 {
index 7b9f3d5..77d1c0c 100644 (file)
@@ -207,7 +207,7 @@ void vid_blitfb(void *fb, int pitch)
 
 void vid_blitfb32(uint32_t *src, int pitch)
 {
-       int i, j, winpos, winleft;
+       int i, j, winpos, winleft, endskip;
        unsigned char *dest;
        uint16_t *dest16;
 
@@ -223,7 +223,7 @@ void vid_blitfb32(uint32_t *src, int pitch)
        if(vid_islinear()) {
                winleft = INT_MAX;
        } else {
-               winleft = 65536;/*cur_mode->win_size << 10;*/
+               winleft = cur_mode->win_size << 10;
                winpos = 0;
                vid_setwin(0, 0);
        }
@@ -242,22 +242,26 @@ void vid_blitfb32(uint32_t *src, int pitch)
 
        case 24:
                dest = vid_vmem;
+               endskip = cur_mode->pitch - cur_mode->width * 3;
+
                for(i=0; i<cur_mode->height; i++) {
                        for(j=0; j<cur_mode->width; j++) {
                                uint32_t pixel = src[j];
                                if(winleft <= 0) {
                                        winpos += cur_mode->win_step;
                                        vid_setwin(0, winpos);
-                                       winleft = 65536;/*cur_mode->win_size << 10;*/
+                                       winleft = cur_mode->win_size << 10;
                                        dest = vid_vmem;
                                }
-                               dest[0] = (pixel >> 16) & 0xff;
+                               dest[0] = pixel & 0xff;
                                dest[1] = (pixel >> 8) & 0xff;
-                               dest[2] = pixel & 0xff;
+                               dest[2] = (pixel >> 16) & 0xff;
                                dest += 3;
                                winleft -= 3;
                        }
                        src = (uint32_t*)((char*)src + pitch);
+                       dest += endskip;
+                       winleft -= endskip;
                }
                break;