Index: trunk/src/VBox/Devices/Graphics/BIOS/vbe.c
===================================================================
--- trunk/src/VBox/Devices/Graphics/BIOS/vbe.c	(revision 67547)
+++ trunk/src/VBox/Devices/Graphics/BIOS/vbe.c	(revision 67548)
@@ -128,4 +128,31 @@
     out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
     out_w(VBE_DISPI_IOPORT_DATA, bpp);
+}
+
+static uint16_t dispi_get_bpp(void)
+{
+    out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
+    return in_w(VBE_DISPI_IOPORT_DATA);
+}
+
+static void dispi_set_virt_width(uint16_t vwidth)
+{
+#ifdef VGA_DEBUG
+    printf("vbe_set_virt_width: %04x\n", vwidth);
+#endif
+    out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH);
+    out_w(VBE_DISPI_IOPORT_DATA, vwidth);
+}
+
+static uint16_t dispi_get_virt_width(void)
+{
+    out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH);
+    return in_w(VBE_DISPI_IOPORT_DATA);
+}
+
+static uint16_t dispi_get_virt_height(void)
+{
+    out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_HEIGHT);
+    return in_w(VBE_DISPI_IOPORT_DATA);
 }
 
@@ -691,2 +718,65 @@
     *AX = result;
 }
+
+/** Function 06h - Set/Get Logical Scan Line Length
+ *
+ *  Input:
+ *              AX      = 4F06h
+ *              BL      = 00h Set Scan Line Length in Pixels
+ *                      = 01h Get Scan Line Length
+ *                      = 02h Set Scan Line Length in Bytes
+ *                      = 03h Get Maximum Scan Line Length
+ *              CX      = If BL=00h Desired Width in Pixels
+ *                        If BL=02h Desired Width in Bytes
+ *                        (Ignored for Get Functions)
+ *
+ *  Output:
+ *              AX      = VBE Return Status
+ *              BX      = Bytes Per Scan Line
+ *              CX      = Actual Pixels Per Scan Line (truncated to
+ *                        nearest complete pixel)
+ *              DX      = Maximum Number of Scan Lines
+ */
+void vbe_biosfn_get_set_scanline_length(uint16_t STACK_BASED *AX, uint16_t STACK_BASED *BX,
+                                        uint16_t STACK_BASED *CX, uint16_t STACK_BASED *DX)
+{
+    uint16_t    val;
+    uint16_t    result;
+    uint8_t     bpp;
+    uint8_t     subfn;
+
+    bpp    = dispi_get_bpp();
+    result = 0x004F;
+    val    = *CX;
+    subfn  = *BX & 0xFF;
+#ifdef VGA_DEBUG
+    printf("VBE get/set scanline len fn=%x, CX=%x\n", subfn, *CX);
+#endif
+    switch(subfn) {
+    case 0x02:
+        if (bpp == 4)
+            val = val * 8;
+        else
+            val = val / (bpp / 8);
+        /* fall through */
+    case 0x00:
+        dispi_set_virt_width(val);
+        /* fall through */
+    case 0x01:
+        val = dispi_get_virt_width();
+        *CX = val;                          /* Width in pixels. */
+        if (bpp == 4)
+            val = val / 8;
+        else
+            val = val * (bpp / 8);
+        val = (val + 3) & ~3;
+        *BX = val;                          /* Bytes per scanline. */
+        *DX = dispi_get_virt_height();      /* Height in lines. */
+        break;
+    default:
+        // function failed
+        result = 0x100;
+        break;
+    }
+    *AX = result;
+}
Index: trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm
===================================================================
--- trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm	(revision 67547)
+++ trunk/src/VBox/Devices/Graphics/BIOS/vberom.asm	(revision 67548)
@@ -49,5 +49,4 @@
 public	vbe_biosfn_return_current_mode
 public	vbe_biosfn_display_window_control
-public	vbe_biosfn_set_get_logical_scan_line_length
 public	vbe_biosfn_set_get_display_start
 public	vbe_biosfn_set_get_dac_palette_format
@@ -304,37 +303,4 @@
   pop  bx
   pop  ax
-  ret
-
-dispi_set_virt_width:
-  call vga_set_virt_width
-  push dx
-  push ax
-  mov  dx, VBE_DISPI_IOPORT_INDEX
-  mov  ax, VBE_DISPI_INDEX_VIRT_WIDTH
-  out_dx_ax
-  pop  ax
-  mov  dx, VBE_DISPI_IOPORT_DATA
-  out_dx_ax
-  pop  dx
-  ret
-
-dispi_get_virt_width:
-  push dx
-  mov  dx, VBE_DISPI_IOPORT_INDEX
-  mov  ax, VBE_DISPI_INDEX_VIRT_WIDTH
-  out_dx_ax
-  mov  dx, VBE_DISPI_IOPORT_DATA
-  in_ax_dx
-  pop  dx
-  ret
-
-dispi_get_virt_height:
-  push dx
-  mov  dx, VBE_DISPI_IOPORT_INDEX
-  mov  ax, VBE_DISPI_INDEX_VIRT_HEIGHT
-  out_dx_ax
-  mov  dx, VBE_DISPI_IOPORT_DATA
-  in_ax_dx
-  pop  dx
   ret
 
