+1.Combuster wrote:How about not limiting yourself to software implementations and just changing the location in video ram where the video card starts displaying, so you never need a copy? The topic title seems to assume a VGA after all...
Geezer said:
Hardware scrolling by changing the framebuffer base address:For hardware scrolling, you instruct the VGA to use a different memory location for the framebuffer. CRTC registers 12 and 13 contain the MSB and LSB of the framebuffer offset, relative to B0000h, B8000h, or A0000h. Hardware scrolling can not continue indefinitely (eventually the framebuffer will extend beyond the end of video memory).
The framebuffer memory can also be divided into virtual consoles (VCs). 32K of video memory is enough for eight 80x25 VCs. The VCs can be spaced 4000 bytes apart (80x25x2), and the hardware scrolling code snippet below can be used to select which VC is currently displayed. (Linux VCs use a different method.)
Code: Select all
/* scroll up one line */
#include <dos.h> /* outportb() */
unsigned short crtc_adr = 0x3D4; /* 0x3B4 for monochrome */
unsigned short offset = 80;
/* the CRTC index is at crtc_adr + 0
select register 12 */
outportb(crtc_adr + 0, 12);
/* the selected CRTC register appears at crtc_adr + 1 */
outportb(crtc_adr + 1, offset >> 8);
outportb(crtc_adr + 0, 13);
outportb(crtc_adr + 1, offset & 0xFF);