home *** CD-ROM | disk | FTP | other *** search
- page 58,132
- ;/*
- ;** fvideo.asm
- ;** contains: setfdrvr(),fgetchat(),fwstr(),frwstr(),fatwstr(),fratwstr(),
- ;** fatwch(),getscrn(),putscrn()
- ;*/
-
- ifndef _LCODE
- include model.h
- endif
- include prologue.h
- name fastvideo
-
- CGAGRSTATUS equ 03dah ;CGA status register
- CGAREGENSEG equ 0b800h ;Segment of CGA regen buffer
- MDAREGENSEG equ 0b000h ;Segment of Monochrome regen buffer
-
- BIOSVIDEO equ 010h ;Rom Bios Video Interrupt #
- GETCURSPOS equ 03h ;Rom Bios Get cursor position
- SETCURSPOS equ 02h ;Rom Bios Set cursor position
- GETCURVIDMODE equ 15 ;Rom Bios Get current video mode
-
-
- ;CRTWAIT: Assume: DX=0x3da
- ; Uses AL register
- ; Waits for Horizontal sync pulse as read from
- ; status register.
- ;
- CRTWAIT macro
- local looph3,looph4
- cli
- looph3: in al,dx
- rcr al,1
- jb looph3 ;;wait till not in again
- looph4: in al,dx
- rcr al,1
- jnb looph4 ;;wait till in horizontal again
- endm
-
-
- dseg dfastvideo
-
- disptable dw offset trapstub1 ;CGA write string at specified cursor
- dw offset trapstub2 ;CGA write string & attribute at specified cursor
- dw offset trapstub3 ;CGA read character & attribute at specified cursor
- dw offset trapstub4 ;CGA write character & attribute
- dw offset trapstub5 ;CGA get region
- dw offset trapstub6 ;CGA put region
-
- tablesize equ ($-disptable)/2
-
-
- ;==>-- Low level routines for Monochrome Display Adapter (MDA)
- ;
- montbl dw offset mwsacur ;mono write string at specified cursor
- dw offset mwsaaccur ;mono write string & attribute at specified cursor
- dw offset mrchatatcur ;mono read character & attribute at specified cursor
- dw offset mwachat ;mono write character & attribute at specified cursor
- dw offset mdgetregion ;mono get region to buffer
- dw offset mdputregion ;mono put buffer to region
-
- ;==>-- Low level routines for Color Graphics Adapter (CGA) with horizontal
- ; retrace checking to eliminate snow.
- ;
- cgartbl dw offset cgracur ;CGA write string at specified cursor
- dw offset cgraaccur ;CGA write string & attribute at specified cursor
- dw offset cgrrchatatcur ;CGA read character & attribute at specified cursor
- dw offset cgrachat ;CGA write character & attribute
- dw offset cgrgetregion ;CGA get region
- dw offset cgrputregion ;CGA put region
-
- ;==>-- Low level routines for Color Graphics Adapter (CGA) without horizontal
- ; retrace checking to eliminate snow. Faster than cgartbl routines and
- ; acceptable on EGA & VGA and other adapters that do not have the snow
- ; problem.
- ;
- cgatbl dw offset cgacur ;CGA write string at specified cursor
- dw offset cgaaaccur ;CGA write string & attribute at specified cursor
- dw offset cgrchatatcur ;CGA read character & attribute at specified cursor
- dw offset cgawchat ;CGA write character & attribute
- dw offset cggetregion ;CGA get region
- dw offset cgputregion ;CGA put region
-
-
- endds
-
-
- pseg cfastvideo
-
- subttl [C functions]
- page
-
-
- ;/*
- ;** void
- ;** setfdrvr(int driverid)
- ;**
- ;** ARGUMENT(s)
- ;** driverid - i.d. of driver to set:
- ;** 0 = monochrome driver
- ;** 1 = CGA driver without retrace checking
- ;** 2 = CGA driver with retrace checking
- ;**
- ;** - -1 = do automatic "best guess" setup.
- ;**
- ;**
- ;** DESCRIPTION
- ;** Permits user program to determine which of the low level drivers will
- ;** be used with the fast video functions. Calling this function is not
- ;** normally necessary.
- ;**
- ;** RETURNS
- ;** void.
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 15:02:21
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc setfdrvr
- mov dx,parm1_ ;dx = option
- cmp dx,0ffffh ;auto requested?
- jnz setman ;if not use parameter
- call autosetup ;else do auto setup
- jmp short setexit
- setman: call setdriver
- setexit:
- cproce
-
-
-
-
-
- ;/*
- ;** unsigned
- ;** fgetchat(int row,int col)
- ;**
- ;** ARGUMENT(s)
- ;** row - Row to read
- ;** col - Column to read
- ;**
- ;** DESCRIPTION
- ;** Returns the character and attribute at the specified row/column.
- ;**
- ;**
- ;** RETURNS
- ;** The Character is returned in the lower 8 bits of the 16 bit value, the
- ;** attribute is returned in the upper 8 bits of the 16 bit value.
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 10:12:13
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc fgetchat
- mov al,parm1_
- mov cl,parm2_
- call disptable+4
- cproce
-
-
- ;/*
- ;** void
- ;** fwstr(char *string)
- ;**
- ;** ARGUMENT(s)
- ;** string - points to null terminated string to write
- ;**
- ;** DESCRIPTION
- ;** Writes string at current cursor location. Moves cursor to new location
- ;** when finished. Does not modify attribute.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 16:03:51
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc fwstr
- mov ah,GETCURSPOS
- xor bh,bh ;page 0
- int BIOSVIDEO ;get cursor row/col to dh/dl
- push dx ;save for later
- if _LDATA
- les di,parm1_ ;ES:DI point to string
- else
- mov ax,ds
- mov es,ax
- mov di,parm1_ ;ES:DI point to string
- endif
- mov al,dh ;AL = row number
- mov cl,dl ;CL = column number
- call disptable ;call via table
- pop dx
- add dl,al ;adjust cursor column
- cmp dl,80 ;see if above max column
- jb fwstrnotend
- mov dl,79 ;stop at max column
- fwstrnotend: xor bh,bh
- mov ah,SETCURSPOS
- int BIOSVIDEO
- cproce
-
-
-
- ;/*
- ;** void
- ;** frwstr(int color,char *string)
- ;**
- ;** ARGUMENT(s)
- ;** color - color to write
- ;** string - points to null terminated string to write
- ;**
- ;** DESCRIPTION
- ;** Writes string in color attribute at current cursor location. Moves cursor to
- ;** new location when finished.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 10:00:43
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc frwstr
- mov ah,GETCURSPOS
- xor bh,bh ;page 0
- int BIOSVIDEO ;get cursor row/col to dh/dl
- push dx ;save for later
- if _LDATA
- les di,parm2_ ;ES:DI point to string
- else
- mov ax,ds
- mov es,ax
- mov di,parm2_ ;ES:DI point to string
- endif
- mov al,dh ;AL = row number
- mov cl,dl ;CL = column number
- mov ch,parm1_ ;CH = attribute to use
- call disptable+2 ;call via table
- pop dx
- add dl,al ;adjust cursor column
- cmp dl,80 ;see if above max column
- jb frwstrnotend
- mov dl,79 ;stop at max column
- frwstrnotend: xor bh,bh
- mov ah,SETCURSPOS
- int BIOSVIDEO
- cproce
-
- ;/*
- ;** void
- ;** fatwstr(int row,int col,char *string)
- ;**
- ;** ARGUMENT(s)
- ;** row - Y position for write (row #)
- ;** col - X position for write (column #)
- ;** string - points to null terminated string to write
- ;**
- ;** DESCRIPTION
- ;** Writes string at specified cursor location. Moves cursor to new location
- ;** when finished. Does not modify attribute.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 09:09:49
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc fatwstr
- if _LDATA
- les di,parm3_ ;ES:DI point to string
- else
- mov ax,ds
- mov es,ax
- mov di,parm3_ ;ES:DI point to string
- endif
- mov al,parm1_ ;AL = row number
- mov cl,parm2_ ;CL = column number
- call disptable ;call via table
- mov dl,parm2_ ;DL = column
- mov dh,parm1_ ;DH = row number
- add dl,al ;adjust cursor column
- cmp dl,80 ;see if above max column
- jb fatwstrnotend
- mov dl,79 ;stop at max column
- fatwstrnotend: xor bh,bh ;set new cursor position
- mov ah,SETCURSPOS
- int BIOSVIDEO
- cproce
-
-
- ;/*
- ;** void
- ;** fratwstr(int row,int col,int color,char *string)
- ;**
- ;** ARGUMENT(s)
- ;** row - Y position for write (row #)
- ;** col - X position for write (column #)
- ;** color - Attribute (color) to use
- ;** string - points to null terminated string to write
- ;**
- ;** DESCRIPTION
- ;** Writes string at specified cursor location using specified attribute.
- ;** Moves cursor to new location when finished.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 10:07:58
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc fratwstr
- if _LDATA
- les di,parm4_ ;ES:DI point to string
- else
- mov ax,ds
- mov es,ax
- mov di,parm4_ ;ES:DI point to string
- endif
- mov al,parm1_ ;AL = row number
- mov cl,parm2_ ;CL = column number
- mov ch,parm3_ ;CH = attribute
- call disptable+2 ;call via table
- mov dl,parm2_ ;DL = column
- mov dh,parm1_ ;DH = row number
- add dl,al ;adjust cursor column
- cmp dl,80 ;see if above max column
- jb fratwstrnotend
- mov dl,79 ;stop at max column
- fratwstrnotend: xor bh,bh ;set new cursor position
- mov ah,SETCURSPOS
- int BIOSVIDEO
- cproce
-
-
- ;/*
- ;** void
- ;** fatwch(int row,int col,int character,unsigned char attribute)
- ;**
- ;** ARGUMENT(s)
- ;**
- ;** row - row to put character on
- ;** col - column to put character on
- ;** character - character to be displayed
- ;** attribute - attribute to be displayed
- ;**
- ;** DESCRIPTION
- ;** Puts character/attribute at row/col specified. Increments cursor to the
- ;** next character position.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 13:20:23
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc fatwch
- mov al,parm1_ ;AL = row
- mov cl,parm2_ ;CL = column
- mov dl,parm3_ ;DL = character
- mov dh,parm4_ ;DH = attribute
- call disptable+6
- mov dh,parm1_ ;DH = row
- mov dl,parm2_ ;DL = col
- inc dl ;increment cursor position
- cmp dl,80
- jb notend1
- mov dl,79
- notend1: xor bh,bh
- mov ah,SETCURSPOS
- int BIOSVIDEO
- cproce
-
-
-
- ;/*
- ;** void
- ;** getscrn(int ulrow,int ulcol,int lrrow,int lrcol,unsigned *buffer)
- ;**
- ;** ARGUMENT(s)
- ;** ulrow - upper left row of region
- ;** ulcol - upper left column of region
- ;** lrrow - lower right row of region
- ;** lrcol - lower right column of region
- ;** buffer - buffer to receive information
- ;**
- ;** DESCRIPTION
- ;** Moves characters and attributes from the rectangular region defined
- ;** by the ulrow/ulcol and lrrow/lrcol to the buffer.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 13:42:01
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc getscrn
- mov al,parm1_ ;AL = ulrow
- mov cl,parm2_ ;CL = ulcol
- mov dh,parm3_ ;DH = lrrow
- sub dh,al ;calculate total number
- inc dh
- mov dl,parm4_ ;DL = lrcol
- sub dl,cl ;calculate total number
- inc dl
- if _LDATA
- les di,parm5_
- else
- mov bx,ds
- mov es,bx
- mov di,parm5_
- endif
- call disptable+8
- cproce
-
- ;/*
- ;** void
- ;** putscrn(int ulrow,int ulcol,int lrrow,int lrcol,unsigned *buffer)
- ;**
- ;** ARGUMENT(s)
- ;** ulrow - upper left row of region
- ;** ulcol - upper left column of region
- ;** lrrow - lower right row of region
- ;** lrcol - lower right column of region
- ;** buffer - buffer holding information
- ;**
- ;** DESCRIPTION
- ;** Moves characters and attributes from the buffer to the rectangular region
- ;** defined by the ulrow/ulcol and lrrow/lrcol.
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 14:15:10
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cproc putscrn
- mov al,parm1_ ;AL = ulrow
- mov cl,parm2_ ;CL = ulcol
- mov dh,parm3_ ;DH = lrrow
- sub dh,al ;calculate total number
- inc dh
- mov dl,parm4_ ;DL = lrcol
- sub dl,cl ;calculate total number
- inc dl
- if _LDATA
- les di,parm5_
- else
- mov bx,ds
- mov es,bx
- mov di,parm5_
- endif
- call disptable+10
- cproce
-
-
-
-
- subttl [CGA (With Retrace) Fast video routines]
- page
- ;/*
- ;** DESCRIPTION
- ;** CGA (with retrace) write string at cursor location. (Does not write
- ;** attributes.
- ;**
- ;** Entry:
- ;** ES:DI -> point to string
- ;** AL -> row number
- ;** CL -> column number
- ;**
- ;** RETURNS
- ;** AX -> number of characters written
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 12:51:42
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgracur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- push ds
- mov dx,CGAGRSTATUS ;dx=CGA status register
- mov ds,ax ;ds points to start of CRT + ROW
- xor si,si ;si=counter
- cgracurloop: mov ah,es:[di] ;get character
- or ah,ah ;terminator?
- jz cgracurex
- CRTWAIT
- mov [bx],ah ;save character in CRT memory
- sti
- inc bx ;move bx past attribute
- inc bx
- inc si ;increment counter
- inc di ;increment source pointer
- jmp short cgracurloop ;repeat
- cgracurex: mov ax,si ;return AX=number of characters
- pop ds ;get DS back
- ret
- cgracur endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (with retrace) write string and attribute at cursor location.
- ;**
- ;** Entry:
- ;** ES:DI -> point to string
- ;** AL -> row number
- ;** CL -> column number
- ;** CH -> Attribute
- ;**
- ;** RETURNS
- ;** AX -> number of characters written
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 13:15:11
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgraaccur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov dx,CGAGRSTATUS ;dx= CGA status register
- xor si,si ;si=counter
- cgraaccurloop: mov ah,es:[di] ;get character
- or ah,ah ;terminator?
- jz cgraaccurex
- CRTWAIT
- mov [bx],ah ;save character in CRT memory
- sti
- inc bx
- CRTWAIT
- mov [bx],ch ;save attribute in CRT memory
- sti
- inc bx
- inc si ;increment counter
- inc di ;increment source pointer
- jmp short cgraaccurloop ;repeat
- cgraaccurex: mov ax,si ;return AX=number of characters
- pop ds ;get DS back
- ret
- cgraaccur endp
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (with retrace) read character and attribute at cursor location.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;**
- ;** RETURNS
- ;** AX -> (AL = character, AH = attribute)
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 13:28:40
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgrrchatatcur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- mov si,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov dx,CGAGRSTATUS
- CRTWAIT
- mov cl,[bx] ;CL=character
- sti
- inc bx
- CRTWAIT
- mov ch,[bx]
- sti
- mov ax,cx ;return value in AX
- mov ds,si ;restore ds
- ret
- cgrrchatatcur endp
-
-
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (with retrace) write character and attribute at cursor location.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DL -> Character
- ;** DH -> Attribute
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 13:05:57
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgrachat proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH=attribute, CL=character
- mov dx,CGAGRSTATUS ;dx= CGA status register
- CRTWAIT
- mov [bx],cl ;save character in CRT memory
- sti
- inc bx
- CRTWAIT
- mov [bx],ch ;save attribute in CRT memory
- sti
- pop ds ;get DS back
- ret
- cgrachat endp
-
-
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (with retrace) get region to buffer.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DH -> number of rows
- ;** DL -> number of columns
- ;** ES:DI -> points to buffer that receives information
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 13:42:01
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgrgetregion proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH =number of rows, CL=number of cols
- mov si,bx ;save starting position in SI
- mov dx,CGAGRSTATUS ;DX=crt status port
- cgrgetrlp2: push cx
- cgrgetrlp1:
- CRTWAIT
- mov al,[bx] ;AL=character
- sti
- mov es:[di],al
- inc di
- inc bx
- CRTWAIT
- mov al,[bx]
- sti
- mov es:[di],al
- inc di
- inc bx
- dec cl ;decrement column count
- jnz cgrgetrlp1 ;do next character
- pop cx ;get orig. cx back
- dec ch ;decrement row count
- jz cgrgetfin ;if zero then done
- add si,160 ;adjust si for next row
- mov bx,si ;set bx for next row
- jmp cgrgetrlp2 ;do next row
-
- cgrgetfin:
-
- pop ds ;restore DS
- ret
- cgrgetregion endp
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (with retrace) put buffer to region.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DH -> number of rows
- ;** DL -> number of columns
- ;** ES:DI -> points to buffer that contains
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 14:15:10
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgrputregion proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH =number of rows, CL=number of cols
- mov si,bx ;save starting position in SI
- mov dx,CGAGRSTATUS ;DX=crt status port
- cgrputrlp2: push cx
- cgrputrlp1:
- mov ah,es:[di]
- CRTWAIT
- mov [bx],ah ;save character
- sti
- inc di
- mov ah,es:[di] ;ah=attribute
- inc bx
- CRTWAIT
- mov [bx],ah
- sti
- inc di
- inc bx
- dec cl ;decrement column count
- jnz cgrputrlp1 ;do next character
- pop cx ;get orig. cx back
- dec ch ;decrement row count
- jz cgrputfin ;if zero then done
- add si,160 ;adjust si for next row
- mov bx,si ;set bx for next row
- jmp cgrputrlp2 ;do next row
-
- cgrputfin:
-
- pop ds ;restore DS
- ret
- cgrputregion endp
-
-
-
-
-
- subttl [CGA (Without Retrace) Fast video routines]
- page
- ;/*
- ;** DESCRIPTION
- ;** CGA write string at cursor location. (Does not write attributes.)
- ;** also does NOT wait on horizontal retrace.
- ;**
- ;** Entry:
- ;** ES:DI -> point to string
- ;** AL -> row number
- ;** CL -> column number
- ;**
- ;** RETURNS
- ;** AX -> number of characters written
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 15:18:17
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgacur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- mov dx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- xor si,si ;si=counter
- cgacurloop: mov al,es:[di] ;get character
- or al,al ;terminator?
- jz cgacurex
- mov [bx],al ;save character in CRT memory
- inc bx ;move bx past attribute
- inc bx
- inc si ;increment counter
- inc di ;increment source pointer
- jmp short cgacurloop ;repeat
- cgacurex: mov ds,dx ;restore ds
- mov ax,si ;return AX=number of characters
- ret
- cgacur endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** CGA write string and attribute at cursor location (without retrace)
- ;**
- ;** Entry:
- ;** ES:DI -> point to string
- ;** AL -> row number
- ;** CL -> column number
- ;** CH -> Attribute
- ;**
- ;** RETURNS
- ;** AX -> number of characters written
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 15:22:13
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgaaaccur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- mov dx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- xor si,si ;si=counter
- cgaaaccurloop: mov al,es:[di] ;get character
- or al,al ;terminator?
- jz cgaaaccurex
- mov [bx],al ;save character in CRT memory
- inc bx
- mov [bx],ch ;save attribute in CRT memory
- inc bx
- inc si ;increment counter
- inc di ;increment source pointer
- jmp short cgaaaccurloop ;repeat
- cgaaaccurex: mov ds,dx ;restore ds
- mov ax,si ;return AX=number of characters
- ret
- cgaaaccur endp
-
- ;/*
- ;** DESCRIPTION
- ;** CGA read character and attribute at cursor location (without retrace)
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;**
- ;** RETURNS
- ;** AX -> (AL = character, AH = attribute)
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 15:18:17
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgrchatatcur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- mov dx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov ax,[bx] ;get character/attribute
- mov ds,dx ;restore ds
- ret
- cgrchatatcur endp
-
- ;/*
- ;** DESCRIPTION
- ;** CGA write character and attribute at cursor location (without retrace)
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DL -> Character
- ;** DH -> Attribute
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 13:05:57
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgawchat proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- mov cx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov [bx],dx ;save character & attribute in CRT memory
- mov ds,cx ;get DS back
- ret
- cgawchat endp
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (without retrace) get region to buffer.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DH -> number of rows
- ;** DL -> number of columns
- ;** ES:DI -> points to buffer that receives information
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 14:24:23
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cggetregion proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH =number of rows, CL=number of cols
- mov si,bx ;save starting position in SI
- cggetrlp2: push cx
- cggetrlp1: mov ax,[bx]
- mov es:[di],ax
- inc di
- inc di
- inc bx
- inc bx
- dec cl ;decrement column count
- jnz cggetrlp1 ;do next character
- pop cx ;get orig. cx back
- dec ch ;decrement row count
- jz cggetfin ;if zero then done
- add si,160 ;adjust si for next row
- mov bx,si ;set bx for next row
- jmp cggetrlp2 ;do next row
- cggetfin: pop ds ;restore DS
- ret
- cggetregion endp
-
- ;/*
- ;** DESCRIPTION
- ;** CGA (without retrace) put buffer to region.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DH -> number of rows
- ;** DL -> number of columns
- ;** ES:DI -> points to buffer that contains
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 14:24:23
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- cgputregion proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,CGAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH =number of rows, CL=number of cols
- mov si,bx ;save starting position in SI
- cgputrlp2: push cx
- cgputrlp1: mov ax,es:[di]
- mov [bx],ax ;save character
- inc di
- inc bx
- inc di
- inc bx
- dec cl ;decrement column count
- jnz cgputrlp1 ;do next character
- pop cx ;get orig. cx back
- dec ch ;decrement row count
- jz cgputfin ;if zero then done
- add si,160 ;adjust si for next row
- mov bx,si ;set bx for next row
- jmp cgputrlp2 ;do next row
- cgputfin: pop ds ;restore DS
- ret
- cgputregion endp
-
-
- subttl [Monochrome Fast video routines]
- page
-
- ;/*
- ;** DESCRIPTION
- ;** monochrome write string at cursor location. (Does not write attributes.
- ;**
- ;** Entry:
- ;** ES:DI -> point to string
- ;** AL -> row number
- ;** CL -> column number
- ;**
- ;** RETURNS
- ;** AX -> number of characters written
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 12:51:42
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- mwsacur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,MDAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- mov dx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- xor si,si ;si=counter
-
- mwsacurloop: mov al,es:[di] ;get character
- or al,al ;terminator?
- jz mwsacurex
- mov [bx],al ;save character in CRT memory
- inc bx ;move bx past attribute
- inc bx
- inc si ;increment counter
- inc di ;increment source pointer
- jmp short mwsacurloop ;repeat
- mwsacurex: mov ds,dx ;restore ds
- mov ax,si ;return AX=number of characters
- ret
- mwsacur endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** monochrome write string and attribute at cursor location.
- ;**
- ;** Entry:
- ;** ES:DI -> point to string
- ;** AL -> row number
- ;** CL -> column number
- ;** CH -> Attribute
- ;**
- ;** RETURNS
- ;** AX -> number of characters written
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 13:15:11
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- mwsaaccur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,MDAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- mov dx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- xor si,si ;si=counter
- mwsaaccurloop: mov al,es:[di] ;get character
- or al,al ;terminator?
- jz mwsaaccurex
- mov [bx],al ;save character in CRT memory
- inc bx
- mov [bx],ch ;save attribute in CRT memory
- inc bx
- inc si ;increment counter
- inc di ;increment source pointer
- jmp short mwsaaccurloop ;repeat
- mwsaaccurex: mov ds,dx ;restore ds
- mov ax,si ;return AX=number of characters
- ret
- mwsaaccur endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** Monochrome read character and attribute at cursor location.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;**
- ;** RETURNS
- ;** AX -> (AL = character, AH = attribute)
- ;**
- ;** AUTHOR
- ;** "" Wed 07-Dec-1988 15:18:17
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- mrchatatcur proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,MDAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- mov dx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov ax,[bx] ;get character/attribute
- mov ds,dx ;restore ds
- ret
- mrchatatcur endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** Monochrome write character and attribute at cursor location.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DL -> Character
- ;** DH -> Attribute
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 13:05:57
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- mwachat proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,MDAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl
- shl bx,1 ;x*2
- mov cx,ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov [bx],dx ;save character & attribute in CRT memory
- mov ds,cx ;get DS back
- ret
- mwachat endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** Monochrome get region to buffer.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DH -> number of rows
- ;** DL -> number of columns
- ;** ES:DI -> points to buffer that receives information
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 14:34:25
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- mdgetregion proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,MDAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH =number of rows, CL=number of cols
- mov si,bx ;save starting position in SI
- mdgetrlp2: push cx
- mdgetrlp1: mov ax,[bx]
- mov es:[di],ax
- inc di
- inc di
- inc bx
- inc bx
- dec cl ;decrement column count
- jnz mdgetrlp1 ;do next character
- pop cx ;get orig. cx back
- dec ch ;decrement row count
- jz mdgetfin ;if zero then done
- add si,160 ;adjust si for next row
- mov bx,si ;set bx for next row
- jmp mdgetrlp2 ;do next row
- mdgetfin: pop ds ;restore DS
- ret
- mdgetregion endp
-
- ;/*
- ;** DESCRIPTION
- ;** Monochrome put buffer to region.
- ;**
- ;** Entry:
- ;** AL -> row number
- ;** CL -> column number
- ;** DH -> number of rows
- ;** DL -> number of columns
- ;** ES:DI -> points to buffer that contains
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 14:34:25
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- mdputregion proc near
- xor ah,ah
- mov bx,ax
- shl ax,1 ;y*2
- shl ax,1 ;y*4
- add ax,bx ;y*5
- shl ax,1 ;y*10
- add ax,MDAREGENSEG ;+starting segment of display
- xor bh,bh
- mov bl,cl ;bl=column number
- shl bx,1 ;x*2
- push ds ;save ds
- mov ds,ax ;ds points to start of CRT + ROW
- mov cx,dx ;CH =number of rows, CL=number of cols
- mov si,bx ;save starting position in SI
- mdputrlp2: push cx
- mdputrlp1: mov ax,es:[di]
- mov [bx],ax ;save character
- inc di
- inc bx
- inc di
- inc bx
- dec cl ;decrement column count
- jnz mdputrlp1 ;do next character
- pop cx ;get orig. cx back
- dec ch ;decrement row count
- jz mdputfin ;if zero then done
- add si,160 ;adjust si for next row
- mov bx,si ;set bx for next row
- jmp mdputrlp2 ;do next row
- mdputfin: pop ds ;restore DS
- ret
- mdputregion endp
-
-
- ;/*
- ;** DESCRIPTION
- ;** sets the low level driver according to value in DX:
- ;**
- ;** DX = 0 = Monochrome driver
- ;** 1 = CGA driver without retrace (ie EGA/VGA)
- ;** 2 = CGA driver with retrace (ie CGA)
- ;**
- ;** RETURNS
- ;** void
- ;**
- ;** AUTHOR
- ;** "" Thu 08-Dec-1988 15:19:22
- ;** Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
- ;**
- ;** MODIFICATIONS
- ;**
- ;*/
- setdriver proc near
- lea di,disptable ;di points to destination
- mov cx,tablesize ;cx = how many words to move
- lea si,montbl ;assume monochrome
- cmp dx,0 ;is it true
- jz setmovit
- lea si,cgatbl ;assume cga/no retrace
- cmp dx,1
- jz setmovit
- lea si,cgartbl
- setmovit: mov ax,[si]
- mov [di],ax
- add di,2
- add si,2
- loop setmovit
- ret
- setdriver endp
-
-
- autosetup proc near
- push ax
- push bx
- push cx
- push dx
- push es
- push di
- mov ah,GETCURVIDMODE ;get current video mode to AL
- int BIOSVIDEO
- xor dx,dx ;assume Monochrome
- cmp al,7 ;check assumption
- jz autosetit
- inc dx ;assume we won't need retrace
- mov ax,01a00h ;Read display combination code
- push dx
- int BIOSVIDEO
- pop dx
- cmp al,01ah ;AL=0x1a if VGA
- jz autosetit
- mov ah,12h
- mov bl,10h ;check for EGA
- push dx
- int BIOSVIDEO
- pop dx
- cmp bl,10h ;bl!=0x10 if EGA
- jnz autosetit
- mov dx,2 ;else assume no ega/vga and
- ;do retrace checking
- autosetit: call setdriver
- pop di
- pop es
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- autosetup endp
-
-
- trapstub1 proc near
- call autosetup
- jmp disptable
- trapstub1 endp
-
- trapstub2 proc near
- call autosetup
- jmp disptable+2
- trapstub2 endp
-
- trapstub3 proc near
- call autosetup
- jmp disptable+4
- trapstub3 endp
-
- trapstub4 proc near
- call autosetup
- jmp disptable+6
- trapstub4 endp
-
- trapstub5 proc near
- call autosetup
- jmp disptable+8
- trapstub5 endp
-
- trapstub6 proc near
- call autosetup
- jmp disptable+10
- trapstub6 endp
-
- endps
- end
-