@@ -569,78 +535,4 @@
 vbe_05_failed:
   mov  ax, 014Fh
-  ret
-
-
-; Function 06h - Set/Get Logical Scan Line Length
-;
-; Input:
-;              AX      = 4F06h
-;              BL      = 00h Set Scan Line Length in Pixels
-;                      = 01h Get Scan Line Length
-;                      = 02h Set Scan Line Length in Bytes
-;                      = 03h Get Maximum Scan Line Length
-;              CX      = If BL=00h Desired Width in Pixels
-;                        If BL=02h Desired Width in Bytes
-;                        (Ignored for Get Functions)
-;
-; Output:
-;              AX      = VBE Return Status
-;              BX      = Bytes Per Scan Line
-;              CX      = Actual Pixels Per Scan Line
-;                        (truncated to nearest complete pixel)
-;              DX      = Maximum Number of Scan Lines
-;
-vbe_biosfn_set_get_logical_scan_line_length:
-  mov  ax, cx
-  cmp  bl, 1
-  je   get_logical_scan_line_length
-  cmp  bl, 2
-  je   set_logical_scan_line_bytes
-  jb   set_logical_scan_line_pixels
-  mov  ax, 0100h
-  ret
-set_logical_scan_line_bytes:
-  push ax
-  call dispi_get_bpp
-  xor  bh, bh
-  mov  bl, ah
-  or   bl, bl
-  pop  ax
-  jnz  no_4bpp_1
-if VBOX_BIOS_CPU gt 8086
-  shl  ax, 3
-else
-  shl  ax, 1
-  shl  ax, 1
-  shl  ax, 1
-endif
-  mov  bl, 1
-no_4bpp_1:
-  xor  dx, dx
-  div  bx
-set_logical_scan_line_pixels:
-  call dispi_set_virt_width
-get_logical_scan_line_length:
-  call dispi_get_bpp
-  xor  bh, bh
-  mov  bl, ah
-  call dispi_get_virt_width
-  mov  cx, ax
-  or   bl, bl
-  jnz  no_4bpp_2
-if VBOX_BIOS_CPU gt 8086
-  shr  ax, 3
-else
-  shr  ax, 1
-  shr  ax, 1
-  shr  ax, 1
-endif
-  mov  bl, 1
-no_4bpp_2:
-  mul  bx
-  mov  bx, ax
-  call dispi_get_virt_height
-  mov  dx, ax
-  mov  ax, 004Fh
   ret
 
Index: trunk/src/VBox/Devices/Graphics/BIOS/vgabios.c
===================================================================
--- trunk/src/VBox/Devices/Graphics/BIOS/vgabios.c	(revision 67547)
+++ trunk/src/VBox/Devices/Graphics/BIOS/vgabios.c	(revision 67548)
@@ -2100,4 +2100,5 @@
 extern void vbe_biosfn_set_mode(uint16_t STACK_BASED *AX, uint16_t BX, uint16_t ES, uint16_t DI);
 extern void vbe_biosfn_save_restore_state(uint16_t STACK_BASED *AX, uint16_t CX, uint16_t DX, uint16_t ES, uint16_t STACK_BASED *BX);
+extern void vbe_biosfn_get_set_scanline_length(uint16_t STACK_BASED *AX, uint16_t STACK_BASED *BX, uint16_t STACK_BASED *CX, uint16_t STACK_BASED *DX);
 
 // --------------------------------------------------------------------------------------------
@@ -2295,4 +2296,7 @@
           vbe_biosfn_save_restore_state(&AX, CX, DX, ES, &BX);
           break;
+         case 0x06:
+          vbe_biosfn_get_set_scanline_length(&AX, &BX, &CX, &DX);
+          break;
          case 0x09:
           //FIXME
Index: trunk/src/VBox/Devices/Graphics/BIOS/vgarom.asm
===================================================================
--- trunk/src/VBox/Devices/Graphics/BIOS/vgarom.asm	(revision 67547)
+++ trunk/src/VBox/Devices/Graphics/BIOS/vgarom.asm	(revision 67548)
@@ -48,5 +48,4 @@
 extrn	vbe_biosfn_return_current_mode:near
 extrn	vbe_biosfn_display_window_control:near
-extrn	vbe_biosfn_set_get_logical_scan_line_length:near
 extrn	vbe_biosfn_set_get_display_start:near
 extrn	vbe_biosfn_set_get_dac_palette_format:near
@@ -167,11 +166,6 @@
 int10_test_vbe_05:
   cmp   al, 5
-  jne   int10_test_vbe_06
+  jne   int10_test_vbe_07
   call  vbe_biosfn_display_window_control
-  jmp   int10_end
-int10_test_vbe_06:
-  cmp   al, 6
-  jne   int10_test_vbe_07
-  call  vbe_biosfn_set_get_logical_scan_line_length
   jmp   int10_end
 int10_test_vbe_07:
