home *** CD-ROM | disk | FTP | other *** search
- ;=============================================================================
- ; Low Level Video Routines
- ;
- ; These are routines to display text and control the screen. All code is BIOS
- ; compatible. All registers are preserved except those used to return
- ; parameters. All parameters are passed through registers. VIDEO_INIT must be
- ; called before the other routines. It is assumed that DS = ES = CS.
-
- ;================================================
- ; Global data.
-
- Video_Mode Db ? ;present mode
- Video_Page Db ? ;active page
- Video_Cols Db ? ;screen columns
-
- ;================================================
- ; Execute the video interrupt 10H. Preserves the
- ; extraneous registers not explicitly preserved
- ; by the interrupt.
- ;
- ; Passes all registers back and forth
- ; tranparently, except for DI, SI, and BP.
-
- Video_Int10 Proc Near
- Push Di
- Push Si
- Push Bp
- Int 10h ;call video
- Pop Bp
- Pop Si
- Pop Di
- Ret
- Endp ;Video_Int10
-
- ;================================================
- ; Initialize the video parameters.
-
- Video_Init Proc Near
- Push Ax
- Push Bx
- Mov Ah, 15 ;function
- Call Video_Int10 ;interrupt 10H
- Mov Video_Mode, Al ;save mode
- Mov Video_Cols, Ah ;save columns
- Mov Video_Page, Bh ;save page
- Pop Bx
- Pop Ax
- Ret
- Endp ;Video_Init
-
- ;================================================
- ; Read the cursor position.
- ;
- ; Out: DH= row; DL= column.
-
- Video_Cget Proc Near
- Push Ax
- Push Bx
- Push Cx
- Mov Ah, 3 ;function
- Mov Bh, Video_Page ;page
- Call Video_Int10 ;interrupt 10H
- Pop Cx
- Pop Bx
- Pop Ax
- Ret
- Endp ;Video_Cget
-
- ;================================================
- ; Set the cursor position.
- ;
- ; In: DH= row; DL= column.
-
- Video_Cset Proc Near
- Push Ax
- Push Bx
- Mov Ah, 2 ;function
- Mov Bh, Video_Page ;page
- Call Video_Int10 ;interrupt 10H
- Pop Bx
- Pop Ax
- Ret
- Endp ;Video_Cset
-
- ;================================================
- ; Advance the cursor some number of columns. Does
- ; NOT wrap around. When the last column is
- ; reached, the cursor is not moved any further.
- ;
- ; In: CL= columns to advance.
-
- Video_Cadv Proc Near
- Push Ax
- Push Cx
- Push Dx
-
- Call Video_Cget ;get cursor location
- Mov Al, Video_Cols ;get the screen columns
- Dec Al ;last screen column
- Cmp Al, Dl ;check if at end
- Jae Vidcad1
- Sub Al, Dl ;get available columns for move
- Cmp Cl, Al ;check if past end
- Jbe Vidcad2
- Mov Cl, Al ;set to maximum
-
- Vidcad1
- Add Dl, Cl ;new column
- Call Video_Cset ;move to new location
-
- Vidcad2
- Pop Dx
- Pop Cx
- Pop Ax
- Ret
- Endp ;Video_Cadv
-
- ;================================================
- ; Write multiple characters with an attribute to
- ; the present cursor location.
- ;
- ; In: AL= character; BL= attribute; CX= count.
-
- Video_Wchrs Proc Near
- Or Cx, Cx ;check if none
- Jz Vidwch1
-
- Push Ax
- Push Bx
- Mov Ah, 9 ;function
- Mov Bh, Video_Page ;page
- Call Video_Int10 ;interrupt 10H
- Call Video_Cadv ;advance cursor
- Pop Bx
- Pop Ax
-
- Vidwch1
- Ret
- Endp ;Video_Wchrs
-
- ;================================================
- ; Write a single character and attribute to the
- ; present cursor location.
- ;
- ; In: AL= character; BL= attribute.
-
- Video_Wchr Proc Near
- Push Cx
- Mov Cx, 1 ;count
- Call Video_Wchrs ;write character
- Pop Cx
- Ret
- Endp ;Video_Wchr
-
- ;================================================
- ; Scroll a portion of the screen up.
- ;
- ; In: DH= upper left hand row; DL= upper left
- ; hand column; CH= lower left hand row; CL= lower
- ; left hand column; AL= lines to scroll (0 means
- ; clear instead of scroll); BL= attribute to use.
-
- Video_Spag Proc Near
- Push Ax
- Mov Ah, 6 ;function
- Call Video_Int10 ;interrupt 10H
- Pop Ax
- Ret
- Endp ;Video_Spag
-
- ;================================================
- ; Clear a portion of the screen.
- ;
- ; In: DH= upper left hand row; DL= upper left
- ; hand column; CH= lower left hand row; CL= lower
- ; left hand column; BL= attribute to use.
-
- Video_Cpag Proc Near
- Push Ax
- Sub Al, Al ;scroll lines zero
- Call Video_Spag ;clear screen
- Pop Ax
- Ret
- Endp ;Video_Cpag
-