home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / video / viddemo.asm next >
Assembly Source File  |  1988-11-09  |  16KB  |  567 lines

  1. TITLE 'Video Demo Program'
  2.  
  3. ;
  4. ; This is a short program to demonstrate the VIDEO.ASM TASM Assembler module.
  5. ; You may use VIDDEMO.MAK to automate the assembly of this program.  It is
  6. ; only designed to work in a 80x25 mode. (Video Modes 2, 3, & 7)
  7. ;
  8. ; All lines that make use of VIDEO.ASM routines or VIDEO.INC equates have
  9. ; been marked with ($) so you can scan through this file and see how to
  10. ; use the routine fairly easily.
  11. ;
  12. ; -- Dave
  13. ;
  14.  
  15. IDEAL            ; Use TASM's ideal mode
  16.  
  17. DOSSEG            ; Use DOS segment ordering
  18.  
  19. MODEL SMALL        ; Small memory model
  20.  
  21. INCLUDE 'VIDEO.INC'    ; Global declarations for VIDEO.ASM
  22.  
  23. ; ------
  24. ; Macros
  25. ; ------
  26.  
  27. MACRO    Pause    Seconds
  28.     LOCAL PauseLoop, KeyFound
  29.     ;
  30.     ; This macro will pause until a key is pressed.
  31.     ;
  32.     ; Uses:
  33.     ;    KeyPressed, ClearKBD
  34.     ;
  35.         push    ax        ; Save regs
  36.         push    cx
  37.     IFNB <Seconds>
  38.         mov    cx, (Seconds*18)+(Seconds/5)    ; 5 is recip of .2!
  39.     ELSE
  40.         mov    cx, 91        ; 5 Seconds
  41.     ENDIF
  42.     PauseLoop:
  43.         call    KeyPressed    ; check for pressed key
  44.         or    al, al        ; Sets the zero flag if null
  45.         jnz    KeyFound    ; loop until key is pressed
  46.         call    Delay        ; Delay for .055 of a second
  47.         loop    PauseLoop
  48.     KeyFound:
  49.         call    ClearKBD    ; Clear the key
  50.         pop    cx        ; Restore registers
  51.         pop    ax
  52. ENDM
  53.  
  54. ; ---------------
  55. ; Program Equates
  56. ; ---------------
  57.  
  58.     Version        EQU     '1.0'
  59.     Date        EQU     '11/9/88'
  60.  
  61.     MaxRows        EQU    25        ; Maximum rows
  62.     CenterRow    EQU    (MaxRows/2)    ; Center row
  63.     MaxCols        EQU    80        ; Maximum columns
  64.     CenterCol    EQU    (MaxCols/2)    ; Center column
  65.     FillRows    EQU    5        ; Number of rows for fill demo
  66.     FillCols    EQU    20        ; Number of cols for fill demo
  67.  
  68. ; -------------
  69. ; Stack Segment
  70. ; -------------
  71.  
  72. STACK    7FFFh        ; 32k Stack (Much more than enough)
  73.  
  74. ; -------------
  75. ; Data Segement
  76. ; -------------
  77.  
  78. ; NOTE: Program relies on data being in current order.  Do not reorder, delete
  79. ;    or insert new data into the list.  Data can be appended to this segment
  80. ;    definition.
  81.  
  82. DATASEG
  83.  
  84.     Title1        DB 'VIDEO.ASM - Direct Screen Writing Routines', 0
  85.     LABEL        T1End BYTE
  86.     T1Len        EQU    (T1End-Title1-1)
  87.  
  88.     Title2        DB 'Author: Dave Bennett / CompuServe 74635,1671', 0
  89.     LABEL        T2End BYTE
  90.     T2Len        EQU    (T2End-Title2-1)
  91.  
  92.     Title3        DB 'Version ', Version, ' - Date: ', Date, 0
  93.     LABEL        T3End BYTE
  94.     T3Len        EQU    (T3End-Title3-1)
  95.  
  96.     Title4        DB 'Features:', 0
  97.     Title5        DB ' - Video mode detection', 0
  98.     Title6        DB ' - Monochrome/CGA/EGA support', 0
  99.     Title7        DB ' - Snow suppression', 0
  100.     Title8        DB ' - Direct character & string writing', 0
  101.     Title9        DB ' - Screen saving & restoring', 0
  102.     Title10        DB ' - Area fills (character, attribute, and both)', 0
  103.     Title11        DB ' - Cursor on & off control', 0
  104.     Title12        DB ' - All commands w/ or w/o attribute changes',0
  105.  
  106.     Msg        DB 'Direct Screen Writing is Fast!!!', 0
  107.     LABEL        MsgEnd BYTE
  108.     MsgLen        EQU    (MsgEnd-Msg-1)
  109.  
  110.     SaveMsg        DB ' Screen has been saved... ', 0
  111.     LABEL        SMsgEnd BYTE
  112.     SMsgLen        EQU    (SMsgEnd-SaveMsg-1)
  113.  
  114.     CharMsg1    DB ' Character ', 0
  115.     CharMsg2    DB ' Writing!! ', 0
  116.  
  117.     Wheel        DB 179, '/-\', 179, '/-\'  ; Wheel Chars
  118.     LABEL        WheelEnd BYTE
  119.     MaxWheel    EQU    (WheelEnd-Wheel-1)    ; Maximum Wheel offset
  120.  
  121.     FillMsg1    DB '-AREA-', 0
  122.     FillMsg2    DB '-FILL-', 0
  123.  
  124.     RestoreMsg    DB ' Here''s your saved screen image! ', 0
  125.     LABEL        RMsgEnd BYTE
  126.     RMsgLen        EQU    (RMsgEnd - RestoreMsg - 1)
  127.  
  128.     VidModErr    DB 'Invalid Video Mode!', 0Dh, 0Ah, '$'
  129.  
  130.     RDir        DB 0            ; Row Direction
  131.     CDir        DB 0            ; Col Direction
  132.  
  133. ; --------------------------
  134. ; Uninitialized Data Segment
  135. ; --------------------------
  136.  
  137. UDATASEG
  138.  
  139.     LowTick        DW (?)        ; Tick holder for Delay routine
  140.     SaveScr        DB 4000 dup (?) ; Screen Save Area
  141.  
  142. ; ------------
  143. ; Code Segment
  144. ; ------------
  145.  
  146. CODESEG
  147.  
  148.     mov    ax, @data    ; Set the
  149.     mov    ds, ax        ;   Data segment
  150.     call    GetVideoMode    ; Get vid mode data.  MUST BE CALLED FIRST ($)
  151.  
  152.     cmp    [VideoMode], BW80    ; ($)
  153.     je    VideoMode_OK        ; Video Mode BW80 is ok
  154.     cmp    [VideoMode], CO80    ; ($)
  155.     je    VideoMode_OK        ; Video Mode CO80 is ok
  156.     cmp    [VideoMode], Mono    ; ($)
  157.     je    VideoMode_OK        ; Monochrome is ok
  158.  
  159.     mov    dx, OFFSET VidModErr    ; All other modes are unacceptable
  160.     mov    ah, 09            ; DOS print string func
  161.     int    21h            ; Call DOS
  162.     jmp    ErrExit            ; Exit the program
  163.  
  164. VideoMode_OK:
  165. ;    mov    [SnowCheck], 0  ; No Snow Checking! ($)
  166.     call    CursorOff    ; Turn the cursor off ($)
  167.  
  168. ; ------------
  169. ; Title Screen
  170. ; ------------
  171.  
  172.     call    ClrScr            ; Clear the screen
  173.     mov    si, (OFFSET Title1)    ; First Message
  174.     mov    bh, Normal        ; Gray on Black ($)
  175.     mov    ah, 1            ; Start at top row
  176.     mov    al, (CenterCol-(T1Len/2))    ; Center the message
  177.     call    DWriteStr        ; Write without attribute ($)
  178.     inc    ah            ; Double
  179.     inc    ah            ;   Space
  180.     mov    al, (CenterCol-(T2Len/2))    ; Center Title Msg 2
  181.  
  182.     ; NOTE: SI Already points to Title2 (See DATASEG)
  183.  
  184.     call    DWriteStr        ; Write the string to the scr ($)
  185.     inc    ah            ; Single Space
  186.     mov    al, (CenterCol-(T3Len/2))    ; Center title Msg 3
  187.     call    DWriteStr        ; Write string to scr ($)
  188.     inc    ah            ; Double
  189.     inc    ah            ;   Space
  190.     mov    al, (CenterCol-(T1Len/2)) ; Align with first row
  191.     call    DWriteStr        ; Write str to scr ($)
  192.     inc    ah            ; Double
  193.     inc    ah            ;   Space
  194.     inc    al            ; Indent
  195.     inc    al            ;   2 Spaces
  196.     mov    cx, 8            ; 8 Feature lines
  197. TS_Features:
  198.     call    DWriteStr        ; Write a feature ($)
  199.     inc    ah            ; Double
  200.     inc    ah            ;   Space
  201.     loop    TS_Features        ; Loop for all feature lines
  202.  
  203.     Pause    <10>            ; Wait for a pressed key (10 seconds)
  204.  
  205. ;---------------
  206. ; DFillAttr Demo
  207. ; --------------
  208.  
  209.     cmp    [VideoMode], Mono    ; This code is'nt suited for mono ($)
  210.     je    DWN_Begin        ; So goto DWriteStNA demo if mono
  211.  
  212.     mov    ax, 0101h        ; First row/First column
  213.     mov    bh, MaxRows        ; All rows
  214.     mov    bl, MaxCols        ; All columns
  215.     mov    dh, 1            ; Initialize attribute
  216.  
  217. DFA_Top:
  218.     and    dh, 00001111b        ; Clear all but foreground
  219.     cmp    dh, 0            ; Check for no attribute
  220.     jne    DFA_Fill        ; Go ahead if attribute
  221.     inc    dh            ; Make sure theres and attr
  222. DFA_Fill:
  223.     call    DFillAttr        ; Fill screen with attribute ($)
  224.     call    Delay            ; Delay for .055 of a second
  225.     inc    dh            ; Next Attribture
  226.     push    ax            ; Store row/col info
  227.     call    KeyPressed        ; Check for a key
  228.     or    al, al            ; Sets zero flag if no char
  229.     pop    ax            ; Restore row/col info
  230.     jz    DFA_Top            ; If no key the loop
  231.     call    ClearKBD        ; Clear key(s) from buffer
  232.  
  233. ;-----------------
  234. ; DWriteStrNA Demo
  235. ; ----------------
  236.  
  237. DWN_Begin:
  238.     call    ClrScr        ; Clear the screen
  239.     mov    ax, 0        ; Initialize row/col
  240.     mov    bh, Normal    ; Initialize Attribute ($)
  241.  
  242.  DWN_MoveMsg:
  243.     mov    si, OFFSET Msg  ; Point to Msg
  244.     test    [RDir], 1    ; Check the direction
  245.     jz    DWN_RInc    ; If direction is right then goto RInc
  246.     dec    ah        ; Decrement the row
  247.     cmp    ah, 1        ; Check to see if row eq 1
  248.     jne    DWN_CheckCol    ;   If not then check columns
  249.     inc    [RDir]        ; Change the direction
  250.     jmp    DWN_CheckCol    ; Check columns
  251. DWN_RInc:
  252.     inc    ah        ; Increment the row
  253.     cmp    ah, MaxRows    ; Check to see if row eq MaxRows
  254.     jne    DWN_CheckCol    ;   If not then check columns
  255.     inc    [RDir]        ; Change the row-wise direction
  256. DWN_CheckCol:
  257.     test    [CDir], 1    ; Check column wise direction
  258.     jz    DWN_CInc    ; If direction is down then goto CInt
  259.     dec    al        ; Decrement the row (Go up)
  260.     cmp    al, 1        ; Check to see if this is column one
  261.     jne    DWN_WriteIt    ;   If not then check attr
  262.     inc    [CDir]        ; Change the direction
  263.     jmp    DWN_WriteIt    ; Check the attr
  264. DWN_CInc:
  265.     inc    al        ; Increment the row
  266.     cmp    al, (MaxCols-MsgLen) ; Check to see if row eq MaxCols
  267.     jne    DWN_WriteIt    ;        If not then check attr
  268.     inc    [CDir]        ; Change the column-wise direction
  269. DWN_WriteIt:
  270.     call    DWriteStrNA    ; Write the str on scr w/o attr change ($)
  271.     push    ax        ; Store ax reg
  272.     call    KeyPressed    ; Check to see if a key has been pressed
  273.     or    al, al        ; Does AL eq zero?
  274.     pop    ax        ; Restore registers
  275.     jz    DWN_MoveMsg    ; if Yes then Redisplay message
  276.     call    ClearKBD    ; Clear the keyboard
  277.  
  278. ; --------------
  279. ; DWriteStr Demo
  280. ; --------------
  281.  
  282.     cmp    [VideoMode], Mono    ; Demo not well suited for mono ($)
  283.     je    STM_Begin        ; so goto StoreToMem demo if mono
  284.  
  285. DW_MoveMsg:
  286.     mov    si, OFFSET Msg  ; Point to Msg
  287.     test    [RDir], 1    ; Check the direction
  288.     jz    DW_RInc        ; If direction is right then goto RInc
  289.     dec    ah        ; Decrement the row
  290.     cmp    ah, 1        ; Check to see if row eq 1
  291.     jne    DW_CheckCol    ;   If not then check columns
  292.     inc    [RDir]        ; Change the direction
  293.     jmp    DW_CheckCol    ; Check columns
  294. DW_RInc:
  295.     inc    ah        ; Increment the row
  296.     cmp    ah, MaxRows    ; Check to see if row eq MaxRows
  297.     jne    DW_CheckCol    ;   If not then check columns
  298.     inc    [RDir]        ; Change the row-wise direction
  299. DW_CheckCol:
  300.     test    [CDir], 1    ; Check column wise direction
  301.     jz    DW_CInc        ; If direction is down then goto CInt
  302.     dec    al        ; Decrement the row (Go up)
  303.     cmp    al, 1        ; Check to see if this is column one
  304.     jne    DW_CheckAttr    ;   If not then check attr
  305.     inc    [CDir]        ; Change the direction
  306.     jmp    DW_CheckAttr    ; Check the attr
  307. DW_CInc:
  308.     inc    al        ; Increment the row
  309.     cmp    al, (MaxCols - MsgLen) ; Check to see if row eq MaxCols
  310.     jne    DW_CheckAttr     ;         If not then check attr
  311.     inc    [CDir]        ; Change the column-wise direction
  312. DW_CheckAttr:
  313.     inc    bh        ; Increment the attribute
  314.     test    bh, Blink    ; Test to see if blink bit is on
  315.     jz    DW_WriteIt    ; If not then skip to WriteIt
  316.     mov    bh, 1        ; Set BH eq 1
  317. DW_WriteIt:
  318.     call    DWriteStr    ; Write the string on the screen ($)
  319.     push    ax        ; Store ax reg
  320.     call    KeyPressed    ; Check to see if a key has been pressed
  321.     or    al, al        ; Does AL eq zero?
  322.     pop    ax        ; Restore registers
  323.     jz    DW_MoveMsg    ; if Yes then Redisplay message
  324.     call    ClearKBD    ; Clear the keyboard
  325.  
  326. ; ----------------------------------------------------------
  327. ; Move current screen image to save area (StoreToMem - Demo)
  328. ; ----------------------------------------------------------
  329.  
  330. STM_Begin:
  331.     mov    ax, @data    ; Place data segment into AX
  332.     mov    es, ax        ; segment for saved image area
  333.  
  334.     ; This might be a good place for some stack checking code. (hint hint)
  335.  
  336.     mov    di, OFFSET SaveScr    ; offset to saved image area (See Stack)
  337.     mov    ax, 0101h    ; Row 1 / Col 1
  338.     mov    bh, MaxRows    ; capture all rows &
  339.     mov    bl, MaxCols    ;      all columns
  340.     call    StoreToMem    ; Save the screen to memory ($)
  341.  
  342.     ; Note: SI Already points to SaveMsg (See DATASEG)
  343.  
  344.     mov    ah, CenterRow    ; Center of screen
  345.     mov    al, (CenterCol-(SMsgLen/2)) ; Center the message
  346.     mov    bh, Reverse+Blink ; Reverse attr (Black on White) & Blink ($)
  347.     call    DWriteStr    ; Display the string! ($)
  348.  
  349.     Pause    <10>        ; Macro to pause for 10 seconds
  350.  
  351. ; -------------
  352. ; DWriteCH Demo
  353. ; -------------
  354.  
  355.     CharMsg1Col    =    24
  356.     CharMsg2Col    =    48
  357.     RowStart    =    1    ; Row to start in
  358.     ColStart    =    6    ; Column to start in
  359.  
  360.     ; Note: SI already points to CharMsg1 (See DATASEG)
  361.  
  362.     call    ClrScr            ; Clear the screen
  363.     mov    ah, CenterRow        ; Middle row of screen
  364.     mov    bh, (Brown*10h+Blue)    ; Blue on Brown (Also ul mono) ($)
  365.     mov    al, CharMsg1Col        ; Point to column for first msg
  366.     call    DWriteStr        ; Write the first string ($)
  367.  
  368.     ; Note: SI now points to CharMsg2 (See DATASEG)
  369.  
  370.     mov    al, CharMsg2Col        ; Column for second msg
  371.     call    DWriteStr        ; Write the second string ($)
  372.  
  373.     mov    ah, RowStart        ; Start row
  374.     mov    al, ColStart        ; Start column
  375.     mov    bh, White        ; White on black ($)
  376.     mov    cx, 1            ; One Character
  377.     mov    si, OFFSET Wheel    ; Offset of wheel characters
  378. DWC_Top:
  379.     mov    bl, [Byte Ptr si]    ; Load character into bl
  380. DWC_WriteIt:
  381.     call    DWriteCH        ; Write the character ($)
  382.     inc    ah            ; Next row
  383.     inc    al            ; Next column
  384.     cmp    ah, MaxRows        ; Check AH against Maximum rows
  385.     jle    DWC_CheckCol        ; If less then then Check columns
  386.     mov    ah, 1            ; Reset row
  387. DWC_CheckCol:
  388.     cmp    al, MaxCols        ; Check AL agains max cols
  389.     jle    DWC_WriteIt        ; If less than max cols then write
  390.     mov    ah, RowStart        ; Reset row
  391.     mov    al, ColStart        ; Reset col
  392. ;    call    Delay            ; Wait 1 / 18.2 of a second
  393.     inc    si            ; Point to next character in wheel
  394.     cmp    si, (OFFSET Wheel + MaxWheel)    ; Maximum offset of Wheel
  395.     jle    DWC_Top
  396. DWC_InKey:
  397.     push    ax        ; Store row/col info
  398.     call    KeyPressed    ; Check to see if a key has been pressed
  399.     or    al, al        ; Sets zero flag if al eq 0
  400.     pop    ax        ; Restore row/col info
  401.     jnz    DWC_End        ; If a key has been press (not null) then end
  402.     mov    si, OFFSET Wheel ; Set SI to offset zero of wheel
  403.     jmp    DWC_Top        ; If zero flag set then loop
  404. DWC_End:
  405.     call    ClearKBD    ; Clear the keyboard
  406.  
  407. ; ------------
  408. ; DFillCH Demo
  409. ; ------------
  410.  
  411.     FillMsgCol    =    36    ; Fill Msgs in column 25
  412.     FillMsg1Row    =    3    ; Message one in row 3
  413.     FillMsg2Row    =    20    ; Message two in row 20
  414.     FillWid        =    15    ; Width of fill
  415.     FillHt        =    4    ; Fill Height
  416.     RInc        =    2    ; Row Increment
  417.     CInc        =    7    ; Column Increment
  418.  
  419.     call    ClrScr        ; Clear the screen
  420.     mov    ah, FillMsg1Row ; Row for first msg
  421.     mov    al, FillMsgCol  ; Col for the msg
  422.     mov    bh, LightBlue+Blink ; LightBlue on Black w/ Blink (ul mono) ($)
  423.  
  424.     ; NOTE: SI Points to first msg already
  425.  
  426.     call    DWriteStr    ; Write the first message (SI points to 2nd) ($)
  427.     mov    ah, FillMsg2Row ; Row for the second message
  428.     call    DWriteStr    ; Write the second message to the screen ($)
  429.  
  430.     mov    ax, 0101h    ; Top row / Left Col
  431.     mov    bh, FillHt    ; Number of rows
  432.     mov    bl, FillWid    ; Number of columns
  433.     mov    dh, 00h        ; Initialize attr
  434.  
  435. DFCH_Top:
  436.     inc    dh        ; Increment dh
  437.     mov    dl, dh        ; Move attribute to character
  438.     call    DFillCh        ; Do the fill ($)
  439.     add    ah, RInc    ; Increment rows
  440.     add    al, CInc    ; Increment columns
  441.     cmp    ah, (MaxRows-FillHt)    ; compare ah to max rows - fill ht
  442.     jle    DFCH_CheckCol    ; If less than or equal to then check columns
  443.     jmp    DFCH_SecPart    ; Goto the second part
  444. DFCH_CheckCol:
  445.     cmp    al, (MaxCols-FillWid)    ; compare al to max cols - fill width
  446.     jle    DFCH_Top        ; Jump to the top if in bounds
  447. DFCH_SecPart:
  448.     mov    dh, 0        ; Initialize the attribute
  449.     mov    ah, 1        ; Top Row
  450.     mov    al, (MaxCols-FillWid) ; Right Side
  451. DFCH_Top2:
  452.     inc    dh        ; Increment dh
  453.     mov    dl, dh        ; Move attribute to character
  454.     call    DFillCh        ; Do the fill
  455.     add    ah, RInc    ; Increment rows
  456.     sub    al, CInc     ; Decrement columns
  457.     cmp    ah, (MaxRows-FillHt)    ; compare ah to max rows - fill ht
  458.     jle    DFCH_CheckCol2  ; If less than or equal to then check columns
  459.     jmp    DFCH_Pause    ; Goto the pause routine
  460. DFCH_CheckCol2:
  461.     cmp    al, 1        ; compare al to 1 (First column)
  462.     jg    DFCH_Top2    ; Jump to the top if in bounds
  463. DFCH_Pause:
  464.     Pause    <10>        ; Macro to pause 10 seconds
  465.  
  466. ; ---------------
  467. ; StoreToScr Demo
  468. ; ---------------
  469.  
  470.     mov    ax, 0101h    ; First row & col
  471.     mov    bh, MaxRows    ; All rows
  472.     mov    bl, MaxCols    ; All columns
  473.     mov    si, OFFSET SaveScr ; Point to area where screen was saved
  474.     call    StoreToScr    ; Restore the saved screen ($)
  475.  
  476.     mov    si, OFFSET RestoreMsg ; Point to restore screen message
  477.     mov    ah, CenterRow    ; Center of screen
  478.     mov    al, (CenterCol-(RMsgLen/2)) ; Center the message
  479.     mov    bh, Reverse+Blink ; Reverse attr (Black on White) & Blink ($)
  480.     call    DWriteStr    ; Display the string! ($)
  481.  
  482.     Pause    <10>         ; Macro - Pause for 10 secs or until key press
  483.  
  484. Exit:
  485.     call    ClrScr        ; Clean up the display
  486. ErrExit:
  487.     call    CursorOn    ; Turn the cursor on ($)
  488.     mov    ah, 4Ch        ; DOS exit function
  489.     int    21h        ; Call DOS to exit
  490.  
  491. ; -------------------
  492. ; Programs Procedures
  493. ; -------------------
  494.  
  495.     PROC ClrScr
  496.     ;
  497.     ; This procedure Clears the screen using VIDEO.ASM
  498.     ;
  499.         push    ax        ; Store registers
  500.         push    bx
  501.         push    dx
  502.         mov    ax, 0101h    ; First row & col
  503.         mov    bh, MaxRows    ; All Rows
  504.         mov    bl, MaxCols    ; All Columns
  505.         mov    dh, Normal    ; Attr = Gray on Black ($)
  506.         mov    dl, ' '        ; Fill scr with spaces
  507.         call    DFillCH        ; Do it! ($)
  508.         pop    dx        ; Restore registers
  509.         pop    bx
  510.         pop    ax
  511.         ret
  512.  
  513.     ENDP ClrScr
  514.  
  515.     PROC KeyPressed
  516.     ;
  517.     ; This procedure uses DOS to check if a key has been pressed.
  518.     ;
  519.     ; Output
  520.     ;    AL = FFh/0  Yes/No
  521.     ; Modifies
  522.     ;    AX
  523.     ;
  524.         mov    ah, 0Bh        ; DOS func 0Bh (Check for pressed key)
  525.         int    21h        ; Call DOS
  526.         xor    ah, ah        ; Clear AH reg
  527.         ret
  528.  
  529.     ENDP KeyPressed
  530.  
  531.     PROC ClearKBD
  532.     ;
  533.     ; This procedure uses DOS to clear the keyboard buffer.
  534.     ;
  535.         push    ax        ; Store AX reg
  536.         mov    ax, 0C00h    ; Dos func 0Ch = Clear KBD
  537.         int    21h        ; Call DOS
  538.         pop    ax        ; Restore AX
  539.         ret
  540.  
  541.     ENDP ClearKBD
  542.  
  543.     PROC Delay
  544.     ;
  545.     ; This procedure delays the CPU for about 1 timer tick or 1/18.2 of
  546.     ; of a second.
  547.     ;
  548.         push    ax
  549.         push    cx
  550.         push    dx
  551.         mov    ah,0        ; INT 1A GetTime function
  552.         int    01ah        ; Call timer interrupt
  553.         mov    [LowTick], dx    ; DX returns low timer tick value
  554.     DelayLoop:
  555.         mov    ah, 0        ; INT 1A GetTime function
  556.         int    01ah        ; Call timer interrupt
  557.         cmp    dx, [LowTick]    ; Compare current val to first
  558.         je    DelayLoop    ; If still the same then loop
  559.         pop    dx
  560.         pop    cx
  561.         pop    ax
  562.         ret
  563.  
  564.     ENDP Delay
  565.  
  566. END ; Of VidDemo.ASM
  567.