diff options
author | Volker Ruppert <info@vruppert.de> | 2004-05-09 20:31:30 +0000 |
---|---|---|
committer | Volker Ruppert <info@vruppert.de> | 2004-05-09 20:31:30 +0000 |
commit | 81fb36a67a07360ef9175aea356e52a8f82dbb21 (patch) | |
tree | a3db467ba07f5e0bf6a82a0c4fae8b2186d7b58f | |
parent | 852a0fc4cc087d010121a617df689348b2c56ddc (diff) | |
download | vgabios-81fb36a67a07360ef9175aea356e52a8f82dbb21.tar.gz |
- VBE init code and some dispi ioport functions rewritten in assembler
- text scroll functions for CGA graphics modes added
- scroll text in graphics modes: attribute for blank line fixed
-rw-r--r-- | vbe.c | 186 | ||||
-rw-r--r-- | vbe.h | 2 | ||||
-rw-r--r-- | vgabios.c | 86 |
3 files changed, 187 insertions, 87 deletions
@@ -86,6 +86,10 @@ _no_vbebios_info_string: .byte 0x0a,0x0d .byte 0x00 +msg_vbe_init: +.ascii "VBE Bios $Id$" +.byte 0x0a,0x0d, 0x00 + #ifndef DYN_LIST // FIXME: for each new mode add a statement here @@ -129,22 +133,31 @@ MACRO HALT mov ax,#?1 out dx,ax MEND -ASM_END -// DISPI ioport functions -// FIXME: what if no VBE host side code? -static Bit16u dispi_get_id() -{ - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID); - return inw(VBE_DISPI_IOPORT_DATA); -} +; DISPI ioport functions -static void dispi_set_id(id) - Bit16u id; -{ - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID); - outw(VBE_DISPI_IOPORT_DATA,id); -} +dispi_get_id: + push dx + mov dx, # VBE_DISPI_IOPORT_INDEX + mov ax, # VBE_DISPI_INDEX_ID + out dx, ax + mov dx, # VBE_DISPI_IOPORT_DATA + in ax, dx + pop dx + ret + +dispi_set_id: + push dx + push ax + mov dx, # VBE_DISPI_IOPORT_INDEX + mov ax, # VBE_DISPI_INDEX_ID + out dx, ax + pop ax + mov dx, # VBE_DISPI_IOPORT_DATA + out dx, ax + pop dx + ret +ASM_END static void dispi_set_xres(xres) Bit16u xres; @@ -184,23 +197,27 @@ dispi_get_bpp: get_bpp_noinc: pop dx ret -ASM_END - -static Bit16u dispi_get_max_bpp() -{ - Bit16u max_bpp, vbe_enable; - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); - vbe_enable = inw(VBE_DISPI_IOPORT_DATA); - outw(VBE_DISPI_IOPORT_DATA,vbe_enable|VBE_DISPI_GETCAPS); - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP); - max_bpp = inw(VBE_DISPI_IOPORT_DATA); - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); - outw(VBE_DISPI_IOPORT_DATA,vbe_enable); - return max_bpp; -} +_dispi_get_max_bpp: + push dx + push bx + call dispi_get_enable + mov bx, ax + or ax, # VBE_DISPI_GETCAPS + call _dispi_set_enable + mov dx, # VBE_DISPI_IOPORT_INDEX + mov ax, # VBE_DISPI_INDEX_BPP + out dx, ax + mov dx, # VBE_DISPI_IOPORT_DATA + in ax, dx + push ax + mov ax, bx + call _dispi_set_enable + pop ax + pop bx + pop dx + ret -ASM_START _dispi_set_enable: push dx push ax @@ -388,60 +405,67 @@ static ModeInfoListItem* mode_info_find_mode(mode, using_lfb) return 0; } -/** Has VBE display - Returns true if VBE display detected - * - */ -Boolean vbe_has_vbe_display() -{ - return read_byte(BIOSMEM_SEG,BIOSMEM_VBE_FLAG); -} +ASM_START -/** VBE Init - Initialise the Vesa Bios Extension Code - * - * This function does a sanity check on the host side display code interface. - */ -void vbe_init() -{ - Bit16u dispi_id; - - outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID); - outw(VBE_DISPI_IOPORT_DATA,VBE_DISPI_ID0); - - dispi_id=inw(VBE_DISPI_IOPORT_DATA); - - if (dispi_id==VBE_DISPI_ID0) - { - write_byte(BIOSMEM_SEG,BIOSMEM_VBE_FLAG,0x01); - dispi_set_id(VBE_DISPI_ID3); - } - printf("VBE Bios $Id$\n"); -} +; Has VBE display - Returns true if VBE display detected -/** VBE Display Info - Display information on screen about the VBE - */ -void vbe_display_info() -{ - // Check for VBE display extension in Bochs - if (vbe_has_vbe_display()) - { - ASM_START - mov ax,#0xc000 - mov ds,ax - mov si,#_vbebios_info_string - call _display_string - ASM_END - } - else - { - ASM_START - mov ax,#0xc000 - mov ds,ax - mov si,#_no_vbebios_info_string - call _display_string - ASM_END - - } -} +_vbe_has_vbe_display: + push ds + push bx + mov ax, # BIOSMEM_SEG + mov ds, ax + mov bx, # BIOSMEM_VBE_FLAG + mov al, [bx] + and al, #0x01 + xor ah, ah + pop bx + pop ds + ret + +; VBE Init - Initialise the Vesa Bios Extension Code +; This function does a sanity check on the host side display code interface. + +vbe_init: + mov ax, # VBE_DISPI_ID0 + call dispi_set_id + call dispi_get_id + cmp ax, # VBE_DISPI_ID0 + jne no_vbe_interface + push ds + push bx + mov ax, # BIOSMEM_SEG + mov ds, ax + mov bx, # BIOSMEM_VBE_FLAG + mov al, #0x01 + mov [bx], al + pop bx + pop ds + mov ax, # VBE_DISPI_ID3 + call dispi_set_id +no_vbe_interface: + mov bx, #msg_vbe_init + push bx + call _printf + inc sp + inc sp + ret + +; VBE Display Info - Display information on screen about the VBE + +vbe_display_info: + call _vbe_has_vbe_display + test ax, ax + jz no_vbe_flag + mov ax, #0xc000 + mov ds, ax + mov si, #_vbebios_info_string + jmp _display_string +no_vbe_flag: + mov ax, #0xc000 + mov ds, ax + mov si, #_no_vbebios_info_string + jmp _display_string +ASM_END /** Function 00h - Return VBE Controller Information * @@ -11,8 +11,6 @@ void dispi_set_enable(enable); * See the function descriptions in vbe.c for more information */ Boolean vbe_has_vbe_display(); -void vbe_init(); -void vbe_display_info(); void vbe_biosfn_return_controller_information(AX, ES, DI); void vbe_biosfn_return_mode_information(AX, CX, ES, DI); void vbe_biosfn_set_mode(AX, BX, ES, DI); @@ -209,7 +209,7 @@ vgabios_init_func: #ifdef VBE ;; init vbe functions - call _vbe_init + call vbe_init #endif ;; set int10 vect @@ -227,7 +227,7 @@ vgabios_init_func: #ifdef VBE ;; show vbe info - call _vbe_display_info + call vbe_display_info #endif @@ -1144,12 +1144,47 @@ Bit8u xstart;Bit8u ystart;Bit8u cols;Bit8u nbcols;Bit8u cheight; } // -------------------------------------------------------------------------------------------- +static void vgamem_copy_cga(xstart,ysrc,ydest,cols,nbcols,cheight) +Bit8u xstart;Bit8u ysrc;Bit8u ydest;Bit8u cols;Bit8u nbcols;Bit8u cheight; +{ + Bit16u src,dest; + Bit8u i; + + src=((ysrc*cheight*nbcols)>>1)+xstart; + dest=((ydest*cheight*nbcols)>>1)+xstart; + for(i=0;i<cheight;i++) + { + if (i & 1) + memcpyb(0xb800,0x2000+dest+(i>>1)*nbcols,0xb800,0x2000+src+(i>>1)*nbcols,cols); + else + memcpyb(0xb800,dest+(i>>1)*nbcols,0xb800,src+(i>>1)*nbcols,cols); + } +} + +// -------------------------------------------------------------------------------------------- +static void vgamem_fill_cga(xstart,ystart,cols,nbcols,cheight,attr) +Bit8u xstart;Bit8u ystart;Bit8u cols;Bit8u nbcols;Bit8u cheight;Bit8u attr; +{ + Bit16u dest; + Bit8u i; + + dest=((ystart*cheight*nbcols)>>1)+xstart; + for(i=0;i<cheight;i++) + { + if (i & 1) + memsetb(0xb800,0x2000+dest+(i>>1)*nbcols,attr,cols); + else + memsetb(0xb800,dest+(i>>1)*nbcols,attr,cols); + } +} + +// -------------------------------------------------------------------------------------------- static void biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir) Bit8u nblines;Bit8u attr;Bit8u rul;Bit8u cul;Bit8u rlr;Bit8u clr;Bit8u page;Bit8u dir; { // page == 0xFF if current - Bit8u mode,line,cheight,cols; + Bit8u mode,line,cheight,bpp,cols; Bit16u nbcols,nbrows,i; Bit16u address; @@ -1242,6 +1277,41 @@ Bit8u nblines;Bit8u attr;Bit8u rul;Bit8u cul;Bit8u rlr;Bit8u clr;Bit8u page;Bit8 } } break; + case CGA: + bpp=vga_modes[line].pixbits; + if(nblines==0&&rul==0&&cul==0&&rlr==nbrows-1&&clr==nbcols-1) + { + memsetb(vga_modes[line].sstart,0,attr,nbrows*nbcols*cheight*bpp); + } + else + { + if(bpp==2) + { + cul<<=1; + cols<<=1; + nbcols<<=1; + } + // if Scroll up + if(dir==SCROLL_UP) + {for(i=rul;i<=rlr;i++) + { + if((i+nblines>rlr)||(nblines==0)) + vgamem_fill_cga(cul,i,cols,nbcols,cheight,attr); + else + vgamem_copy_cga(cul,i+nblines,i,cols,nbcols,cheight); + } + } + else + {for(i=rlr;i>=rul;i--) + { + if((i<rul+nblines)||(nblines==0)) + vgamem_fill_cga(cul,i,cols,nbcols,cheight,attr); + else + vgamem_copy_cga(cul,i,i-nblines,cols,nbcols,cheight); + } + } + } + break; #ifdef DEBUG default: printf("Scroll in graphics mode "); @@ -1873,7 +1943,15 @@ Bit8u car;Bit8u page;Bit8u attr;Bit8u flag; // Do we need to scroll ? if(ycurs==nbrows) - {biosfn_scroll(0x01,0x07,0,0,nbrows-1,nbcols-1,page,SCROLL_UP); + { + if(vga_modes[line].class==TEXT) + { + biosfn_scroll(0x01,0x07,0,0,nbrows-1,nbcols-1,page,SCROLL_UP); + } + else + { + biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP); + } ycurs-=1; } |