home *** CD-ROM | disk | FTP | other *** search
-
- include grphdrvr.inc
-
- ;******************************************************************************}
- ; TEGL Windows ToolKit II }
- ; Copyright (C) 1990, TEGL Systems Corporation }
- ; All Rights Reserved. }
- ;******************************************************************************}
-
- .code
-
- db 'RT',8,8,'TGI Device Driver (VGA320x200/SVGA640x480)x256 1.1 - May 8 1991',13,10
- db 'Copyright (c) 1989,1990 TEGL Systems Corporation',13,10
- db 01ah ; end of file for TYPE
- db 00 ; end of Copyright Header
-
- db 8,'GRVGA256',0 ; driver module name
-
- ; VGA320x200x256
- mode0: db 14,'VGA320x200x256',0,0,0,0,0,0,0
- dw 0 ; Mode Number
- dw 319 ; Device Full Resolution in X
- dw 199 ; Device Full Resolution in Y
- dw 8 ; Standard char size X
- dw 8 ; Standard char size Y
- dw 255 ; Number of colors
- dw 2 ; Number of pages
- dw 256 ; max palette
- dw 0 ; buffer offset for 2 page
- dw 0A000h ; Screen Segment
- dw 320 ; bytes per line
- dw 7750 ; x aspect
- dw 10000 ; y aspect
- dd 0 ; Driver Pointer
- dd 0 ; Driver Name Pointer
- dd 0 ; Driver Jump Table
- dd 0 ; Graphics Work Buffer
- dw 0 ; Graphics Buffer Size
- dw 0 ; Read/Write modes
- db 0 ; transparency on-$ff/off-$00
- db 0 ; jagged characters
- dd 0 ; pointer to font table
- db 0 ; allow EGA palette changes
- db 1 ; allow VGA 256 palette changes
- db 1 ; proportional font switch
- dw 0ffffh ; fillmask for lines
- dw 0 ; viewport - minx
- dw 0 ; viewport - miny
- dw 319 ; viewport - maxx
- dw 199 ; viewport - maxy
- db 1 ; viewport - clipping on/off
- dw 15 ; Mouse color
- dw 0 ; Mouse hotspot
- dw 0 ; Mouse hotspot
- dd 0 ; Mouse Cursor Mask
- dd 0 ; Next VideoMode
-
- mode1: db 15,'SVGA640x480x256',0,0,0,0,0,0
- dw 1 ; Mode Number
- dw 639 ; Device Full Resolution in X
- dw 479 ; Device Full Resolution in Y
- dw 8 ; Standard char size X
- dw 8 ; Standard char size Y
- dw 255 ; Number of colors
- dw 1 ; Number of pages
- dw 256 ; max palette
- dw 0 ; buffer offset for 2 page
- dw 0A000h ; Screen Segment
- dw 640 ; bytes per line
- dw 10000 ; x aspect
- dw 10000 ; y aspect
- dd 0 ; Driver Pointer
- dd 0 ; Driver Name Pointer
- dd 0 ; Driver Jump Table
- dd 0 ; Graphics Work Buffer
- dw 0 ; Graphics Buffer Size
- dw 0 ; Read/Write modes
- db 0 ; transparency on-$ff/off-$00
- db 0 ; jagged characters
- dd 0 ; pointer to font table
- db 0 ; allow EGA palette changes
- db 1 ; allow VGA 256 palette changes
- db 1 ; proportional font switch
- dw 0ffffh ; fillmask for lines
- dw 0 ; viewport - minx
- dw 0 ; viewport - miny
- dw 639 ; viewport - maxx
- dw 479 ; viewport - maxy
- db 1 ; viewport - clipping on/off
- dw 15 ; Mouse color
- dw 0 ; Mouse hotspot
- dw 0 ; Mouse hotspot
- dd 0 ; Mouse Cursor Mask
- dd 0 ; Next VideoMode
-
- mode2: db 15,'SVGA800x600x256',0,0,0,0,0,0
- dw 2 ; Mode Number
- dw 799 ; Device Full Resolution in X
- dw 599 ; Device Full Resolution in Y
- dw 8 ; Standard char size X
- dw 8 ; Standard char size Y
- dw 255 ; Number of colors
- dw 1 ; Number of pages
- dw 256 ; max palette
- dw 0 ; buffer offset for 2 page
- dw 0A000h ; Screen Segment
- dw 800 ; bytes per line
- dw 9500 ; x aspect
- dw 10000 ; y aspect
- dd 0 ; Driver Pointer
- dd 0 ; Driver Name Pointer
- dd 0 ; Driver Jump Table
- dd 0 ; Graphics Work Buffer
- dw 0 ; Graphics Buffer Size
- dw 0 ; Read/Write modes
- db 0 ; transparency on-$ff/off-$00
- db 0 ; jagged characters
- dd 0 ; pointer to font table
- db 0 ; allow EGA palette changes
- db 1 ; allow VGA 256 palette changes
- db 1 ; proportional font switch
- dw 0ffffh ; fillmask for lines
- dw 0 ; viewport - minx
- dw 0 ; viewport - miny
- dw 799 ; viewport - maxx
- dw 599 ; viewport - maxy
- db 1 ; viewport - clipping on/off
- dw 15 ; Mouse color
- dw 0 ; Mouse hotspot
- dw 0 ; Mouse hotspot
- dd 0 ; Mouse Cursor Mask
- dd 0 ; Next VideoMode
-
- mode3: db 16,'SVGA1024x768x256',0,0,0,0,0
- dw 3 ; Mode Number
- dw 1023 ; Device Full Resolution in X
- dw 767 ; Device Full Resolution in Y
- dw 8 ; Standard char size X
- dw 8 ; Standard char size Y
- dw 255 ; Number of colors
- dw 1 ; Number of pages
- dw 256 ; max palette
- dw 0 ; buffer offset for 2 page
- dw 0A000h ; Screen Segment
- dw 1024 ; bytes per line
- dw 10000 ; x aspect
- dw 10000 ; y aspect
- dd 0 ; Driver Pointer
- dd 0 ; Driver Name Pointer
- dd 0 ; Driver Jump Table
- dd 0 ; Graphics Work Buffer
- dw 0 ; Graphics Buffer Size
- dw 0 ; Read/Write modes
- db 0 ; transparency on-$ff/off-$00
- db 0 ; jagged characters
- dd 0 ; pointer to font table
- db 0 ; allow EGA palette changes
- db 1 ; allow VGA 256 palette changes
- db 1 ; proportional font switch
- dw 0ffffh ; fillmask for lines
- dw 0 ; viewport - minx
- dw 0 ; viewport - miny
- dw 1023 ; viewport - maxx
- dw 767 ; viewport - maxy
- db 1 ; viewport - clipping on/off
- dw 15 ; Mouse color
- dw 0 ; Mouse hotspot
- dw 0 ; Mouse hotspot
- dd 0 ; Mouse Cursor Mask
- dd 0 ; Next VideoMode
-
- modeend: dw 0ffffh ; 0ffff - last mode
-
- drvjumptable: dw initvideomode ; mode:word,TEGLTable:dword,initflg:byte
- dw setxlattable ; XlatTable:dword
- dw setvideotable ; TEGLTable:dword
- dw getvideotable ; returns pointer to TEGLTable
- dw imagesize ; argx1:word,argy1:word,argx2:word,argy2:word
- dw fastline ; argx1:word,argy1:word,argx2:word,argy2:word,color:word
- dw scanborder ; argx:word,argy:word,bordercolor:word,scan:word
- dw putpixs ; argx:word,argy:word,color:word
- dw getpixs ; argx:word,argy:word
- dw getbiti ; argx0:word,argy0:word,argx1:word,argy1:word,addrbuf:dword
- dw putbiti ; argx:word,argy:word,addrbuf:dword,rmwb:word
- dw extractimg ; argx0:word,argy0:word,argx1:word,argy1:word,addrbuf1:dword,addrbuf2:dword
- dw overlayimg ; argx0:word,argy0:word,addrbuf1:dword,addrbuf2:dword
- dw extractpixs ; argx0:word,argy0:word,addrbuff:dword
- dw wrtchar ; argc:word,argx:word,argy:word,argfgd:word
- dw mcursoroff ;
- dw mcursoron ; argx:word,argy:word
- dw msetpos ; argx:word,argy:word
- dw movevideopixels ; argx0:word,argy0:word,argx1:word,argy1:word,argx2:word,argy2:word,vertlines:word,horzlines:word,spage:word,tpage:word
- dw setvpage ; pagen:word
- dw setapage ; pagen:word
-
- db 16 dup (0) ;required for driver alignment
-
- ; 16 bytes/row * 16rows + 5 byte header
- mcursorsavearea db 262 dup (0)
- mflag dw 0
- scradrofs dw 0
- scradrseg dw 0
- scradrpg dw 0
- current64kpage dw 0
- TDTable dd 0
- XLTable dd 0
- vesashift db 0
-
-
- vga512flag dw ?
- vga1024flag dw ?
- svgatype dw 0 ;flag so whichvga() is only called once
- bankadr dw ?
-
- ;x_genoa equ 1
- ;x_paradise equ 2
- ;x_ati equ 3
- ;x_everex equ 4
- ;x_trident equ 5
- ;x_video7 equ 6
- ;x_chiptech equ 7
- ;x_tseng4 equ 8
- ;x_tseng equ 9
- ;x_ahead equ 10
- ;x_aheadb equ 11
- ;x_oak equ 12
- ;x_cirrus equ 13
-
- x_cirrus equ 1
- x_everex equ 2
- x_paradise equ 3
- x_tseng equ 4
- x_trident equ 5
- x_t8900 equ 6
- x_ativga equ 7
- x_aheada equ 8
- x_aheadb equ 9
- x_oaktech equ 10
- x_video7 equ 11
- x_chipstech equ 12
- x_tseng4 equ 13
- x_genoa equ 14
- x_ncr equ 15
- x_compaq equ 16
- x_vesa equ 17
-
-
- initvideomode proc far
-
- push ds
- push si
- lds si,cs:TDTable
- mov bx,ds:[si].vmodenum
- pop si
- pop ds
-
- mov ax,ds
- or ax,ax
- mov ax,-10
- jz initviddone
-
- or bx,bx
- jnz nxtevgamode
-
- call setsvga320x200
- jmp short initviddone
-
- nxtevgamode: cmp bx,1
- jnz trysvgamode
- call setsvga640x480
- jmp short initviddone
-
- trysvgamode: cmp bx,2
- jnz try1024mode
- call setsvga800x600
- jmp short initviddone
-
- try1024mode: cmp bx,3
- jnz initviddone
- call setsvga1024x768
-
- initviddone: ret
- initvideomode endp
-
- SetSVGA320x200 proc near
- mov ax,cs:svgatype
- cmp ax,0
- jb no200type
-
- cmp ax,0
- jnz ok200type
-
- call whichsvga
- jc no200type
-
- ok200type: mov ax,013h
- int 10h
- xor ax,ax
-
- no200type: ret
- SetSVGA320x200 endp
-
- SetSVGA640x480 proc near
- mov ax,cs:svgatype
- cmp ax,0
- jnz okset
-
- call whichsvga
- mov ax,cs:svgatype
- cmp ax,0
-
- okset: jb nohardware
- mov cx,ax
- test vga512flag,1
- jz nohardware
-
- cmp cx,x_genoa
- mov ax,5ch
- je set480
-
- cmp cx,x_paradise
- mov ax,5fh
- je set480
- cmp cx,x_compaq
- je set480
-
- cmp cx,x_ativga
- mov ax,62h
- je set480
-
- cmp cx,x_everex
- mov ax,70h
- mov bl,30h
- je set480
-
- cmp cx,x_trident
- mov ax,5dh
- je set480
- cmp cx,x_t8900
- je set480
-
- cmp cx,x_video7
- mov ax,6f05h
- mov bl,67h
- je set480
-
- cmp cx,x_chipstech
- mov ax,79h
- je set480
-
- cmp cx,x_tseng4
- mov ax,2eh
- je set480
- cmp cx,x_tseng
- je set480
-
- cmp cx,x_aheada
- mov ax,61h
- je set480
- cmp cx,x_aheadb
- je set480
-
- cmp cx,x_oaktech
- mov ax,53h
- je set480
-
- cmp cx,x_ncr
- mov ax,5fh
- je set480
-
- ; cmp cx,x_cirrus ;cirrus doesn't have a 640x480(256)
- nohardware: mov ax,-2
- jmp short nosvgatype
-
- set480: int 10h
- xor ax,ax
- nosvgatype:
- ret
- SetSVGA640x480 endp
-
-
- SetSVGA800x600 proc near
- mov ax,cs:svgatype
- cmp ax,0
- jnz oksets
-
- call whichsvga
- mov ax,cs:svgatype
- cmp ax,0
-
- oksets: jb nosvgatypes
- mov cx,ax
- test vga512flag,1
- jz nohardwares
-
- cmp cx,x_genoa
- mov ax,30h
- je set600
-
- cmp cx,x_paradise ;paradise doesn't have a 800x600(256)
- jz nohardwares
-
- cmp cx,x_ativga
- mov ax,63h
- je set600
-
- cmp cx,x_everex
- mov ax,70h
- mov bl,31h
- je set600
-
- cmp cx,x_trident
- mov ax,5eh
- je set600
- cmp cx,x_t8900
- je set600
-
- cmp cx,x_video7
- mov ax,6f05h
- mov bl,69h
- je set600
-
- cmp cx,x_chipstech
- mov ax,7bh
- je set600
-
- cmp cx,x_tseng4
- mov ax,30h
- je set600
-
- cmp cx,x_tseng
- mov ax,30h
- je set600
-
- cmp cx,x_aheada
- mov ax,62h
- je set600
- cmp cx,x_aheadb
- je set600
-
- cmp cx,x_oaktech
- mov ax,54h
- je set600
-
- cmp cx,x_ncr
- mov ax,5ch
- je set600
-
- nohardwares: mov ax,-2
- jmp short nosvgatypes
-
- set600: int 10h
- xor ax,ax
- nosvgatypes:
- ret
- SetSVGA800x600 endp
-
- SetSVGA1024x768 proc near
- mov ax,cs:svgatype
- cmp ax,0
- jnz oksets2
-
- call whichsvga
- mov ax,cs:svgatype
- cmp ax,0
-
- oksets2: jb nosvgatypes2
- mov cx,ax
- test vga1024flag,1
- jz nohardwares2
-
- cmp cx,x_genoa
- mov ax,38h
- je set768
-
- cmp cx,x_paradise ;paradise doesn't have a 1024x768(256)
- jz nohardwares2
-
- cmp cx,x_ativga ;ATI doesn't have a 1024x768(256)
- jz nohardwares2
-
- cmp cx,x_everex ;everex doesn't have a 1024x768(256)
- jz nohardwares2
-
- cmp cx,x_trident ;old trident doesn't have a 1024x768(256)
- jz nohardwares2
-
- cmp cx,x_t8900
- mov ax,62h
- je set768
-
- cmp cx,x_video7 ;new video7
- mov ax,6f05h
- mov bl,6ah
- jz nosvgatypes2
-
- cmp cx,x_chipstech ;chiptech doesn't have a 1024x768(256)
- jz nohardwares2
-
- cmp cx,x_tseng4
- mov ax,38h
- je set768
-
- cmp cx,x_tseng
- mov ax,38h
- je set768
-
- ; cmp cx,x_aheada ;ahead doesn't have a 1024x768(256)
- ; jz nohardwares2
-
- ; cmp cx,x_aheadb ;aheadb doesn't have a 1024x768(256)
- ; jz nohardwares2
-
- ; cmp cx,x_oaktech ;oak doesn't have a 1024x768(256)
- ; jz nohardwares2
-
- nohardwares2: mov ax,-2
- jmp short nosvgatypes2
-
- set768: int 10h
- xor ax,ax
- nosvgatypes2:
- ret
- SetSVGA1024x768 endp
-
-
- setxlattable proc far XlatTable:dword
- push es
- push di
-
- les di,XlatTable
- mov word ptr cs:XLTable,di
- mov word ptr cs:XLTable+2,es
-
- pop di
- pop es
- ret
- setxlattable endp
-
-
- setvideotable proc far TEGLTable:dword
- push es
- push di
-
- les di,TEGLTable
- mov word ptr cs:TDTable,di
- mov word ptr cs:TDTable+2,es
-
- cmp cs:svgatype,0
- jnz svgainitdone
-
- call whichsvga
-
- svgainitdone:
- pop di
- pop es
- ret
- setvideotable endp
-
- getvideotable proc far
-
- mov ax,word ptr cs:TDTable
- mov dx,word ptr cs:TDTable+2
-
- ret
- getvideotable endp
-
- imagesize proc far argx1:word,argy1:word,argx2:word,argy2:word
- push bx
-
- mov ax,argx2 ;x1-x+1
- sub ax,argx1
- inc ax
-
- mov bx,argy2 ;y1-y+1
- sub bx,argy1
- inc bx
-
- mul bx ;rows x bytes per row
- add ax,6 ;add 6 for header
- adc dx,0
-
- pop bx
- ret
- imagesize endp
-
-
- fastline proc far argx1:word,argy1:word,argx2:word,argy2:word,color:word
- local varincr1:word,varincr2:word,varroutine:word
- local rmwb:word,fillmask:byte,bpline:word,transparent:byte
-
- push ds
- push si
- push es
- push di
-
- cld
- colorxlat color
-
- lds si,cs:TDtable
- mov ax,ds:[si].rmwbits
- mov rmwb,ax
-
- mov ax,ds:[si].vbytesperline
- mov bpline,ax
-
- mov al,byte ptr ds:[si].teglfillmask
- mov fillmask,al
-
- mov al,ds:[si].transparency
- mov transparent,al
-
- cmp rmwb,80h ; not?
- jnz oknot
- not color
- oknot:
-
- ; check for vertical line
-
- mov si,bpline ; initial y-increment
- mov cx,argx2
- sub cx,argx1 ; cx := x2 - x1
- jz vertline13 ; jump if vertical line
-
- ; force x1 < x2
-
- jns l01 ; jump if x2 > x1
- neg cx ; cx := x1 - x2
- mov bx,argx2 ; exchange x1 and x2
- xchg bx,argx1
- mov argx2,bx
-
- mov bx,argy2 ; exchange y1 and y2
- xchg bx,argy1
- mov argy2,bx
-
- ; calculate dy = abs(y2-y1)
-
- l01: mov bx,argy2
- sub bx,argy1 ; bx := y2 - y1
- jnz l02
- jmp horizline13 ; jump if horizontal line
-
- l02: jns l03 ; jump if slope is positive
-
- neg bx ; bx := y1 - y2
- neg si ; negate y-increment
-
- ; select appropriate routine for slope of line
-
- l03: push si ; preserve y-increment
-
- mov varroutine,0 ; loslopeline13
- cmp bx,cx
- jle l04 ; jump if dy <= dx (slope <= 1)
- mov varroutine,1 ; hislopeline13
- xchg bx,cx ; exchange dy and dx
-
- ; calculate initial decision variable and increments
-
- l04: shl bx,1 ; bx := 2 * dy
- mov varincr1,bx ; incr1 := 2 * dy
- sub bx,cx
- mov si,bx ; si := d = 2 * dy - dx
- sub bx,cx
- mov varincr2,bx ; incr2 := 2 * (dy - dx)
-
- ; calculate first pixel address
-
- push cx ; preserve this register
- mov ax,argy1 ; ax := y
- mov bx,argx1 ; bx := x
- call activeaddr ; es:bx -> buffer
-
- mov di,bx ; es:di -> buffer
-
- pop cx ; restore this register
- inc cx ; cx := # of pixels to draw
-
- pop bx ; bx := y-increment
- test varroutine,1 ; jump to appropriate routine for slope
- jnz jmphislopeline
- jmp loslopeline13
- jmphislopeline: jmp hislopeline13
-
-
- ; routine for vertical lines
-
- vertline13: mov ax,argy1 ; ax := y1
- mov bx,argy2 ; bx := y2
- mov cx,bx
- sub cx,ax ; cx := dy
- jge l31 ; jump if dy >= 0
-
- neg cx ; force dy >= 0
- mov ax,bx ; ax := y2
-
- l31: inc cx ; cx := # of pixels to draw
- mov bx,argx1 ; bx := x
- push cx ; preserve this register
- call activeaddr ; es:bx -> video buffer
-
- pop cx
- mov di,bx ; es:di -> video buffer
-
- mov al,byte ptr [color] ; al := pixel value
- mov bl,fillmask
-
- cmp rmwb,18h ; fgxor
- jz vgl36a ; jump if pixel should be xored
-
- test rmwb,08h ; fgand
- jnz vgl35a ; jump if pixel should be anded
-
- test rmwb,10h ; fgor
- jnz vgl37a ; jump if pixel should be ored
-
- ;------------------ [fgnorm] set bit
- ;<<<<<Write pixel>>>>>>
- l32: ror bl,1
- jnc l32b
- mov es:[di],al ; set pixel value in buffer
- l32b: add di,si ; increment to next line
- jnc l32a
- call nextpage
- l32a: loop l32
- jmp svlexit
-
- ;------------------ [fgxor] set bit
- ;<<<<<Write pixel>>>>>>
- vgl36a: ror bl,1
- jnc vgl36b
- xor es:[di],al ; set pixel value in buffer
- vgl36b: add di,si ; increment to next line
- jnc vgl36c
- call nextpage
- vgl36c: loop vgl36a
- jmp svlexit
-
- ;------------------ [fgand] set bit
- ;<<<<<Write pixel>>>>>>
- vgl35a: ror bl,1
- jnc vgl35b
- and es:[di],al ; set pixel value in buffer
- vgl35b: add di,si ; increment to next line
- jnc vgl35c
- call nextpage
- vgl35c: loop vgl35a
- jmp svlexit
-
- ;------------------ [fgor] set bit
- ;<<<<<Write pixel>>>>>>
- vgl37a: ror bl,1
- jnc vgl37b
- or es:[di],al ; set pixel value in buffer
- vgl37b: add di,si ; increment to next line
- jnc vgl37c
- call nextpage
- vgl37c: loop vgl37a
- jmp svlexit
-
-
-
- ; routine for horizontal lines (slope = 0)
-
- horizline13:
- push cx ; preserve cx
- mov ax,argy1
- mov bx,argx1
- call activeaddr ; es:bx -> video buffer
- mov di,bx ; es:di -> buffer
-
- pop cx
- inc cx ; cx := number of pixels to draw
-
- mov al,byte ptr [color] ; al := pixel value
-
- xor dx,dx
- push di
- add di,cx
- jc h13a ; exceed 64k boundary
-
- ;------------------ Within Boundary Solid Line
- pop di
- ;<<<<<Write pixel>>>>>>
- mov bl,fillmask
- push bx
- xor bl,0ffh
- pop bx
- jnz h13c
-
- test rmwb,0ffh
- jnz h13c
-
- rep stosb ; update the video buffer
- jmp svlexit
-
-
- ;------------------ Cross Boundary Horizontal
- h13a: mov dx,di ; remainder
- pop di
- mov cx,di
- neg cx
-
- mov bl,fillmask
- push bx
- xor bl,0ffh
- pop bx
- jnz h13c
-
- test rmwb,0ffh
- jnz h13c
-
- ;------------------ Cross Boundary Horizontal Solid Line
- ;<<<<<Write pixel>>>>>>
- rep stosb ; update the video buffer
- mov cx,dx
- jcxz cxbsldone
- call nextpage
- ;<<<<<Write pixel>>>>>>
- rep stosb ; update the video buffer
- cxbsldone: jmp svlexit
-
-
- ;------------------ Cross Boundary Horizontal Dotted Line
- h13c: cmp rmwb,18h ; fgxor
- jz vgl14a ; jump if pixel should be xored
-
- test rmwb,08h ; fgand
- jnz vgl15a ; jump if pixel should be anded
-
- test rmwb,10h ; fgor
- jnz vgl16a ; jump if pixel should be ored
-
- ;------------------ [fgnorm] set bit
- ;<<<<<Write pixel>>>>>>
- mov bh,transparent
- not bh
-
- or bh,bh ; if transparency off 0xff then
- jnz vgl13a ; line is in bar fill mode
-
- push cx
- mov cx,argx1
- and cl,7
- ; xor cl,7
- rol bl,cl ; ***********fillmask
- ; ror bl,1 ; ***********fillmask
- pop cx
-
- vgl13a: rol bl,1
- jnc vgl13ba
- mov es:[di],al
- inc di
- loop vgl13a
- jmp short vgl13b
-
- vgl13ba: and es:[di],bh
- inc di
- loop vgl13a
-
- vgl13b: mov cx,dx
- jcxz vgl13e
-
- call nextpage
- ;<<<<<Write pixel>>>>>>
- vgl13c: rol bl,1
- jnc vgl13da
- mov es:[di],al
- vgl13d: inc di
- loop vgl13c
- vgl13e: jmp svlexit
-
- vgl13da: and es:[di],bh
- jmp short vgl13d
-
- ;------------------ [fgxor] set bit
- ;<<<<<Write pixel>>>>>>
- vgl14a: rol bl,1
- jnc vgl14b
- xor es:[di],al
- vgl14b: inc di
- loop vgl14a
-
- mov cx,dx
- jcxz vgl14e
-
- call nextpage
- ;<<<<<Write pixel>>>>>>
- vgl14c: rol bl,1
- jnc vgl14d
- xor es:[di],al
- vgl14d: inc di
- loop vgl14c
- vgl14e: jmp svlexit
-
- ;------------------ [fgand] set bit
- ;<<<<<Write pixel>>>>>>
- vgl15a: rol bl,1
- jnc vgl15b
- and es:[di],al
- vgl15b: inc di
- loop vgl15a
-
- mov cx,dx
- jcxz vgl15e
-
- call nextpage
- ;<<<<<Write pixel>>>>>>
- vgl15c: rol bl,1
- jnc vgl15d
- and es:[di],al
- vgl15d: inc di
- loop vgl15c
- vgl15e: jmp svlexit
-
- ;------------------ [fgor] set bit
- ;<<<<<Write pixel>>>>>>
- vgl16a: rol bl,1
- jnc vgl16b
- or es:[di],al
- vgl16b: inc di
- loop vgl16a
-
- mov cx,dx
- jcxz vgl16e
-
- call nextpage
- ;<<<<<Write pixel>>>>>>
- vgl16c: rol bl,1
- jnc vgl16d
- or es:[di],al
- vgl16d: inc di
- loop vgl16c
- vgl16e: jmp svlexit
-
-
- ; routine for dy <= dx (slope <= 1) ; es:di -> video buffer
- ; bx = y-increment
- ; cx = #pixels to draw
- ; si = decision variable
- loslopeline13:
-
- mov al,byte ptr [color] ; al := pixel value
- mov dl,fillmask
- mov dh,byte ptr [rmwb]
-
- ;<<<<<Write pixel>>>>>>
- l11: ror dl,1
- jnc l11b
-
- test dh,0ffh ; fgnorm
- jz sl11a
-
- cmp dh,18h ; fgxor
- jnz sl11b
- xor es:[di],al
- jmp short l11b
-
- sl11b: test dh,08h ; fgand
- jz sl11c
- and es:[di],al
- jmp short l11b
-
- sl11c: test dh,10h ; fgor
- jz sl11a
- or es:[di],al
- jmp short l11b
-
- sl11a: mov es:[di],al ; store pixel, increment x
-
- l11b: inc di
- jnz l11a
- call nextpage
-
- l11a: or si,si ; test sign of d
- jns l12 ; jump if d >= 0
-
- add si,varincr1 ; d := d + incr1
- loop l11
- jmp svlexit
-
- l12: add si,varincr2 ; d := d + incr2
- or bx,bx
- js l12b
- add di,bx ; increment y
- jnc l12a
- call nextpage
- jmp short l12a
-
- l12b:
- add di,bx ; increment y
- jc l12a
- call lastpage
-
- l12a: loop l11
- jmp short svlexit
-
-
- ; routine for dy > dx (slope > 1) ; es:di -> video buffer
- ; bx = y-increment
- ; cx = #pixels to draw
- ; si = decision variable
- hislopeline13:
- mov al,byte ptr [color] ; al := pixel value
- mov dl,fillmask
- mov dh,byte ptr [rmwb]
-
- ;<<<<<Write pixel>>>>>>
- l21: ror dl,1 ; update next pixel, increment x
- jnc l21c
-
- test dh,0ffh ; fgnorm
- jz sl21a
-
- cmp dh,18h ; fgxor
- jnz sl21b
- xor es:[di],al
- jmp short l21c
-
- sl21b: test dh,08h ; fgand
- jz sl21c
- and es:[di],al
- jmp short l21c
-
- sl21c: test dh,10h ; fgor
- jz sl21a
- or es:[di],al
- jmp short l21c
-
- sl21a: mov es:[di],al
-
- l21c: inc di
- jnz l21a
- call nextpage
-
- l21a: or bx,bx
- js l21b
-
- add di,bx ; increment y
- jnc l22
- call nextpage
- jmp short l22
-
- l21b: add di,bx ; increment y
- jc l22
- call lastpage
-
- l22: or si,si ; test sign of d
- jns l23 ; jump if d >= 0
-
- add si,varincr1 ; d := d + incr1
-
- or di,di ; going up!!
- jnz l22b
- call lastpage
-
- l22b: dec di ; decrement x (already incremented
- loop l21 ; by stosb)
- jmp short svlexit
-
- l23: add si,varincr2 ; d := d + incr2
- loop l21
-
- svlexit: pop di
- pop es
- pop si
- pop ds
- ret
-
- fastline endp
-
-
- putpixs proc far argx:word,argy:word,color:word
- local rmwb:word
-
- push ds
- push si
- push es
- push di
-
- cld
- colorxlat color
-
- lds si,cs:TDtable
- mov ax,ds:[si].rmwbits
- mov rmwb,ax
-
- mov ax,ds:[si].wminy
- cmp argy,ax
- jl putpx04
-
- mov ax,ds:[si].wmaxy
- cmp argy,ax
- jg putpx04
-
- mov ax,ds:[si].wminx
- cmp argx,ax
- jl putpx04
-
- mov ax,ds:[si].wmaxx
- cmp argx,ax
- jg putpx04
-
- mov ax,argy ; ax := y
- mov bx,argx ; bx := x
- call activeaddr ; es:bx -> buffer
- mov di,bx
-
- mov bx,rmwb
- mov al,byte ptr [color]
-
- or bl,bl
- jz putpx02
-
- cmp bl,80h ; fgnot
- jnz putpx01
- not al
- jmp short putpx02
-
- putpx01: cmp bl,18h ; fgxor
- jz putpx03
- xor es:[di],al
- jmp short putpx04
-
- putpx03: test bl,08h ; fgand
- jnz putpx05
- and es:[di],al
- jmp short putpx04
-
- putpx05: test bl,10h ; fgor
- jnz putpx02
- or es:[di],al
- jmp short putpx04
-
- putpx02: stosb ; fgnorm
-
- putpx04: pop di
- pop es
- pop si
- pop ds
-
- ret
- putpixs endp
-
-
- scanborder proc far argx:word,argy:word,bordercolor:word,scan:word
- local swminx:word,swmaxx:word
- push ds
- push si
- push es
- push di
-
- lds si,cs:TDtable
- mov ax,ds:[si].wminx
- mov swminx,ax
- mov ax,ds:[si].wmaxx
- mov swmaxx,ax
-
- mov ax,argy ; ax := y
- ; xor bx,bx ; bx := x = 0
- mov bx,argx
- call activeaddr ; ah := bit mask
- ; es:bx -> buffer
- mov di,bx ; es:di -> buffer
-
- mov al,byte ptr [bordercolor] ; ah := color for comparing
- mov si,argx
-
- test scan,8000h
- jz forwscan
-
- ; scan for color match
- backscan: mov cx,si
- inc cx
- sub cx,swminx
- jle scanl08
- jcxz scanl08
-
- scanl01: cmp al,es:[di]
- je scanl08
- dec si
- sub di,1
- jnc scanl02
- call lastpage
- scanl02: loop scanl01
- cld
- jmp short scanl08
-
-
- forwscan: mov cx,swmaxx
- inc cx
- sub cx,argx
- jle scanl08
- jcxz scanl08
-
- scanl03: cmp al,es:[di]
- je scanl08
- inc si
- inc di
- jnz scanl04
- call nextpage
- scanl04: loop scanl03
-
- scanl08: mov ax,si
- pop di
- pop es
- pop si
- pop ds
- ret
- scanborder endp
-
- getpixs proc far argx:word,argy:word
- push es
- push di
-
- mov ax,argy ; ax := y
- mov bx,argx ; bx := x
- call activeaddr ; es:bx -> buffer
- mov di,bx
-
- xor ax,ax
- mov al,es:[di]
-
- pop di
- pop es
- ret
- getpixs endp
-
-
- getbiti proc far argx0:word,argy0:word,argx1:word,argy1:word,addrbuf:dword
- local varpixelrows : word, varpixelrowlen : word
- local bpline:word
-
- push ds
- push si
- push di
-
- cld
- lds si,cs:TDtable
- mov ax,ds:[si].vbytesperline
- mov bpline,ax
-
- mov ax,argy0
- mov bx,argx0
- call activeaddr
- push es
- pop ds
- mov si,bx ; ds:si for screen address
-
- les di,addrbuf ; es:di save buffer
-
- mov ax,argy1
- sub ax,argy0
- inc ax
- mov varpixelrows,ax
- stosw
- mov cx,ax
-
- mov ax,argx1
- sub ax,argx0
- inc ax
- mov varpixelrowlen,ax
- stosw
-
- mov bx,bpline ; next line after current
- sub bx,ax ; position
- mov bpline,bx
-
- xor ax,ax
- stosb
-
-
- getbl01: push cx
- mov cx,varpixelrowlen
-
- mov bx,si
- add bx,cx
- jnc getbl02
-
- mov cx,si
- neg cx
- rep movsb
- call nextpage
- mov cx,bx
-
- getbl02: rep movsb
-
- add si,bpline
- jnc getbl03
- call nextpage
-
- getbl03: pop cx
- test di,08000h
- jz getbl04
- normalize es,di ;pointer to stored bit block
- getbl04: loop getbl01
-
- pop di
- pop si
- pop ds
- ret
- getbiti endp
-
-
- putbiti proc far argx:word,argy:word,addrbuf:dword,rmwb:word
- local varpixelrows:word,varpixelrowlen:word
- local bpline:word
-
- push ds
- push si
- push es
- push di
-
- cld
- lds si,cs:TDtable
- mov ax,ds:[si].vbytesperline
- mov bpline,ax
-
- mov ax,argy
- mov bx,argx
- call activeaddr
- mov di,bx ; es:di for screen address
-
- lds si,addrbuf ; ds:si save buffer
-
- lodsw
- mov varpixelrows,ax
- mov cx,ax
-
- lodsw
- mov varpixelrowlen,ax
-
- mov bx,bpline ; next line after current
- sub bx,ax ; position
- mov bpline,bx
-
- lodsb
-
- mov bx,rmwb
- or bl,bl
- jz putbl01
-
- cmp bl,80h ; fgnot
- jz putnot01
-
- cmp bl,18h ; fgxor
- jnz putbl01b
- jmp putxor01
-
- putbl01b: test bl,08h ; fgand
- jz putbl01a
- jmp putand01
-
- putbl01a: test bl,10h ; fgor
- jz putbl01
- jmp put_or01
-
- ;------------------ [fgnorm] put biti
- putbl01: push cx
- mov cx,varpixelrowlen
-
- mov bx,di
- add bx,cx
- jnc putbl02
-
- mov cx,di
- neg cx
- rep movsb
- call nextpage
- mov cx,bx
-
- putbl02: rep movsb
- add di,bpline
- jnc putbl03
- call nextpage
- putbl03: pop cx
- test si,8000h
- jz putbl04
- normalize ds,si ;pointer to stored bit block
- putbl04: loop putbl01
- jmp putbitdone
-
- ;------------------ [fgnot] put biti
- putnot01: push cx
- mov cx,varpixelrowlen
-
- putnot02: mov al,ds:[si]
- not al
- mov es:[di],al
-
- inc si
- inc di
- jnz putnt2a
- call nextpage
- putnt2a: loop putnot02
-
- add di,bpline
- jnc putnot03
- call nextpage
- putnot03: pop cx
- test si,8000h
- jz putnot04
- normalize ds,si ;pointer to stored bit block
- putnot04: loop putnot01
- jmp putbitdone
-
- ;------------------ [fgxor] put biti
- putxor01: push cx
- mov cx,varpixelrowlen
-
- putxor02: mov al,ds:[si]
- xor es:[di],al
- inc si
- inc di
- jnz putxr2a
- call nextpage
- putxr2a: loop putxor02
-
- add di,bpline
- jnc putxor03
- call nextpage
- putxor03: pop cx
- test si,8000h
- jz putxor04
- normalize ds,si ;pointer to stored bit block
- putxor04: loop putxor01
- jmp short putbitdone
-
- ;------------------ [fgand] put biti
- putand01: push cx
- mov cx,varpixelrowlen
-
- putand02: mov al,ds:[si]
- and es:[di],al
- inc si
- inc di
- jnz putan2a
- call nextpage
- putan2a: loop putand02
-
- add di,bpline
- jnc putand03
- call nextpage
- putand03: pop cx
- test si,8000h
- jz putand04
- normalize ds,si ;pointer to stored bit block
- putand04: loop putand01
- jmp short putbitdone
-
- ;------------------ [fgor] put biti
- put_or01: push cx
- mov cx,varpixelrowlen
-
- put_or02: mov al,ds:[si]
- or es:[di],al
- inc si
- inc di
- jnz putor2a
- call nextpage
- putor2a: loop put_or02
-
- add di,bpline
- jnc put_or03
- call nextpage
- put_or03: pop cx
- test si,8000h
- jz put_or04
- normalize ds,si ;pointer to stored bit block
- put_or04: loop put_or01
-
- putbitdone: pop di
- pop es
- pop si
- pop ds
- ret
- putbiti endp
-
-
- ; extract from buffer2 to buffer1
- extractimg proc far argx0:word,argy0:word,argx1:word,argy1:word,addrbuf1:dword,addrbuf2:dword
- local var1pixelrows : word, var1pixelrowlen : word
- local var2pixelrows : word, var2pixelrowlen : word
-
- push ds
- push si
- push es
- push di
-
- les di,addrbuf1
- lds si,addrbuf2
-
- cld
- lodsw ; var2pixelrows
- mov var2pixelrows,ax
- lodsw ; var2pixelrows
- mov var2pixelrowlen,ax
- lodsb
-
- ; compute dimensions of bit block
- ; build 5-byte bit block header
-
- ; number of pixel rows
- mov ax,argy1
- sub ax,argy0
- inc ax
- mov var1pixelrows,ax
- stosw
-
- ; number of bytes per row
- mov ax,argx1
- sub ax,argx0
- inc ax
- mov var1pixelrowlen,ax
- stosw
-
- mov al,0
- stosb
-
- mov ax,argy0
- mov bx,argx0
-
- mov dx,var2pixelrowlen
- mul dx ; multiply rows by bytesperrow
- add bx,ax
- adc dx,0
-
- add bx,si
- adc dx,0
-
- push bx
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
-
- mov cx,ds
- add cx,bx
- mov ds,cx
- pop si
- and si,0fh
-
- mov bx,var2pixelrowlen
- sub bx,var1pixelrowlen
- mov cx,var1pixelrows
-
- ; copy from bit block2 to bit block1
-
- extrc06: push cx
- mov cx,var1pixelrowlen
-
- rep movsb
-
- add si,bx
- test si,8000h
- jz extrc07
- normalize ds,si
- extrc07: test di,8000h
- jz extrc08
- normalize es,di
- extrc08: pop cx
- loop extrc06
-
- pop di
- pop es
- pop si
- pop ds
- ret
- extractimg endp
-
-
- ; overlay image from addrbuf1 to addrbuf2 at x,y
- overlayimg proc far argx0:word,argy0:word,addrbuf1:dword,addrbuf2:dword
- local var1pixelrows : word, var1pixelrowlen : word
- local var2pixelrows : word, var2pixelrowlen : word
-
- push ds
- push si
- push es
- push di
-
- cld
-
- lds si,addrbuf2
- lodsw ; var2pixelrows
- mov var2pixelrows,ax
- lodsw ; var2pixelrows
- mov var2pixelrowlen,ax
- lodsb
-
- push ds
- push si
- pop di
- pop es
-
- lds si,addrbuf1
- lodsw ; var1pixelrows
- mov var1pixelrows,ax
- lodsw ; var1pixelrows
- mov var1pixelrowlen,ax
- lodsb
-
- mov ax,argy0
- mov bx,argx0
-
- mov dx,var2pixelrowlen
- mul dx ; multiply rows by bytesperrow
- add bx,ax
- adc dx,0
-
- add bx,di
- adc dx,0
-
- push bx
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
-
- mov cx,es
- add cx,bx
- mov es,cx
- pop di
- and di,0fh
-
- mov bx,var2pixelrowlen
- sub bx,var1pixelrowlen
- mov cx,var1pixelrows
-
- ; copy from bit block2 to bit block1
-
- ovrl06: push cx
- mov cx,var1pixelrowlen
-
- rep movsb
-
- add di,bx
- test di,8000h
- jz ovrl07
- normalize es,di
- ovrl07: test si,8000h
- jz ovrl08
- normalize ds,si
- ovrl08: pop cx
- loop ovrl06
-
- pop di
- pop es
- pop si
- pop ds
- ret
-
- overlayimg endp
-
-
- extractpixs proc far argx0:word,argy0:word,addrbuff:dword
- local varpixelrows : word, varpixelrowlen : word
-
- push ds
- push si
- push es
- push di
-
- lds si,addrbuff
-
- cld
- lodsw ; var2pixelrows
- mov varpixelrows,ax
- lodsw ; var2pixelrows
- mov varpixelrowlen,ax
- lodsb
-
-
- mov ax,argy0
- mov bx,argx0
-
- mov dx,varpixelrowlen
- mul dx ; multiply rows by bytesperrow
- add bx,ax
- adc dx,0
-
- add bx,si
- adc dx,0
-
- push bx
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
- shr dx,1
- rcr bx,1
-
- mov cx,ds
- add cx,bx
- mov ds,cx
- pop si
- and si,0fh
-
- mov ax,ds:[si]
-
- pop di
- pop es
- pop si
- pop ds
- ret
- extractpixs endp
-
-
- wrtchar proc far argc:word,argx:word,argy:word,argfgd:word,argbgd:word
- local jaggy:word,transparent:byte,charshift:byte
- local rmwb:word,bpline:word,bpchar:byte,lastbytemask:byte
-
- push ds
- push si
- push es
- push di
-
- colorxlat argfgd
- ; colorxlat argbgd
-
- ; set up character definition table addressing
-
- lds si,cs:TDtable
- les di,ds:[si].fonttable
-
- mov ax,argc ; al := character code
- xor ah,ah
- cmp al,es:[di].FontAsciiStart
- jb nowrtjmp
- cmp al,es:[di].FontAsciiEnd
- jbe okwrtjmp
-
- nowrtjmp: jmp nowrt
-
-
- okwrtjmp:
- mov ax,ds:[si].rmwbits
- mov rmwb,ax
-
- mov ax,ds:[si].vbytesperline
- mov bpline,ax
-
- mov al,ds:[si].transparency
- mov transparent,al
-
- xor ax,ax
- mov al,ds:[si].jagged
- and al,1
- xchg al,ah
- mov jaggy,ax
-
-
- ; calculate first pixel address
- push es
-
- mov ax,argy ; ax := y
- mov bx,argx ; bx := x
- call activeaddr ; es:bx -> buffer
-
- push es ; transfer video buffer segment
- pop ds ; to ds:si
- mov si,bx
-
- ; set up character definition table addressing
- pop es
- xor ax,ax
- mov al,es:[di].FontHeight ;Multiply fontheight by fontwidth
- mov cx,ax
-
- xor bx,bx
- mov bl,es:[di].fontbytewidth
- mov bpchar,bl
- mul bx
-
- mov dx,argc ; dl := character code
- sub dl,es:[di].FontAsciiStart
- mul dx ; ax := offset into char def table
- ; (points * char code)
-
- add di,255 + size TEGLFontInfo ;skip font table info
- add di,ax ; add character offset
-
- mov bl,byte ptr [argfgd] ; bl := foreground pixel value
- mov bh,byte ptr [argbgd] ; bh := background pixel value
-
- mov ch,bpchar ; bytes per character
- xor ax,ax
- mov al,ch ; number of bytes per char width
- shl al,1
- shl al,1
- shl al,1
- mov dx,bpline
- sub dx,ax
-
- ;***This driver has not been adapted to use Transparency
- mov bl,byte ptr [rmwb] ; bl := read-modify-write bits
- mov al,byte ptr [argfgd] ; al := foreground pixel value
- ; mov ch,0
- ; dec cl
- ;***This driver has not been adapted to use Transparency or extended bits
-
- cmp bl,80h ; fgnot
- jnz wrtcl10
- not al
- mov bl,0
-
- wrtcl10: mov ah,es:[di] ; ah := pattern for next row of pixels
-
- xchg cl,byte ptr jaggy
- shr ah,cl ; jaggies
- xchg cl,byte ptr jaggy
-
- mov bh,8
- wrt12: rol ah,1
- jnc wrt11
-
- or bl,bl
- jnz otherwrt
-
- wrtpx02: mov ds:[si],al ; fgnorm
- wrt11: inc si
- jnz wrt11a
- call nextpage
- wrt11a: dec bh
- jnz wrt12
-
- inc di ; es:di -> next byte in char def table
- dec ch ; width bytes
- jnz wrtcl10
-
- add si,dx ; increment to next line in video buffer
- jnc wrt11b
- call nextpage
- wrt11b:
- xchg dx,jaggy
- xchg dl,dh
- xchg dx,jaggy
-
- mov ch,bpchar
- dec cl
- jnz wrtcl10
-
- nowrt: pop di
- pop es
- pop si
- pop ds
- ret
-
- otherwrt: cmp bl,18h ; fgxor
- jz wrtpx03
-
- test bl,08h ; fgand
- jnz wrtpx05
-
- or ds:[si],al ; fgor
- jmp wrt11
-
- wrtpx05: and ds:[si],al
- jmp wrt11
-
- wrtpx03: xor ds:[si],al
- jmp wrt11
-
- wrtchar endp
-
-
- ; ax := y
- ; bx := x
- ; returns es:bx page offset
- ; dx 64k page number
- activeaddr proc near
-
- push ax
- push ds
- push si
-
- lds si,cs:TDtable
- mov dx,ds:[si].vbytesperline
- mul dx ;Multiply y*bytesrow
-
- add bx,ax ;Add in x coordinate
- adc dx,0 ; and any carry
-
- ; cmp dx,cs:current64kpage
- ; jz nonewpage
- mov ax,dx
- call changepage
-
- nonewpage: mov ax,0a000h
- mov es,ax ;ES:BX = byte address of pixel
-
- pop si
- pop ds
- pop ax
- ret
- activeaddr endp
-
-
- mcursoroff proc far
- push es
- push di
- push ds
- push si
-
- ; replace mouse cursor area
- test cs:mflag,1
- jz nomoff
-
- mov cs:mflag,0
-
- mov ax,cs:current64kpage
- push ax
-
- ; modify putbiti to put an array of 16x16 bytes
- les di,dword ptr cs:scradrofs
- mov ax,cs:scradrpg
- cmp ax,cs:current64kpage
- jz nompage
- call changepage
-
- nompage: push cs
- pop ds
- mov si,offset mcursorsavearea
- call mputblock
-
- pop ax
- cmp ax,cs:current64kpage
- je nomoff
- call changepage ; restore video page
-
- nomoff: pop si ; restore caller registers and return
- pop ds
- pop di
- pop es
- ret
- mcursoroff endp
-
-
- mcursoron proc far argx:word,argy:word
- local varshift:word,wordmask:word,mscolor:byte,bpline:word
- local last64kpage:word
- ; assume ds:@data
-
- push es
- push di
- push ds
- push si
-
- mov ax,cs:current64kpage
- push ax
-
- ; save mouse cursor area
- lds si,cs:TDtable
- mov ax,ds:[si].vbytesperline
- sub ax,16
- mov bpline,ax
-
- mov ax,ds:[si].mousecolor
- mov mscolor,al
-
- mov cs:mflag,1 ; mouse cursor on
-
- mov ax,argy ; ax := y
- sub ax,ds:[si].mousehotspot_yofs
- jnc hotset1
- mov ax,argy
-
- hotset1: mov bx,argx ; bx := x
- sub bx,ds:[si].mousehotspot_xofs
- jnc hotset2
- mov bx,argx
-
- hotset2: call activeaddr ; es:bx -> buffer
- mov cs:scradrseg,es
- mov cs:scradrofs,bx
- mov cs:scradrpg,dx
- mov last64kpage,dx
-
- push es
- push cs
- pop es
- pop ds
-
- mov si,bx ; ds:si -> screen buffer
- mov di,offset mcursorsavearea ; es:di -> mcursorsave
- call mgetblock
-
- ; set up mouse cursor table addressing
-
- mov cx,16 ; number of pixel rows in cursor
- lds si,cs:TDtable
- lds si,ds:[si].mousemask
- les di,dword ptr cs:scradrofs
-
- mov ax,last64kpage
- cmp ax,cs:current64kpage
- jz mcl10
- call changepage
-
- mcl10: push cx
- ; push si
-
- mov bx,ds:[si]
- mov cx,16 ; number of pixel per row
- xor ax,ax
- mov ah,mscolor
- mov dx,ds:[si+32]
-
- mcl12: rol bx,1
- jc mcl11
- mov es:[di],al
- mcl11: rol dx,1
- jnc mcl11b
- mov es:[di],ah
- mcl11b: inc di
- jnz mcl11a
- call nextpage
- mcl11a: loop mcl12
-
- ; pop si
- pop cx
-
- inc si
- inc si
-
- add di,bpline
- jnc mcl11c
- call nextpage
- mcl11c: loop mcl10
-
- pop ax
- cmp ax,cs:current64kpage
- je mcl11d
- call changepage ; restore video page
-
- mcl11d: pop si ; restore caller registers and return
- pop ds
- pop di
- pop es
-
- ret
- mcursoron endp
-
- msetpos proc far argx:word,argy:word
- push ds
-
- test cs:mflag,1
- jz nomset
-
- call mcursoroff
-
- mov ax,argx
- push ax
- mov ax,argy
- push ax
- call mcursoron
-
- nomset: pop ds
- ret
- msetpos endp
-
-
- ; assume ds:si=addrbuf es:di=screenadr
- mputblock proc near
- push si
- push di
- push bx
-
- mov dx,ds
- mov ax,si
- lds si,cs:TDtable
- mov bx,ds:[si].vbytesperline
- sub bx,16
- mov si,ax
- mov ds,dx
-
- cld
- mov cx,16
- mcputblck02: push cx
- mov cx,16
-
- mcputblck04: movsb
- or di,di
- jnz mcputblck01
- call nextpage
- mcputblck01: loop mcputblck04
-
- add di,bx
- jnc mcputblck03
- call nextpage
- mcputblck03: pop cx
- loop mcputblck02
-
- pop bx
- pop di
- pop si
- ret
- mputblock endp
-
-
- ; assume es:di=addrbuf ds:si=screenadr
- mgetblock proc near
- push si
- push di
- push bx
-
- mov dx,ds
- mov ax,si
- lds si,cs:TDtable
- mov bx,ds:[si].vbytesperline
- sub bx,16
- mov si,ax
- mov ds,dx
-
- cld
- mov cx,16
- mcgetblck02: push cx
-
- mov cx,16
- mcgetblck04: movsb
- or si,si
- jnz mcgetblck05
- call nextpage
- mcgetblck05: loop mcgetblck04
-
- add si,bx
- jnc mcgetblck03
- call nextpage
- mcgetblck03: pop cx
- loop mcgetblck02
-
- pop bx
- pop di
- pop si
- ret
- mgetblock endp
-
-
-
- lastpage proc near
- push ax
-
- mov ax,cs:current64kpage
- dec ax
-
- call changepage
-
- pop ax
- ret
-
- lastpage endp
-
- nextpage proc near
- push ax
-
- mov ax,cs:current64kpage
- inc ax
-
- call changepage
-
- pop ax
- ret
-
- nextpage endp
-
-
- movevideopixels proc far argx0:word,argy0:word,argx1:word,argy1:word,argx2:word,argy2:word,vertlines:word,horzlines:word,spage:dword,tpage:dword
- local bpline:word,varpixelrows:word,varpixelrowlen:word
- local sourcescr:dword,sourcepage:word,pagechange:word
- local targetscr:dword,targetpage:word,workbuffer:dword
-
- push ds
- push es
- push si
- push di
-
- ;-----------------------------------------------
- cld
-
- lds si,cs:TDtable
- mov ax,ds:[si].vbytesperline
- mov bpline,ax
-
- les di,ds:[si].vgraphbuffer
- mov word ptr [workbuffer],di
- mov word ptr [workbuffer+2],es
-
- mov pagechange,1
- ;-----------------------------------------------
- mov ax,horzlines
- or ax,ax
- jz noadj_89
-
- mov ax,horzlines
- test ah,80h
- jz notneg1 ;scroll left? ; +-+--------+
- ; | <<<< -1 |
- ; +-+--------+
- mov bx,argx0
- sub bx,ax
- mov argx0,bx
- jmp short noadj_89
-
- notneg1: mov bx,argx2 ;scroll right? ; +--------+-+
- add bx,ax ; | 1 >>>> |
- mov argx2,bx ; +--------+-+
-
- mov bx,argx1
- sub bx,ax
- mov argx1,bx
-
- noadj_89:
- mov ax,argx1
- sub ax,argx0
- inc ax ;number of bytes to mov
- mov varpixelrowlen,ax
-
- mov ax,argy1 ;number of lines
- sub ax,argy0 ;number of lines
- inc ax
-
- ;-----------------------------------------------
- ; extablish addressing
- test vertlines,8000h
- jnz bottomupmove
-
- sub ax,vertlines
- mov varpixelrows,ax
-
- mov ax,argy0 ;source ; +----------+
- add ax,vertlines ; +----/\----+
- mov bx,argx0 ; | |
- ; | |
- ; +----------+
-
- mov dx,bpline
- mul dx ;Multiply y*bytesrow
-
- add bx,ax ;Add in x coordinate
- adc dx,0 ; and any carry
-
- mov ax,word ptr [spage]
- and ax,000fh
- add bx,ax
- adc dx,0 ; and any carry
-
- mov ax,word ptr [spage]
- shr ax,1
- shr ax,1
- shr ax,1
- shr ax,1
- add ax,word ptr [spage+2]
-
- mov sourcepage,dx
- mov word ptr [sourcescr],bx
- mov word ptr [sourcescr+2],ax
-
- ;-------
- mov ax,argy2 ;target
- mov bx,argx2
- mov dx,bpline
- mul dx
- add bx,ax
- adc dx,0 ; and any carry
-
- mov ax,word ptr [tpage]
- and ax,000fh
- add bx,ax
- adc dx,0 ; and any carry
-
- mov ax,word ptr [tpage]
- shr ax,1
- shr ax,1
- shr ax,1
- shr ax,1
- add ax,word ptr [tpage+2]
-
- mov targetpage,dx
- mov word ptr [targetscr],bx
- mov word ptr [targetscr+2],ax
- jmp movevideobl_01
-
-
- bottomupmove: add ax,vertlines
- mov varpixelrows,ax
-
- mov ax,argy0 ;source ; +----------+
- add ax,varpixelrows ; | |
- dec ax ; | |
- mov bx,argx0 ; +----\/----+
- ; +----------+
- mov dx,bpline
- mul dx
- add bx,ax ;Add in x coordinate
- adc dx,0 ; and any carry
-
- mov ax,word ptr [spage]
- and ax,000fh
- add bx,ax
- adc dx,0 ; and any carry
-
- mov ax,word ptr [spage]
- shr ax,1
- shr ax,1
- shr ax,1
- shr ax,1
- add ax,word ptr [spage+2]
-
- mov sourcepage,dx
- mov word ptr [sourcescr],bx
- mov word ptr [sourcescr+2],ax
-
-
- mov ax,argy1
- sub ax,argy0
- add ax,argy2
- mov bx,argx2 ;target
-
- mov dx,bpline
- mul dx
- add bx,ax
- adc dx,0 ; and any carry
-
- mov ax,word ptr [tpage]
- and ax,000fh
- add bx,ax
- adc dx,0 ; and any carry
-
- mov ax,word ptr [tpage]
- shr ax,1
- shr ax,1
- shr ax,1
- shr ax,1
- add ax,word ptr [tpage+2]
-
- mov targetpage,dx
- mov word ptr [targetscr],bx
- mov word ptr [targetscr+2],ax
-
- ; xor ax,ax
- ; sub ax,bpline ; negate bpline
- ; mov bpline,ax
-
- xor ax,ax
- sub ax,pagechange
- mov pagechange,ax
-
- ;-----------------------------------------------------move screen to buffer
- movevideobl_01:
- les di,workbuffer
- lds si,sourcescr
- mov ax,sourcepage
- call changepage
-
- mov cx,varpixelrowlen
- mov bx,si
- add bx,cx
- jnc movevideobl_02
-
- mov cx,si
- neg cx
- shr cx,1
- rep movsw
- adc cx,0
- rep movsb
- call nextpage
- mov cx,bx
-
- movevideobl_02: shr cx,1
- rep movsw
- adc cx,0
- rep movsb
-
- ;-----------------------------------------------------move buffer to screen
- mvetoscr_09: lds si,workbuffer
- les di,targetscr
- mov ax,targetpage
- call changepage
-
- mov cx,varpixelrowlen
- mov bx,di
- add bx,cx
- jnc movetoscr_10
-
- mov cx,di
- neg cx
- shr cx,1
- rep movsw
- adc cx,0
- rep movsb
- call nextpage
- mov cx,bx
-
- movetoscr_10: shr cx,1
- rep movsw
- adc cx,0
- rep movsb
- ;-----------------------------------------------------move buffer to screen
- mvetoscr_30: mov ax,bpline
- mov bx,pagechange
- test bx,08000h ;check if we are going backwards
- jz mvetoscr_fwd
-
- sub word ptr [targetscr],ax
- sbb targetpage,0
- sub word ptr [sourcescr],ax
- sbb sourcepage,0
- jmp short mvetoscr_32
-
-
- mvetoscr_fwd: add word ptr [targetscr],ax
- adc targetpage,0
- add word ptr [sourcescr],ax
- adc sourcepage,0
-
- mvetoscr_32: dec varpixelrows
- jz mvetoscr_33
- jmp movevideobl_01
-
- mvetoscr_33:
- pop di
- pop si
- pop es
- pop ds
- ret
- movevideopixels endp
-
-
-
- setvpage proc far pagen:word
- push ds
- push si
- push es
- push di
-
- lds si,cs:TDtable
- mov ax,pagen
- cmp ax,ds:[si].vmaxpages
- jg novpage
-
- mov bx,40h
- mov ds,bx
- mov si,62h
- mov ds:[si],al
- mov si,4eh
- xor bx,bx
- or al,al
- jz vpageit
- mov bx,8000h
- vpageit: mov ds:[si],bx
-
- mov ah,5
- int 10h
-
- novpage: pop di
- pop es
- pop si
- pop ds
- ret
- setvpage endp
-
- setapage proc far pagen:word
- push ds
- push si
- push es
- push di
-
- lds si,cs:TDtable
- mov ax,pagen
- cmp ax,ds:[si].vmaxpages
- jg noapage
-
- or al,al ; if 0 then mov 0 to activepage
- mov ds:[si].activepage,0
- jz noapage
- mov ds:[si].activepage,8000h
-
- noapage: pop di
- pop es
- pop si
- pop ds
- ret
- setapage endp
-
-
- ;----------------------------------------------------------------------------;
- ; ;
- ;----------------------------------------------------------------------------;
-
- changepage proc near ;bank number is in AX
- cli
- mov cs:current64kpage,ax
- jmp word ptr cs:bankadr
- changepage endp
-
- _tseng proc near ;Tseng
- push ax
- push dx
- and al,7
- mov ah,al
- shl al,1
- shl al,1
- shl al,1
- or al,ah
- or al,01000000b
- mov dx,3cdh
- out dx,al
- sti
- pop dx
- pop ax
- ret
- _tseng endp
-
-
- _tseng4 proc near ;Tseng 4000 series
- push ax
- push dx
- mov ah,al
- mov dx,3bfh ;Enable access to extended registers
- mov al,3
- out dx,al
- mov dl,0d8h
- mov al,0a0h
- out dx,al
- and ah,15
- mov al,ah
- shl al,1
- shl al,1
- shl al,1
- shl al,1
- or al,ah
- mov dl,0cdh
- out dx,al
- sti
- pop dx
- pop ax
- ret
- _tseng4 endp
-
-
- _trident proc near ;Trident
- push ax
- push dx
- mov dx,3ceh ;set page size to 64k
- mov al,6
- out dx,al
- inc dl
- in al,dx
- dec dl
- or al,4
- mov ah,al
- mov al,6
- out dx,ax
-
- mov dl,0c4h ;switch to BPS mode
- mov al,0bh
- out dx,al
- inc dl
- in al,dx
- dec dl
-
- mov ah,byte ptr cs:current64kpage ;OSEG
- xor ah,2
- mov dx,3c4h
- mov al,0eh
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _trident endp
-
-
- _video7 proc near ;Video 7
- push ax
- push dx
- push cx
- and ax,15
- mov ch,al
- mov dx,3c4h
- mov ax,0ea06h
- out dx,ax
- mov ah,ch
- and ah,1
- mov al,0f9h
- out dx,ax
- mov al,ch
- and al,1100b
- mov ah,al
- shr ah,1
- shr ah,1
- or ah,al
- mov al,0f6h
- out dx,al
- inc dx
- in al,dx
- dec dx
- and al,not 1111b
- or ah,al
- mov al,0f6h
- out dx,ax
- mov ah,ch
- mov cl,4
- shl ah,cl
- and ah,100000b
- mov dl,0cch
- in al,dx
- mov dl,0c2h
- and al,not 100000b
- or al,ah
- out dx,al
- sti
- pop cx
- pop dx
- pop ax
- ret
- _video7 endp
-
-
- _paradise proc near ;Paradise
- push ax
- push dx
- mov dx,3ceh
- mov ax,50fh ;turn off write protect on VGA registers
- out dx,ax
- mov ah,byte ptr cs:current64kpage ;OSEG
- shl ah,1
- shl ah,1
- shl ah,1
- shl ah,1
- mov al,9
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _paradise endp
-
-
- _chipstech proc near ;Chips & Tech
- push ax
- push dx
- mov dx,46e8h ;place chip in setup mode
- mov ax,1eh
- out dx,ax
- mov dx,103h ;enable extended registers
- mov ax,0080h
- out dx,ax
- mov dx,46e8h ;bring chip out of setup mode
- mov ax,0eh
- out dx,ax
- mov ah,byte ptr cs:current64kpage ;OSEG[curbk]
- shl ah,1 ;change 64k bank number into 16k bank number
- shl ah,1
- mov al,10h
- mov dx,3d6h
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _chipstech endp
-
-
- _ativga proc near ;ATI VGA Wonder
- push ax
- push dx
- mov ah,al
- mov dx,1ceh
- mov al,0b2h
- out dx,al
- inc dl
- in al,dx
- shl ah,1
- and al,0e1h
- or ah,al
- mov al,0b2h
- dec dl
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _ativga endp
-
-
- _everex proc near ;Everex
- push ax
- push dx
- push cx
- mov cl,al
- mov dx,3c4h
- mov al,8
- out dx,al
- inc dl
- in al,dx
- dec dl
- shl al,1
- shr cl,1
- rcr al,1
- mov ah,al
- mov al,8
- out dx,ax
- mov dl,0cch
- in al,dx
- mov dl,0c2h
- and al,0dfh
- shr cl,1
- jc nob2
- or al,20h
- nob2: out dx,al
- sti
- pop cx
- pop dx
- pop ax
- ret
- _everex endp
-
-
- _aheada proc near ;Ahead Systems Ver A
- push ax
- push dx
- push cx
- mov ch,al
- mov dx,3ceh ;Enable extended registers
- mov ax,200fh
- out dx,ax
- mov dl,0cch ;bit 0
- in al,dx
- mov dl,0c2h
- and al,11011111b
- shr ch,1
- jnc skpa
- or al,00100000b
- skpa: out dx,al
- mov dl,0cfh ;bits 1,2,3
- mov al,0
- out dx,al
- inc dx
- in al,dx
- dec dx
- and al,11111000b
- or al,ch
- mov ah,al
- mov al,0
- out dx,ax
- sti
- pop cx
- pop dx
- pop ax
- ret
- _aheada endp
-
-
- _aheadb proc near ;Ahead Systems Ver A
- push ax
- push dx
- push cx
- mov ch,al
- mov dx,3ceh ;Enable extended registers
- mov ax,200fh
- out dx,ax
- mov ah,ch
- mov cl,4
- shl ah,cl
- or ah,ch
- mov al,0dh
- out dx,ax
- sti
- pop cx
- pop dx
- pop ax
- ret
- _aheadb endp
-
-
- _oaktech proc near ;Oak Technology Inc OTI-067
- push ax
- push dx
- and al,15
- mov ah,al
- shl al,1
- shl al,1
- shl al,1
- shl al,1
- or ah,al
- mov al,11h
- mov dx,3deh
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _oaktech endp
-
- _genoa proc near
- push ax
- push dx
- mov ah,al
- shl al,1
- shl al,1
- shl al,1
- or ah,al
- mov al,6
- or ah,40h
- mov dx,3c4h
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _genoa endp
-
- _ncr proc near ;NCR 77C22E
- push ax
- push dx
- shl al,1 ;change 64k bank number into 16k bank number
- shl al,1
- mov ah,al
- mov al,18h
- mov dx,3c4h
- out dx,ax
- mov ax,19h
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _ncr endp
-
- _compaq proc near ;Compaq
- push ax
- push dx
- mov dx,3ceh
- mov ax,50fh ;unlock extended registers
- out dx,ax
- mov ah,byte ptr cs:current64kpage ;OSEG[curbk]
- shl ah,1 ;change 64k bank number into 4k bank number
- shl ah,1
- shl ah,1
- shl ah,1
- mov al,45h
- out dx,ax
- sti
- pop dx
- pop ax
- ret
- _compaq endp
-
- _vesa proc near ;Vesa SVGA interface
- push ax
- push bx
- push cx
- push dx
- mov cl,[vesashift]
- shl ax,cl
- mov dx,ax
- xor bx,bx
- mov ax,4f05h
- int 10h
- sti
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- _vesa endp
-
-
- _nobank proc near
- sti
- ret
- _nobank endp
-
-
- ;----------------------------------------------------------------------------;
- ; ;
- ;----------------------------------------------------------------------------;
- whichsvga proc near
- push es
- push di
- push ds
- push si
- push dx
- push cx
- push bx
-
- lds si,cs:TDTable
- lds si,ds:[si].vjumptable
- add si,_nobank-drvjumptable
- mov cs:bankadr,si
-
- mov cs:current64kpage,0
- mov cs:vga512flag,0
- mov cs:vga1024flag,0
- mov cs:svgatype,-2
-
- call getvgatype
-
- mov ax,cs:svgatype
- cmp ax,x_genoa
- mov bx,_genoa-drvjumptable
- je found
-
- cmp ax,x_paradise
- mov bx,_paradise-drvjumptable
- je found
-
- cmp ax,x_ativga
- mov bx,_ativga-drvjumptable
- je found
-
- cmp ax,x_everex
- mov bx,_everex-drvjumptable
- je found
-
- cmp ax,x_trident
- mov bx,_trident-drvjumptable
- je found
- cmp ax,x_t8900
- je found
-
- cmp ax,x_video7
- mov bx,_video7-drvjumptable
- je found
-
- cmp ax,x_chipstech
- mov bx,_chipstech-drvjumptable
- je found
-
- cmp ax,x_tseng4
- mov bx,_tseng4-drvjumptable
- je found
-
- cmp ax,x_tseng
- mov bx,_tseng-drvjumptable
- je found
-
- cmp ax,x_aheada
- mov bx,_aheada-drvjumptable
- je found
-
- cmp ax,x_aheadb
- mov bx,_aheadb-drvjumptable
- je found
-
- cmp ax,x_oaktech
- mov bx,_oaktech-drvjumptable
- je found
-
- cmp ax,x_cirrus
- mov bx,_nobank-drvjumptable
- je found
-
- cmp ax,x_ncr
- mov bx,_ncr-drvjumptable
- je found
-
- cmp ax,x_compaq
- mov bx,_compaq-drvjumptable
- je found
-
- cmp ax,x_vesa
- mov bx,_vesa-drvjumptable
-
- stc
- jne nofnd
-
- found: lds si,cs:TDTable
- lds si,ds:[si].vjumptable
- add si,bx
- mov cs:bankadr,si
-
- clc
- nofnd: pop bx
- pop cx
- pop dx
- pop si
- pop ds
- pop di
- pop es
- ret
- whichsvga endp
-
- ;----------------------------------------------------------------------------;
- ; ;
- ;----------------------------------------------------------------------------;
- nojmp macro
- local lbl
- jmp lbl
- lbl:
- endm
-
-
- getvgatype proc near
- mov si,1
- mov ax,0c000h
- mov es,ax
- cmp word ptr es:[40h],'13' ;ATI Signiture on the Video BIOS
- jnz noati
-
- mov cs:svgatype,x_ativga
- cli
- mov dx,1ceh
- mov al,0bbh
- out dx,al
- inc dl
- in al,dx
- sti
- and al,20h
- jz no512
- mov cs:vga512flag,1
- no512: jmp fini
-
- noati: mov ax,7000h ;Test for Everex
- xor bx,bx
- cld
- int 10h
- cmp al,70h
- jnz noev
-
- mov cs:svgatype,x_everex
- and ch,11000000b ;how much memory on board
- jz skp
- mov cs:vga512flag,1
- skp: ;fall through for Everex boards using Trident or Tseng4000
-
- noev: mov ax,0bf03h ;Test for Compaq
- xor bx,bx
- mov cx,bx
- int 10h
- cmp ax,0bf03h
- jnz nocp
- test cl,40h ;is 640x480x256 available?
- jz nocp
- mov cs:svgatype,x_compaq
- mov cs:vga512flag,1
- jmp fini
-
- nocp: mov dx,3c4h ;Test for NCR 77C22E
- mov ax,0ff05h
- call _isport2
- jnz noncr
- mov ax,5 ;Disable extended registers
- out dx,ax
- mov ax,0ff10h ;Try to write to extended register 10
- call _isport2 ;If it writes then not NCR
- jz noncr
- mov ax,105h ;Enable extended registers
- out dx,ax
- mov ax,0ff10h
- call _isport2
- jnz noncr ;If it does NOT write then not NCR
- mov cs:svgatype,x_ncr
- mov cs:vga512flag,1
- jmp fini
-
- noncr: mov dx,3c4h ;Test for Trident
- mov al,0bh
- out dx,al
- inc dl
- in al,dx
- cmp al,06h
- ja notri
- cmp al,2
- jb notri
- mov cs:svgatype,x_trident
- cmp al,3
- jb no89
- mov cs:svgatype,x_t8900
- mov dx,3d5h
- mov al,1fh
- out dx,al
- inc dx
- in al,dx
- and al,3
- cmp al,1
- jb notmem
- mov cs:vga512flag,1
- je notmem
- mov cs:vga1024flag,1
- notmem: jmp fini
-
- no89: mov cs:vga512flag,1
- jmp fini
-
- notri: mov ax,6f00h ;Test for Video 7
- xor bx,bx
- cld
- int 10h
- cmp bx,'V7'
- jnz nov7
- mov cs:svgatype,x_video7
- mov ax,6f07h
- cld
- int 10h
- and ah,7fh
- cmp ah,1
- jbe skp2
- mov cs:vga512flag,1
- skp2: cmp ah,3
- jbe skp3
- mov cs:vga1024flag,1
- skp3: jmp fini
-
- nov7: mov dx,3d4h ;Test for GENOA GVGA
- mov ax,032eh ;check for Herchi Register
- call _isport2
- jnz nogn
- mov dx,3c4h ;check for memory segment register
- mov ax,3f06h
- call _isport2
- jnz nogn
- mov cs:svgatype,x_genoa
- mov cs:vga512flag,1
- jmp fini
-
- nogn: call _cirrus ;Test for Cirrus
- cmp cs:svgatype,x_cirrus
- jne noci
- jmp fini
-
- noci: mov dx,3ceh ;Test for Paradise
- mov al,9 ;check Bank switch register
- out dx,al
- inc dx
- in al,dx
- dec dx
- or al,al
- jnz nopd
-
- mov ax,50fh ;turn off write protect on VGA registers
- out dx,ax
- mov cx,1
- mov dx,3ceh ;Test for Paradise
- call _chkbk
- jc nopd ;if bank 0 and 1 same not paradise
- mov cs:svgatype,x_paradise
- mov dx,3ceh
- mov al,0bh ;512k detect from Bob Berry
- out dx,al
- inc dx
- in al,dx
- test al,80h ;if top bit set then 512k
- jz nop512
- mov cs:vga512flag,1
- nop512: jmp fini
-
- nopd: mov ax,5f00h ;Test for Chips & Tech
- xor bx,bx
- cld
- int 10h
- cmp al,5fh
- jnz noct
- mov cs:svgatype,x_chipstech
- cmp bh,1
- jb skp4
- mov cs:vga512flag,1
- skp4: jmp fini
-
- noct: mov ch,0
- mov dx,3d4h ;check for Tseng 4000 series
- mov ax,0f33h
- call _isport2
- jnz not4
- mov ch,1
-
- mov dx,3bfh ;Enable access to extended registers
- mov al,3
- out dx,al
- mov dx,3d8h
- mov al,0a0h
- out dx,al
- jmp short yes4
-
- not4: mov dx,3d4h ;Test for Tseng 3000 or 4000
- mov ax,1f25h ;is the Overflow High register there?
- call _isport2
- jnz nots
- mov al,03fh ;bottom six bits only
- jmp short yes3
- yes4: mov al,0ffh
- yes3: mov dx,3cdh ;test bank switch register
- call _isport1
- jnz nots
- mov cs:svgatype,x_tseng
- cmp ch,0
- jnz t4mem
- mov cs:vga512flag,1
- jmp fini
-
- t4mem: mov dx,3d4h ;Tseng 4000 memory detect 1meg
- mov al,37h
- out dx,al
- inc dx
- in al,dx
- test al,1000b ;if using 64kx4 RAMs then no more than 256k
- jz nomem
- and al,3
- cmp al,1 ;if 8 bit wide bus then only two 256kx4 RAMs
- jbe nomem
- mov cs:vga512flag,1
- cmp al,2 ;if 16 bit wide bus then four 256kx4 RAMs
- je nomem
- mov cs:vga1024flag,1 ;full meg with eight 256kx4 RAMs
- nomem: mov cs:svgatype,x_tseng4
- jmp fini
-
- nots:
- mov dx,3ceh ;Test for Above A or B chipsets
- mov ax,200fh
- out dx,ax
- inc dx
- nojmp
- in al,dx
- cmp al,21h
- jz verb
- cmp al,20h
- jnz noab
- mov cs:svgatype,x_aheada
- mov cs:vga512flag,1
- jmp short fini
-
- verb: mov cs:svgatype,x_aheadb
- mov cs:vga512flag,1
- jmp short fini
-
- noab: mov dx,3deh ;Test for Oak Technology
- mov ax,0ff11h ;look for bank switch register
- call _isport2
- jz oakok
-
- push es
- push di
- push cx
-
- cld
- mov ax,0c000h
- mov es,ax
- xor di,di
- mov cx,256
-
- mov al,'O'
- findoak: repne scasb
- jcxz notoak
-
- cmp byte ptr es:[di],'A'
- jne findoak
-
- cmp byte ptr es:[di+1],'K'
- jne findoak
-
- pop cx
- pop di
- pop es
- jmp short oakok
-
-
- notoak: pop cx
- pop di
- pop es
- jmp short nooak
-
- oakok: mov cs:svgatype,x_oaktech
- mov al,0dh
- out dx,al
- inc dx
- nojmp
- in al,dx
- test al,80h
- jz no4ram
- mov cs:vga512flag,1
- no4ram: jmp short fini
-
- nooak: mov si,0
-
- fini: mov ax,si
- ret
- getvgatype endp
-
-
- _cirrus proc near
- mov dx,3d4h ; assume 3dx addressing
- mov al,0ch ; screen a start address hi
- out dx,al ; select index
- inc dx ; point to data
- mov ah,al ; save index in ah
- in al,dx ; get screen a start address hi
- xchg ah,al ; swap index and data
- push ax ; save old value
- push dx ; save crtc address
- xor al,al ; clear crc
- out dx,al ; and out to the crtc
-
- mov al,1fh ; Eagle ID register
- dec dx ; back to index
- out dx,al ; select index
- inc dx ; point to data
- in al,dx ; read the id register
- mov bh,al ; and save it in bh
-
- mov cl,4 ; nibble swap rotate count
- mov dx,3c4h ; sequencer/extensions
- mov bl,6 ; extensions enable register
-
- ror bh,cl ; compute extensions disable value
- mov ax,bx ; extensions disable
- out dx,ax ; disable extensions
- inc dx ; point to data
- in al,dx ; read enable flag
- or al,al ; disabled ?
- jnz exit ; nope, not an cirrus
-
- ror bh,cl ; compute extensions enable value
- dec dx ; point to index
- mov ax,bx ; extensions enable
- out dx,ax ; enable extensions
- inc dx ; point to data
- in al,dx ; read enable flag
- cmp al,1 ; enabled ?
- jne exit ; nope, not an cirrus
- mov cs:svgatype,x_cirrus
-
- exit: pop dx ; restore crtc address
- dec dx ; point to index
- pop ax ; recover crc index and data
- out dx,ax ; restore crc value
- ret
- _cirrus endp
-
- _chkbk proc near ;bank switch check routine
- push es
- mov di,0b800h
- mov es,di
- xor di,di
- mov bx,1234h
- call _gochk
- jnz badchk
- mov bx,4321h
- call _gochk
- jnz badchk
- clc
- pop es
- ret
- badchk: stc
- pop es
- ret
- _chkbk endp
-
- _gochk proc near
- push si
- push es
- mov si,bx
-
- mov al,cl
- call _pdrsub
- xchg bl,es:[di]
- mov al,ch
- call _pdrsub
- xchg bh,es:[di]
-
- xchg si,bx
-
- mov al,cl
- call _pdrsub
- xor bl,es:[di]
- mov al,ch
- call _pdrsub
- xor bh,es:[di]
-
- xchg si,bx
-
- mov al,ch
- call _pdrsub
- mov es:[di],bh
- mov al,cl
- call _pdrsub
- mov es:[di],bl
-
- mov al,0
- call _pdrsub
- or si,si
- pop es
- pop si
- ret
- _gochk endp
-
-
- _pdrsub proc near ;Paradise
- mov ah,al
- mov al,9
- out dx,ax
- ret
- _pdrsub endp
-
-
- _isport2 proc near
- push bx
- mov bx,ax
- out dx,al
- mov ah,al
- inc dx
- in al,dx
- dec dx
- xchg al,ah
- push ax
- mov ax,bx
- out dx,ax
- out dx,al
- mov ah,al
- inc dx
- in al,dx
- dec dx
- and al,bh
- cmp al,bh
- jnz noport2
- mov al,ah
- mov ah,0
- out dx,ax
- out dx,al
- mov ah,al
- inc dx
- in al,dx
- dec dx
- and al,bh
- cmp al,0
- noport2: pop ax
- out dx,ax
- pop bx
- ret
- _isport2 endp
-
- _isport1 proc near
- mov ah,al
- in al,dx
- push ax
- mov al,ah
- out dx,al
- in al,dx
- and al,ah
- cmp al,ah
- jnz noport1
- mov al,0
- out dx,al
- in al,dx
- and al,ah
- cmp al,0
- noport1: pop ax
- out dx,al
- ret
- _isport1 endp
-
-
- end